blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
5
146
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
7
license_type
stringclasses
2 values
repo_name
stringlengths
6
79
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
4 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.07k
426M
star_events_count
int64
0
27
fork_events_count
int64
0
12
gha_license_id
stringclasses
3 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
6 values
src_encoding
stringclasses
26 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
1 class
length_bytes
int64
20
6.28M
extension
stringclasses
20 values
content
stringlengths
20
6.28M
authors
sequencelengths
1
16
author_lines
sequencelengths
1
16
ad7fbed2d9683447245d454caa474fbbba35c84a
823afcea9ac0705f6262ccffdff65d687822fe93
/RayTracing/Src/Image.h
73837f1b18cc8c95c2a0c463378070ccf2cd0aa5
[]
no_license
shourav9884/raytracing99999
02b405759edf7eb5021496f87af8fa8157e972be
19c5e3a236dc1356f6b4ec38efcc05827acb9e04
refs/heads/master
2016-09-10T03:30:54.820034
2006-10-15T21:49:19
2006-10-15T21:49:19
null
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
1,450
h
#pragma once //#include <string> //using namespace std; #include "ColorRGBub.h" #include <cstdio> using namespace std; #include "IL/IL.h" class Image { // Membros estaticos para o DevIL private: static bool DevILInitialized; static ILuint DevILImageName; private: ILubyte *imageData; int width; int height; int bytesPerPixel; int format; int type; public: Image( void ); Image( const char *aFileName ); ~Image( void ); inline int getWidth() const { return width; } inline int getHeight() const { return height; } inline int getBytesPerPixel() const { return bytesPerPixel; } inline ILubyte *getImageData() { return this->imageData; } inline ColorRGBub getPixel( int xPosition, int yPosition ) { ColorRGBub result(0,0,0); if( xPosition < this->width && yPosition < this->height ) { // Se a imagem foi inicializa if(this->imageData != NULL) { const int deslocX = xPosition*this->bytesPerPixel; const int deslocY = yPosition*this->width*this->bytesPerPixel; // Lembrar que BMP além de serem escritos de cabeca para baixo, eles tambem // possuem um pixel format diferente (BGR ao inves de RGB) result.r = this->imageData[deslocX + deslocY + 0]; result.g = this->imageData[deslocX + deslocY + 1]; result.b = this->imageData[deslocX + deslocY + 2]; } } return result; } };
[ "saulopessoa@34b68867-b01b-0410-ab61-0f167d00cb52" ]
[ [ [ 1, 75 ] ] ]
ee0765a3b1caa4c828d96e7dd529c8157f5dd238
823afcea9ac0705f6262ccffdff65d687822fe93
/RayTracing/Src/Texture.cpp
e9bdba4a5fe4a173668264dd371c2b6df3d21a0f
[]
no_license
shourav9884/raytracing99999
02b405759edf7eb5021496f87af8fa8157e972be
19c5e3a236dc1356f6b4ec38efcc05827acb9e04
refs/heads/master
2016-09-10T03:30:54.820034
2006-10-15T21:49:19
2006-10-15T21:49:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
205
cpp
#include "Texture.h" Texture::Texture( const char *aFileName, InterpolationType aInterpolationType ) : image( aFileName ), interpolationType(aInterpolationType) { } Texture::~Texture(void) { }
[ "saulopessoa@34b68867-b01b-0410-ab61-0f167d00cb52" ]
[ [ [ 1, 10 ] ] ]
3496c3bbea5798e69812e6b7363ba7f9e6cd4a5d
24bc1634133f5899f7db33e5d9692ba70940b122
/src/ammo/input/input_sys.hpp
a622d965de35d2b83c39e1c346cece4598209dc6
[]
no_license
deft-code/ammo
9a9cd9bd5fb75ac1b077ad748617613959dbb7c9
fe4139187dd1d371515a2d171996f81097652e99
refs/heads/master
2016-09-05T08:48:51.786465
2009-10-09T05:49:00
2009-10-09T05:49:00
32,252,326
0
0
null
null
null
null
UTF-8
C++
false
false
688
hpp
#ifndef AMMO_INPUT_INPUT_SYS_HPP #define AMMO_INPUT_INPUT_SYS_HPP #include <map> #include <string> #include <vector> #include <boost/shared_ptr.hpp> #include "SFML/Window/Input.hpp" #include "ammo/enums/playeractions.hpp" #include "ammo/input/input_impl.hpp" #include "RakNetTypes.h" namespace ammo { class InputAction; class Input; class InputSys { public: void AddInputMap(SystemAddress owner, std::vector<InputAction*> inputs); Input GetInput(SystemAddress owner); void Update(const sf::Input& input, float dt); protected: std::map<SystemAddress, InputImpl> _impls; }; } #endif
[ "delldude@d8b90d80-bb63-11dd-bed2-db724ec49875", "PhillipSpiess@d8b90d80-bb63-11dd-bed2-db724ec49875" ]
[ [ [ 1, 13 ], [ 16, 19 ], [ 21, 24 ], [ 27, 29 ], [ 31, 33 ] ], [ [ 14, 15 ], [ 20, 20 ], [ 25, 26 ], [ 30, 30 ], [ 34, 34 ] ] ]
26c07c47f5501a0f31f10e434738e6892fa07a2c
b14d5833a79518a40d302e5eb40ed5da193cf1b2
/cpp/extern/xercesc++/2.6.0/src/xercesc/dom/DOMNotation.hpp
bf285a8adfa56678991bc04f6cbc9707c7ae5d0e
[ "Apache-2.0" ]
permissive
andyburke/bitflood
dcb3fb62dad7fa5e20cf9f1d58aaa94be30e82bf
fca6c0b635d07da4e6c7fbfa032921c827a981d6
refs/heads/master
2016-09-10T02:14:35.564530
2011-11-17T09:51:49
2011-11-17T09:51:49
2,794,411
1
0
null
null
null
null
UTF-8
C++
false
false
3,771
hpp
#ifndef DOMNotation_HEADER_GUARD_ #define DOMNotation_HEADER_GUARD_ /* * Copyright 2001-2002,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * 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. */ /* * $Id: DOMNotation.hpp,v 1.8 2004/09/26 15:38:02 gareth Exp $ */ #include <xercesc/util/XercesDefs.hpp> #include <xercesc/dom/DOMNode.hpp> XERCES_CPP_NAMESPACE_BEGIN /** * This interface represents a notation declared in the DTD. A notation either * declares, by name, the format of an unparsed entity (see section 4.7 of * the XML 1.0 specification), or is used for formal declaration of * Processing Instruction targets (see section 2.6 of the XML 1.0 * specification). The <code>nodeName</code> attribute inherited from * <code>DOMNode</code> is set to the declared name of the notation. * <p>The DOM Level 1 does not support editing <code>DOMNotation</code> nodes; * they are therefore readonly. * <p>A <code>DOMNotation</code> node does not have any parent. * * @since DOM Level 1 */ class CDOM_EXPORT DOMNotation: public DOMNode { protected: // ----------------------------------------------------------------------- // Hidden constructors // ----------------------------------------------------------------------- /** @name Hidden constructors */ //@{ DOMNotation() {}; //@} private: // ----------------------------------------------------------------------- // Unimplemented constructors and operators // ----------------------------------------------------------------------- /** @name Unimplemented constructors and operators */ //@{ DOMNotation(const DOMNotation &); DOMNotation & operator = (const DOMNotation &); //@} public: // ----------------------------------------------------------------------- // All constructors are hidden, just the destructor is available // ----------------------------------------------------------------------- /** @name Destructor */ //@{ /** * Destructor * */ virtual ~DOMNotation() {}; //@} // ----------------------------------------------------------------------- // Virtual DOMNotation interface // ----------------------------------------------------------------------- /** @name Functions introduced in DOM Level 1 */ //@{ // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- /** * Get the public identifier of this notation. * * If the public identifier was not * specified, this is <code>null</code>. * @return Returns the public identifier of the notation * @since DOM Level 1 */ virtual const XMLCh *getPublicId() const = 0; /** * Get the system identifier of this notation. * * If the system identifier was not * specified, this is <code>null</code>. * @return Returns the system identifier of the notation * @since DOM Level 1 */ virtual const XMLCh *getSystemId() const = 0; //@} }; XERCES_CPP_NAMESPACE_END #endif
[ [ [ 1, 113 ] ] ]
0616940935d42f2eebb3aa0d1d13f5576170761f
7f6fe18cf018aafec8fa737dfe363d5d5a283805
/ntk/storage/src/path.cpp
7dc4abbe761872bd1bf0a3a3d02d49c087acb38d
[]
no_license
snori/ntk
4db91d8a8fc836ca9a0dc2bc41b1ce767010d5ba
86d1a32c4ad831e791ca29f5e7f9e055334e8fe7
refs/heads/master
2020-05-18T05:28:49.149912
2009-08-04T16:47:12
2009-08-04T16:47:12
268,861
2
0
null
null
null
null
SHIFT_JIS
C++
false
false
6,393
cpp
/****************************************************************************** The NTK Library Copyright (C) 1998-2003 Noritaka Suzuki $Id: path.cpp,v 1.7 2003/11/11 12:07:09 nsuzuki Exp $ ******************************************************************************/ #define NTK_BUILD #include "ntk/storage/path.h" #include <vector> #include <ntk/support/debug.h> #include <ntk/storage/directory.h> namespace ntk { //######################################################## namespace { const char SEPARATOR = '\\'; bool is_separator(const char* c) { return c[0] == '/' || c[0] == '\\'; } bool drive_name_check(const String& path) { return ('a' <= path[0] && path[0] <= 'z' || 'A' <= path[0] && path[0] <= 'Z') && path[1] == ':' && (path[2] == '\\' || path[2] == '/'); } }// anonymous namespace //######################################################## Path::Path() : Flattenable() { } Path::Path(const String& path, const String& leaf, bool normalize) : Flattenable() { set_to(path, leaf, normalize); } Path::Path(const Directory& dir, const String& leaf, bool normalize) : Flattenable() { set_to(dir, leaf, normalize); } Path::Path(const Entry& entry) { set_to(entry); } Path::Path(const Path& rhs) : Flattenable(rhs) { m_path = rhs.m_path; } Path& Path::operator=(const Path& rhs) { if(&rhs == this) return *this; Flattenable::operator=(rhs); m_path = rhs.m_path; return *this; } Path::~Path() { } status_t Path::set_to(const String& path, const String& leaf, bool normalize_) { if(! drive_name_check(path)) return status_t(st::BAD_VALUE_ERROR, "ドライブ名がありません\n"); m_path = path; make_up_(); if(leaf != "") append(leaf); if(normalize_) normalize(); return st::OK; } status_t Path::set_to(const Directory& dir, const String& leaf, bool normalize) { return set_to(dir.entry().path().as_string(), leaf, normalize); } status_t Path::set_to(const Entry& entry) { return set_to(entry.path().as_string()); } void Path::unset() { m_path = ""; } status_t Path::init_check() const { return drive_name_check(m_path) ? st::OK : st::NOT_INITIALIZED_ERROR; } status_t Path::append(const String& path, bool normalize) { if(path == "" || is_separator(&path[0])) return status_t(st::BAD_VALUE_ERROR, "path が正しくありません (Path::append(const String&, bool)\n"); if(! is_separator(&m_path[m_path.size() -1])) m_path += SEPARATOR; m_path += path; make_up_(); return st::OK; } status_t Path::up() { return st::ERR; } Path Path::up(status_t* status) const { status_t sts_, &sts = status ? *status : sts_; Path path = *this; sts = path.up(); return path; } void Path::normalize() { for(String::iterator c = m_path.begin(); c != m_path.end(); ++c) { if(! (is_separator(&c[0]) && c[1] == '.')) continue; if(c[2] == '.' && is_separator(&c[3]))// "../" { String::iterator prev_separator = c -1, next_separator = c +3; // hige/hoge/../huga // ^(1) ^(2) // (1) prev_separator // (2) next_separator if(prev_separator == m_path.begin()) return; // 直前にセパレータが連続であるかもしれない while(is_separator(&prev_separator[0])) { --prev_separator; if(prev_separator == m_path.begin()) return; } // 一階層上る while(is_separator(&prev_separator[0]) == false) { --prev_separator; if(prev_separator == m_path.begin()) return; } m_path.erase(prev_separator, next_separator); c = m_path.begin(); } else if(is_separator(&c[2]))// "./" { m_path.erase(c, c +2); c = m_path.begin(); } } } status_t Path::flatten(void* buffer, Size num_bytes) const { return st::ERR; } status_t Path::unflatten(TypeCode type_code, void* buffer, Size num_bytes) { return st::ERR; } //******************************************************** // public accessors String Path::as_string(status_t* status) const { if(status) *status = st::OK; return m_path; } status_t Path::get_string(String* str) const { if(str == NULL) return st::BAD_VALUE_ERROR; *str = m_path; return st::OK; } String Path::leaf(status_t* status) const { String leaf_; status_t sts_, &sts = status ? *status : sts_; sts = get_leaf(&leaf_); return leaf_; } status_t Path::get_leaf(String* str) const { if(str == NULL) return st::BAD_VALUE_ERROR; const char* last_separator = strrchr(&m_path[0], SEPARATOR); *str = String(last_separator +1, &m_path[m_path.size()]); return st::OK; } String Path::parent(status_t* status) const { String parent_; status_t sts_, &sts = status ? *status : sts_; sts = get_parent(&parent_); return parent_; } status_t Path::get_parent(String* str) const { if(str == NULL) return st::BAD_VALUE_ERROR; status_t sts = init_check(); if(sts.is_valid_without_eval() == false) return sts; const char* last_separator = strrchr(&m_path[0], SEPARATOR); *str = String(&m_path[0], last_separator); return st::OK; } Path::Size Path::flattened_size() const { return 0; } Path::TypeCode Path::type_code() const { return 0; } bool Path::allows_type_code(TypeCode type_code_) const { return type_code_ == type_code(); } bool Path::is_root() const { return m_path[3] == '\0' && drive_name_check(m_path); } //******************************************************** // functions void Path::make_up_() { replace_separators_(); remove_last_separator_(); } void Path::replace_separators_() { const char SEP = '\\'; const char BAD_SEP = '/'; for(String::iterator it = m_path.begin(); it != m_path.end(); ++it) if(*it == BAD_SEP) *it = SEP; } void Path::remove_last_separator_() { String::iterator c = m_path.end() -1; if(c == m_path.begin() || (*c != '\\' && *c != '/') || is_root()) return; // 末尾に separator が複数あった時のため while(*(c -1) == '\\' || *(c -1) == '/') { --c; if(c == m_path.begin()) return; } m_path.erase(c, m_path.end()); } //######################################################## }// namespace ntk
[ [ [ 1, 365 ] ] ]
94c79d4861a5937bc9bb2d06b2a399adfb334a25
ce105c9e4ac9b1b77a160793e0c336826b936670
/c++/appointment/appointment/MyDate.cpp
8d528ca32952fbd20d1820407351e579fa984def
[]
no_license
jmcgranahan/jusall-programinghw
a32909655cec085d459c2c567c2f1bed2b947612
d6c5b54d0300a784dee0257364cd049f741cee81
refs/heads/master
2020-08-27T03:27:24.013332
2011-04-25T06:30:27
2011-04-25T06:30:27
40,640,139
0
0
null
null
null
null
UTF-8
C++
false
false
11,894
cpp
// MyDate.cpp #include <iostream> #include "MyDate.h" #include <ctime> #include <cstring> using namespace std; //Custom int MyDate::monthToDay(int month, int year) { int tempDays = 0; /*fml*/ bool isLeap = (year%4 == 0)&& ((year%100 != 0) || (year%400 == 0)); if(month == 1) tempDays += 0; else if(month == 2) tempDays += 31; else if(month == 3) tempDays += (59 + (isLeap *1)); else if(month == 4) tempDays += (90 + (isLeap *1)); else if(month == 5) tempDays += (120 + (isLeap *1)); else if(month == 6) tempDays += (151 + (isLeap *1)); else if(month == 7) tempDays += (181 + (isLeap *1)); else if(month == 8) tempDays += (212 + (isLeap *1)); else if(month == 9) tempDays += (243 + (isLeap *1)); else if(month == 10) tempDays += (273 + (isLeap *1)); else if(month == 11) tempDays += (304 + (isLeap *1)); else if(month == 12) tempDays += (334 + (isLeap *1)); return tempDays; } int MyDate::yearToDay(int year) { int tempDays = 0; bool isLeap = this->IsLeapYear(); while (year > 1) { if((year%4 == 0)&& ((year%100 != 0) || (year%400 == 0))) { tempDays += 366; } else { tempDays += 365; } year--; } if(isLeap) tempDays--; return tempDays; } // CONSTRUCTORS MyDate::MyDate() { _days = 1; } MyDate::MyDate(int day, int month, int year) { int tempDays = 0; if(month == 2 && (day > ( 28 + (IsLeapYear(year) * 1)))) { cout << "day too large for month, changing to last day of month" <<endl; day = 28 + (IsLeapYear(year) * 1); } else if( (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) && day > 31) { cout << "day too large for month, changing to last day of month" <<endl; day = 31; } else if((month == 4 || month == 6 || month == 9 || month == 11) && day > 30) { cout << "day too large for month, changing to last day of month" <<endl; day = 30; } if( day < 1) { cout << "day too low, using first of month"<<endl; day = 1; } tempDays += (year-1) * 365 + ( ((int) ((year-1) / 4)) - ((int) ((year-1) / 100)) + ((int) ((year-1) / 400))); tempDays += monthToDay(month, year); tempDays += day; _days = tempDays; } MyDate::MyDate(int days) { if(days < 1) days = 1; _days = days; return; } MyDate::MyDate(MyDate & aMyDate) { _days = aMyDate.GetDateSerial(); return; } // METHODS bool MyDate::IsLeapYear(MyDate & aMyDate) { int year = aMyDate.GetYear(); if((year%4 == 0)&& ((year%100 != 0) || (year%400 == 0))) return true; else return false; } bool MyDate::IsLeapYear(int year) { if((year%4 == 0)&& ((year%100 != 0) || (year%400 == 0))) return true; else return false; } bool MyDate::IsLeapYear() { int year = this->GetYear(); if((year%4 == 0)&& ((year%100 != 0) || (year%400 == 0))) return true; else return false; } int MyDate::GetDay() { int tempDays = _days; int year = this->GetYear(); int month = this->GetMonth(); tempDays -= yearToDay(year); tempDays -= monthToDay(month,year); return tempDays; } void MyDate::SetDay(int newDay) { int day = this->GetDay(); int newMonth = this->GetMonth(); int newYear = this->GetYear(); int tempDays = _days; tempDays -= day; if(newMonth == 2 && (newDay > ( 28 + (IsLeapYear(newYear) * 1)))) { cout << "day too large for month, changing to last day of month" <<endl; newDay = 28 + (IsLeapYear(newYear) * 1); } else if( (newMonth == 1 || newMonth == 3 || newMonth == 5 || newMonth == 7 || newMonth == 8 || newMonth == 10 || newMonth == 12) && newDay > 31) { cout << "day too large for month, changing to last day of month" <<endl; newDay = 31; } else if((newMonth == 4 || newMonth == 6 || newMonth == 9 || newMonth == 11) && newDay > 30) { cout << "day too large for month, changing to last day of month" <<endl; newDay = 30; } if( newDay < 1) { cout << "day too low, using first of month"<<endl; newDay = 1; } tempDays += newDay; _days = tempDays; } int MyDate::GetMonth()/*I lost the game*/ { int tempDays = _days; int year = this->GetYear(); int month = 0; bool isLeap = this->IsLeapYear(); tempDays -= yearToDay(year); //cout << tempDays <<endl; if(tempDays <= 31) month = 1; else if (tempDays <= (59 + ( 1 * isLeap))) month = 2; else if (tempDays <= (243 + ( 1 * isLeap))) { tempDays -= (59 + ( 1 * isLeap)); month = 3; int extraDay = 1; while(tempDays > (30 + extraDay)) { tempDays -= (30 + extraDay); month++; extraDay = !extraDay; } } else { tempDays -= (243 + ( 1 * isLeap)); month = 9; int extraDay = 1; while(tempDays > (30 + extraDay)) { tempDays -= (30 + extraDay); month++; extraDay = !extraDay; } } return month; } void MyDate::SetMonth(int newMonth) { int newDay = this->GetDay(); int Month = this->GetMonth(); int newYear = this->GetYear(); int tempDays = _days; tempDays -= newDay; tempDays -= monthToDay(Month, newYear); if(newMonth == 2 && (newDay > ( 28 + (IsLeapYear(newYear) * 1)))) { //cout << "day too large for month, changing to last day of month" <<endl; newDay = 28 + (IsLeapYear(newYear) * 1); } else if( (newMonth == 1 || newMonth == 3 || newMonth == 5 || newMonth == 7 || newMonth == 8 || newMonth == 10 || newMonth == 12) && newDay > 31) { //cout << "day too large for month, changing to last day of month" <<endl; newDay = 31; } else if((newMonth == 4 || newMonth == 6 || newMonth == 9 || newMonth == 11) && newDay > 30) { //cout << "day too large for month, changing to last day of month" <<endl; newDay = 30; } tempDays += monthToDay(newMonth,newYear); tempDays += newDay; _days = tempDays; } int MyDate::GetYear() { int tempDays = _days; int year = 1; while(tempDays >= 365){ if((year%4 == 0)&& ((year%100 != 0) || (year%400 == 0))) { tempDays -= 366; } else { tempDays -= 365; } year++; } return year; } void MyDate::SetYear(int newYear) { int tempDays = _days; int year = this->GetYear(); tempDays -= yearToDay(year); tempDays += yearToDay(newYear); _days = tempDays; } //void GetDayName(char * dayBuffer); void MyDate::GetMonthName(char * monthBuffer) { int month = this->GetMonth(); char * monthStr = new char[10]; if(month == 1) strcpy(monthStr, "January"); else if(month == 2) strcpy(monthStr, "Febuary"); else if(month == 3) strcpy(monthStr, "March"); else if(month == 4) strcpy(monthStr, "April"); else if(month == 5) strcpy(monthStr, "May"); else if(month == 6) strcpy(monthStr, "June"); else if(month == 7) strcpy(monthStr, "July"); else if(month == 8) strcpy(monthStr, "August"); else if(month == 9) strcpy(monthStr, "September"); else if(month == 10) strcpy(monthStr, "October"); else if(month == 11) strcpy(monthStr, "November"); else if(month == 12) strcpy(monthStr, "December"); strcpy(monthBuffer, monthStr); delete [] monthStr; } int MyDate::GetDateSerial() const { return _days; } void MyDate::SetDate(int Days) { _days = Days; return; } void MyDate::SetDate(int newDay, int newMonth, int newYear) { int tempDays = 0; if(newMonth == 2 && (newDay > ( 28 + (IsLeapYear(newYear) * 1)))) { cout << "day too large for month, changing to last day of month" <<endl; newDay = 28 + (IsLeapYear(newYear) * 1); } else if( (newMonth == 1 || newMonth == 3 || newMonth == 5 || newMonth == 7 || newMonth == 8 || newMonth == 10 || newMonth == 12) && newDay > 31) { cout << "day too large for month, changing to last day of month" <<endl; newDay = 31; } else if((newMonth == 4 || newMonth == 6 || newMonth == 9 || newMonth == 11) && newDay > 30) { cout << "day too large for month, changing to last day of month" <<endl; newDay = 30; } if( newDay < 1) { cout << "day too low, using first of month"<<endl; newDay = 1; } tempDays += (newYear-1) * 365 + ( ((int) ((newYear-1) / 4)) - ((int) ((newYear-1) / 100)) + ((int) ((newYear-1) / 400))); tempDays += monthToDay(newMonth,newYear); tempDays += newDay; _days = tempDays; return; } void MyDate::SetDate(const MyDate & aMyDate) { _days = aMyDate.GetDateSerial(); return; } MyDate MyDate::Now() { time_t seconds; seconds = time (NULL); MyDate tempMyDate(1,1,1970); tempMyDate.AddDays(seconds/86400); return tempMyDate; } void MyDate::AddYears(int moreYears) { int year = this->GetYear(); int tempDays = _days; tempDays -= yearToDay(year); year += moreYears; tempDays += yearToDay(year); _days = tempDays; } void MyDate::AddMonths(int moreMonths) { int year = this->GetYear(); int month = this->GetMonth(); int tempDays = _days; tempDays -= monthToDay(month,year); month += moreMonths; tempDays += monthToDay(month,year); _days = tempDays; } void MyDate::AddDays(long moreDays) { this->_days += moreDays; } void MyDate::AddDate(const MyDate & aMyDate) { _days += aMyDate.GetDateSerial(); } int MyDate::Compare(const MyDate & aMyDate) const { return aMyDate.GetDateSerial() - _days; } bool MyDate::Equals(const MyDate & aMyDate) const { if (aMyDate.GetDateSerial() - _days == 0) return true; else return false; } void MyDate::SubtractYears(int lessYears) { int tempDays = _days; int year = this->GetYear(); tempDays -= yearToDay(year); year -= lessYears; tempDays += yearToDay(year); _days= tempDays; } void MyDate::SubtractMonths(int lessMonths) { int year = this->GetYear(); int month = this->GetMonth(); int tempDays = _days; tempDays -= monthToDay(month,year); month -= lessMonths; tempDays += monthToDay(month,year); _days = tempDays; } void MyDate::SubtractDays(long lessDays) { this->_days -= lessDays; } void MyDate::SubtractDate(const MyDate & aMyDate) { _days -= aMyDate.GetDateSerial(); } MyDate MyDate::operator= (const MyDate & aMyDate) { this->_days = aMyDate.GetDateSerial(); return 0; } MyDate MyDate::operator+ (const MyDate & aMyDate) const { MyDate temp; temp.SetDate(*this); temp.AddDate(aMyDate); return temp; } MyDate MyDate::operator+= (const MyDate & aMyDate) { this->AddDate(aMyDate); return 0; } // >, <, >=, <=, ==, != (boolean relational test operators) bool MyDate::operator> (const MyDate & aMyDate) const { if( this->GetDateSerial() > aMyDate.GetDateSerial()) return true; else return false; } bool MyDate::operator< (const MyDate & aMyDate) const { if( this->GetDateSerial() < aMyDate.GetDateSerial()) return true; else return false; } bool MyDate::operator>= (const MyDate & aMyDate) const { if( this->GetDateSerial() >= aMyDate.GetDateSerial()) return true; else return false; } bool MyDate::operator<= (const MyDate & aMyDate) const { if( this->GetDateSerial() <= aMyDate.GetDateSerial()) return true; else return false; } bool MyDate::operator== (const MyDate & aMyDate) const { if( this->GetDateSerial() == aMyDate.GetDateSerial()) return true; else return false; } bool MyDate::operator!= (const MyDate & aMyDate) const { if( this->GetDateSerial() != aMyDate.GetDateSerial()) return true; else return false; } // <<, >> stream insertion and extraction ostream & operator<< (ostream & os, MyDate & aMyDate) { os << aMyDate.GetDay() << "/"<< aMyDate.GetMonth() <<"/" <<aMyDate.GetYear(); return os; } // date must be one of these formats // ??? istream & operator>> (istream & is, MyDate & aMyDate) { int day; int month; int year; cout << "year: "; cin >> year; cout << endl << "month: "; cin >> month; cout << endl << "day: "; cin >> day; aMyDate.SetDate(day,month,year); return is; }
[ "biga05@c0f360ae-aefd-11de-b8dd-ab4b6ce6d521" ]
[ [ [ 1, 503 ] ] ]
801fc1f47c8b8d3c006022e7bfc81bf6a66591c6
da48afcbd478f79d70767170da625b5f206baf9a
/tbmessage/src/SendPage.h
d90f887b75e1d10552762c9e3ccc252f8f9a2ed8
[]
no_license
haokeyy/fahister
5ba50a99420dbaba2ad4e5ab5ee3ab0756563d04
c71dc56a30b862cc4199126d78f928fce11b12e5
refs/heads/master
2021-01-10T19:09:22.227340
2010-05-06T13:17:35
2010-05-06T13:17:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,036
h
#pragma once #include "afxcmn.h" #include "afxwin.h" #include "libraries\explorerocx.h" // CSendPage dialog class CSendPage : public CDialog { DECLARE_DYNAMIC(CSendPage) public: CSendPage(CWnd* pParent = NULL); // standard constructor virtual ~CSendPage(); // Dialog Data enum { IDD = IDD_SEND_VIEW }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual BOOL OnInitDialog(); long lastMemberId; BOOL m_IsStop; DECLARE_MESSAGE_MAP() public: CString szTaobaoSendUrl; CString m_szLastSenderId; afx_msg void OnBnClickedBtnSendmsg(); afx_msg void OnBnClickedBtnAddAccount(); afx_msg void OnBnClickedBtnDelAccount(); CListCtrl m_AccountList; CComboBox m_CmbSpeed; void InitSpeed(); void LoadMembers(long startId, long stepCount); void SetPagging(long start, long pageSize); void SaveProfile(); void LoadProfile(); void StartSendMsg(); void StopSendMsg(); int GetNextMessage(CString& szNextMessage); BOOL IsOnline(CString szUserId); int GetNextMember(CString& szNextReceiver); BOOL OpenSendWindow(CString szSenderID, CString szReceiverID); LRESULT OnSendMsgCompleted(WPARAM wParam, LPARAM lParam); CExplorerOcx m_ExprMsgHelp; void SendImMsg(); CListCtrl m_MessageList; CListCtrl m_MemberList; afx_msg void OnBnClickedBtnAddMsg(); afx_msg void OnBnClickedBtnEditMsg(); afx_msg void OnBnClickedBtnDelMsg(); afx_msg void OnBnClickedBtnImport2(); afx_msg void OnBnClickedBtnExport2(); afx_msg void OnBnClickedBtnClear(); afx_msg void OnBnClickedBtnClear2(); afx_msg void OnBnClickedBtnFirstPage(); afx_msg void OnBnClickedBtnPrevPage(); afx_msg void OnBnClickedBtnNextPage(); afx_msg void OnBnClickedBtnLastPage(); int m_nSendLimit; int m_nSendedCount; CString m_szSendUrl; CString m_szAdText; afx_msg void OnBnClickedBtnReset(); afx_msg void OnDestroy(); afx_msg void OnBnClickedBtnImport(); };
[ "[email protected]@d41c10be-1f87-11de-a78b-a7aca27b2395" ]
[ [ [ 1, 70 ] ] ]
43762775fcd4589098aaf9fe2c12875ea79e004f
9267674a05b4561b921413a711e9dbd6193b936a
/src/players/warrior.cpp
51acd155d42c4343d40fbb99ae3b10fa4f0eaaed
[]
no_license
scognito/puppetfigher
249564d09eab07f75444dde60fb0f10f6deba2c0
ddf34730304e66dbe8de2d5cd12a5e61f7aded36
refs/heads/master
2021-01-16T23:06:38.792594
2009-09-25T19:56:03
2009-09-25T19:56:03
32,251,497
0
0
null
null
null
null
UTF-8
C++
false
false
2,501
cpp
#include "warrior.h" extern u8 head_png[], torso_png[], bicep_png[], forearm_png[], hand_png[], thigh_png[], calf_png[], foot_png[]; extern u8 bullet_png[]; //,gun_png[]; extern char player_gsa[]; Warrior::Warrior(float x, float y, b2World* w): Player(x,y,player_gsa, w, 120, 30) { InitArmor(); InitWeapon(); } Warrior::~Warrior() { } void Warrior::InitWeapon() { Weapon::Type tWeapon; tWeapon.dx = 0; tWeapon.dy = 0; tWeapon.dang = 0; //tWeapon.img = new Image(); //tWeapon.img->LoadImage(gun_png, IMG_LOAD_TYPE_BUFFER); tWeapon.bullet_image = new Image(); tWeapon.bullet_image->LoadImage(bullet_png, IMG_LOAD_TYPE_BUFFER); tWeapon.velocity = 18.0; tWeapon.bullet_strength = 5.0; tWeapon.power_consumption = 1.0; tWeapon.firing_delay = 3.0; tWeapon.max_tof = 100; this->SetWeapon(tWeapon); } void Warrior::InitArmor() { //TODO Load this armor from some sort of player info Armor::Type tArmor; tArmor.dx = 0; tArmor.dy = 0; tArmor.dang = 90; //Init Head tArmor.armor_type = Armor::Category::HEAD; tArmor.img = new Image(); tArmor.img->LoadImage(head_png, IMG_LOAD_TYPE_BUFFER); this->SetArmor(tArmor); //Init Torso tArmor.dang = 270; tArmor.armor_type = Armor::Category::TORSO; tArmor.img = new Image(); tArmor.img->LoadImage(torso_png, IMG_LOAD_TYPE_BUFFER); this->SetArmor(tArmor); tArmor.dang = 90; //Init Bicep tArmor.armor_type = Armor::Category::BICEP; tArmor.img = new Image(); tArmor.img->LoadImage(bicep_png, IMG_LOAD_TYPE_BUFFER); this->SetArmor(tArmor); //Init forearm tArmor.armor_type = Armor::Category::FOREARM; tArmor.img = new Image(); tArmor.img->LoadImage(forearm_png, IMG_LOAD_TYPE_BUFFER); this->SetArmor(tArmor); //Init hand tArmor.armor_type = Armor::Category::HAND; tArmor.img = new Image(); tArmor.img->LoadImage(hand_png, IMG_LOAD_TYPE_BUFFER); this->SetArmor(tArmor); //Init Thigh tArmor.armor_type = Armor::Category::THIGH; tArmor.img = new Image(); tArmor.img->LoadImage(thigh_png, IMG_LOAD_TYPE_BUFFER); this->SetArmor(tArmor); //Init CALF tArmor.armor_type = Armor::Category::CALF; tArmor.img = new Image(); tArmor.img->LoadImage(calf_png, IMG_LOAD_TYPE_BUFFER); this->SetArmor(tArmor); //Init Foot tArmor.armor_type = Armor::Category::FOOT; tArmor.img = new Image(); tArmor.img->LoadImage(foot_png, IMG_LOAD_TYPE_BUFFER); this->SetArmor(tArmor); }
[ "justin.hawkins@6d35b48c-a465-11de-bea2-1db044c32224" ]
[ [ [ 1, 102 ] ] ]
7734f50a3ec1a501d5dbb0c8acabfc36cfd05138
ce262ae496ab3eeebfcbb337da86d34eb689c07b
/SEAudio/SESceneGraph/SESoundBuffer.cpp
62b6c96e895f6d82b00ee0fbfadf2290af148ade
[]
no_license
pizibing/swingengine
d8d9208c00ec2944817e1aab51287a3c38103bea
e7109d7b3e28c4421c173712eaf872771550669e
refs/heads/master
2021-01-16T18:29:10.689858
2011-06-23T04:27:46
2011-06-23T04:27:46
33,969,301
0
0
null
null
null
null
GB18030
C++
false
false
6,602
cpp
// Swing Engine Version 1 Source Code // Most of techniques in the engine are mainly based on David Eberly's // Wild Magic 4 open-source code.The author of Swing Engine learned a lot // from Eberly's experience of architecture and algorithm. // Several sub-systems are totally new,and others are re-implimented or // re-organized based on Wild Magic 4's sub-systems. // Copyright (c) 2007-2010. All Rights Reserved // // Eberly's permission: // Geometric Tools, Inc. // http://www.geometrictools.com // Copyright (c) 1998-2006. All Rights Reserved // // This library is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 2.1 of the License, or (at // your option) any later version. The license is available for reading at // the location: // http://www.gnu.org/copyleft/lgpl.html #include "SEAudioPCH.h" #include "SESoundBuffer.h" using namespace Swing; SE_IMPLEMENT_RTTI(Swing, SESoundBuffer, SEObject); SE_IMPLEMENT_STREAM(SESoundBuffer); //SE_REGISTER_STREAM(SESoundBuffer); //---------------------------------------------------------------------------- SESoundBuffer::SESoundBuffer(int iWCount, SEWave** apWaves) { SE_ASSERT( iWCount > 0 && apWaves ); m_Waves.resize(iWCount); for( int i = 0; i < iWCount; i++ ) { m_Waves[i] = apWaves[i]; } } //---------------------------------------------------------------------------- SESoundBuffer::SESoundBuffer(const SESoundBuffer* pSBuffer) { SE_ASSERT( pSBuffer ); m_Waves.resize(pSBuffer->m_Waves.size()); for( int i = 0; i < (int)pSBuffer->m_Waves.size(); i++ ) { m_Waves[i] = pSBuffer->m_Waves[i]; } } //---------------------------------------------------------------------------- SESoundBuffer::SESoundBuffer() { } //---------------------------------------------------------------------------- SESoundBuffer::~SESoundBuffer() { // 通知所有使用此SBuffer的audio renderer,资源即将被释放, // 从而允许audio renderer释放与此SB有关的资源. Release(); } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- // name and unique id //---------------------------------------------------------------------------- SEObject* SESoundBuffer::GetObjectByName(const std::string& rName) { SEObject* pFound = SEObject::GetObjectByName(rName); if( pFound ) { return pFound; } for( int i = 0; i < (int)m_Waves.size(); i++ ) { if( m_Waves[i] ) { pFound = m_Waves[i]->GetObjectByName(rName); if( pFound ) { return pFound; } } } return 0; } //---------------------------------------------------------------------------- void SESoundBuffer::GetAllObjectsByName(const std::string& rName, std::vector<SEObject*>& rObjects) { SEObject::GetAllObjectsByName(rName, rObjects); for( int i = 0; i < (int)m_Waves.size(); i++ ) { if( m_Waves[i] ) { m_Waves[i]->GetAllObjectsByName(rName, rObjects); } } } //---------------------------------------------------------------------------- SEObject* SESoundBuffer::GetObjectByID(unsigned int uiID) { SEObject* pFound = SEObject::GetObjectByID(uiID); if( pFound ) { return pFound; } for( int i = 0; i < (int)m_Waves.size(); i++ ) { if( m_Waves[i] ) { pFound = m_Waves[i]->GetObjectByID(uiID); if( pFound ) { return pFound; } } } return 0; } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- // streaming //---------------------------------------------------------------------------- void SESoundBuffer::Load(SEStream& rStream, SEStream::SELink* pLink) { SE_BEGIN_DEBUG_STREAM_LOAD; SEObject::Load(rStream, pLink); // link data int iWCount; rStream.Read(iWCount); m_Waves.resize(iWCount); for( int i = 0; i < iWCount; i++ ) { SEObject* pObject; rStream.Read(pObject); // m_Waves[i] pLink->Add(pObject); } SE_END_DEBUG_STREAM_LOAD(SESoundBuffer); } //---------------------------------------------------------------------------- void SESoundBuffer::Link(SEStream& rStream, SEStream::SELink* pLink) { SEObject::Link(rStream, pLink); for( int i = 0; i < (int)m_Waves.size(); i++ ) { SEObject* pLinkID = pLink->GetLinkID(); m_Waves[i] = (SEWave*)rStream.GetFromMap(pLinkID); } } //---------------------------------------------------------------------------- bool SESoundBuffer::Register(SEStream& rStream) const { if( !SEObject::Register(rStream) ) { return false; } for( int i = 0; i < (int)m_Waves.size(); i++ ) { if( m_Waves[i] ) { m_Waves[i]->Register(rStream); } } return true; } //---------------------------------------------------------------------------- void SESoundBuffer::Save(SEStream& rStream) const { SE_BEGIN_DEBUG_STREAM_SAVE; SEObject::Save(rStream); // link data int iWCount = (int)m_Waves.size(); rStream.Write(iWCount); for( int i = 0; i < iWCount; i++ ) { rStream.Write(m_Waves[i]); } SE_END_DEBUG_STREAM_SAVE(SESoundBuffer); } //---------------------------------------------------------------------------- int SESoundBuffer::GetDiskUsed(const SEStreamVersion& rVersion) const { return SEObject::GetDiskUsed(rVersion) + sizeof(int) + (int)m_Waves.size()*SE_PTRSIZE(m_Waves[0]); } //---------------------------------------------------------------------------- SEStringTree* SESoundBuffer::SaveStrings(const char*) { SEStringTree* pTree = SE_NEW SEStringTree; // strings pTree->Append(Format(&TYPE, GetName().c_str())); // children pTree->Append(SEObject::SaveStrings()); for( int i = 0; i < (int)m_Waves.size(); i++ ) { pTree->Append(m_Waves[i]->SaveStrings()); } return pTree; } //----------------------------------------------------------------------------
[ "[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac" ]
[ [ [ 1, 222 ] ] ]
a5a7100e85e089cd6f4cbad519f1aa258a7f2c95
463c3b62132d215e245a097a921859ecb498f723
/lib/dlib/test/hash_set.cpp
54d9e4105fe679e4e98608ac18c7bd46c2cd03e2
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
athulan/cppagent
58f078cee55b68c08297acdf04a5424c2308cfdc
9027ec4e32647e10c38276e12bcfed526a7e27dd
refs/heads/master
2021-01-18T23:34:34.691846
2009-05-05T00:19:54
2009-05-05T00:19:54
197,038
4
1
null
null
null
null
UTF-8
C++
false
false
12,684
cpp
// Copyright (C) 2003 Davis E. King ([email protected]) // License: Boost Software License See LICENSE.txt for the full license. #include <sstream> #include <string> #include <cstdlib> #include <ctime> #include <dlib/hash_set.h> #include "tester.h" namespace { using namespace test; using namespace std; using namespace dlib; logger dlog("test.hash_set"); template < typename hash_set > void hash_set_kernel_test ( ) /*! requires - hash_set is an implementation of hash_set/hash_set_kernel_abstract.h and is instantiated with int ensures - runs tests on hash_set for compliance with the specs !*/ { srand(static_cast<unsigned int>(time(0))); print_spinner(); hash_set test, test2; enumerable<const int>& e = test; DLIB_CASSERT(e.at_start() == true,""); for (int j = 0; j < 4; ++j) { print_spinner(); DLIB_CASSERT(test.at_start() == true,""); DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_CASSERT(test.move_next() == false,""); DLIB_CASSERT(test.move_next() == false,""); DLIB_CASSERT(test.move_next() == false,""); DLIB_CASSERT(test.move_next() == false,""); DLIB_CASSERT(test.move_next() == false,""); DLIB_CASSERT(test.move_next() == false,""); DLIB_CASSERT(test.move_next() == false,""); DLIB_CASSERT(test.at_start() == false,""); DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_CASSERT(test.size() == 0,""); DLIB_CASSERT(test.is_member(5) == false,""); DLIB_CASSERT(test.is_member(0) == false,""); DLIB_CASSERT(test.is_member(-999) == false,""); DLIB_CASSERT(test.is_member(4999) == false,""); int a,b = 0; a = 8; test.add(a); DLIB_CASSERT(test.size() == 1,""); DLIB_CASSERT(test.is_member(8) == true,""); DLIB_CASSERT(test.is_member(5) == false,""); DLIB_CASSERT(test.is_member(0) == false,""); DLIB_CASSERT(test.is_member(-999) == false,""); DLIB_CASSERT(test.is_member(4999) == false,""); a = 53; test.add(a); DLIB_CASSERT(test.size() == 2,""); DLIB_CASSERT(test.is_member(53) == true,""); DLIB_CASSERT(test.is_member(5) == false,""); DLIB_CASSERT(test.is_member(0) == false,""); DLIB_CASSERT(test.is_member(-999) == false,""); DLIB_CASSERT(test.is_member(4999) == false,""); swap(test,test2); DLIB_CASSERT(test2.is_member(8) == true,""); DLIB_CASSERT(test2.is_member(5) == false,""); DLIB_CASSERT(test2.is_member(0) == false,""); DLIB_CASSERT(test2.is_member(-999) == false,""); DLIB_CASSERT(test2.is_member(4999) == false,""); DLIB_CASSERT(test2.size() == 2,""); DLIB_CASSERT(test2.is_member(53) == true,""); DLIB_CASSERT(test2.is_member(5) == false,""); DLIB_CASSERT(test2.is_member(0) == false,""); DLIB_CASSERT(test2.is_member(-999) == false,""); DLIB_CASSERT(test2.is_member(4999) == false,""); DLIB_CASSERT(test.size() == 0,""); DLIB_CASSERT(test.is_member(8) == false,""); DLIB_CASSERT(test.is_member(5) == false,""); DLIB_CASSERT(test.is_member(0) == false,""); DLIB_CASSERT(test.is_member(-999) == false,""); DLIB_CASSERT(test.is_member(4999) == false,""); DLIB_CASSERT(test.size() == 0,""); DLIB_CASSERT(test.is_member(53) == false,""); DLIB_CASSERT(test.is_member(5) == false,""); DLIB_CASSERT(test.is_member(0) == false,""); DLIB_CASSERT(test.is_member(-999) == false,""); DLIB_CASSERT(test.is_member(4999) == false,""); test.clear(); DLIB_CASSERT(test.at_start() == true,""); DLIB_CASSERT(test.move_next() == false,""); DLIB_CASSERT(test.move_next() == false,""); DLIB_CASSERT(test.move_next() == false,""); DLIB_CASSERT(test.move_next() == false,""); DLIB_CASSERT(test.move_next() == false,""); DLIB_CASSERT(test.at_start() == false,""); DLIB_CASSERT(test.size() == 0,""); while (test.size() < 10000) { a = ::rand(); if (!test.is_member(a)) test.add(a); } DLIB_CASSERT(test.size() == 10000,""); test.clear(); DLIB_CASSERT(test.size() == 0,""); while (test.size() < 10000) { a = ::rand(); if (!test.is_member(a)) test.add(a); } DLIB_CASSERT(test.size() == 10000,""); int count = 0; while (test.move_next()) { DLIB_CASSERT(test.element() == test.element(),""); DLIB_CASSERT(test.element() == test.element(),""); DLIB_CASSERT(test.element() == test.element(),""); ++count; } DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_CASSERT(test.at_start() == false,""); DLIB_CASSERT(test.move_next() == false,""); DLIB_CASSERT(test.current_element_valid() == false,""); DLIB_CASSERT(test.at_start() == false,""); DLIB_CASSERT(test.move_next() == false,""); DLIB_CASSERT(count == 10000,""); test.swap(test2); DLIB_CASSERT(test.size() == 2,""); DLIB_CASSERT(test2.size() == 10000,""); count = 0; test2.reset(); while (test2.move_next()) { DLIB_CASSERT(test2.element() == test2.element(),""); DLIB_CASSERT(test2.element() == test2.element(),""); DLIB_CASSERT(test2.element() == test2.element(),""); ++count; } DLIB_CASSERT(test2.size() == 10000,""); DLIB_CASSERT(count == 10000,""); DLIB_CASSERT(test2.current_element_valid() == false,""); DLIB_CASSERT(test2.at_start() == false,""); DLIB_CASSERT(test2.move_next() == false,""); DLIB_CASSERT(test2.current_element_valid() == false,""); DLIB_CASSERT(test2.at_start() == false,""); DLIB_CASSERT(test2.move_next() == false,""); test2.clear(); DLIB_CASSERT(test2.size() == 0,""); DLIB_CASSERT(test2.at_start() == true,""); while (test.size() < 20000) { a = ::rand(); if (!test.is_member(a)) test.add(a); } DLIB_CASSERT(test.at_start() == true,""); { int* array = new int[test.size()]; int* tmp = array; // serialize the state of test, then clear test, then // load the state back into test. ostringstream sout; serialize(test,sout); DLIB_CASSERT(test.at_start() == true,""); istringstream sin(sout.str()); test.clear(); deserialize(test,sin); count = 0; while (test.move_next()) { DLIB_CASSERT(test.element() == test.element(),""); DLIB_CASSERT(test.element() == test.element(),""); DLIB_CASSERT(test.element() == test.element(),""); *tmp = test.element(); ++tmp; ++count; } DLIB_CASSERT(count == 20000,""); tmp = array; for (int i = 0; i < 20000; ++i) { DLIB_CASSERT(test.is_member(*tmp) == true,""); ++tmp; } DLIB_CASSERT(test.size() == 20000,""); tmp = array; count = 0; while (test.size() > 10000) { test.remove(*tmp,a); DLIB_CASSERT(*tmp == a,""); ++tmp; ++count; } DLIB_CASSERT(count == 10000,""); DLIB_CASSERT(test.size() == 10000,""); while (test.move_next()) { ++count; } DLIB_CASSERT(count == 20000,""); DLIB_CASSERT(test.size() == 10000,""); while (test.size() < 20000) { a = ::rand(); if (!test.is_member(a)) test.add(a); } test2.swap(test); count = 0; while (test2.move_next()) { DLIB_CASSERT(test2.element() == test2.element(),""); DLIB_CASSERT(test2.element() == test2.element(),""); DLIB_CASSERT(test2.element() == test2.element(),""); ++count; } DLIB_CASSERT(count == 20000,""); DLIB_CASSERT(test2.size() == 20000,""); while (test2.size()>0) { test2.remove_any(b); } DLIB_CASSERT(test2.size() == 0,""); delete [] array; } test.clear(); test2.clear(); while (test.size() < 10000) { a = ::rand(); if (!test.is_member(a)) test.add(a); } count = 0; while (test.move_next()) { ++count; if (count == 5000) break; DLIB_CASSERT(test.current_element_valid() == true,""); } test.reset(); count = 0; while (test.move_next()) { ++count; DLIB_CASSERT(test.current_element_valid() == true,""); } DLIB_CASSERT(count == 10000,""); test.clear(); test2.clear(); } { test.clear(); DLIB_CASSERT(test.size() == 0,""); int a = 5; test.add(a); a = 7; test.add(a); DLIB_CASSERT(test.size() == 2,""); DLIB_CASSERT(test.is_member(7),""); DLIB_CASSERT(test.is_member(5),""); test.destroy(7); DLIB_CASSERT(test.size() == 1,""); DLIB_CASSERT(!test.is_member(7),""); DLIB_CASSERT(test.is_member(5),""); test.destroy(5); DLIB_CASSERT(test.size() == 0,""); DLIB_CASSERT(!test.is_member(7),""); DLIB_CASSERT(!test.is_member(5),""); } } class hash_set_tester : public tester { public: hash_set_tester ( ) : tester ("test_hash_set", "Runs tests on the hash_set component.") {} void perform_test ( ) { dlog << LINFO << "testing kernel_1a"; hash_set_kernel_test<hash_set<int,14>::kernel_1a>(); dlog << LINFO << "testing kernel_1a_c"; hash_set_kernel_test<hash_set<int,14>::kernel_1a_c>(); dlog << LINFO << "testing kernel_1b"; hash_set_kernel_test<hash_set<int,14>::kernel_1b>(); dlog << LINFO << "testing kernel_1b_c"; hash_set_kernel_test<hash_set<int,14>::kernel_1b_c>(); dlog << LINFO << "testing kernel_1c"; hash_set_kernel_test<hash_set<int,14>::kernel_1c>(); dlog << LINFO << "testing kernel_1c_c"; hash_set_kernel_test<hash_set<int,14>::kernel_1c_c>(); } } a; }
[ "jimmy@DGJ3X3B1.(none)" ]
[ [ [ 1, 387 ] ] ]
ed021e510bf6e014884b490df053f477fc6f14f9
e2e41b28ec8db552a4f2148089dc995050ef69e8
/src/bindings/luascript/cpp-scripts/guards/sc_guard_durotar.cpp
364c3335b5ebef8f265181eddcbb49ca6205abec
[]
no_license
bing2008/mangos-luascript
951e6f8a4db96a0c67d85958264804993b6352a5
041593c330681705fc5e7fb7393c6c3a356892d5
refs/heads/master
2021-08-27T15:28:50.017479
2006-12-12T14:19:27
2006-12-12T14:19:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,674
cpp
/* * Copyright (C) 2005,2006 ScriptDev <https://opensvn.csie.org/ScriptDev/> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "sc_defines.h" bool GossipHello_guard_durotar(Player *player, Creature *_Creature) { player->ADD_GOSSIP_ITEM( 6, "The bank" , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); player->ADD_GOSSIP_ITEM( 2, "The wind rider master" , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); player->ADD_GOSSIP_ITEM( 1, "The inn" , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); player->ADD_GOSSIP_ITEM( 5, "The stable master" , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4); player->ADD_GOSSIP_ITEM( 3, "A class trainer" , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5); player->ADD_GOSSIP_ITEM( 3, "A profession trainer" , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6); player->SEND_GOSSIP_MENU(4037,_Creature->GetGUID()); return true; } /******************************************************* * Start of GOSSIP_MENU *******************************************************/ void SendDefaultMenu_guard_durotar(Player *player, Creature *_Creature, uint32 action) { if (action == GOSSIP_ACTION_INFO_DEF + 1)//Bank player->SEND_GOSSIP_MENU(4032,_Creature->GetGUID()); if (action == GOSSIP_ACTION_INFO_DEF + 2)//Wind rider player->SEND_GOSSIP_MENU(4033,_Creature->GetGUID()); if (action == GOSSIP_ACTION_INFO_DEF + 3)//Inn { player->SEND_POI(338.7, -4688.87, 6, 6, 0, "Razor Hill Inn"); player->SEND_GOSSIP_MENU(4034,_Creature->GetGUID()); } if (action == GOSSIP_ACTION_INFO_DEF + 4)//Stable master { player->SEND_POI(330.31, -4710.66, 6, 6, 0, "Shoja'my"); player->SEND_GOSSIP_MENU(5973,_Creature->GetGUID()); } if (action == GOSSIP_ACTION_INFO_DEF + 5)//Class trainer { player->ADD_GOSSIP_ITEM( 3, "Hunter" , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 1); player->ADD_GOSSIP_ITEM( 3, "Mage" , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 2); player->ADD_GOSSIP_ITEM( 3, "Priest" , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 3); player->ADD_GOSSIP_ITEM( 3, "Rogue" , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 4); player->ADD_GOSSIP_ITEM( 3, "Shaman" , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 5); player->ADD_GOSSIP_ITEM( 3, "Warlock" , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 6); player->ADD_GOSSIP_ITEM( 3, "Warrior" , GOSSIP_SENDER_SEC_CLASSTRAIN, GOSSIP_ACTION_INFO_DEF + 7); player->SEND_GOSSIP_MENU(4035,_Creature->GetGUID()); } if (action == GOSSIP_ACTION_INFO_DEF + 6)//Profession trainer { player->ADD_GOSSIP_ITEM( 3, "Alchemy" , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 1); player->ADD_GOSSIP_ITEM( 3, "Blacksmithing" , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 2); player->ADD_GOSSIP_ITEM( 3, "Cooking" , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 3); player->ADD_GOSSIP_ITEM( 3, "Enchanting" , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 4); player->ADD_GOSSIP_ITEM( 3, "Engineering" , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 5); player->ADD_GOSSIP_ITEM( 3, "First Aid" , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 6); player->ADD_GOSSIP_ITEM( 3, "Fishing" , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 7); player->ADD_GOSSIP_ITEM( 3, "Herbalism" , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 8); player->ADD_GOSSIP_ITEM( 3, "Leatherworking" , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 9); player->ADD_GOSSIP_ITEM( 3, "Mining" , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 10); player->ADD_GOSSIP_ITEM( 3, "Skinning" , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 11); player->ADD_GOSSIP_ITEM( 3, "Tailoring" , GOSSIP_SENDER_SEC_PROFTRAIN, GOSSIP_ACTION_INFO_DEF + 12); player->SEND_GOSSIP_MENU(4036,_Creature->GetGUID()); } } void SendClassTrainerMenu_guard_durotar(Player *player, Creature *_Creature, uint32 action) { if (action == GOSSIP_ACTION_INFO_DEF + 1)//Hunter { player->SEND_POI(276, -4706.72, 6, 6, 0, "Thotar"); player->SEND_GOSSIP_MENU(4013,_Creature->GetGUID()); } if (action == GOSSIP_ACTION_INFO_DEF + 2)//Mage { player->SEND_POI(-839.33, -4935.6, 6, 6, 0, "Un'Thuwa"); player->SEND_GOSSIP_MENU(4014,_Creature->GetGUID()); } if (action == GOSSIP_ACTION_INFO_DEF + 3)//Priest { player->SEND_POI(296.22, -4828.1, 6, 6, 0, "Tai'jin"); player->SEND_GOSSIP_MENU(4015,_Creature->GetGUID()); } if (action == GOSSIP_ACTION_INFO_DEF + 4)//Rogue { player->SEND_POI(265.76, -4709, 6, 6, 0, "Kaplak"); player->SEND_GOSSIP_MENU(4016,_Creature->GetGUID()); } if (action == GOSSIP_ACTION_INFO_DEF + 5)//Shaman { player->SEND_POI(307.79, -4836.97, 6, 6, 0, "Swart"); player->SEND_GOSSIP_MENU(4017,_Creature->GetGUID()); } if (action == GOSSIP_ACTION_INFO_DEF + 6)//Warlock { player->SEND_POI(355.88, -4836.45, 6, 6, 0, "Dhugru Gorelust"); player->SEND_GOSSIP_MENU(4018,_Creature->GetGUID()); } if (action == GOSSIP_ACTION_INFO_DEF + 7)//Warrior { player->SEND_POI(312.3, -4824.66, 6, 6, 0, "Tarshaw Jaggedscar"); player->SEND_GOSSIP_MENU(4019,_Creature->GetGUID()); } } void SendProfTrainerMenu_guard_durotar(Player *player, Creature *_Creature, uint32 action) { if (action == GOSSIP_ACTION_INFO_DEF + 1)//Alchemy { player->SEND_POI(-800.25, -4894.33, 6, 6, 0, "Miao'zan"); player->SEND_GOSSIP_MENU(4020,_Creature->GetGUID()); } if (action == GOSSIP_ACTION_INFO_DEF + 2)//Blacksmithing { player->SEND_POI(373.24, -4716.45, 6, 6, 0, "Dwukk"); player->SEND_GOSSIP_MENU(4021,_Creature->GetGUID()); } if (action == GOSSIP_ACTION_INFO_DEF + 3)//Cooking player->SEND_GOSSIP_MENU(4022,_Creature->GetGUID()); if (action == GOSSIP_ACTION_INFO_DEF + 4)//Enchanting player->SEND_GOSSIP_MENU(4023,_Creature->GetGUID()); if (action == GOSSIP_ACTION_INFO_DEF + 5)//Engineering { player->SEND_POI(368.95, -4723.95, 6, 6, 0, "Mukdrak"); player->SEND_GOSSIP_MENU(4024,_Creature->GetGUID()); } if (action == GOSSIP_ACTION_INFO_DEF + 6)//First Aid { player->SEND_POI(327.17, -4825.62, 6, 6, 0, "Rawrk"); player->SEND_GOSSIP_MENU(4025,_Creature->GetGUID()); } if (action == GOSSIP_ACTION_INFO_DEF + 7)//Fishing { player->SEND_POI(-1065.48, -4777.43, 6, 6, 0, "Lau'Tiki"); player->SEND_GOSSIP_MENU(4026,_Creature->GetGUID()); } if (action == GOSSIP_ACTION_INFO_DEF + 8)//Herbalism { player->SEND_POI(-836.25, -4896.89, 6, 6, 0, "Mishiki"); player->SEND_GOSSIP_MENU(4027,_Creature->GetGUID()); } if (action == GOSSIP_ACTION_INFO_DEF + 9)//Leatherworking player->SEND_GOSSIP_MENU(4028,_Creature->GetGUID()); if (action == GOSSIP_ACTION_INFO_DEF + 10)//Mining { player->SEND_POI(366.94, -4705, 6, 6, 0, "Krunn"); player->SEND_GOSSIP_MENU(4029,_Creature->GetGUID()); } if (action == GOSSIP_ACTION_INFO_DEF + 11)//Skinning player->SEND_GOSSIP_MENU(4030,_Creature->GetGUID()); if (action == GOSSIP_ACTION_INFO_DEF + 12)//Tailoring player->SEND_GOSSIP_MENU(4031,_Creature->GetGUID()); } bool GossipSelect_guard_durotar(Player *player, Creature *_Creature, uint32 sender, uint32 action ) { if (sender == GOSSIP_SENDER_MAIN) SendDefaultMenu_guard_durotar(player, _Creature, action); if (sender == GOSSIP_SENDER_SEC_CLASSTRAIN) SendClassTrainerMenu_guard_durotar(player, _Creature, action); if (sender == GOSSIP_SENDER_SEC_PROFTRAIN) SendProfTrainerMenu_guard_durotar(player, _Creature, action); return true; } /******************************************************* * End of GOSSIP_MENU *******************************************************/ void AddSC_guard_durotar() { Script *newscript; newscript = new Script; newscript->Name="guard_durotar"; newscript->pGossipHello = &GossipHello_guard_durotar; newscript->pGossipSelect = &GossipSelect_guard_durotar; m_scripts[nrscripts++] = newscript; }
[ "Derex101@f2ff2d62-ea21-0410-8eb0-7b0e83e86450" ]
[ [ [ 1, 224 ] ] ]
5998b1a5341ae0146945ded5fe621e5b7f6b080c
3daaefb69e57941b3dee2a616f62121a3939455a
/mgllib/src/3d/Mgl3dDot.cpp
9b6dbac93cff8a30b1af3b2cdf189f2e3f7589c3
[]
no_license
myun2ext/open-mgl-legacy
21ccadab8b1569af8fc7e58cf494aaaceee32f1e
8faf07bad37a742f7174b454700066d53a384eae
refs/heads/master
2016-09-06T11:41:14.108963
2009-12-28T12:06:58
2009-12-28T12:06:58
null
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
465
cpp
////////////////////////////////////////////////////////// // // Mgl3dDot // - MglGraphicManager サーフェスクラス // ////////////////////////////////////////////////////////// #include "stdafx.h" #include "Mgl3dDot.h" // コンストラクタ CMgl3dDots::CMgl3dDots() { m_myudg = NULL; m_d3d = NULL; } // 初期化 void CMgl3dDots::Init( CMglGraphicManager* in_myudg ) { m_myudg = in_myudg; m_d3d = m_myudg->GetD3dDevPtr(); }
[ "myun2@6d62ff88-fa28-0410-b5a4-834eb811a934" ]
[ [ [ 1, 23 ] ] ]
c84b6ea84c208e70a0c503fef59e0291f3ab7648
f02d9d86fb32f26a1f2615be8240539cac92f9c2
/NewSoftSerial.cpp
557b4af9bfd87fb2304fe83b34937786d99554d9
[]
no_license
MarSik/MarSclock
30cc546c5cba98c3d28eaf348de50004e6b6f066
4df639a1b3cd19e75ae9ef599bdab0841e64ce8d
refs/heads/master
2020-12-24T14:36:59.876220
2011-02-22T22:21:57
2011-02-22T22:21:57
1,200,961
0
0
null
null
null
null
UTF-8
C++
false
false
14,292
cpp
/* NewSoftSerial.cpp - Multi-instance software serial library Copyright (c) 2006 David A. Mellis. All rights reserved. -- Interrupt-driven receive and other improvements by ladyada -- Tuning, circular buffer, derivation from class Print, multi-instance support, porting to 8MHz processors, various optimizations, PROGMEM delay tables, inverse logic and direct port writing by Mikal Hart This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA The latest version of this library can always be found at http://arduiniana.org. */ // When set, _DEBUG co-opts pins 11 and 13 for debugging with an // oscilloscope or logic analyzer. Beware: it also slightly modifies // the bit times, so don't rely on it too much at high baud rates #define _DEBUG 0 #define _DEBUG_PIN1 11 #define _DEBUG_PIN2 13 // // Includes // #include <avr/interrupt.h> #include <avr/pgmspace.h> #include "WConstants.h" #include "pins_arduino.h" #include "NewSoftSerial.h" // Abstractions for maximum portability between processors // These are macros to associate pins to pin change interrupts #if !defined(digitalPinToPCICR) // Courtesy Paul Stoffregen #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) #define digitalPinToPCICR(p) (((p) >= 0 && (p) <= 21) ? (&PCICR) : ((uint8_t *)NULL)) #define digitalPinToPCICRbit(p) (((p) <= 7) ? 2 : (((p) <= 13) ? 0 : 1)) #define digitalPinToPCMSK(p) (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)NULL)))) #define digitalPinToPCMSKbit(p) (((p) <= 7) ? (p) : (((p) <= 13) ? ((p) - 8) : ((p) - 14))) #else #define digitalPinToPCICR(p) ((uint8_t *)NULL) #define digitalPinToPCICRbit(p) 0 #define digitalPinToPCMSK(p) ((uint8_t *)NULL) #define digitalPinToPCMSKbit(p) 0 #endif #endif // // Lookup table // typedef struct _DELAY_TABLE { long baud; unsigned short rx_delay_centering; unsigned short rx_delay_intrabit; unsigned short rx_delay_stopbit; unsigned short tx_delay; } DELAY_TABLE; #if F_CPU == 16000000 static const DELAY_TABLE PROGMEM table[] = { // baud rxcenter rxintra rxstop tx { 115200, 1, 17, 17, 12, }, { 57600, 10, 37, 37, 33, }, { 38400, 25, 57, 57, 54, }, { 31250, 31, 70, 70, 68, }, { 28800, 34, 77, 77, 74, }, { 19200, 54, 117, 117, 114, }, { 14400, 74, 156, 156, 153, }, { 9600, 114, 236, 236, 233, }, { 4800, 233, 474, 474, 471, }, { 2400, 471, 950, 950, 947, }, { 1200, 947, 1902, 1902, 1899, }, { 300, 3804, 7617, 7617, 7614, }, }; const int XMIT_START_ADJUSTMENT = 5; #elif F_CPU == 8000000 static const DELAY_TABLE table[] PROGMEM = { // baud rxcenter rxintra rxstop tx { 115200, 1, 5, 5, 3, }, { 57600, 1, 15, 15, 13, }, { 38400, 2, 25, 26, 23, }, { 31250, 7, 32, 33, 29, }, { 28800, 11, 35, 35, 32, }, { 19200, 20, 55, 55, 52, }, { 14400, 30, 75, 75, 72, }, { 9600, 50, 114, 114, 112, }, { 4800, 110, 233, 233, 230, }, { 2400, 229, 472, 472, 469, }, { 1200, 467, 948, 948, 945, }, { 300, 1895, 3805, 3805, 3802, }, }; const int XMIT_START_ADJUSTMENT = 4; #elif F_CPU == 20000000 // 20MHz support courtesy of the good people at macegr.com. // Thanks, Garrett! static const DELAY_TABLE PROGMEM table[] = { // baud rxcenter rxintra rxstop tx { 115200, 3, 21, 21, 18, }, { 57600, 20, 43, 43, 41, }, { 38400, 37, 73, 73, 70, }, { 31250, 45, 89, 89, 88, }, { 28800, 46, 98, 98, 95, }, { 19200, 71, 148, 148, 145, }, { 14400, 96, 197, 197, 194, }, { 9600, 146, 297, 297, 294, }, { 4800, 296, 595, 595, 592, }, { 2400, 592, 1189, 1189, 1186, }, { 1200, 1187, 2379, 2379, 2376, }, { 300, 4759, 9523, 9523, 9520, }, }; const int XMIT_START_ADJUSTMENT = 6; #else #error This version of NewSoftSerial supports only 20, 16 and 8MHz processors #endif // // Statics // NewSoftSerial *NewSoftSerial::active_object = 0; char NewSoftSerial::_receive_buffer[_NewSS_MAX_RX_BUFF]; volatile uint8_t NewSoftSerial::_receive_buffer_tail = 0; volatile uint8_t NewSoftSerial::_receive_buffer_head = 0; // // Debugging // // This function generates a brief pulse // for debugging or measuring on an oscilloscope. inline void DebugPulse(uint8_t pin, uint8_t count) { #if _DEBUG volatile uint8_t *pport = portOutputRegister(digitalPinToPort(pin)); uint8_t val = *pport; while (count--) { *pport = val | digitalPinToBitMask(pin); *pport = val; } #endif } // // Private methods // /* static */ inline void NewSoftSerial::tunedDelay(uint16_t delay) { uint8_t tmp=0; asm volatile("sbiw %0, 0x01 \n\t" "ldi %1, 0xFF \n\t" "cpi %A0, 0xFF \n\t" "cpc %B0, %1 \n\t" "brne .-10 \n\t" : "+r" (delay), "+a" (tmp) : "0" (delay) ); } // This function sets the current object as the "active" // one and returns true if it replaces another bool NewSoftSerial::activate(void) { if (active_object != this) { _buffer_overflow = false; uint8_t oldSREG = SREG; cli(); _receive_buffer_head = _receive_buffer_tail = 0; active_object = this; SREG = oldSREG; return true; } return false; } // // The receive routine called by the interrupt handler // void NewSoftSerial::recv() { #if GCC_VERSION < 40302 // Work-around for avr-gcc 4.3.0 OSX version bug // Preserve the registers that the compiler misses // (courtesy of Arduino forum user *etracer*) asm volatile( "push r18 \n\t" "push r19 \n\t" "push r20 \n\t" "push r21 \n\t" "push r22 \n\t" "push r23 \n\t" "push r26 \n\t" "push r27 \n\t" ::); #endif uint8_t d = 0; // If RX line is high, then we don't see any start bit // so interrupt is probably not for us if (_inverse_logic ? rx_pin_read() : !rx_pin_read()) { // Wait approximately 1/2 of a bit width to "center" the sample tunedDelay(_rx_delay_centering); DebugPulse(_DEBUG_PIN2, 1); // Read each of the 8 bits for (uint8_t i=0x1; i; i <<= 1) { tunedDelay(_rx_delay_intrabit); DebugPulse(_DEBUG_PIN2, 1); uint8_t noti = ~i; if (rx_pin_read()) d |= i; else // else clause added to ensure function timing is ~balanced d &= noti; } // skip the stop bit tunedDelay(_rx_delay_stopbit); DebugPulse(_DEBUG_PIN2, 1); if (_inverse_logic) d = ~d; // if buffer full, set the overflow flag and return if ((_receive_buffer_tail + 1) % _NewSS_MAX_RX_BUFF != _receive_buffer_head) { // save new data in buffer: tail points to where byte goes _receive_buffer[_receive_buffer_tail] = d; // save new byte _receive_buffer_tail = (_receive_buffer_tail + 1) % _NewSS_MAX_RX_BUFF; } else { #if _DEBUG // for scope: pulse pin as overflow indictator DebugPulse(_DEBUG_PIN1, 1); #endif _buffer_overflow = true; } } #if GCC_VERSION < 40302 // Work-around for avr-gcc 4.3.0 OSX version bug // Restore the registers that the compiler misses asm volatile( "pop r27 \n\t" "pop r26 \n\t" "pop r23 \n\t" "pop r22 \n\t" "pop r21 \n\t" "pop r20 \n\t" "pop r19 \n\t" "pop r18 \n\t" ::); #endif } void NewSoftSerial::tx_pin_write(uint8_t pin_state) { if (pin_state == LOW) *_transmitPortRegister &= ~_transmitBitMask; else *_transmitPortRegister |= _transmitBitMask; } uint8_t NewSoftSerial::rx_pin_read() { return *_receivePortRegister & _receiveBitMask; } // // Interrupt handling // /* static */ inline void NewSoftSerial::handle_interrupt() { if (active_object) { active_object->recv(); } } /* #if defined(PCINT0_vect) ISR(PCINT0_vect) { NewSoftSerial::handle_interrupt(); } #endif */ #if defined(PCINT1_vect) ISR(PCINT1_vect) { NewSoftSerial::handle_interrupt(); } #endif #if defined(PCINT2_vect) ISR(PCINT2_vect) { NewSoftSerial::handle_interrupt(); } #endif #if defined(PCINT3_vect) ISR(PCINT3_vect) { NewSoftSerial::handle_interrupt(); } #endif // // Constructor // NewSoftSerial::NewSoftSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic /* = false */) : _rx_delay_centering(0), _rx_delay_intrabit(0), _rx_delay_stopbit(0), _tx_delay(0), _buffer_overflow(false), _inverse_logic(inverse_logic) { setTX(transmitPin); setRX(receivePin); } // // Destructor // NewSoftSerial::~NewSoftSerial() { end(); } void NewSoftSerial::setTX(uint8_t tx) { pinMode(tx, OUTPUT); digitalWrite(tx, HIGH); _transmitBitMask = digitalPinToBitMask(tx); uint8_t port = digitalPinToPort(tx); _transmitPortRegister = portOutputRegister(port); } void NewSoftSerial::setRX(uint8_t rx) { pinMode(rx, INPUT); if (!_inverse_logic) digitalWrite(rx, HIGH); // pullup for normal logic! _receivePin = rx; _receiveBitMask = digitalPinToBitMask(rx); uint8_t port = digitalPinToPort(rx); _receivePortRegister = portInputRegister(port); } // // Public methods // void NewSoftSerial::begin(long speed) { _rx_delay_centering = _rx_delay_intrabit = _rx_delay_stopbit = _tx_delay = 0; for (unsigned i=0; i<sizeof(table)/sizeof(table[0]); ++i) { long baud = pgm_read_dword(&table[i].baud); if (baud == speed) { _rx_delay_centering = pgm_read_word(&table[i].rx_delay_centering); _rx_delay_intrabit = pgm_read_word(&table[i].rx_delay_intrabit); _rx_delay_stopbit = pgm_read_word(&table[i].rx_delay_stopbit); _tx_delay = pgm_read_word(&table[i].tx_delay); break; } } // Set up RX interrupts, but only if we have a valid RX baud rate if (_rx_delay_stopbit) { if (digitalPinToPCICR(_receivePin)) { *digitalPinToPCICR(_receivePin) |= _BV(digitalPinToPCICRbit(_receivePin)); *digitalPinToPCMSK(_receivePin) |= _BV(digitalPinToPCMSKbit(_receivePin)); } tunedDelay(_tx_delay); // if we were low this establishes the end } #if _DEBUG pinMode(_DEBUG_PIN1, OUTPUT); pinMode(_DEBUG_PIN2, OUTPUT); #endif activate(); } void NewSoftSerial::end() { if (digitalPinToPCMSK(_receivePin)) *digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin)); } // Read data from buffer int NewSoftSerial::read(void) { uint8_t d; // A newly activated object never has any rx data if (activate()) return -1; // Empty buffer? if (_receive_buffer_head == _receive_buffer_tail) return -1; // Read from "head" d = _receive_buffer[_receive_buffer_head]; // grab next byte _receive_buffer_head = (_receive_buffer_head + 1) % _NewSS_MAX_RX_BUFF; return d; } uint8_t NewSoftSerial::available(void) { // A newly activated object never has any rx data if (activate()) return 0; return (_receive_buffer_tail + _NewSS_MAX_RX_BUFF - _receive_buffer_head) % _NewSS_MAX_RX_BUFF; } void NewSoftSerial::write(uint8_t b) { if (_tx_delay == 0) return; activate(); uint8_t oldSREG = SREG; cli(); // turn off interrupts for a clean txmit // Write the start bit tx_pin_write(_inverse_logic ? HIGH : LOW); tunedDelay(_tx_delay + XMIT_START_ADJUSTMENT); // Write each of the 8 bits if (_inverse_logic) { for (byte mask = 0x01; mask; mask <<= 1) { if (b & mask) // choose bit tx_pin_write(LOW); // send 1 else tx_pin_write(HIGH); // send 0 tunedDelay(_tx_delay); } tx_pin_write(LOW); // restore pin to natural state } else { for (byte mask = 0x01; mask; mask <<= 1) { if (b & mask) // choose bit tx_pin_write(HIGH); // send 1 else tx_pin_write(LOW); // send 0 tunedDelay(_tx_delay); } tx_pin_write(HIGH); // restore pin to natural state } SREG = oldSREG; // turn interrupts back on tunedDelay(_tx_delay); } #if !defined(cbi) #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) #endif void NewSoftSerial::enable_timer0(bool enable) { if (enable) #if defined(__AVR_ATmega8__) sbi(TIMSK, TOIE0); #else sbi(TIMSK0, TOIE0); #endif else #if defined(__AVR_ATmega8__) cbi(TIMSK, TOIE0); #else cbi(TIMSK0, TOIE0); #endif } void NewSoftSerial::flush() { if (active_object == this) { uint8_t oldSREG = SREG; cli(); _receive_buffer_head = _receive_buffer_tail = 0; SREG = oldSREG; } }
[ [ [ 1, 541 ] ] ]
8bb8ff970b334d3ea6f02b24043e1f6708b951e9
037faae47a5b22d3e283555e6b5ac2a0197faf18
/plugins/pad/zeropad/Linux/linux.cpp
64df9abbde6d81bcf6888a7cd626dfaf28421f4f
[]
no_license
isabella232/pcsx2-sourceforge
6e5aac8d0b476601bfc8fa83ded66c1564b8c588
dbb2c3a010081b105a8cba0c588f1e8f4e4505c6
refs/heads/master
2023-03-18T22:23:15.102593
2008-11-17T20:10:17
2008-11-17T20:10:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
25,024
cpp
/* ZeroPAD - author: zerofrog(@gmail.com) * Copyright (C) 2006-2007 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <string.h> #include <gtk/gtk.h> #include <pthread.h> #define JOYSTICK_SUPPORT #ifdef JOYSTICK_SUPPORT #include <SDL/SDL.h> #endif #include "zeropad.h" extern "C" { #include "interface.h" #include "support.h" #include "callbacks.h" } Display *GSdsp; static pthread_spinlock_t s_mutexStatus; static u32 s_keyPress[2], s_keyRelease[2]; // thread safe static u32 s_bSDLInit = false; // holds all joystick info class JoystickInfo { public: JoystickInfo(); ~JoystickInfo() { Destroy(); } void Destroy(); // opens handles to all possible joysticks static void EnumerateJoysticks(vector<JoystickInfo*>& vjoysticks); bool Init(int id, bool bStartThread=true); // opens a handle and gets information void Assign(int pad); // assigns a joystick to a pad void TestForce(); const string& GetName() { return devname; } int GetNumButtons() { return numbuttons; } int GetNumAxes() { return numaxes; } int GetNumPOV() { return numpov; } int GetId() { return _id; } int GetPAD() { return pad; } int GetDeadzone(int axis) { return deadzone; } void SaveState(); int GetButtonState(int i) { return vbutstate[i]; } int GetAxisState(int i) { return vaxisstate[i]; } void SetButtonState(int i, int state) { vbutstate[i] = state; } void SetAxisState(int i, int value) { vaxisstate[i] = value; } #ifdef JOYSTICK_SUPPORT SDL_Joystick* GetJoy() { return joy; } #endif private: string devname; // pretty device name int _id; int numbuttons, numaxes, numpov; int axisrange, deadzone; int pad; vector<int> vbutstate, vaxisstate; #ifdef JOYSTICK_SUPPORT SDL_Joystick* joy; #endif }; static vector<JoystickInfo*> s_vjoysticks; extern string s_strIniPath; void SaveConfig() { int i, j; FILE *f; char cfg[255]; strcpy(cfg, s_strIniPath.c_str()); f = fopen(cfg,"w"); if (f == NULL) { printf("ZeroPAD: failed to save ini %s\n", s_strIniPath.c_str()); return; } for (j=0; j<2; j++) { for (i=0; i<PADKEYS; i++) { fprintf(f, "[%d][%d] = 0x%lx\n", j, i, conf.keys[j][i]); } } fprintf(f, "log = %d\n", conf.log); fprintf(f, "options = %d\n", conf.options); fclose(f); } static char* s_pGuiKeyMap[] = { "L2", "R2", "L1", "R1", "Triangle", "Circle", "Cross", "Square", "Select", "L3", "R3", "Start", "Up", "Right", "Down", "Left", "Lx", "Rx", "Ly", "Ry" }; string GetLabelFromButton(const char* buttonname) { string label = "e"; label += buttonname; return label; } void LoadConfig() { FILE *f; char str[256]; char cfg[255]; int i, j; memset(&conf, 0, sizeof(conf)); conf.keys[0][0] = XK_a; // L2 conf.keys[0][1] = XK_semicolon; // R2 conf.keys[0][2] = XK_w; // L1 conf.keys[0][3] = XK_p; // R1 conf.keys[0][4] = XK_i; // TRIANGLE conf.keys[0][5] = XK_l; // CIRCLE conf.keys[0][6] = XK_k; // CROSS conf.keys[0][7] = XK_j; // SQUARE conf.keys[0][8] = XK_v; // SELECT conf.keys[0][11] = XK_n;// START conf.keys[0][12] = XK_e; // UP conf.keys[0][13] = XK_f; // RIGHT conf.keys[0][14] = XK_d; // DOWN conf.keys[0][15] = XK_s; // LEFT conf.log = 0; strcpy(cfg, s_strIniPath.c_str()); f = fopen(cfg, "r"); if (f == NULL) { printf("ZeroPAD: failed to load ini %s\n", s_strIniPath.c_str()); SaveConfig();//save and return return; } for (j=0; j<2; j++) { for (i=0; i<PADKEYS; i++) { sprintf(str, "[%d][%d] = 0x%%x\n", j, i); fscanf(f, str, &conf.keys[j][i]); } } fscanf(f, "log = %d\n", &conf.log); fscanf(f, "options = %d\n", &conf.options); fclose(f); } GtkWidget *MsgDlg; void OnMsg_Ok() { gtk_widget_destroy(MsgDlg); gtk_main_quit(); } void SysMessage(char *fmt, ...) { GtkWidget *Ok,*Txt; GtkWidget *Box,*Box1; va_list list; char msg[512]; va_start(list, fmt); vsprintf(msg, fmt, list); va_end(list); if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0; MsgDlg = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER); gtk_window_set_title(GTK_WINDOW(MsgDlg), "GSsoft Msg"); gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 5); Box = gtk_vbox_new(5, 0); gtk_container_add(GTK_CONTAINER(MsgDlg), Box); gtk_widget_show(Box); Txt = gtk_label_new(msg); gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5); gtk_widget_show(Txt); Box1 = gtk_hbutton_box_new(); gtk_box_pack_start(GTK_BOX(Box), Box1, FALSE, FALSE, 0); gtk_widget_show(Box1); Ok = gtk_button_new_with_label("Ok"); gtk_signal_connect (GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL); gtk_container_add(GTK_CONTAINER(Box1), Ok); GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT); gtk_widget_show(Ok); gtk_widget_show(MsgDlg); gtk_main(); } s32 _PADopen(void *pDsp) { GSdsp = *(Display**)pDsp; pthread_spin_init(&s_mutexStatus, PTHREAD_PROCESS_PRIVATE); s_keyPress[0] = s_keyPress[1] = 0; s_keyRelease[0] = s_keyRelease[1] = 0; XAutoRepeatOff(GSdsp); JoystickInfo::EnumerateJoysticks(s_vjoysticks); return 0; } void _PADclose() { pthread_spin_destroy(&s_mutexStatus); XAutoRepeatOn(GSdsp); vector<JoystickInfo*>::iterator it; FORIT(it, s_vjoysticks) delete *it; s_vjoysticks.clear(); } void _PADupdate(int pad) { pthread_spin_lock(&s_mutexStatus); status[pad] |= s_keyRelease[pad]; status[pad] &= ~s_keyPress[pad]; s_keyRelease[pad] = 0; s_keyPress[pad] = 0; pthread_spin_unlock(&s_mutexStatus); } int _GetJoystickIdFromPAD(int pad) { // select the right joystick id int joyid = -1; for(int i = 0; i < PADKEYS; ++i) { if( IS_JOYSTICK(conf.keys[pad][i]) || IS_JOYBUTTONS(conf.keys[pad][i]) ) { joyid = PAD_GETJOYID(conf.keys[pad][i]); break; } } return joyid; } void CALLBACK PADupdate(int pad) { int i; XEvent E; int keyPress=0,keyRelease=0; KeySym key; // keyboard input while (XPending(GSdsp) > 0) { XNextEvent(GSdsp, &E); switch (E.type) { case KeyPress: //_KeyPress(pad, XLookupKeysym((XKeyEvent *)&E, 0)); break; key = XLookupKeysym((XKeyEvent *)&E, 0); for (i=0; i<PADKEYS; i++) { if (key == conf.keys[pad][i]) { keyPress|=(1<<i); keyRelease&=~(1<<i); break; } } event.event = KEYPRESS; event.key = key; break; case KeyRelease: key = XLookupKeysym((XKeyEvent *)&E, 0); //_KeyRelease(pad, XLookupKeysym((XKeyEvent *)&E, 0)); for (i=0; i<PADKEYS; i++) { if (key == conf.keys[pad][i]) { keyPress&=~(1<<i); keyRelease|= (1<<i); break; } } event.event = KEYRELEASE; event.key = key; break; case FocusIn: XAutoRepeatOff(GSdsp); break; case FocusOut: XAutoRepeatOn(GSdsp); break; } } // joystick info #ifdef JOYSTICK_SUPPORT SDL_JoystickUpdate(); for (int i=0; i<PADKEYS; i++) { int key = conf.keys[pad][i]; JoystickInfo* pjoy = NULL; if( IS_JOYBUTTONS(key) ) { int joyid = PAD_GETJOYID(key); if( joyid >= 0 && joyid < (int)s_vjoysticks.size()) { pjoy = s_vjoysticks[joyid]; if( SDL_JoystickGetButton((pjoy)->GetJoy(), PAD_GETJOYBUTTON(key)) ) { status[(pjoy)->GetPAD()] &= ~(1<<i); // pressed } else status[(pjoy)->GetPAD()] |= (1<<i); // pressed } } else if( IS_JOYSTICK(key) ) { int joyid = PAD_GETJOYID(key); if( joyid >= 0 && joyid < (int)s_vjoysticks.size()) { pjoy = s_vjoysticks[joyid]; int value = SDL_JoystickGetAxis((pjoy)->GetJoy(), PAD_GETJOYSTICK_AXIS(key)); int pad = (pjoy)->GetPAD(); switch(i) { case PAD_LX: if( abs(value) > (pjoy)->GetDeadzone(value) ) { g_lanalog[pad].x = value/256; if( conf.options&PADOPTION_REVERTLX ) g_lanalog[pad].x = -g_lanalog[pad].x; g_lanalog[pad].x += 0x80; } else g_lanalog[pad].x = 0x80; break; case PAD_LY: if( abs(value) > (pjoy)->GetDeadzone(value) ) { g_lanalog[pad].y = value/256; if( conf.options&PADOPTION_REVERTLX ) g_lanalog[pad].y = -g_lanalog[pad].y; g_lanalog[pad].y += 0x80; } else g_lanalog[pad].y = 0x80; break; case PAD_RX: if( abs(value) > (pjoy)->GetDeadzone(value) ) { g_ranalog[pad].x = value/256; if( conf.options&PADOPTION_REVERTLX ) g_ranalog[pad].x = -g_ranalog[pad].x; g_ranalog[pad].x += 0x80; } else g_ranalog[pad].x = 0x80; break; case PAD_RY: if( abs(value) > (pjoy)->GetDeadzone(value) ) { g_ranalog[pad].y = value/256; if( conf.options&PADOPTION_REVERTLX ) g_ranalog[pad].y = -g_ranalog[pad].y; g_ranalog[pad].y += 0x80; } else g_ranalog[pad].y = 0x80; break; } } } else if( IS_POV(key) ) { int joyid = PAD_GETJOYID(key); if( joyid >= 0 && joyid < (int)s_vjoysticks.size()) { pjoy = s_vjoysticks[joyid]; int value = SDL_JoystickGetAxis((pjoy)->GetJoy(), PAD_GETJOYSTICK_AXIS(key)); int pad = (pjoy)->GetPAD(); if( PAD_GETPOVSIGN(key) && (value<-2048) ) status[pad] &= ~(1<<i); else if( !PAD_GETPOVSIGN(key) && (value>2048) ) status[pad] &= ~(1<<i); else status[pad] |= (1<<i); } } } #endif pthread_spin_lock(&s_mutexStatus); s_keyPress[pad] |= keyPress; s_keyPress[pad] &= ~keyRelease; s_keyRelease[pad] |= keyRelease; s_keyRelease[pad] &= ~keyPress; pthread_spin_unlock(&s_mutexStatus); } static GtkWidget *Conf=NULL, *s_devicecombo=NULL; static int s_selectedpad = 0; void UpdateConf(int pad) { s_selectedpad = pad; int i; GtkWidget *Btn; for (i=0; i<ARRAYSIZE(s_pGuiKeyMap); i++) { if( s_pGuiKeyMap[i] == NULL ) continue; Btn = lookup_widget(Conf, GetLabelFromButton(s_pGuiKeyMap[i]).c_str()); if( Btn == NULL ) { printf("ZeroPAD: cannot find key %s\n", s_pGuiKeyMap[i]); continue; } string tmp; if( IS_KEYBOARD(conf.keys[pad][i]) ) { char* pstr = XKeysymToString(PAD_GETKEY(conf.keys[pad][i])); if( pstr != NULL ) tmp = pstr; } else if( IS_JOYBUTTONS(conf.keys[pad][i]) ) { tmp.resize(20); sprintf(&tmp[0], "JBut %d", PAD_GETJOYBUTTON(conf.keys[pad][i])); } else if( IS_JOYSTICK(conf.keys[pad][i]) ) { tmp.resize(20); sprintf(&tmp[0], "JAxis %d", PAD_GETJOYSTICK_AXIS(conf.keys[pad][i])); } else if( IS_POV(conf.keys[pad][i]) ) { tmp.resize(20); sprintf(&tmp[0], "JPOV %d%s", PAD_GETJOYSTICK_AXIS(conf.keys[pad][i]), PAD_GETPOVSIGN(conf.keys[pad][i])?"-":"+"); } if (tmp.size() > 0) { gtk_entry_set_text(GTK_ENTRY(Btn), tmp.c_str()); } else gtk_entry_set_text(GTK_ENTRY(Btn), "Unknown"); gtk_object_set_user_data(GTK_OBJECT(Btn), (void*)(PADKEYS*pad+i)); } // check bounds int joyid = _GetJoystickIdFromPAD(pad); if( joyid < 0 || joyid >= (int)s_vjoysticks.size() ) { // get first unused joystick for(joyid = 0; joyid < s_vjoysticks.size(); ++joyid) { if( s_vjoysticks[joyid]->GetPAD() < 0 ) break; } } if( joyid >= 0 && joyid < (int)s_vjoysticks.size() ) { // select the combo gtk_combo_box_set_active(GTK_COMBO_BOX(s_devicecombo), joyid); } else gtk_combo_box_set_active(GTK_COMBO_BOX(s_devicecombo), s_vjoysticks.size()); // no gamepad int padopts = conf.options>>(16*pad); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "checkbutton_reverselx")), padopts&PADOPTION_REVERTLX); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "checkbutton_reversely")), padopts&PADOPTION_REVERTLY); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "checkbutton_reverserx")), padopts&PADOPTION_REVERTRX); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "checkbutton_reversery")), padopts&PADOPTION_REVERTRY); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "forcefeedback")), padopts&PADOPTION_FORCEFEEDBACK); } void OnConf_Key(GtkButton *button, gpointer user_data) { GdkEvent *ev; GtkWidget* label = lookup_widget(Conf, GetLabelFromButton(gtk_button_get_label(button)).c_str()); if( label == NULL ) { printf("couldn't find correct label\n"); return; } int id = (int)(uptr)gtk_object_get_user_data(GTK_OBJECT(label)); int pad = id/PADKEYS; int key = id%PADKEYS; unsigned long *pkey = &conf.keys[pad][key]; vector<JoystickInfo*>::iterator itjoy; // save the states #ifdef JOYSTICK_SUPPORT SDL_JoystickUpdate(); FORIT(itjoy, s_vjoysticks) (*itjoy)->SaveState(); #endif for (;;) { ev = gdk_event_get(); if (ev != NULL) { if (ev->type == GDK_KEY_PRESS) { *pkey = ev->key.keyval; char* tmp = XKeysymToString(*pkey); if (tmp != NULL) gtk_entry_set_text(GTK_ENTRY(label), tmp); else gtk_entry_set_text(GTK_ENTRY(label), "Unknown"); return; } } #ifdef JOYSTICK_SUPPORT SDL_JoystickUpdate(); FORIT(itjoy, s_vjoysticks) { // MAKE sure to look for changes in the state!! for(int i = 0; i < (*itjoy)->GetNumButtons(); ++i) { int but = SDL_JoystickGetButton((*itjoy)->GetJoy(), i); if( but != (*itjoy)->GetButtonState(i) ) { if( !but ) { // released, we don't really want this (*itjoy)->SetButtonState(i, 0); break; } *pkey = PAD_JOYBUTTON((*itjoy)->GetId(), i); char str[32]; sprintf(str, "JBut %d", i); gtk_entry_set_text(GTK_ENTRY(label), str); return; } } for(int i = 0; i < (*itjoy)->GetNumAxes(); ++i) { int value = SDL_JoystickGetAxis((*itjoy)->GetJoy(), i); if( value != (*itjoy)->GetAxisState(i) ) { if( abs(value) <= (*itjoy)->GetAxisState(i)) {// we don't want this // released, we don't really want this (*itjoy)->SetButtonState(i, value); break; } if( abs(value) > 0x3fff ) { if( key < 16 ) { // POV *pkey = PAD_POV((*itjoy)->GetId(), value<0, i); char str[32]; sprintf(str, "JPOV %d%s", i, value<0?"-":"+"); gtk_entry_set_text(GTK_ENTRY(label), str); return; } else { // axis *pkey = PAD_JOYSTICK((*itjoy)->GetId(), i); char str[32]; sprintf(str, "JAxis %d", i); gtk_entry_set_text(GTK_ENTRY(label), str); return; } } } } } #endif } } void OnConf_Pad1(GtkButton *button, gpointer user_data) { if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)) ) UpdateConf(0); } void OnConf_Pad2(GtkButton *button, gpointer user_data) { if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)) ) UpdateConf(1); } void OnConf_Ok(GtkButton *button, gpointer user_data) { // conf.analog = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(Analog)); SaveConfig(); gtk_widget_destroy(Conf); gtk_main_quit(); } void OnConf_Cancel(GtkButton *button, gpointer user_data) { gtk_widget_destroy(Conf); gtk_main_quit(); LoadConfig(); // load previous config } void CALLBACK PADconfigure() { LoadConfig(); Conf = create_Conf(); // recreate JoystickInfo::EnumerateJoysticks(s_vjoysticks); s_devicecombo = lookup_widget(Conf, "joydevicescombo"); // fill the combo char str[255]; vector<JoystickInfo*>::iterator it; FORIT(it, s_vjoysticks) { sprintf(str, "%d: %s - but: %d, axes: %d, pov: %d", (*it)->GetId(), (*it)->GetName().c_str(), (*it)->GetNumButtons(), (*it)->GetNumAxes(), (*it)->GetNumPOV()); gtk_combo_box_append_text (GTK_COMBO_BOX (s_devicecombo), str); } gtk_combo_box_append_text (GTK_COMBO_BOX (s_devicecombo), "No Gamepad"); UpdateConf(0); gtk_widget_show_all(Conf); gtk_main(); } // GUI event handlers void on_joydevicescombo_changed(GtkComboBox *combobox, gpointer user_data) { int joyid = gtk_combo_box_get_active(combobox); // unassign every joystick with this pad for(int i = 0; i < (int)s_vjoysticks.size(); ++i) { if( s_vjoysticks[i]->GetPAD() == s_selectedpad ) s_vjoysticks[i]->Assign(-1); } if( joyid >= 0 && joyid < (int)s_vjoysticks.size() ) s_vjoysticks[joyid]->Assign(s_selectedpad); } void on_checkbutton_reverselx_toggled(GtkToggleButton *togglebutton, gpointer user_data) { int mask = PADOPTION_REVERTLX<<(16*s_selectedpad); if( gtk_toggle_button_get_active(togglebutton) ) conf.options |= mask; else conf.options &= ~mask; } void on_checkbutton_reversely_toggled(GtkToggleButton *togglebutton, gpointer user_data) { int mask = PADOPTION_REVERTLY<<(16*s_selectedpad); if( gtk_toggle_button_get_active(togglebutton) ) conf.options |= mask; else conf.options &= ~mask; } void on_checkbutton_reverserx_toggled(GtkToggleButton *togglebutton, gpointer user_data) { int mask = PADOPTION_REVERTRX<<(16*s_selectedpad); if( gtk_toggle_button_get_active(togglebutton) ) conf.options |= mask; else conf.options &= ~mask; } void on_checkbutton_reversery_toggled(GtkToggleButton *togglebutton, gpointer user_data) { int mask = PADOPTION_REVERTRY<<(16*s_selectedpad); if( gtk_toggle_button_get_active(togglebutton) ) conf.options |= mask; else conf.options &= ~mask; } void on_forcefeedback_toggled(GtkToggleButton *togglebutton, gpointer user_data) { int mask = PADOPTION_REVERTLX<<(16*s_selectedpad); if( gtk_toggle_button_get_active(togglebutton) ) { conf.options |= mask; int joyid = gtk_combo_box_get_active(GTK_COMBO_BOX(s_devicecombo)); if( joyid >= 0 && joyid < (int)s_vjoysticks.size() ) s_vjoysticks[joyid]->TestForce(); } else conf.options &= ~mask; } GtkWidget *About = NULL; void OnAbout_Ok(GtkButton *button, gpointer user_data) { gtk_widget_destroy(About); gtk_main_quit(); } void CALLBACK PADabout() { About = create_About(); gtk_widget_show_all(About); gtk_main(); } s32 CALLBACK PADtest() { return 0; } ////////////////////////// // Joystick definitions // ////////////////////////// // opens handles to all possible joysticks void JoystickInfo::EnumerateJoysticks(vector<JoystickInfo*>& vjoysticks) { #ifdef JOYSTICK_SUPPORT if( !s_bSDLInit ) { if( SDL_Init(SDL_INIT_JOYSTICK) < 0 ) return; SDL_JoystickEventState(SDL_QUERY); s_bSDLInit = true; } vector<JoystickInfo*>::iterator it; FORIT(it, vjoysticks) delete *it; vjoysticks.resize(SDL_NumJoysticks()); for(int i = 0; i < (int)vjoysticks.size(); ++i) { vjoysticks[i] = new JoystickInfo(); vjoysticks[i]->Init(i, true); } // set the pads for(int pad = 0; pad < 2; ++pad) { // select the right joystick id int joyid = -1; for(int i = 0; i < PADKEYS; ++i) { if( IS_JOYSTICK(conf.keys[pad][i]) || IS_JOYBUTTONS(conf.keys[pad][i]) ) { joyid = PAD_GETJOYID(conf.keys[pad][i]); break; } } if( joyid >= 0 && joyid < (int)s_vjoysticks.size() ) s_vjoysticks[joyid]->Assign(pad); } #endif } JoystickInfo::JoystickInfo() { #ifdef JOYSTICK_SUPPORT joy = NULL; #endif _id = -1; pad = -1; axisrange = 0x7fff; deadzone = 2000; } void JoystickInfo::Destroy() { #ifdef JOYSTICK_SUPPORT if( joy != NULL ) { if( SDL_JoystickOpened(_id) ) SDL_JoystickClose(joy); joy = NULL; } #endif } bool JoystickInfo::Init(int id, bool bStartThread) { #ifdef JOYSTICK_SUPPORT Destroy(); _id = id; joy = SDL_JoystickOpen(id); if( joy == NULL ) { printf("failed to open joystick %d\n", id); return false; } numaxes = SDL_JoystickNumAxes(joy); numbuttons = SDL_JoystickNumButtons(joy); numpov = SDL_JoystickNumHats(joy); devname = SDL_JoystickName(id); vbutstate.resize(numbuttons); vaxisstate.resize(numbuttons); return true; #else return false; #endif } // assigns a joystick to a pad void JoystickInfo::Assign(int newpad) { if( pad == newpad ) return; pad = newpad; if( pad >= 0 ) { for(int i = 0; i < PADKEYS; ++i) { if( IS_JOYBUTTONS(conf.keys[pad][i]) ) { conf.keys[pad][i] = PAD_JOYBUTTON(_id, PAD_GETJOYBUTTON(conf.keys[pad][i])); } else if( IS_JOYSTICK(conf.keys[pad][i]) ) { conf.keys[pad][i] = PAD_JOYSTICK(_id, PAD_GETJOYBUTTON(conf.keys[pad][i])); } } } } void JoystickInfo::SaveState() { #ifdef JOYSTICK_SUPPORT for(int i = 0; i < numbuttons; ++i) vbutstate[i] = SDL_JoystickGetButton(joy, i); for(int i = 0; i < numaxes; ++i) vaxisstate[i] = SDL_JoystickGetAxis(joy, i); #endif } void JoystickInfo::TestForce() { }
[ "zerofrog@23c756db-88ba-2448-99d7-e6e4c676ec84" ]
[ [ [ 1, 829 ] ] ]
a6662e43f02ea480ab419a27079e31370b45e27a
40b507c2dde13d14bb75ee1b3c16b4f3f82912d1
/extensions/bintools/CallWrapper.cpp
41392e2bff3114b86a005385f2504ec5b6694972
[]
no_license
Nephyrin/-furry-octo-nemesis
5da2ef75883ebc4040e359a6679da64ad8848020
dd441c39bd74eda2b9857540dcac1d98706de1de
refs/heads/master
2016-09-06T01:12:49.611637
2008-09-14T08:42:28
2008-09-14T08:42:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,052
cpp
/** * vim: set ts=4 : * ============================================================================= * SourceMod BinTools Extension * Copyright (C) 2004-2007 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 "CallWrapper.h" CallWrapper::CallWrapper(CallConvention cv, const PassInfo *paramInfo, const PassInfo *retInfo, unsigned int numParams) { m_Cv = cv; if (numParams) { m_Params = new PassEncode[numParams]; for (size_t i=0; i<numParams; i++) { m_Params[i].info = paramInfo[i]; } } else { m_Params = NULL; } if (retInfo) { m_RetParam = new PassInfo; *m_RetParam = *retInfo; } else { m_RetParam = NULL; } m_NumParams = numParams; /* Calculate virtual stack offsets for each parameter */ size_t offs = 0; if (cv == CallConv_ThisCall) { offs += sizeof(void *); } for (size_t i=0; i<numParams; i++) { m_Params[i].offset = offs; offs += m_Params[i].info.size; } } CallWrapper::~CallWrapper() { delete [] m_Params; delete m_RetParam; g_SPEngine->FreePageMemory(m_Addrs[ADDR_CODEBASE]); } void CallWrapper::Destroy() { delete this; } CallConvention CallWrapper::GetCallConvention() { return m_Cv; } const PassEncode *CallWrapper::GetParamInfo(unsigned int num) { return (num+1 > m_NumParams) ? NULL : &m_Params[num]; } const PassInfo *CallWrapper::GetReturnInfo() { return m_RetParam; } unsigned int CallWrapper::GetParamCount() { return m_NumParams; } void CallWrapper::Execute(void *vParamStack, void *retBuffer) { typedef void (*CALL_EXECUTE)(void *, void *); CALL_EXECUTE fn = (CALL_EXECUTE)m_Addrs[ADDR_CODEBASE]; fn(vParamStack, retBuffer); }
[ [ [ 1, 2 ], [ 7, 7 ], [ 28, 45 ], [ 48, 80 ], [ 86, 111 ] ], [ [ 3, 4 ], [ 6, 6 ], [ 8, 10 ], [ 12, 15 ], [ 17, 18 ], [ 20, 27 ] ], [ [ 5, 5 ], [ 11, 11 ], [ 16, 16 ], [ 19, 19 ], [ 46, 47 ], [ 81, 85 ] ] ]
044d9e6c9977cfd2544bf1532a9dd10b4dc941cc
44c199da11089def20f6f015a6f45650254f7aef
/LayerKit/LKUtil.h
5409b4f31dc2ad4ef5cb90f0991fcd5939166b67
[]
no_license
UIKit0/layerkit
0fa34caab7fa8a860774344eaa6d3ed1c5554e44
b89d0cb57ee9ea58d3353dc0b316d014fbba63e4
refs/heads/master
2021-01-22T07:13:33.878753
2009-06-11T09:50:11
2009-06-11T09:50:11
32,292,281
0
0
null
null
null
null
UTF-8
C++
false
false
1,515
h
/* * Copyright (C) 2007 University of South Australia * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Contributors: * Andrew Cunningham <[email protected]> */ #ifndef LKUtil_h #define LKUtil_h #include <algorithm> //#include "mmlib/manymouse.h" #include <vector> struct LKEvent; /** creates a vector of LKEvents by polling input from * the ManyMouse library */ std::vector<LKEvent*> BuildLKEventsFromManyMouseEvents(void); /** returns true if the iterable source of type S contains the * element t of type T, else false */ template <class S, class T> bool contains(S& source, T& t) { if (source.empty()) return false; typename S::iterator found = std::find(source.begin(), source.end(), t); return (found != source.end()); } #endif
[ "andrew.cunningham@a912c014-566b-11de-a7a4-5dc384e62361" ]
[ [ [ 1, 49 ] ] ]
c4bedda1241420f50ff9af3d83c51e4e34454ca0
ef23e388061a637f82b815d32f7af8cb60c5bb1f
/src/emu/machine/intelfsh.h
693e97ce6a45b360b58539070e1ebed3aa8c5756
[]
no_license
marcellodash/psmame
76fd877a210d50d34f23e50d338e65a17deff066
09f52313bd3b06311b910ed67a0e7c70c2dd2535
refs/heads/master
2021-05-29T23:57:23.333706
2011-06-23T20:11:22
2011-06-23T20:11:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,236
h
/* Intel Flash ROM emulation */ #ifndef _INTELFLASH_H_ #define _INTELFLASH_H_ //************************************************************************** // INTERFACE CONFIGURATION MACROS //************************************************************************** #define MCFG_INTEL_28F016S5_ADD(_tag) \ MCFG_DEVICE_ADD(_tag, INTEL_28F016S5, 0) #define MCFG_SHARP_LH28F016S_ADD(_tag) \ MCFG_DEVICE_ADD(_tag, SHARP_LH28F016S, 0) #define MCFG_FUJITSU_29F016A_ADD(_tag) \ MCFG_DEVICE_ADD(_tag, FUJITSU_29F016A, 0) #define MCFG_INTEL_E28F400_ADD(_tag) \ MCFG_DEVICE_ADD(_tag, INTEL_E28F400, 0) #define MCFG_MACRONIX_29L001MC_ADD(_tag) \ MCFG_DEVICE_ADD(_tag, MACRONIX_29L001MC, 0) #define MCFG_PANASONIC_MN63F805MNP_ADD(_tag) \ MCFG_DEVICE_ADD(_tag, PANASONIC_MN63F805MNP, 0) #define MCFG_SANYO_LE26FV10N1TS_ADD(_tag) \ MCFG_DEVICE_ADD(_tag, SANYO_LE26FV10N1TS, 0) #define MCFG_SHARP_LH28F400_ADD(_tag) \ MCFG_DEVICE_ADD(_tag, SHARP_LH28F400, 0) #define MCFG_INTEL_E28F008SA_ADD(_tag) \ MCFG_DEVICE_ADD(_tag, INTEL_E28F008SA, 0) #define MCFG_INTEL_TE28F160_ADD(_tag) \ MCFG_DEVICE_ADD(_tag, INTEL_TE28F160, 0) #define MCFG_SHARP_UNK128MBIT_ADD(_tag) \ MCFG_DEVICE_ADD(_tag, SHARP_UNK128MBIT, 0) //************************************************************************** // TYPE DEFINITIONS //************************************************************************** class intelfsh_device; // ======================> intelfsh_device_config class intelfsh_device_config : public device_config, public device_config_memory_interface, public device_config_nvram_interface { friend class intelfsh_device; protected: // constants enum { // 8-bit variants FLASH_INTEL_28F016S5 = 0x0800, FLASH_FUJITSU_29F016A, FLASH_SHARP_LH28F016S, FLASH_INTEL_E28F008SA, FLASH_MACRONIX_29L001MC, FLASH_PANASONIC_MN63F805MNP, FLASH_SANYO_LE26FV10N1TS, // 16-bit variants FLASH_SHARP_LH28F400 = 0x1000, FLASH_INTEL_E28F400, FLASH_INTEL_TE28F160, FLASH_SHARP_UNK128MBIT }; // construction/destruction intelfsh_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock, UINT32 variant); // device_config_memory_interface overrides virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const; // internal state address_space_config m_space_config; UINT32 m_type; INT32 m_size; UINT8 m_bits; UINT8 m_device_id; UINT8 m_maker_id; bool m_sector_is_4k; }; // ======================> intelfsh_device class intelfsh_device : public device_t, public device_memory_interface, public device_nvram_interface { friend class intelfsh_device_config; protected: // construction/destruction intelfsh_device(running_machine &_machine, const intelfsh_device_config &config); protected: // device-level overrides virtual void device_start(); virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); // device_config_nvram_interface overrides virtual void nvram_default(); virtual void nvram_read(emu_file &file); virtual void nvram_write(emu_file &file); // derived helpers UINT32 read_full(UINT32 offset); void write_full(UINT32 offset, UINT32 data); // internal state const intelfsh_device_config & m_config; UINT8 m_status; INT32 m_erase_sector; INT32 m_flash_mode; bool m_flash_master_lock; emu_timer * m_timer; INT32 m_bank; }; // ======================> intelfsh8_device_config class intelfsh8_device_config : public intelfsh_device_config { friend class intelfsh8_device; protected: // construction/destruction intelfsh8_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock, UINT32 variant); }; // ======================> intelfsh8_device class intelfsh8_device : public intelfsh_device { friend class intelfsh8_device_config; friend class intel_28f016s5_device_config; friend class fujitsu_29f016a_device_config; friend class sharp_lh28f016s_device_config; friend class intel_e28f008sa_device_config; friend class macronix_29l001mc_device_config; friend class panasonic_mn63f805mnp_device_config; friend class sanyo_le26fv10n1ts_device_config; protected: // construction/destruction intelfsh8_device(running_machine &_machine, const intelfsh_device_config &config); public: // public interface UINT8 read(offs_t offset) { return read_full(offset); } void write(offs_t offset, UINT8 data) { write_full(offset, data); } UINT8 read_raw(offs_t offset) { return m_addrspace[0]->read_byte(offset); } void write_raw(offs_t offset, UINT8 data) { m_addrspace[0]->write_byte(offset, data); } }; // ======================> intelfsh16_device_config class intelfsh16_device_config : public intelfsh_device_config { friend class intelfsh16_device; protected: // construction/destruction intelfsh16_device_config(const machine_config &mconfig, device_type type, const char *name, const char *tag, const device_config *owner, UINT32 clock, UINT32 variant); }; // ======================> intelfsh16_device class intelfsh16_device : public intelfsh_device { friend class intelfsh16_device_config; friend class sharp_lh28f400_device_config; friend class intel_te28f160_device_config; friend class intel_e28f400_device_config; friend class sharp_unk128mbit_device_config; protected: // construction/destruction intelfsh16_device(running_machine &_machine, const intelfsh_device_config &config); public: // public interface UINT16 read(offs_t offset) { return read_full(offset); } void write(offs_t offset, UINT16 data) { write_full(offset, data); } UINT16 read_raw(offs_t offset) { return m_addrspace[0]->read_word(offset * 2); } void write_raw(offs_t offset, UINT16 data) { m_addrspace[0]->write_word(offset * 2, data); } }; // ======================> trivial variants // 8-bit variants DECLARE_TRIVIAL_DERIVED_DEVICE(intel_28f016s5_device_config, intelfsh8_device_config, intel_28f016s5_device, intelfsh8_device) DECLARE_TRIVIAL_DERIVED_DEVICE(fujitsu_29f016a_device_config, intelfsh8_device_config, fujitsu_29f016a_device, intelfsh8_device) DECLARE_TRIVIAL_DERIVED_DEVICE(sharp_lh28f016s_device_config, intelfsh8_device_config, sharp_lh28f016s_device, intelfsh8_device) DECLARE_TRIVIAL_DERIVED_DEVICE(intel_e28f008sa_device_config, intelfsh8_device_config, intel_e28f008sa_device, intelfsh8_device) DECLARE_TRIVIAL_DERIVED_DEVICE(macronix_29l001mc_device_config, intelfsh8_device_config, macronix_29l001mc_device, intelfsh8_device) DECLARE_TRIVIAL_DERIVED_DEVICE(panasonic_mn63f805mnp_device_config, intelfsh8_device_config, panasonic_mn63f805mnp_device, intelfsh8_device) DECLARE_TRIVIAL_DERIVED_DEVICE(sanyo_le26fv10n1ts_device_config, intelfsh8_device_config, sanyo_le26fv10n1ts_device, intelfsh8_device) // 16-bit variants DECLARE_TRIVIAL_DERIVED_DEVICE(sharp_lh28f400_device_config, intelfsh16_device_config, sharp_lh28f400_device, intelfsh16_device) DECLARE_TRIVIAL_DERIVED_DEVICE(intel_te28f160_device_config, intelfsh16_device_config, intel_te28f160_device, intelfsh16_device) DECLARE_TRIVIAL_DERIVED_DEVICE(intel_e28f400_device_config, intelfsh16_device_config, intel_e28f400_device, intelfsh16_device) DECLARE_TRIVIAL_DERIVED_DEVICE(sharp_unk128mbit_device_config, intelfsh16_device_config, sharp_unk128mbit_device, intelfsh16_device) // device type definition extern const device_type INTEL_28F016S5; extern const device_type SHARP_LH28F016S; extern const device_type FUJITSU_29F016A; extern const device_type INTEL_E28F400; extern const device_type MACRONIX_29L001MC; extern const device_type PANASONIC_MN63F805MNP; extern const device_type SANYO_LE26FV10N1TS; extern const device_type SHARP_LH28F400; extern const device_type INTEL_E28F008SA; extern const device_type INTEL_TE28F160; extern const device_type SHARP_UNK128MBIT; #endif
[ "Mike@localhost" ]
[ [ [ 1, 248 ] ] ]
614a85e8b0f5deb540311900f25cedc9e5e8b46f
8a223ca4416c60f4ad302bc045a182af8b07c2a5
/Orders-ListeningFakeProblem-Cpp/Support-GTest-Cpp/include/gtest/gtest-message.h
f06de71ba8a504e994307b2b200419a3e5b24eed
[ "BSD-3-Clause" ]
permissive
sinojelly/sinojelly
8a773afd0fcbae73b1552a217ed9cee68fc48624
ee40852647c6a474a7add8efb22eb763a3be12ff
refs/heads/master
2016-09-06T18:13:28.796998
2010-03-06T13:22:12
2010-03-06T13:22:12
33,052,404
0
0
null
null
null
null
UTF-8
C++
false
false
8,365
h
// Copyright 2005, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Author: [email protected] (Zhanyong Wan) // // The Google C++ Testing Framework (Google Test) // // This header file defines the Message class. // // IMPORTANT NOTE: Due to limitation of the C++ language, we have to // leave some internal implementation details in this header file. // They are clearly marked by comments like this: // // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. // // Such code is NOT meant to be used by a user directly, and is subject // to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user // program! #ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_ #define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_ #include <gtest/internal/gtest-string.h> #include <gtest/internal/gtest-internal.h> namespace testing { // The Message class works like an ostream repeater. // // Typical usage: // // 1. You stream a bunch of values to a Message object. // It will remember the text in a StrStream. // 2. Then you stream the Message object to an ostream. // This causes the text in the Message to be streamed // to the ostream. // // For example; // // testing::Message foo; // foo << 1 << " != " << 2; // std::cout << foo; // // will print "1 != 2". // // Message is not intended to be inherited from. In particular, its // destructor is not virtual. // // Note that StrStream behaves differently in gcc and in MSVC. You // can stream a NULL char pointer to it in the former, but not in the // latter (it causes an access violation if you do). The Message // class hides this difference by treating a NULL char pointer as // "(null)". class Message { private: // The type of basic IO manipulators (endl, ends, and flush) for // narrow streams. typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&); public: // Constructs an empty Message. // We allocate the StrStream separately because it otherwise each use of // ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's // stack frame leading to huge stack frames in some cases; gcc does not reuse // the stack space. Message() : ss_(new internal::StrStream) {} // Copy constructor. Message(const Message& msg) : ss_(new internal::StrStream) { // NOLINT *ss_ << msg.GetString(); } // Constructs a Message from a C-string. explicit Message(const char* str) : ss_(new internal::StrStream) { *ss_ << str; } ~Message() { delete ss_; } #ifdef __SYMBIAN32__ // Streams a value (either a pointer or not) to this object. template <typename T> inline Message& operator <<(const T& value) { StreamHelper(typename internal::is_pointer<T>::type(), value); return *this; } #else // Streams a non-pointer value to this object. template <typename T> inline Message& operator <<(const T& val) { ::GTestStreamToHelper(ss_, val); return *this; } // Streams a pointer value to this object. // // This function is an overload of the previous one. When you // stream a pointer to a Message, this definition will be used as it // is more specialized. (The C++ Standard, section // [temp.func.order].) If you stream a non-pointer, then the // previous definition will be used. // // The reason for this overload is that streaming a NULL pointer to // ostream is undefined behavior. Depending on the compiler, you // may get "0", "(nil)", "(null)", or an access violation. To // ensure consistent result across compilers, we always treat NULL // as "(null)". template <typename T> inline Message& operator <<(T* const& pointer) { // NOLINT if (pointer == NULL) { *ss_ << "(null)"; } else { ::GTestStreamToHelper(ss_, pointer); } return *this; } #endif // __SYMBIAN32__ // Since the basic IO manipulators are overloaded for both narrow // and wide streams, we have to provide this specialized definition // of operator <<, even though its body is the same as the // templatized version above. Without this definition, streaming // endl or other basic IO manipulators to Message will confuse the // compiler. Message& operator <<(BasicNarrowIoManip val) { *ss_ << val; return *this; } // Instead of 1/0, we want to see true/false for bool values. Message& operator <<(bool b) { return *this << (b ? "true" : "false"); } // These two overloads allow streaming a wide C string to a Message // using the UTF-8 encoding. Message& operator <<(const wchar_t* wide_c_str) { return *this << internal::String::ShowWideCString(wide_c_str); } Message& operator <<(wchar_t* wide_c_str) { return *this << internal::String::ShowWideCString(wide_c_str); } #if GTEST_HAS_STD_WSTRING // Converts the given wide string to a narrow string using the UTF-8 // encoding, and streams the result to this Message object. Message& operator <<(const ::std::wstring& wstr); #endif // GTEST_HAS_STD_WSTRING #if GTEST_HAS_GLOBAL_WSTRING // Converts the given wide string to a narrow string using the UTF-8 // encoding, and streams the result to this Message object. Message& operator <<(const ::wstring& wstr); #endif // GTEST_HAS_GLOBAL_WSTRING // Gets the text streamed to this object so far as a String. // Each '\0' character in the buffer is replaced with "\\0". // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. internal::String GetString() const { return internal::StrStreamToString(ss_); } private: #ifdef __SYMBIAN32__ // These are needed as the Nokia Symbian Compiler cannot decide between // const T& and const T* in a function template. The Nokia compiler _can_ // decide between class template specializations for T and T*, so a // tr1::type_traits-like is_pointer works, and we can overload on that. template <typename T> inline void StreamHelper(internal::true_type dummy, T* pointer) { if (pointer == NULL) { *ss_ << "(null)"; } else { ::GTestStreamToHelper(ss_, pointer); } } template <typename T> inline void StreamHelper(internal::false_type dummy, const T& value) { ::GTestStreamToHelper(ss_, value); } #endif // __SYMBIAN32__ // We'll hold the text streamed to this object here. internal::StrStream* const ss_; // We declare (but don't implement) this to prevent the compiler // from implementing the assignment operator. void operator=(const Message&); }; // Streams a Message to an ostream. inline std::ostream& operator <<(std::ostream& os, const Message& sb) { return os << sb.GetString(); } } // namespace testing #endif // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
[ "chenguodong@localhost" ]
[ [ [ 1, 224 ] ] ]
f8e9ce381d44176fd1dd6f93411e8b8c284e81c2
9a48be80edc7692df4918c0222a1640545384dbb
/Libraries/Boost1.40/libs/math/src/tr1/fmaxf.cpp
b26493f949c51503160c4eb3f238a490b4264f18
[ "BSL-1.0" ]
permissive
fcrick/RepSnapper
05e4fb1157f634acad575fffa2029f7f655b7940
a5809843f37b7162f19765e852b968648b33b694
refs/heads/master
2021-01-17T21:42:29.537504
2010-06-07T05:38:05
2010-06-07T05:38:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
734
cpp
// Copyright John Maddock 2008. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // # include <pch.hpp> #ifndef BOOST_MATH_TR1_SOURCE # define BOOST_MATH_TR1_SOURCE #endif #include <boost/math/tr1.hpp> #include <boost/math/special_functions/fpclassify.hpp> #include "c_policy.hpp" #if !(defined(__HP_aCC) && (__HP_aCC >= 61400)) extern "C" float BOOST_MATH_TR1_DECL fmaxf BOOST_PREVENT_MACRO_SUBSTITUTION(float x, float y) { if((boost::math::isnan)(x)) return y; if((boost::math::isnan)(y)) return x; return (std::max)(x, y); } #endif
[ "metrix@Blended.(none)" ]
[ [ [ 1, 27 ] ] ]
9e0f7560038a141eba2d20704721e02b30fd803b
81344a13313d27b6af140bc8c9b77c9c2e81fee2
/AiTopRll/StdAfx.cpp
ee10129c6e50d83601a7d77cb4111938b8fbe92d
[]
no_license
radtek/aitop
169912e43a6d2bc4018219634d13dc786fa28a31
a2a89859d0d912b0844593972a2310798573219f
refs/heads/master
2021-01-01T03:57:19.378394
2008-06-17T16:03:19
2008-06-17T16:03:19
58,142,437
0
0
null
null
null
null
UTF-8
C++
false
false
295
cpp
// stdafx.cpp : source file that includes just the standard includes // AiTopRll.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file
[ [ [ 1, 8 ] ] ]
c95912e3869f0af4888b406bd80cd181cdb4e8cc
33b5565fb265463ed201c31f38ba3bd305a4e5d9
/FLHook/tags/Latest/src/source/HkCbIServerImpl.cpp
940a3e66469f01387c7b0d3074465b7d42daf294
[]
no_license
HeIIoween/FLHook-And-88-Flak-m0tah
be1ee2fa0e240c24160dda168b8b23ad6aec2b48
3f0737f7456ef3eed5dd67cfec1b838d32b8b5e1
refs/heads/master
2021-05-07T14:00:34.880461
2011-01-28T00:21:41
2011-01-28T00:21:41
109,712,726
1
0
null
null
null
null
UTF-8
C++
false
false
99,751
cpp
#include "wildcards.hh" #include "hook.h" #include "CInGame.h" #define ISERVER_LOG() if(set_iDebug >= 2) AddLog(__FUNCSIG__); #define ISERVER_LOGARG_WS(a) if(set_iDebug >= 2) AddLog(" " #a ": %s", wstos((const wchar_t*)a).c_str()); #define ISERVER_LOGARG_S(a) if(set_iDebug >= 2) AddLog(" " #a ": %s", (const char*)a); #define ISERVER_LOGARG_UI(a) if(set_iDebug >= 2) AddLog(" " #a ": %u", (uint)a); #define ISERVER_LOGARG_I(a) if(set_iDebug >= 2) AddLog(" " #a ": %d", (int)a); #define ISERVER_LOGARG_F(a) if(set_iDebug >= 2) AddLog(" " #a ": %f", (float)a); CInGame admin; //Repair gun vars float g_fRepairMaxHP; float g_fRepairBeforeHP; float g_fRepairDamage; uint g_iRepairShip; bool g_bRepairPendHit = false; BinaryTree<SOLAR_REPAIR> *btSolarList = new BinaryTree<SOLAR_REPAIR>(); list<MOB_UNDOCKBASEKILL> lstUndockKill; namespace HkIServerImpl { /************************************************************************************************************** this is our "main" loop **************************************************************************************************************/ // add timers here typedef void (*_TimerFunc)(); struct TIMER { _TimerFunc proc; mstime tmIntervallMS; mstime tmLastCall; }; TIMER Timers[] = { {ProcessPendingCommands, 50, 0}, {HkTimerUpdatePingData, 1000, 0}, {HkTimerUpdateLossData, LOSS_INTERVALL, 0}, {HkTimerCheckKick, 1000, 0}, {HkTimerNPCAndF1Check, 50, 0}, {HkTimerSolarRepair, 1000, 0}, {HkTimerCheckResolveResults, 0, 0}, {HkTimerCloakHandler, 500, 0}, {HkTimerSpaceObjMark, 2000, 0}, {HkTimerNPCDockHandler, 2500, 0}, {HkTimerRepairShip, 250, 0}, {HkTimerMarkDelay, 150, 0}, {HkTimerSolarDestroyDelay, 150, 0} }; int __stdcall Update(void) { static bool bFirstTime = true; if(bFirstTime) { FLHookInit(); bFirstTime = false; } // call timers for(uint i = 0; (i < sizeof(Timers)/sizeof(TIMER)); i++) { if((timeInMS() - Timers[i].tmLastCall) >= Timers[i].tmIntervallMS) { Timers[i].tmLastCall = timeInMS(); Timers[i].proc(); } } char *pData; memcpy(&pData, g_FLServerDataPtr + 0x40, 4); memcpy(&g_iServerLoad, pData + 0x204, 4); int iRet = Server.Update(); return iRet; } /************************************************************************************************************** Chat-Messages are hooked here <Parameters> cId: Sender's ClientID lP1: size of rdlReader (used when extracting text from that buffer) rdlReader: RenderDisplayList which contains the chat-text cIdTo: recipient's clientid(0x10000 = universe chat else when (cIdTo & 0x10000) = true -> system chat) iP2: ??? **************************************************************************************************************/ bool g_bInSubmitChat = false; uint g_iTextLen = 0; bool g_bChatAction = false; void __stdcall SubmitChat(struct CHAT_ID cId, unsigned long lP1, void const *rdlReader, struct CHAT_ID cIdTo, int iP2) { wchar_t wszBuf[1024] = L""; try { uint iClientID = cId.iID; // anti base-idle if(ClientInfo[iClientID].iBaseEnterTime) { ClientInfo[iClientID].iBaseEnterTime = (uint)time(0); } if(cIdTo.iID == 0x10004) { g_bInSubmitChat = true; Server.SubmitChat(cId, lP1, rdlReader, cIdTo, iP2); g_bInSubmitChat = false; return; } // extract text from rdlReader BinaryRDLReader rdl; uint iRet1; rdl.extract_text_from_buffer(wszBuf, sizeof(wszBuf), iRet1, (const char*)rdlReader, lP1); wstring wscBuf = wszBuf; g_iTextLen = (uint)wscBuf.length(); //Check for FLServer commands if(!wscBuf.find(L"/u ") || !wscBuf.find(L"/universe ") || !wscBuf.find(L"/s ") || !wscBuf.find(L"/system ") || !wscBuf.find(L"/g ") || !wscBuf.find(L"/group ") || !wscBuf.find(L"/l ") || !wscBuf.find(L"/local ") || !wscBuf.find(L"/leave") || !wscBuf.find(L"/lv") || !wscBuf.find(L"/join ") || !wscBuf.find(L"/j ")) g_iTextLen -= 3; // check for user cmds if(UserCmd_Process(iClientID, wscBuf)) return; if( wszBuf[0] == '.' && g_iTextLen>1 && wszBuf[1] != '.' ) { // flhook admin command CAccount *acc = Players.FindAccountFromClientID(iClientID); wstring wscAccDirname; HkGetAccountDirName(acc, wscAccDirname); string scAdminFile = scAcctPath + wstos(wscAccDirname) + "\\flhookadmin.ini"; WIN32_FIND_DATA fd; HANDLE hFind = FindFirstFile(scAdminFile.c_str(), &fd); if(hFind != INVALID_HANDLE_VALUE) { // is admin FindClose(hFind); admin.ReadRights(scAdminFile); admin.iClientID = iClientID; admin.wscAdminName = Players.GetActiveCharacterName(iClientID); admin.ExecuteCommandString(wszBuf + 1); return; } } //System chat to universe chat setting if(set_bSystemToUniverse) { if(cIdTo.iID!=0x10003 && cIdTo.iID && cIdTo.iID & 0x00010000) cIdTo.iID = 0x00010000; } if(!wscBuf.find(L"/me ")) g_bChatAction = true; else g_bChatAction = false; // process chat event if(set_bSocketActivated) //Only process if sockets enabled { wstring wscEvent; wscEvent.reserve(256); wscEvent = L"chat"; wscEvent += L" from="; if(!cId.iID) wscEvent += L"console"; else wscEvent += Players.GetActiveCharacterName(cId.iID); wscEvent += L" id="; wscEvent += stows(itos(cId.iID)); wscEvent += L" type="; if(cIdTo.iID == 0x00010000) wscEvent += L"universe"; else if(cIdTo.iID & 0x00010000) wscEvent += L"system"; else { wscEvent += L"player"; wscEvent += L" to="; if(!cIdTo.iID) wscEvent += L"console"; else wscEvent += Players.GetActiveCharacterName(cIdTo.iID); wscEvent += L" idto="; wscEvent += stows(itos(cIdTo.iID)); } wscEvent += L" text="; wscEvent += wscBuf; ProcessEvent(wscEvent); } // check if chat should be suppressed foreach(set_lstChatSuppress, wstring, i) { if((ToLower(wscBuf)).find(ToLower(*i)) == 0) return; } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } // send g_bInSubmitChat = true; try { Server.SubmitChat(cId, lP1, rdlReader, cIdTo, iP2); } catch(...) { AddLog("Exception in Server.SubmitChat"); } g_bInSubmitChat = false; } /************************************************************************************************************** Called when player ship was created in space (after undock or login) **************************************************************************************************************/ void __stdcall PlayerLaunch(unsigned int iShip, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iShip); ISERVER_LOGARG_UI(iClientID); list <CARGO_INFO> lstCargo; try { ClientInfo[iClientID].iShip = iShip; ClientInfo[iClientID].iKillsInARow = 0; ClientInfo[iClientID].bCruiseActivated = false; ClientInfo[iClientID].bThrusterActivated = false; ClientInfo[iClientID].bEngineKilled = false; ClientInfo[iClientID].bTradelane = false; HkInitCloakSettings(iClientID); if(ClientInfo[iClientID].bCanCloak) { ClientInfo[iClientID].bMustSendUncloak = true; } // adjust cash, this is necessary when cash was added while use was in charmenu/had other char selected wstring wscCharname = ToLower(Players.GetActiveCharacterName(iClientID)); foreach(ClientInfo[iClientID].lstMoneyFix, MONEY_FIX, i) { if(!(*i).wscCharname.compare(wscCharname)) { HkAddCash(wscCharname, (*i).iAmount); ClientInfo[iClientID].lstMoneyFix.remove(*i); break; } } // adjust cargo, this is necessary when cargo was added while use was in charmenu/had other char selected for(list<CARGO_FIX>::iterator i2 = ClientInfo[iClientID].lstCargoFix.begin(); (i2 != ClientInfo[iClientID].lstCargoFix.end()); ) { if(!(*i2).wscCharname.compare(wscCharname)) { HkAddCargo(wscCharname, i2->iGoodID, i2->iCount, i2->bMission); i2 = ClientInfo[iClientID].lstCargoFix.erase(i2); } else i2++; } if(set_vNoPvpGoodIDs.size()) { HkEnumCargo(ARG_CLIENTID(iClientID), lstCargo, 0); ClientInfo[iClientID].bNoPvp = false; foreach(lstCargo, CARGO_INFO, cargo) { bool bBreak = false; for(uint i=0; i<set_vNoPvpGoodIDs.size(); i++) { if(cargo->bMounted && set_vNoPvpGoodIDs[i]==cargo->iArchID) { int iRep; pub::Player::GetRep(iClientID, iRep); uint iAffil; Reputation::Vibe::GetAffiliation(iRep, iAffil, false); if(set_vNoPvpFactionIDs[i] && iAffil!=set_vNoPvpFactionIDs[i]) { pub::Reputation::SetReputation(iRep, set_vNoPvpFactionIDs[i], 0.9f); pub::Reputation::SetAffiliation(iRep, set_vNoPvpFactionIDs[i]); } ClientInfo[iClientID].bNoPvp = true; bBreak = true; break; } } if(bBreak) break; } if(!ClientInfo[iClientID].bNoPvp) //Might have previously had a no-pvp token, reset rep and/or affiliation with groups { int iRep; pub::Player::GetRep(iClientID, iRep); uint iAffil; Reputation::Vibe::GetAffiliation(iRep, iAffil, false); for(uint i=0; i<set_vNoPvpFactionIDs.size(); i++) { if(set_vNoPvpFactionIDs[i]) { pub::Reputation::SetReputation(iRep, set_vNoPvpFactionIDs[i], 0.0f); if(iAffil==set_vNoPvpFactionIDs[i]) { pub::Reputation::SetAffiliation(iRep, -1); break; } } } } } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } g_iClientID = iClientID; //Launch hook, mobile docking stuffs if(ClientInfo[iClientID].bMobileDocked) { if(ClientInfo[iClientID].lstJumpPath.size()) //Not in same system, follow jump path { pub::SpaceObj::GetLocation(ClientInfo[iClientID].lstJumpPath.front(), g_Vlaunch, g_Mlaunch); g_Vlaunch.x -= g_Mlaunch.data[0][2]*750; g_Vlaunch.y -= g_Mlaunch.data[1][2]*750; g_Vlaunch.z -= g_Mlaunch.data[2][2]*750; g_Mlaunch.data[0][0] = -g_Mlaunch.data[0][0]; g_Mlaunch.data[1][0] = -g_Mlaunch.data[1][0]; g_Mlaunch.data[2][0] = -g_Mlaunch.data[2][0]; g_Mlaunch.data[0][2] = -g_Mlaunch.data[0][2]; g_Mlaunch.data[1][2] = -g_Mlaunch.data[1][2]; g_Mlaunch.data[2][2] = -g_Mlaunch.data[2][2]; g_bInPlayerLaunch = true; Server.PlayerLaunch(iShip, iClientID); g_bInPlayerLaunch = false; uint iShip; pub::Player::GetShip(iClientID, iShip); ClientInfo[iClientID].bPathJump = true; pub::SpaceObj::InstantDock(iShip, ClientInfo[iClientID].lstJumpPath.front(), 1); ClientInfo[iClientID].lstJumpPath.pop_front(); } else if(ClientInfo[iClientID].iDockClientID) //same system and carrier still exists { uint iDockClientID = ClientInfo[iClientID].iDockClientID; uint iTargetBaseID; pub::Player::GetBase(iDockClientID, iTargetBaseID); if(iTargetBaseID) //carrier docked { uint iTargetShip = ClientInfo[iDockClientID].iLastSpaceObjDocked; if(iTargetShip) //got the spaceObj of the base alright { uint iType; pub::SpaceObj::GetType(iTargetShip, iType); pub::SpaceObj::GetLocation(iTargetShip, g_Vlaunch, g_Mlaunch); if(iType==32) //docking ring { g_Mlaunch.data[0][0] = -g_Mlaunch.data[0][0]; g_Mlaunch.data[1][0] = -g_Mlaunch.data[1][0]; g_Mlaunch.data[2][0] = -g_Mlaunch.data[2][0]; g_Mlaunch.data[0][2] = -g_Mlaunch.data[0][2]; g_Mlaunch.data[1][2] = -g_Mlaunch.data[1][2]; g_Mlaunch.data[2][2] = -g_Mlaunch.data[2][2]; g_Vlaunch.x += g_Mlaunch.data[0][0]*90; g_Vlaunch.y += g_Mlaunch.data[1][0]*90; g_Vlaunch.z += g_Mlaunch.data[2][0]*90; } else { g_Vlaunch.x += g_Mlaunch.data[0][1]*set_iMobileDockOffset; g_Vlaunch.y += g_Mlaunch.data[1][1]*set_iMobileDockOffset; g_Vlaunch.z += g_Mlaunch.data[2][1]*set_iMobileDockOffset; } g_bInPlayerLaunch = true; Server.PlayerLaunch(iShip, iClientID); g_bInPlayerLaunch = false; pub::Player::RevertCamera(iClientID); } else //backup: set player's base to that of target, hope they won't get kicked (this shouldn't happen) { Players[iClientID].iBaseID = iTargetBaseID; Server.PlayerLaunch(iShip, iClientID); } } else //carrier not docked { uint iTargetShip; pub::Player::GetShip(iDockClientID, iTargetShip); pub::SpaceObj::GetLocation(iTargetShip, g_Vlaunch, g_Mlaunch); g_Vlaunch.x += g_Mlaunch.data[0][1]*set_iMobileDockOffset; g_Vlaunch.y += g_Mlaunch.data[1][1]*set_iMobileDockOffset; g_Vlaunch.z += g_Mlaunch.data[2][1]*set_iMobileDockOffset; g_bInPlayerLaunch = true; Server.PlayerLaunch(iShip, iClientID); g_bInPlayerLaunch = false; pub::Player::RevertCamera(iClientID); } } else //same system, carrier does not exist { g_Vlaunch = ClientInfo[iClientID].Vlaunch; g_Mlaunch = ClientInfo[iClientID].Mlaunch; g_bInPlayerLaunch = true; Server.PlayerLaunch(iShip, iClientID); g_bInPlayerLaunch = false; pub::Player::RevertCamera(iClientID); } } else //regular launch { Server.PlayerLaunch(iShip, iClientID); } try { //Mobile docking uint iShipArchID; pub::Player::GetShipID(iClientID, iShipArchID); MOBILE_SHIP uwFind = MOBILE_SHIP(iShipArchID); MOBILE_SHIP *uwFound = set_btMobDockShipArchIDs->Find(&uwFind); if(uwFound) //ship is mobile base { ClientInfo[iClientID].bMobileBase = true; ClientInfo[iClientID].iMaxPlayersDocked = uwFound->iMaxNumOccupants; } else { ClientInfo[iClientID].bMobileBase = false; } //Print Death Penalty notice if(set_fDeathPenalty) { UINT_WRAP uwShip = UINT_WRAP(Players[iClientID].iShipArchID); UINT_WRAP uwSystem = UINT_WRAP(Players[iClientID].iSystemID); if(!set_btNoDeathPenalty->Find(&uwShip) && !set_btNoDPSystems->Find(&uwSystem)) { int iCash; HkGetCash(ARG_CLIENTID(iClientID), iCash); float fValue; pub::Player::GetAssetValue(iClientID, fValue); ClientInfo[iClientID].iDeathPenaltyCredits = (int)(fValue * set_fDeathPenalty); if(ClientInfo[iClientID].bDisplayDPOnLaunch) PrintUserCmdText(iClientID, L"Notice: the death penalty for your ship will be " + ToMoneyStr(ClientInfo[iClientID].iDeathPenaltyCredits) + L" credits. Type /dp for more information."); } else ClientInfo[iClientID].iDeathPenaltyCredits = 0; } //Add ship to list of ships to repair if(set_mapItemRepair.size()) { if(!lstCargo.size()) { HkEnumCargo(ARG_CLIENTID(iClientID), lstCargo, 0); } foreach(lstCargo, CARGO_INFO, cargo) { if(!cargo->bMounted) continue; map<uint,float>::iterator repair = set_mapItemRepair.find(cargo->iArchID); if(repair != set_mapItemRepair.end()) { SHIP_REPAIR sr; sr.iObjID = iShip; sr.fIncreaseHealth = repair->second; g_lstRepairShips.push_back(sr); break; } } } map<uint,float>::iterator repair = set_mapShipRepair.find(iShipArchID); if(repair != set_mapShipRepair.end()) { SHIP_REPAIR sr; sr.iObjID = iShip; sr.fIncreaseHealth = repair->second; g_lstRepairShips.push_back(sr); } if(!ClientInfo[iClientID].iLastExitedBaseID) { ClientInfo[iClientID].iLastExitedBaseID = 1; // event ProcessEvent(L"spawn char=%s id=%d system=%s", Players.GetActiveCharacterName(iClientID), iClientID, HkGetPlayerSystem(iClientID).c_str()); } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } /************************************************************************************************************** Called when player fires a weapon **************************************************************************************************************/ void __stdcall FireWeapon(unsigned int iClientID, struct XFireWeaponInfo const &wpn) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); try { } catch(...) { AddLog("Exception in %s", __FUNCTION__); } Server.FireWeapon(iClientID, wpn); } /************************************************************************************************************** Called when one player hits a target with a gun <Parameters> ci: only figured out where dwTargetShip is ... **************************************************************************************************************/ void __stdcall SPMunitionCollision(struct SSPMunitionCollisionInfo const & ci, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); uint iClientIDTarget; try { iClientIDTarget = HkGetClientIDByShip(ci.dwTargetShip); if(iClientIDTarget && !AllowPlayerDamage(iClientID, iClientIDTarget)) return; //Check if weapon is a repair gun REPAIR_GUN FindGun = REPAIR_GUN(ci.iProjectileArchID, 0.0f); REPAIR_GUN *RepGun = set_btRepairGun->Find(&FindGun); if(RepGun) { float maxHealth, curHealth; pub::SpaceObj::GetHealth(ci.dwTargetShip, curHealth, maxHealth); uint iType; pub::SpaceObj::GetType(ci.dwTargetShip, iType); if(iType!=2) //object is a planet (not damagable) { if(!curHealth) { if((uint)(ci.dwTargetShip/1000000000))//Object is dead and a solar; boost health here { float fSetHealth = RepGun->damage/maxHealth; if(fSetHealth>1.0f) fSetHealth = 1.0f; pub::SpaceObj::SetRelativeHealth(ci.dwTargetShip, fSetHealth); } return; } g_fRepairMaxHP = maxHealth; g_fRepairBeforeHP = curHealth; g_iRepairShip = ci.dwTargetShip; g_fRepairDamage = RepGun->damage; g_bRepairPendHit = true; } } else { g_bRepairPendHit = false; //ClientInfo[iClientID].tmLastWeaponHit = timeInMS(); } /*uint iType; pub::SpaceObj::GetType(ci.dwTargetShip, iType); PrintUniverseText(L"type=%u", iType);*/ } catch(...) { AddLog("Exception in %s", __FUNCTION__); } iDmgTo = iClientIDTarget; Server.SPMunitionCollision(ci, iClientID); } /************************************************************************************************************** Called when player moves his ship **************************************************************************************************************/ void __stdcall SPObjUpdate(struct SSPObjUpdateInfo const &ui, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); try { if(ClientInfo[iClientID].bCanCloak && ClientInfo[iClientID].bMustSendUncloak && !ClientInfo[iClientID].bIsCloaking) { HkUnCloak(iClientID); ClientInfo[iClientID].bMustSendUncloak = false; } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } Server.SPObjUpdate(ui, iClientID); } /************************************************************************************************************** Called when one player collides with a space object and is damaged **************************************************************************************************************/ void __stdcall SPObjCollision(struct SSPObjCollisionInfo const &ci, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); bool bShieldsUp = false; float fHealthBefore = 0.0f; uint iShip; try { uint iClientIDTarget = HkGetClientIDByShip(ci.dwTargetShip); if(iClientIDTarget && !AllowPlayerDamage(iClientID, iClientIDTarget)) return; pub::Player::GetShip(iClientID, iShip); uint iType; pub::SpaceObj::GetType(ci.dwTargetShip, iType); if(iType == 65536) //Is FIGHTER { float fMass; pub::SpaceObj::GetMass(iShip, fMass); //PrintUniverseText(L"mass=%f, type=%u", inspect->get_mass(), iType); if(set_fSpinProtectMass!=-1.0f && !iClientIDTarget && fMass>=set_fSpinProtectMass) { Vector V1, V2; pub::SpaceObj::GetMotion(ci.dwTargetShip, V1, V2); pub::SpaceObj::GetMass(ci.dwTargetShip, fMass); V1.x *= set_fSpinImpulseMultiplier * fMass; V1.y *= set_fSpinImpulseMultiplier * fMass; V1.z *= set_fSpinImpulseMultiplier * fMass; V2.x *= set_fSpinImpulseMultiplier * fMass; V2.y *= set_fSpinImpulseMultiplier * fMass; V2.z *= set_fSpinImpulseMultiplier * fMass; //PrintUserCmdText(iClientID, L"Boink! %f %f %f", V1.x, V1.y, V1.z); pub::SpaceObj::AddImpulse(ci.dwTargetShip, V1, V2); } } if(set_bDamageNPCsCollision && !iClientIDTarget) { float fMaxHealth; pub::SpaceObj::GetShieldHealth(iShip, fHealthBefore, fMaxHealth, bShieldsUp); if(!bShieldsUp) { pub::SpaceObj::GetHealth(iShip, fHealthBefore, fMaxHealth); } } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } Server.SPObjCollision(ci, iClientID); try { float fDamage; if(fHealthBefore && !pub::SpaceObj::ExistsAndAlive(ci.dwTargetShip) && !pub::SpaceObj::ExistsAndAlive(iShip)) { float fHealth, fHealthTarget, fMaxHealth; if(bShieldsUp) { pub::SpaceObj::GetShieldHealth(iShip, fHealth, fMaxHealth, bShieldsUp); } else { pub::SpaceObj::GetHealth(iShip, fHealth, fMaxHealth); } fDamage = fHealthBefore - fHealth; pub::SpaceObj::GetShieldHealth(ci.dwTargetShip, fHealthTarget, fMaxHealth, bShieldsUp); if(bShieldsUp) { if(fHealthTarget) { fHealth = fHealthTarget - fDamage; HkSetShieldHealth(ci.dwTargetShip, iClientID, iShip, DC_GUN, fHealth); } } else { pub::SpaceObj::GetHealth(ci.dwTargetShip, fHealthTarget, fMaxHealth); if(fHealthTarget) { fHealth = fHealthTarget - fDamage; HkSetHullHealth(ci.dwTargetShip, iClientID, iShip, DC_GUN, fHealth); } } } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } /************************************************************************************************************** Called when player has undocked and is now ready to fly **************************************************************************************************************/ void __stdcall LaunchComplete(unsigned int iBaseID, unsigned int iShip) { ISERVER_LOG(); ISERVER_LOGARG_UI(iBaseID); ISERVER_LOGARG_UI(iShip); uint iClientID; try { iClientID = HkGetClientIDByShip(iShip); if(iClientID) ClientInfo[iClientID].tmSpawnTime = timeInMS(); // save for anti-dockkill else return; // event ProcessEvent(L"launch char=%s id=%d base=%s system=%s", Players.GetActiveCharacterName(iClientID), iClientID, HkGetBaseNickByID(ClientInfo[iClientID].iLastExitedBaseID).c_str(), HkGetPlayerSystem(iClientID).c_str()); } catch(...) { AddLog("Exception in %s", __FUNCTION__); } Server.LaunchComplete(iBaseID, iShip); try { //For those whose carrier has died, kill and set last base list<MOB_UNDOCKBASEKILL>::iterator killClient = lstUndockKill.begin(); for(killClient = lstUndockKill.begin(); killClient!=lstUndockKill.end(); killClient++) { if(iClientID==killClient->iClientID) { Players[iClientID].iPrevBaseID = killClient->iBaseID; if(killClient->bKill) HkKill(ARG_CLIENTID(iClientID)); lstUndockKill.erase(killClient); return; } } //marking, marks are reset when docking, so re-mark them on launch for(uint i=0; i<ClientInfo[iClientID].vMarkedObjs.size(); i++) { if(pub::SpaceObj::ExistsAndAlive(ClientInfo[iClientID].vMarkedObjs[i])) { if(i!=ClientInfo[iClientID].vMarkedObjs.size()-1) { ClientInfo[iClientID].vMarkedObjs[i] = ClientInfo[iClientID].vMarkedObjs[ClientInfo[iClientID].vMarkedObjs.size()-1]; i--; } ClientInfo[iClientID].vMarkedObjs.pop_back(); continue; } pub::Player::MarkObj(iClientID, ClientInfo[iClientID].vMarkedObjs[i], 1); } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } /************************************************************************************************************** Called when player selects a character **************************************************************************************************************/ void __stdcall CharacterSelect(struct CHARACTER_ID const & cId, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_S(&cId); ISERVER_LOGARG_UI(iClientID); uint iOldGroupID; try { //group re-add on char change if(set_bInviteOnCharChange) { HkGetGroupID(ARG_CLIENTID(iClientID), iOldGroupID); } //Ship bought at dealer check uint iShipID; pub::Player::GetShipID(iClientID, iShipID); if(ClientInfo[iClientID].iShipID && ClientInfo[iClientID].iShipID!=iShipID) { HkNewShipBought(iClientID); } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } wstring wscCharBefore; try { const wchar_t *wszCharname = Players.GetActiveCharacterName(iClientID); wscCharBefore = wszCharname ? Players.GetActiveCharacterName(iClientID) : L""; ClientInfo[iClientID].iLastExitedBaseID = 0; Server.CharacterSelect(cId, iClientID); } catch(...) { HkAddKickLog(iClientID, L"Corrupt charfile?"); HkKick(ARG_CLIENTID(iClientID)); return; } try { wstring wscCharname = Players.GetActiveCharacterName(iClientID); if(wscCharBefore.compare(wscCharname) != 0) { //Remove kbeam cargo restore for(uint i=0; i<vRestoreKBeamClientIDs.size(); i++) { if(iClientID==vRestoreKBeamClientIDs[i]) { if(i!=vRestoreKBeamClientIDs.size()-1) { vRestoreKBeamClientIDs[i] = vRestoreKBeamClientIDs[vRestoreKBeamClientIDs.size()-1]; vRestoreKBeamCargo[i] = vRestoreKBeamCargo[vRestoreKBeamCargo.size()-1]; } vRestoreKBeamClientIDs.pop_back(); vRestoreKBeamCargo.pop_back(); break; } } LoadUserCharSettings(iClientID); if(set_bInviteOnCharChange) { HkAddToGroup(ARG_CLIENTID(iClientID), iOldGroupID); } ClientInfo[iClientID].iShipID = 0; ClientInfo[iClientID].bCharInfoReqAfterDeath = false; } // anti-cheat check list <CARGO_INFO> lstCargo; HkEnumCargo(ARG_CLIENTID(iClientID), lstCargo, 0); foreach(lstCargo, CARGO_INFO, it) { if((*it).iCount < 0) { HkAddCheaterLog(wscCharname, L"Negative good-count, likely to have cheated in the past"); wchar_t wszBuf[256]; swprintf(wszBuf, L"Possible cheating detected (%s)", wscCharname.c_str()); HkMsgU(wszBuf); HkBan(ARG_CLIENTID(iClientID), true); HkKick(ARG_CLIENTID(iClientID)); } } // event CAccount *acc = Players.FindAccountFromClientID(iClientID); wstring wscDir; HkGetAccountDirName(acc, wscDir); HKPLAYERINFO pi; HkGetPlayerInfo(ARG_CLIENTID(iClientID), pi, false); ProcessEvent(L"login char=%s accountdirname=%s id=%d ip=%s", wscCharname.c_str(), wscDir.c_str(), iClientID, pi.wscIP.c_str()); } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } /************************************************************************************************************** Called when player enters base **************************************************************************************************************/ bool bIgnoreCancelMobDock = false; //ignore removal from carrier docked-list void __stdcall BaseEnter(unsigned int iBaseID, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iBaseID); ISERVER_LOGARG_UI(iClientID); Server.BaseEnter(iBaseID, iClientID); try { //mobile docking - remove from target's docked list ClientInfo[iClientID].iLastEnteredBaseID = iBaseID; if(!bIgnoreCancelMobDock) { if(ClientInfo[iClientID].bMobileDocked) { wstring wscBase = ToLower(HkGetBaseNickByID(iBaseID)); if(wscBase.find(L"mobile_proxy_base")==-1) { if(ClientInfo[iClientID].iDockClientID) { ClientInfo[ClientInfo[iClientID].iDockClientID].lstPlayersDocked.remove(iClientID); ClientInfo[iClientID].iDockClientID = 0; } ClientInfo[iClientID].bMobileDocked = false; } } } else bIgnoreCancelMobDock = false; //Automarking ClientInfo[iClientID].vAutoMarkedObjs.clear(); ClientInfo[iClientID].vDelayedAutoMarkedObjs.clear(); // adjust cash, this is necessary when cash was added while use was in charmenu/had other char selected wstring wscCharname = ToLower(Players.GetActiveCharacterName(iClientID)); foreach(ClientInfo[iClientID].lstMoneyFix, MONEY_FIX, i) { if(!(*i).wscCharname.compare(wscCharname)) { HkAddCash(wscCharname, (*i).iAmount); ClientInfo[iClientID].lstMoneyFix.remove(*i); break; } } // adjust cargo, this is necessary when cash was added while use was in charmenu/had other char selected for(list<CARGO_FIX>::iterator i2 = ClientInfo[iClientID].lstCargoFix.begin(); (i2 != ClientInfo[iClientID].lstCargoFix.end()); ) { if(!(*i2).wscCharname.compare(wscCharname)) { HkAddCargo(wscCharname, i2->iGoodID, i2->iCount, i2->bMission); i2 = ClientInfo[iClientID].lstCargoFix.erase(i2); } else i2++; } //add items if KillBeam was used if(vRestoreKBeamClientIDs.size()) { list<CARGO_INFO> lstAfterCargo; HkEnumCargo(ARG_CLIENTID(iClientID), lstAfterCargo, 0); for(uint i=0; i<vRestoreKBeamClientIDs.size(); i++) { if(iClientID==vRestoreKBeamClientIDs[i]) { foreach(vRestoreKBeamCargo[i], CARGO_INFO, bcargo) { if(!bcargo->bMounted) //add to cargo { bool bContinue = false; foreach(lstAfterCargo, CARGO_INFO, acargo) //check to see if dropped { if(bcargo->iArchID==acargo->iArchID) { bContinue = true; break; } } if(bContinue) continue; HkAddCargo(ARG_CLIENTID(iClientID), bcargo->iArchID, bcargo->iCount, bcargo->bMission); } } if(i!=vRestoreKBeamClientIDs.size()-1) { vRestoreKBeamClientIDs[i] = vRestoreKBeamClientIDs[vRestoreKBeamClientIDs.size()-1]; vRestoreKBeamCargo[i] = vRestoreKBeamCargo[vRestoreKBeamCargo.size()-1]; } vRestoreKBeamClientIDs.pop_back(); vRestoreKBeamCargo.pop_back(); break; } } } // autobuy // moved below //if(set_bAutoBuy) // HkPlayerAutoBuy(iClientID, iBaseID); // clear damage tracking ClientInfo[iClientID].lstDmgRec.clear(); //Death penalty HkPenalizeDeath(ARG_CLIENTID(iClientID), 0, true); // event ProcessEvent(L"baseenter char=%s id=%d base=%s system=%s", Players.GetActiveCharacterName(iClientID), iClientID, HkGetBaseNickByID(iBaseID).c_str(), HkGetPlayerSystem(iClientID).c_str()); } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } /************************************************************************************************************** Called when player exits base **************************************************************************************************************/ void __stdcall BaseExit(unsigned int iBaseID, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iBaseID); ISERVER_LOGARG_UI(iClientID); try { // autobuy if(set_bUserCmdAutoBuy) HkPlayerAutoBuy(iClientID, iBaseID); ClientInfo[iClientID].iBaseEnterTime = 0; ClientInfo[iClientID].iLastExitedBaseID = iBaseID; } catch(...) { AddLog("Exception in %s", __FUNCTION__); } Server.BaseExit(iBaseID, iClientID); try { const wchar_t *wszCharname = Players.GetActiveCharacterName(iClientID); // event ProcessEvent(L"baseexit char=%s id=%d base=%s system=%s", Players.GetActiveCharacterName(iClientID), iClientID, HkGetBaseNickByID(iBaseID).c_str(), HkGetPlayerSystem(iClientID).c_str()); } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } /************************************************************************************************************** Called when player connects **************************************************************************************************************/ void __stdcall OnConnect(unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); try { if(ClientInfo[iClientID].tmF1TimeDisconnect > timeInMS()) return; ClientInfo[iClientID].iConnects++; ClearClientInfo(iClientID); } catch(...) { AddLog("Exception in %s", __FUNCTION__); } Server.OnConnect(iClientID); try { // event wstring wscIP; HkGetPlayerIP(iClientID, wscIP); ProcessEvent(L"connect id=%d ip=%s", iClientID, wscIP.c_str()); } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } /************************************************************************************************************** Called when player disconnects **************************************************************************************************************/ //Note that the base will ALWAYS be 0 inside of this method void __stdcall DisConnect(unsigned int iClientID, enum EFLConnection p2) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); ISERVER_LOGARG_UI(p2); Vector VCharFilePos; wstring wscPlayerName = L"", wscSystem = L""; const wchar_t *wszCharname; bool bDeathPenaltyOnEnter; try { ClientInfo[iClientID].lstMoneyFix.clear(); ClientInfo[iClientID].lstCargoFix.clear(); if (ClientInfo[iClientID].bInWrapGate) { // OMG JH disconnection HAXER, KILL KILL KILL NOW uint iShip; pub::Player::GetShip(iClientID, iShip); pub::SpaceObj::SetInvincible(iShip, false, false, 0); pub::SpaceObj::SetRelativeHealth(iShip, 0.0f); // kill the player } uint iShip; pub::Player::GetShip(iClientID, iShip); //mobile docking if(ClientInfo[iClientID].bMobileDocked) { if(!iShip) //Docked at carrier { if(ClientInfo[iClientID].iDockClientID) //carrier still exists { Players[iClientID].iPrevBaseID = Players[ClientInfo[iClientID].iDockClientID].iPrevBaseID; uint iTargetShip; pub::Player::GetShip(ClientInfo[iClientID].iDockClientID, iTargetShip); if(iTargetShip) //carrier in space { Matrix m; pub::SpaceObj::GetLocation(iTargetShip, VCharFilePos, m); wscPlayerName = Players.GetActiveCharacterName(iClientID); } else //carrier docked { Players[iClientID].iBaseID = Players[ClientInfo[iClientID].iDockClientID].iBaseID; } wscSystem = HkGetPlayerSystem(iClientID); //remove from docked client list ClientInfo[ClientInfo[iClientID].iDockClientID].lstPlayersDocked.remove(iClientID); } else //carrier does not exist, use stored location info { if(ClientInfo[iClientID].lstJumpPath.size()) { uint iSystemID; pub::GetSystemGateConnection(ClientInfo[iClientID].lstJumpPath.back(), iSystemID); wscSystem = HkGetSystemNickByID(iSystemID); } list<MOB_UNDOCKBASEKILL>::iterator killClient = lstUndockKill.begin(); //Find the last_base for(killClient = lstUndockKill.begin(); killClient!=lstUndockKill.end(); killClient++) { if(iClientID==killClient->iClientID) { Players[iClientID].iBaseID = killClient->iBaseID; Players[iClientID].iPrevBaseID = killClient->iBaseID; lstUndockKill.erase(killClient); break; } } VCharFilePos = ClientInfo[iClientID].Vlaunch; wscPlayerName = Players.GetActiveCharacterName(iClientID); } } else //in space, update last base only { if(ClientInfo[iClientID].iDockClientID) //carrier still exists { Players[iClientID].iPrevBaseID = Players[ClientInfo[iClientID].iDockClientID].iPrevBaseID; } } } if(ClientInfo[iClientID].lstPlayersDocked.size()) { Matrix m; Vector v; uint iShip; pub::Player::GetShip(iClientID, iShip); if(iShip) pub::SpaceObj::GetLocation(iShip, v, m); foreach(ClientInfo[iClientID].lstPlayersDocked, uint, dockedClientID) //go through all of the docked players and deal with them { uint iDockedShip; pub::Player::GetShip(*dockedClientID, iDockedShip); if(iDockedShip) //player is in space { Players[*dockedClientID].iPrevBaseID = iShip ? Players[iClientID].iPrevBaseID : Players[iClientID].iBaseID; if(!ClientInfo[*dockedClientID].lstJumpPath.size()) { ClientInfo[*dockedClientID].bMobileDocked = false; } } else //player is docked { if(iShip) //carrier is in space { ClientInfo[*dockedClientID].Vlaunch = v; ClientInfo[*dockedClientID].Mlaunch = m; MOB_UNDOCKBASEKILL dKill; dKill.iClientID = *dockedClientID; dKill.iBaseID = Players[iClientID].iPrevBaseID; dKill.bKill = false; lstUndockKill.push_back(dKill); } else //carrier is docked { uint iTargetShip = ClientInfo[iClientID].iLastSpaceObjDocked; MOB_UNDOCKBASEKILL dKill; dKill.iClientID = *dockedClientID; dKill.iBaseID = ClientInfo[iClientID].iLastEnteredBaseID; dKill.bKill = false; lstUndockKill.push_back(dKill); if(iTargetShip) //got the spaceObj of the base alright { uint iType; pub::SpaceObj::GetType(iTargetShip, iType); pub::SpaceObj::GetLocation(iTargetShip, ClientInfo[*dockedClientID].Vlaunch, ClientInfo[*dockedClientID].Mlaunch); if(iType==32) { ClientInfo[*dockedClientID].Mlaunch.data[0][0] = -ClientInfo[*dockedClientID].Mlaunch.data[0][0]; ClientInfo[*dockedClientID].Mlaunch.data[1][0] = -ClientInfo[*dockedClientID].Mlaunch.data[1][0]; ClientInfo[*dockedClientID].Mlaunch.data[2][0] = -ClientInfo[*dockedClientID].Mlaunch.data[2][0]; ClientInfo[*dockedClientID].Mlaunch.data[0][2] = -ClientInfo[*dockedClientID].Mlaunch.data[0][2]; ClientInfo[*dockedClientID].Mlaunch.data[1][2] = -ClientInfo[*dockedClientID].Mlaunch.data[1][2]; ClientInfo[*dockedClientID].Mlaunch.data[2][2] = -ClientInfo[*dockedClientID].Mlaunch.data[2][2]; ClientInfo[*dockedClientID].Vlaunch.x += ClientInfo[*dockedClientID].Mlaunch.data[0][0]*90; ClientInfo[*dockedClientID].Vlaunch.y += ClientInfo[*dockedClientID].Mlaunch.data[1][0]*90; ClientInfo[*dockedClientID].Vlaunch.z += ClientInfo[*dockedClientID].Mlaunch.data[2][0]*90; } else { ClientInfo[*dockedClientID].Vlaunch.x += ClientInfo[*dockedClientID].Mlaunch.data[0][1]*set_iMobileDockOffset; ClientInfo[*dockedClientID].Vlaunch.y += ClientInfo[*dockedClientID].Mlaunch.data[1][1]*set_iMobileDockOffset; ClientInfo[*dockedClientID].Vlaunch.z += ClientInfo[*dockedClientID].Mlaunch.data[2][1]*set_iMobileDockOffset; } } else //backup: set player's base to that of target, hope they won't get kicked (this shouldn't happen) { Players[*dockedClientID].iBaseID = Players[iClientID].iBaseID; } } } ClientInfo[*dockedClientID].iDockClientID = 0; } ClientInfo[iClientID].lstPlayersDocked.clear(); } //Remove kbeam cargo restore for(uint i=0; i<vRestoreKBeamClientIDs.size(); i++) { if(iClientID==vRestoreKBeamClientIDs[i]) { if(i!=vRestoreKBeamClientIDs.size()-1) { vRestoreKBeamClientIDs[i] = vRestoreKBeamClientIDs[vRestoreKBeamClientIDs.size()-1]; vRestoreKBeamCargo[i] = vRestoreKBeamCargo[vRestoreKBeamCargo.size()-1]; } vRestoreKBeamClientIDs.pop_back(); vRestoreKBeamCargo.pop_back(); break; } } //Check the undock kill list, just in case foreach(lstUndockKill, MOB_UNDOCKBASEKILL, bkill) { if(bkill->iClientID == iClientID) { lstUndockKill.erase(bkill); break; } } if(!iShip) { uint iShipID; pub::Player::GetShipID(iClientID, iShipID); if(ClientInfo[iClientID].iShipID && ClientInfo[iClientID].iShipID!=iShipID) { HkNewShipBought(iClientID); } } bDeathPenaltyOnEnter = ClientInfo[iClientID].bDeathPenaltyOnEnter; if(ClientInfo[iClientID].iControllerID) pub::Controller::Destroy(ClientInfo[iClientID].iControllerID); if(!ClientInfo[iClientID].bDisconnected) { ClientInfo[iClientID].bDisconnected = true; // event wszCharname = Players.GetActiveCharacterName(iClientID); ProcessEvent(L"disconnect char=%s id=%d", (wszCharname ? wszCharname : L""), iClientID); } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } Server.DisConnect(iClientID, p2); try{ //mobile docking - add position, system to char file if(wscPlayerName.length()) { list<wstring> lstCharFile; if(HKHKSUCCESS(HkReadCharFile(wscPlayerName, lstCharFile))) { wchar_t wszPos[32]; swprintf(wszPos, L"pos = %f, %f, %f", VCharFilePos.x, VCharFilePos.y, VCharFilePos.z); list<wstring>::iterator line = lstCharFile.begin(); wstring wscCharFile = L""; bool bReplacedBase = false, bFoundPos = false, bFoundSystem = wscSystem.length() ? false : true; for(line = lstCharFile.begin(); line!=lstCharFile.end(); line++) { wstring wscNewLine = *line; if(!bReplacedBase && line->find(L"base")==0) { wscNewLine = L"last_" + *line; bReplacedBase = true; continue; //for now } if(!bFoundPos && line->find(L"system")==0) { if(!bFoundSystem) { wscNewLine = L"system = " + wscSystem; bFoundSystem = true; } wscNewLine += L"\n"; wscNewLine += wszPos; bFoundPos = true; } wscCharFile += wscNewLine + L"\n"; } wscCharFile.substr(0, wscCharFile.length()-1); HkWriteCharFile(wscPlayerName, wscCharFile); } } if(bDeathPenaltyOnEnter) { HkPenalizeDeath(wszCharname, 0, true); } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } /************************************************************************************************************** Called when trade is being terminated **************************************************************************************************************/ void __stdcall TerminateTrade(unsigned int iClientID, int iAccepted) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); ISERVER_LOGARG_I(iAccepted); Server.TerminateTrade(iClientID, iAccepted); try { if(iAccepted) { // save both chars to prevent cheating in case of server crash HkSaveChar(ARG_CLIENTID(iClientID)); if(ClientInfo[iClientID].iTradePartner) HkSaveChar(ARG_CLIENTID(ClientInfo[iClientID].iTradePartner)); } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } /************************************************************************************************************** Called when new trade request **************************************************************************************************************/ void __stdcall InitiateTrade(unsigned int iClientID1, unsigned int iClientID2) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID1); ISERVER_LOGARG_UI(iClientID2); try { // save traders client-ids ClientInfo[iClientID1].iTradePartner = iClientID2; ClientInfo[iClientID2].iTradePartner = iClientID1; } catch(...) { AddLog("Exception in %s", __FUNCTION__); } Server.InitiateTrade(iClientID1, iClientID2); } /************************************************************************************************************** Called when equipment is being activated/disabled **************************************************************************************************************/ void __stdcall ActivateEquip(unsigned int iClientID, struct XActivateEquip const &aq) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); try { if((aq.sID == 0x23) && !aq.bActivate) ClientInfo[iClientID].bCruiseActivated = false; // enginekill enabled ClientInfo[iClientID].bEngineKilled = !aq.bActivate; } catch(...) { AddLog("Exception in %s", __FUNCTION__); } Server.ActivateEquip(iClientID, aq); } /************************************************************************************************************** Called when cruise engine is being activated/disabled **************************************************************************************************************/ void __stdcall ActivateCruise(unsigned int iClientID, struct XActivateCruise const &ac) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); try { ClientInfo[iClientID].bCruiseActivated = ac.bActivate; } catch(...) { AddLog("Exception in %s", __FUNCTION__); } Server.ActivateCruise(iClientID, ac); } /************************************************************************************************************** Called when thruster is being activated/disabled **************************************************************************************************************/ void __stdcall ActivateThrusters(unsigned int iClientID, struct XActivateThrusters const &at) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); try { ClientInfo[iClientID].bThrusterActivated = at.bActivate; } catch(...) { AddLog("Exception in %s", __FUNCTION__); } Server.ActivateThrusters(iClientID, at); } /************************************************************************************************************** Called when player sells good on a base **************************************************************************************************************/ void __stdcall GFGoodSell(struct SGFGoodSellInfo const &gsi, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); try { // anti base-idle ClientInfo[iClientID].iBaseEnterTime = (uint)time(0); // anti-cheat check list <CARGO_INFO> lstCargo; HkEnumCargo(ARG_CLIENTID(iClientID), lstCargo, 0); foreach(lstCargo, CARGO_INFO, it) { if(((*it).iArchID == gsi.iArchID) && (abs(gsi.iCount) > (*it).iCount)) { const wchar_t *wszCharname = Players.GetActiveCharacterName(iClientID); HkAddCheaterLog(wszCharname, L"Sold more good than possible"); wchar_t wszBuf[256]; swprintf(wszBuf, L"Possible cheating detected (%s)", wszCharname); HkMsgU(wszBuf); HkBan(ARG_CLIENTID(iClientID), true); HkKick(ARG_CLIENTID(iClientID)); } } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } Server.GFGoodSell(gsi, iClientID); } /************************************************************************************************************** Called when player connects or pushes f1 or respawns after dying **************************************************************************************************************/ void __stdcall CharacterInfoReq(unsigned int iClientID, bool p2) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); ISERVER_LOGARG_UI(p2); Vector VCharFilePos; wstring wscPlayerName = L"", wscSystem = L""; try { if (ClientInfo[iClientID].bInWrapGate) { // OMG JH F1 HAXER, KILL KILL KILL NOW uint iShip; pub::Player::GetShip(iClientID, iShip); //if(iShip) pub::SpaceObj::SetInvincible(iShip, false, false, 0); pub::SpaceObj::SetRelativeHealth(iShip, 0.0f); // kills the player } if(!ClientInfo[iClientID].bCharSelected) ClientInfo[iClientID].bCharSelected = true; else { // pushed f1 uint iShip = 0; pub::Player::GetShip(iClientID, iShip); if(!ClientInfo[iClientID].bCharInfoReqAfterDeath) { pub::Controller::Destroy(ClientInfo[iClientID].iControllerID); //mobile docking if(ClientInfo[iClientID].bMobileDocked) { if(!iShip) //Docked at carrier { if(ClientInfo[iClientID].iDockClientID) //carrier still exists { Players[iClientID].iPrevBaseID = Players[ClientInfo[iClientID].iDockClientID].iPrevBaseID; uint iTargetShip; pub::Player::GetShip(ClientInfo[iClientID].iDockClientID, iTargetShip); if(iTargetShip) //carrier in space { Matrix m; pub::SpaceObj::GetLocation(iTargetShip, VCharFilePos, m); wscPlayerName = Players.GetActiveCharacterName(iClientID); } else //carrier docked { Players[iClientID].iBaseID = Players[ClientInfo[iClientID].iDockClientID].iBaseID; } wscSystem = HkGetPlayerSystem(iClientID); //remove from docked client list ClientInfo[ClientInfo[iClientID].iDockClientID].lstPlayersDocked.remove(iClientID); } else //carrier does not exist, use stored location info { if(ClientInfo[iClientID].lstJumpPath.size()) { uint iSystemID; pub::GetSystemGateConnection(ClientInfo[iClientID].lstJumpPath.back(), iSystemID); wscSystem = HkGetSystemNickByID(iSystemID); } list<MOB_UNDOCKBASEKILL>::iterator killClient = lstUndockKill.begin(); //Find the last_base for(killClient = lstUndockKill.begin(); killClient!=lstUndockKill.end(); killClient++) { if(iClientID==killClient->iClientID) { Players[iClientID].iBaseID = killClient->iBaseID; Players[iClientID].iPrevBaseID = killClient->iBaseID; lstUndockKill.erase(killClient); break; } } VCharFilePos = ClientInfo[iClientID].Vlaunch; wscPlayerName = Players.GetActiveCharacterName(iClientID); } } else //in space, update last base only { if(ClientInfo[iClientID].iDockClientID) //carrier still exists { Players[iClientID].iPrevBaseID = Players[ClientInfo[iClientID].iDockClientID].iPrevBaseID; } } } if(ClientInfo[iClientID].lstPlayersDocked.size()) { Matrix m; Vector v; uint iShip; pub::Player::GetShip(iClientID, iShip); if(iShip) pub::SpaceObj::GetLocation(iShip, v, m); foreach(ClientInfo[iClientID].lstPlayersDocked, uint, dockedClientID) //go through all of the docked players and deal with them { uint iDockedShip; pub::Player::GetShip(*dockedClientID, iDockedShip); if(iDockedShip) //player is in space { Players[*dockedClientID].iPrevBaseID = iShip ? Players[iClientID].iPrevBaseID : Players[iClientID].iBaseID; if(!ClientInfo[*dockedClientID].lstJumpPath.size()) { ClientInfo[*dockedClientID].bMobileDocked = false; } } else //player is docked { if(iShip) //carrier is in space { ClientInfo[*dockedClientID].Vlaunch = v; ClientInfo[*dockedClientID].Mlaunch = m; MOB_UNDOCKBASEKILL dKill; dKill.iClientID = *dockedClientID; dKill.iBaseID = Players[iClientID].iPrevBaseID; dKill.bKill = false; lstUndockKill.push_back(dKill); } else //carrier is docked { uint iTargetShip = ClientInfo[iClientID].iLastSpaceObjDocked; MOB_UNDOCKBASEKILL dKill; dKill.iClientID = *dockedClientID; dKill.iBaseID = ClientInfo[iClientID].iLastEnteredBaseID; dKill.bKill = false; lstUndockKill.push_back(dKill); if(iTargetShip) //got the spaceObj of the base alright { uint iType; pub::SpaceObj::GetType(iTargetShip, iType); pub::SpaceObj::GetLocation(iTargetShip, ClientInfo[*dockedClientID].Vlaunch, ClientInfo[*dockedClientID].Mlaunch); if(iType==32) { ClientInfo[*dockedClientID].Mlaunch.data[0][0] = -ClientInfo[*dockedClientID].Mlaunch.data[0][0]; ClientInfo[*dockedClientID].Mlaunch.data[1][0] = -ClientInfo[*dockedClientID].Mlaunch.data[1][0]; ClientInfo[*dockedClientID].Mlaunch.data[2][0] = -ClientInfo[*dockedClientID].Mlaunch.data[2][0]; ClientInfo[*dockedClientID].Mlaunch.data[0][2] = -ClientInfo[*dockedClientID].Mlaunch.data[0][2]; ClientInfo[*dockedClientID].Mlaunch.data[1][2] = -ClientInfo[*dockedClientID].Mlaunch.data[1][2]; ClientInfo[*dockedClientID].Mlaunch.data[2][2] = -ClientInfo[*dockedClientID].Mlaunch.data[2][2]; ClientInfo[*dockedClientID].Vlaunch.x += ClientInfo[*dockedClientID].Mlaunch.data[0][0]*90; ClientInfo[*dockedClientID].Vlaunch.y += ClientInfo[*dockedClientID].Mlaunch.data[1][0]*90; ClientInfo[*dockedClientID].Vlaunch.z += ClientInfo[*dockedClientID].Mlaunch.data[2][0]*90; } else { ClientInfo[*dockedClientID].Vlaunch.x += ClientInfo[*dockedClientID].Mlaunch.data[0][1]*set_iMobileDockOffset; ClientInfo[*dockedClientID].Vlaunch.y += ClientInfo[*dockedClientID].Mlaunch.data[1][1]*set_iMobileDockOffset; ClientInfo[*dockedClientID].Vlaunch.z += ClientInfo[*dockedClientID].Mlaunch.data[2][1]*set_iMobileDockOffset; } } else //backup: set player's base to that of target, hope they won't get kicked (this shouldn't happen) { Players[*dockedClientID].iBaseID = Players[iClientID].iBaseID; } } } ClientInfo[*dockedClientID].iDockClientID = 0; } ClientInfo[iClientID].lstPlayersDocked.clear(); } } else //Player respawning { ClientInfo[iClientID].bCharInfoReqAfterDeath = false; } ClientInfo[iClientID].iControllerID = 0; if(iShip) { // in space ClientInfo[iClientID].tmF1Time = timeInMS() + set_iAntiF1; return; } } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } try { // HkAddConnectLog(iClientID); Server.CharacterInfoReq(iClientID, p2); } catch(...) { // something is wrong with charfile HkAddKickLog(iClientID, L"Corrupt charfile?"); HkKick(ARG_CLIENTID(iClientID)); return; } try{ //mobile docking - add position to char file if(wscPlayerName.length()) { list<wstring> lstCharFile; if(HKHKSUCCESS(HkReadCharFile(wscPlayerName, lstCharFile))) { wchar_t wszPos[32]; swprintf(wszPos, L"pos = %f, %f, %f", VCharFilePos.x, VCharFilePos.y, VCharFilePos.z); list<wstring>::iterator line = lstCharFile.begin(); wstring wscCharFile = L""; bool bReplacedBase = false, bFoundPos = false, bFoundSystem = wscSystem.length() ? false : true; for(line = lstCharFile.begin(); line!=lstCharFile.end(); line++) { wstring wscNewLine = *line; if(!bReplacedBase && line->find(L"base")==0) { wscNewLine = L"last_" + *line; bReplacedBase = true; continue; //for now } if(!bFoundPos && line->find(L"system")==0) { if(!bFoundSystem) { wscNewLine = L"system = " + wscSystem; bFoundSystem = true; } wscNewLine += L"\n"; wscNewLine += wszPos; bFoundPos = true; } wscCharFile += wscNewLine + L"\n"; } wscCharFile.substr(0, wscCharFile.length()-1); HkWriteCharFile(wscPlayerName, wscCharFile); } } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } /************************************************************************************************************** Called when player jumps in system **************************************************************************************************************/ void __stdcall JumpInComplete(unsigned int iSystemID, unsigned int iShip) { ISERVER_LOG(); ISERVER_LOGARG_UI(iSystemID); ISERVER_LOGARG_UI(iShip); Server.JumpInComplete(iSystemID, iShip); try { uint iClientID = HkGetClientIDByShip(iShip); if(!iClientID) return; //mobile docking - update last base to that of the proxy base in new system for those docked but in space, also fix up jump path if(ClientInfo[iClientID].lstPlayersDocked.size()) { string scBase = HkGetPlayerSystemS(iClientID) + "_Mobile_Proxy_Base"; uint iBaseID = 0; pub::GetBaseID(iBaseID, (scBase).c_str()); if(iBaseID) { foreach(ClientInfo[iClientID].lstPlayersDocked, uint, dockedClientID) { Players[*dockedClientID].iPrevBaseID = iBaseID; for(list<uint>::iterator jumpObj = ClientInfo[*dockedClientID].lstJumpPath.begin(); jumpObj!=ClientInfo[*dockedClientID].lstJumpPath.end(); jumpObj++) { uint iJumpSystemID; pub::SpaceObj::GetSystem(*jumpObj, iJumpSystemID); if(iJumpSystemID==iSystemID) { ClientInfo[*dockedClientID].lstJumpPath.erase(jumpObj, ClientInfo[*dockedClientID].lstJumpPath.end()); break; } } } } } // mobile docking switching systems if(ClientInfo[iClientID].lstJumpPath.size()) //player is traveling to carrier { ClientInfo[iClientID].bPathJump = true; pub::SpaceObj::InstantDock(iShip, ClientInfo[iClientID].lstJumpPath.front(), 1); ClientInfo[iClientID].lstJumpPath.pop_front(); return; } else { if(ClientInfo[iClientID].bPathJump) { if(ClientInfo[iClientID].iDockClientID) //carrier still exists { uint iTargetShip; pub::Player::GetShip(ClientInfo[iClientID].iDockClientID, iTargetShip); if(iTargetShip) //carrier in space { Vector vBeam; Matrix mBeam; pub::SpaceObj::GetLocation(iTargetShip, vBeam, mBeam); vBeam.x += mBeam.data[0][1]*set_iMobileDockOffset; vBeam.y += mBeam.data[1][1]*set_iMobileDockOffset; vBeam.z += mBeam.data[2][1]*set_iMobileDockOffset; HkBeamInSys(ARG_CLIENTID(iClientID), vBeam, mBeam); } else //carrier docked { uint iTargetShip = ClientInfo[ClientInfo[iClientID].iDockClientID].iLastSpaceObjDocked; if(iTargetShip) //got the spaceObj of the base alright { uint iType; pub::SpaceObj::GetType(iTargetShip, iType); Vector vBeam; Matrix mBeam; pub::SpaceObj::GetLocation(iTargetShip, vBeam, mBeam); if(iType==32) { mBeam.data[0][0] = -mBeam.data[0][0]; mBeam.data[1][0] = -mBeam.data[1][0]; mBeam.data[2][0] = -mBeam.data[2][0]; mBeam.data[0][2] = -mBeam.data[0][2]; mBeam.data[1][2] = -mBeam.data[1][2]; mBeam.data[2][2] = -mBeam.data[2][2]; vBeam.x += mBeam.data[0][0]*90; vBeam.y += mBeam.data[1][0]*90; vBeam.z += mBeam.data[2][0]*90; } else { vBeam.x += mBeam.data[0][1]*set_iMobileDockOffset; vBeam.y += mBeam.data[1][1]*set_iMobileDockOffset; vBeam.z += mBeam.data[2][1]*set_iMobileDockOffset; } HkBeamInSys(ARG_CLIENTID(iClientID), vBeam, mBeam); } } } else //carrier does not exist, use stored info { HkBeamInSys(ARG_CLIENTID(iClientID), ClientInfo[iClientID].Vlaunch, ClientInfo[iClientID].Mlaunch); ClientInfo[iClientID].bMobileDocked = false; } ClientInfo[iClientID].bPathJump = false; } } ClientInfo[iClientID].bInWrapGate = false; if(ClientInfo[iClientID].bCanCloak && (ClientInfo[iClientID].bCloaked || ClientInfo[iClientID].bIsCloaking)) ClientInfo[iClientID].bMustSendUncloak = true; //Make player damageable pub::SpaceObj::SetInvincible(iShip, false, false, 0); //marking - check to see if any of the delayed marks correspond to new system vector<uint> vTempMark; for(uint i=0; i<ClientInfo[iClientID].vDelayedSystemMarkedObjs.size(); i++) { if(pub::SpaceObj::ExistsAndAlive(ClientInfo[iClientID].vDelayedSystemMarkedObjs[i])) { if(i!=ClientInfo[iClientID].vDelayedSystemMarkedObjs.size()-1) { ClientInfo[iClientID].vDelayedSystemMarkedObjs[i] = ClientInfo[iClientID].vDelayedSystemMarkedObjs[ClientInfo[iClientID].vDelayedSystemMarkedObjs.size()-1]; i--; } ClientInfo[iClientID].vDelayedSystemMarkedObjs.pop_back(); continue; } uint iTargetSystem; pub::SpaceObj::GetSystem(ClientInfo[iClientID].vDelayedSystemMarkedObjs[i], iTargetSystem); if(iTargetSystem==iSystemID) { pub::Player::MarkObj(iClientID, ClientInfo[iClientID].vDelayedSystemMarkedObjs[i], 1); vTempMark.push_back(ClientInfo[iClientID].vDelayedSystemMarkedObjs[i]); if(i!=ClientInfo[iClientID].vDelayedSystemMarkedObjs.size()-1) { ClientInfo[iClientID].vDelayedSystemMarkedObjs[i] = ClientInfo[iClientID].vDelayedSystemMarkedObjs[ClientInfo[iClientID].vDelayedSystemMarkedObjs.size()-1]; i--; } ClientInfo[iClientID].vDelayedSystemMarkedObjs.pop_back(); } } for(uint i=0; i<ClientInfo[iClientID].vMarkedObjs.size(); i++) { if(!pub::SpaceObj::ExistsAndAlive(ClientInfo[iClientID].vMarkedObjs[i])) ClientInfo[iClientID].vDelayedSystemMarkedObjs.push_back(ClientInfo[iClientID].vMarkedObjs[i]); } ClientInfo[iClientID].vMarkedObjs = vTempMark; //Death Penalty - calculate DP and display message to character if switching from a system on the exclude list if(set_fDeathPenalty && !ClientInfo[iClientID].iDeathPenaltyCredits) { UINT_WRAP uwShip = UINT_WRAP(Players[iClientID].iShipArchID); UINT_WRAP uwSystem = UINT_WRAP(Players[iClientID].iSystemID); if(!set_btNoDeathPenalty->Find(&uwShip) && !set_btNoDPSystems->Find(&uwSystem)) { int iCash; HkGetCash(ARG_CLIENTID(iClientID), iCash); float fValue; pub::Player::GetAssetValue(iClientID, fValue); ClientInfo[iClientID].iDeathPenaltyCredits = (int)(fValue * set_fDeathPenalty); if(ClientInfo[iClientID].bDisplayDPOnLaunch) PrintUserCmdText(iClientID, L"Notice: the death penalty for your ship will be %i credits. Type /dp for more information.", ClientInfo[iClientID].iDeathPenaltyCredits); } } // event ProcessEvent(L"jumpin char=%s id=%d system=%s", Players.GetActiveCharacterName(iClientID), iClientID, HkGetSystemNickByID(iSystemID).c_str()); } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } /************************************************************************************************************** Called when player jumps out of system **************************************************************************************************************/ void __stdcall SystemSwitchOutComplete(unsigned int iShip, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iShip); ISERVER_LOGARG_UI(iClientID); try { //mobile docking if(ClientInfo[iClientID].lstPlayersDocked.size()) { uint iTarget; pub::SpaceObj::GetTarget(iShip, iTarget); foreach(ClientInfo[iClientID].lstPlayersDocked, uint, dockedClientID) { uint iDockedShip; pub::Player::GetShip(*dockedClientID, iDockedShip); if(!iDockedShip) ClientInfo[*dockedClientID].lstJumpPath.push_back(iTarget); } } // event ProcessEvent(L"switchout char=%s id=%d system=%s", Players.GetActiveCharacterName(iClientID), iClientID, HkGetPlayerSystem(iClientID).c_str()); } catch(...) { AddLog("Exception in %s", __FUNCTION__); } //Make player invincible to fix JHs/JGs near mine fields sometimes exploding player while jumping (in jump tunnel) pub::SpaceObj::SetInvincible(iShip, true, true, 0); ClientInfo[iClientID].bInWrapGate = true; Server.SystemSwitchOutComplete(iShip, iClientID); } /************************************************************************************************************** Called when player logs in **************************************************************************************************************/ void __stdcall Login(struct SLoginInfo const &li, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_WS(&li); ISERVER_LOGARG_UI(iClientID); Server.Login(li, iClientID); try { if(iClientID > Players.GetMaxPlayerCount()) return; // lalala DisconnectDelay bug if(!HkIsValidClientID(iClientID)) return; // player was kicked // check for ip ban wstring wscIP; HkGetPlayerIP(iClientID, wscIP); foreach(set_lstBans, wstring, itb) { if(Wildcard::wildcardfit(wstos(*itb).c_str(), wstos(wscIP).c_str())) { HkAddKickLog(iClientID, L"IP/Hostname ban(%s matches %s)", wscIP.c_str(), (*itb).c_str()); if(set_bBanAccountOnMatch) HkBan(ARG_CLIENTID(iClientID), true); HkKick(ARG_CLIENTID(iClientID)); } } // resolve RESOLVE_IP rip; rip.wscIP = wscIP; rip.wscHostname = L""; rip.iConnects = ClientInfo[iClientID].iConnects; // security check so that wrong person doesnt get banned rip.iClientID = iClientID; EnterCriticalSection(&csIPResolve); g_lstResolveIPs.push_back(rip); LeaveCriticalSection(&csIPResolve); // count players struct PlayerData *pPD = 0; uint iPlayers = 0; while(pPD = Players.traverse_active(pPD)) iPlayers++; if(iPlayers > (Players.GetMaxPlayerCount() - set_iReservedSlots)) { // check if player has a reserved slot CAccount *acc = Players.FindAccountFromClientID(iClientID); wstring wscDir; HkGetAccountDirName(acc, wscDir); string scUserFile = scAcctPath + wstos(wscDir) + "\\flhookuser.ini"; bool bReserved = IniGetB(scUserFile, "Settings", "ReservedSlot", false); if(!bReserved) { HkKick(ARG_CLIENTID(iClientID)); return; } } LoadUserSettings(iClientID); } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } /************************************************************************************************************** Called on item spawn **************************************************************************************************************/ void __stdcall MineAsteroid(unsigned int p1, class Vector const &vPos, unsigned int iLookID, unsigned int iGoodID, unsigned int iCount, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); // ISERVER_LOGARG_UI(vPos); ISERVER_LOGARG_UI(iLookID); ISERVER_LOGARG_UI(iGoodID); ISERVER_LOGARG_UI(iCount); ISERVER_LOGARG_UI(iClientID); /*try { PrintUniverseText(L"MineAsteroid %u %u %u %u %u", p1, iLookID, iGoodID, iCount, iClientID); } catch(...) { AddLog("Exception in %s", __FUNCTION__); }*/ Server.MineAsteroid(p1, vPos, iLookID, iGoodID, iCount, iClientID); } /************************************************************************************************************** **************************************************************************************************************/ void __stdcall GoTradelane(unsigned int iClientID, struct XGoTradelane const &gtl) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); try { ClientInfo[iClientID].bTradelane = true; } catch(...) { AddLog("Exception in %s", __FUNCTION__); } Server.GoTradelane(iClientID, gtl); } /************************************************************************************************************** **************************************************************************************************************/ void __stdcall StopTradelane(unsigned int iClientID, unsigned int p2, unsigned int p3, unsigned int p4) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); ISERVER_LOGARG_UI(p2); ISERVER_LOGARG_UI(p3); ISERVER_LOGARG_UI(p4); try { ClientInfo[iClientID].bTradelane = false; } catch(...) { AddLog("Exception in %s", __FUNCTION__); } Server.StopTradelane(iClientID, p2, p3, p4); } //////////////////////////////////////////////////////// void __stdcall AbortMission(unsigned int p1, unsigned int p2) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_UI(p2); Server.AbortMission(p1, p2); } void __stdcall AcceptTrade(unsigned int iClientID, bool p2) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); ISERVER_LOGARG_UI(p2); Server.AcceptTrade(iClientID, p2); } /************************************************************************************************************** Called when player adds an item to a trade request **************************************************************************************************************/ void __stdcall AddTradeEquip(unsigned int iClientID, struct EquipDesc const &ed) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); Server.AddTradeEquip(iClientID, ed); try { UINT_WRAP uw = UINT_WRAP(ed.archid); if(set_btNoTrade->Find(&uw)) { pub::Player::SendNNMessage(iClientID, pub::GetNicknameId("objective_failed")); pub::Player::SendNNMessage(iClientID, pub::GetNicknameId("none_available")); Server.TerminateTrade(iClientID, 0); //cancel trade } else { map<uint, map<Archetype::AClassType, char> >::iterator typeMap = set_mapSysItemRestrictions.find(Players[iClientID].iSystemID); if(typeMap != set_mapSysItemRestrictions.end()) { Archetype::Equipment *equip = Archetype::GetEquipment(ed.archid); map<Archetype::AClassType, char>::iterator types = typeMap->second.find(equip->get_class_type()); if(types != typeMap->second.end()) { pub::Player::SendNNMessage(iClientID, pub::GetNicknameId("objective_failed")); pub::Player::SendNNMessage(iClientID, pub::GetNicknameId("none_available")); Server.TerminateTrade(iClientID, 0); //cancel trade } } } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } void __stdcall BaseInfoRequest(unsigned int p1, unsigned int p2, bool p3) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_UI(p2); ISERVER_LOGARG_UI(p3); Server.BaseInfoRequest(p1, p2, p3); } void __stdcall CharacterSkipAutosave(unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); Server.CharacterSkipAutosave(iClientID); } void __stdcall CommComplete(unsigned int p1, unsigned int p2, unsigned int p3,enum CommResult cr) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_UI(p2); ISERVER_LOGARG_UI(p3); ISERVER_LOGARG_UI(cr); Server.CommComplete(p1, p2, p3, cr); } void __stdcall Connect(char const *p1, unsigned short *p2) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_WS(p2); Server.Connect(p1, p2); // doesn't do anything } void __stdcall CreateNewCharacter(struct SCreateCharacterInfo const & scci, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); Server.CreateNewCharacter(scci, iClientID); } void __stdcall DelTradeEquip(unsigned int iClientID, struct EquipDesc const &ed) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); Server.DelTradeEquip(iClientID, ed); } void __stdcall DestroyCharacter(struct CHARACTER_ID const &cId, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); ISERVER_LOGARG_S(&cId); Server.DestroyCharacter(cId, iClientID); } void __stdcall Dock(unsigned int const &p1, unsigned int const &p2) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_UI(p2); Server.Dock(p1, p2); } void __stdcall DumpPacketStats(char const *p1) { ISERVER_LOG(); Server.DumpPacketStats(p1); } void __stdcall ElapseTime(float p1) { ISERVER_LOG(); ISERVER_LOGARG_F(p1); Server.ElapseTime(p1); } void __stdcall GFGoodBuy(struct SGFGoodBuyInfo const &gbi, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); Server.GFGoodBuy(gbi, iClientID); } void __stdcall GFGoodVaporized(struct SGFGoodVaporizedInfo const &gvi, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); Server.GFGoodVaporized(gvi, iClientID); } void __stdcall GFObjSelect(unsigned int p1, unsigned int p2) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_UI(p2); Server.GFObjSelect(p1, p2); } unsigned int __stdcall GetServerID(void) { ISERVER_LOG(); return Server.GetServerID(); } char const * __stdcall GetServerSig(void) { ISERVER_LOG(); return Server.GetServerSig(); } void __stdcall GetServerStats(struct ServerStats &ss) { ISERVER_LOG(); Server.GetServerStats(ss); } void __stdcall Hail(unsigned int p1, unsigned int p2, unsigned int p3) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_UI(p2); ISERVER_LOGARG_UI(p3); Server.Hail(p1, p2, p3); } void __stdcall InterfaceItemUsed(unsigned int p1, unsigned int p2) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_UI(p2); Server.InterfaceItemUsed(p1, p2); } void __stdcall JettisonCargo(unsigned int iClientID, struct XJettisonCargo const &jc) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); Server.JettisonCargo(iClientID, jc); } /************************************************************************************************************** Called when player enters a room on a base **************************************************************************************************************/ void __stdcall LocationEnter(unsigned int p1, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_UI(iClientID); Server.LocationEnter(p1, iClientID); try { // anti base-idle ClientInfo[iClientID].iBaseEnterTime = (uint)time(0); } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } /************************************************************************************************************** Called when player exits a room on a base **************************************************************************************************************/ void __stdcall LocationExit(unsigned int p1, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_UI(iClientID); Server.LocationExit(p1, iClientID); try { uint iShipID; pub::Player::GetShipID(iClientID, iShipID); if(ClientInfo[iClientID].iShipID && ClientInfo[iClientID].iShipID!=iShipID) { HkNewShipBought(iClientID); } ClientInfo[iClientID].iShipID = iShipID; } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } void __stdcall LocationInfoRequest(unsigned int p1,unsigned int p2, bool p3) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_UI(p2); ISERVER_LOGARG_UI(p3); Server.LocationInfoRequest(p1, p2, p3); } void __stdcall MissionResponse(unsigned int p1, unsigned long p2, bool p3, unsigned int p4) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_UI(p2); ISERVER_LOGARG_UI(p3); ISERVER_LOGARG_UI(p4); Server.MissionResponse(p1, p2, p3, p4); } void __stdcall MissionSaveB(unsigned int iClientID, unsigned long p2) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); ISERVER_LOGARG_UI(p2); Server.MissionSaveB(iClientID, p2); } void __stdcall NewCharacterInfoReq(unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); Server.NewCharacterInfoReq(iClientID); // doesn't do anything } void __stdcall PopUpDialog(unsigned int p1, unsigned int p2) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_UI(p2); Server.PopUpDialog(p1, p2); } void __stdcall PushToServer(class CDAPacket *packet) { ISERVER_LOG(); Server.PushToServer(packet); // doesn't do anything } void __stdcall RTCDone(unsigned int p1, unsigned int p2) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_UI(p2); Server.RTCDone(p1, p2); } /************************************************************************************************************** Called when an item (Commodity, equipment) is bought **************************************************************************************************************/ /*p1 = GoodID p2 = ?, seems to have something to do with the hardpoint p3 = number of items p4 = health p5 = mounted p6 = client-id*/ void __stdcall ReqAddItem(unsigned int p1, char const *p2, int p3, float p4, bool p5, unsigned int p6) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); // ISERVER_LOGARG_S(p2); ISERVER_LOGARG_UI(p3); ISERVER_LOGARG_F(p4); ISERVER_LOGARG_UI(p5); ISERVER_LOGARG_UI(p6); bool bFoundItemRestriction = false; try { if(p5) { MOUNT_RESTRICTION mrFind = MOUNT_RESTRICTION(p1); MOUNT_RESTRICTION *mrFound = set_btMRestrict->Find(&mrFind); /*Check to make sure ship can mount good*/ if(mrFound) { uint iShipArchID; pub::Player::GetShipID(p6, iShipArchID); UINT_WRAP uw = UINT_WRAP(iShipArchID); if(!mrFound->btShipArchIDs->Find(&uw)) { pub::Player::SendNNMessage(p6, pub::GetNicknameId("cancelled")); pub::Player::SendNNMessage(p6, pub::GetNicknameId("loaded_into_cargo_hold")); pub::Player::SendNNMessage(p6, pub::GetNicknameId("no_place_to_mount")); p5 = false; //block mount } } } //Item restrictions ITEM_RESTRICT irFind = ITEM_RESTRICT(p1); ITEM_RESTRICT *irFound = set_btItemRestrictions->Find(&irFind); if(irFound) { list<CARGO_INFO> lstCargo; HkEnumCargo(ARG_CLIENTID(p6), lstCargo, 0); foreach(lstCargo, CARGO_INFO, cargo) { UINT_WRAP uw = UINT_WRAP(cargo->iArchID); if(irFound->btItems->Find(&uw)) { bFoundItemRestriction = true; break; } } } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } Server.ReqAddItem(p1, p2, p3, p4, p5, p6); try { if(bFoundItemRestriction) { ushort iID; HkGetSIDFromGoodID(p6, iID, p1); pub::Player::RemoveCargo(p6, iID, p3); uint iBaseID; pub::Player::GetBase(p6, iBaseID); float fPrice = 0; pub::Market::GetPrice(iBaseID, p1, fPrice); if(fPrice) HkAddCash(ARG_CLIENTID(p6), (int)fPrice); pub::Player::SendNNMessage(p6, pub::GetNicknameId("cancelled")); pub::Player::SendNNMessage(p6, pub::GetNicknameId("not_interested")); } /*Code for rep change when items are bought*/ if(p5)//Item is being added mounted { for(uint i = 0 ; (i < set_vAffilItems.size()); i++) //Items set in INI { if(set_vAffilItems[i]==p1) { uint iBaseID; pub::Player::GetBase(p6, iBaseID); iBaseID = HkGetSpaceObjFromBaseID(iBaseID); int iBaseRep, iPlayerRep; pub::SpaceObj::GetSolarRep(iBaseID, iBaseRep); pub::Player::GetRep(p6, iPlayerRep); uint iRepGroupID, iOldRepGroupID; Reputation::Vibe::GetAffiliation(iBaseRep, iRepGroupID, false); Reputation::Vibe::GetAffiliation(iPlayerRep, iOldRepGroupID, false); if(iOldRepGroupID!=iRepGroupID) Reputation::Vibe::SetAffiliation(iPlayerRep, iRepGroupID, false); return; } } foreach(set_lstFactionTags, FACTION_TAG, tag) //Auto-detected items in misc_equip.ini { if((*tag).iArchID==p1) { uint iRepGroupID, iOldRepGroupID; pub::Reputation::GetReputationGroup(iRepGroupID, (*tag).scFaction.c_str()); int iPlayerRep; pub::Player::GetRep(p6, iPlayerRep); Reputation::Vibe::GetAffiliation(iPlayerRep, iOldRepGroupID, false); if(iOldRepGroupID!=iRepGroupID) Reputation::Vibe::SetAffiliation(iPlayerRep, iRepGroupID, false); break; } } } // anti base-idle ClientInfo[p6].iBaseEnterTime = (uint)time(0); } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } /************************************************************************************************************** Called when equipping internal equipment **************************************************************************************************************/ void __stdcall ReqModifyItem(unsigned short p1, char const *p2, int p3, float p4, bool p5, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); // ISERVER_LOGARG_S(p2); ISERVER_LOGARG_I(p3); ISERVER_LOGARG_F(p4); ISERVER_LOGARG_UI(p5); ISERVER_LOGARG_UI(iClientID); try { if(p5) { uint iGoodID; if(HKHKSUCCESS(HkGetGoodIDFromSID(iClientID, p1, iGoodID))) { MOUNT_RESTRICTION mrFind = MOUNT_RESTRICTION(iGoodID); MOUNT_RESTRICTION *mrFound = set_btMRestrict->Find(&mrFind); /*Check to make sure ship can mount good*/ if(mrFound) { uint iShipArchID; pub::Player::GetShipID(iClientID, iShipArchID); UINT_WRAP uw = UINT_WRAP(iShipArchID); if(!mrFound->btShipArchIDs->Find(&uw)) { //remove and then add cargo to fix client mounted disagreement pub::Player::RemoveCargo(iClientID, p1, p3); pub::Player::AddCargo(iClientID, iGoodID, p3, 1, false); pub::Player::SendNNMessage(iClientID, pub::GetNicknameId("no_place_to_mount")); return; } } } } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } Server.ReqModifyItem(p1, p2, p3, p4, p5, iClientID); try { // anti base-idle ClientInfo[iClientID].iBaseEnterTime = (uint)time(0); } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } void __stdcall ReqCargo(class EquipDescList const &edl, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); Server.ReqCargo(edl, iClientID); // doesn't do anything } void __stdcall ReqChangeCash(int p1, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_UI(iClientID); Server.ReqChangeCash(p1, iClientID); } void __stdcall ReqCollisionGroups(class std::list<struct CollisionGroupDesc,class std::allocator<struct CollisionGroupDesc> > const &p1, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); Server.ReqCollisionGroups(p1, iClientID); } void __stdcall ReqDifficultyScale(float p1, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_F(p1); ISERVER_LOGARG_UI(iClientID); Server.ReqDifficultyScale(p1, iClientID); } /************************************************************************************************************** Called when equipping all equipment other than internal equipment **************************************************************************************************************/ void __stdcall ReqEquipment(class EquipDescList const &edl, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); Server.ReqEquipment(edl, iClientID); try { // anti base-idle ClientInfo[iClientID].iBaseEnterTime = (uint)time(0); } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } void __stdcall ReqHullStatus(float p1, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_F(p1); ISERVER_LOGARG_UI(iClientID); Server.ReqHullStatus(p1, iClientID); } void __stdcall ReqRemoveItem(unsigned short p1, int p2, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_I(p2); ISERVER_LOGARG_UI(iClientID); Server.ReqRemoveItem(p1, p2, iClientID); } void __stdcall ReqSetCash(int p1, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_I(p1); ISERVER_LOGARG_UI(iClientID); Server.ReqSetCash(p1, iClientID); } void __stdcall ReqShipArch(unsigned int p1, unsigned int p2) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_UI(p2); Server.ReqShipArch(p1, p2); } void __stdcall RequestBestPath(unsigned int p1, unsigned char *p2, int p3) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); // ISERVER_LOGARG_S(p2); ISERVER_LOGARG_I(p3); Server.RequestBestPath(p1, p2, p3); } void __stdcall RequestCancel(int p1, unsigned int p2, unsigned int p3, unsigned long p4, unsigned int p5) { ISERVER_LOG(); ISERVER_LOGARG_I(p1); ISERVER_LOGARG_UI(p2); ISERVER_LOGARG_UI(p3); ISERVER_LOGARG_UI(p4); ISERVER_LOGARG_UI(p5); try{ if(!p1) //docking { foreach(ClientInfo[p5].lstRemCargo, CARGO_REMOVE, cargo) { HkAddCargo(ARG_CLIENTID(p5), cargo->iGoodID, cargo->iCount, false); } ClientInfo[p5].lstRemCargo.clear(); } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } Server.RequestCancel(p1, p2, p3, p4, p5); } void __stdcall RequestCreateShip(unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); Server.RequestCreateShip(iClientID); } /************************************************************************************************************** Called upon flight change (goto, dock, formation) **************************************************************************************************************/ /*p1 = iType? ==0 if docking, ==1 if formation p2 = iShip of person docking p3 = iShip of dock/formation target p4 seems to be 0 all the time p5 seems to be 0 all the time p6 = iClientID*/ void __stdcall RequestEvent(int p1, unsigned int p2, unsigned int p3, unsigned int p4, unsigned long p5, unsigned int p6) { ISERVER_LOG(); ISERVER_LOGARG_I(p1); ISERVER_LOGARG_UI(p2); ISERVER_LOGARG_UI(p3); ISERVER_LOGARG_UI(p4); ISERVER_LOGARG_UI(p5); ISERVER_LOGARG_UI(p6); try { //Moved to SpaceObjDock, kept here to avoid silly docking responses from bases if(!p1)//docking { float fRelativeHealth; pub::SpaceObj::GetRelativeHealth(p3, fRelativeHealth); if(fRelativeHealth<set_fBaseDockDmg) { pub::Player::SendNNMessage(p6, pub::GetNicknameId("dock_disallowed")); PrintUserCmdText(p6, L"The docking ports are damaged"); return; } //mobile docking if(!((uint)(p3/1000000000))) //Docking at non solar { if(ClientInfo[p6].bMobileBase) //prevent mobile bases from docking with each other { pub::Player::SendNNMessage(p6, pub::GetNicknameId("dock_disallowed")); return; } uint iTargetClientID = HkGetClientIDByShip(p3); if(iTargetClientID) { if(!ClientInfo[iTargetClientID].bMobileBase) { pub::Player::SendNNMessage(p6, pub::GetNicknameId("dock_disallowed")); return; } //Make sure players are in same group uint iGroupID = Players.GetGroupID(p6), iTargetGroupID = Players.GetGroupID(iTargetClientID); if(!iGroupID || !iTargetGroupID || iGroupID!=iTargetGroupID) { pub::Player::SendNNMessage(p6, pub::GetNicknameId("dock_disallowed")); return; } //Dock player at mobile dock base in system Matrix mClient, mTarget; Vector vClient, vTarget; pub::SpaceObj::GetLocation(p2, vClient, mClient); pub::SpaceObj::GetLocation(p3, vTarget, mTarget); uint iDunno; IObjInspectImpl *inspect; GetShipInspect(p3, inspect, iDunno); if(HkDistance3D(vClient, vTarget) > set_iMobileDockRadius+inspect->cobject()->hierarchy_radius()) //outside of docking radius { pub::Player::SendNNMessage(p6, pub::GetNicknameId("nnv_dock_too_far")); return; } if(!HkIsOkayToDock(p6, iTargetClientID)) { pub::Player::SendNNMessage(p6, pub::GetNicknameId("insufficient_cargo_space")); return; } string scSystem = HkGetPlayerSystemS(p6); string scBase = scSystem + "_Mobile_Proxy_Base"; uint iBaseID; if(pub::GetBaseID(iBaseID, (scBase).c_str()) == -4) //base does not exist { ConPrint(L"WARNING: Mobile docking proxy base does not exist in system " + stows(scSystem) + L"\n"); pub::Player::SendNNMessage(p6, pub::GetNicknameId("dock_disallowed")); return; } uint iTargetProxyObj = CreateID(scBase.c_str()); bIgnoreCancelMobDock = true; pub::SpaceObj::InstantDock(p2, iTargetProxyObj, 1); ClientInfo[iTargetClientID].lstPlayersDocked.remove(p6); ClientInfo[iTargetClientID].lstPlayersDocked.push_back(p6); ClientInfo[p6].bMobileDocked = true; ClientInfo[p6].iDockClientID = iTargetClientID; return; } else { pub::Player::SendNNMessage(p6, pub::GetNicknameId("dock_disallowed")); return; } } if(ClientInfo[p6].bMobileBase) { ClientInfo[p6].iLastSpaceObjDocked = p3; } ClientInfo[p6].lstRemCargo.clear(); DOCK_RESTRICTION jrFind = DOCK_RESTRICTION(p3); DOCK_RESTRICTION *jrFound = set_btJRestrict->Find(&jrFind); if(jrFound) { list<CARGO_INFO> lstCargo; bool bPresent = false; HkEnumCargo(ARG_CLIENTID(p6), lstCargo, 0); foreach(lstCargo, CARGO_INFO, cargo) { if(cargo->iArchID == jrFound->iArchID) //Item is present { if(jrFound->iCount > 0) { if(cargo->iCount >= jrFound->iCount) bPresent = true; } else if(jrFound->iCount < 0) { if(cargo->iCount >= -jrFound->iCount) { bPresent = true; CARGO_REMOVE cm; cm.iGoodID = cargo->iArchID; cm.iCount = -jrFound->iCount; ClientInfo[p6].lstRemCargo.push_back(cm); pub::Player::RemoveCargo(p6, cargo->iID, -jrFound->iCount); } } else { if(cargo->bMounted) bPresent = true; } break; } } if(!bPresent) { pub::Player::SendNNMessage(p6, pub::GetNicknameId("info_access_denied")); PrintUserCmdText(p6, jrFound->wscDeniedMsg); return; //block dock } } ClientInfo[p6].bCheckedDock = true; } } catch(...) { AddLog("Exception in %s", __FUNCTION__); } Server.RequestEvent(p1, p2, p3, p4, p5, p6); } void __stdcall RequestGroupPositions(unsigned int p1, unsigned char *p2, int p3) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); // ISERVER_LOGARG_S(p2); ISERVER_LOGARG_I(p3); Server.RequestGroupPositions(p1, p2, p3); } void __stdcall RequestPlayerStats(unsigned int p1, unsigned char *p2, int p3) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); // ISERVER_LOGARG_S(p2); ISERVER_LOGARG_I(p3); Server.RequestPlayerStats(p1, p2, p3); } void __stdcall RequestRankLevel(unsigned int p1, unsigned char *p2, int p3) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); // ISERVER_LOGARG_S(p2); ISERVER_LOGARG_I(p3); Server.RequestRankLevel(p1, p2, p3); } void __stdcall RequestTrade(unsigned int p1, unsigned int p2) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_UI(p2); Server.RequestTrade(p1, p2); } void __stdcall SPBadLandsObjCollision(struct SSPBadLandsObjCollisionInfo const &p1, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); Server.SPBadLandsObjCollision(p1, iClientID); } void __stdcall SPRequestInvincibility(unsigned int p1, bool p2, enum InvincibilityReason p3, unsigned int p4) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_UI(p2); ISERVER_LOGARG_UI(p3); ISERVER_LOGARG_UI(p4); Server.SPRequestInvincibility(p1, p2, p3, p4); } void __stdcall SPRequestUseItem(struct SSPUseItem const &p1, unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); Server.SPRequestUseItem(p1, iClientID); } void __stdcall SPScanCargo(unsigned int const &p1, unsigned int const &p2, unsigned int p3) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); ISERVER_LOGARG_UI(p2); ISERVER_LOGARG_UI(p3); Server.SPScanCargo(p1, p2, p3); } void __stdcall SaveGame(struct CHARACTER_ID const &cId, unsigned short const *p2, unsigned int p3) { ISERVER_LOG(); ISERVER_LOGARG_S(&cId); // ISERVER_LOGARG_S(p2); ISERVER_LOGARG_UI(p3); Server.SaveGame(cId, p2, p3); } void __stdcall SetActiveConnection(enum EFLConnection p1) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); Server.SetActiveConnection(p1); // doesn't do anything } void __stdcall SetInterfaceState(unsigned int p1, unsigned char *p2, int p3) { ISERVER_LOG(); ISERVER_LOGARG_UI(p1); // ISERVER_LOGARG_S(p2); ISERVER_LOGARG_I(p3); Server.SetInterfaceState(p1, p2, p3); } void __stdcall SetManeuver(unsigned int iClientID, struct XSetManeuver const &p2) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); Server.SetManeuver(iClientID, p2); } void __stdcall SetMissionLog(unsigned int iClientID, unsigned char *p2, int p3) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); // ISERVER_LOGARG_S(p2); ISERVER_LOGARG_I(p3); Server.SetMissionLog(iClientID, p2, p3); } uint iLastSetTarget = 0; /************************************************************************************************************** Called when player selects a new target **************************************************************************************************************/ void __stdcall SetTarget(unsigned int iClientID, struct XSetTarget const &p2) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); Server.SetTarget(iClientID, p2); try { //Capture solar objects for alternate solar objects repair if(p2.iTargetSpaceID!=iLastSetTarget && (uint)(p2.iTargetSpaceID/1000000000)) //target is a solar { /*uint iType; pub::SpaceObj::GetType(p2.iTargetSpaceID, iType); PrintUserCmdText(iClientID, L"type=%u", iType);*/ float fHealth, fMaxHealth; pub::SpaceObj::GetHealth(p2.iTargetSpaceID, fHealth, fMaxHealth); FLOAT_WRAP fw = FLOAT_WRAP(fMaxHealth); if(set_btSupressHealth->Find(&fw)) { SOLAR_REPAIR *sr = new SOLAR_REPAIR(p2.iTargetSpaceID, -1); sr->iObjectID = p2.iTargetSpaceID; if(!fHealth) { sr->iTimeAfterDestroyed = 0; } btSolarList->Add(sr); } } iLastSetTarget = p2.iTargetSpaceID; } catch(...) { AddLog("Exception in %s", __FUNCTION__); } } void __stdcall SetTradeMoney(unsigned int iClientID, unsigned long p2) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); ISERVER_LOGARG_UI(p2); Server.SetTradeMoney(iClientID, p2); } void __stdcall SetVisitedState(unsigned int iClientID, unsigned char *p2, int p3) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); // ISERVER_LOGARG_S(p2); ISERVER_LOGARG_I(p3); Server.SetVisitedState(iClientID, p2, p3); } void __stdcall SetWeaponGroup(unsigned int iClientID, unsigned char *p2, int p3) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); // ISERVER_LOGARG_S(p2); ISERVER_LOGARG_I(p3); Server.SetWeaponGroup(iClientID, p2, p3); } void __stdcall Shutdown(void) { ISERVER_LOG(); Server.Shutdown(); } bool __stdcall Startup(struct SStartupInfo const &p1) { ISERVER_LOG(); return Server.Startup(p1); } void __stdcall StopTradeRequest(unsigned int iClientID) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); Server.StopTradeRequest(iClientID); } /************************************************************************************************************** Called when player starts to tractor an object **************************************************************************************************************/ void __stdcall TractorObjects(unsigned int iClientID, struct XTractorObjects const &p2) { ISERVER_LOG(); ISERVER_LOGARG_UI(iClientID); //Deny tractor if dead float fHealth; pub::Player::GetRelativeHealth(iClientID, fHealth); if(!fHealth) { pub::Player::SendNNMessage(iClientID, pub::GetNicknameId("nnv_tractor_failure")); pub::Player::SendNNMessage(iClientID, pub::GetNicknameId("info_ship_destroyed")); return; } Server.TractorObjects(iClientID, p2); } void __stdcall TradeResponse(unsigned char const *p1, int p2, unsigned int iClientID) { ISERVER_LOG(); /// ISERVER_LOGARG_S(p1); ISERVER_LOGARG_I(p2); ISERVER_LOGARG_UI(iClientID); Server.TradeResponse(p1, p2, iClientID); } /************************************************************************************************************** IServImpl hook entries **************************************************************************************************************/ HOOKENTRY hookEntries[] = { {(FARPROC)SubmitChat, -0x08, 0}, {(FARPROC)FireWeapon, 0x000, 0}, {(FARPROC)ActivateEquip, 0x004, 0}, {(FARPROC)ActivateCruise, 0x008, 0}, {(FARPROC)ActivateThrusters, 0x00C, 0}, {(FARPROC)SetTarget, 0x010, 0}, {(FARPROC)TractorObjects, 0x014, 0}, {(FARPROC)GoTradelane, 0x018, 0}, {(FARPROC)StopTradelane, 0x01C, 0}, {(FARPROC)JettisonCargo, 0x020, 0}, {(FARPROC)Startup, 0x024, 0}, {(FARPROC)Shutdown, 0x028, 0}, // {(FARPROC)Update, 0x02C, 0}, // no need to add here, already hooked in DllMain {(FARPROC)ElapseTime, 0x030, 0}, {(FARPROC)PushToServer, 0x034, 0}, // or SetActiveConnection?! // {(FARPROC)SwapConnections, 0x038, 0}, // ??? {(FARPROC)Connect, 0x03C, 0}, {(FARPROC)DisConnect, 0x040, 0}, {(FARPROC)OnConnect, 0x044, 0}, {(FARPROC)Login, 0x048, 0}, {(FARPROC)CharacterInfoReq, 0x04C, 0}, {(FARPROC)CharacterSelect, 0x050, 0}, {(FARPROC)SetActiveConnection, 0x054, 0}, // or PushToServer? {(FARPROC)CreateNewCharacter, 0x058, 0}, {(FARPROC)DestroyCharacter, 0x05C, 0}, {(FARPROC)CharacterSkipAutosave, 0x060, 0}, {(FARPROC)ReqShipArch, 0x064, 0}, {(FARPROC)ReqHullStatus, 0x068, 0}, {(FARPROC)ReqCollisionGroups, 0x06C, 0}, {(FARPROC)ReqEquipment, 0x070, 0}, {(FARPROC)ReqCargo, 0x074, 0}, {(FARPROC)ReqAddItem, 0x078, 0}, {(FARPROC)ReqRemoveItem, 0x07C, 0}, {(FARPROC)ReqModifyItem, 0x080, 0}, {(FARPROC)ReqSetCash, 0x084, 0}, {(FARPROC)ReqChangeCash, 0x088, 0}, {(FARPROC)BaseEnter, 0x08C, 0}, {(FARPROC)BaseExit, 0x090, 0}, {(FARPROC)LocationEnter, 0x094, 0}, {(FARPROC)LocationExit, 0x098, 0}, {(FARPROC)BaseInfoRequest, 0x09C, 0}, {(FARPROC)LocationInfoRequest, 0x0A0, 0}, {(FARPROC)GFObjSelect, 0x0A4, 0}, {(FARPROC)GFGoodVaporized, 0x0A8, 0}, {(FARPROC)MissionResponse, 0x0AC, 0}, {(FARPROC)TradeResponse, 0x0B0, 0}, {(FARPROC)GFGoodBuy, 0x0B4, 0}, {(FARPROC)GFGoodSell, 0x0B8, 0}, {(FARPROC)SystemSwitchOutComplete, 0x0BC, 0}, {(FARPROC)PlayerLaunch, 0x0C0, 0}, {(FARPROC)LaunchComplete, 0x0C4, 0}, {(FARPROC)JumpInComplete, 0x0C8, 0}, {(FARPROC)Hail, 0x0CC, 0}, {(FARPROC)SPObjUpdate, 0x0D0, 0}, {(FARPROC)SPMunitionCollision, 0x0D4, 0}, {(FARPROC)SPBadLandsObjCollision, 0x0D8, 0}, {(FARPROC)SPObjCollision, 0x0DC, 0}, {(FARPROC)SPRequestUseItem, 0x0E0, 0}, {(FARPROC)SPRequestInvincibility, 0x0E4, 0}, {(FARPROC)SaveGame, 0x0E8, 0}, {(FARPROC)MissionSaveB, 0x0EC, 0}, {(FARPROC)RequestEvent, 0x0F0, 0}, {(FARPROC)RequestCancel, 0x0F4, 0}, {(FARPROC)MineAsteroid, 0x0F8, 0}, {(FARPROC)CommComplete, 0x0FC, 0}, {(FARPROC)RequestCreateShip, 0x100, 0}, {(FARPROC)SPScanCargo, 0x104, 0}, {(FARPROC)SetManeuver, 0x108, 0}, {(FARPROC)InterfaceItemUsed, 0x10C, 0}, {(FARPROC)AbortMission, 0x110, 0}, {(FARPROC)RTCDone, 0x114, 0}, {(FARPROC)SetWeaponGroup, 0x118, 0}, {(FARPROC)SetVisitedState, 0x11C, 0}, {(FARPROC)RequestBestPath, 0x120, 0}, {(FARPROC)RequestPlayerStats, 0x124, 0}, {(FARPROC)PopUpDialog, 0x128, 0}, {(FARPROC)RequestGroupPositions, 0x12C, 0}, {(FARPROC)SetMissionLog, 0x130, 0}, {(FARPROC)SetInterfaceState, 0x134, 0}, {(FARPROC)RequestRankLevel, 0x138, 0}, {(FARPROC)InitiateTrade, 0x13C, 0}, {(FARPROC)TerminateTrade, 0x140, 0}, {(FARPROC)AcceptTrade, 0x144, 0}, {(FARPROC)SetTradeMoney, 0x148, 0}, {(FARPROC)AddTradeEquip, 0x14C, 0}, {(FARPROC)DelTradeEquip, 0x150, 0}, {(FARPROC)RequestTrade, 0x154, 0}, {(FARPROC)StopTradeRequest, 0x158, 0}, {(FARPROC)ReqDifficultyScale, 0x15C, 0}, {(FARPROC)GetServerID, 0x160, 0}, {(FARPROC)GetServerSig, 0x164, 0}, {(FARPROC)DumpPacketStats, 0x168, 0}, {(FARPROC)Dock, 0x16C, 0}, }; }
[ "M0tah@62241663-6891-49f9-b8c1-0f2e53ca0faf" ]
[ [ [ 1, 3093 ] ] ]
a73367f7d764b9500097b93db98484cfee43acb2
f794fd0abaed1011ede69129e36ce436347693fd
/CScene.h
3252e31f2841879e18734ddf05a1bd7f912b26c6
[]
no_license
konradrodzik/raytracer-cpu-gpu
d7a048a45f94457d7dde5f1eb3b34ecc83867ffb
0ac756a43998b4c0a3d6c923745922ba03cf7b6c
refs/heads/master
2016-09-15T21:00:23.107984
2011-01-24T01:04:41
2011-01-24T01:04:41
32,467,714
0
0
null
null
null
null
UTF-8
C++
false
false
1,712
h
//////////////////////////////////// // Konrad Rodrigo Rodzik (c) 2010 // //////////////////////////////////// #ifndef __H_CScene_H__ #define __H_CScene_H__ // Scene class class CScene { public: // Default constructor CScene(int width, int height); // Destructor ~CScene(); // Get primitives count int getPrimitivesCount(); // Get primitive CBasePrimitive* getPrimitive(unsigned int index); // Add primitive to scene void addPrimitive(CBasePrimitive* prim); // Load scene from file static CScene* loadScene(const char* sceneFile, int width, int height); // Parse scene file bool parseSceneFile(char* buffer); // Get camera pointer CCamera* getCamera(); // Set camera pointer void setCamera(CCamera* camera) { m_camera = camera; } CSpherePrimitive* getSpherePrimitive() { for(unsigned int i = 0; i < m_primitives.size(); ++i) { if(m_primitives[i]->getType() == EPT_SPHERE) { return (CSpherePrimitive*)(m_primitives[i]); } } return NULL; } int getSphereCount(); int getPlaneCount(); int getBoxCount(); void fillSphereArray(CSpherePrimitive* array); void fillPlaneArray(CPlanePrimitive* array); void fillBoxArray(CBoxPrimitive* array); void setName(char* name); const char* getName(); public: std::vector<CBasePrimitive*> m_primitives; // Scene primitives std::vector<CLight*> m_lights; // Scene lights CCamera* m_camera; // Camera on scene std::vector<CTexture*> m_textures; // All loaded textures std::string m_sceneName; // Name of scene // Settings int m_width; // Window width int m_height; // Window height }; #endif
[ "konrad.rodzik@8e044db2-5a41-7fc7-fe2a-5b7de51f5869" ]
[ [ [ 1, 81 ] ] ]
1b12f4b4af7819ece3a3438681501ac02ed5f48b
968aa9bac548662b49af4e2b873b61873ba6f680
/imgtools/imglib/symbolutil/symbolgenerator.cpp
2dcfc53c7903e206cdf4bbfa3a4cf31b96bda059
[]
no_license
anagovitsyn/oss.FCL.sftools.dev.build
b3401a1ee3fb3c8f3d5caae6e5018ad7851963f3
f458a4ce83f74d603362fe6b71eaa647ccc62fee
refs/heads/master
2021-12-11T09:37:34.633852
2010-12-01T08:05:36
2010-12-01T08:05:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
12,141
cpp
/* * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: * */ #include <vector> #include <boost/regex.hpp> #define MAX_LINE 65535 #include "symbolgenerator.h" #include "e32image.h" #include "h_utl.h" #if defined(__LINUX__) #define PATH_SEPARATOR '/' #else #define PATH_SEPARATOR '\\' #endif extern TInt gThreadNum; extern TBool gGenBsymbols; boost::mutex SymbolGenerator::iMutexSingleton; SymbolGenerator* SymbolGenerator::iInst = NULL; SymbolGenerator* SymbolGenerator::GetInstance(){ if(iInst == NULL) { iMutexSingleton.lock(); if(iInst == NULL) { iInst = new SymbolGenerator(); } iMutexSingleton.unlock(); } return iInst; } void SymbolGenerator::Release() { if(iInst != NULL) { iInst->join(); } iMutexSingleton.lock(); if(iInst != NULL) { delete iInst; iInst = NULL; } iMutexSingleton.unlock(); } void SymbolGenerator::SetSymbolFileName( const string& fileName ){ if(iSymFile.is_open()) iSymFile.close(); if(gGenBsymbols) { string s = fileName.substr(0,fileName.rfind('.'))+".bsym"; if(iImageType == ERofsImage) { printf("* Writing %s - ROFS BSymbol file\n", s.c_str()); } else { printf("* Writing %s - ROM BSymbol file\n", s.c_str()); } iSymFile.open(s.c_str(), ios_base::binary); } else { string s = fileName.substr(0,fileName.rfind('.'))+".symbol"; if(iImageType == ERofsImage) { printf("* Writing %s - ROFS Symbol file\n", s.c_str()); } else { printf("* Writing %s - ROM Symbol file\n", s.c_str()); } iSymFile.open(s.c_str()); } } void SymbolGenerator::AddFile( const string& fileName, bool isExecutable ){ iMutex.lock(); iQueueFiles.push(TPlacedEntry(fileName, "" , isExecutable)); iMutex.unlock(); iCond.notify_all(); } void SymbolGenerator::AddEntry(const TPlacedEntry& aEntry) { iMutex.lock(); iQueueFiles.push(aEntry); iMutex.unlock(); iCond.notify_all(); } void SymbolGenerator::SetFinished() { boost::mutex::scoped_lock lock(iMutex); iFinished = true; iCond.notify_all(); } TPlacedEntry SymbolGenerator::GetNextPlacedEntry() { TPlacedEntry pe("", "", false); if(1) { boost::mutex::scoped_lock lock(iMutex); while(!iFinished && iQueueFiles.empty()) iCond.wait(lock); if(!iQueueFiles.empty()) { pe = iQueueFiles.front(); iQueueFiles.pop(); } } return pe; } void SymbolGenerator::thrd_func(){ boost::thread_group threads; SymbolWorker worker; for(int i=0; i < gThreadNum; i++) { threads.create_thread(worker); } threads.join_all(); SymbolGenerator::GetInstance()->FlushSymbolFileContent(); } SymbolGenerator::SymbolGenerator() : boost::thread(thrd_func),iFinished(false) { if(gGenBsymbols) { iSymbolType = ESymBsym; } else { iSymbolType = ESymCommon; } } SymbolGenerator::~SymbolGenerator(){ if(joinable()) join(); for(int i=0; i < (int)iLogMessages.size(); i++) { cout << iLogMessages[i]; } iSymFile.flush(); iSymFile.close(); } void SymbolGenerator::FlushSymbolFileContent() { if(iSymbolType == ESymCommon) { return; } TBsymHeader tmpBsymHeader; memset(&tmpBsymHeader, 0, sizeof(tmpBsymHeader)); tmpBsymHeader.iMagic[0] = 'B'; tmpBsymHeader.iMagic[1] = 'S'; tmpBsymHeader.iMagic[2] = 'Y'; tmpBsymHeader.iMagic[3] = 'M'; tmpBsymHeader.iMajorVer[0] = BsymMajorVer >> 8; tmpBsymHeader.iMajorVer[1] = BsymMajorVer & 0xff; tmpBsymHeader.iMinorVer[0] = BsymMinorVer >> 8; tmpBsymHeader.iMinorVer[1] = BsymMinorVer & 0xff; if(ByteOrderUtil::IsLittleEndian()) { tmpBsymHeader.iEndiannessFlag = 0; } else { tmpBsymHeader.iEndiannessFlag = 1; } tmpBsymHeader.iCompressionFlag = 1; //count the space for TDbgUnitEntries and TSymbolEntries int fileCount = iMapFileInfoSet.size(); TUint32 sizeNeeded = fileCount * sizeof(TDbgUnitEntry); for(int i = 0; i < fileCount; i++) { sizeNeeded += iMapFileInfoSet[i].iSymbolPCEntrySet.size() * sizeof(TSymbolEntry); } //write string to the temporary memory area MemoryWriter mWriter; mWriter.SetOffset(sizeNeeded); mWriter.SetStringTableStart(sizeNeeded); mWriter.AddEmptyString(); //first to prepare the file info entries TDbgUnitEntry TUint32 startSymbolIndex = 0; for(int i = 0; i < fileCount; i++) { iMapFileInfoSet[i].iDbgUnitPCEntry.iDbgUnitEntry.iStartSymbolIndex = startSymbolIndex; iMapFileInfoSet[i].iDbgUnitPCEntry.iDbgUnitEntry.iPCNameOffset = mWriter.AddString(iMapFileInfoSet[i].iDbgUnitPCEntry.iPCName); iMapFileInfoSet[i].iDbgUnitPCEntry.iDbgUnitEntry.iDevNameOffset = mWriter.AddString(iMapFileInfoSet[i].iDbgUnitPCEntry.iDevName); startSymbolIndex += iMapFileInfoSet[i].iSymbolPCEntrySet.size(); } //second to layout the symbols unit for the mapfile for(int i = 0; i < fileCount; i++) { int symbolcount = iMapFileInfoSet[i].iSymbolPCEntrySet.size(); for(int j =0; j< symbolcount; j++) { iMapFileInfoSet[i].iSymbolPCEntrySet[j].iSymbolEntry.iScopeNameOffset = mWriter.AddScopeName(iMapFileInfoSet[i].iSymbolPCEntrySet[j].iScopeName); iMapFileInfoSet[i].iSymbolPCEntrySet[j].iSymbolEntry.iNameOffset = mWriter.AddString(iMapFileInfoSet[i].iSymbolPCEntrySet[j].iName); iMapFileInfoSet[i].iSymbolPCEntrySet[j].iSymbolEntry.iSecNameOffset = mWriter.AddString(iMapFileInfoSet[i].iSymbolPCEntrySet[j].iSecName); } } //write out the BSym file content char* pstart = mWriter.GetDataPointer(); //write out the map file info int unitlen = sizeof(TDbgUnitEntry); for(int i = 0; i < fileCount; i++) { memcpy(pstart, &iMapFileInfoSet[i].iDbgUnitPCEntry.iDbgUnitEntry, unitlen); pstart += unitlen; } //wirte out the symbol unit info unitlen = sizeof(TSymbolEntry); for(int i = 0; i < fileCount; i++) { int symbolcount = iMapFileInfoSet[i].iSymbolPCEntrySet.size(); for(int j =0; j < symbolcount; j++) { memcpy(pstart, &iMapFileInfoSet[i].iSymbolPCEntrySet[j].iSymbolEntry, unitlen); pstart += unitlen; } } //write out the memory out to the symbol file int totalPages = (mWriter.GetOffset() + ( BSYM_PAGE_SIZE -1)) / 4096; TUint32 compressInfoLength = sizeof(TCompressedHeaderInfo) + sizeof(TPageInfo)*(totalPages -1); char* tmpBuffer = new char[compressInfoLength]; TCompressedHeaderInfo * pCompressedHeaderInfo = (TCompressedHeaderInfo *) tmpBuffer; pCompressedHeaderInfo->iPageSize = BSYM_PAGE_SIZE; pCompressedHeaderInfo->iTotalPageNumber = totalPages; TPageInfo* tmpPage = &pCompressedHeaderInfo->iPages[0]; for(int i = 0; i < totalPages; i++) { tmpPage->iPageStartOffset = i * BSYM_PAGE_SIZE; if(tmpPage->iPageStartOffset + BSYM_PAGE_SIZE < mWriter.GetOffset()) { tmpPage->iPageDataSize = BSYM_PAGE_SIZE; } else { tmpPage->iPageDataSize = mWriter.GetOffset() - tmpPage->iPageStartOffset; } tmpPage++; } //prepare the TBsymHeader, TDbgUnitEntry and TSymbolEntry to the memory tmpBsymHeader.iDbgUnitOffset = sizeof(TBsymHeader) + compressInfoLength; tmpBsymHeader.iDbgUnitCount = fileCount; tmpBsymHeader.iSymbolOffset = fileCount*sizeof(TDbgUnitEntry); tmpBsymHeader.iSymbolCount = startSymbolIndex; tmpBsymHeader.iStringTableOffset = mWriter.GetStringTableStart(); tmpBsymHeader.iStringTableBytes = mWriter.GetOffset() - tmpBsymHeader.iStringTableOffset; tmpBsymHeader.iUncompressSize = mWriter.GetOffset(); //start the compress threads Print(EAlways, "Start compress for Bsymbol file\n"); PageCompressWorker compressWorker(pCompressedHeaderInfo, mWriter.GetDataPointer()); boost::thread_group threads; for(int i=0; i < gThreadNum; i++) { threads.create_thread(compressWorker); } threads.join_all(); Print(EAlways, "Complete compress for Bsymbol file\n"); //pack all the pages together tmpPage = &pCompressedHeaderInfo->iPages[0]; TPageInfo* prePage = NULL; char* pchar = mWriter.GetDataPointer(); for(int i=0; i < totalPages -1; i++) { prePage = tmpPage; tmpPage++; memcpy(pchar + prePage->iPageStartOffset + prePage->iPageDataSize, pchar + tmpPage->iPageStartOffset, tmpPage->iPageDataSize); tmpPage->iPageStartOffset = prePage->iPageStartOffset + prePage->iPageDataSize; } tmpBsymHeader.iCompressedSize = tmpPage->iPageStartOffset + tmpPage->iPageDataSize; mWriter.SetOffset(tmpBsymHeader.iCompressedSize); tmpBsymHeader.iCompressInfoOffset = sizeof(TBsymHeader); iSymFile.write((char*)&tmpBsymHeader, sizeof(TBsymHeader)); iSymFile.write((char*)pCompressedHeaderInfo, compressInfoLength); iSymFile.write(mWriter.GetDataPointer(), mWriter.GetOffset()); delete[] tmpBuffer; for(int i = 0; i < fileCount; i++) { iMapFileInfoSet[i].iSymbolPCEntrySet.clear(); } iMapFileInfoSet.clear(); } SymbolWorker::SymbolWorker() { } SymbolWorker::~SymbolWorker() { } void SymbolWorker::operator()() { SymbolProcessUnit* aSymbolProcessUnit; SymbolGenerator* symbolgenerator = SymbolGenerator::GetInstance(); if(symbolgenerator->GetImageType() == ERomImage) { if(gGenBsymbols) { aSymbolProcessUnit = new BsymRomSymbolProcessUnit(symbolgenerator); } else { aSymbolProcessUnit = new CommenRomSymbolProcessUnit(); } } else { if(gGenBsymbols) { aSymbolProcessUnit = new BsymRofsSymbolProcessUnit(symbolgenerator); } else { aSymbolProcessUnit = new CommenRofsSymbolProcessUnit(); } } while(1) { if(symbolgenerator->HasFinished() && symbolgenerator->IsEmpty()) { break; } TPlacedEntry pe = symbolgenerator->GetNextPlacedEntry(); if(pe.iFileName.empty()) continue; aSymbolProcessUnit->ProcessEntry(pe); symbolgenerator->LockOutput(); aSymbolProcessUnit->FlushStdOut(symbolgenerator->iLogMessages); aSymbolProcessUnit->FlushSymbolContent(symbolgenerator->GetOutputFileStream()); symbolgenerator->UnlockOutput(); } delete aSymbolProcessUnit; } TCompressedHeaderInfo* PageCompressWorker::pHeaderInfo = NULL; int PageCompressWorker::currentPage = 0; boost::mutex PageCompressWorker::m_mutex; int PageCompressWorker::m_error = 0; char* PageCompressWorker::iChar = NULL; PageCompressWorker::PageCompressWorker(TCompressedHeaderInfo* aHeaderInfo, char* aChar) { pHeaderInfo = aHeaderInfo; iChar = aChar; } PageCompressWorker::~PageCompressWorker() {} void PageCompressWorker::operator()() { int tobecompress = 0; CBytePair bpe; while(1) { m_mutex.lock(); tobecompress =currentPage; currentPage++; m_mutex.unlock(); if(tobecompress >= (int) pHeaderInfo->iTotalPageNumber) break; TPageInfo* current = &pHeaderInfo->iPages[0] + tobecompress; TUint8* in = (TUint8*)(iChar + current->iPageStartOffset); TUint8* out = in; TInt outSize = BytePairCompress(out, in, current->iPageDataSize, &bpe); if(outSize == KErrTooBig) { outSize = BSYM_PAGE_SIZE; } if(outSize < 0) { m_mutex.lock(); m_error = -1; m_mutex.unlock(); break; } current->iPageDataSize = outSize; } }
[ [ [ 1, 398 ] ] ]
284543c6fe916593c79c33ae5259df2999fa15d5
5e6ff9e6e8427078135a7b4d3b194bcbf631e9cd
/EngineSource/dpslim/dpslim/Database/Source/DBBrand.cpp
f2823b811983394bccd137a1bc07f8011dacc031
[]
no_license
karakots/dpresurrection
1a6f3fca00edd24455f1c8ae50764142bb4106e7
46725077006571cec1511f31d314ccd7f5a5eeef
refs/heads/master
2016-09-05T09:26:26.091623
2010-02-01T11:24:41
2010-02-01T11:24:41
32,189,181
0
0
null
null
null
null
UTF-8
C++
false
false
2,803
cpp
// ---------------------- // // Created 11/20/200 // Vicki de Mey, DecisionPower, Inc. // // ---------------------- #include "DBBrand.h" #include "DBModel.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // IMPLEMENT_DYNAMIC(BrandRecordset, CRecordset) BrandRecordset::BrandRecordset(CDatabase* pdb) : CRecordset(pdb) { //{{AFX_FIELD_INIT(BrandRecordset) m_BrandID = 1; m_BrandName = _T(""); m_nFields = 2; //}}AFX_FIELD_INIT // Changing default type ensures that blocking hstmt is used without // the ODBC cursor library. //m_nDefaultType = snapshot; m_nDefaultType = CRecordset::snapshot; // Using bound parameters in place of MFC filter string modification. //m_nParams = 1; } CString BrandRecordset::GetDefaultConnect() { // We don't allow the record set to connect on it's own. Dynamic // creation from the view passes the document's database to // the record set. //return _T("ODBC;DSN=Test"); return _T(""); } CString BrandRecordset::GetDefaultSQL() { CString tmp("SELECT brand_id, brand_name FROM brand "); tmp += ModelRecordset::ModelQuery; return tmp; } void BrandRecordset::DoFieldExchange(CFieldExchange* pFX) { // Create our own field exchange mechanism. We must do this for two // reasons. First, MFC's class wizard cannot currently determine the data // types of procedure columns. Second, we must create our own parameter // data exchange lines to take advantage of a bound ODBC input parameter. //{{AFX_FIELD_MAP(BrandRecordset) pFX->SetFieldType(CFieldExchange::outputColumn); RFX_Long(pFX, _T("[brand_id]"), m_BrandID); RFX_Text(pFX, _T("[brand_name]"), m_BrandName); //}}AFX_FIELD_MAP //pFX->SetFieldType(CFieldExchange::param); //RFX_Text(pFX, _T("@CustID"), m_strCustID); } ///////////////////////////////////////////////////////////////////////////// #ifdef _DEBUG void BrandRecordset::AssertValid() const { CRecordset::AssertValid(); } void BrandRecordset::Dump(CDumpContext& dc) const { CRecordset::Dump(dc); } #endif //_DEBUG int BrandRecordset::Open(unsigned int nOpenType, LPCTSTR lpszSql, DWORD dwOptions) { // Override the default behavior of the Open member function. We want to // ensure that the record set executes on the SQL Server default // (blocking) statement type. nOpenType = CRecordset::snapshot; //forwardOnly; dwOptions = CRecordset::readOnly; try { CRecordset::Open(nOpenType, GetDefaultSQL(), dwOptions); } catch (CException* e) { e->Delete(); return FALSE; } return TRUE; }
[ "Isaac.Noble@fd82578e-0ebe-11df-96d9-85c6b80b8d9c" ]
[ [ [ 1, 106 ] ] ]
94e6b0fc4eeb81a523432e9c6397135e2666e9da
580738f96494d426d6e5973c5b3493026caf8b6a
/Include/Vcl/idqotdserver.hpp
4cd2bad99639a31e12a72d2260bd79325424b675
[]
no_license
bravesoftdz/cbuilder-vcl
6b460b4d535d17c309560352479b437d99383d4b
7b91ef1602681e094a6a7769ebb65ffd6f291c59
refs/heads/master
2021-01-10T14:21:03.726693
2010-01-11T11:23:45
2010-01-11T11:23:45
48,485,606
2
1
null
null
null
null
UTF-8
C++
false
false
1,834
hpp
// Borland C++ Builder // Copyright (c) 1995, 2002 by Borland Software Corporation // All rights reserved // (DO NOT EDIT: machine generated header) 'IdQotdServer.pas' rev: 6.00 #ifndef IdQotdServerHPP #define IdQotdServerHPP #pragma delphiheader begin #pragma option push -w- #pragma option push -Vx #include <IdComponent.hpp> // Pascal unit #include <IdTCPServer.hpp> // Pascal unit #include <IdGlobal.hpp> // Pascal unit #include <Classes.hpp> // Pascal unit #include <SysInit.hpp> // Pascal unit #include <System.hpp> // Pascal unit //-- user supplied ----------------------------------------------------------- namespace Idqotdserver { //-- type declarations ------------------------------------------------------- typedef void __fastcall (__closure *TIdQOTDGetEvent)(Idtcpserver::TIdPeerThread* Thread); class DELPHICLASS TIdQOTDServer; class PASCALIMPLEMENTATION TIdQOTDServer : public Idtcpserver::TIdTCPServer { typedef Idtcpserver::TIdTCPServer inherited; protected: TIdQOTDGetEvent FOnCommandQOTD; virtual bool __fastcall DoExecute(Idtcpserver::TIdPeerThread* Thread); public: __fastcall virtual TIdQOTDServer(Classes::TComponent* AOwner); __published: __property TIdQOTDGetEvent OnCommandQOTD = {read=FOnCommandQOTD, write=FOnCommandQOTD}; __property DefaultPort = {default=17}; public: #pragma option push -w-inl /* TIdTCPServer.Destroy */ inline __fastcall virtual ~TIdQOTDServer(void) { } #pragma option pop }; //-- var, const, procedure --------------------------------------------------- } /* namespace Idqotdserver */ using namespace Idqotdserver; #pragma option pop // -w- #pragma option pop // -Vx #pragma delphiheader end. //-- end unit ---------------------------------------------------------------- #endif // IdQotdServer
[ "bitscode@7bd08ab0-fa70-11de-930f-d36749347e7b" ]
[ [ [ 1, 59 ] ] ]
e88e911b6236a91f438199a3e2c4074738aef66a
6c8c4728e608a4badd88de181910a294be56953a
/OgreRenderingModule/OgreImageTextureResource.h
d35d29de5f39afb6f773053db9fcaa78a32b426d
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
caocao/naali
29c544e121703221fe9c90b5c20b3480442875ef
67c5aa85fa357f7aae9869215f840af4b0e58897
refs/heads/master
2021-01-21T00:25:27.447991
2010-03-22T15:04:19
2010-03-22T15:04:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,083
h
// For conditions of distribution and use, see copyright notice in license.txt #ifndef incl_OgreRenderer_OgreImageTextureResource_h #define incl_OgreRenderer_OgreImageTextureResource_h #include "AssetInterface.h" #include "TextureInterface.h" #include "OgreModuleApi.h" #include <OgreTexture.h> namespace OgreRenderer { class OgreImageTextureResource; typedef boost::shared_ptr<OgreImageTextureResource> OgreImageTextureResourcePtr; //! An Ogre-specific texture resource, created from image not J2K stream /*! \ingroup OgreRenderingModuleClient */ class OGRE_MODULE_API OgreImageTextureResource : public Foundation::ResourceInterface { public: //! constructor /*! \param id texture id */ OgreImageTextureResource(const std::string& id); //! constructor /*! \param id texture id \param source source image */ OgreImageTextureResource(const std::string& id, Foundation::AssetPtr source); //! destructor virtual ~OgreImageTextureResource(); //! returns resource type in text form virtual const std::string& GetType() const; //! returns whether resource valid virtual bool IsValid() const; //! returns Ogre texture /*! may be null if no data successfully set yet */ Ogre::TexturePtr GetTexture() const { return ogre_texture_; } //! returns whether has alpha channel bool HasAlpha() const; //! sets contents from raw source texture /*! \param source source raw texture data \return true if successful */ bool SetData(Foundation::AssetPtr source); //! returns resource type in text form (static) static const std::string& GetTypeStatic(); private: //! Remove texture void RemoveTexture(); //! Ogre texture Ogre::TexturePtr ogre_texture_; }; } #endif
[ "cadaver@5b2332b8-efa3-11de-8684-7d64432d61a3" ]
[ [ [ 1, 68 ] ] ]
4b44e4f6e630501a3494c90b116cfd5db480dcf5
d112566843e130e29fa468f868682212a71f4f25
/src/gcode.cpp
5a649638f5ed61b9e869302699d86322131b1e9f
[]
no_license
danieldaz/repsnapper
ffbb05b3fa3eae1d0e5418098de3feac42ffb6bb
1bca689bed4ad57b5c8dd94b51eb9cadf86b8b9d
refs/heads/master
2020-12-25T05:36:12.563953
2011-09-18T15:35:24
2011-09-18T15:35:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,126
cpp
/* This file is a part of the RepSnapper project. Copyright (C) 2010 Kulitorum This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "config.h" #include "stdafx.h" #include "math.h" #include "gcode.h" #include <iostream> #include <sstream> #include "model.h" #include "progress.h" using namespace std; GCode::GCode() { Min.x = Min.y = Min.z = 99999999.0f; Max.x = Max.y = Max.z = -99999999.0f; Center.x = Center.y = Center.z = 0.0f; buffer = Gtk::TextBuffer::create(); } void GCode::Read(Model *MVC, Progress *progress, string filename) { clear(); ifstream file; file.open(filename.c_str()); //open a file if(!file.good()) { // MessageBrowser->add(str(boost::format("Error opening file %s") % Filename).c_str()); return; } uint LineNr = 0; string s; Vector3f globalPos(0,0,0); Min.x = Min.y = Min.z = 99999999.0f; Max.x = Max.y = Max.z = -99999999.0f; while(getline(file,s)) { istringstream line(s); LineNr++; string buffer; line >> buffer; // read something append_text ((s+"\n").c_str()); // FIXME: assumes all files are 100k lines, bad! progress->update(int(LineNr/1000)); if(buffer.find( ";", 0) != string::npos) // COMMENT continue; Command command; if( buffer.find( "G21", 0) != string::npos ) //Coordinated Motion { command.Code = MILLIMETERSASUNITS; commands.push_back(command); } if( buffer.find( "G1", 0) != string::npos ) //string::npos means not defined { command.Code = COORDINATEDMOTION; command.where = globalPos; while(line >> buffer) // read next keyword { if( buffer.find( "X", 0) != string::npos ) //string::npos means not defined { string number = buffer.substr(1,buffer.length()-1); // 16 characters command.where.x = ToFloat(number); } if( buffer.find( "Y", 0) != string::npos ) //string::npos means not defined { string number = buffer.substr(1,buffer.length()-1); // 16 characters command.where.y = ToFloat(number); } if( buffer.find( "Z", 0) != string::npos ) //string::npos means not defined { string number = buffer.substr(1,buffer.length()-1); // 16 characters command.where.z = ToFloat(number); } if( buffer.find( "E", 0) != string::npos ) //string::npos means not defined { string number = buffer.substr(1,buffer.length()-1); // 16 characters command.e = ToFloat(number); } if( buffer.find( "F", 0) != string::npos ) //string::npos means not defined { string number = buffer.substr(1,buffer.length()-1); // 16 characters command.f = ToFloat(number); } } if(command.where.x < -100) continue; if(command.where.y < -100) continue; globalPos = command.where; if(command.where.x < Min.x) Min.x = command.where.x; if(command.where.y < Min.y) Min.y = command.where.y; if(command.where.z < Min.z) Min.z = command.where.z; if(command.where.x > Max.x) Max.x = command.where.x; if(command.where.y > Max.y) Max.y = command.where.y; if(command.where.z > Max.z) Max.z = command.where.z; commands.push_back(command); } else if( buffer.find( "G0", 0) != string::npos ) //Rapid Motion { command.Code = RAPIDMOTION; command.where = globalPos; while(line >> buffer) // read next keyword { if( buffer.find( "X", 0) != string::npos ) //string::npos means not defined { string number = buffer.substr(1,buffer.length()-1); // 16 characters command.where.x = ToFloat(number); } if( buffer.find( "Y", 0) != string::npos ) //string::npos means not defined { string number = buffer.substr(1,buffer.length()-1); // 16 characters command.where.y = ToFloat(number); } if( buffer.find( "Z", 0) != string::npos ) //string::npos means not defined { string number = buffer.substr(1,buffer.length()-1); // 16 characters command.where.z = ToFloat(number); } if( buffer.find( "E", 0) != string::npos ) //string::npos means not defined { string number = buffer.substr(1,buffer.length()-1); // 16 characters command.e = ToFloat(number); } if( buffer.find( "F", 0) != string::npos ) //string::npos means not defined { string number = buffer.substr(1,buffer.length()-1); // 16 characters command.f = ToFloat(number); } } if(command.where.x < -100) continue; if(command.where.y < -100) continue; globalPos = command.where; if(command.where.x < Min.x) Min.x = command.where.x; if(command.where.y < Min.y) Min.y = command.where.y; if(command.where.z < Min.z) Min.z = command.where.z; if(command.where.x > Max.x) Max.x = command.where.x; if(command.where.y > Max.y) Max.y = command.where.y; if(command.where.z > Max.z) Max.z = command.where.z; commands.push_back(command); } } Center.x = (Max.x + Min.x )/2; Center.y = (Max.y + Min.y )/2; Center.z = (Max.z + Min.z )/2; } void GCode::draw(const Settings &settings) { /*--------------- Drawing -----------------*/ Vector3f thisPos(0,0,0); Vector4f LastColor = Vector4f(0.0f,0.0f,0.0f,1.0f); Vector4f Color = Vector4f(0.0f,0.0f,0.0f,1.0f); float Distance = 0.0f; Vector3f pos(0,0,0); uint start = (uint)(settings.Display.GCodeDrawStart*(float)(commands.size())); uint end = (uint)(settings.Display.GCodeDrawEnd*(float)(commands.size())); float LastE=0.0f; bool extruderon = false; glEnable(GL_BLEND); glDisable(GL_CULL_FACE); for(uint i=start;i<commands.size() && i < end ;i++) { switch(commands[i].Code) { case SETSPEED: case ZMOVE: case EXTRUDERON: extruderon = true; break; case EXTRUDEROFF: extruderon = false; break; case COORDINATEDMOTION3D: if (extruderon) Color = settings.Display.GCodeExtrudeRGBA; else Color = settings.Display.GCodeMoveRGBA; LastColor = Color; Distance += (commands[i].where-pos).length(); glLineWidth(3); glBegin(GL_LINES); glColor4fv(&Color[0]); if(i==end-1) glColor4f(0,1,0,Color.a); glVertex3fv((GLfloat*)&pos); glVertex3fv((GLfloat*)&commands[i].where); glEnd(); LastColor = Color; LastE=commands[i].e; break; case COORDINATEDMOTION: if(commands[i].e == LastE) { glLineWidth(3); float speed = commands[i].f; float luma = speed / settings.Hardware.MaxPrintSpeedXY*0.5f; if(settings.Display.LuminanceShowsSpeed == false) luma = 1.0f; Color = settings.Display.GCodeMoveRGBA; Color *= luma; } else { glLineWidth(3); float speed = commands[i].f; float luma = speed/settings.Hardware.MaxPrintSpeedXY; if(settings.Display.LuminanceShowsSpeed == false) luma = 1.0f; Color = settings.Display.GCodeExtrudeRGBA; Color *= luma; } if(settings.Display.LuminanceShowsSpeed == false) LastColor = Color; Distance += (commands[i].where-pos).length(); glBegin(GL_LINES); glColor4fv(&LastColor[0]); if(i==end-1) glColor3f(1,0,0); glVertex3fv((GLfloat*)&pos); glColor4fv(&Color[0]); if(i==end-1) glColor3f(1,0,0); glVertex3fv((GLfloat*)&commands[i].where); glEnd(); LastColor = Color; LastE=commands[i].e; break; case RAPIDMOTION: glLineWidth(1); glBegin(GL_LINES); glColor3f(0.75f,0.0f,0.0f); Distance += (commands[i].where-pos).length(); glVertex3fv((GLfloat*)&pos); glVertex3fv((GLfloat*)&commands[i].where); glEnd(); break; default: break; // ignored GCodes } if(commands[i].Code != EXTRUDERON && commands[i].Code != EXTRUDEROFF) pos = commands[i].where; } glLineWidth(1); std::stringstream oss; oss << "Length: " << Distance/1000.0f << " - " << Distance/200000.0f << " Hour."; // std::cout << oss.str(); // Draw bbox glColor3f(1,0,0); glBegin(GL_LINE_LOOP); glVertex3f(Min.x, Min.y, Min.z); glVertex3f(Max.x, Min.y, Min.z); glVertex3f(Max.x, Max.y, Min.z); glVertex3f(Min.x, Max.y, Min.z); glEnd(); glBegin(GL_LINE_LOOP); glVertex3f(Min.x, Min.y, Max.z); glVertex3f(Max.x, Min.y, Max.z); glVertex3f(Max.x, Max.y, Max.z); glVertex3f(Min.x, Max.y, Max.z); glEnd(); glBegin(GL_LINES); glVertex3f(Min.x, Min.y, Min.z); glVertex3f(Min.x, Min.y, Max.z); glVertex3f(Min.x, Max.y, Min.z); glVertex3f(Min.x, Max.y, Max.z); glVertex3f(Max.x, Max.y, Min.z); glVertex3f(Max.x, Max.y, Max.z); glVertex3f(Max.x, Min.y, Min.z); glVertex3f(Max.x, Min.y, Max.z); glEnd(); } void GCode::MakeText(string &GcodeTxt, const string &GcodeStart, const string &GcodeLayer, const string &GcodeEnd, bool UseIncrementalEcode, bool Use3DGcode, float AntioozeDistance, float AntioozeSpeed) { float lastE = -10; Vector3f pos(0,0,0); Vector3f LastPos(-10,-10,-10); std::stringstream oss; GcodeTxt += GcodeStart + "\n"; for(uint i=0;i<commands.size() ;i++) { oss.str( "" ); switch(commands[i].Code) { case SELECTEXTRUDER: oss << "T0\n"; GcodeTxt += oss.str(); break; case SETSPEED: commands[i].where.z = LastPos.z; commands[i].e = lastE; case ZMOVE: commands[i].where.x = LastPos.x; commands[i].where.y = LastPos.y; case COORDINATEDMOTION: if ((commands[i].where.x != LastPos.x) + (commands[i].where.y != LastPos.y) + (commands[i].where.z != LastPos.z) != 0 && AntioozeDistance != 0 && commands[i].e == lastE && !Use3DGcode && AntioozeDistance != 0) { if (UseIncrementalEcode) { oss << "G1 E" << (lastE - AntioozeDistance) << " F" << AntioozeSpeed << " ;antiooze retract\n"; } else { oss << "G1 E" << -(AntioozeDistance) << " F" << AntioozeSpeed << " ;antiooze retract\n"; } } oss << "G1 "; if(commands[i].where.x != LastPos.x) oss << "X" << commands[i].where.x << " "; if(commands[i].where.y != LastPos.y) oss << "Y" << commands[i].where.y << " "; if(commands[i].where.z != LastPos.z) oss << "Z" << commands[i].where.z << " "; if(commands[i].e != lastE) { if(UseIncrementalEcode) // in incremental mode, the same is nothing { if(commands[i].e != lastE) oss << "E" << commands[i].e << " "; } else { if(commands[i].e >= 0.0f) oss << "E" << commands[i].e << " "; } } oss << "F" << commands[i].f; if(commands[i].comment.length() != 0) oss << " ;" << commands[i].comment << "\n"; else oss << "\n"; if ((commands[i].where.x != LastPos.x) + (commands[i].where.y != LastPos.y) + (commands[i].where.z != LastPos.z) != 0 && AntioozeDistance != 0 && commands[i].e == lastE && !Use3DGcode && AntioozeDistance != 0) { if (UseIncrementalEcode) { oss << "G1 E" << lastE << " F" << AntioozeSpeed << " ;antiooze return\n"; } else { oss << "G1 E" << AntioozeDistance << " F" << AntioozeSpeed << " ;antiooze return\n"; } } GcodeTxt += oss.str(); if(commands[i].Code == ZMOVE && commands[i].where.z != LastPos.z) GcodeTxt += GcodeLayer + "\n"; LastPos = commands[i].where; if( commands[i].e >= 0.0f) lastE = commands[i].e; break; case EXTRUDERON: if(i != 0 && commands[i-1].Code == EXTRUDEROFF) continue; // Dont switch extruder on/off right after eachother oss << "M101\n"; GcodeTxt += oss.str(); break; case EXTRUDEROFF: if(i != 0 && (i+1) < commands.size() && commands[i+1].Code == EXTRUDERON) continue; // Dont switch extruder on/off right after eachother if(i != 0 && (i+1) < commands.size() && commands[i+1].Code == EXTRUDEROFF) continue; // don't switch extruder off twize oss << "M103\n"; GcodeTxt += oss.str(); break; case COORDINATEDMOTION3D: oss << "G1 X" << commands[i].where.x << " Y" << commands[i].where.y << " Z" << commands[i].where.z; oss << " F" << commands[i].f; if(commands[i].comment.length() != 0) oss << " ;" << commands[i].comment << "\n"; else oss << "\n"; GcodeTxt += oss.str(); LastPos = commands[i].where; break; case RAPIDMOTION: oss << "G0 X" << commands[i].where.x << " Y" << commands[i].where.y << " Z" << commands[i].where.z << "\n"; GcodeTxt += oss.str(); LastPos = commands[i].where; break; case GOTO: oss << "G92"; if(commands[i].where.x != LastPos.x && commands[i].where.x >= 0) { LastPos.x = commands[i].where.x; oss << " X" << commands[i].where.x; } if(commands[i].where.y != LastPos.y && commands[i].where.y >= 0) { LastPos.y = commands[i].where.y; oss << " Y" << commands[i].where.y; } if(commands[i].where.z != LastPos.z && commands[i].where.z >= 0) { LastPos.z = commands[i].where.z; oss << " Z" << commands[i].where.z; } if(commands[i].e != lastE && commands[i].e >= 0.0f) { lastE = commands[i].e; oss << " E" << commands[i].e; } oss << "\n"; GcodeTxt += oss.str(); break; default: break; // ignored CGCode } pos = commands[i].where; } GcodeTxt += GcodeEnd + "\n"; buffer->set_text (GcodeTxt); } void GCode::Write (Model *model, string filename) { FILE *file; file = fopen (filename.c_str(), "w+"); if (!file) model->alert (_("failed to open file")); else { fprintf (file, "%s", buffer->get_text().c_str()); fclose (file); } } void GCode::append_text (const std::string &line) { buffer->insert (buffer->end(), line); } std::string GCode::get_text () const { return buffer->get_text(); } void GCode::clear() { buffer->erase (buffer->begin(), buffer->end()); commands.clear(); } GCodeIter::GCodeIter (Glib::RefPtr<Gtk::TextBuffer> buffer) : m_buffer (buffer), m_it (buffer->begin()), m_line_count (buffer->get_line_count()), m_cur_line (1) { } std::string GCodeIter::next_line() { Gtk::TextBuffer::iterator last = m_it; m_it = m_buffer->get_iter_at_line (m_cur_line++); return m_buffer->get_text (last, m_it); } bool GCodeIter::finished() { return m_cur_line > m_line_count; } GCodeIter *GCode::get_iter () { return new GCodeIter (buffer); }
[ [ [ 1, 18 ] ], [ [ 19, 19 ], [ 41, 41 ], [ 405, 405 ], [ 407, 408 ], [ 474, 474 ], [ 476, 484 ], [ 503, 508 ], [ 511, 528 ] ], [ [ 20, 26 ], [ 31, 32 ], [ 34, 37 ], [ 39, 40 ], [ 42, 42 ], [ 44, 63 ], [ 73, 198 ], [ 200, 203 ], [ 206, 207 ], [ 210, 212 ], [ 215, 227 ], [ 232, 235 ], [ 237, 237 ], [ 239, 249 ], [ 252, 252 ], [ 255, 259 ], [ 262, 262 ], [ 265, 265 ], [ 267, 269 ], [ 271, 273 ], [ 275, 404 ], [ 406, 406 ], [ 409, 469 ] ], [ [ 27, 30 ], [ 33, 33 ], [ 38, 38 ], [ 43, 43 ], [ 64, 72 ], [ 228, 228 ], [ 230, 230 ], [ 254, 254 ], [ 264, 264 ], [ 470, 473 ], [ 475, 475 ], [ 485, 502 ], [ 509, 510 ] ], [ [ 199, 199 ], [ 208, 209 ], [ 250, 251 ], [ 260, 261 ], [ 266, 266 ] ], [ [ 204, 205 ], [ 213, 214 ], [ 229, 229 ], [ 231, 231 ], [ 236, 236 ], [ 238, 238 ], [ 253, 253 ], [ 263, 263 ], [ 270, 270 ], [ 274, 274 ] ] ]
04fa5ba9631e3ca0cc4eecf52f16326da630be6c
e7c45d18fa1e4285e5227e5984e07c47f8867d1d
/Common/Models/CONTROL1/GENCON.H
b1abdfe709cb2d75e041ce79fa3c50e90c69e6a7
[]
no_license
abcweizhuo/Test3
0f3379e528a543c0d43aad09489b2444a2e0f86d
128a4edcf9a93d36a45e5585b70dee75e4502db4
refs/heads/master
2021-01-17T01:59:39.357645
2008-08-20T00:00:29
2008-08-20T00:00:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,111
h
//================== SysCAD - Copyright Kenwalt (Pty) Ltd =================== // $Nokeywords: $ //=========================================================================== #ifndef __GENCON_H #define __GENCON_H #ifndef __SC_DEFS_H #include "sc_defs.h" #endif #ifndef __FLWNODE_H #include "flwnode.h" #endif //#ifndef __M_BASE_H //#include "m_base.h" //#endif #include "models.h" #ifdef __GENCON_CPP #define DllImportExport #elif !defined(Control1) #define DllImportExport DllImport #else #define DllImportExport #endif #define WithPGMWatches 0 //=========================================================================== #if WithPGMWatches class GCWatch { public: Strng S; pGCVar pV; }; #endif //============================================================================ const int MaxPGMWatch = 15; DEFINE_TAGOBJ(GControl); class GControl : public FlwNode//, GCXRefHelper { public: GControl(pTagObjClass pClass_, pchar TagIn, pTaggedObject pAttach, TagObjAttachment eAttach); virtual ~GControl(); virtual void ResetData(flag Complete); private: void SetMaxVarData(long NewSize); void DDBAddWatchedVars(DataDefnBlk& DDB, char* pHdTag, pGCVar VarList, int Lvl, int &nPg, int &nOnPg, flag ForceNewPage, int MaxPerPage, bool UserPages, int &SubPg, char PgPrefix); void DDBAddArrayWatchedVars(DataDefnBlk & DDB, int &nPg, int MaxPerPage); void CountWatchedVars(pGCVar VarList, int & TagCount, int & LineCount, int & PageCount); flag LoadPGM(char* pPGMName, flag WithDebug); public: virtual void BuildDataDefn(DataDefnBlk & DDB); virtual flag DataXchg(DataChangeBlk & DCB); virtual flag ValidateData(ValidateDataBlk & VDB); virtual flag PreStartCheck(); virtual void EvalCtrlInitialise(eScdCtrlTasks Tasks=CO_All); virtual void EvalCtrlStrategy(eScdCtrlTasks Tasks=CO_All); void DoEvalCtrl(); void EvalCtrlTerminate(eScdCtrlTasks Tasks=CO_All); virtual void SetState(eScdMdlStateActs RqdState); void DoTextFileChangeTag(Strng fn, pchar pOldTag, pchar pNewTag, int& TagChangeCount, bool lookInComments, bool listChanges); virtual int ChangeTag(pchar pOldTag, pchar pNewTag); virtual int DeleteTag(pchar pDelTag); virtual flag GetOtherData(FilingControlBlock &FCB); virtual flag PutOtherData(FilingControlBlock &FCB); virtual void OnAppActivate(BOOL bActive); virtual int FilesUsed(CFilesUsedArray & Files); // CNodeXRefMngr Overides virtual bool TestXRefListActive(); virtual int UpdateXRefLists(CXRefBuildResults & Results); virtual void UnlinkAllXRefs(); virtual dword ModelStatus(); DEFINE_CI(GControl, FlwNode, 6+MaxCondMsgs+MaxCondMsgs); public: flag bFlag1; bool bBool1; bool bBool2; Strng sPGMName; //name of pgm file Strng sPGMFile; //temp name of pgm file Strng sPGMPath; //temp path of pgm file GCInsMngr PgmMngr; //PGM manager #if WithPGMWatches GCWatch Watch[MaxPGMWatch]; //array of watches #endif GCVar** m_VarData; //pointer to array of data vars (external refrences) int m_nVarData; //number of data vars long m_nMaxVarData; //current max length of array of data vars CCriticalSection m_VarDataSect; HANDLE m_hProcess[TP_MaxTtlIncludeFiles]; //process handle for the editor DWORD m_dwProcessId[TP_MaxTtlIncludeFiles]; //process ID for the editor FILETIME m_EditTime[TP_MaxTtlIncludeFiles]; //time editor scheduled flag bOn; //must the pgm be executed etc flag bEncrypt; //expect encrypted pgm flag bAutoReload; // AutoReload ? flag bReloadReqd; // flag bWithDBG; // int iIterCnt; //iteration counter byte m_bMustInit:1, //flag set to indicate that Initialise must happen m_bIterOne:1, //flag set for first iteration when run is pressed m_bMustTerm:1, //flag set to indicate that Terminate must happen bJustLoaded:1, //flag set True just after PGM is loaded bEmpty:1, //flag set True for Empty SetState option bPreset:1; //flag set True for Preset SetState option #if WithPGMWatches bWatchesOn:1; //flag set True to activate watches #endif Strng m_sEditFileNameNew; }; //=========================================================================== #undef DllImportExport #endif
[ [ [ 1, 52 ], [ 54, 54 ], [ 56, 62 ], [ 65, 65 ], [ 67, 77 ], [ 79, 100 ], [ 105, 105 ], [ 107, 119 ], [ 121, 128 ] ], [ [ 53, 53 ], [ 55, 55 ], [ 106, 106 ] ], [ [ 63, 64 ], [ 66, 66 ], [ 78, 78 ], [ 101, 104 ], [ 120, 120 ] ] ]
856569dbb3b9338e484ce1921d2e0b15f9298aed
0043aea568b672f34df4e80015a14f6b03f33ef1
/source/src/JsonObject.cpp
0ed57d91d4e0ede44f44b6998596daa5ae4380e1
[]
no_license
gosuwachu/s60-json-library
300d5c0428ab3b0e45e12bb821464a3dd351e2d1
fb0074abe3b225f1974c04ecd9dcda72e710c1fa
refs/heads/master
2021-01-01T17:27:58.266546
2010-08-06T11:42:35
2010-08-06T11:42:35
32,650,647
0
0
null
null
null
null
UTF-8
C++
false
false
6,267
cpp
/* Copyright (c) 2009, Piotr Wach, Polidea All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Polidea 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 PIOTR WACH, POLIDEA ''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 PIOTR WACH, POLIDEA BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "JsonObject.h" #include "JsonString.h" #include "JsonArray.h" #include "StringUtil.h" TBool IsEqual(const CJsonPair &pair1, const CJsonPair &pair2) { return (&pair1 == &pair2); } TUint32 HashFunction(const CJsonPair &pair) { TUint32 hash = 0; for(TInt i = 0; i < pair.Key().Length(); ++i) hash = pair.Key()[i] + (hash << 6) + (hash << 16) - hash; return hash; } CJsonObject::CJsonObject() : MJsonValue( MJsonValue::EObject ) { // No implementation required } CJsonObject::~CJsonObject() { for(int i = 0; i < iMembers.Count(); ++i) if( iMembers[i] ) delete iMembers[i]; iMembers.Close(); } void CJsonObject::AddIntL(const TDesC& aKey, TInt aValue) { CJsonPair* pair = new (ELeave) CJsonPair(aKey, MJsonValue::EString); ((CJsonString*)pair->Value())->SetIntL(aValue); iMembers.AppendL( pair ); } void CJsonObject::AddInt64L(const TDesC& aKey, TInt64 aValue) { CJsonPair* pair = new (ELeave) CJsonPair(aKey, MJsonValue::EString); ((CJsonString*)pair->Value())->SetInt64L(aValue); iMembers.AppendL( pair ); } void CJsonObject::AddReal32L(const TDesC& aKey, TReal32 aValue) { CJsonPair* pair = new (ELeave) CJsonPair(aKey, MJsonValue::EString); ((CJsonString*)pair->Value())->SetReal32L(aValue); iMembers.AppendL( pair ); } void CJsonObject::AddReal64L(const TDesC& aKey, TReal64 aValue) { CJsonPair* pair = new (ELeave) CJsonPair(aKey, MJsonValue::EString); ((CJsonString*)pair->Value())->SetReal64L(aValue); iMembers.AppendL( pair ); } void CJsonObject::AddBoolL(const TDesC& aKey, TBool aValue) { CJsonPair* pair = new (ELeave) CJsonPair(aKey, MJsonValue::EString); ((CJsonString*)pair->Value())->SetBoolL(aValue); iMembers.AppendL( pair ); } void CJsonObject::AddL(const TDesC& aKey, const TDesC& aValue) { CJsonPair* pair = new (ELeave) CJsonPair(aKey, MJsonValue::EString); ((CJsonString*)pair->Value())->SetStringL(aValue); iMembers.AppendL( pair ); } void CJsonObject::AddL(const TDesC& aKey, CJsonObject* aValue) { CJsonPair* pair = new (ELeave) CJsonPair(aKey, aValue); iMembers.AppendL( pair ); } void CJsonObject::AddL(const TDesC& aKey, CJsonArray* aValue) { CJsonPair* pair = new (ELeave) CJsonPair(aKey, aValue); iMembers.AppendL( pair ); } TInt CJsonObject::Find(const TDesC& aKey) const { for( TInt i = 0; i < iMembers.Count(); i++ ) { // object found if( iMembers[i]->Key().Compare( aKey ) == 0 ) return i; } return KErrNotFound; } void CJsonObject::GetValue(TInt aIndex, MJsonValue*& aValue) const { if( 0 <= aIndex && aIndex < iMembers.Count() ) { aValue = iMembers[aIndex]->Value(); } else aValue = NULL; } void CJsonObject::GetObjectL(const TDesC& aKey, CJsonObject*& aObject) const { aObject = FindEntryAndCast<CJsonObject>( aKey ); } void CJsonObject::GetArrayL(const TDesC& aKey, CJsonArray*& aArray) const { aArray = FindEntryAndCast<CJsonArray>( aKey ); } void CJsonObject::GetStringL(const TDesC& aKey, TDes& aString) const { CJsonString* jsonString; if( jsonString = FindEntryAndCast<CJsonString>( aKey ) ) aString.Copy( jsonString->String() ); } void CJsonObject::GetIntL(const TDesC& aKey, TInt& aInt) const { CJsonString* jsonString; if( jsonString = FindEntryAndCast<CJsonString>( aKey ) ) aInt = jsonString->IntL(); else aInt = 0; } void CJsonObject::GetInt64L(const TDesC& aKey, TInt64& aInt) const { CJsonString* jsonString; if( jsonString = FindEntryAndCast<CJsonString>( aKey ) ) aInt = jsonString->Int64L(); else aInt = 0; } void CJsonObject::GetBoolL(const TDesC& aKey, TBool& aBool) const { CJsonString* jsonString; if( jsonString = FindEntryAndCast<CJsonString>( aKey ) ) aBool = jsonString->BoolL(); else aBool = 0; } void CJsonObject::GetReal32L(const TDesC& aKey, TReal32& aReal) const { CJsonString* jsonString; if( jsonString = FindEntryAndCast<CJsonString>( aKey ) ) aReal = jsonString->Real32L(); else aReal = 0; } void CJsonObject::GetReal64L(const TDesC& aKey, TReal64& aReal) const { CJsonString* jsonString; if( jsonString = FindEntryAndCast<CJsonString>( aKey ) ) aReal = jsonString->Real64L(); else aReal = 0; } void CJsonObject::ToStringL(RBuf& aOutputString) const { RBufAppendL(aOutputString, '{' ); for(int i = 0; i < iMembers.Count() - 1; ++i) { if( iMembers[i] ) iMembers[i]->ToStringL( aOutputString ); RBufAppendL(aOutputString, ',' ); } if(iMembers[iMembers.Count() - 1]) iMembers[iMembers.Count() - 1]->ToStringL( aOutputString ); RBufAppendL(aOutputString, '}' ); }
[ "wach.piotrek@b73fb3d4-a2a3-11de-a23d-972bf86d3223" ]
[ [ [ 1, 210 ] ] ]
a344b665f53e50b9954ba65fb2fa9d3a3b8d3931
33f59b1ba6b12c2dd3080b24830331c37bba9fe2
/Depend/Foundation/Distance/Wm4Distance.h
205b0a9813a2f81979ba4649c201c5096d1f2d4a
[]
no_license
daleaddink/flagship3d
4835c223fe1b6429c12e325770c14679c42ae3c6
6cce5b1ff7e7a2d5d0df7aa0594a70d795c7979a
refs/heads/master
2021-01-15T16:29:12.196094
2009-11-01T10:18:11
2009-11-01T10:18:11
37,734,654
1
0
null
null
null
null
UTF-8
C++
false
false
3,426
h
// Geometric Tools, Inc. // http://www.geometrictools.com // Copyright (c) 1998-2006. All Rights Reserved // // The Wild Magic Version 4 Foundation Library source code is supplied // under the terms of the license agreement // http://www.geometrictools.com/License/Wm4FoundationLicense.pdf // and may not be copied or disclosed except in accordance with the terms // of that agreement. #ifndef WM4DISTANCE_H #define WM4DISTANCE_H #include "Wm4FoundationLIB.h" #include "Wm4Vector2.h" #include "Wm4Vector3.h" namespace Wm4 { template <class Real, class TVector> class WM4_FOUNDATION_ITEM Distance { public: // abstract base class virtual ~Distance (); // static distance queries virtual Real Get () = 0; // distance virtual Real GetSquared () = 0; // squared distance // function calculations for dynamic distance queries virtual Real Get (Real fT, const TVector& rkVelocity0, const TVector& rkVelocity1) = 0; virtual Real GetSquared (Real fT, const TVector& rkVelocity0, const TVector& rkVelocity1) = 0; // Derivative calculations for dynamic distance queries. The defaults // use finite difference estimates // f'(t) = (f(t+h)-f(t-h))/(2*h) // where h = DifferenceStep. A derived class may override these and // provide implementations of exact formulas that do not require h. virtual Real GetDerivative (Real fT, const TVector& rkVelocity0, const TVector& rkVelocity1); virtual Real GetDerivativeSquared (Real fT, const TVector& rkVelocity0, const TVector& rkVelocity1); // Dynamic distance queries. The function computes the smallest distance // between the two objects over the time interval [tmin,tmax]. virtual Real Get (Real fTMin, Real fTMax, const TVector& rkVelocity0, const TVector& rkVelocity1); virtual Real GetSquared (Real fTMin, Real fTMax, const TVector& rkVelocity0, const TVector& rkVelocity1); // for Newton's method and inverse parabolic interpolation int MaximumIterations; // default = 8 Real ZeroThreshold; // default = Math<Real>::ZERO_TOLERANCE // for derivative approximations void SetDifferenceStep (Real fDifferenceStep); // default = 1e-03 Real GetDifferenceStep () const; // The time at which minimum distance occurs for the dynamic queries. Real GetContactTime () const; // Closest points on the two objects. These are valid for static or // dynamic queries. The set of closest points on a single object need // not be a single point. In this case, the Boolean member functions // return 'true'. A derived class may support querying for the full // contact set. const TVector& GetClosestPoint0 () const; const TVector& GetClosestPoint1 () const; bool HasMultipleClosestPoints0 () const; bool HasMultipleClosestPoints1 () const; protected: Distance (); Real m_fContactTime; TVector m_kClosestPoint0; TVector m_kClosestPoint1; bool m_bHasMultipleClosestPoints0; bool m_bHasMultipleClosestPoints1; Real m_fDifferenceStep, m_fInvTwoDifferenceStep; }; typedef Distance<float,Vector2f> Distance2f; typedef Distance<float,Vector3f> Distance3f; typedef Distance<double,Vector2d> Distance2d; typedef Distance<double,Vector3d> Distance3d; } #endif
[ "yf.flagship@e79fdf7c-a9d8-11de-b950-3d5b5f4ea0aa" ]
[ [ [ 1, 94 ] ] ]
10056fd31d645f236eed1757e2940f758153064e
e1f7c2f6dd66916fe5b562d9dd4c0a5925197ec4
/Engine/Project/src/AGSkybox.cpp
a62267838045a858546a74cd1de46c2b331afdd6
[]
no_license
OtterOrder/agengineproject
de990ad91885b54a0c63adf66ff2ecc113e0109d
0b92a590af4142369e2946f692d5f30a06d32135
refs/heads/master
2020-05-27T07:44:25.593878
2011-05-01T14:52:05
2011-05-01T14:52:05
32,115,301
0
0
null
null
null
null
UTF-8
C++
false
false
3,355
cpp
#include "AGSkybox.h" #include "AGUtilities.h" struct SKYBOX_VERTEX { FLOAT x,y,z; }; #define SKYBOX_FVF (AGFVF_XYZ) //------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------ AGSkybox::AGSkybox() : AG3DGraphicEntity () { _mpCubeTex = NULL; _mpSizeVB = 1.0f; SKYBOX_VERTEX _Vertices[24]= { // Front quad, NOTE: All quads face inward {-_mpSizeVB, -_mpSizeVB, _mpSizeVB}, {-_mpSizeVB, _mpSizeVB, _mpSizeVB}, { _mpSizeVB, -_mpSizeVB, _mpSizeVB}, { _mpSizeVB, _mpSizeVB, _mpSizeVB}, // Back quad { _mpSizeVB, -_mpSizeVB, -_mpSizeVB}, { _mpSizeVB, _mpSizeVB, -_mpSizeVB}, {-_mpSizeVB, -_mpSizeVB, -_mpSizeVB}, {-_mpSizeVB, _mpSizeVB, -_mpSizeVB}, // Left quad {-_mpSizeVB, -_mpSizeVB, -_mpSizeVB}, {-_mpSizeVB, _mpSizeVB, -_mpSizeVB}, {-_mpSizeVB, -_mpSizeVB, _mpSizeVB}, {-_mpSizeVB, _mpSizeVB, _mpSizeVB}, // Right quad { _mpSizeVB, -_mpSizeVB, _mpSizeVB}, { _mpSizeVB, _mpSizeVB, _mpSizeVB}, { _mpSizeVB, -_mpSizeVB, -_mpSizeVB}, { _mpSizeVB, _mpSizeVB, -_mpSizeVB}, // Top quad {-_mpSizeVB, _mpSizeVB, _mpSizeVB}, {-_mpSizeVB, _mpSizeVB, -_mpSizeVB}, { _mpSizeVB, _mpSizeVB, _mpSizeVB}, { _mpSizeVB, _mpSizeVB, -_mpSizeVB}, // Bottom quad {-_mpSizeVB, -_mpSizeVB, -_mpSizeVB}, {-_mpSizeVB, -_mpSizeVB, _mpSizeVB}, { _mpSizeVB, -_mpSizeVB, -_mpSizeVB}, { _mpSizeVB, -_mpSizeVB, _mpSizeVB} }; AGCreateVertexBuffer(sizeof(_Vertices), SKYBOX_FVF, _mpSkyVB); void * psommets; AGLockVertexBuffer(0, _mpSkyVB, sizeof(_Vertices), (void **)&psommets); memcpy(psommets,_Vertices,sizeof(_Vertices)); AGUnlockVertexBuffer(_mpSkyVB); } //------------------------------------------------------------------------------------------------------------------------------ AGSkybox::~AGSkybox() { SAFE_RELEASE(_mpSkyVB); } //------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------ void AGSkybox::Update() { AG3DGraphicEntity::Update(); } //------------------------------------------------------------------------------------------------------------------------------ void AGSkybox::Draw (CFirstPersonCamera* _pCamera, AG3DScene* _pScene) ////. { _mpMaterial->Activate(); _mpMaterial->Apply(_pScene, this); AGMatrix viewProj; AGMatrixMultiply(&viewProj, &_mWorld, _pCamera->GetViewMatrix()); AGMatrixMultiply(&viewProj, &viewProj, _pCamera->GetProjMatrix()); _mpMaterial->GetVertexShader()->SetMatrix("g_mWorldViewProjection", viewProj); for ( ULONG i = 0; i < 6; ++i ) { AGDrawVertexBuffer(sizeof(SKYBOX_VERTEX), SKYBOX_FVF, _mpSkyVB, i * 4, 2 ); } } //------------------------------------------------------------------------------------------------------------------------------ void AGSkybox::SetTexture (cStr _FileName) { SAFE_DECREF(_mpCubeTex); _mpCubeTex = AGResourceManager::GetSingleton()->Load<AGTextureCube>(_FileName); }
[ "germain.mazac@fe70d4ac-e33c-11de-8d18-5b59c22968bc" ]
[ [ [ 1, 109 ] ] ]
9a2fffad3cd936592fba20b11587e2dceb203093
3970f1a70df104f46443480d1ba86e246d8f3b22
/imebra/src/imebra/src/dataHandlerStringCS.cpp
e47c4e820eb4a5318447ab4b876cb68293e740cc
[]
no_license
zhan2016/vimrid
9f8ea8a6eb98153300e6f8c1264b2c042c23ee22
28ae31d57b77df883be3b869f6b64695df441edb
refs/heads/master
2021-01-20T16:24:36.247136
2009-07-28T18:32:31
2009-07-28T18:32:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,243
cpp
/* 0.0.46 Imebra: a C++ dicom library. Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 by Paolo Brandoli This program is free software; you can redistribute it and/or modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 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 AFFERO GENERAL PUBLIC LICENSE Version 3 for more details. You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 along with this program; If not, see http://www.gnu.org/licenses/ ------------------- If you want to use Imebra commercially then you have to buy the commercial license available at http://puntoexe.com After you buy the commercial license then you can use Imebra according to the terms described in the Imebra Commercial License Version 1. A copy of the Imebra Commercial License Version 1 is available in the documentation pages. Imebra is available at http://puntoexe.com The author can be contacted by email at [email protected] or by mail at the following address: Paolo Brandoli Preglov trg 6 1000 Ljubljana Slovenia */ /*! \file dataHandlerStringCS.cpp \brief Implementation of the class dataHandlerStringCS. */ #include "../include/dataHandlerStringCS.h" namespace puntoexe { namespace imebra { namespace handlers { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // dataHandlerStringCS // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// imbxUint8 dataHandlerStringCS::getPaddingByte() { return 0x20; } imbxUint32 dataHandlerStringCS::getUnitSize() { return 0; } imbxUint32 dataHandlerStringCS::maxSize() { return 16; } } // namespace handlers } // namespace imebra } // namespace puntoexe
[ [ [ 1, 91 ] ] ]
efcc3d51e422d3bac6c71fa9e02820a1b91568bc
f66868527283310626d03cfa70ce7fe16b981b0e
/include/algebra3.h
69cc9a3a346de858dca37c3dcb9c0d7896c26545
[]
no_license
therichardnguyen/-CS184-AS3
1c5bbfcc180c2af81ca2bb7a5a9b9a793ae77ada
8a9942107cdfa25cc89b26cd5d45ff0aec0108e0
refs/heads/master
2021-01-22T14:39:43.984704
2011-02-17T22:21:04
2011-02-17T22:21:04
1,380,146
0
0
null
null
null
null
UTF-8
C++
false
false
44,902
h
/**************************************************************** * * * C++ Vector and Matrix Algebra routines * * Author: Jean-Francois DOUE * * Version 3.1 --- October 1993 * * * ****************************************************************/ // // From "Graphics Gems IV / Edited by Paul S. Heckbert // Academic Press, 1994, ISBN 0-12-336156-9 // "You are free to use and modify this code in any way // you like." (p. xv) // // Modified by J. Nagle, March 1997 // - All functions are inline. // - All functions are const-correct. // - All checking is via the standard "assert" macro. // - Stream I/O is disabled for portability, but can be // re-enabled by defining ALGEBRA3IOSTREAMS. // #ifndef ALGEBRA3H #define ALGEBRA3H #include <stdlib.h> #include <assert.h> #include <math.h> #ifndef M_PI #define M_PI 3.14159265358979323846 #endif // this line defines a new type: pointer to a function which returns a // double and takes as argument a double typedef double (*V_FCT_PTR)(double); // min-max macros #define MIN(A,B) ((A) < (B) ? (A) : (B)) #define MAX(A,B) ((A) > (B) ? (A) : (B)) #undef min // allow as function names #undef max #define ALGEBRA3IOSTREAMS #include <iostream> using namespace std; // error handling macro #define ALGEBRA_ERROR(E) { assert(false); } // avoid conflict with some of the inst sun machines, which #define ES 2 #undef ES class vec2; class vec3; class vec4; class mat3; class mat4; enum { VX, VY, VZ, VW }; // axes enum { PA, PB, PC, PD }; // planes enum { RED, GREEN, BLUE }; // colors enum { KA, KD, KS, ES }; // phong coefficients // // PI // //const double M_PI = (double) 3.14159265358979323846; // per CRC handbook, 14th. ed. //const double M_PI_2 = (M_PI/2.0); // PI/2 //const double M2_PI = (M_PI*2.0); // PI*2 /**************************************************************** * * * 2D Vector * * * ****************************************************************/ class vec2 { protected: double n[2]; public: // Constructors vec2(); vec2(const double x, const double y); vec2(const double d); vec2(const vec2& v); // copy constructor vec2(const vec3& v); // cast v3 to v2 vec2(const vec3& v, int dropAxis); // cast v3 to v2 // Assignment operators vec2& operator =(const vec2& v); // assignment of a vec2 vec2& operator +=(const vec2& v); // incrementation by a vec2 vec2& operator -=(const vec2& v); // decrementation by a vec2 vec2& operator *=(const double d); // multiplication by a constant vec2& operator /=(const double d); // division by a constant double& operator [](int i); // indexing double operator [](int i) const;// read-only indexing // special functions double length() const; // length of a vec2 double length2() const; // squared length of a vec2 vec2& normalize(); // normalize a vec2 in place vec2& apply(V_FCT_PTR fct); // apply a func. to each component // friends friend vec2 operator -(const vec2& v); // -v1 friend vec2 operator +(const vec2& a, const vec2& b); // v1 + v2 friend vec2 operator -(const vec2& a, const vec2& b); // v1 - v2 friend vec2 operator *(const vec2& a, const double d); // v1 * 3.0 friend vec2 operator *(const double d, const vec2& a); // 3.0 * v1 friend vec2 operator *(const mat3& a, const vec2& v); // M . v friend vec2 operator *(const vec2& v, const mat3& a); // v . M friend double operator *(const vec2& a, const vec2& b); // dot product friend vec2 operator /(const vec2& a, const double d); // v1 / 3.0 friend vec3 operator ^(const vec2& a, const vec2& b); // cross product friend int operator ==(const vec2& a, const vec2& b); // v1 == v2 ? friend int operator !=(const vec2& a, const vec2& b); // v1 != v2 ? #ifdef ALGEBRA3IOSTREAMS friend ostream& operator <<(ostream& s, const vec2& v); // output to stream friend istream& operator >>(istream& s, vec2& v); // input from strm. #endif /* ALGEBRA3IOSTREAMS */ friend void swap(vec2& a, vec2& b); // swap v1 & v2 friend vec2 min(const vec2& a, const vec2& b); // min(v1, v2) friend vec2 max(const vec2& a, const vec2& b); // max(v1, v2) friend vec2 prod(const vec2& a, const vec2& b); // term by term * // necessary friend declarations friend class vec3; }; /**************************************************************** * * * 3D Vector * * * ****************************************************************/ class vec3 { protected: double n[3]; public: // Constructors vec3(); vec3(const double x, const double y, const double z); vec3(const double d); vec3(const vec3& v); // copy constructor vec3(const vec2& v); // cast v2 to v3 vec3(const vec2& v, double d); // cast v2 to v3 vec3(const vec4& v); // cast v4 to v3 vec3(const vec4& v, int dropAxis); // cast v4 to v3 // Assignment operators vec3& operator =(const vec3& v); // assignment of a vec3 vec3& operator +=(const vec3& v); // incrementation by a vec3 vec3& operator -=(const vec3& v); // decrementation by a vec3 vec3& operator *=(const double d); // multiplication by a constant vec3& operator /=(const double d); // division by a constant double& operator [](int i); // indexing double operator[](int i) const; // read-only indexing // special functions double length() const; // length of a vec3 double length2() const; // squared length of a vec3 vec3& normalize(); // normalize a vec3 in place vec3& apply(V_FCT_PTR fct); // apply a func. to each component // friends friend vec3 operator -(const vec3& v); // -v1 friend vec3 operator +(const vec3& a, const vec3& b); // v1 + v2 friend vec3 operator -(const vec3& a, const vec3& b); // v1 - v2 friend vec3 operator *(const vec3& a, const double d); // v1 * 3.0 friend vec3 operator *(const double d, const vec3& a); // 3.0 * v1 friend vec3 operator *(const mat4& a, const vec3& v); // M . v friend vec3 operator *(const vec3& v, const mat4& a); // v . M friend double operator *(const vec3& a, const vec3& b); // dot product friend vec3 operator /(const vec3& a, const double d); // v1 / 3.0 friend vec3 operator ^(const vec3& a, const vec3& b); // cross product friend int operator ==(const vec3& a, const vec3& b); // v1 == v2 ? friend int operator !=(const vec3& a, const vec3& b); // v1 != v2 ? #ifdef ALGEBRA3IOSTREAMS friend ostream& operator <<(ostream& s, const vec3& v); // output to stream friend istream& operator >>(istream& s, vec3& v); // input from strm. #endif // ALGEBRA3IOSTREAMS friend void swap(vec3& a, vec3& b); // swap v1 & v2 friend vec3 min(const vec3& a, const vec3& b); // min(v1, v2) friend vec3 max(const vec3& a, const vec3& b); // max(v1, v2) friend vec3 prod(const vec3& a, const vec3& b); // term by term * // necessary friend declarations friend class vec2; friend class vec4; friend class mat3; friend vec2 operator *(const mat3& a, const vec2& v); // linear transform friend vec3 operator *(const mat3& a, const vec3& v); friend mat3 operator *(const mat3& a, const mat3& b); // matrix 3 product }; /**************************************************************** * * * 4D Vector * * * ****************************************************************/ class vec4 { protected: double n[4]; public: // Constructors vec4(); vec4(const double x, const double y, const double z, const double w); vec4(const double d); vec4(const vec4& v); // copy constructor vec4(const vec3& v); // cast vec3 to vec4 vec4(const vec3& v, const double d); // cast vec3 to vec4 // Assignment operators vec4& operator =(const vec4& v); // assignment of a vec4 vec4& operator +=(const vec4& v); // incrementation by a vec4 vec4& operator -=(const vec4& v); // decrementation by a vec4 vec4& operator *=(const double d); // multiplication by a constant vec4& operator /=(const double d); // division by a constant double& operator [](int i); // indexing double operator[](int i) const; // read-only indexing // special functions double length() const; // length of a vec4 double length2() const; // squared length of a vec4 vec4& normalize(); // normalize a vec4 in place vec4& apply(V_FCT_PTR fct); // apply a func. to each component // friends friend vec4 operator -(const vec4& v); // -v1 friend vec4 operator +(const vec4& a, const vec4& b); // v1 + v2 friend vec4 operator -(const vec4& a, const vec4& b); // v1 - v2 friend vec4 operator *(const vec4& a, const double d); // v1 * 3.0 friend vec4 operator *(const double d, const vec4& a); // 3.0 * v1 friend vec4 operator *(const mat4& a, const vec4& v); // M . v friend vec4 operator *(const vec4& v, const mat4& a); // v . M friend double operator *(const vec4& a, const vec4& b); // dot product friend vec4 operator /(const vec4& a, const double d); // v1 / 3.0 friend int operator ==(const vec4& a, const vec4& b); // v1 == v2 ? friend int operator !=(const vec4& a, const vec4& b); // v1 != v2 ? #ifdef ALGEBRA3IOSTREAMS friend ostream& operator <<(ostream& s, const vec4& v); // output to stream friend istream& operator >>(istream& s, vec4& v); // input from strm. #endif // ALGEBRA3IOSTREAMS friend void swap(vec4& a, vec4& b); // swap v1 & v2 friend vec4 min(const vec4& a, const vec4& b); // min(v1, v2) friend vec4 max(const vec4& a, const vec4& b); // max(v1, v2) friend vec4 prod(const vec4& a, const vec4& b); // term by term * // necessary friend declarations friend class vec3; friend class mat4; friend vec3 operator *(const mat4& a, const vec3& v); // linear transform friend mat4 operator *(const mat4& a, const mat4& b); // matrix 4 product }; /**************************************************************** * * * 3x3 Matrix * * * ****************************************************************/ class mat3 { protected: vec3 v[3]; public: // Constructors mat3(); mat3(const vec3& v0, const vec3& v1, const vec3& v2); mat3(const double d); mat3(const mat3& m); // Assignment operators mat3& operator =(const mat3& m); // assignment of a mat3 mat3& operator +=(const mat3& m); // incrementation by a mat3 mat3& operator -=(const mat3& m); // decrementation by a mat3 mat3& operator *=(const double d); // multiplication by a constant mat3& operator /=(const double d); // division by a constant vec3& operator [](int i); // indexing const vec3& operator [](int i) const; // read-only indexing // special functions mat3 transpose() const; // transpose mat3 inverse() const; // inverse mat3& apply(V_FCT_PTR fct); // apply a func. to each element // friends friend mat3 operator -(const mat3& a); // -m1 friend mat3 operator +(const mat3& a, const mat3& b); // m1 + m2 friend mat3 operator -(const mat3& a, const mat3& b); // m1 - m2 friend mat3 operator *(const mat3& a, const mat3& b); // m1 * m2 friend mat3 operator *(const mat3& a, const double d); // m1 * 3.0 friend mat3 operator *(const double d, const mat3& a); // 3.0 * m1 friend mat3 operator /(const mat3& a, const double d); // m1 / 3.0 friend int operator ==(const mat3& a, const mat3& b); // m1 == m2 ? friend int operator !=(const mat3& a, const mat3& b); // m1 != m2 ? #ifdef ALGEBRA3IOSTREAMS friend ostream& operator <<(ostream& s, const mat3& m); // output to stream friend istream& operator >>(istream& s, mat3& m); // input from strm. #endif // ALGEBRA3IOSTREAMS friend void swap(mat3& a, mat3& b); // swap m1 & m2 // necessary friend declarations friend vec3 operator *(const mat3& a, const vec3& v); // linear transform friend vec2 operator *(const mat3& a, const vec2& v); // linear transform }; /**************************************************************** * * * 4x4 Matrix * * * ****************************************************************/ class mat4 { protected: vec4 v[4]; public: // Constructors mat4(); mat4(const vec4& v0, const vec4& v1, const vec4& v2, const vec4& v3); mat4(const double d); mat4(const mat4& m); // Assignment operators mat4& operator =(const mat4& m); // assignment of a mat4 mat4& operator +=(const mat4& m); // incrementation by a mat4 mat4& operator -=(const mat4& m); // decrementation by a mat4 mat4& operator *=(const double d); // multiplication by a constant mat4& operator /=(const double d); // division by a constant vec4& operator [](int i); // indexing const vec4& operator [](int i) const; // read-only indexing // special functions mat4 transpose() const; // transpose mat4 inverse() const; // inverse mat4& apply(V_FCT_PTR fct); // apply a func. to each element // friends friend mat4 operator -(const mat4& a); // -m1 friend mat4 operator +(const mat4& a, const mat4& b); // m1 + m2 friend mat4 operator -(const mat4& a, const mat4& b); // m1 - m2 friend mat4 operator *(const mat4& a, const mat4& b); // m1 * m2 friend mat4 operator *(const mat4& a, const double d); // m1 * 4.0 friend mat4 operator *(const double d, const mat4& a); // 4.0 * m1 friend mat4 operator /(const mat4& a, const double d); // m1 / 3.0 friend int operator ==(const mat4& a, const mat4& b); // m1 == m2 ? friend int operator !=(const mat4& a, const mat4& b); // m1 != m2 ? #ifdef ALGEBRA3IOSTREAMS friend ostream& operator <<(ostream& s, const mat4& m); // output to stream friend istream& operator >>(istream& s, mat4& m); // input from strm. #endif // ALGEBRA3IOSTREAMS friend void swap(mat4& a, mat4& b); // swap m1 & m2 // necessary friend declarations friend vec4 operator *(const mat4& a, const vec4& v); // linear transform friend vec3 operator *(const mat4& a, const vec3& v); // linear transform }; /**************************************************************** * * * 2D functions and 3D functions * * * ****************************************************************/ mat3 identity2D(); // identity 2D mat3 translation2D(const vec2& v); // translation 2D mat3 rotation2D(const vec2& Center, const double angleDeg); // rotation 2D mat3 scaling2D(const vec2& scaleVector); // scaling 2D mat4 identity3D(); // identity 3D mat4 translation3D(const vec3& v); // translation 3D mat4 rotation3D(vec3 Axis, const double angleDeg);// rotation 3D mat4 scaling3D(const vec3& scaleVector); // scaling 3D mat4 perspective3D(const double d); // perspective 3D // // Implementation // /**************************************************************** * * * vec2 Member functions * * * ****************************************************************/ // CONSTRUCTORS inline vec2::vec2() { } inline vec2::vec2(const double x, const double y) { n[VX] = x; n[VY] = y; } inline vec2::vec2(const double d) { n[VX] = n[VY] = d; } inline vec2::vec2(const vec2& v) { n[VX] = v.n[VX]; n[VY] = v.n[VY]; } inline vec2::vec2(const vec3& v) // it is up to caller to avoid divide-by-zero { n[VX] = v.n[VX] / v.n[VZ]; n[VY] = v.n[VY] / v.n[VZ]; } ; inline vec2::vec2(const vec3& v, int dropAxis) { switch (dropAxis) { case VX: n[VX] = v.n[VY]; n[VY] = v.n[VZ]; break; case VY: n[VX] = v.n[VX]; n[VY] = v.n[VZ]; break; default: n[VX] = v.n[VX]; n[VY] = v.n[VY]; break; } } // ASSIGNMENT OPERATORS inline vec2& vec2::operator =(const vec2& v) { n[VX] = v.n[VX]; n[VY] = v.n[VY]; return *this; } inline vec2& vec2::operator +=(const vec2& v) { n[VX] += v.n[VX]; n[VY] += v.n[VY]; return *this; } inline vec2& vec2::operator -=(const vec2& v) { n[VX] -= v.n[VX]; n[VY] -= v.n[VY]; return *this; } inline vec2& vec2::operator *=(const double d) { n[VX] *= d; n[VY] *= d; return *this; } inline vec2& vec2::operator /=(const double d) { double d_inv = 1. / d; n[VX] *= d_inv; n[VY] *= d_inv; return *this; } inline double& vec2::operator [](int i) { assert(!(i < VX || i> VY)); // subscript check return n[i]; } inline double vec2::operator [](int i) const { assert(!(i < VX || i> VY)); return n[i]; } // SPECIAL FUNCTIONS inline double vec2::length() const { return sqrt(length2()); } inline double vec2::length2() const { return n[VX] * n[VX] + n[VY] * n[VY]; } inline vec2& vec2::normalize() // it is up to caller to avoid divide-by-zero { *this /= length(); return *this; } inline vec2& vec2::apply(V_FCT_PTR fct) { n[VX] = (*fct)(n[VX]); n[VY] = (*fct)(n[VY]); return *this; } // FRIENDS inline vec2 operator -(const vec2& a) { return vec2(-a.n[VX], -a.n[VY]); } inline vec2 operator +(const vec2& a, const vec2& b) { return vec2(a.n[VX] + b.n[VX], a.n[VY] + b.n[VY]); } inline vec2 operator -(const vec2& a, const vec2& b) { return vec2(a.n[VX] - b.n[VX], a.n[VY] - b.n[VY]); } inline vec2 operator *(const vec2& a, const double d) { return vec2(d * a.n[VX], d * a.n[VY]); } inline vec2 operator *(const double d, const vec2& a) { return a * d; } inline vec2 operator *(const mat3& a, const vec2& v) { vec3 av; av.n[VX] = a.v[0].n[VX] * v.n[VX] + a.v[0].n[VY] * v.n[VY] + a.v[0].n[VZ]; av.n[VY] = a.v[1].n[VX] * v.n[VX] + a.v[1].n[VY] * v.n[VY] + a.v[1].n[VZ]; av.n[VZ] = a.v[2].n[VX] * v.n[VX] + a.v[2].n[VY] * v.n[VY] + a.v[2].n[VZ]; return av; } inline vec2 operator *(const vec2& v, const mat3& a) { return a.transpose() * v; } inline double operator *(const vec2& a, const vec2& b) { return (a.n[VX] * b.n[VX] + a.n[VY] * b.n[VY]); } inline vec2 operator /(const vec2& a, const double d) { double d_inv = 1. / d; return vec2(a.n[VX] * d_inv, a.n[VY] * d_inv); } inline vec3 operator ^(const vec2& a, const vec2& b) { return vec3(0.0, 0.0, a.n[VX] * b.n[VY] - b.n[VX] * a.n[VY]); } inline int operator ==(const vec2& a, const vec2& b) { return (a.n[VX] == b.n[VX]) && (a.n[VY] == b.n[VY]); } inline int operator !=(const vec2& a, const vec2& b) { return !(a == b); } #ifdef ALGEBRA3IOSTREAMS inline ostream& operator <<(ostream& s, const vec2& v) { return s << "| " << v.n[VX] << ' ' << v.n[VY] << " |"; } inline istream& operator >>(istream& s, vec2& v) { vec2 v_tmp; char c = ' '; while (isspace(c)) s >> c; // The vectors can be formatted either as x y or | x y | if (c == '|') { s >> v_tmp[VX] >> v_tmp[VY]; while (s >> c && isspace(c)) ; if (c != '|') s.setstate(ios::badbit); } else { s.putback(c); s >> v_tmp[VX] >> v_tmp[VY]; } if (s) v = v_tmp; return s; } #endif // ALGEBRA3IOSTREAMS inline void swap(vec2& a, vec2& b) { vec2 tmp(a); a = b; b = tmp; } inline vec2 min(const vec2& a, const vec2& b) { return vec2(MIN(a.n[VX], b.n[VX]), MIN(a.n[VY], b.n[VY]));} inline vec2 max(const vec2& a, const vec2& b) { return vec2(MAX(a.n[VX], b.n[VX]), MAX(a.n[VY], b.n[VY]));} inline vec2 prod(const vec2& a, const vec2& b) { return vec2(a.n[VX] * b.n[VX], a.n[VY] * b.n[VY]); } /**************************************************************** * * * vec3 Member functions * * * ****************************************************************/ // CONSTRUCTORS inline vec3::vec3() { } inline vec3::vec3(const double x, const double y, const double z) { n[VX] = x; n[VY] = y; n[VZ] = z; } inline vec3::vec3(const double d) { n[VX] = n[VY] = n[VZ] = d; } inline vec3::vec3(const vec3& v) { n[VX] = v.n[VX]; n[VY] = v.n[VY]; n[VZ] = v.n[VZ]; } inline vec3::vec3(const vec2& v) { n[VX] = v.n[VX]; n[VY] = v.n[VY]; n[VZ] = 1.0; } inline vec3::vec3(const vec2& v, double d) { n[VX] = v.n[VX]; n[VY] = v.n[VY]; n[VZ] = d; } inline vec3::vec3(const vec4& v) // it is up to caller to avoid divide-by-zero { n[VX] = v.n[VX] / v.n[VW]; n[VY] = v.n[VY] / v.n[VW]; n[VZ] = v.n[VZ] / v.n[VW]; } inline vec3::vec3(const vec4& v, int dropAxis) { switch (dropAxis) { case VX: n[VX] = v.n[VY]; n[VY] = v.n[VZ]; n[VZ] = v.n[VW]; break; case VY: n[VX] = v.n[VX]; n[VY] = v.n[VZ]; n[VZ] = v.n[VW]; break; case VZ: n[VX] = v.n[VX]; n[VY] = v.n[VY]; n[VZ] = v.n[VW]; break; default: n[VX] = v.n[VX]; n[VY] = v.n[VY]; n[VZ] = v.n[VZ]; break; } } // ASSIGNMENT OPERATORS inline vec3& vec3::operator =(const vec3& v) { n[VX] = v.n[VX]; n[VY] = v.n[VY]; n[VZ] = v.n[VZ]; return *this; } inline vec3& vec3::operator +=(const vec3& v) { n[VX] += v.n[VX]; n[VY] += v.n[VY]; n[VZ] += v.n[VZ]; return *this; } inline vec3& vec3::operator -=(const vec3& v) { n[VX] -= v.n[VX]; n[VY] -= v.n[VY]; n[VZ] -= v.n[VZ]; return *this; } inline vec3& vec3::operator *=(const double d) { n[VX] *= d; n[VY] *= d; n[VZ] *= d; return *this; } inline vec3& vec3::operator /=(const double d) { double d_inv = 1. / d; n[VX] *= d_inv; n[VY] *= d_inv; n[VZ] *= d_inv; return *this; } inline double& vec3::operator [](int i) { assert(! (i < VX || i> VZ)); return n[i]; } inline double vec3::operator [](int i) const { assert(! (i < VX || i> VZ)); return n[i]; } // SPECIAL FUNCTIONS inline double vec3::length() const { return sqrt(length2()); } inline double vec3::length2() const { return n[VX] * n[VX] + n[VY] * n[VY] + n[VZ] * n[VZ]; } inline vec3& vec3::normalize() // it is up to caller to avoid divide-by-zero { *this /= length(); return *this; } inline vec3& vec3::apply(V_FCT_PTR fct) { n[VX] = (*fct)(n[VX]); n[VY] = (*fct)(n[VY]); n[VZ] = (*fct)(n[VZ]); return *this; } // FRIENDS inline vec3 operator -(const vec3& a) { return vec3(-a.n[VX], -a.n[VY], -a.n[VZ]); } inline vec3 operator +(const vec3& a, const vec3& b) { return vec3(a.n[VX] + b.n[VX], a.n[VY] + b.n[VY], a.n[VZ] + b.n[VZ]); } inline vec3 operator -(const vec3& a, const vec3& b) { return vec3(a.n[VX] - b.n[VX], a.n[VY] - b.n[VY], a.n[VZ] - b.n[VZ]); } inline vec3 operator *(const vec3& a, const double d) { return vec3(d * a.n[VX], d * a.n[VY], d * a.n[VZ]); } inline vec3 operator *(const double d, const vec3& a) { return a * d; } inline vec3 operator *(const mat3& a, const vec3& v) { #define ROWCOL(i) a.v[i].n[0]*v.n[VX] + a.v[i].n[1]*v.n[VY] \ + a.v[i].n[2]*v.n[VZ] return vec3(ROWCOL(0),ROWCOL(1), ROWCOL(2)); #undef ROWCOL // (i) } inline vec3 operator *(const mat4& a, const vec3& v) { return a * vec4(v); } inline vec3 operator *(const vec3& v, const mat4& a) { return a.transpose() * v; } inline double operator *(const vec3& a, const vec3& b) { return (a.n[VX] * b.n[VX] + a.n[VY] * b.n[VY] + a.n[VZ] * b.n[VZ]); } inline vec3 operator /(const vec3& a, const double d) { double d_inv = 1. / d; return vec3(a.n[VX] * d_inv, a.n[VY] * d_inv, a.n[VZ] * d_inv); } inline vec3 operator ^(const vec3& a, const vec3& b) { return vec3(a.n[VY] * b.n[VZ] - a.n[VZ] * b.n[VY], a.n[VZ] * b.n[VX] - a.n[VX] * b.n[VZ], a.n[VX] * b.n[VY] - a.n[VY] * b.n[VX]); } inline int operator ==(const vec3& a, const vec3& b) { return (a.n[VX] == b.n[VX]) && (a.n[VY] == b.n[VY]) && (a.n[VZ] == b.n[VZ]); } inline int operator !=(const vec3& a, const vec3& b) { return !(a == b); } #ifdef ALGEBRA3IOSTREAMS inline ostream& operator <<(ostream& s, const vec3& v) { return s << "| " << v.n[VX] << ' ' << v.n[VY] << ' ' << v.n[VZ] << " |"; } inline istream& operator >>(istream& s, vec3& v) { vec3 v_tmp; char c = ' '; while (isspace(c)) s >> c; // The vectors can be formatted either as x y z or | x y z | if (c == '|') { s >> v_tmp[VX] >> v_tmp[VY] >> v_tmp[VZ]; while (s >> c && isspace(c)) ; if (c != '|') s.setstate(ios::badbit); } else { s.putback(c); s >> v_tmp[VX] >> v_tmp[VY] >> v_tmp[VZ]; } if (s) v = v_tmp; return s; } #endif // ALGEBRA3IOSTREAMS inline void swap(vec3& a, vec3& b) { vec3 tmp(a); a = b; b = tmp; } inline vec3 min(const vec3& a, const vec3& b) { return vec3(MIN(a.n[VX], b.n[VX]), MIN(a.n[VY], b.n[VY]), MIN(a.n[VZ], b.n[VZ]));} inline vec3 max(const vec3& a, const vec3& b) { return vec3(MAX(a.n[VX], b.n[VX]), MAX(a.n[VY], b.n[VY]), MAX(a.n[VZ], b.n[VZ]));} inline vec3 prod(const vec3& a, const vec3& b) { return vec3(a.n[VX] * b.n[VX], a.n[VY] * b.n[VY], a.n[VZ] * b.n[VZ]); } /**************************************************************** * * * vec4 Member functions * * * ****************************************************************/ // CONSTRUCTORS inline vec4::vec4() { } inline vec4::vec4(const double x, const double y, const double z, const double w) { n[VX] = x; n[VY] = y; n[VZ] = z; n[VW] = w; } inline vec4::vec4(const double d) { n[VX] = n[VY] = n[VZ] = n[VW] = d; } inline vec4::vec4(const vec4& v) { n[VX] = v.n[VX]; n[VY] = v.n[VY]; n[VZ] = v.n[VZ]; n[VW] = v.n[VW]; } inline vec4::vec4(const vec3& v) { n[VX] = v.n[VX]; n[VY] = v.n[VY]; n[VZ] = v.n[VZ]; n[VW] = 1.0; } inline vec4::vec4(const vec3& v, const double d) { n[VX] = v.n[VX]; n[VY] = v.n[VY]; n[VZ] = v.n[VZ]; n[VW] = d; } // ASSIGNMENT OPERATORS inline vec4& vec4::operator =(const vec4& v) { n[VX] = v.n[VX]; n[VY] = v.n[VY]; n[VZ] = v.n[VZ]; n[VW] = v.n[VW]; return *this; } inline vec4& vec4::operator +=(const vec4& v) { n[VX] += v.n[VX]; n[VY] += v.n[VY]; n[VZ] += v.n[VZ]; n[VW] += v.n[VW]; return *this; } inline vec4& vec4::operator -=(const vec4& v) { n[VX] -= v.n[VX]; n[VY] -= v.n[VY]; n[VZ] -= v.n[VZ]; n[VW] -= v.n[VW]; return *this; } inline vec4& vec4::operator *=(const double d) { n[VX] *= d; n[VY] *= d; n[VZ] *= d; n[VW] *= d; return *this; } inline vec4& vec4::operator /=(const double d) { double d_inv = 1. / d; n[VX] *= d_inv; n[VY] *= d_inv; n[VZ] *= d_inv; n[VW] *= d_inv; return *this; } inline double& vec4::operator [](int i) { assert(! (i < VX || i> VW)); return n[i]; } inline double vec4::operator [](int i) const { assert(! (i < VX || i> VW)); return n[i]; } // SPECIAL FUNCTIONS inline double vec4::length() const { return sqrt(length2()); } inline double vec4::length2() const { return n[VX] * n[VX] + n[VY] * n[VY] + n[VZ] * n[VZ] + n[VW] * n[VW]; } inline vec4& vec4::normalize() // it is up to caller to avoid divide-by-zero { *this /= length(); return *this; } inline vec4& vec4::apply(V_FCT_PTR fct) { n[VX] = (*fct)(n[VX]); n[VY] = (*fct)(n[VY]); n[VZ] = (*fct)(n[VZ]); n[VW] = (*fct)(n[VW]); return *this; } // FRIENDS inline vec4 operator -(const vec4& a) { return vec4(-a.n[VX], -a.n[VY], -a.n[VZ], -a.n[VW]); } inline vec4 operator +(const vec4& a, const vec4& b) { return vec4(a.n[VX] + b.n[VX], a.n[VY] + b.n[VY], a.n[VZ] + b.n[VZ], a.n[VW] + b.n[VW]); } inline vec4 operator -(const vec4& a, const vec4& b) { return vec4(a.n[VX] - b.n[VX], a.n[VY] - b.n[VY], a.n[VZ] - b.n[VZ], a.n[VW] - b.n[VW]); } inline vec4 operator *(const vec4& a, const double d) { return vec4(d * a.n[VX], d * a.n[VY], d * a.n[VZ], d * a.n[VW]); } inline vec4 operator *(const double d, const vec4& a) { return a * d; } inline vec4 operator *(const mat4& a, const vec4& v) { #define ROWCOL(i) a.v[i].n[0]*v.n[VX] + a.v[i].n[1]*v.n[VY] \ + a.v[i].n[2]*v.n[VZ] + a.v[i].n[3]*v.n[VW] return vec4(ROWCOL(0),ROWCOL(1), ROWCOL(2),ROWCOL(3)); #undef ROWCOL // (i) } inline vec4 operator *(const vec4& v, const mat4& a) { return a.transpose() * v; } inline double operator *(const vec4& a, const vec4& b) { return (a.n[VX] * b.n[VX] + a.n[VY] * b.n[VY] + a.n[VZ] * b.n[VZ] + a.n[VW] * b.n[VW]); } inline vec4 operator /(const vec4& a, const double d) { double d_inv = 1. / d; return vec4(a.n[VX] * d_inv, a.n[VY] * d_inv, a.n[VZ] * d_inv, a.n[VW] * d_inv); } inline int operator ==(const vec4& a, const vec4& b) { return (a.n[VX] == b.n[VX]) && (a.n[VY] == b.n[VY]) && (a.n[VZ] == b.n[VZ]) && (a.n[VW] == b.n[VW]); } inline int operator !=(const vec4& a, const vec4& b) { return !(a == b); } #ifdef ALGEBRA3IOSTREAMS inline ostream& operator <<(ostream& s, const vec4& v) { return s << "| " << v.n[VX] << ' ' << v.n[VY] << ' ' << v.n[VZ] << ' ' << v.n[VW] << " |"; } inline istream& operator >>(istream& s, vec4& v) { vec4 v_tmp; char c = ' '; while (isspace(c)) s >> c; // The vectors can be formatted either as x y z w or | x y z w | if (c == '|') { s >> v_tmp[VX] >> v_tmp[VY] >> v_tmp[VZ] >> v_tmp[VW]; while (s >> c && isspace(c)) ; if (c != '|') s.setstate(ios::badbit); } else { s.putback(c); s >> v_tmp[VX] >> v_tmp[VY] >> v_tmp[VZ] >> v_tmp[VW]; } if (s) v = v_tmp; return s; } #endif // ALGEBRA3IOSTREAMS inline void swap(vec4& a, vec4& b) { vec4 tmp(a); a = b; b = tmp; } inline vec4 min(const vec4& a, const vec4& b) { return vec4(MIN(a.n[VX], b.n[VX]), MIN(a.n[VY], b.n[VY]), MIN(a.n[VZ], b.n[VZ]), MIN(a.n[VW], b.n[VW]));} inline vec4 max(const vec4& a, const vec4& b) { return vec4(MAX(a.n[VX], b.n[VX]), MAX(a.n[VY], b.n[VY]), MAX(a.n[VZ], b.n[VZ]), MAX(a.n[VW], b.n[VW]));} inline vec4 prod(const vec4& a, const vec4& b) { return vec4(a.n[VX] * b.n[VX], a.n[VY] * b.n[VY], a.n[VZ] * b.n[VZ], a.n[VW] * b.n[VW]); } /**************************************************************** * * * mat3 member functions * * * ****************************************************************/ // CONSTRUCTORS inline mat3::mat3() { } inline mat3::mat3(const vec3& v0, const vec3& v1, const vec3& v2) { v[0] = v0; v[1] = v1; v[2] = v2; } inline mat3::mat3(const double d) { v[0] = v[1] = v[2] = vec3(d); } inline mat3::mat3(const mat3& m) { v[0] = m.v[0]; v[1] = m.v[1]; v[2] = m.v[2]; } // ASSIGNMENT OPERATORS inline mat3& mat3::operator =(const mat3& m) { v[0] = m.v[0]; v[1] = m.v[1]; v[2] = m.v[2]; return *this; } inline mat3& mat3::operator +=(const mat3& m) { v[0] += m.v[0]; v[1] += m.v[1]; v[2] += m.v[2]; return *this; } inline mat3& mat3::operator -=(const mat3& m) { v[0] -= m.v[0]; v[1] -= m.v[1]; v[2] -= m.v[2]; return *this; } inline mat3& mat3::operator *=(const double d) { v[0] *= d; v[1] *= d; v[2] *= d; return *this; } inline mat3& mat3::operator /=(const double d) { v[0] /= d; v[1] /= d; v[2] /= d; return *this; } inline vec3& mat3::operator [](int i) { assert(! (i < VX || i> VZ)); return v[i]; } inline const vec3& mat3::operator [](int i) const { assert(!(i < VX || i> VZ)); return v[i]; } // SPECIAL FUNCTIONS inline mat3 mat3::transpose() const { return mat3(vec3(v[0][0], v[1][0], v[2][0]), vec3(v[0][1], v[1][1], v[2][1]), vec3(v[0][2], v[1][2], v[2][2])); } inline mat3 mat3::inverse() const // Gauss-Jordan elimination with partial pivoting { mat3 a(*this), // As a evolves from original mat into identity b(identity2D()); // b evolves from identity into inverse(a) int i, j, i1; // Loop over cols of a from left to right, eliminating above and below diag for (j = 0; j < 3; j++) { // Find largest pivot in column j among rows j..2 i1 = j; // Row with largest pivot candidate for (i = j + 1; i < 3; i++) if (fabs(a.v[i].n[j]) > fabs(a.v[i1].n[j])) i1 = i; // Swap rows i1 and j in a and b to put pivot on diagonal swap(a.v[i1], a.v[j]); swap(b.v[i1], b.v[j]); // Scale row j to have a unit diagonal if (a.v[j].n[j] == 0.)ALGEBRA_ERROR("mat3::inverse: singular matrix; can't invert\n") b.v[j] /= a.v[j].n[j]; a.v[j] /= a.v[j].n[j]; // Eliminate off-diagonal elems in col j of a, doing identical ops to b for (i = 0; i < 3; i++) if (i != j) { b.v[i] -= a.v[i].n[j] * b.v[j]; a.v[i] -= a.v[i].n[j] * a.v[j]; } } return b; } inline mat3& mat3::apply(V_FCT_PTR fct) { v[VX].apply(fct); v[VY].apply(fct); v[VZ].apply(fct); return *this; } // FRIENDS inline mat3 operator -(const mat3& a) { return mat3(-a.v[0], -a.v[1], -a.v[2]); } inline mat3 operator +(const mat3& a, const mat3& b) { return mat3(a.v[0] + b.v[0], a.v[1] + b.v[1], a.v[2] + b.v[2]); } inline mat3 operator -(const mat3& a, const mat3& b) { return mat3(a.v[0] - b.v[0], a.v[1] - b.v[1], a.v[2] - b.v[2]); } inline mat3 operator *(const mat3& a, const mat3& b) { #define ROWCOL(i, j) \ a.v[i].n[0]*b.v[0][j] + a.v[i].n[1]*b.v[1][j] + a.v[i].n[2]*b.v[2][j] return mat3(vec3(ROWCOL(0,0),ROWCOL(0,1), ROWCOL(0,2)), vec3(ROWCOL(1,0),ROWCOL(1,1), ROWCOL(1,2)), vec3(ROWCOL(2,0),ROWCOL(2,1), ROWCOL(2,2))); #undef ROWCOL // (i, j) } inline mat3 operator *(const mat3& a, const double d) { return mat3(a.v[0] * d, a.v[1] * d, a.v[2] * d); } inline mat3 operator *(const double d, const mat3& a) { return a * d; } inline mat3 operator /(const mat3& a, const double d) { return mat3(a.v[0] / d, a.v[1] / d, a.v[2] / d); } inline int operator ==(const mat3& a, const mat3& b) { return (a.v[0] == b.v[0]) && (a.v[1] == b.v[1]) && (a.v[2] == b.v[2]); } inline int operator !=(const mat3& a, const mat3& b) { return !(a == b); } #ifdef ALGEBRA3IOSTREAMS inline ostream& operator <<(ostream& s, const mat3& m) { return s << m.v[VX] << '\n' << m.v[VY] << '\n' << m.v[VZ]; } inline istream& operator >>(istream& s, mat3& m) { mat3 m_tmp; s >> m_tmp[VX] >> m_tmp[VY] >> m_tmp[VZ]; if (s) m = m_tmp; return s; } #endif // ALGEBRA3IOSTREAMS inline void swap(mat3& a, mat3& b) { mat3 tmp(a); a = b; b = tmp; } /**************************************************************** * * * mat4 member functions * * * ****************************************************************/ // CONSTRUCTORS inline mat4::mat4() { } inline mat4::mat4(const vec4& v0, const vec4& v1, const vec4& v2, const vec4& v3) { v[0] = v0; v[1] = v1; v[2] = v2; v[3] = v3; } inline mat4::mat4(const double d) { v[0] = v[1] = v[2] = v[3] = vec4(d); } inline mat4::mat4(const mat4& m) { v[0] = m.v[0]; v[1] = m.v[1]; v[2] = m.v[2]; v[3] = m.v[3]; } // ASSIGNMENT OPERATORS inline mat4& mat4::operator =(const mat4& m) { v[0] = m.v[0]; v[1] = m.v[1]; v[2] = m.v[2]; v[3] = m.v[3]; return *this; } inline mat4& mat4::operator +=(const mat4& m) { v[0] += m.v[0]; v[1] += m.v[1]; v[2] += m.v[2]; v[3] += m.v[3]; return *this; } inline mat4& mat4::operator -=(const mat4& m) { v[0] -= m.v[0]; v[1] -= m.v[1]; v[2] -= m.v[2]; v[3] -= m.v[3]; return *this; } inline mat4& mat4::operator *=(const double d) { v[0] *= d; v[1] *= d; v[2] *= d; v[3] *= d; return *this; } inline mat4& mat4::operator /=(const double d) { v[0] /= d; v[1] /= d; v[2] /= d; v[3] /= d; return *this; } inline vec4& mat4::operator [](int i) { assert(! (i < VX || i> VW)); return v[i]; } inline const vec4& mat4::operator [](int i) const { assert(! (i < VX || i> VW)); return v[i]; } // SPECIAL FUNCTIONS; inline mat4 mat4::transpose() const { return mat4(vec4(v[0][0], v[1][0], v[2][0], v[3][0]), vec4(v[0][1], v[1][1], v[2][1], v[3][1]), vec4(v[0][2], v[1][2], v[2][2], v[3][2]), vec4(v[0][3], v[1][3], v[2][3], v[3][3])); } inline mat4 mat4::inverse() const // Gauss-Jordan elimination with partial pivoting { mat4 a(*this), // As a evolves from original mat into identity b(identity3D()); // b evolves from identity into inverse(a) int i, j, i1; // Loop over cols of a from left to right, eliminating above and below diag for (j = 0; j < 4; j++) { // Find largest pivot in column j among rows j..3 i1 = j; // Row with largest pivot candidate for (i = j + 1; i < 4; i++) if (fabs(a.v[i].n[j]) > fabs(a.v[i1].n[j])) i1 = i; // Swap rows i1 and j in a and b to put pivot on diagonal swap(a.v[i1], a.v[j]); swap(b.v[i1], b.v[j]); // Scale row j to have a unit diagonal if (a.v[j].n[j] == 0.)ALGEBRA_ERROR("mat4::inverse: singular matrix; can't invert\n"); b.v[j] /= a.v[j].n[j]; a.v[j] /= a.v[j].n[j]; // Eliminate off-diagonal elems in col j of a, doing identical ops to b for (i = 0; i < 4; i++) if (i != j) { b.v[i] -= a.v[i].n[j] * b.v[j]; a.v[i] -= a.v[i].n[j] * a.v[j]; } } return b; } inline mat4& mat4::apply(V_FCT_PTR fct) { v[VX].apply(fct); v[VY].apply(fct); v[VZ].apply(fct); v[VW].apply(fct); return *this; } // FRIENDS inline mat4 operator -(const mat4& a) { return mat4(-a.v[0], -a.v[1], -a.v[2], -a.v[3]); } inline mat4 operator +(const mat4& a, const mat4& b) { return mat4(a.v[0] + b.v[0], a.v[1] + b.v[1], a.v[2] + b.v[2], a.v[3] + b.v[3]); } inline mat4 operator -(const mat4& a, const mat4& b) { return mat4(a.v[0] - b.v[0], a.v[1] - b.v[1], a.v[2] - b.v[2], a.v[3] - b.v[3]); } inline mat4 operator *(const mat4& a, const mat4& b) { #define ROWCOL(i, j) a.v[i].n[0]*b.v[0][j] + a.v[i].n[1]*b.v[1][j] + \ a.v[i].n[2]*b.v[2][j] + a.v[i].n[3]*b.v[3][j] return mat4(vec4(ROWCOL(0,0),ROWCOL(0,1), ROWCOL(0,2),ROWCOL(0,3)), vec4(ROWCOL(1,0),ROWCOL(1,1), ROWCOL(1,2),ROWCOL(1,3)), vec4(ROWCOL(2,0),ROWCOL(2,1), ROWCOL(2,2),ROWCOL(2,3)), vec4(ROWCOL(3,0),ROWCOL(3,1), ROWCOL(3,2),ROWCOL(3,3))); #undef ROWCOL } inline mat4 operator *(const mat4& a, const double d) { return mat4(a.v[0] * d, a.v[1] * d, a.v[2] * d, a.v[3] * d); } inline mat4 operator *(const double d, const mat4& a) { return a * d; } inline mat4 operator /(const mat4& a, const double d) { return mat4(a.v[0] / d, a.v[1] / d, a.v[2] / d, a.v[3] / d); } inline int operator ==(const mat4& a, const mat4& b) { return ((a.v[0] == b.v[0]) && (a.v[1] == b.v[1]) && (a.v[2] == b.v[2]) && (a.v[3] == b.v[3])); } inline int operator !=(const mat4& a, const mat4& b) { return !(a == b); } #ifdef ALGEBRA3IOSTREAMS inline ostream& operator <<(ostream& s, const mat4& m) { return s << m.v[VX] << '\n' << m.v[VY] << '\n' << m.v[VZ] << '\n' << m.v[VW]; } inline istream& operator >>(istream& s, mat4& m) { mat4 m_tmp; s >> m_tmp[VX] >> m_tmp[VY] >> m_tmp[VZ] >> m_tmp[VW]; if (s) m = m_tmp; return s; } #endif // ALGEBRA3IOSTREAMS inline void swap(mat4& a, mat4& b) { mat4 tmp(a); a = b; b = tmp; } /**************************************************************** * * * Mathematica Functions * * * ****************************************************************/ inline mat3 List(vec3 v0, vec3 v1, vec3 v2) { return mat3(v0, v1, v2); } inline vec3 List(double s0, double s1, double s2) { return vec3(s0, s1, s2); } // note -- I removed pointless redefinitions of existing math functions, as they were pointless //inline double Abs(double value) { return abs(value); } //inline double Power(double value, double exp) { return pow(value, exp); } //inline double Sqrt(double value) { return sqrt(value); } /**************************************************************** * * * 2D functions and 3D functions * * * ****************************************************************/ inline mat3 identity2D() { return mat3(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0)); } inline mat3 translation2D(const vec2& v) { return mat3(vec3(1.0, 0.0, v[VX]), vec3(0.0, 1.0, v[VY]), vec3(0.0, 0.0, 1.0)); } inline mat3 rotation2D(const vec2& Center, const double angleDeg) { double angleRad = angleDeg * M_PI / 180.0, c = cos(angleRad), s = sin( angleRad); return mat3(vec3(c, -s, Center[VX] * (1.0 - c) + Center[VY] * s), vec3(s, c, Center[VY] * (1.0 - c) - Center[VX] * s), vec3(0.0, 0.0, 1.0)); } inline mat3 scaling2D(const vec2& scaleVector) { return mat3(vec3(scaleVector[VX], 0.0, 0.0), vec3(0.0, scaleVector[VY], 0.0), vec3(0.0, 0.0, 1.0)); } inline mat4 identity3D() { return mat4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); } inline mat4 translation3D(const vec3& v) { return mat4(vec4(1.0, 0.0, 0.0, v[VX]), vec4(0.0, 1.0, 0.0, v[VY]), vec4( 0.0, 0.0, 1.0, v[VZ]), vec4(0.0, 0.0, 0.0, 1.0)); } inline mat4 rotation3D(vec3 Axis, const double angleDeg) { double angleRad = angleDeg * M_PI / 180.0, c = cos(angleRad), s = sin( angleRad), t = 1.0 - c; Axis.normalize(); return mat4(vec4(t * Axis[VX] * Axis[VX] + c, t * Axis[VX] * Axis[VY] - s * Axis[VZ], t * Axis[VX] * Axis[VZ] + s * Axis[VY], 0.0), vec4(t * Axis[VX] * Axis[VY] + s * Axis[VZ], t * Axis[VY] * Axis[VY] + c, t * Axis[VY] * Axis[VZ] - s * Axis[VX], 0.0), vec4(t * Axis[VX] * Axis[VZ] - s * Axis[VY], t * Axis[VY] * Axis[VZ] + s * Axis[VX], t * Axis[VZ] * Axis[VZ] + c, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); } inline mat4 scaling3D(const vec3& scaleVector) { return mat4(vec4(scaleVector[VX], 0.0, 0.0, 0.0), vec4(0.0, scaleVector[VY], 0.0, 0.0), vec4(0.0, 0.0, scaleVector[VZ], 0.0), vec4(0.0, 0.0, 0.0, 1.0)); } inline mat4 perspective3D(const double d) { return mat4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 1.0 / d, 0.0)); } #endif // ALGEBRA3H
[ [ [ 1, 1565 ] ] ]
408e9cdc8e1c78b89689a74a94d9874d479c5d8b
7b4c786d4258ce4421b1e7bcca9011d4eeb50083
/Learning OpenCV/Chapter 6 - Image Transforms/Ch6_Test_cvHoughLines2.cpp
310a597b819b09a85c16a66a9fa5ab600f3d4e2e
[]
no_license
lzq123218/guoyishi-works
dbfa42a3e2d3bd4a984a5681e4335814657551ef
4e78c8f2e902589c3f06387374024225f52e5a92
refs/heads/master
2021-12-04T11:11:32.639076
2011-05-30T14:12:43
2011-05-30T14:12:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,841
cpp
//////////////////////////////////////////////////// // Date: 2009-10-02 // Coder: Yishi Guo // Copy From: OpenCV: Image Processing and Computer Vision Reference Manual // Chapter: 6 // Content: cvHoughLines2 | Image Transforms // Page: 156 //////////////////////////////////////////////////// #include <cv.h> #include <highgui.h> int main(int argc, char** argv) { if ( argc >= 2 ) { // Initialize variables // IplImage* src = cvLoadImage( argv[1], CV_LOAD_IMAGE_GRAYSCALE ); IplImage* dst = cvCreateImage( cvGetSize(src), src->depth, 1 ); IplImage* color_dst = cvCreateImage( cvGetSize(src), IPL_DEPTH_8U, 3 ); CvMemStorage* storage = cvCreateMemStorage(0); CvSeq* lines = 0; int i = 0; // Do something on the image // if ( argc >= 4 ) { cvCanny( src, dst, atoi(argv[2]), atoi(argv[3]), 3 ); } else { cvCanny( src, dst, 50, 200, 3 ); } cvCvtColor( dst, color_dst, CV_GRAY2BGR ); // cvHoughLines2 // if ( argc >= 9 ) { lines = cvHoughLines2( dst, storage, CV_HOUGH_PROBABILISTIC, atoi(argv[4]), atof(argv[5]), atoi(argv[6]), atoi(argv[7]), atoi(argv[8]) ); } else { lines = cvHoughLines2( dst, storage, CV_HOUGH_PROBABILISTIC, 1, CV_PI/180, 50, 50, 10 ); } // Draw lines on the image // for( i = 0; i < lines->total; i++ ) { CvPoint* line = (CvPoint*)cvGetSeqElem(lines, i); cvLine( color_dst, line[0], line[1], CV_RGB(255, 0, 0), 3, 8 ); } cvNamedWindow("Source", 1 ); cvShowImage( "Source", src ); cvNamedWindow( "Hough", 1 ); cvShowImage( "Hough", color_dst ); cvWaitKey(0); // Clear resources // cvReleaseImage( &src ); cvReleaseImage( &dst ); cvReleaseImage( &color_dst ); cvDestroyWindow( "Source" ); cvDestroyWindow( "Hough" ); } return 0; }
[ "baicaibang@70501136-4834-11de-8855-c187e5f49513" ]
[ [ [ 1, 67 ] ] ]
27f1fd2f04447ad84f9324d05bc911aed4ebfd71
1ad310fc8abf44dbcb99add43f6c6b4c97a3767c
/samples_c++/cpp/TribotRC/sample.cpp
901f2d9fa9bf1df3a5c1226154af5b84adcb84ec
[]
no_license
Jazzinghen/spamOSEK
fed44979b86149809f0fe70355f2117e9cb954f3
7223a2fb78401e1d9fa96ecaa2323564c765c970
refs/heads/master
2020-06-01T03:55:48.113095
2010-05-19T14:37:30
2010-05-19T14:37:30
580,640
1
2
null
null
null
null
UTF-8
C++
false
false
2,422
cpp
// Tribot RC sample.cpp for TOPPERS/ATK(OSEK) #include <algorithm> // ECRobot++ API #include "Motor.h" #include "Lcd.h" #include "Nxt.h" #include "Clock.h" #include "Speaker.h" #include "GamePad.h" #include "Bluetooth.h" #include "BTConnection.h" using namespace ecrobot; #include "Driver.h" #include "GamePadDriver.h" #include "DriverManager.h" //============================================================================= // Device objects Motor motorR(PORT_A, false); // brake:off Motor motorL(PORT_B, false); // brake:off Bluetooth bt; Clock nxtClock; Lcd lcd; Nxt nxt; Speaker speaker; static const CHAR BT_PASS_KEY[] = "1234"; // Bluetooth pass key extern "C" { #include "kernel.h" #include "kernel_id.h" #include "ecrobot_interface.h" //============================================================================= // 1msec timer interrupt hook void user_1ms_isr_type2(void){} //============================================================================= // Main Task TASK(TaskMain) { // Establish blutooth connection with the PC BTConnection btConnection(bt, lcd, nxt); if (btConnection.connect(BT_PASS_KEY) == 1) { speaker.playTone(440U, 500U, 30U); // Beep a tone to inform the robot is ready to drive } // Define and register drivers GamePad gp(bt); GamePadDriver gpDriver(gp); // Control the robot using a PC HID gamepad controller Driver defaultDriver; DriverManager drivers; (void)drivers.createDriverTable(2); (void)drivers.add(&gpDriver); // Highest priority (void)drivers.add(&defaultDriver); // Lowest priority VectorT<S16> cmd; while(1) { (void)drivers.update(); // This should be invoked prior to get the latest request switch(drivers.getRequest()) { case Driver::DRIVE: cmd = drivers.getCommand(); // Calculate PWM value for each motor based on the command received from the Gamepad S16 pwmR = cmd.mX - cmd.mY; S16 pwmL = cmd.mX + cmd.mY; // Check PWM limits pwmR = std::max(std::min(pwmR, static_cast<S16>(Motor::PWM_MAX)), static_cast<S16>(Motor::PWM_MIN)); pwmL = std::max(std::min(pwmL, static_cast<S16>(Motor::PWM_MAX)), static_cast<S16>(Motor::PWM_MIN)); motorR.setPWM(static_cast<S8>(pwmR)); motorL.setPWM(static_cast<S8>(pwmL)); break; default: break; // Do nothing } nxtClock.wait(40); // 40msec wait } } };
[ "jazzinghen@Jehuty.(none)" ]
[ [ [ 1, 86 ] ] ]
1a1f50f7f7820b36463af80b528ca0d5ccfe39f3
119ba245bea18df8d27b84ee06e152b35c707da1
/unreal/branches/robots/qrgui/interpreters/robots/details/robotImplementations/sensorImplementations/abstractSensorImplementation.h
766c8dbdc1e2e5adf92cedb2ce1b3e6709af7b8b
[]
no_license
nfrey/qreal
05cd4f9b9d3193531eb68ff238d8a447babcb3d2
71641e6c5f8dc87eef9ec3a01cabfb9dd7b0e164
refs/heads/master
2020-04-06T06:43:41.910531
2011-05-30T19:30:09
2011-05-30T19:30:09
1,634,768
0
0
null
null
null
null
UTF-8
C++
false
false
703
h
#pragma once #include <QtCore/QObject> #include "../../../sensorConstants.h" namespace qReal { namespace interpreters { namespace robots { namespace details { namespace robotImplementations { namespace sensorImplementations { class AbstractSensorImplementation : public QObject { Q_OBJECT public: AbstractSensorImplementation(inputPort::InputPortEnum const &port); virtual ~AbstractSensorImplementation() {}; virtual void read() = 0; void setPort(inputPort::InputPortEnum const &port); signals: void response(int reading); void failure(); protected: enum State { idle , pending }; inputPort::InputPortEnum mPort; State mState; }; } } } } } }
[ [ [ 1, 40 ] ] ]
83795cf49bbaa4213d46d91525cabf17f3007d1a
6e563096253fe45a51956dde69e96c73c5ed3c18
/dhnetsdk/dvr/Net/Broadcast.cpp
e2d8eba21a49135be97893e2ee0b1018c469f2e6
[]
no_license
15831944/phoebemail
0931b76a5c52324669f902176c8477e3bd69f9b1
e10140c36153aa00d0251f94bde576c16cab61bd
refs/heads/master
2023-03-16T00:47:40.484758
2010-10-11T02:31:02
2010-10-11T02:31:02
null
0
0
null
null
null
null
GB18030
C++
false
false
4,689
cpp
// BroadCast.cpp: implementation of the BroadCast class. // ////////////////////////////////////////////////////////////////////// #include "../StdAfx.h" #include "Broadcast.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CBroadcast::CBroadcast() : TPBroadcast(this) { m_pPacketBuf = NULL; m_nBufSize = 0; m_nWritePos = 0; m_nReadPos = 0; m_pRecvPakcet = NULL; m_pUserData = NULL; } int CBroadcast::CreateRecvBuf(unsigned int nRecvSize) { if (nRecvSize > 0 && m_pPacketBuf == NULL) { m_pPacketBuf = new unsigned char[nRecvSize]; if (m_pPacketBuf != NULL) { m_nBufSize = nRecvSize; return 1; } } return -1; } CBroadcast::~CBroadcast() { if (m_pPacketBuf != NULL) { delete m_pPacketBuf; m_pPacketBuf = NULL; } m_nBufSize = 0; } void CBroadcast::SetCallBack(OnBroadcastPacketFunc cbReceivePacket, void *userdata) { m_pRecvPakcet = cbReceivePacket; m_pUserData = userdata; } int CBroadcast::ConnectHost(int nRemotePort) { return Connect(NULL, nRemotePort); } int CBroadcast::ConnectHost(const char* szLocalIp, int nLocalPort, int nRemotePort) { return Connect(szLocalIp, nLocalPort, NULL, nRemotePort); } void CBroadcast::Disconnect() { Close(); } int CBroadcast::WriteData(char *pBuf, int nLen) { IBufferRef pDataBuf = CAutoBuffer::CreateBuffer(nLen, pBuf, true); if (pDataBuf.IsEmpty()) { return -1; } return Send(0, pDataBuf); } int CBroadcast::onData(int nEngineId, int nConnId, unsigned char* data, int nLen) { int nRet = 1; if (m_pPacketBuf == NULL) { return nRet; } CReadWriteMutexLock lock(m_csBuffer); if (nLen > 0) { /***********************缓冲数据***********************/ // 现在当包长大于存储空间时采取丢包的原则 // 情况可能有:调试中断太久和收到错误数据包 int nEndPos = nLen + m_nWritePos; // 如果缓冲区足够缓冲数据 if (nEndPos <= m_nBufSize) { memcpy(m_pPacketBuf + m_nWritePos, data, nLen); m_nWritePos = m_nWritePos + nLen; } // 如果缓冲区不足以缓冲数据,从头再来 else { // 整个缓冲区都不足以容纳该数据,一般是因为调试中断太久或错误数据包 if (nLen + (m_nWritePos-m_nReadPos) >= m_nBufSize) { nLen = 0; nRet = -1; } else { memmove(m_pPacketBuf, m_pPacketBuf + m_nReadPos, m_nWritePos - m_nReadPos); m_nWritePos = m_nWritePos - m_nReadPos; m_nReadPos = 0; if (nLen > 0) { memcpy(m_pPacketBuf + m_nWritePos, data, nLen); m_nWritePos = m_nWritePos + nLen; } } } } lock.Unlock(); return nRet; } /* * 摘要:处理数据 * 返回值:0:忙;1:空闲 */ int CBroadcast::onDealData(int nEngineId, int nConnId, unsigned char* buffer, int nLen) { int nRet = 1; if (m_pPacketBuf == NULL) { return nRet; } int nPacketLen = GetData(buffer, nLen); if (nPacketLen > 0) { if (m_pRecvPakcet) { m_pRecvPakcet(this, buffer, nPacketLen, NULL, m_pUserData); } nRet = 0; } return nRet; } int CBroadcast::onSendDataAck(int nEngineId, int nConnId, int nId) { return 1; } int CBroadcast::onConnect(int nEngineId, int nConnId, char* szIp, int nPort) { return 1; } int CBroadcast::onClose(int nEngineId, int nConnId) { return 1; } int CBroadcast::onDisconnect(int nEngineId, int nConnId) { return 1; } int CBroadcast::onReconnect(int nEngineId, int nConnId) { return 1; } int CBroadcast::GetData(unsigned char* buf, int len) { int nDataLen = 0; CReadWriteMutexLock lock(m_csBuffer); if ((int)(m_nWritePos - m_nReadPos) >= HEADER_SIZE) { unsigned int extlen = *(unsigned int*)(m_pPacketBuf + m_nReadPos + 4); extlen += *(unsigned char*)(m_pPacketBuf + m_nReadPos + 2); if ((extlen + HEADER_SIZE) >= len) { // 指示的扩展数据太长,不正常,清空缓存 #ifdef DEBUG OutputDebugString("指示的扩展数据太长,不正常,清空缓存\n"); #endif m_nWritePos = m_nReadPos = 0; return 0; } if (m_nWritePos - m_nReadPos >= extlen + HEADER_SIZE) { nDataLen = extlen + HEADER_SIZE; memcpy(buf, m_pPacketBuf + m_nReadPos, nDataLen); m_nReadPos += nDataLen; } } lock.Unlock(); return nDataLen; }
[ "guoqiao@a83c37f4-16cc-5f24-7598-dca3a346d5dd" ]
[ [ [ 1, 220 ] ] ]
bf3ad837b1ebe5cc50c5de6aa2bae5d10e897a33
037faae47a5b22d3e283555e6b5ac2a0197faf18
/pcsx2v2/windows/Debugreg.cpp
f73700c8981be758f1db538c030e00d8b4a81c9e
[]
no_license
isabella232/pcsx2-sourceforge
6e5aac8d0b476601bfc8fa83ded66c1564b8c588
dbb2c3a010081b105a8cba0c588f1e8f4e4505c6
refs/heads/master
2023-03-18T22:23:15.102593
2008-11-17T20:10:17
2008-11-17T20:10:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
66,912
cpp
/* Pcsx2 - Pc Ps2 Emulator * Copyright (C) 2002-2008 Pcsx2 Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #define WINVER 0x0500 #include <windows.h> #include <commdlg.h> #include "resource.h" #include "Debugger.h" #include "Debug.h" #include "R5900.h" #include "R3000a.h" #include "VUmicro.h" HINSTANCE m_hInst; HWND m_hWnd; char text1[256]; /*R3000a registers handle */ static HWND IOPGPR0Handle=NULL; static HWND IOPGPR1Handle=NULL; static HWND IOPGPR2Handle=NULL; static HWND IOPGPR3Handle=NULL; static HWND IOPGPR4Handle=NULL; static HWND IOPGPR5Handle=NULL; static HWND IOPGPR6Handle=NULL; static HWND IOPGPR7Handle=NULL; static HWND IOPGPR8Handle=NULL; static HWND IOPGPR9Handle=NULL; static HWND IOPGPR10Handle=NULL; static HWND IOPGPR11Handle=NULL; static HWND IOPGPR12Handle=NULL; static HWND IOPGPR13Handle=NULL; static HWND IOPGPR14Handle=NULL; static HWND IOPGPR15Handle=NULL; static HWND IOPGPR16Handle=NULL; static HWND IOPGPR17Handle=NULL; static HWND IOPGPR18Handle=NULL; static HWND IOPGPR19Handle=NULL; static HWND IOPGPR20Handle=NULL; static HWND IOPGPR21Handle=NULL; static HWND IOPGPR22Handle=NULL; static HWND IOPGPR23Handle=NULL; static HWND IOPGPR24Handle=NULL; static HWND IOPGPR25Handle=NULL; static HWND IOPGPR26Handle=NULL; static HWND IOPGPR27Handle=NULL; static HWND IOPGPR28Handle=NULL; static HWND IOPGPR29Handle=NULL; static HWND IOPGPR30Handle=NULL; static HWND IOPGPR31Handle=NULL; static HWND IOPGPRPCHandle=NULL; static HWND IOPGPRHIHandle=NULL; static HWND IOPGPRLOHandle=NULL; /*R5900 registers handle */ static HWND GPR0Handle=NULL; static HWND GPR1Handle=NULL; static HWND GPR2Handle=NULL; static HWND GPR3Handle=NULL; static HWND GPR4Handle=NULL; static HWND GPR5Handle=NULL; static HWND GPR6Handle=NULL; static HWND GPR7Handle=NULL; static HWND GPR8Handle=NULL; static HWND GPR9Handle=NULL; static HWND GPR10Handle=NULL; static HWND GPR11Handle=NULL; static HWND GPR12Handle=NULL; static HWND GPR13Handle=NULL; static HWND GPR14Handle=NULL; static HWND GPR15Handle=NULL; static HWND GPR16Handle=NULL; static HWND GPR17Handle=NULL; static HWND GPR18Handle=NULL; static HWND GPR19Handle=NULL; static HWND GPR20Handle=NULL; static HWND GPR21Handle=NULL; static HWND GPR22Handle=NULL; static HWND GPR23Handle=NULL; static HWND GPR24Handle=NULL; static HWND GPR25Handle=NULL; static HWND GPR26Handle=NULL; static HWND GPR27Handle=NULL; static HWND GPR28Handle=NULL; static HWND GPR29Handle=NULL; static HWND GPR30Handle=NULL; static HWND GPR31Handle=NULL; static HWND GPRPCHandle=NULL; static HWND GPRHIHandle=NULL; static HWND GPRLOHandle=NULL; /*end of r3000a registers handle */ /*cop0 registers here */ static HWND COP00Handle=NULL; static HWND COP01Handle=NULL; static HWND COP02Handle=NULL; static HWND COP03Handle=NULL; static HWND COP04Handle=NULL; static HWND COP05Handle=NULL; static HWND COP06Handle=NULL; static HWND COP07Handle=NULL; static HWND COP08Handle=NULL; static HWND COP09Handle=NULL; static HWND COP010Handle=NULL; static HWND COP011Handle=NULL; static HWND COP012Handle=NULL; static HWND COP013Handle=NULL; static HWND COP014Handle=NULL; static HWND COP015Handle=NULL; static HWND COP016Handle=NULL; static HWND COP017Handle=NULL; static HWND COP018Handle=NULL; static HWND COP019Handle=NULL; static HWND COP020Handle=NULL; static HWND COP021Handle=NULL; static HWND COP022Handle=NULL; static HWND COP023Handle=NULL; static HWND COP024Handle=NULL; static HWND COP025Handle=NULL; static HWND COP026Handle=NULL; static HWND COP027Handle=NULL; static HWND COP028Handle=NULL; static HWND COP029Handle=NULL; static HWND COP030Handle=NULL; static HWND COP031Handle=NULL; static HWND COP0PCHandle=NULL; static HWND COP0HIHandle=NULL; static HWND COP0LOHandle=NULL; /*end of cop0 registers */ /*cop1 registers here */ static HWND COP10Handle=NULL; static HWND COP11Handle=NULL; static HWND COP12Handle=NULL; static HWND COP13Handle=NULL; static HWND COP14Handle=NULL; static HWND COP15Handle=NULL; static HWND COP16Handle=NULL; static HWND COP17Handle=NULL; static HWND COP18Handle=NULL; static HWND COP19Handle=NULL; static HWND COP110Handle=NULL; static HWND COP111Handle=NULL; static HWND COP112Handle=NULL; static HWND COP113Handle=NULL; static HWND COP114Handle=NULL; static HWND COP115Handle=NULL; static HWND COP116Handle=NULL; static HWND COP117Handle=NULL; static HWND COP118Handle=NULL; static HWND COP119Handle=NULL; static HWND COP120Handle=NULL; static HWND COP121Handle=NULL; static HWND COP122Handle=NULL; static HWND COP123Handle=NULL; static HWND COP124Handle=NULL; static HWND COP125Handle=NULL; static HWND COP126Handle=NULL; static HWND COP127Handle=NULL; static HWND COP128Handle=NULL; static HWND COP129Handle=NULL; static HWND COP130Handle=NULL; static HWND COP131Handle=NULL; static HWND COP1C0Handle=NULL; static HWND COP1C1Handle=NULL; static HWND COP1ACCHandle=NULL; /*end of cop1 registers */ /*cop2 floating registers*/ static HWND VU0F00Handle=NULL; static HWND VU0F01Handle=NULL; static HWND VU0F02Handle=NULL; static HWND VU0F03Handle=NULL; static HWND VU0F04Handle=NULL; static HWND VU0F05Handle=NULL; static HWND VU0F06Handle=NULL; static HWND VU0F07Handle=NULL; static HWND VU0F08Handle=NULL; static HWND VU0F09Handle=NULL; static HWND VU0F10Handle=NULL; static HWND VU0F11Handle=NULL; static HWND VU0F12Handle=NULL; static HWND VU0F13Handle=NULL; static HWND VU0F14Handle=NULL; static HWND VU0F15Handle=NULL; static HWND VU0F16Handle=NULL; static HWND VU0F17Handle=NULL; static HWND VU0F18Handle=NULL; static HWND VU0F19Handle=NULL; static HWND VU0F20Handle=NULL; static HWND VU0F21Handle=NULL; static HWND VU0F22Handle=NULL; static HWND VU0F23Handle=NULL; static HWND VU0F24Handle=NULL; static HWND VU0F25Handle=NULL; static HWND VU0F26Handle=NULL; static HWND VU0F27Handle=NULL; static HWND VU0F28Handle=NULL; static HWND VU0F29Handle=NULL; static HWND VU0F30Handle=NULL; static HWND VU0F31Handle=NULL; /*end of cop2 floating registers*/ /*cop2 control registers */ static HWND VU0C00Handle=NULL; static HWND VU0C01Handle=NULL; static HWND VU0C02Handle=NULL; static HWND VU0C03Handle=NULL; static HWND VU0C04Handle=NULL; static HWND VU0C05Handle=NULL; static HWND VU0C06Handle=NULL; static HWND VU0C07Handle=NULL; static HWND VU0C08Handle=NULL; static HWND VU0C09Handle=NULL; static HWND VU0C10Handle=NULL; static HWND VU0C11Handle=NULL; static HWND VU0C12Handle=NULL; static HWND VU0C13Handle=NULL; static HWND VU0C14Handle=NULL; static HWND VU0C15Handle=NULL; static HWND VU0C16Handle=NULL; static HWND VU0C17Handle=NULL; static HWND VU0C18Handle=NULL; static HWND VU0C19Handle=NULL; static HWND VU0C20Handle=NULL; static HWND VU0C21Handle=NULL; static HWND VU0C22Handle=NULL; static HWND VU0C23Handle=NULL; static HWND VU0C24Handle=NULL; static HWND VU0C25Handle=NULL; static HWND VU0C26Handle=NULL; static HWND VU0C27Handle=NULL; static HWND VU0C28Handle=NULL; static HWND VU0C29Handle=NULL; static HWND VU0C30Handle=NULL; static HWND VU0C31Handle=NULL; static HWND VU0ACCHandle=NULL; /*end of cop2 control registers */ /*vu1 floating registers*/ static HWND VU1F00Handle=NULL; static HWND VU1F01Handle=NULL; static HWND VU1F02Handle=NULL; static HWND VU1F03Handle=NULL; static HWND VU1F04Handle=NULL; static HWND VU1F05Handle=NULL; static HWND VU1F06Handle=NULL; static HWND VU1F07Handle=NULL; static HWND VU1F08Handle=NULL; static HWND VU1F09Handle=NULL; static HWND VU1F10Handle=NULL; static HWND VU1F11Handle=NULL; static HWND VU1F12Handle=NULL; static HWND VU1F13Handle=NULL; static HWND VU1F14Handle=NULL; static HWND VU1F15Handle=NULL; static HWND VU1F16Handle=NULL; static HWND VU1F17Handle=NULL; static HWND VU1F18Handle=NULL; static HWND VU1F19Handle=NULL; static HWND VU1F20Handle=NULL; static HWND VU1F21Handle=NULL; static HWND VU1F22Handle=NULL; static HWND VU1F23Handle=NULL; static HWND VU1F24Handle=NULL; static HWND VU1F25Handle=NULL; static HWND VU1F26Handle=NULL; static HWND VU1F27Handle=NULL; static HWND VU1F28Handle=NULL; static HWND VU1F29Handle=NULL; static HWND VU1F30Handle=NULL; static HWND VU1F31Handle=NULL; /*end of vu1 floating registers*/ /*vu1 control registers */ static HWND VU1C00Handle=NULL; static HWND VU1C01Handle=NULL; static HWND VU1C02Handle=NULL; static HWND VU1C03Handle=NULL; static HWND VU1C04Handle=NULL; static HWND VU1C05Handle=NULL; static HWND VU1C06Handle=NULL; static HWND VU1C07Handle=NULL; static HWND VU1C08Handle=NULL; static HWND VU1C09Handle=NULL; static HWND VU1C10Handle=NULL; static HWND VU1C11Handle=NULL; static HWND VU1C12Handle=NULL; static HWND VU1C13Handle=NULL; static HWND VU1C14Handle=NULL; static HWND VU1C15Handle=NULL; static HWND VU1C16Handle=NULL; static HWND VU1C17Handle=NULL; static HWND VU1C18Handle=NULL; static HWND VU1C19Handle=NULL; static HWND VU1C20Handle=NULL; static HWND VU1C21Handle=NULL; static HWND VU1C22Handle=NULL; static HWND VU1C23Handle=NULL; static HWND VU1C24Handle=NULL; static HWND VU1C25Handle=NULL; static HWND VU1C26Handle=NULL; static HWND VU1C27Handle=NULL; static HWND VU1C28Handle=NULL; static HWND VU1C29Handle=NULL; static HWND VU1C30Handle=NULL; static HWND VU1C31Handle=NULL; static HWND VU1ACCHandle=NULL; /*end of vu1 control registers */ LRESULT CALLBACK R3000reg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); //comctl32 lib must add to project.. int CreatePropertySheet(HWND hwndOwner) { PROPSHEETPAGE psp[7]; PROPSHEETHEADER psh; psp[0].dwSize = sizeof(PROPSHEETPAGE); psp[0].dwFlags = PSP_USETITLE; psp[0].hInstance = m_hInst; psp[0].pszTemplate = MAKEINTRESOURCE( IDD_GPREGS); psp[0].pszIcon = NULL; psp[0].pfnDlgProc =(DLGPROC)R5900reg; psp[0].pszTitle = "R5900"; psp[0].lParam = 0; psp[1].dwSize = sizeof(PROPSHEETPAGE); psp[1].dwFlags = PSP_USETITLE; psp[1].hInstance = m_hInst; psp[1].pszTemplate = MAKEINTRESOURCE( IDD_CP0REGS ); psp[1].pszIcon = NULL; psp[1].pfnDlgProc =(DLGPROC)COP0reg; psp[1].pszTitle = "COP0"; psp[1].lParam = 0; psp[2].dwSize = sizeof(PROPSHEETPAGE); psp[2].dwFlags = PSP_USETITLE; psp[2].hInstance = m_hInst; psp[2].pszTemplate = MAKEINTRESOURCE( IDD_CP1REGS ); psp[2].pszIcon = NULL; psp[2].pfnDlgProc =(DLGPROC)COP1reg; psp[2].pszTitle = "COP1"; psp[2].lParam = 0; psp[3].dwSize = sizeof(PROPSHEETPAGE); psp[3].dwFlags = PSP_USETITLE; psp[3].hInstance = m_hInst; psp[3].pszTemplate = MAKEINTRESOURCE( IDD_VU0REGS ); psp[3].pszIcon = NULL; psp[3].pfnDlgProc =(DLGPROC)COP2Freg; psp[3].pszTitle = "COP2F"; psp[3].lParam = 0; psp[4].dwSize = sizeof(PROPSHEETPAGE); psp[4].dwFlags = PSP_USETITLE; psp[4].hInstance = m_hInst; psp[4].pszTemplate = MAKEINTRESOURCE( IDD_VU0INTEGER ); psp[4].pszIcon = NULL; psp[4].pfnDlgProc =(DLGPROC)COP2Creg; psp[4].pszTitle = "COP2C"; psp[4].lParam = 0; psp[5].dwSize = sizeof(PROPSHEETPAGE); psp[5].dwFlags = PSP_USETITLE; psp[5].hInstance = m_hInst; psp[5].pszTemplate = MAKEINTRESOURCE( IDD_VU1REGS ); psp[5].pszIcon = NULL; psp[5].pfnDlgProc =(DLGPROC)VU1Freg; psp[5].pszTitle = "VU1F"; psp[5].lParam = 0; psp[6].dwSize = sizeof(PROPSHEETPAGE); psp[6].dwFlags = PSP_USETITLE; psp[6].hInstance = m_hInst; psp[6].pszTemplate = MAKEINTRESOURCE( IDD_VU1INTEGER ); psp[6].pszIcon = NULL; psp[6].pfnDlgProc =(DLGPROC)VU1Creg; psp[6].pszTitle = "VU1C"; psp[6].lParam = 0; psp[6].dwSize = sizeof(PROPSHEETPAGE); psp[6].dwFlags = PSP_USETITLE; psp[6].hInstance = m_hInst; psp[6].pszTemplate = MAKEINTRESOURCE( IDD_IOPREGS ); psp[6].pszIcon = NULL; psp[6].pfnDlgProc =(DLGPROC)R3000reg; psp[6].pszTitle = "R3000"; psp[6].lParam = 0; psh.dwSize = sizeof(PROPSHEETHEADER); psh.dwFlags = PSH_PROPSHEETPAGE | PSH_MODELESS; psh.hwndParent =hwndOwner; psh.hInstance = m_hInst; psh.pszIcon = NULL; psh.pszCaption = (LPSTR) "Debugger"; psh.nStartPage = 0; psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE); psh.ppsp = (LPCPROPSHEETPAGE) &psp; return (PropertySheet(&psh)); } LRESULT CALLBACK R3000reg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: IOPGPR0Handle=GetDlgItem(hDlg,IDC_IOPGPR0); IOPGPR1Handle=GetDlgItem(hDlg,IDC_IOPGPR1); IOPGPR2Handle=GetDlgItem(hDlg,IDC_IOPGPR2); IOPGPR3Handle=GetDlgItem(hDlg,IDC_IOPGPR3); IOPGPR4Handle=GetDlgItem(hDlg,IDC_IOPGPR4); IOPGPR5Handle=GetDlgItem(hDlg,IDC_IOPGPR5); IOPGPR6Handle=GetDlgItem(hDlg,IDC_IOPGPR6); IOPGPR7Handle=GetDlgItem(hDlg,IDC_IOPGPR7); IOPGPR8Handle=GetDlgItem(hDlg,IDC_IOPGPR8); IOPGPR9Handle=GetDlgItem(hDlg,IDC_IOPGPR9); IOPGPR10Handle=GetDlgItem(hDlg,IDC_IOPGPR10); IOPGPR11Handle=GetDlgItem(hDlg,IDC_IOPGPR11); IOPGPR12Handle=GetDlgItem(hDlg,IDC_IOPGPR12); IOPGPR13Handle=GetDlgItem(hDlg,IDC_IOPGPR13); IOPGPR14Handle=GetDlgItem(hDlg,IDC_IOPGPR14); IOPGPR15Handle=GetDlgItem(hDlg,IDC_IOPGPR15); IOPGPR16Handle=GetDlgItem(hDlg,IDC_IOPGPR16); IOPGPR17Handle=GetDlgItem(hDlg,IDC_IOPGPR17); IOPGPR18Handle=GetDlgItem(hDlg,IDC_IOPGPR18); IOPGPR19Handle=GetDlgItem(hDlg,IDC_IOPGPR19); IOPGPR20Handle=GetDlgItem(hDlg,IDC_IOPGPR20); IOPGPR21Handle=GetDlgItem(hDlg,IDC_IOPGPR21); IOPGPR22Handle=GetDlgItem(hDlg,IDC_IOPGPR22); IOPGPR23Handle=GetDlgItem(hDlg,IDC_IOPGPR23); IOPGPR24Handle=GetDlgItem(hDlg,IDC_IOPGPR24); IOPGPR25Handle=GetDlgItem(hDlg,IDC_IOPGPR25); IOPGPR26Handle=GetDlgItem(hDlg,IDC_IOPGPR26); IOPGPR27Handle=GetDlgItem(hDlg,IDC_IOPGPR27); IOPGPR28Handle=GetDlgItem(hDlg,IDC_IOPGPR28); IOPGPR29Handle=GetDlgItem(hDlg,IDC_IOPGPR29); IOPGPR30Handle=GetDlgItem(hDlg,IDC_IOPGPR30); IOPGPR31Handle=GetDlgItem(hDlg,IDC_IOPGPR31); IOPGPRPCHandle=GetDlgItem(hDlg,IDC_IOPGPR_PC); IOPGPRHIHandle=GetDlgItem(hDlg,IDC_IOPGPR_HI); IOPGPRLOHandle=GetDlgItem(hDlg,IDC_IOPGPR_LO); UpdateRegs(); return (TRUE); break; case WM_COMMAND: switch(LOWORD(wParam)) { case (IDOK || IDCANCEL): EndDialog(hDlg,TRUE); return(TRUE); break; } break; } return(FALSE); } LRESULT CALLBACK R5900reg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: GPR0Handle=GetDlgItem(hDlg,IDC_GPR0); GPR1Handle=GetDlgItem(hDlg,IDC_GPR1); GPR2Handle=GetDlgItem(hDlg,IDC_GPR2); GPR3Handle=GetDlgItem(hDlg,IDC_GPR3); GPR4Handle=GetDlgItem(hDlg,IDC_GPR4); GPR5Handle=GetDlgItem(hDlg,IDC_GPR5); GPR6Handle=GetDlgItem(hDlg,IDC_GPR6); GPR7Handle=GetDlgItem(hDlg,IDC_GPR7); GPR8Handle=GetDlgItem(hDlg,IDC_GPR8); GPR9Handle=GetDlgItem(hDlg,IDC_GPR9); GPR10Handle=GetDlgItem(hDlg,IDC_GPR10); GPR11Handle=GetDlgItem(hDlg,IDC_GPR11); GPR12Handle=GetDlgItem(hDlg,IDC_GPR12); GPR13Handle=GetDlgItem(hDlg,IDC_GPR13); GPR14Handle=GetDlgItem(hDlg,IDC_GPR14); GPR15Handle=GetDlgItem(hDlg,IDC_GPR15); GPR16Handle=GetDlgItem(hDlg,IDC_GPR16); GPR17Handle=GetDlgItem(hDlg,IDC_GPR17); GPR18Handle=GetDlgItem(hDlg,IDC_GPR18); GPR19Handle=GetDlgItem(hDlg,IDC_GPR19); GPR20Handle=GetDlgItem(hDlg,IDC_GPR20); GPR21Handle=GetDlgItem(hDlg,IDC_GPR21); GPR22Handle=GetDlgItem(hDlg,IDC_GPR22); GPR23Handle=GetDlgItem(hDlg,IDC_GPR23); GPR24Handle=GetDlgItem(hDlg,IDC_GPR24); GPR25Handle=GetDlgItem(hDlg,IDC_GPR25); GPR26Handle=GetDlgItem(hDlg,IDC_GPR26); GPR27Handle=GetDlgItem(hDlg,IDC_GPR27); GPR28Handle=GetDlgItem(hDlg,IDC_GPR28); GPR29Handle=GetDlgItem(hDlg,IDC_GPR29); GPR30Handle=GetDlgItem(hDlg,IDC_GPR30); GPR31Handle=GetDlgItem(hDlg,IDC_GPR31); GPRPCHandle=GetDlgItem(hDlg,IDC_GPR_PC); GPRHIHandle=GetDlgItem(hDlg,IDC_GPR_HI); GPRLOHandle=GetDlgItem(hDlg,IDC_GPR_LO); UpdateRegs(); return (TRUE); break; case WM_COMMAND: switch(LOWORD(wParam)) { case (IDOK || IDCANCEL): EndDialog(hDlg,TRUE); return(TRUE); break; } break; } return(FALSE); } LRESULT CALLBACK COP0reg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: COP00Handle=GetDlgItem(hDlg,IDC_CP00); COP01Handle=GetDlgItem(hDlg,IDC_CP01); COP02Handle=GetDlgItem(hDlg,IDC_CP02); COP03Handle=GetDlgItem(hDlg,IDC_CP03); COP04Handle=GetDlgItem(hDlg,IDC_CP04); COP05Handle=GetDlgItem(hDlg,IDC_CP05); COP06Handle=GetDlgItem(hDlg,IDC_CP06); COP07Handle=GetDlgItem(hDlg,IDC_CP07); COP08Handle=GetDlgItem(hDlg,IDC_CP08); COP09Handle=GetDlgItem(hDlg,IDC_CP09); COP010Handle=GetDlgItem(hDlg,IDC_CP010); COP011Handle=GetDlgItem(hDlg,IDC_CP011); COP012Handle=GetDlgItem(hDlg,IDC_CP012); COP013Handle=GetDlgItem(hDlg,IDC_CP013); COP014Handle=GetDlgItem(hDlg,IDC_CP014); COP015Handle=GetDlgItem(hDlg,IDC_CP015); COP016Handle=GetDlgItem(hDlg,IDC_CP016); COP017Handle=GetDlgItem(hDlg,IDC_CP017); COP018Handle=GetDlgItem(hDlg,IDC_CP018); COP019Handle=GetDlgItem(hDlg,IDC_CP019); COP020Handle=GetDlgItem(hDlg,IDC_CP020); COP021Handle=GetDlgItem(hDlg,IDC_CP021); COP022Handle=GetDlgItem(hDlg,IDC_CP022); COP023Handle=GetDlgItem(hDlg,IDC_CP023); COP024Handle=GetDlgItem(hDlg,IDC_CP024); COP025Handle=GetDlgItem(hDlg,IDC_CP025); COP026Handle=GetDlgItem(hDlg,IDC_CP026); COP027Handle=GetDlgItem(hDlg,IDC_CP027); COP028Handle=GetDlgItem(hDlg,IDC_CP028); COP029Handle=GetDlgItem(hDlg,IDC_CP029); COP030Handle=GetDlgItem(hDlg,IDC_CP030); COP031Handle=GetDlgItem(hDlg,IDC_CP031); UpdateRegs(); return (TRUE); break; case WM_COMMAND: switch(LOWORD(wParam)) { case (IDOK || IDCANCEL): EndDialog(hDlg,TRUE); return(TRUE); break; } break; } return(FALSE); } LRESULT CALLBACK COP1reg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: COP10Handle=GetDlgItem(hDlg,IDC_FP0); COP11Handle=GetDlgItem(hDlg,IDC_FP1); COP12Handle=GetDlgItem(hDlg,IDC_FP2); COP13Handle=GetDlgItem(hDlg,IDC_FP3); COP14Handle=GetDlgItem(hDlg,IDC_FP4); COP15Handle=GetDlgItem(hDlg,IDC_FP5); COP16Handle=GetDlgItem(hDlg,IDC_FP6); COP17Handle=GetDlgItem(hDlg,IDC_FP7); COP18Handle=GetDlgItem(hDlg,IDC_FP8); COP19Handle=GetDlgItem(hDlg,IDC_FP9); COP110Handle=GetDlgItem(hDlg,IDC_FP10); COP111Handle=GetDlgItem(hDlg,IDC_FP11); COP112Handle=GetDlgItem(hDlg,IDC_FP12); COP113Handle=GetDlgItem(hDlg,IDC_FP13); COP114Handle=GetDlgItem(hDlg,IDC_FP14); COP115Handle=GetDlgItem(hDlg,IDC_FP15); COP116Handle=GetDlgItem(hDlg,IDC_FP16); COP117Handle=GetDlgItem(hDlg,IDC_FP17); COP118Handle=GetDlgItem(hDlg,IDC_FP18); COP119Handle=GetDlgItem(hDlg,IDC_FP19); COP120Handle=GetDlgItem(hDlg,IDC_FP20); COP121Handle=GetDlgItem(hDlg,IDC_FP21); COP122Handle=GetDlgItem(hDlg,IDC_FP22); COP123Handle=GetDlgItem(hDlg,IDC_FP23); COP124Handle=GetDlgItem(hDlg,IDC_FP24); COP125Handle=GetDlgItem(hDlg,IDC_FP25); COP126Handle=GetDlgItem(hDlg,IDC_FP26); COP127Handle=GetDlgItem(hDlg,IDC_FP27); COP128Handle=GetDlgItem(hDlg,IDC_FP28); COP129Handle=GetDlgItem(hDlg,IDC_FP29); COP130Handle=GetDlgItem(hDlg,IDC_FP30); COP131Handle=GetDlgItem(hDlg,IDC_FP31); COP1C0Handle=GetDlgItem(hDlg,IDC_FCR0); COP1C1Handle=GetDlgItem(hDlg,IDC_FCR31); COP1ACCHandle=GetDlgItem(hDlg,IDC_FPU_ACC); UpdateRegs(); return (TRUE); break; case WM_COMMAND: switch(LOWORD(wParam)) { case (IDOK || IDCANCEL): EndDialog(hDlg,TRUE); return(TRUE); break; } break; } return(FALSE); } LRESULT CALLBACK COP2Freg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: VU0F00Handle=GetDlgItem(hDlg,IDC_VU0_VF00); VU0F01Handle=GetDlgItem(hDlg,IDC_VU0_VF01); VU0F02Handle=GetDlgItem(hDlg,IDC_VU0_VF02); VU0F03Handle=GetDlgItem(hDlg,IDC_VU0_VF03); VU0F04Handle=GetDlgItem(hDlg,IDC_VU0_VF04); VU0F05Handle=GetDlgItem(hDlg,IDC_VU0_VF05); VU0F06Handle=GetDlgItem(hDlg,IDC_VU0_VF06); VU0F07Handle=GetDlgItem(hDlg,IDC_VU0_VF07); VU0F08Handle=GetDlgItem(hDlg,IDC_VU0_VF08); VU0F09Handle=GetDlgItem(hDlg,IDC_VU0_VF09); VU0F10Handle=GetDlgItem(hDlg,IDC_VU0_VF10); VU0F11Handle=GetDlgItem(hDlg,IDC_VU0_VF11); VU0F12Handle=GetDlgItem(hDlg,IDC_VU0_VF12); VU0F13Handle=GetDlgItem(hDlg,IDC_VU0_VF13); VU0F14Handle=GetDlgItem(hDlg,IDC_VU0_VF14); VU0F15Handle=GetDlgItem(hDlg,IDC_VU0_VF15); VU0F16Handle=GetDlgItem(hDlg,IDC_VU0_VF16); VU0F17Handle=GetDlgItem(hDlg,IDC_VU0_VF17); VU0F18Handle=GetDlgItem(hDlg,IDC_VU0_VF18); VU0F19Handle=GetDlgItem(hDlg,IDC_VU0_VF19); VU0F20Handle=GetDlgItem(hDlg,IDC_VU0_VF20); VU0F21Handle=GetDlgItem(hDlg,IDC_VU0_VF21); VU0F22Handle=GetDlgItem(hDlg,IDC_VU0_VF22); VU0F23Handle=GetDlgItem(hDlg,IDC_VU0_VF23); VU0F24Handle=GetDlgItem(hDlg,IDC_VU0_VF24); VU0F25Handle=GetDlgItem(hDlg,IDC_VU0_VF25); VU0F26Handle=GetDlgItem(hDlg,IDC_VU0_VF26); VU0F27Handle=GetDlgItem(hDlg,IDC_VU0_VF27); VU0F28Handle=GetDlgItem(hDlg,IDC_VU0_VF28); VU0F29Handle=GetDlgItem(hDlg,IDC_VU0_VF29); VU0F30Handle=GetDlgItem(hDlg,IDC_VU0_VF30); VU0F31Handle=GetDlgItem(hDlg,IDC_VU0_VF31); UpdateRegs(); return (TRUE); break; case WM_COMMAND: switch(LOWORD(wParam)) { case (IDOK || IDCANCEL): EndDialog(hDlg,TRUE); return(TRUE); break; } break; } return(FALSE); } LRESULT CALLBACK COP2Creg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: VU0C00Handle=GetDlgItem(hDlg,IDC_VU0_VI00); VU0C01Handle=GetDlgItem(hDlg,IDC_VU0_VI01); VU0C02Handle=GetDlgItem(hDlg,IDC_VU0_VI02); VU0C03Handle=GetDlgItem(hDlg,IDC_VU0_VI03); VU0C04Handle=GetDlgItem(hDlg,IDC_VU0_VI04); VU0C05Handle=GetDlgItem(hDlg,IDC_VU0_VI05); VU0C06Handle=GetDlgItem(hDlg,IDC_VU0_VI06); VU0C07Handle=GetDlgItem(hDlg,IDC_VU0_VI07); VU0C08Handle=GetDlgItem(hDlg,IDC_VU0_VI08); VU0C09Handle=GetDlgItem(hDlg,IDC_VU0_VI09); VU0C10Handle=GetDlgItem(hDlg,IDC_VU0_VI10); VU0C11Handle=GetDlgItem(hDlg,IDC_VU0_VI11); VU0C12Handle=GetDlgItem(hDlg,IDC_VU0_VI12); VU0C13Handle=GetDlgItem(hDlg,IDC_VU0_VI13); VU0C14Handle=GetDlgItem(hDlg,IDC_VU0_VI14); VU0C15Handle=GetDlgItem(hDlg,IDC_VU0_VI15); VU0C16Handle=GetDlgItem(hDlg,IDC_VU0_VI16); VU0C17Handle=GetDlgItem(hDlg,IDC_VU0_VI17); VU0C18Handle=GetDlgItem(hDlg,IDC_VU0_VI18); VU0C19Handle=GetDlgItem(hDlg,IDC_VU0_VI19); VU0C20Handle=GetDlgItem(hDlg,IDC_VU0_VI20); VU0C21Handle=GetDlgItem(hDlg,IDC_VU0_VI21); VU0C22Handle=GetDlgItem(hDlg,IDC_VU0_VI22); VU0C23Handle=GetDlgItem(hDlg,IDC_VU0_VI23); VU0C24Handle=GetDlgItem(hDlg,IDC_VU0_VI24); VU0C25Handle=GetDlgItem(hDlg,IDC_VU0_VI25); VU0C26Handle=GetDlgItem(hDlg,IDC_VU0_VI26); VU0C27Handle=GetDlgItem(hDlg,IDC_VU0_VI27); VU0C28Handle=GetDlgItem(hDlg,IDC_VU0_VI28); VU0C29Handle=GetDlgItem(hDlg,IDC_VU0_VI29); VU0C30Handle=GetDlgItem(hDlg,IDC_VU0_VI30); VU0C31Handle=GetDlgItem(hDlg,IDC_VU0_VI31); VU0ACCHandle=GetDlgItem(hDlg,IDC_VU0_ACC); UpdateRegs(); return (TRUE); break; case WM_COMMAND: switch(LOWORD(wParam)) { case (IDOK || IDCANCEL): EndDialog(hDlg,TRUE); return(TRUE); break; } break; } return(FALSE); } LRESULT CALLBACK VU1Freg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: VU1F00Handle=GetDlgItem(hDlg,IDC_VU1_VF00); VU1F01Handle=GetDlgItem(hDlg,IDC_VU1_VF01); VU1F02Handle=GetDlgItem(hDlg,IDC_VU1_VF02); VU1F03Handle=GetDlgItem(hDlg,IDC_VU1_VF03); VU1F04Handle=GetDlgItem(hDlg,IDC_VU1_VF04); VU1F05Handle=GetDlgItem(hDlg,IDC_VU1_VF05); VU1F06Handle=GetDlgItem(hDlg,IDC_VU1_VF06); VU1F07Handle=GetDlgItem(hDlg,IDC_VU1_VF07); VU1F08Handle=GetDlgItem(hDlg,IDC_VU1_VF08); VU1F09Handle=GetDlgItem(hDlg,IDC_VU1_VF09); VU1F10Handle=GetDlgItem(hDlg,IDC_VU1_VF10); VU1F11Handle=GetDlgItem(hDlg,IDC_VU1_VF11); VU1F12Handle=GetDlgItem(hDlg,IDC_VU1_VF12); VU1F13Handle=GetDlgItem(hDlg,IDC_VU1_VF13); VU1F14Handle=GetDlgItem(hDlg,IDC_VU1_VF14); VU1F15Handle=GetDlgItem(hDlg,IDC_VU1_VF15); VU1F16Handle=GetDlgItem(hDlg,IDC_VU1_VF16); VU1F17Handle=GetDlgItem(hDlg,IDC_VU1_VF17); VU1F18Handle=GetDlgItem(hDlg,IDC_VU1_VF18); VU1F19Handle=GetDlgItem(hDlg,IDC_VU1_VF19); VU1F20Handle=GetDlgItem(hDlg,IDC_VU1_VF20); VU1F21Handle=GetDlgItem(hDlg,IDC_VU1_VF21); VU1F22Handle=GetDlgItem(hDlg,IDC_VU1_VF22); VU1F23Handle=GetDlgItem(hDlg,IDC_VU1_VF23); VU1F24Handle=GetDlgItem(hDlg,IDC_VU1_VF24); VU1F25Handle=GetDlgItem(hDlg,IDC_VU1_VF25); VU1F26Handle=GetDlgItem(hDlg,IDC_VU1_VF26); VU1F27Handle=GetDlgItem(hDlg,IDC_VU1_VF27); VU1F28Handle=GetDlgItem(hDlg,IDC_VU1_VF28); VU1F29Handle=GetDlgItem(hDlg,IDC_VU1_VF29); VU1F30Handle=GetDlgItem(hDlg,IDC_VU1_VF30); VU1F31Handle=GetDlgItem(hDlg,IDC_VU1_VF31); UpdateRegs(); return (TRUE); break; case WM_COMMAND: switch(LOWORD(wParam)) { case (IDOK || IDCANCEL): EndDialog(hDlg,TRUE); return(TRUE); break; } break; } return(FALSE); } LRESULT CALLBACK VU1Creg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: VU1C00Handle=GetDlgItem(hDlg,IDC_VU1_VI00); VU1C01Handle=GetDlgItem(hDlg,IDC_VU1_VI01); VU1C02Handle=GetDlgItem(hDlg,IDC_VU1_VI02); VU1C03Handle=GetDlgItem(hDlg,IDC_VU1_VI03); VU1C04Handle=GetDlgItem(hDlg,IDC_VU1_VI04); VU1C05Handle=GetDlgItem(hDlg,IDC_VU1_VI05); VU1C06Handle=GetDlgItem(hDlg,IDC_VU1_VI06); VU1C07Handle=GetDlgItem(hDlg,IDC_VU1_VI07); VU1C08Handle=GetDlgItem(hDlg,IDC_VU1_VI08); VU1C09Handle=GetDlgItem(hDlg,IDC_VU1_VI09); VU1C10Handle=GetDlgItem(hDlg,IDC_VU1_VI10); VU1C11Handle=GetDlgItem(hDlg,IDC_VU1_VI11); VU1C12Handle=GetDlgItem(hDlg,IDC_VU1_VI12); VU1C13Handle=GetDlgItem(hDlg,IDC_VU1_VI13); VU1C14Handle=GetDlgItem(hDlg,IDC_VU1_VI14); VU1C15Handle=GetDlgItem(hDlg,IDC_VU1_VI15); VU1C16Handle=GetDlgItem(hDlg,IDC_VU1_VI16); VU1C17Handle=GetDlgItem(hDlg,IDC_VU1_VI17); VU1C18Handle=GetDlgItem(hDlg,IDC_VU1_VI18); VU1C19Handle=GetDlgItem(hDlg,IDC_VU1_VI19); VU1C20Handle=GetDlgItem(hDlg,IDC_VU1_VI20); VU1C21Handle=GetDlgItem(hDlg,IDC_VU1_VI21); VU1C22Handle=GetDlgItem(hDlg,IDC_VU1_VI22); VU1C23Handle=GetDlgItem(hDlg,IDC_VU1_VI23); VU1C24Handle=GetDlgItem(hDlg,IDC_VU1_VI24); VU1C25Handle=GetDlgItem(hDlg,IDC_VU1_VI25); VU1C26Handle=GetDlgItem(hDlg,IDC_VU1_VI26); VU1C27Handle=GetDlgItem(hDlg,IDC_VU1_VI27); VU1C28Handle=GetDlgItem(hDlg,IDC_VU1_VI28); VU1C29Handle=GetDlgItem(hDlg,IDC_VU1_VI29); VU1C30Handle=GetDlgItem(hDlg,IDC_VU1_VI30); VU1C31Handle=GetDlgItem(hDlg,IDC_VU1_VI31); VU1ACCHandle=GetDlgItem(hDlg,IDC_VU1_ACC); UpdateRegs(); return (TRUE); break; case WM_COMMAND: switch(LOWORD(wParam)) { case (IDOK || IDCANCEL): EndDialog(hDlg,TRUE); return(TRUE); break; } break; } return(FALSE); } void UpdateRegs(void) { wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[0]); SendMessage(IOPGPR0Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[1]); SendMessage(IOPGPR1Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[2]); SendMessage(IOPGPR2Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[3]); SendMessage(IOPGPR3Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[4]); SendMessage(IOPGPR4Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[5]); SendMessage(IOPGPR5Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[6]); SendMessage(IOPGPR6Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[7]); SendMessage(IOPGPR7Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[8]); SendMessage(IOPGPR8Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[9]); SendMessage(IOPGPR9Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[10]); SendMessage(IOPGPR10Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[11]); SendMessage(IOPGPR11Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[12]); SendMessage(IOPGPR12Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[13]); SendMessage(IOPGPR13Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[14]); SendMessage(IOPGPR14Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[15]); SendMessage(IOPGPR15Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[16]); SendMessage(IOPGPR16Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[17]); SendMessage(IOPGPR17Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[18]); SendMessage(IOPGPR18Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[19]); SendMessage(IOPGPR19Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[20]); SendMessage(IOPGPR20Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[21]); SendMessage(IOPGPR21Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[22]); SendMessage(IOPGPR22Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[23]); SendMessage(IOPGPR23Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[24]); SendMessage(IOPGPR24Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[25]); SendMessage(IOPGPR25Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[26]); SendMessage(IOPGPR26Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[27]); SendMessage(IOPGPR27Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[28]); SendMessage(IOPGPR28Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[29]); SendMessage(IOPGPR29Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[30]); SendMessage(IOPGPR30Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[31]); SendMessage(IOPGPR31Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",psxRegs.pc ); SendMessage(IOPGPRPCHandle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[32]); SendMessage(IOPGPRHIHandle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X\0",psxRegs.GPR.r[33]); SendMessage(IOPGPRLOHandle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[0].UL[3],cpuRegs.GPR.r[0].UL[2],cpuRegs.GPR.r[0].UL[1],cpuRegs.GPR.r[0].UL[0] ); SendMessage(GPR0Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[1].UL[3], cpuRegs.GPR.r[1].UL[2],cpuRegs.GPR.r[1].UL[1],cpuRegs.GPR.r[1].UL[0] ); SendMessage(GPR1Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[2].UL[3],cpuRegs.GPR.r[2].UL[2], cpuRegs.GPR.r[2].UL[1],cpuRegs.GPR.r[2].UL[0]); SendMessage(GPR2Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[3].UL[3],cpuRegs.GPR.r[3].UL[2], cpuRegs.GPR.r[3].UL[1],cpuRegs.GPR.r[3].UL[0] ); SendMessage(GPR3Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[4].UL[3],cpuRegs.GPR.r[4].UL[2], cpuRegs.GPR.r[4].UL[1],cpuRegs.GPR.r[4].UL[0] ); SendMessage(GPR4Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[5].UL[3],cpuRegs.GPR.r[5].UL[2],cpuRegs.GPR.r[5].UL[1], cpuRegs.GPR.r[5].UL[0] ); SendMessage(GPR5Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[6].UL[3],cpuRegs.GPR.r[6].UL[2], cpuRegs.GPR.r[6].UL[1], cpuRegs.GPR.r[6].UL[0]); SendMessage(GPR6Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[7].UL[3], cpuRegs.GPR.r[7].UL[2],cpuRegs.GPR.r[7].UL[1],cpuRegs.GPR.r[7].UL[0] ); SendMessage(GPR7Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[8].UL[3],cpuRegs.GPR.r[8].UL[2],cpuRegs.GPR.r[8].UL[1],cpuRegs.GPR.r[8].UL[0] ); SendMessage(GPR8Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[9].UL[3],cpuRegs.GPR.r[9].UL[2],cpuRegs.GPR.r[9].UL[1], cpuRegs.GPR.r[9].UL[0] ); SendMessage(GPR9Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[10].UL[3],cpuRegs.GPR.r[10].UL[2],cpuRegs.GPR.r[10].UL[1],cpuRegs.GPR.r[10].UL[0] ); SendMessage(GPR10Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[11].UL[3],cpuRegs.GPR.r[11].UL[2],cpuRegs.GPR.r[11].UL[1],cpuRegs.GPR.r[11].UL[0] ); SendMessage(GPR11Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[12].UL[3],cpuRegs.GPR.r[12].UL[2],cpuRegs.GPR.r[12].UL[1],cpuRegs.GPR.r[12].UL[0] ); SendMessage(GPR12Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[13].UL[3],cpuRegs.GPR.r[13].UL[2],cpuRegs.GPR.r[13].UL[1],cpuRegs.GPR.r[13].UL[0] ); SendMessage(GPR13Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[14].UL[3],cpuRegs.GPR.r[14].UL[2],cpuRegs.GPR.r[14].UL[1],cpuRegs.GPR.r[14].UL[0] ); SendMessage(GPR14Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[15].UL[3],cpuRegs.GPR.r[15].UL[2],cpuRegs.GPR.r[15].UL[1],cpuRegs.GPR.r[15].UL[0] ); SendMessage(GPR15Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[16].UL[3],cpuRegs.GPR.r[16].UL[2],cpuRegs.GPR.r[16].UL[1],cpuRegs.GPR.r[16].UL[0] ); SendMessage(GPR16Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[17].UL[3],cpuRegs.GPR.r[17].UL[2],cpuRegs.GPR.r[17].UL[1],cpuRegs.GPR.r[17].UL[0] ); SendMessage(GPR17Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[18].UL[3],cpuRegs.GPR.r[18].UL[2],cpuRegs.GPR.r[18].UL[1],cpuRegs.GPR.r[18].UL[0] ); SendMessage(GPR18Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[19].UL[3],cpuRegs.GPR.r[19].UL[2],cpuRegs.GPR.r[19].UL[1],cpuRegs.GPR.r[19].UL[0] ); SendMessage(GPR19Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[20].UL[3],cpuRegs.GPR.r[20].UL[2],cpuRegs.GPR.r[20].UL[1],cpuRegs.GPR.r[20].UL[0] ); SendMessage(GPR20Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[21].UL[3],cpuRegs.GPR.r[21].UL[2],cpuRegs.GPR.r[21].UL[1],cpuRegs.GPR.r[21].UL[0] ); SendMessage(GPR21Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[22].UL[3],cpuRegs.GPR.r[22].UL[2],cpuRegs.GPR.r[22].UL[1],cpuRegs.GPR.r[22].UL[0] ); SendMessage(GPR22Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[23].UL[3],cpuRegs.GPR.r[23].UL[2],cpuRegs.GPR.r[23].UL[1],cpuRegs.GPR.r[23].UL[0] ); SendMessage(GPR23Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[24].UL[3],cpuRegs.GPR.r[24].UL[2],cpuRegs.GPR.r[24].UL[1],cpuRegs.GPR.r[24].UL[0] ); SendMessage(GPR24Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[25].UL[3],cpuRegs.GPR.r[25].UL[2],cpuRegs.GPR.r[25].UL[1],cpuRegs.GPR.r[25].UL[0] ); SendMessage(GPR25Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[26].UL[3],cpuRegs.GPR.r[26].UL[2],cpuRegs.GPR.r[26].UL[1],cpuRegs.GPR.r[26].UL[0] ); SendMessage(GPR26Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[27].UL[3],cpuRegs.GPR.r[27].UL[2],cpuRegs.GPR.r[27].UL[1],cpuRegs.GPR.r[27].UL[0] ); SendMessage(GPR27Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[28].UL[3],cpuRegs.GPR.r[28].UL[2],cpuRegs.GPR.r[28].UL[1],cpuRegs.GPR.r[28].UL[0] ); SendMessage(GPR28Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[29].UL[3],cpuRegs.GPR.r[29].UL[2],cpuRegs.GPR.r[29].UL[1],cpuRegs.GPR.r[29].UL[0] ); SendMessage(GPR29Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[30].UL[3],cpuRegs.GPR.r[30].UL[2],cpuRegs.GPR.r[30].UL[1],cpuRegs.GPR.r[30].UL[0] ); SendMessage(GPR30Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.GPR.r[31].UL[3],cpuRegs.GPR.r[31].UL[2],cpuRegs.GPR.r[31].UL[1],cpuRegs.GPR.r[31].UL[0] ); SendMessage(GPR31Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.pc ); SendMessage(GPRPCHandle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0",cpuRegs.HI.UL[3],cpuRegs.HI.UL[2] ,cpuRegs.HI.UL[1] ,cpuRegs.HI.UL[0] ); SendMessage(GPRHIHandle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"0x%08X_%08X_%08X_%08X\0\0",cpuRegs.LO.UL[3],cpuRegs.LO.UL[2],cpuRegs.LO.UL[1],cpuRegs.LO.UL[0] ); SendMessage(GPRLOHandle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[0] ); SendMessage(COP00Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[1]); SendMessage(COP01Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[2]); SendMessage(COP02Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[3]); SendMessage(COP03Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[4]); SendMessage(COP04Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[5]); SendMessage(COP05Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[6]); SendMessage(COP06Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[7]); SendMessage(COP07Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[8]); SendMessage(COP08Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[9]); SendMessage(COP09Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[10]); SendMessage(COP010Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[11]); SendMessage(COP011Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[12]); SendMessage(COP012Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[13]); SendMessage(COP013Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[14]); SendMessage(COP014Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[15]); SendMessage(COP015Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[16]); SendMessage(COP016Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[17]); SendMessage(COP017Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[18]); SendMessage(COP018Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[19]); SendMessage(COP019Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[20]); SendMessage(COP020Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[21]); SendMessage(COP021Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[22]); SendMessage(COP022Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[23]); SendMessage(COP023Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[24]); SendMessage(COP024Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[25]); SendMessage(COP025Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[26]); SendMessage(COP026Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[27]); SendMessage(COP027Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[28]); SendMessage(COP028Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[29]); SendMessage(COP029Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[30]); SendMessage(COP030Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",cpuRegs.CP0.r[31]); SendMessage(COP031Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[0].f ); SendMessage(COP10Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[1].f); SendMessage(COP11Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[2].f); SendMessage(COP12Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[3].f); SendMessage(COP13Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[4].f); SendMessage(COP14Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[5].f); SendMessage(COP15Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[6].f); SendMessage(COP16Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[7].f); SendMessage(COP17Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[8].f); SendMessage(COP18Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[9].f); SendMessage(COP19Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[10].f); SendMessage(COP110Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[11].f); SendMessage(COP111Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[12].f); SendMessage(COP112Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[13].f); SendMessage(COP113Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[14].f); SendMessage(COP114Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[15].f); SendMessage(COP115Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[16].f); SendMessage(COP116Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[17].f); SendMessage(COP117Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[18].f); SendMessage(COP118Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[19].f); SendMessage(COP119Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[20].f); SendMessage(COP120Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[21].f); SendMessage(COP121Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[22].f); SendMessage(COP122Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[23].f); SendMessage(COP123Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[24].f); SendMessage(COP124Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[25].f); SendMessage(COP125Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[26].f); SendMessage(COP126Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[27].f); SendMessage(COP127Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[28].f); SendMessage(COP128Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[29].f); SendMessage(COP129Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[30].f); SendMessage(COP130Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.fpr[31].f); SendMessage(COP131Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",fpuRegs.fprc[0]); SendMessage(COP1C0Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",fpuRegs.fprc[31]); SendMessage(COP1C1Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f",fpuRegs.ACC.f); SendMessage(COP1ACCHandle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[0].f.w,VU0.VF[0].f.z,VU0.VF[0].f.y,VU0.VF[0].f.x ); SendMessage(VU0F00Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[1].f.w,VU0.VF[1].f.z,VU0.VF[1].f.y,VU0.VF[1].f.x ); SendMessage(VU0F01Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[2].f.w,VU0.VF[2].f.z,VU0.VF[2].f.y,VU0.VF[2].f.x ); SendMessage(VU0F02Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[3].f.w,VU0.VF[3].f.z,VU0.VF[3].f.y,VU0.VF[3].f.x ); SendMessage(VU0F03Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[4].f.w,VU0.VF[4].f.z,VU0.VF[4].f.y,VU0.VF[4].f.x ); SendMessage(VU0F04Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[5].f.w,VU0.VF[5].f.z,VU0.VF[5].f.y,VU0.VF[5].f.x); SendMessage(VU0F05Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[6].f.w,VU0.VF[6].f.z,VU0.VF[6].f.y,VU0.VF[6].f.x ); SendMessage(VU0F06Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[7].f.w,VU0.VF[7].f.z,VU0.VF[7].f.y,VU0.VF[7].f.x ); SendMessage(VU0F07Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[8].f.w,VU0.VF[8].f.z,VU0.VF[8].f.y,VU0.VF[8].f.x ); SendMessage(VU0F08Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[9].f.w,VU0.VF[9].f.z,VU0.VF[9].f.y,VU0.VF[9].f.x ); SendMessage(VU0F09Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[10].f.w,VU0.VF[10].f.z,VU0.VF[10].f.y,VU0.VF[10].f.x ); SendMessage(VU0F10Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[11].f.w,VU0.VF[11].f.z,VU0.VF[11].f.y,VU0.VF[11].f.x ); SendMessage(VU0F11Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[12].f.w,VU0.VF[12].f.z,VU0.VF[12].f.y,VU0.VF[12].f.x ); SendMessage(VU0F12Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[13].f.w,VU0.VF[13].f.z,VU0.VF[13].f.y,VU0.VF[13].f.x ); SendMessage(VU0F13Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[14].f.w,VU0.VF[14].f.z,VU0.VF[14].f.y,VU0.VF[14].f.x ); SendMessage(VU0F14Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[15].f.w,VU0.VF[15].f.z,VU0.VF[15].f.y,VU0.VF[15].f.x ); SendMessage(VU0F15Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[16].f.w,VU0.VF[16].f.z,VU0.VF[16].f.y,VU0.VF[16].f.x ); SendMessage(VU0F16Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[17].f.w,VU0.VF[17].f.z,VU0.VF[17].f.y,VU0.VF[17].f.x ); SendMessage(VU0F17Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[18].f.w,VU0.VF[18].f.z,VU0.VF[18].f.y,VU0.VF[18].f.x ); SendMessage(VU0F18Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[19].f.w,VU0.VF[19].f.z,VU0.VF[19].f.y,VU0.VF[19].f.x ); SendMessage(VU0F19Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[20].f.w,VU0.VF[20].f.z,VU0.VF[20].f.y,VU0.VF[20].f.x ); SendMessage(VU0F20Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[21].f.w,VU0.VF[21].f.z,VU0.VF[21].f.y,VU0.VF[21].f.x ); SendMessage(VU0F21Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[22].f.w,VU0.VF[22].f.z,VU0.VF[22].f.y,VU0.VF[22].f.x ); SendMessage(VU0F22Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[23].f.w,VU0.VF[23].f.z,VU0.VF[23].f.y,VU0.VF[23].f.x ); SendMessage(VU0F23Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[24].f.w,VU0.VF[24].f.z,VU0.VF[24].f.y,VU0.VF[24].f.x ); SendMessage(VU0F24Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[25].f.w,VU0.VF[25].f.z,VU0.VF[25].f.y,VU0.VF[25].f.x ); SendMessage(VU0F25Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[26].f.w,VU0.VF[26].f.z,VU0.VF[26].f.y,VU0.VF[26].f.x ); SendMessage(VU0F26Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[27].f.w,VU0.VF[27].f.z,VU0.VF[27].f.y,VU0.VF[27].f.x ); SendMessage(VU0F27Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[28].f.w,VU0.VF[28].f.z,VU0.VF[28].f.y,VU0.VF[28].f.x ); SendMessage(VU0F28Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[29].f.w,VU0.VF[29].f.z,VU0.VF[29].f.y,VU0.VF[29].f.x ); SendMessage(VU0F29Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[30].f.w,VU0.VF[30].f.z,VU0.VF[30].f.y,VU0.VF[30].f.x ); SendMessage(VU0F30Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.VF[31].f.w,VU0.VF[31].f.z,VU0.VF[31].f.y,VU0.VF[31].f.x ); SendMessage(VU0F31Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[0] ); SendMessage(VU0C00Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[1]); SendMessage(VU0C01Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[2]); SendMessage(VU0C02Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[3]); SendMessage(VU0C03Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[4]); SendMessage(VU0C04Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[5]); SendMessage(VU0C05Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[6]); SendMessage(VU0C06Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[7]); SendMessage(VU0C07Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[8]); SendMessage(VU0C08Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[9]); SendMessage(VU0C09Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[10]); SendMessage(VU0C10Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[11]); SendMessage(VU0C11Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[12]); SendMessage(VU0C12Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[13]); SendMessage(VU0C13Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[14]); SendMessage(VU0C14Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[15]); SendMessage(VU0C15Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[16]); SendMessage(VU0C16Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[17]); SendMessage(VU0C17Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[18]); SendMessage(VU0C18Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[19]); SendMessage(VU0C19Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[20]); SendMessage(VU0C20Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[21]); SendMessage(VU0C21Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[22]); SendMessage(VU0C22Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[23]); SendMessage(VU0C23Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[24]); SendMessage(VU0C24Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[25]); SendMessage(VU0C25Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[26]); SendMessage(VU0C26Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[27]); SendMessage(VU0C27Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[28]); SendMessage(VU0C28Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[29]); SendMessage(VU0C29Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[30]); SendMessage(VU0C30Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU0.VI[31]); SendMessage(VU0C31Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU0.ACC.f.w,VU0.ACC.f.z,VU0.ACC.f.y,VU0.ACC.f.x ); SendMessage(VU0ACCHandle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[0].f.w,VU1.VF[0].f.z,VU1.VF[0].f.y,VU1.VF[0].f.x ); SendMessage(VU1F00Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[1].f.w,VU1.VF[1].f.z,VU1.VF[1].f.y,VU1.VF[1].f.x ); SendMessage(VU1F01Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[2].f.w,VU1.VF[2].f.z,VU1.VF[2].f.y,VU1.VF[2].f.x ); SendMessage(VU1F02Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[3].f.w,VU1.VF[3].f.z,VU1.VF[3].f.y,VU1.VF[3].f.x ); SendMessage(VU1F03Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[4].f.w,VU1.VF[4].f.z,VU1.VF[4].f.y,VU1.VF[4].f.x ); SendMessage(VU1F04Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[5].f.w,VU1.VF[5].f.z,VU1.VF[5].f.y,VU1.VF[5].f.x); SendMessage(VU1F05Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[6].f.w,VU1.VF[6].f.z,VU1.VF[6].f.y,VU1.VF[6].f.x ); SendMessage(VU1F06Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[7].f.w,VU1.VF[7].f.z,VU1.VF[7].f.y,VU1.VF[7].f.x ); SendMessage(VU1F07Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[8].f.w,VU1.VF[8].f.z,VU1.VF[8].f.y,VU1.VF[8].f.x ); SendMessage(VU1F08Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[9].f.w,VU1.VF[9].f.z,VU1.VF[9].f.y,VU1.VF[9].f.x ); SendMessage(VU1F09Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[10].f.w,VU1.VF[10].f.z,VU1.VF[10].f.y,VU1.VF[10].f.x ); SendMessage(VU1F10Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[11].f.w,VU1.VF[11].f.z,VU1.VF[11].f.y,VU1.VF[11].f.x ); SendMessage(VU1F11Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[12].f.w,VU1.VF[12].f.z,VU1.VF[12].f.y,VU1.VF[12].f.x ); SendMessage(VU1F12Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[13].f.w,VU1.VF[13].f.z,VU1.VF[13].f.y,VU1.VF[13].f.x ); SendMessage(VU1F13Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[14].f.w,VU1.VF[14].f.z,VU1.VF[14].f.y,VU1.VF[14].f.x ); SendMessage(VU1F14Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[15].f.w,VU1.VF[15].f.z,VU1.VF[15].f.y,VU1.VF[15].f.x ); SendMessage(VU1F15Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[16].f.w,VU1.VF[16].f.z,VU1.VF[16].f.y,VU1.VF[16].f.x ); SendMessage(VU1F16Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[17].f.w,VU1.VF[17].f.z,VU1.VF[17].f.y,VU1.VF[17].f.x ); SendMessage(VU1F17Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[18].f.w,VU1.VF[18].f.z,VU1.VF[18].f.y,VU1.VF[18].f.x ); SendMessage(VU1F18Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[19].f.w,VU1.VF[19].f.z,VU1.VF[19].f.y,VU1.VF[19].f.x ); SendMessage(VU1F19Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[20].f.w,VU1.VF[20].f.z,VU1.VF[20].f.y,VU1.VF[20].f.x ); SendMessage(VU1F20Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[21].f.w,VU1.VF[21].f.z,VU1.VF[21].f.y,VU1.VF[21].f.x ); SendMessage(VU1F21Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[22].f.w,VU1.VF[22].f.z,VU1.VF[22].f.y,VU1.VF[22].f.x ); SendMessage(VU1F22Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[23].f.w,VU1.VF[23].f.z,VU1.VF[23].f.y,VU1.VF[23].f.x ); SendMessage(VU1F23Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[24].f.w,VU1.VF[24].f.z,VU1.VF[24].f.y,VU1.VF[24].f.x ); SendMessage(VU1F24Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[25].f.w,VU1.VF[25].f.z,VU1.VF[25].f.y,VU1.VF[25].f.x ); SendMessage(VU1F25Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[26].f.w,VU1.VF[26].f.z,VU1.VF[26].f.y,VU1.VF[26].f.x ); SendMessage(VU1F26Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[27].f.w,VU1.VF[27].f.z,VU1.VF[27].f.y,VU1.VF[27].f.x ); SendMessage(VU1F27Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[28].f.w,VU1.VF[28].f.z,VU1.VF[28].f.y,VU1.VF[28].f.x ); SendMessage(VU1F28Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[29].f.w,VU1.VF[29].f.z,VU1.VF[29].f.y,VU1.VF[29].f.x ); SendMessage(VU1F29Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[30].f.w,VU1.VF[30].f.z,VU1.VF[30].f.y,VU1.VF[30].f.x ); SendMessage(VU1F30Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.VF[31].f.w,VU1.VF[31].f.z,VU1.VF[31].f.y,VU1.VF[31].f.x ); SendMessage(VU1F31Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[0] ); SendMessage(VU1C00Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[1]); SendMessage(VU1C01Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[2]); SendMessage(VU1C02Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[3]); SendMessage(VU1C03Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[4]); SendMessage(VU1C04Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[5]); SendMessage(VU1C05Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[6]); SendMessage(VU1C06Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[7]); SendMessage(VU1C07Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[8]); SendMessage(VU1C08Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[9]); SendMessage(VU1C09Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[10]); SendMessage(VU1C10Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[11]); SendMessage(VU1C11Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[12]); SendMessage(VU1C12Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[13]); SendMessage(VU1C13Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[14]); SendMessage(VU1C14Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[15]); SendMessage(VU1C15Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[16]); SendMessage(VU1C16Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[17]); SendMessage(VU1C17Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[18]); SendMessage(VU1C18Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[19]); SendMessage(VU1C19Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[20]); SendMessage(VU1C20Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[21]); SendMessage(VU1C21Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[22]); SendMessage(VU1C22Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[23]); SendMessage(VU1C23Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[24]); SendMessage(VU1C24Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[25]); SendMessage(VU1C25Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[26]); SendMessage(VU1C26Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[27]); SendMessage(VU1C27Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[28]); SendMessage(VU1C28Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[29]); SendMessage(VU1C29Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[30]); SendMessage(VU1C30Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); wsprintf(text1,"%x",VU1.VI[31]); SendMessage(VU1C31Handle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); sprintf(text1,"%f_%f_%f_%f\0",VU1.ACC.f.w,VU1.ACC.f.z,VU1.ACC.f.y,VU1.ACC.f.x ); SendMessage(VU1ACCHandle,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text1); } void EEDumpRegs(FILE * fp) { char text2[256]; int i; for(i = 0; i < 32; i++) { sprintf(text1,"%x_%x_%x_%x",cpuRegs.GPR.r[i].UL[3],cpuRegs.GPR.r[i].UL[2],cpuRegs.GPR.r[i].UL[1],cpuRegs.GPR.r[i].UL[0]); sprintf(text2,"GPR Register %d: ",i+1); fprintf(fp,text2); fprintf(fp,text1); fprintf(fp,"\n"); } sprintf(text1,"0x%x",cpuRegs.pc); fprintf(fp,"PC Register : "); fprintf(fp,text1); fprintf(fp,"\n"); sprintf(text1,"%x_%x_%x_%x",cpuRegs.HI.UL[3],cpuRegs.HI.UL[2],cpuRegs.HI.UL[1],cpuRegs.HI.UL[0]); fprintf(fp,"GPR Register HI: "); fprintf(fp,text1); fprintf(fp,"\n"); sprintf(text1,"%x_%x_%x_%x",cpuRegs.LO.UL[3],cpuRegs.LO.UL[2],cpuRegs.LO.UL[1],cpuRegs.LO.UL[0]); fprintf(fp,"GPR Register LO: "); fprintf(fp,text1); fprintf(fp,"\n"); for(i = 0; i < 32; i++) { sprintf(text1,"0x%x",cpuRegs.CP0.r[i]); sprintf(text2,"COP0 Register %d: ",i+1); fprintf(fp,text2); fprintf(fp,text1); fprintf(fp,"\n"); } } void IOPDumpRegs(FILE * fp) { char text2[256]; int i; for(i = 0; i < 32; i++) { sprintf(text1,"%x",psxRegs.GPR.r[i]); sprintf(text2,"GPR Register %d: ",i+1); fprintf(fp,text2); fprintf(fp,text1); fprintf(fp,"\n"); } sprintf(text1,"0x%x",psxRegs.pc); fprintf(fp,"PC Register : "); fprintf(fp,text1); fprintf(fp,"\n"); sprintf(text1,"%x",psxRegs.GPR.r[32]); fprintf(fp,"GPR Register HI: "); fprintf(fp,text1); fprintf(fp,"\n"); sprintf(text1,"%x",psxRegs.GPR.r[33]); fprintf(fp,"GPR Register LO: "); fprintf(fp,text1); fprintf(fp,"\n"); }
[ "saqibakhtar@23c756db-88ba-2448-99d7-e6e4c676ec84" ]
[ [ [ 1, 1483 ] ] ]
4c6d61b11fb493d20b99c8281eda87625e221fce
de98f880e307627d5ce93dcad1397bd4813751dd
/3libs/ut/include/OXTaskPanel.h
cbc3899fab13161d0c75bc3efa44f85be7d2f07e
[]
no_license
weimingtom/sls
7d44391bc0c6ae66f83ddcb6381db9ae97ee0dd8
d0d1de9c05ecf8bb6e4eda8a260c7a2f711615dd
refs/heads/master
2021-01-10T22:20:55.638757
2011-03-19T06:23:49
2011-03-19T06:23:49
44,464,621
2
0
null
null
null
null
UTF-8
C++
false
false
5,404
h
#pragma once #pragma comment(lib, "uxtheme") #include "oxdllext.h" #include <shlwapi.h> #pragma warning (push,3) #include <vector> #pragma warning (pop) using namespace std; // The following declarations are for the XP theme API (for pre-XP OS support) typedef HANDLE HTHEME; #define WM_THEMECHANGED 0x031A #define TMT_TEXTCOLOR 3803 #define TMT_FONT 210 bool G_LoadThemeLibrary(); typedef HANDLE(__stdcall *OPENTHEMEDATA)(HWND hwnd, LPCTSTR pszClassList); HTHEME G_OpenThemeData(HWND hwnd, LPCWSTR pszClassList); typedef HRESULT(__stdcall *CLOSETHEMEDATA)(HANDLE hTheme); HRESULT G_CloseThemeData(HTHEME hTheme); typedef HRESULT(__stdcall *DRAWTHEMEBACKGROUND)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect); HRESULT G_DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const RECT *pClipRect); typedef HRESULT (__stdcall *DRAWTHEMETEXT)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect); HRESULT G_DrawThemeText(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCTSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect); typedef HRESULT (__stdcall *DRAWTHEMEEDGE)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pDestRect, UINT uEdge, UINT uFlags, RECT *pContentRect); HRESULT G_DrawThemeEdge(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pDestRect, UINT uEdge, UINT uFlags, OPTIONAL OUT RECT *pContentRect); typedef HRESULT (__stdcall *GETTHEMECOLOR)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT COLORREF *pColor); HRESULT G_GetThemeColor(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT COLORREF *pColor); typedef HRESULT (__stdcall *GETTHEMEFONT)(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, int iStateId, int iPropId, OUT LOGFONT *pFont); HRESULT G_GetThemeFont(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, int iStateId, int iPropId, OUT LOGFONT *pFont); #define ANIMATIONTIMERID 3001 #define REVANIMATIONTIMERID 3002 #define ANIMATIONINTERVAL 60 #define NUMANIMSTEPS 8 enum GroupType { GTList }; class Item { friend class COXTaskPanel; friend struct TaskGroup; private: CRect m_ItemRect; public: Item():m_bIsMouseHovered(false) { } CString m_strText; UINT m_nIconID; CString m_strCmd; bool m_bIsMouseHovered; }; struct TaskGroup { TaskGroup(CString group = _T("")):m_strGroupName(group), m_bIsMouseHovered(false), m_GroupType(GTList), m_bIsCollapsed(true),m_bAnimationEnabled(false) { } CString m_strGroupName; operator CString() { return m_strGroupName; } CRect m_HeaderRect; bool m_bIsMouseHovered; GroupType m_GroupType; bool m_bIsCollapsed; bool m_bAnimationEnabled; void AddItem(const Item& item) { m_vecItems.push_back(item); } Item* FindItemWithPt(const CPoint& pt) { for(vector<Item>::iterator it = m_vecItems.begin(); it != m_vecItems.end(); it++) { if(it->m_ItemRect.PtInRect(pt)) { return &(*it); } } return NULL; } vector<Item> m_vecItems; }; // COXTaskPanel #ifndef OCR_HAND #define OCR_HAND 32649 #endif enum PanelDimensions { PDPanelFixedWidth = 225, PDLeftMargin = 10, PDTopMargin = 10, PDHeaderWidth = 190, PDHeaderHeight = 25, PDHeaderTextDisplacement = 9, PDHeaderIconDisplacement = 170, PDGroupSeparatorWidth = 40, PDGroupItemHeight = 20, PDGroupItemLeftMargin = 35, PDGroupIconLeftMargin = 9, PDGroupIconVerticalDisplacement = 1 }; class OX_CLASS_DECL COXTaskPanel : public CWnd { DECLARE_DYNAMIC(COXTaskPanel) public: COXTaskPanel(); virtual ~COXTaskPanel(); protected: HTHEME m_hTheme; vector<TaskGroup> m_vecGroups; bool m_bLastHover; Item* m_ActiveItem; bool m_bMouseOnControl; bool m_bIgnoreButtonUp; int m_nAnimSteps; CWnd* pOldFocus; protected: DECLARE_MESSAGE_MAP() public: afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnClose(); afx_msg void OnPaint(); afx_msg LRESULT OnMouseLeave(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnThemeChanged(WPARAM wParam, LPARAM lParam); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg BOOL OnEraseBkgnd(CDC* pDC); virtual BOOL Create(RECT rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); TaskGroup* AddGroup(LPCTSTR szGroupName); static bool IsThemed(); private: void DrawGroups(HDC hDC); void DrawGroupHeader(HDC hDC, const CRect& recGroupHeader, vector<TaskGroup>::iterator it); void DrawGroupItem(HDC hDC, const CRect& recGroupItem, vector<Item>::iterator it); void DrawDownArrow(HDC hDC, const CRect& recGroupIcon); void DrawUpArrow(HDC hDC, const CRect& recGroupIcon); bool RenderAlphaBlend(HDC hDC, HDC tmpDC, CRect recGroupBodyTarget, CRect recGroupBodySource); void AdjustScrollBars(CRect recGroupHeader); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt); afx_msg void OnTimer(UINT_PTR nIDEvent); };
[ [ [ 1, 186 ] ] ]
078e554eb49fef28bfbab411377410c04a35a6ea
0466568120485fcabdba5aa22a4b0fea13068b8b
/opencv/modules/gpu/src/error.cpp
0ca918d521ec6bdc5c5c1f735aa4a8a3e6426d07
[]
no_license
coapp-packages/opencv
be25a9aec58d9ac890fc764932ba67914add078d
c78981e0d8f602fde523a82c3a7e2c3fef1f39bc
refs/heads/master
2020-05-17T12:11:25.406742
2011-07-14T17:13:01
2011-07-14T17:13:01
2,048,483
3
0
null
null
null
null
UTF-8
C++
false
false
7,872
cpp
/*M/////////////////////////////////////////////////////////////////////////////////////// // // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. // // By downloading, copying, installing or using the software you agree to this license. // If you do not agree to this license, do not download, install, // copy or use the software. // // // License Agreement // For Open Source Computer Vision Library // // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. // Copyright (C) 2009, Willow Garage Inc., all rights reserved. // Third party copyrights are property of their respective owners. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // * Redistribution's of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // * Redistribution's 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. // // * The name of the copyright holders may not 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 Intel Corporation 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. // //M*/ #include "precomp.hpp" using namespace cv; using namespace cv::gpu; #if !defined (HAVE_CUDA) #else /* !defined (HAVE_CUDA) */ namespace { #define error_entry(entry) { entry, #entry } ////////////////////////////////////////////////////////////////////////// // NPP errors struct NppError { int error; string str; } npp_errors [] = { error_entry( NPP_NOT_SUPPORTED_MODE_ERROR ), error_entry( NPP_ROUND_MODE_NOT_SUPPORTED_ERROR ), error_entry( NPP_RESIZE_NO_OPERATION_ERROR ), #if defined (_MSC_VER) error_entry( NPP_NOT_SUFFICIENT_COMPUTE_CAPABILITY ), #endif error_entry( NPP_BAD_ARG_ERROR ), error_entry( NPP_LUT_NUMBER_OF_LEVELS_ERROR ), error_entry( NPP_TEXTURE_BIND_ERROR ), error_entry( NPP_COEFF_ERROR ), error_entry( NPP_RECT_ERROR ), error_entry( NPP_QUAD_ERROR ), error_entry( NPP_WRONG_INTERSECTION_ROI_ERROR ), error_entry( NPP_NOT_EVEN_STEP_ERROR ), error_entry( NPP_INTERPOLATION_ERROR ), error_entry( NPP_RESIZE_FACTOR_ERROR ), error_entry( NPP_HAAR_CLASSIFIER_PIXEL_MATCH_ERROR ), error_entry( NPP_MEMFREE_ERR ), error_entry( NPP_MEMSET_ERR ), error_entry( NPP_MEMCPY_ERROR ), error_entry( NPP_MEM_ALLOC_ERR ), error_entry( NPP_HISTO_NUMBER_OF_LEVELS_ERROR ), error_entry( NPP_MIRROR_FLIP_ERR ), error_entry( NPP_INVALID_INPUT ), error_entry( NPP_ALIGNMENT_ERROR ), error_entry( NPP_STEP_ERROR ), error_entry( NPP_SIZE_ERROR ), error_entry( NPP_POINTER_ERROR ), error_entry( NPP_NULL_POINTER_ERROR ), error_entry( NPP_CUDA_KERNEL_EXECUTION_ERROR ), error_entry( NPP_NOT_IMPLEMENTED_ERROR ), error_entry( NPP_ERROR ), error_entry( NPP_NO_ERROR ), error_entry( NPP_SUCCESS ), error_entry( NPP_WARNING ), error_entry( NPP_WRONG_INTERSECTION_QUAD_WARNING ), error_entry( NPP_MISALIGNED_DST_ROI_WARNING ), error_entry( NPP_AFFINE_QUAD_INCORRECT_WARNING ), error_entry( NPP_DOUBLE_SIZE_WARNING ), error_entry( NPP_ODD_ROI_WARNING ) }; int error_num = sizeof(npp_errors)/sizeof(npp_errors[0]); struct Searcher { int err; Searcher(int err_) : err(err_) {}; bool operator()(const NppError& e) const { return e.error == err; } }; ////////////////////////////////////////////////////////////////////////// // CUFFT errors struct CufftError { int code; string message; }; const CufftError cufft_errors[] = { error_entry(CUFFT_INVALID_PLAN), error_entry(CUFFT_ALLOC_FAILED), error_entry(CUFFT_INVALID_TYPE), error_entry(CUFFT_INVALID_VALUE), error_entry(CUFFT_INTERNAL_ERROR), error_entry(CUFFT_EXEC_FAILED), error_entry(CUFFT_SETUP_FAILED), error_entry(CUFFT_INVALID_SIZE), error_entry(CUFFT_UNALIGNED_DATA) }; struct CufftErrorComparer { CufftErrorComparer(int code_): code(code_) {} bool operator()(const CufftError& other) const { return other.code == code; } int code; }; const int cufft_error_num = sizeof(cufft_errors) / sizeof(cufft_errors[0]); } namespace cv { namespace gpu { const string getNppErrorString( int err ) { int idx = std::find_if(npp_errors, npp_errors + error_num, Searcher(err)) - npp_errors; const string& msg = (idx != error_num) ? npp_errors[idx].str : string("Unknown error code"); std::stringstream interpreter; interpreter << msg <<" [Code = " << err << "]"; return interpreter.str(); } void nppError( int err, const char *file, const int line, const char *func) { cv::error( cv::Exception(CV_GpuNppCallError, getNppErrorString(err), func, file, line) ); } const string getCufftErrorString(int err_code) { const CufftError* cufft_error = std::find_if( cufft_errors, cufft_errors + cufft_error_num, CufftErrorComparer(err_code)); bool found = cufft_error != cufft_errors + cufft_error_num; std::stringstream ss; ss << (found ? cufft_error->message : "Unknown error code"); ss << " [Code = " << err_code << "]"; return ss.str(); } void cufftError(int err, const char *file, const int line, const char *func) { cv::error(cv::Exception(CV_GpuCufftCallError, getCufftErrorString(err), func, file, line)); } void error(const char *error_string, const char *file, const int line, const char *func) { int code = CV_GpuApiCallError; if (std::uncaught_exception()) { const char* errorStr = cvErrorStr(code); const char* function = func ? func : "unknown function"; std::cerr << "OpenCV Error: " << errorStr << "(" << error_string << ") in " << function << ", file " << file << ", line " << line; std::cerr.flush(); } else cv::error( cv::Exception(code, error_string, func, file, line) ); } } } #endif
[ "anatoly@73c94f0f-984f-4a5f-82bc-2d8db8d8ee08", "alexeys@73c94f0f-984f-4a5f-82bc-2d8db8d8ee08", "morozov.andrey@73c94f0f-984f-4a5f-82bc-2d8db8d8ee08" ]
[ [ [ 1, 58 ], [ 62, 72 ], [ 75, 75 ], [ 77, 121 ], [ 156, 177 ], [ 198, 215 ] ], [ [ 59, 61 ], [ 122, 155 ], [ 178, 197 ] ], [ [ 73, 74 ], [ 76, 76 ], [ 216, 216 ] ] ]
e04e21c5547d5d63b208d6fe58c9181ebd54ea99
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/boost/python/object_core.hpp
2fc65a1eaf94a262845d9ef5f1aabbd853b4cad3
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
UTF-8
C++
false
false
13,918
hpp
// Copyright David Abrahams 2002. // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef OBJECT_CORE_DWA2002615_HPP # define OBJECT_CORE_DWA2002615_HPP # include <boost/python/detail/prefix.hpp> # include <boost/type.hpp> # include <boost/python/call.hpp> # include <boost/python/handle_fwd.hpp> # include <boost/python/errors.hpp> # include <boost/python/refcount.hpp> # include <boost/python/detail/preprocessor.hpp> # include <boost/python/tag.hpp> # include <boost/python/def_visitor.hpp> # include <boost/python/detail/raw_pyobject.hpp> # include <boost/python/detail/dependent.hpp> # include <boost/python/object/forward.hpp> # include <boost/python/object/add_to_namespace.hpp> # include <boost/preprocessor/iterate.hpp> # include <boost/preprocessor/debug/line.hpp> # include <boost/python/detail/is_xxx.hpp> # include <boost/python/detail/string_literal.hpp> # include <boost/python/detail/def_helper_fwd.hpp> # include <boost/type_traits/is_same.hpp> # include <boost/type_traits/is_convertible.hpp> # include <boost/type_traits/remove_reference.hpp> # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) # include <boost/type_traits/add_pointer.hpp> # endif # include <boost/mpl/if.hpp> namespace boost { namespace python { namespace converter { template <class T> struct arg_to_python; } // Put this in an inner namespace so that the generalized operators won't take over namespace api { // This file contains the definition of the object class and enough to // construct/copy it, but not enough to do operations like // attribute/item access or addition. template <class Policies> class proxy; struct const_attribute_policies; struct attribute_policies; struct const_item_policies; struct item_policies; struct const_slice_policies; struct slice_policies; class slice_nil; typedef proxy<const_attribute_policies> const_object_attribute; typedef proxy<attribute_policies> object_attribute; typedef proxy<const_item_policies> const_object_item; typedef proxy<item_policies> object_item; typedef proxy<const_slice_policies> const_object_slice; typedef proxy<slice_policies> object_slice; // // is_proxy -- proxy type detection // BOOST_PYTHON_IS_XXX_DEF(proxy, boost::python::api::proxy, 1) template <class T> struct object_initializer; class object; typedef PyObject* (object::*bool_type)() const; template <class U> class object_operators : public def_visitor<U> { protected: # if !defined(BOOST_MSVC) || BOOST_MSVC >= 1300 typedef object const& object_cref; # else typedef object object_cref; # endif public: // function call // object operator()() const; # define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PYTHON_MAX_ARITY, <boost/python/object_call.hpp>)) # include BOOST_PP_ITERATE() // truth value testing // operator bool_type() const; bool operator!() const; // needed for vc6 // Attribute access // const_object_attribute attr(char const*) const; object_attribute attr(char const*); // item access // const_object_item operator[](object_cref) const; object_item operator[](object_cref); template <class T> const_object_item operator[](T const& key) const # if !defined(BOOST_MSVC) || BOOST_MSVC > 1300 ; # else { return (*this)[object(key)]; } # endif template <class T> object_item operator[](T const& key) # if !defined(BOOST_MSVC) || BOOST_MSVC > 1300 ; # else { return (*this)[object(key)]; } # endif // slicing // const_object_slice slice(object_cref, object_cref) const; object_slice slice(object_cref, object_cref); const_object_slice slice(slice_nil, object_cref) const; object_slice slice(slice_nil, object_cref); const_object_slice slice(object_cref, slice_nil) const; object_slice slice(object_cref, slice_nil); const_object_slice slice(slice_nil, slice_nil) const; object_slice slice(slice_nil, slice_nil); template <class T, class V> const_object_slice slice(T const& start, V const& end) const # if !defined(BOOST_MSVC) || BOOST_MSVC > 1300 ; # else { return this->slice( slice_bound<T>::type(start) , slice_bound<V>::type(end)); } # endif template <class T, class V> object_slice slice(T const& start, V const& end) # if !defined(BOOST_MSVC) || BOOST_MSVC > 1300 ; # else { return this->slice( slice_bound<T>::type(start) , slice_bound<V>::type(end)); } # endif private: // def visitation for adding callable objects as class methods template <class ClassT, class DocStringT> void visit(ClassT& cl, char const* name, python::detail::def_helper<DocStringT> const& helper) const { // It's too late to specify anything other than docstrings if // the callable object is already wrapped. BOOST_STATIC_ASSERT( (is_same<char const*,DocStringT>::value || detail::is_string_literal<DocStringT const>::value)); objects::add_to_namespace(cl, name, this->derived_visitor(), helper.doc()); } friend class python::def_visitor_access; private: // there is a confirmed CWPro8 codegen bug here. We prevent the // early destruction of a temporary by binding a named object // instead. # if __MWERKS__ < 0x3000 || __MWERKS__ > 0x3003 typedef object const& object_cref2; # else typedef object const object_cref2; # endif }; // VC6 and VC7 require this base class in order to generate the // correct copy constructor for object. We can't define it there // explicitly or it will complain of ambiguity. struct object_base : object_operators<object> { // copy constructor without NULL checking, for efficiency. inline object_base(object_base const&); inline object_base(PyObject* ptr); object_base& operator=(object_base const& rhs); ~object_base(); // Underlying object access -- returns a borrowed reference PyObject* ptr() const; private: PyObject* m_ptr; }; # ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template <class T, class U> struct is_derived_impl { static T x; template <class X> static X* to_pointer(X const&); static char test(U const*); typedef char (&no)[2]; static no test(...); BOOST_STATIC_CONSTANT(bool, value = sizeof(test(to_pointer(x))) == 1); }; template <class T, class U> struct is_derived : mpl::bool_<is_derived_impl<T,U>::value> {}; # else template <class T, class U> struct is_derived : is_convertible< typename remove_reference<T>::type* , U const* > {}; # endif template <class T> typename objects::unforward_cref<T>::type do_unforward_cref(T const& x) { # if BOOST_WORKAROUND(__GNUC__, == 2) typedef typename objects::unforward_cref<T>::type ret; return ret(x); # else return x; # endif } # if BOOST_WORKAROUND(__GNUC__, == 2) // GCC 2.x has non-const string literals; this hacks around that problem. template <unsigned N> char const (& do_unforward_cref(char const(&x)[N]) )[N] { return x; } # endif class object; template <class T> PyObject* object_base_initializer(T const& x) { typedef typename is_derived< BOOST_DEDUCED_TYPENAME objects::unforward_cref<T>::type , object >::type is_obj; return object_initializer< BOOST_DEDUCED_TYPENAME unwrap_reference<T>::type >::get( x , is_obj() ); } class object : public object_base { public: // default constructor creates a None object object(); // explicit conversion from any C++ object to Python template <class T> explicit object( T const& x # if BOOST_WORKAROUND(BOOST_MSVC, < 1300) // use some SFINAE to un-confuse MSVC about its // copy-initialization ambiguity claim. , typename mpl::if_<is_proxy<T>,int&,int>::type* = 0 # endif ) : object_base(object_base_initializer(x)) { } // Throw error_already_set() if the handle is null. BOOST_PYTHON_DECL explicit object(handle<> const&); private: public: // implementation detail -- for internal use only explicit object(detail::borrowed_reference); explicit object(detail::new_reference); explicit object(detail::new_non_null_reference); }; // Macros for forwarding constructors in classes derived from // object. Derived classes will usually want these as an // implementation detail # define BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS_(derived, base) \ inline explicit derived(python::detail::borrowed_reference p) \ : base(p) {} \ inline explicit derived(python::detail::new_reference p) \ : base(p) {} \ inline explicit derived(python::detail::new_non_null_reference p) \ : base(p) {} # if !defined(BOOST_MSVC) || BOOST_MSVC >= 1300 # define BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS_ # else // MSVC6 has a bug which causes an explicit template constructor to // be preferred over an appropriate implicit conversion operator // declared on the argument type. Normally, that would cause a // runtime failure when using extract<T> to extract a type with a // templated constructor. This additional constructor will turn that // runtime failure into an ambiguity error at compile-time due to // the lack of partial ordering, or at least a link-time error if no // generalized template constructor is declared. # define BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(derived, base) \ BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS_(derived, base) \ template <class T> \ explicit derived(extract<T> const&); # endif // // object_initializer -- get the handle to construct the object with, // based on whether T is a proxy or derived from object // template <bool is_proxy = false, bool is_object_manager = false> struct object_initializer_impl { static PyObject* get(object const& x, mpl::true_) { return python::incref(x.ptr()); } template <class T> static PyObject* get(T const& x, mpl::false_) { return python::incref(converter::arg_to_python<T>(x).get()); } }; template <> struct object_initializer_impl<true, false> { template <class Policies> static PyObject* get(proxy<Policies> const& x, mpl::false_) { return python::incref(x.operator object().ptr()); } }; template <> struct object_initializer_impl<false, true> { template <class T, class U> static PyObject* get(T const& x, U) { return python::incref(get_managed_object(x, tag)); } }; template <> struct object_initializer_impl<true, true> {}; // empty implementation should cause an error template <class T> struct object_initializer : object_initializer_impl< is_proxy<T>::value , converter::is_object_manager<T>::value > {}; } using api::object; template <class T> struct extract; // // implementation // inline object::object() : object_base(python::incref(Py_None)) {} // copy constructor without NULL checking, for efficiency inline api::object_base::object_base(object_base const& rhs) : m_ptr(python::incref(rhs.m_ptr)) {} inline api::object_base::object_base(PyObject* p) : m_ptr(p) {} inline api::object_base& api::object_base::operator=(api::object_base const& rhs) { Py_INCREF(rhs.m_ptr); Py_DECREF(this->m_ptr); this->m_ptr = rhs.m_ptr; return *this; } inline api::object_base::~object_base() { Py_DECREF(m_ptr); } inline object::object(detail::borrowed_reference p) : object_base(python::incref((PyObject*)p)) {} inline object::object(detail::new_reference p) : object_base(expect_non_null((PyObject*)p)) {} inline object::object(detail::new_non_null_reference p) : object_base((PyObject*)p) {} inline PyObject* api::object_base::ptr() const { return m_ptr; } // // Converter specialization implementations // namespace converter { template <class T> struct object_manager_traits; template <> struct object_manager_traits<object> { BOOST_STATIC_CONSTANT(bool, is_specialized = true); static bool check(PyObject*) { return true; } static python::detail::new_non_null_reference adopt(PyObject* x) { return python::detail::new_non_null_reference(x); } }; } inline PyObject* get_managed_object(object const& x, tag_t) { return x.ptr(); } }} // namespace boost::python # include <boost/python/slice_nil.hpp> #endif // OBJECT_CORE_DWA2002615_HPP
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 485 ] ] ]
7f6a282cf33339e14bce45da2967b583cbbeba47
709cd826da3ae55945fd7036ecf872ee7cdbd82a
/Term/WildMagic2/Applications/Physics/BallHill/BallHill.cpp
55b303b7f63cc9524bc3d9d1b16eb2d0f615c3eb
[]
no_license
argapratama/kucgbowling
20dbaefe1596358156691e81ccceb9151b15efb0
65e40b6f33c5511bddf0fa350c1eefc647ace48a
refs/heads/master
2018-01-08T15:27:44.784437
2011-06-19T15:23:39
2011-06-19T15:23:39
36,738,655
0
0
null
null
null
null
UTF-8
C++
false
false
9,467
cpp
// Magic Software, Inc. // http://www.magic-software.com // http://www.wild-magic.com // Copyright (c) 2003. All Rights Reserved // // The Game Physics source code is supplied under the terms of the license // agreement http://www.magic-software.com/License/GamePhysics.pdf and may not // be copied or disclosed except in accordance with the terms of that // agreement. #include "BallHill.h" #include "PhysicsModule.h" using namespace std; BallHill g_kTheApp; //#define SINGLE_STEP //---------------------------------------------------------------------------- BallHill::BallHill () : Application("BallHill",0,0,640,480, ColorRGB(0.839215f,0.894117f,0.972549f)) { } //---------------------------------------------------------------------------- BallHill::~BallHill () { } //---------------------------------------------------------------------------- bool BallHill::OnInitialize () { if ( !Application::OnInitialize() ) return false; // set up the physics module m_kModule.Gravity = 1.0; m_kModule.A1 = 2.0; m_kModule.A2 = 1.0; m_kModule.A3 = 1.0; m_kModule.Radius = 0.1; double dTime = 0.0; double dDeltaTime = 0.01; double dY1 = 0.0; double dDY1 = 0.1; double dY2 = 0.0; double dDY2 = 0.1; m_kModule.Initialize(dTime,dDeltaTime,dY1,dDY1,dY2,dDY2); // set up the scene graph m_spkScene = new Node(4); // wireframe mode m_spkWireframe = new WireframeState; m_spkScene->SetRenderState(m_spkWireframe); // depth buffering ZBufferState* pkZBuffer = new ZBufferState; pkZBuffer->Enabled() = true; pkZBuffer->Writeable() = true; pkZBuffer->Compare() = ZBufferState::CF_LEQUAL; m_spkScene->SetRenderState(pkZBuffer); m_spkScene->AttachChild(CreateGround()); m_spkScene->AttachChild(CreateHill()); m_spkScene->AttachChild(CreateBall()); m_spkScene->AttachChild(CreatePath()); // set up camera ms_spkCamera->SetFrustum(1.0f,100.0f,-0.55f,0.55f,0.4125f,-0.4125f); float fAngle = 0.1f*Mathf::PI; float fCos = Mathf::Cos(fAngle), fSin = Mathf::Sin(fAngle); Vector3f kCUp(-fSin,0.0f,fCos); Vector3f kCDir(-fCos,0.0f,-fSin); Vector3f kCLeft = kCUp.Cross(kCDir); Vector3f kCLoc(4.0f,0.0f,2.0f); ms_spkCamera->SetFrame(kCLoc,kCLeft,kCUp,kCDir); // initial update of objects ms_spkCamera->Update(); m_spkScene->UpdateGS(0.0f); m_spkScene->UpdateRS(); m_spkMotionObject = m_spkScene; m_bTurretActive = true; SetTurretAxes(); m_fTrnSpeed = 0.001f; m_fRotSpeed = 0.001f; return true; } //---------------------------------------------------------------------------- void BallHill::OnTerminate () { m_spkScene = NULL; m_spkWireframe = NULL; m_spkBall = NULL; m_spkHill = NULL; Application::OnTerminate(); } //---------------------------------------------------------------------------- void BallHill::OnIdle () { MeasureTime(); MoveCamera(); if ( MoveObject() ) m_spkScene->UpdateGS(0.0f); #ifndef SINGLE_STEP DoPhysical(); #endif ms_spkRenderer->ClearBuffers(); if ( ms_spkRenderer->BeginScene() ) { ms_spkRenderer->Draw(m_spkScene); DrawFrameRate(8,GetHeight()-8,ColorRGB::WHITE); ms_spkRenderer->EndScene(); } ms_spkRenderer->DisplayBackBuffer(); UpdateClicks(); } //---------------------------------------------------------------------------- void BallHill::OnKeyDown (unsigned char ucKey, int iX, int iY) { if ( ucKey == 'q' || ucKey == 'Q' || ucKey == KEY_ESCAPE ) { RequestTermination(); return; } switch ( ucKey ) { case 'w': // toggle wireframe case 'W': m_spkWireframe->Enabled() = !m_spkWireframe->Enabled(); break; #ifdef SINGLE_STEP case 'g': case 'G': DoPhysical(); break; #endif } } //---------------------------------------------------------------------------- TriMesh* BallHill::CreateGround () { TriMesh* pkGround = NULL; CreateRectangleMesh(pkGround,Vector3f::ZERO,Vector3f::UNIT_X, Vector3f::UNIT_Y,Vector3f::UNIT_Z,32.0f,32.0f,false,false,true); m_spkGround = pkGround; // change the texture repeat int iVQuantity = m_spkGround->GetVertexQuantity(); Vector2f* akUV = m_spkGround->Textures(); for (int i = 0; i < iVQuantity; i++) akUV[i] *= 8.0f; Texture* pkTexture = new Texture; pkTexture->SetImage(Image::Load("grass.mif")); pkTexture->Filter() = Texture::FM_LINEAR; pkTexture->Mipmap() = Texture::MM_LINEAR_LINEAR; pkTexture->Apply() = Texture::AM_REPLACE; pkTexture->Wrap() = Texture::WM_WRAP_S_WRAP_T; TextureState* pkTS = new TextureState; pkTS->Set(0,pkTexture); m_spkGround->SetRenderState(pkTS); return pkGround; } //---------------------------------------------------------------------------- TriMesh* BallHill::CreateHill () { TriMesh* pkHill = NULL; CreateDiskMesh(pkHill,32,32,Vector3f::ZERO,2.0f,Vector3f::UNIT_X, Vector3f::UNIT_Y,Vector3f::UNIT_Z,false,false,true); m_spkHill = pkHill; // change the texture repeat int iVQuantity = m_spkHill->GetVertexQuantity(); Vector2f* akUV = m_spkHill->Textures(); int i; for (i = 0; i < iVQuantity; i++) akUV[i] *= 8.0f; Texture* pkTexture = new Texture; pkTexture->SetImage(Image::Load("gravel.mif")); pkTexture->Filter() = Texture::FM_LINEAR; pkTexture->Mipmap() = Texture::MM_LINEAR_LINEAR; pkTexture->Apply() = Texture::AM_REPLACE; pkTexture->Wrap() = Texture::WM_WRAP_S_WRAP_T; TextureState* pkTS = new TextureState; pkTS->Set(0,pkTexture); m_spkHill->SetRenderState(pkTS); // adjust disk vertices to form elliptical paraboloid for the hill Vector3f* akVertex = m_spkHill->Vertices(); for (i = 0; i < iVQuantity; i++) { akVertex[i].Z() = m_kModule.GetHeight(akVertex[i].X(), akVertex[i].Y()); } m_spkHill->UpdateModelBound(); m_spkHill->UpdateModelNormals(); return m_spkHill; } //---------------------------------------------------------------------------- TriMesh* BallHill::CreateBall () { TriMesh* pkBall = NULL; m_fRadius = (float)m_kModule.Radius; CreateSphereMesh(pkBall,16,16,Vector3f::ZERO,m_fRadius,Vector3f::UNIT_X, Vector3f::UNIT_Y,Vector3f::UNIT_Z,false,false,true,true); m_spkBall = pkBall; m_spkBall->Translate().Z() = (float)m_kModule.A3 + m_fRadius; Texture* pkTexture = new Texture; pkTexture->SetImage(Image::Load("BallTexture.mif")); pkTexture->Filter() = Texture::FM_LINEAR; pkTexture->Mipmap() = Texture::MM_LINEAR_LINEAR; pkTexture->Apply() = Texture::AM_REPLACE; pkTexture->Wrap() = Texture::WM_WRAP_S_WRAP_T; TextureState* pkTS = new TextureState; pkTS->Set(0,pkTexture); m_spkBall->SetRenderState(pkTS); UpdateBall(); return m_spkBall; } //---------------------------------------------------------------------------- Polyline* BallHill::CreatePath () { // points used to display path of ball const int iPQuantity = 1024; Vector3f* akPVertex = new Vector3f[iPQuantity]; ColorRGB* akPColor = new ColorRGB[iPQuantity]; for (int i = 0; i < iPQuantity; i++) { akPVertex[i] = Vector3f::ZERO; akPColor[i] = ColorRGB::WHITE; } m_spkPath = new Polyline(iPQuantity,akPVertex,NULL,akPColor,NULL,false); m_spkPath->SetActiveQuantity(0); m_iNextPoint = 0; return m_spkPath; } //---------------------------------------------------------------------------- void BallHill::DoPhysical () { // allow motion only while ball is above the ground level if ( m_spkBall->Translate().Z() <= m_fRadius ) return; // move the ball m_kModule.Update(); Vector3f kCenter = UpdateBall(); // Draw only the active quantity of pendulum points for the initial // portion of the simulation. Once all points are activated, then all // are drawn. int iVQuantity = m_spkPath->GetVertexQuantity(); int iAQuantity = m_spkPath->GetActiveQuantity(); if ( iAQuantity < iVQuantity ) m_spkPath->SetActiveQuantity(++iAQuantity); // Update the path that the ball has followed. The points are stored in // a circular queue, so the oldest points eventually disappear and are // reused for the new points. m_spkPath->Vertices()[m_iNextPoint] = kCenter; if ( ++m_iNextPoint == iVQuantity ) m_iNextPoint = 0; } //---------------------------------------------------------------------------- Vector3f BallHill::UpdateBall () { // Compute the location of the center of the ball and the incremental // rotation implied by its motion. Vector3f kCenter; Matrix3f kIncrRot; m_kModule.GetData(kCenter,kIncrRot); // update the ball position and orientation m_spkBall->Translate() = kCenter; m_spkBall->UpdateGS(0.0f); m_spkBall->Rotate() = kIncrRot*m_spkBall->Rotate(); // return the new ball center for further use by application return kCenter; } //----------------------------------------------------------------------------
[ [ [ 1, 297 ] ] ]
29de60f2b01078f25d04630a11ccf4787c9bac67
871585f3c45603024488cabd14184610af7a081f
/block_match_inc_d/library.cpp
c88867f13b97279397929e7f18c9c56a4e9a01ad
[]
no_license
davideanastasia/ORIP
9ac6fb8c490d64da355d34804d949b85ea17dbff
54c180b442a02a202076b8072ceb573f5e345871
refs/heads/master
2016-09-06T14:17:22.765343
2011-11-05T16:23:23
2011-11-05T16:23:23
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
19,473
cpp
/* ORIP_v2 –> Op Ref Im Proc -> Oper Refin Imag Process -> Operational Refinement of Image Processing * * Copyright Davide Anastasia and Yiannis Andreopoulos, University College London * * http://www.ee.ucl.ac.uk/~iandreop/ORIP.html * If you have not retrieved this source code via the above link, please contact [email protected] and [email protected] * */ // [row][col] //#define EARLY_TERMINATION (1) #include "common_lib.h" #include "library.h" #include <iomanip> using namespace std; // -- packing --- long __max_value; int __M; double __eps; int __inv_eps; int __num_pack; // -------------- void setup_env(int b_col, int b_row, int bit4bitplane) { // calculate __max_value dinamically double max_sample_value = pow(2.0, bit4bitplane) - 1; __max_value = long (2 * pow(max_sample_value * (b_col * b_row), 2.0)); double pow_2 = log10(double(__max_value))/log10(2.0); __M = int(ceil(pow_2) + 1); __inv_eps = int(pow(2.0, (__M))); __eps = pow(2.0, -(__M)); __num_pack = 2; //__num_pack = int(floor(LIMIT/__M) + 1); while ( exp_error(__max_value) > 0.5 ) __num_pack--; } void show_env_status() { cout << endl; cout << " Max Value = " << __max_value << endl; cout << " M = " << __M << endl; cout << " EPS = " << __eps << endl; cout << " 1/EPS = " << __inv_eps << endl; cout << " Packing = " << __num_pack << endl; cout << " Max Expect Error = " << pow(2.0, -(MAX_PACKING))*__max_value/pow(2.0, (-(__num_pack-1)*__M)) << endl; cout << endl; } match** create_matrix(int col, int row) { // init memory match** mem = new match*[row]; for (int k = 0; k < row; k++) { mem[k] = new match[col]; } // reset memory for (int i = 0; i < row; i++) for (int j = 0; j < col; j++) { mem[i][j].src_x = 0; mem[i][j].src_y = 0; mem[i][j].dest_x = 0; mem[i][j].dest_y = 0; mem[i][j].m_value = INT_MAX; } return mem; } #define SPACE_S 3 #define SPACE_M 6 void print_matrix(match** matrix, int c_size, int r_size, int print_col, int print_row) { for (int i = 0 ; i < print_row; i++) { for (int j = 0 ; j < print_col; j++) { cout << " " << "[(" << setw(SPACE_S) << matrix[i][j].src_x << "," << setw(SPACE_S) << matrix[i][j].src_y << ")" << " > " << setw(SPACE_M) << matrix[i][j].m_value << " >" << " (" << setw(SPACE_S) << matrix[i][j].dest_x << "," << setw(SPACE_S) << matrix[i][j].dest_y << ")]"; } cout << endl; } } int block_match_d(double**** ref_area, int w_ref_area, int h_ref_area, double** block_ref, int w_blk, int h_blk, int x, int y, int search_range, match& output) { int early_termination=0; int curr_grid_ref,grid_j,progress_grid; int curr_SSD_grid1,curr_SSD_grid2; double curr_SSD_grid=0,tmp; output.m_value = INT_MAX; for (int i=0; i<2*search_range; i++) { for (int j=0; j<2*search_range; j++) { if ((i%2)==0 && (j%2)==0) { curr_grid_ref=0; grid_j=j/2; progress_grid=0; } if ((i%2)==1 && (j%2)==0) { curr_grid_ref=1; grid_j=j/2; progress_grid=0; } if ((i%2)==0 && (j%2)==1) { curr_grid_ref=1; grid_j=(j-1)/2; progress_grid=1; } if ((i%2)==1 && (j%2)==1) { curr_grid_ref=0; grid_j=(j-1)/2; progress_grid=1; } curr_SSD_grid = 0; early_termination = 0; for (int block_i=1; block_i<=h_blk; block_i++) { for (int block_j=1; block_j<=w_blk/2; block_j++) { tmp = (block_ref[block_i][block_j] - ref_area[progress_grid][curr_grid_ref][i+block_i][grid_j+block_j]); curr_SSD_grid += (tmp*tmp); } #ifdef EARLY_TERMINATION if ((block_i%2)==0) { double R0,R1, R2; int U1; R0 = curr_SSD_grid; curr_SSD_grid1 = full_round(R0); R1 = (R0-curr_SSD_grid1)/__eps; U1 = full_round(R1); R2 = (R1-U1)/__eps; curr_SSD_grid2 = full_round(R2); if ( curr_SSD_grid1 + curr_SSD_grid2 > output.m_value ) { // the unpacked SSDs exceed the best--> terminate early_termination=1; break; } } #endif } #ifdef EARLY_TERMINATION if ( early_termination == 0 ) { output.m_value = curr_SSD_grid1 + curr_SSD_grid2; output.dest_x = x + j - search_range; output.dest_y = y + i - search_range; } #else double R0,R1, R2; int U1; R0 = curr_SSD_grid; curr_SSD_grid1 = full_round(R0); R1 = (R0-curr_SSD_grid1)/__eps; U1 = full_round(R1); R2 = (R1-U1)/__eps; curr_SSD_grid2 = full_round(R2); if ( curr_SSD_grid1 + curr_SSD_grid2 < output.m_value ) { output.m_value=curr_SSD_grid1+curr_SSD_grid2; output.dest_x = x + j - search_range; output.dest_y = y + i - search_range; } #endif } } return 0; } int block_match_d_log_search(double**** ref_area, int w_ref_area, int h_ref_area, double** block_ref, int w_blk, int h_blk, int x, int y, int search_range, match& output, int spiral_size) { int r_area_size = search_range*2; int early_termination = 0; int curr_grid_ref; int grid_j; int progress_grid; int curr_SSD_grid1; int curr_SSD_grid2; double curr_SSD_grid = 0; double tmp; output.m_value = INT_MAX; int acc = 0; int acc_d = 0; int x_curr, y_curr; int x_pivot = search_range; // central point of the reference area int y_pivot = search_range; // step 16, 8, 4, 2 int step = search_range/2 + 1; while (1) { if ( step != 1) { for ( int pos = 0; pos < 5; pos++ ) // 5 positions { switch (pos) { case 0: x_curr = x_pivot; y_curr = y_pivot; break; case 1: x_curr = x_pivot + step; y_curr = y_pivot; break; case 2: x_curr = x_pivot; y_curr = y_pivot + step; break; case 3: x_curr = x_pivot - step; y_curr = y_pivot; break; case 4: x_curr = x_pivot; y_curr = y_pivot - step; break; } // END switch // calculate match if ( x_curr >= 0 && y_curr >=0 && x_curr < r_area_size && y_curr < r_area_size ) { if ((y_curr%2)==0 && (x_curr%2)==0) { curr_grid_ref=0; grid_j=x_curr/2; progress_grid=0; } if ((y_curr%2)==1 && (x_curr%2)==0) { curr_grid_ref=1; grid_j=x_curr/2; progress_grid=0; } if ((y_curr%2)==0 && (x_curr%2)==1) { curr_grid_ref=1; grid_j=(x_curr-1)/2; progress_grid=1; } if ((y_curr%2)==1 && (x_curr%2)==1) { curr_grid_ref=0; grid_j=(x_curr-1)/2; progress_grid=1; } curr_SSD_grid = 0; #ifdef EARLY_TERMINATION early_termination = 0; #endif for (int block_i=1; block_i<=h_blk; block_i++) { for (int block_j=1; block_j<=w_blk/2; block_j++) { tmp = (block_ref[block_i][block_j] - ref_area[progress_grid][curr_grid_ref][y_curr + block_i][grid_j + block_j]); curr_SSD_grid += (tmp*tmp); } #ifdef EARLY_TERMINATION if ((block_i%2)==0) { double R0,R1, R2; int U1; R0 = curr_SSD_grid; curr_SSD_grid1 = full_round(R0); R1 = (R0-curr_SSD_grid1)/__eps; U1 = full_round(R1); R2 = (R1-U1)/__eps; curr_SSD_grid2 = full_round(R2); if ( curr_SSD_grid1 + curr_SSD_grid2 > output.m_value ) { // the unpacked SSDs exceed the best--> terminate early_termination=1; break; } } #endif } #ifdef EARLY_TERMINATION if ( early_termination == 0 ) { output.m_value = curr_SSD_grid1 + curr_SSD_grid2; output.dest_x = x + x_curr - search_range; output.dest_y = y + y_curr - search_range; } #else double R0,R1, R2; int U1; R0 = curr_SSD_grid; curr_SSD_grid1 = full_round(R0); R1 = (R0-curr_SSD_grid1)/__eps; U1 = full_round(R1); R2 = (R1-U1)/__eps; curr_SSD_grid2 = full_round(R2); if ( curr_SSD_grid1 + curr_SSD_grid2 < output.m_value ) { output.m_value = curr_SSD_grid1 + curr_SSD_grid2; output.dest_x = x + x_curr - search_range; output.dest_y = y + y_curr - search_range; } #endif } // if ( x_curr >= 0 && y_curr >=0 && x_curr < w_s_area && y_curr < h_s_area ) } // for ( int pos = 0; pos < 5; pos++ ) step = step/2; // update step // if (step == 0) break; if (step != 1) step++; // update pivot x_pivot = search_range + (output.dest_x - output.src_x); y_pivot = search_range + (output.dest_y - output.src_y); } else { // STEP is 1, so I do a spiral search around the already found best match for (int sx = 1; sx <= spiral_size; sx++ ) { // for each side (4 sides!) for (int v = 0; v < 4; v++) { // for each elem for ( int idx = (1-sx) ; idx <= sx ; idx++ ) { switch (v) { case 0: y_curr = y_pivot + idx; x_curr = x_pivot + sx; break; case 1: y_curr = y_pivot + sx; x_curr = x_pivot - idx; break; case 2: y_curr = y_pivot - idx; x_curr = x_pivot - sx; break; case 3: y_curr = y_pivot - sx; x_curr = x_pivot + idx; break; } if ( x_curr >= 0 && y_curr >=0 && x_curr < r_area_size && y_curr < r_area_size ) { if ((y_curr%2)==0 && (x_curr%2)==0) { curr_grid_ref=0; grid_j=x_curr/2; progress_grid=0; } if ((y_curr%2)==1 && (x_curr%2)==0) { curr_grid_ref=1; grid_j=x_curr/2; progress_grid=0; } if ((y_curr%2)==0 && (x_curr%2)==1) { curr_grid_ref=1; grid_j=(x_curr-1)/2; progress_grid=1; } if ((y_curr%2)==1 && (x_curr%2)==1) { curr_grid_ref=0; grid_j=(x_curr-1)/2; progress_grid=1; } curr_SSD_grid = 0; #ifdef EARLY_TERMINATION early_termination = 0; #endif for (int block_i=1; block_i<=h_blk; block_i++) { for (int block_j=1; block_j<=w_blk/2; block_j++) { tmp = (block_ref[block_i][block_j] - ref_area[progress_grid][curr_grid_ref][y_curr + block_i][grid_j + block_j]); curr_SSD_grid += (tmp*tmp); } #ifdef EARLY_TERMINATION if ((block_i%2)==0) { double R0,R1, R2; int U1; R0 = curr_SSD_grid; curr_SSD_grid1 = full_round(R0); R1 = (R0-curr_SSD_grid1)/__eps; U1 = full_round(R1); R2 = (R1-U1)/__eps; curr_SSD_grid2 = full_round(R2); if ( curr_SSD_grid1 + curr_SSD_grid2 > output.m_value ) { // the unpacked SSDs exceed the best--> terminate early_termination=1; break; } } #endif } #ifdef EARLY_TERMINATION if ( early_termination == 0 ) { output.m_value = curr_SSD_grid1 + curr_SSD_grid2; output.dest_x = x + x_curr - search_range; output.dest_y = y + y_curr - search_range; } #else double R0,R1, R2; int U1; R0 = curr_SSD_grid; curr_SSD_grid1 = full_round(R0); R1 = (R0-curr_SSD_grid1)/__eps; U1 = full_round(R1); R2 = (R1-U1)/__eps; curr_SSD_grid2 = full_round(R2); if ( curr_SSD_grid1 + curr_SSD_grid2 < output.m_value ) { output.m_value = curr_SSD_grid1 + curr_SSD_grid2; output.dest_x = x + x_curr - search_range; output.dest_y = y + y_curr - search_range; } #endif } } } } return 0; } // END IF step == 1; } // while (1) } void block_match_d_spiral(matrix ref_area, int w_ref_area, int h_ref_area, matrix block, int w_blk, int h_blk, int x, int y, int search_range, match& output, int spiral_size) { int r_area_size = search_range*2; int acc_t = 0; int acc = 0; int x_curr, y_curr; int x_pivot = search_range + (output.dest_x - output.src_x); int y_pivot = search_range + (output.dest_y - output.src_y); // look the center position first for (int n = 1; n <= h_blk; n++) // 0 -> h_blk - 1 { for (int m = 1; m <= w_blk; m++) // 0 -> w_blk - 1 { acc_t = ref_area[y_pivot + n][x_pivot + m] - block[n][m]; acc += (acc_t * acc_t); } } output.m_value = acc; // for each circle for (int sx = 1; sx <= spiral_size; sx++ ) { // for each side (4 sides!) for (int v = 0; v < 4; v++) { // for each elem for ( int idx = (1-sx) ; idx <= sx ; idx++ ) { switch (v) { case 0: y_curr = y_pivot + idx; x_curr = x_pivot + sx; break; case 1: y_curr = y_pivot + sx; x_curr = x_pivot - idx; break; case 2: y_curr = y_pivot - idx; x_curr = x_pivot - sx; break; case 3: y_curr = y_pivot - sx; x_curr = x_pivot + idx; break; } if ( x_curr >= 0 && y_curr >=0 && x_curr < r_area_size && y_curr < r_area_size ) { acc = 0; for (int n = 1; n <= h_blk; n++) // 0 -> h_blk - 1 { if ( acc >= output.m_value ) break; for (int m = 1; m <= w_blk; m++) // 0 -> w_blk - 1 { acc_t = ref_area[y_curr + n][x_curr + m] - block[n][m]; acc += (acc_t * acc_t); } } if ( acc < output.m_value ) { output.m_value = acc; output.dest_x = x_curr + x - search_range; output.dest_y = y_curr + y - search_range; } } } } } } /* void pick_best_and_store(matrix input, match& output, int x, int y, int search_range) { int mat_dim = (search_range*2)+1; output.src_x = x; output.src_y = y; output.m_value = INT_MAX; for (int i = 0; i < mat_dim; i++ ) // row { for (int j = 0; j < mat_dim; j++) // col { if ( input[i][j] < output.m_value ) { output.m_value = input[i][j]; output.dest_x = x - search_range + j; output.dest_y = y - search_range + i; } } } } */ /* void pick_best_and_store_bounded(matrix input, match& output, int x, int y, int search_range, int w_img, int h_img, int blk_size) { int mat_dim = (search_range*2)+1; output.src_x = x; output.src_y = y; output.m_value = INT_MAX; int x_base = x - search_range; int y_base = y - search_range; for (int i = 0; i < mat_dim; i++ ) // row { for (int j = 0; j < mat_dim; j++) // col { if ( input[i][j] < output.m_value ) { // min border if (y_base + i >= 0) if (x_base + j >= 0) if (x_base + j + blk_size <= w_img) if (y_base + i + blk_size <= h_img) { output.m_value = input[i][j]; output.dest_x = x_base + j; output.dest_y = y_base + i; } } } } } */ void pack_ref_area(matrix input, int elem, double**** output, int width, int height) { int jout; // [prog_i][grid_i][i][j] for (int i=1; i<=height; i++) { jout=1; for (int j=(2-(i%2)); j<=width; j+=2) { // 1,1 in Matlab output[0][0][i][jout]=input[i][j]; output[0][1][i][jout]=input[i][j]*__eps; jout++; } jout=1; for (int j=((i%2)+1); j<=width; j+=2) { // 2,1 in Matlab output[0][0][i][jout]+=input[i][j]*__eps; output[0][1][i][jout]+=input[i][j]; jout++; } jout=1; for (int j=(2+(i%2)); j<=width; j+=2) { // 1,2 in Matlab output[1][0][i][jout]=input[i][j]; output[1][1][i][jout]=input[i][j]*__eps; jout++; } jout=1; for (int j=(3-(i%2)); j<=width; j+=2) { // 2,2 in Matlab output[1][0][i][jout]+=input[i][j]*__eps; output[1][1][i][jout]+=input[i][j]; jout++; } } } void pack_block(matrix block, int elem, double** output, int width, int height) { int jout; for (int i=1; i<=height; i++) // row { jout=1; for (int j=(2-(i%2)); j<=width; j+=2) { output[i][jout]=block[i][j]; jout++; } jout=1; for (int j=((i%2)+1); j<=width; j+=2) { output[i][jout]+=block[i][j]*__eps; jout++; } //if ( i%2 == 0 ) { // output[i][j]= blocks[i][j] + eps*block[i][j+1]; //} else { // output[i][j]= blocks[i][j+1] + eps*block[i][j]; //} } } void unpack_matrix_and_store_d(double** input, matrix* output, int b_idx, int elem, int width, int height, int bitplane, int bits) { int tmp = 0; double ax = 0.0; int bx = 0; int shift = (bitplane - bits + 1)*2; for (int row = 0; row < height; row++) // row { for (int col = 0; col < width; col++) // col { if ( input[row][col] == MARKER ) { // it never happens with the new code output[b_idx][row][col] = INT_MAX; output[b_idx + 1][row][col] = INT_MAX; } else { ax = input[row][col]; bx = full_round(ax); output[b_idx][row][col] += (bx << shift); ax = (ax - bx)/(__eps); bx = full_round(ax); //output[b_idx + i][row][col] += (bx << shift); ax = (ax - bx)/(__eps); bx = full_round(ax); output[b_idx + 1][row][col] += (bx << shift); } } } } void write_block(matrix input, int width_b, int height_b, int x, int y, matrix output, int width, int height) { for (int i = 0; i < height_b; i++) for (int j = 0; j < width_b; j++) output[i+y][j+x] = input[i+1][j+1]; } void block_index_2_x_y(int blk_idx, int &x, int &y, int n_h_blocks, int block_size) { y = block_size*((blk_idx)/n_h_blocks); x = block_size*((blk_idx)%n_h_blocks); }
[ [ [ 1, 697 ] ] ]
c0b9f57dfe5f0907e98a36ec88cf5b9a1c2f5f17
1de469a75db091d9cd27bca397435b7843259c89
/npWinFormsHost/plugin.h
afb1c42064c8eb5b7c8d6270198b785b28079232
[]
no_license
xgc820313/npwinformhost
37fa2b05501e5c644778e9444f8d7eeade7d26b8
54c5dd6dec1a6f5a367ab10c8aa536387362157d
refs/heads/master
2020-06-02T08:17:28.194444
2009-08-02T01:12:34
2009-08-02T01:12:34
38,348,141
0
0
null
null
null
null
UTF-8
C++
false
false
2,671
h
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (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.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #ifndef __PLUGIN_H__ #define __PLUGIN_H__ #include "pluginbase.h" #include "nsScriptablePeer.h" class nsPluginInstance : public nsPluginInstanceBase { public: nsPluginInstance(NPP aInstance); ~nsPluginInstance(); NPBool init(NPWindow* aWindow); void shut(); NPBool isInitialized(); // we need to provide implementation of this method as it will be // used by Mozilla to retrieve the scriptable peer NPError GetValue(NPPVariable variable, void *value); // locals void showVersion(); void clear(); nsScriptablePeer* getScriptablePeer(); void SetUserControl(System::Windows::Forms::UserControl^ usrCtr); private: NPP mInstance; NPBool mInitialized; HWND mhWnd; nsScriptablePeer * mScriptablePeer; WNDPROC lpOldProc; public: char mString[128]; }; #endif // __PLUGIN_H__
[ "mendoza.ivan@acbfbcf6-3f1b-11de-be05-5f7a86268029" ]
[ [ [ 1, 77 ] ] ]
86b639801e64961681801847e17cd72f82ecdbab
629e4fdc23cb90c0144457e994d1cbb7c6ab8a93
/lib/dio/textfiledio.h
883cf74297c1be17c6f75ccf9f6bb9d570bc4b63
[]
no_license
akin666/ice
4ed846b83bcdbd341b286cd36d1ef5b8dc3c0bf2
7cfd26a246f13675e3057ff226c17d95a958d465
refs/heads/master
2022-11-06T23:51:57.273730
2011-12-06T22:32:53
2011-12-06T22:32:53
276,095,011
0
0
null
null
null
null
UTF-8
C++
false
false
2,253
h
/* * TextFileDIO.h * * Created on: 6.3.2011 * Author: akin */ #ifndef ICE_TEXTFILEDIO_H_ #define ICE_TEXTFILEDIO_H_ #include "dio" #include <fstream> namespace ice { class TextFileDIO : public DIO { protected: std::fstream stream; public: TextFileDIO(); TextFileDIO( std::string path ) throw (DIOException); virtual ~TextFileDIO(); void open( std::string path ) throw (DIOException); virtual void readNext(); virtual bool empty(); virtual bool isOk(); virtual void close(); virtual void refresh(); virtual void lock(); virtual void unlock(); virtual unsigned int getDataSize(); virtual int getPosition() throw (DIOException); virtual void setPosition( int position ) throw (DIOException); virtual void forward( int position ) throw (DIOException); virtual void backward( int position ) throw (DIOException); virtual void read( float& arg ) throw (DIOException); virtual void read( char& arg ) throw (DIOException); virtual void read( unsigned char& arg ) throw (DIOException); virtual void read( int& arg ) throw (DIOException); virtual void read( unsigned int& arg ) throw (DIOException); virtual void read( bool& arg ) throw (DIOException); virtual void read( std::string& arg ) throw (DIOException); virtual void readLine( std::string& arg ) throw (DIOException); virtual unsigned int readBlock( unsigned char *buffer , unsigned int byte_count ) throw (DIOException); virtual void writeFloat( const float& arg ) throw (DIOException); virtual void writeByte( const char& arg ) throw (DIOException); virtual void writeByte( const unsigned char& arg ) throw (DIOException); virtual void writeInt( const int& arg ) throw (DIOException); virtual void writeUnsignedInt( const unsigned int& arg ) throw (DIOException); virtual void writeBool( const bool& arg ) throw (DIOException); virtual void writeString( const std::string& arg ) throw (DIOException); virtual void writeLine( const std::string& arg ) throw (DIOException); virtual unsigned int writeBlock( const unsigned char *buffer , unsigned int byte_count ) throw (DIOException); }; } #endif /* TEXTFILEDIO_H_ */
[ "akin@lich", "akin@localhost" ]
[ [ [ 1, 7 ], [ 10, 10 ], [ 12, 21 ], [ 23, 24 ], [ 26, 39 ], [ 68, 71 ] ], [ [ 8, 9 ], [ 11, 11 ], [ 22, 22 ], [ 25, 25 ], [ 40, 67 ] ] ]
32dacb620a0bdc4dc2f26b21e6a1101110c8af76
f95341dd85222aa39eaa225262234353f38f6f97
/DesktopX/Plugins/DXCanvas/Sources/CanvasShadow.cpp
d8ed649f0d654219ad56eed59ea326d4691a0bad
[]
no_license
Templier/threeoaks
367b1a0a45596b8fe3607be747b0d0e475fa1df2
5091c0f54bd0a1b160ddca65a5e88286981c8794
refs/heads/master
2020-06-03T11:08:23.458450
2011-10-31T04:33:20
2011-10-31T04:33:20
32,111,618
0
0
null
null
null
null
UTF-8
C++
false
false
8,200
cpp
/////////////////////////////////////////////////////////////////////////////////////////////// // // Canvas Plugin for DesktopX // // Copyright (c) 2008-2010, Julien Templier // All rights reserved. // /////////////////////////////////////////////////////////////////////////////////////////////// // * $LastChangedRevision$ // * $LastChangedDate$ // * $LastChangedBy$ /////////////////////////////////////////////////////////////////////////////////////////////// // // Uses code from Mozilla (see Readme and licence folder) // /////////////////////////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #define _USE_MATH_DEFINES #include <math.h> #include "CanvasShadow.h" const float CanvasShadow::MAX_SIGMA = 35; // Blur radius is approximately 3/2 times the box-blur size const float CanvasShadow::GAUSSIAN_SCALE_FACTOR = (3 * sqrt(2 * (float)M_PI) / 4) * (3/2); cairo_t* CanvasShadow::getContext(cairo_t* ctx, CanvasState* state, EXTENTS_RECT extents) { // Store values originalContext = ctx; this->extents = extents; this->state = state; // Calculate standard deviation for Gaussian blur if (state->currentState().shadowBlur < 8) sigma = state->currentState().shadowBlur / 2; else sigma = sqrt(state->currentState().shadowBlur); // Clamp sigma if (sigma > MAX_SIGMA) sigma = MAX_SIGMA; blurRadius = (int)floor(sigma*GAUSSIAN_SCALE_FACTOR + 0.5); // Add blur area to extents rectangle extents.x1 -= blurRadius; extents.y1 -= blurRadius; extents.x2 += blurRadius; extents.y2 += blurRadius; // Initialize our surface surface = cairo_image_surface_create(CAIRO_FORMAT_A8, (int)abs(extents.x2-extents.x1), (int)abs(extents.y2-extents.y1)); if (cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) { surface = NULL; return NULL; } // Use a device offset so callers don't need to worry about translating // coordinates, they can draw as if this was part of the destination context // at the coordinates of rect. cairo_surface_set_device_offset(surface, -extents.x1, -extents.y1); context = cairo_create(surface); if (cairo_status(context) != CAIRO_STATUS_SUCCESS) { context = NULL; return NULL; } // Copy the original context data to our new context copyContext(); cairo_set_operator(context, CAIRO_OPERATOR_SOURCE); return context; } void CanvasShadow::draw() { #ifdef DEBUG _ASSERT(context != NULL); _ASSERT(surface != NULL); #endif // check that we have been initialized properly if (!context || !surface) return; // Save the current context matrix and set the context for drawing the shadow cairo_matrix_t savedMatrix; cairo_get_matrix(originalContext, &savedMatrix); cairo_identity_matrix(originalContext); cairo_translate(originalContext, state->currentState().shadowOffsetX, state->currentState().shadowOffsetY); // draw the shadow if (blurRadius != 0) applyBlur(); cairo_mask_surface(originalContext, surface, 0, 0); cairo_set_matrix(originalContext, &savedMatrix); // Cleanup the context and surface cairo_destroy(context); cairo_surface_destroy(surface); context = NULL; surface = NULL; } ////////////////////////////////////////////////////////////////////////// // Utils bool CanvasShadow::copyContext() { if (context == NULL || originalContext == NULL) return false; // Apply the original matrix cairo_matrix_t originalMatrix; cairo_get_matrix(originalContext, &originalMatrix); cairo_transform(context, &originalMatrix); // Add the path cairo_path_t* originalPath = cairo_copy_path(originalContext); cairo_new_path(context); cairo_append_path(context, originalPath); cairo_path_destroy(originalPath); // Get patterns if any cairo_pattern_t* originalPattern = cairo_get_source(originalContext); cairo_pattern_t* pattern; if (originalPattern) pattern = cairo_pattern_reference(originalPattern); else pattern = cairo_pattern_create_rgba(0, 0, 0, 0); cairo_set_source(context, pattern); // Apply current status cairo_set_line_width(context, cairo_get_line_width(originalContext)); cairo_set_line_cap(context, cairo_get_line_cap(originalContext)); cairo_set_line_join(context, cairo_get_line_join(originalContext)); cairo_set_miter_limit(context, cairo_get_miter_limit(originalContext)); cairo_set_fill_rule(context, cairo_get_fill_rule(originalContext)); return true; } // Apply the blur void CanvasShadow::applyBlur() { // Blur radius must be > 2 blurRadius = max(blurRadius, 2); unsigned char* buffer = cairo_image_surface_get_data(surface); int stride = cairo_image_surface_get_stride(surface); int rows = cairo_image_surface_get_height(surface); // Create temporary buffer unsigned char* tempBuffer = (unsigned char*) calloc((size_t)(stride * rows), sizeof(char)); if (tempBuffer == NULL) return; // Computes lobes int lobes[3][2]; computeLobes(blurRadius, lobes); blur(buffer, tempBuffer, HORIZONTAL, lobes[0][0], lobes[0][1], stride, rows); blur(tempBuffer, buffer, HORIZONTAL, lobes[1][0], lobes[1][1], stride, rows); blur(buffer, tempBuffer, HORIZONTAL, lobes[2][0], lobes[2][1], stride, rows); blur(tempBuffer, buffer, VERTICAL, lobes[0][0], lobes[0][1], stride, rows); blur(buffer, tempBuffer, VERTICAL, lobes[1][0], lobes[1][1], stride, rows); blur(tempBuffer, buffer, VERTICAL, lobes[2][0], lobes[2][1], stride, rows); free(tempBuffer); } void CanvasShadow::blur(unsigned char* input, unsigned char* output, Direction direction, int leftLobe, int rightLobe, int stride, int rows) { int boxSize = leftLobe + rightLobe + 1; if (direction == HORIZONTAL) { for (int y = 0; y < rows; y++) { int sum = 0; for (int i = 0; i < boxSize; i++) { int pos = i - leftLobe; pos = max(pos, 0); pos = min(pos, stride - 1); sum += input[stride * y + pos]; } for (int x = 0; x < stride; x++) { int tmp = x - leftLobe; int last = max(tmp, 0); int next = min(tmp + boxSize, stride - 1); output[stride * y + x] = (unsigned char)(sum/boxSize); sum += input[stride * y + next] - input[stride * y + last]; } } } else { for (int x = 0; x < stride; x++) { int sum = 0; for (int i = 0; i < boxSize; i++) { int pos = i - leftLobe; // top lobe pos = max(pos, 0); pos = min(pos, rows - 1); sum += input[stride * pos + x]; } for (int y = 0; y < rows; y++) { int tmp = y - rightLobe; // bottom lobe int last = max(tmp, 0); int next = min(tmp + boxSize, rows - 1); output[stride * y + x] = (unsigned char)(sum/boxSize); sum += input[stride * next + x] - input[stride * last + x]; } } } } void CanvasShadow::computeLobes(int radius, int lobes[3][2]) { int major = 0, minor = 0, final = 0; /* See http://www.w3.org/TR/SVG/filters.html#feGaussianBlur for * some notes about approximating the Gaussian blur with box-blurs. * The comments below are in the terminology of that page. */ int z = radius/3; switch (radius % 3) { case 0: // aRadius = z*3; choose d = 2*z + 1 major = minor = final = z; break; case 1: // aRadius = z*3 + 1 // This is a tricky case since there is no value of d which will // yield a radius of exactly aRadius. If d is odd, i.e. d=2*k + 1 // for some integer k, then the radius will be 3*k. If d is even, // i.e. d=2*k, then the radius will be 3*k - 1. // So we have to choose values that don't match the standard // algorithm. major = z + 1; minor = final = z; break; case 2: // aRadius = z*3 + 2; choose d = 2*z + 2 major = final = z + 1; minor = z; break; } #ifdef DEBUG // Lobes should sum to the right length _ASSERT_EXPR((major + minor + final == radius), L"Lobes should sum to the right length"); #endif lobes[0][0] = major; lobes[0][1] = minor; lobes[1][0] = minor; lobes[1][1] = major; lobes[2][0] = final; lobes[2][1] = final; }
[ "julien.templier@ab80709b-eb45-0410-bb3a-633ce738720d" ]
[ [ [ 1, 282 ] ] ]
cfb0f82447941b722042b7d003aa79f06e09accb
867f5533667cce30d0743d5bea6b0c083c073386
/jingxian-network/src/jingxian/connection_functionals.h
cfdc39ffaf727b84dd145740ea946fe9da033faf
[]
no_license
mei-rune/jingxian-project
32804e0fa82f3f9a38f79e9a99c4645b9256e889
47bc7a2cb51fa0d85279f46207f6d7bea57f9e19
refs/heads/master
2022-08-12T18:43:37.139637
2009-12-11T09:30:04
2009-12-11T09:30:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
44,591
h
#ifndef __connection_base_h_ #define __connection_base_h_ #include "jingxian/config.h" #if !defined (JINGXIAN_LACKS_PRAGMA_ONCE) # pragma once #endif /* JINGXIAN_LACKS_PRAGMA_ONCE */ // Include files #include <list> #ifndef LOCK #define LOCK() #endif template<class T> class _connection_base { public: virtual ~_connection_base() {} }; template<> class _connection_base<void ()> { public: virtual ~_connection_base() {} virtual void call() = 0; }; template<typename result_type> class _connection_base<result_type ()> { public: virtual ~_connection_base() {} virtual result_type call() = 0; }; template<typename arg1_type> class _connection_base<void (arg1_type)> { public: virtual ~_connection_base() {} virtual void call(arg1_type) = 0; }; template<typename result_type, typename arg1_type> class _connection_base<result_type (arg1_type)> { public: virtual ~_connection_base() {} virtual result_type call(arg1_type) = 0; }; template<class arg1_type, class arg2_type> class _connection_base<void (arg1_type, arg2_type)> { public: virtual ~_connection_base() {} virtual void call(arg1_type, arg2_type) = 0; }; template<typename result_type, class arg1_type, class arg2_type> class _connection_base<result_type (arg1_type, arg2_type)> { public: virtual ~_connection_base() {} virtual result_type call(arg1_type, arg2_type) = 0; }; template<class arg1_type, class arg2_type, class arg3_type> class _connection_base<void (arg1_type, arg2_type, arg3_type)> { public: virtual ~_connection_base() {} virtual void call(arg1_type, arg2_type, arg3_type) = 0; }; template<typename result_type, class arg1_type, class arg2_type, class arg3_type> class _connection_base<result_type (arg1_type, arg2_type, arg3_type)> { public: virtual ~_connection_base() {} virtual result_type call(arg1_type, arg2_type, arg3_type) = 0; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type> class _connection_base<void (arg1_type, arg2_type, arg3_type, arg4_type)> { public: virtual ~_connection_base() {} virtual void call(arg1_type, arg2_type, arg3_type, arg4_type) = 0; }; template<typename result_type, class arg1_type, class arg2_type, class arg3_type, class arg4_type> class _connection_base<result_type (arg1_type, arg2_type, arg3_type, arg4_type)> { public: virtual ~_connection_base() {} virtual result_type call(arg1_type, arg2_type, arg3_type, arg4_type) = 0; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type> class _connection_base<void (arg1_type, arg2_type, arg3_type, arg4_type, arg5_type)> { public: virtual ~_connection_base() {} virtual void call(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type) = 0; }; template<typename result_type, class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type> class _connection_base<result_type (arg1_type, arg2_type, arg3_type, arg4_type, arg5_type)> { public: virtual ~_connection_base() {} virtual result_type call(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type) = 0; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class arg6_type> class _connection_base<void (arg1_type, arg2_type, arg3_type, arg4_type , arg5_type, arg6_type)> { public: virtual ~_connection_base() {} virtual void call(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type) = 0; }; template<typename result_type, class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class arg6_type> class _connection_base<result_type (arg1_type, arg2_type, arg3_type, arg4_type , arg5_type, arg6_type)> { public: virtual ~_connection_base() {} virtual result_type call(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type) = 0; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class arg6_type, class arg7_type> class _connection_base<void (arg1_type, arg2_type, arg3_type, arg4_type , arg5_type, arg6_type, arg7_type)> { public: virtual ~_connection_base() {} virtual void call(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type) = 0; }; template<typename result_type, class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class arg6_type, class arg7_type> class _connection_base<result_type (arg1_type, arg2_type, arg3_type, arg4_type , arg5_type, arg6_type, arg7_type)> { public: virtual ~_connection_base() {} virtual result_type call(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type) = 0; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class arg6_type, class arg7_type, class arg8_type> class _connection_base<void (arg1_type, arg2_type, arg3_type, arg4_type , arg5_type, arg6_type, arg7_type, arg8_type)> { public: virtual ~_connection_base() {} virtual void call(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type) = 0; }; template<typename result_type, class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class arg6_type, class arg7_type, class arg8_type> class _connection_base<result_type (arg1_type, arg2_type, arg3_type, arg4_type , arg5_type, arg6_type, arg7_type, arg8_type)> { public: virtual ~_connection_base() {} virtual result_type call(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type) = 0; }; template<class dest_type, class args_type> class _connection : public _connection_base<args_type> { public: }; template<class dest_type> class _connection<dest_type, void ()> : public _connection_base<void ()> { public: _connection() : m_pobject(NULL) , m_pmemfun(NULL) { } _connection(dest_type* pobject, void (dest_type::*pmemfun)()) : m_pobject(pobject) , m_pmemfun(pmemfun) { } virtual ~_connection() { } virtual void call() { (m_pobject->*m_pmemfun)(); } private: dest_type* m_pobject; void (dest_type::* m_pmemfun)(); }; template<class dest_type, class result_type> class _connection<dest_type, result_type ()> : public _connection_base<result_type ()> { public: _connection() : m_pobject(NULL) , m_pmemfun(NULL) { } _connection(dest_type* pobject, result_type (dest_type::*pmemfun)()) : m_pobject(pobject) , m_pmemfun(pmemfun) { } virtual ~_connection() { } virtual result_type call() { return (m_pobject->*m_pmemfun)(); } private: dest_type* m_pobject; result_type (dest_type::* m_pmemfun)(); }; template<class dest_type, class arg1_type> class _connection<dest_type, void (arg1_type)> : public _connection_base<void (arg1_type)> { public: _connection() :m_pobject(NULL) ,m_pmemfun(NULL) { } _connection(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type)) : m_pobject(pobject) , m_pmemfun(pmemfun) { } virtual ~_connection() { } virtual void call(arg1_type a1) { (m_pobject->*m_pmemfun)(a1); } private: dest_type* m_pobject; void (dest_type::* m_pmemfun)(arg1_type); }; template<class dest_type, class result_type, class arg1_type> class _connection<dest_type, result_type (arg1_type)> : public _connection_base<result_type (arg1_type)> { public: _connection() :m_pobject(NULL) ,m_pmemfun(NULL) { } _connection(dest_type* pobject, result_type (dest_type::*pmemfun)(arg1_type)) : m_pobject(pobject) , m_pmemfun(pmemfun) { } virtual ~_connection() { } virtual result_type call(arg1_type a1) { return (m_pobject->*m_pmemfun)(a1); } private: dest_type* m_pobject; result_type (dest_type::* m_pmemfun)(arg1_type); }; template<class dest_type, class arg1_type, class arg2_type> class _connection<dest_type, void (arg1_type, arg2_type)> : public _connection_base<void (arg1_type, arg2_type)> { public: _connection() :m_pobject(NULL) ,m_pmemfun(NULL) { } _connection(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, arg2_type)) : m_pobject(pobject) , m_pmemfun(pmemfun) { } virtual ~_connection() { } virtual void call(arg1_type a1, arg2_type a2) { (m_pobject->*m_pmemfun)(a1, a2); } private: dest_type* m_pobject; void (dest_type::* m_pmemfun)(arg1_type, arg2_type); }; template<class dest_type, class result_type, class arg1_type, class arg2_type> class _connection<dest_type, result_type (arg1_type, arg2_type)> : public _connection_base<result_type (arg1_type, arg2_type)> { public: _connection() :m_pobject(NULL) ,m_pmemfun(NULL) { } _connection(dest_type* pobject, result_type (dest_type::*pmemfun)(arg1_type, arg2_type)) : m_pobject(pobject) , m_pmemfun(pmemfun) { } virtual ~_connection() { } virtual result_type call(arg1_type a1, arg2_type a2) { return (m_pobject->*m_pmemfun)(a1, a2); } private: dest_type* m_pobject; result_type (dest_type::* m_pmemfun)(arg1_type, arg2_type); }; template<class dest_type, class arg1_type, class arg2_type, class arg3_type> class _connection<dest_type, void (arg1_type, arg2_type, arg3_type)> : public _connection_base<void (arg1_type, arg2_type, arg3_type)> { public: _connection() :m_pobject(NULL) ,m_pmemfun(NULL) { } _connection(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, arg2_type, arg3_type)) : m_pobject(pobject) , m_pmemfun(pmemfun) { } virtual ~_connection() { } virtual void call(arg1_type a1, arg2_type a2, arg3_type a3) { (m_pobject->*m_pmemfun)(a1, a2, a3); } private: dest_type* m_pobject; void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type); }; template<class dest_type, class result_type, class arg1_type, class arg2_type, class arg3_type> class _connection<dest_type, result_type (arg1_type, arg2_type, arg3_type)> : public _connection_base<result_type (arg1_type, arg2_type, arg3_type)> { public: _connection() :m_pobject(NULL) ,m_pmemfun(NULL) { } _connection(dest_type* pobject, result_type (dest_type::*pmemfun)(arg1_type, arg2_type, arg3_type)) : m_pobject(pobject) , m_pmemfun(pmemfun) { } virtual ~_connection() { } virtual result_type call(arg1_type a1, arg2_type a2, arg3_type a3) { return (m_pobject->*m_pmemfun)(a1, a2, a3); } private: dest_type* m_pobject; result_type (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type); }; template<class dest_type, class arg1_type, class arg2_type , class arg3_type, class arg4_type> class _connection<dest_type, void (arg1_type, arg2_type, arg3_type, arg4_type)> : public _connection_base<void (arg1_type, arg2_type, arg3_type, arg4_type)> { public: _connection() :m_pobject(NULL) ,m_pmemfun(NULL) { } _connection(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type)) : m_pobject(pobject) , m_pmemfun(pmemfun) { } virtual ~_connection() { } virtual void call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) { (m_pobject->*m_pmemfun)(a1, a2, a3, a4); } private: dest_type* m_pobject; void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type); }; template<class dest_type, class result_type, class arg1_type, class arg2_type , class arg3_type, class arg4_type> class _connection<dest_type, result_type (arg1_type, arg2_type, arg3_type, arg4_type)> : public _connection_base<result_type (arg1_type, arg2_type, arg3_type, arg4_type)> { public: _connection() :m_pobject(NULL) ,m_pmemfun(NULL) { } _connection(dest_type* pobject, result_type (dest_type::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type)) : m_pobject(pobject) , m_pmemfun(pmemfun) { } virtual ~_connection() { } virtual result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) { return (m_pobject->*m_pmemfun)(a1, a2, a3, a4); } private: dest_type* m_pobject; result_type (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type); }; template<class dest_type, class arg1_type, class arg2_type , class arg3_type, class arg4_type, class arg5_type> class _connection<dest_type, void (arg1_type, arg2_type, arg3_type , arg4_type, arg5_type)> : public _connection_base<void (arg1_type, arg2_type, arg3_type , arg4_type, arg5_type)> { public: _connection() :m_pobject(NULL) ,m_pmemfun(NULL) { } _connection(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type)) : m_pobject(pobject) , m_pmemfun(pmemfun) { } virtual ~_connection() { } virtual void call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5) { (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5); } private: dest_type* m_pobject; void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type); }; template<class dest_type, class result_type, class arg1_type, class arg2_type , class arg3_type, class arg4_type, class arg5_type> class _connection<dest_type, result_type (arg1_type, arg2_type, arg3_type , arg4_type, arg5_type)> : public _connection_base<result_type (arg1_type, arg2_type, arg3_type , arg4_type, arg5_type)> { public: _connection() :m_pobject(NULL) ,m_pmemfun(NULL) { } _connection(dest_type* pobject, result_type (dest_type::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type)) : m_pobject(pobject) , m_pmemfun(pmemfun) { } virtual ~_connection() { } virtual result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5) { return (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5); } private: dest_type* m_pobject; result_type (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type); }; template<class dest_type, class arg1_type, class arg2_type , class arg3_type, class arg4_type, class arg5_type, class arg6_type> class _connection<dest_type, void (arg1_type, arg2_type, arg3_type , arg4_type, arg5_type, arg6_type)> : public _connection_base<void (arg1_type, arg2_type, arg3_type , arg4_type, arg5_type, arg6_type)> { public: _connection() :m_pobject(NULL) ,m_pmemfun(NULL) { } _connection(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type)) : m_pobject(pobject) , m_pmemfun(pmemfun) { } virtual ~_connection() { } virtual void call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6) { (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6); } private: dest_type* m_pobject; void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type); }; template<class dest_type, class result_type, class arg1_type, class arg2_type , class arg3_type, class arg4_type, class arg5_type, class arg6_type> class _connection<dest_type, result_type (arg1_type, arg2_type, arg3_type , arg4_type, arg5_type, arg6_type)> : public _connection_base<result_type (arg1_type, arg2_type, arg3_type , arg4_type, arg5_type, arg6_type)> { public: _connection() :m_pobject(NULL) ,m_pmemfun(NULL) { } _connection(dest_type* pobject, result_type (dest_type::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type)) : m_pobject(pobject) , m_pmemfun(pmemfun) { } virtual ~_connection() { } virtual result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6) { return (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6); } private: dest_type* m_pobject; result_type (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type); }; template<class dest_type, class arg1_type, class arg2_type , class arg3_type, class arg4_type, class arg5_type, class arg6_type , class arg7_type> class _connection<dest_type, void (arg1_type, arg2_type, arg3_type , arg4_type, arg5_type, arg6_type, arg7_type)> : public _connection_base<void (arg1_type, arg2_type, arg3_type , arg4_type, arg5_type, arg6_type, arg7_type)> { public: _connection() :m_pobject(NULL) ,m_pmemfun(NULL) { } _connection(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type)) : m_pobject(pobject) , m_pmemfun(pmemfun) { } virtual ~_connection() { } virtual void call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7) { (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6, a7); } private: dest_type* m_pobject; void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type); }; template<class dest_type, class result_type, class arg1_type, class arg2_type , class arg3_type, class arg4_type, class arg5_type, class arg6_type , class arg7_type> class _connection<dest_type, result_type (arg1_type, arg2_type, arg3_type , arg4_type, arg5_type, arg6_type, arg7_type)> : public _connection_base<result_type (arg1_type, arg2_type, arg3_type , arg4_type, arg5_type, arg6_type, arg7_type)> { public: _connection() :m_pobject(NULL) ,m_pmemfun(NULL) { } _connection(dest_type* pobject, result_type (dest_type::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type)) : m_pobject(pobject) , m_pmemfun(pmemfun) { } virtual ~_connection() { } virtual result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7) { return (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6, a7); } private: dest_type* m_pobject; result_type (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type); }; template<class dest_type, class arg1_type, class arg2_type , class arg3_type, class arg4_type, class arg5_type, class arg6_type , class arg7_type, class arg8_type> class _connection<dest_type, void (arg1_type, arg2_type, arg3_type , arg4_type, arg5_type, arg6_type, arg7_type, arg8_type)> : public _connection_base<void (arg1_type, arg2_type, arg3_type , arg4_type, arg5_type, arg6_type, arg7_type, arg8_type)> { public: _connection() :m_pobject(NULL) ,m_pmemfun(NULL) { } _connection(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type)) : m_pobject(pobject) , m_pmemfun(pmemfun) { } virtual ~_connection() { } virtual void call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8) { (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6, a7, a8); } private: dest_type* m_pobject; void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type); }; template<class dest_type, class result_type, class arg1_type, class arg2_type , class arg3_type, class arg4_type, class arg5_type, class arg6_type , class arg7_type, class arg8_type> class _connection<dest_type, result_type (arg1_type, arg2_type, arg3_type , arg4_type, arg5_type, arg6_type, arg7_type, arg8_type)> : public _connection_base<result_type (arg1_type, arg2_type, arg3_type , arg4_type, arg5_type, arg6_type, arg7_type, arg8_type)> { public: _connection() :m_pobject(NULL) ,m_pmemfun(NULL) { } _connection(dest_type* pobject, result_type (dest_type::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type)) : m_pobject(pobject) , m_pmemfun(pmemfun) { } virtual ~_connection() { } virtual result_type call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8) { return (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6, a7, a8); } private: dest_type* m_pobject; result_type (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type); }; template<class T> class signal { }; template<> class signal<void ()> : public _connection_base<void ()> { public: typedef signal<void ()> this_type; typedef _connection_base<void ()> function_type; typedef std::list<function_type *> connections_list; typedef std::list<this_type *> signal_list; signal() { } virtual ~signal() { disconnect_all(); } void disconnect_all() { LOCK(); for (connections_list::iterator it = m_owner_slots.begin() ; it != m_owner_slots.end(); ++ it) { delete (*it); } m_owner_slots.clear(); m_slots.clear(); } void connect(function_type& connection) { LOCK(); m_slots.push_back(&connection); } void disconnect(function_type& connection) { LOCK(); m_slots.remove(&connection); } template<class desttype> void connect(desttype* pclass, void (desttype::*pmemfun)()) { LOCK(); _connection<desttype, void ()>* conn = new _connection<desttype, void ()>(pclass, pmemfun); m_owner_slots.push_back(conn); } void call() { LOCK(); connections_list::const_iterator itNext, it = m_owner_slots.begin(); connections_list::const_iterator itEnd = m_owner_slots.end(); while (it != itEnd) { itNext = it; ++itNext; (*it)->call(); it = itNext; } it = m_slots.begin(); itEnd = m_slots.end(); while (it != itEnd) { itNext = it; ++itNext; (*it)->call(); it = itNext; } } void operator()() { this->call(); } protected: connections_list m_owner_slots; connections_list m_slots; }; template<typename arg1_type> class signal<void (arg1_type)> : public _connection_base<void (arg1_type)> { public: typedef signal<void (arg1_type)> this_type; typedef _connection_base<void (arg1_type)> function_type; typedef std::list<function_type *> connections_list; typedef std::list<this_type *> signal_list; signal() { } virtual ~signal() { disconnect_all(); } void disconnect_all() { LOCK(); for (connections_list::iterator it = m_owner_slots.begin() ; it != m_owner_slots.end(); ++ it) { delete (*it); } m_owner_slots.clear(); m_slots.clear(); } void connect(function_type& connection) { LOCK(); m_slots.push_back(&connection); } void disconnect(function_type& connection) { LOCK(); m_slots.remove(&connection); } template<class desttype> void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type)) { LOCK(); _connection<desttype, void (arg1_type)>* conn = new _connection<desttype, void (arg1_type)>(pclass, pmemfun); m_owner_slots.push_back(conn); } void call(arg1_type a1) { LOCK(); connections_list::const_iterator itNext, it = m_owner_slots.begin(); connections_list::const_iterator itEnd = m_owner_slots.end(); while (it != itEnd) { itNext = it; ++itNext; (*it)->call(a1); it = itNext; } it = m_slots.begin(); itEnd = m_slots.end(); while (it != itEnd) { itNext = it; ++itNext; (*it)->call(a1); it = itNext; } } void operator()(arg1_type a1) { this->call(a1); } protected: connections_list m_owner_slots; connections_list m_slots; }; template<class arg1_type, class arg2_type> class signal<void (arg1_type, arg2_type)> : public _connection_base<void (arg1_type, arg2_type)> { public: typedef signal<void (arg1_type, arg2_type)> this_type; typedef _connection_base<void (arg1_type, arg2_type)> function_type; typedef std::list<function_type *> connections_list; typedef std::list<this_type *> signal_list; signal() { } virtual ~signal() { disconnect_all(); } void disconnect_all() { LOCK(); for (connections_list::iterator it = m_owner_slots.begin() ; it != m_owner_slots.end(); ++ it) { delete (*it); } m_owner_slots.clear(); m_slots.clear(); } void connect(function_type& connection) { LOCK(); m_slots.push_back(&connection); } void disconnect(function_type& connection) { LOCK(); m_slots.remove(&connection); } template<class desttype> void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, arg2_type)) { LOCK(); _connection<desttype, void (arg1_type, arg2_type)>* conn = new _connection<desttype, void (arg1_type, arg2_type)>(pclass, pmemfun); m_owner_slots.push_back(conn); } void call(arg1_type a1, arg2_type a2) { LOCK(); connections_list::const_iterator itNext, it = m_owner_slots.begin(); connections_list::const_iterator itEnd = m_owner_slots.end(); while (it != itEnd) { itNext = it; ++itNext; (*it)->call(a1, a2); it = itNext; } it = m_slots.begin(); itEnd = m_slots.end(); while (it != itEnd) { itNext = it; ++itNext; (*it)->call(a1, a2); it = itNext; } } void operator()(arg1_type a1, arg2_type a2) { this->call(a1, a2); } protected: connections_list m_owner_slots; connections_list m_slots; }; template<class arg1_type, class arg2_type, class arg3_type> class signal<void (arg1_type, arg2_type, arg3_type)> : public _connection_base<void (arg1_type, arg2_type, arg3_type)> { public: typedef signal<void (arg1_type, arg2_type, arg3_type)> this_type; typedef _connection_base<void (arg1_type, arg2_type, arg3_type)> function_type; typedef std::list<function_type *> connections_list; typedef std::list<this_type *> signal_list; signal() { } virtual ~signal() { disconnect_all(); } void disconnect_all() { LOCK(); for (connections_list::iterator it = m_owner_slots.begin() ; it != m_owner_slots.end(); ++ it) { delete (*it); } m_owner_slots.clear(); m_slots.clear(); } void connect(function_type& connection) { LOCK(); m_slots.push_back(&connection); } void disconnect(function_type& connection) { LOCK(); m_slots.remove(&connection); } template<class desttype> void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, arg2_type, arg3_type)) { LOCK(); _connection<desttype, void (arg1_type, arg2_type, arg3_type)>* conn = new _connection<desttype, void (arg1_type, arg2_type, arg3_type)>(pclass, pmemfun); m_owner_slots.push_back(conn); } void call(arg1_type a1, arg2_type a2, arg3_type a3) { LOCK(); connections_list::const_iterator itNext, it = m_owner_slots.begin(); connections_list::const_iterator itEnd = m_owner_slots.end(); while (it != itEnd) { itNext = it; ++itNext; (*it)->call(a1, a2, a3); it = itNext; } it = m_slots.begin(); itEnd = m_slots.end(); while (it != itEnd) { itNext = it; ++itNext; (*it)->call(a1, a2, a3); it = itNext; } } void operator()(arg1_type a1, arg2_type a2, arg3_type a3) { this->call(a1, a2, a3); } protected: connections_list m_owner_slots; connections_list m_slots; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type> class signal<void (arg1_type, arg2_type, arg3_type, arg4_type)> : public _connection_base<void (arg1_type, arg2_type, arg3_type, arg4_type)> { public: typedef signal<void (arg1_type, arg2_type, arg3_type, arg4_type)> this_type; typedef _connection_base<void (arg1_type, arg2_type, arg3_type, arg4_type)> function_type; typedef std::list<function_type *> connections_list; typedef std::list<this_type *> signal_list; signal() { } virtual ~signal() { disconnect_all(); } void disconnect_all() { LOCK(); for (connections_list::iterator it = m_owner_slots.begin() ; it != m_owner_slots.end(); ++ it) { delete (*it); } m_owner_slots.clear(); m_slots.clear(); } void connect(function_type& connection) { LOCK(); m_slots.push_back(&connection); } void disconnect(function_type& connection) { LOCK(); m_slots.remove(&connection); } template<class desttype> void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type)) { LOCK(); _connection<desttype, void (arg1_type, arg2_type, arg3_type, arg4_type)>* conn = new _connection<desttype, void (arg1_type, arg2_type, arg3_type , arg4_type)>(pclass, pmemfun); m_owner_slots.push_back(conn); } void call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) { LOCK(); connections_list::const_iterator itNext, it = m_owner_slots.begin(); connections_list::const_iterator itEnd = m_owner_slots.end(); while (it != itEnd) { itNext = it; ++itNext; (*it)->call(a1, a2, a3, a4); it = itNext; } it = m_slots.begin(); itEnd = m_slots.end(); while (it != itEnd) { itNext = it; ++itNext; (*it)->call(a1, a2, a3, a4); it = itNext; } } void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) { this->call(a1, a2, a3, a4); } protected: connections_list m_owner_slots; connections_list m_slots; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type> class signal<void (arg1_type, arg2_type, arg3_type, arg4_type, arg5_type)> : public _connection_base<void (arg1_type, arg2_type, arg3_type, arg4_type, arg5_type)> { public: typedef signal<void (arg1_type, arg2_type, arg3_type, arg4_type, arg5_type)> this_type; typedef _connection_base<void (arg1_type, arg2_type, arg3_type, arg4_type, arg5_type)> function_type; typedef std::list<function_type *> connections_list; typedef std::list<this_type *> signal_list; signal() { } virtual ~signal() { disconnect_all(); } void disconnect_all() { LOCK(); for (connections_list::iterator it = m_owner_slots.begin() ; it != m_owner_slots.end(); ++ it) { delete (*it); } m_owner_slots.clear(); m_slots.clear(); } void connect(function_type& connection) { LOCK(); m_slots.push_back(&connection); } void disconnect(function_type& connection) { LOCK(); m_slots.remove(&connection); } template<class desttype> void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type)) { LOCK(); _connection<desttype, void (arg1_type, arg2_type, arg3_type , arg4_type, arg5_type)>* conn = new _connection<desttype, void (arg1_type, arg2_type, arg3_type, arg4_type, arg5_type)>(pclass, pmemfun); m_owner_slots.push_back(conn); } void call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5) { LOCK(); connections_list::const_iterator itNext, it = m_owner_slots.begin(); connections_list::const_iterator itEnd = m_owner_slots.end(); while (it != itEnd) { itNext = it; ++itNext; (*it)->call(a1, a2, a3, a4, a5); it = itNext; } it = m_slots.begin(); itEnd = m_slots.end(); while (it != itEnd) { itNext = it; ++itNext; (*it)->call(a1, a2, a3, a4, a5); it = itNext; } } void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5) { this->call(a1, a2, a3, a4, a5); } protected: connections_list m_owner_slots; connections_list m_slots; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class arg6_type> class signal<void (arg1_type, arg2_type, arg3_type, arg4_type , arg5_type, arg6_type)> : public _connection_base<void (arg1_type, arg2_type, arg3_type, arg4_type , arg5_type, arg6_type)> { public: typedef signal<void (arg1_type, arg2_type, arg3_type, arg4_type , arg5_type, arg6_type)> this_type; typedef _connection_base<void (arg1_type, arg2_type, arg3_type, arg4_type , arg5_type, arg6_type)> function_type; typedef std::list<function_type *> connections_list; typedef std::list<this_type *> signal_list; signal() { } virtual ~signal() { disconnect_all(); } void disconnect_all() { LOCK(); for (connections_list::iterator it = m_owner_slots.begin() ; it != m_owner_slots.end(); ++ it) { delete (*it); } m_owner_slots.clear(); m_slots.clear(); } void connect(function_type& connection) { LOCK(); m_slots.push_back(&connection); } void disconnect(function_type& connection) { LOCK(); m_slots.remove(&connection); } template<class desttype> void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type)) { LOCK(); _connection<desttype, void (arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type)>* conn = new _connection<desttype, void (arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type)>(pclass, pmemfun); m_owner_slots.push_back(conn); } void call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6) { LOCK(); connections_list::const_iterator itNext, it = m_owner_slots.begin(); connections_list::const_iterator itEnd = m_owner_slots.end(); while (it != itEnd) { itNext = it; ++itNext; (*it)->call(a1, a2, a3, a4, a5, a6); it = itNext; } it = m_slots.begin(); itEnd = m_slots.end(); while (it != itEnd) { itNext = it; ++itNext; (*it)->call(a1, a2, a3, a4, a5, a6); it = itNext; } } void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6) { this->call(a1, a2, a3, a4, a5, a6); } protected: connections_list m_owner_slots; connections_list m_slots; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class arg6_type, class arg7_type> class signal<void (arg1_type, arg2_type, arg3_type, arg4_type , arg5_type, arg6_type, arg7_type)> : public _connection_base<void (arg1_type, arg2_type, arg3_type, arg4_type , arg5_type, arg6_type, arg7_type)> { public: typedef signal<void (arg1_type, arg2_type, arg3_type, arg4_type , arg5_type, arg6_type, arg7_type)> this_type; typedef _connection_base<void (arg1_type, arg2_type, arg3_type, arg4_type , arg5_type, arg6_type, arg7_type)> function_type; typedef std::list<function_type *> connections_list; typedef std::list<this_type *> signal_list; signal() { } virtual ~signal() { disconnect_all(); } void disconnect_all() { LOCK(); for (connections_list::iterator it = m_owner_slots.begin() ; it != m_owner_slots.end(); ++ it) { delete (*it); } m_owner_slots.clear(); m_slots.clear(); } void connect(function_type& connection) { LOCK(); m_slots.push_back(&connection); } void disconnect(function_type& connection) { LOCK(); m_slots.remove(&connection); } template<class desttype> void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type)) { LOCK(); _connection<desttype, void (arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type)>* conn = new _connection<desttype, void (arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type)>(pclass, pmemfun); m_owner_slots.push_back(conn); } void call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7) { LOCK(); connections_list::const_iterator itNext, it = m_owner_slots.begin(); connections_list::const_iterator itEnd = m_owner_slots.end(); while (it != itEnd) { itNext = it; ++itNext; (*it)->call(a1, a2, a3, a4, a5, a6, a7); it = itNext; } it = m_slots.begin(); itEnd = m_slots.end(); while (it != itEnd) { itNext = it; ++itNext; (*it)->call(a1, a2, a3, a4, a5, a6, a7); it = itNext; } } void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7) { this->call(a1, a2, a3, a4, a5, a6, a7); } protected: connections_list m_owner_slots; connections_list m_slots; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class arg6_type, class arg7_type, class arg8_type> class signal<void (arg1_type, arg2_type, arg3_type, arg4_type , arg5_type, arg6_type, arg7_type, arg8_type)> : public _connection_base<void (arg1_type, arg2_type, arg3_type, arg4_type , arg5_type, arg6_type, arg7_type, arg8_type)> { public: typedef signal<void (arg1_type, arg2_type, arg3_type, arg4_type , arg5_type, arg6_type, arg7_type, arg8_type)> this_type; typedef _connection_base<void (arg1_type, arg2_type, arg3_type, arg4_type , arg5_type, arg6_type, arg7_type, arg8_type)> function_type; typedef std::list<function_type *> connections_list; typedef std::list<this_type *> signal_list; signal() { } virtual ~signal() { disconnect_all(); } void disconnect_all() { LOCK(); for (connections_list::iterator it = m_owner_slots.begin() ; it != m_owner_slots.end(); ++ it) { delete (*it); } m_owner_slots.clear(); m_slots.clear(); } void connect(function_type& connection) { LOCK(); m_slots.push_back(&connection); } void disconnect(function_type& connection) { LOCK(); m_slots.remove(&connection); } template<class desttype> void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type)) { LOCK(); _connection<desttype, void (arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type)>* conn = new _connection<desttype, void (arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type)>(pclass, pmemfun); m_owner_slots.push_back(conn); } void call(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8) { LOCK(); connections_list::const_iterator itNext, it = m_owner_slots.begin(); connections_list::const_iterator itEnd = m_owner_slots.end(); while (it != itEnd) { itNext = it; ++itNext; (*it)->call(a1, a2, a3, a4, a5, a6, a7, a8); it = itNext; } it = m_slots.begin(); itEnd = m_slots.end(); while (it != itEnd) { itNext = it; ++itNext; (*it)->call(a1, a2, a3, a4, a5, a6, a7, a8); it = itNext; } } void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8) { call(a1, a2, a3, a4, a5, a6, a7, a8); } protected: connections_list m_owner_slots; connections_list m_slots; }; #endif // __connection_base_h_
[ "runner.mei@0dd8077a-353d-11de-b438-597f59cd7555" ]
[ [ [ 1, 1731 ] ] ]
75b7952b2e9bf53d20e7811947c3669b2acb0b92
f08e489d72121ebad042e5b408371eaa212d3da9
/TP1_v1/src/Estructuras/Bucket.h
7c492df98bdd187a0370ec2f07ea0835ba1f88df
[]
no_license
estebaneze/datos022011-tp1-vane
627a1b3be9e1a3e4ab473845ef0ded9677e623e0
33f8a8fd6b7b297809a0feac14d10f9815f8388b
refs/heads/master
2021-01-20T03:35:36.925750
2011-12-04T18:19:55
2011-12-04T18:19:55
41,821,700
0
0
null
null
null
null
UTF-8
C++
false
false
1,759
h
#ifndef BUCKET_H_ #define BUCKET_H_ #include "key_node.h" #include "refs.h" /**Clase Bucket */ class Bucket { private: int N;//id del Bucket std::vector<std::pair<Key_Node,Refs> > bucket; //<clave de hash , elems del array del bucket> int refs; //cantidad de referencia al buckets public: Bucket(); Bucket(int,int); Bucket(const Bucket &toCopy); /**Inserta la clave en el bucket * @param key clave a insertar * @param value numero de registro donde encontrar la clave en el archivo de datos */ void insertKey( Key_Node &key, Refs value); /**Elimina la clave en el bucket * @param key clave a eliminar */ void deleteKey ( Key_Node &key); /**Obtiene el numero de bucket * @return numero de bucket */ int getNBucket() const; /**Obtiene el numero de registro donde encontrar la clave en el archivo de datos */ Refs * getValue ( Key_Node &key); /**Verifica si el bucket esta vacio */ bool empty(); /**Devuelve la cantidad de pares clave-reg del bucket */ int size(); /**Vacia el bucket */ void clear(); /**Devuelve el tamanio en bytes del bucket */ int sizeKb() const; /**Devuelve el par clave-reg de la posicion indicada */ std::pair<Key_Node,Refs> at(int i); /**Obtiene el bucket */ std::vector<std::pair<Key_Node,Refs> > getBucket(); /**Verifica la existencia de una clave en el bucket */ bool exists( Key_Node &key); /**Agrega una referencia al bucket */ void addRef(); /**Actualiza las referencias al bucket */ void updateRef(int ref); void duplicateRef(); void divRef(); int getRef(); virtual ~Bucket(); }; #endif /*BUCKET_H_*/
[ [ [ 1, 89 ] ] ]
c0dc0616cc375eb3b898b3477aeeb7a10e8b5a28
b1093f654e78210a00e6ca561c1a8f8f108f543e
/include/processor/SubstituteProcessor.h
8a9c3534bc4965b4b0734cfcbaab7407fe967339
[]
no_license
childhood/libAiml
bc82b7cd8859aa6fe0a7a3c42ffe4591438ae329
7954dc347463bcb4ab0070af87b9cbd421b08acc
refs/heads/master
2021-01-18T10:07:02.407246
2010-09-20T04:40:34
2010-09-20T04:40:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
605
h
/** * SubstituteProcessor - Used to apply custom substitutions * * @author Jonathan Roewen */ #ifndef SUBSTITUTE_PROCESSOR_H #define SUBSTITUTE_PROCESSOR_H #include "AimlProcessor.h" #include "Kernel.h" #include "Utils.h" #include <string> using namespace std; class SubstituteProcessor : public AimlProcessor { public: ~SubstituteProcessor() { } string process(Match *m, PElement e, Responder *r, const string &id) { string value = Kernel::process(m, e, r, id); string sub = e->getAttribute("sub"); return Substituter::substitute(value, sub); } }; #endif
[ [ [ 1, 29 ] ] ]
46beb9d16fcc616d26d437311563375d0ab8af12
580738f96494d426d6e5973c5b3493026caf8b6a
/Include/Vcl/idnntpserver.hpp
6dbe40485f8504bea01c77d00410f4d5b51ce29d
[]
no_license
bravesoftdz/cbuilder-vcl
6b460b4d535d17c309560352479b437d99383d4b
7b91ef1602681e094a6a7769ebb65ffd6f291c59
refs/heads/master
2021-01-10T14:21:03.726693
2010-01-11T11:23:45
2010-01-11T11:23:45
48,485,606
2
1
null
null
null
null
UTF-8
C++
false
false
6,288
hpp
// Borland C++ Builder // Copyright (c) 1995, 2002 by Borland Software Corporation // All rights reserved // (DO NOT EDIT: machine generated header) 'IdNNTPServer.pas' rev: 6.00 #ifndef IdNNTPServerHPP #define IdNNTPServerHPP #pragma delphiheader begin #pragma option push -w- #pragma option push -Vx #include <IdComponent.hpp> // Pascal unit #include <IdTCPServer.hpp> // Pascal unit #include <IdGlobal.hpp> // Pascal unit #include <Classes.hpp> // Pascal unit #include <SysInit.hpp> // Pascal unit #include <System.hpp> // Pascal unit //-- user supplied ----------------------------------------------------------- namespace Idnntpserver { //-- type declarations ------------------------------------------------------- typedef AnsiString IdNNTPServer__1[26]; typedef void __fastcall (__closure *TGetEvent)(Idtcpserver::TIdPeerThread* AThread); typedef void __fastcall (__closure *TOtherEvent)(Idtcpserver::TIdPeerThread* AThread, AnsiString ACommand, AnsiString AParm, bool &AHandled); typedef void __fastcall (__closure *TDoByIDEvent)(Idtcpserver::TIdPeerThread* AThread, AnsiString AActualID); typedef void __fastcall (__closure *TDoByNoEvent)(Idtcpserver::TIdPeerThread* AThread, unsigned AActualNumber); typedef void __fastcall (__closure *TGroupEvent)(Idtcpserver::TIdPeerThread* AThread, AnsiString AGroup); typedef void __fastcall (__closure *TNewsEvent)(Idtcpserver::TIdPeerThread* AThread, AnsiString AParm); typedef void __fastcall (__closure *TDataEvent)(Idtcpserver::TIdPeerThread* AThread, System::TObject* AData); class DELPHICLASS TIdNNTPServer; class PASCALIMPLEMENTATION TIdNNTPServer : public Idtcpserver::TIdTCPServer { typedef Idtcpserver::TIdTCPServer inherited; protected: TOtherEvent fOnCommandAuthInfo; TDoByIDEvent fOnCommandArticleID; TDoByNoEvent fOnCommandArticleNO; TDoByIDEvent fOnCommandBodyID; TDoByNoEvent fOnCommandBodyNO; TDoByIDEvent fOnCommandHeadID; TDoByNoEvent fOnCommandHeadNO; TDoByIDEvent fOnCommandStatID; TDoByNoEvent fOnCommandStatNO; TGroupEvent fOnCommandGroup; TNewsEvent fOnCommandList; TGetEvent fOnCommandHelp; TDoByIDEvent fOnCommandIHave; TGetEvent fOnCommandLast; TNewsEvent fOnCommandMode; TNewsEvent fOnCommandNewGroups; TNewsEvent fOnCommandNewNews; TGetEvent fOnCommandNext; TGetEvent fOnCommandPost; TGetEvent fOnCommandQuit; TGetEvent fOnCommandSlave; TNewsEvent fOnCommandXOver; TNewsEvent fOnCommandXHDR; TGetEvent fOnCommandDate; TNewsEvent fOnCommandListgroup; TDoByIDEvent fOnCommandTakeThis; TDoByIDEvent fOnCommandCheck; TNewsEvent fOnCommandXThread; TNewsEvent fOnCommandXGTitle; TNewsEvent fOnCommandXPat; TOtherEvent fOnCommandOther; virtual bool __fastcall DoExecute(Idtcpserver::TIdPeerThread* AThread); public: __fastcall virtual TIdNNTPServer(Classes::TComponent* AOwner); __published: __property TOtherEvent OnCommandAuthInfo = {read=fOnCommandAuthInfo, write=fOnCommandAuthInfo}; __property TDoByIDEvent OnCommandArticleID = {read=fOnCommandArticleID, write=fOnCommandArticleID}; __property TDoByNoEvent OnCommandArticleNo = {read=fOnCommandArticleNO, write=fOnCommandArticleNO}; __property TDoByIDEvent OnCommandBodyID = {read=fOnCommandBodyID, write=fOnCommandBodyID}; __property TDoByNoEvent OnCommandBodyNo = {read=fOnCommandBodyNO, write=fOnCommandBodyNO}; __property TDoByIDEvent OnCommandCheck = {read=fOnCommandCheck, write=fOnCommandCheck}; __property TDoByIDEvent OnCommandHeadID = {read=fOnCommandHeadID, write=fOnCommandHeadID}; __property TDoByNoEvent OnCommandHeadNo = {read=fOnCommandHeadNO, write=fOnCommandHeadNO}; __property TDoByIDEvent OnCommandStatID = {read=fOnCommandStatID, write=fOnCommandStatID}; __property TDoByNoEvent OnCommandStatNo = {read=fOnCommandStatNO, write=fOnCommandStatNO}; __property TGroupEvent OnCommandGroup = {read=fOnCommandGroup, write=fOnCommandGroup}; __property TNewsEvent OnCommandList = {read=fOnCommandList, write=fOnCommandList}; __property TGetEvent OnCommandHelp = {read=fOnCommandHelp, write=fOnCommandHelp}; __property TDoByIDEvent OnCommandIHave = {read=fOnCommandIHave, write=fOnCommandIHave}; __property TGetEvent OnCommandLast = {read=fOnCommandLast, write=fOnCommandLast}; __property TNewsEvent OnCommandMode = {read=fOnCommandMode, write=fOnCommandMode}; __property TNewsEvent OnCommandNewGroups = {read=fOnCommandNewGroups, write=fOnCommandNewGroups}; __property TNewsEvent OnCommandNewNews = {read=fOnCommandNewNews, write=fOnCommandNewNews}; __property TGetEvent OnCommandNext = {read=fOnCommandNext, write=fOnCommandNext}; __property TGetEvent OnCommandPost = {read=fOnCommandPost, write=fOnCommandPost}; __property TGetEvent OnCommandQuit = {read=fOnCommandQuit, write=fOnCommandQuit}; __property TGetEvent OnCommandSlave = {read=fOnCommandSlave, write=fOnCommandSlave}; __property TDoByIDEvent OnCommandTakeThis = {read=fOnCommandTakeThis, write=fOnCommandTakeThis}; __property TNewsEvent OnCommandXOver = {read=fOnCommandXOver, write=fOnCommandXOver}; __property TNewsEvent OnCommandXHDR = {read=fOnCommandXHDR, write=fOnCommandXHDR}; __property TGetEvent OnCommandDate = {read=fOnCommandDate, write=fOnCommandDate}; __property TNewsEvent OnCommandListgroup = {read=fOnCommandListgroup, write=fOnCommandListgroup}; __property TNewsEvent OnCommandXThread = {read=fOnCommandXThread, write=fOnCommandXThread}; __property TNewsEvent OnCommandXGTitle = {read=fOnCommandXGTitle, write=fOnCommandXGTitle}; __property TNewsEvent OnCommandXPat = {read=fOnCommandXPat, write=fOnCommandXPat}; __property TOtherEvent OnCommandOther = {read=fOnCommandOther, write=fOnCommandOther}; __property DefaultPort = {default=119}; public: #pragma option push -w-inl /* TIdTCPServer.Destroy */ inline __fastcall virtual ~TIdNNTPServer(void) { } #pragma option pop }; //-- var, const, procedure --------------------------------------------------- extern PACKAGE AnsiString KnownCommands[26]; } /* namespace Idnntpserver */ using namespace Idnntpserver; #pragma option pop // -w- #pragma option pop // -Vx #pragma delphiheader end. //-- end unit ---------------------------------------------------------------- #endif // IdNNTPServer
[ "bitscode@7bd08ab0-fa70-11de-930f-d36749347e7b" ]
[ [ [ 1, 134 ] ] ]
59cf22b8ea8c58729d9dfb09dcf77551f57ca3c9
cbb40e1d71bc4585ad3a58d32024090901487b76
/trunk/tokamaksrc/TokaDemo/CMilkShape3DMesh.h
1c90a4feafb7e40d8dd65b47f5fb0326447d1c5f
[]
no_license
huangleon/tokamak
c0dee7b8182ced6b514b37cf9c526934839c6c2e
0218e4d17dcf93b7ab476e3e8bd4026f390f82ca
refs/heads/master
2021-01-10T10:11:42.617076
2011-08-22T02:32:16
2011-08-22T02:32:16
50,816,154
0
0
null
null
null
null
GB18030
C++
false
false
11,630
h
#pragma once ////////////////////////////////////////////////////////////////// //文件: MilkShape3DMesh.h //描述: MilkShape3D的读取,并且经过扩展,支持多个动作 // 与原版MilkShape3D的改进在于: // 1.支持预计算包围盒,省掉Framemove里的开销 // 2.旋转信息由四元数来代替,替换原来只是使用四元数来插值的方法 // 3.支持可以根据需要,关掉法线的变换。在不需要光照的地方省掉法线的变换来提高效率。 // 4.将原来友骨架促使顶点变化转化为顶点变化,增加cpu的cache命中率,并且便于将动作文件进行分离 // 5. 支持动作切换时的平滑过渡功能 // 6.在进行纹理读取时禁掉三线性过滤,关掉mipmap,能节省一部分内存 // 7.为了便于加速读取,可以存储为新格式 //历史: // 赵磊 创建 // //////////////////////////////////////////////////////////////// #include "IAnimatedMeshMS3D.h" #include "IReadFile.h" #include "IFileSystem.h" #include "irrArray.h" #include "irrString.h" #include "irrMap.h" #include "SMesh.h" #include "SMeshBuffer.h" #include "quaternion.h" #include "IrrlichtDevice.h" namespace irr { namespace scene { namespace sklani { class CResMngr; class CRes : public IUnknown { friend class CResMngr; public: CRes(); virtual ~CRes(); public: bool operator < (const CRes& other) const { return m_strName < other.m_strName; } void SetResName(const core::stringc &strName) { m_strName = strName; } const core::stringc &GetResName() { return m_strName; } protected: core::stringc m_strName; CResMngr *m_pResMngr; }; class CResMngr { public: bool RegisterRes(const core::stringc &strName,CRes *pRes); void RemoveRes(const core::stringc &strName); CRes *QueryRes(const core::stringc &strName); void Clear(); protected: typedef irr::core::map<core::stringc,CRes *> MAP_NAME2RES; MAP_NAME2RES m_mapRes; }; class CAction_ : public IUnknown { friend class CSkeletonAni; public: CAction_(); virtual ~CAction_(); public: void SetSize(s32 iJointNum,s32 iFrameNum); int GetFrameNum() { return m_iFrameNum; } public: //半开区间 struct SSubActionInfo { int m_iFrameStart; int m_iFrameEnd; }; bool AddAction(CAction_ *pAction,SSubActionInfo &info); bool AddAction(const core::stringc &strActionName,SSubActionInfo &info,IrrlichtDevice *Device); bool SplitToSubAction(core::array<SSubActionInfo> &arrayInfo,core::array<CAction_ *> &arrayRet); bool ImportActionFromFile(io::IReadFile *pFile); bool ImportActionFromFile(const core::stringc &strName,irr::IrrlichtDevice *Device); bool Export(io::IWriteFile *pWriteFile); bool Import(io::IReadFile *pReadFile); public: struct SKeyframe { core::vector3df m_vTrans; core::quaternion m_qRotate; }; const SKeyframe &GetJointKeyframe(s32 iJointIndex,s32 iFrameNum) const { return *(m_pKeyframe + m_iJointNum * iFrameNum + iJointIndex); } SKeyframe &GetJointKeyframe(s32 iJointIndex,s32 iFrameNum) { return *(m_pKeyframe + m_iJointNum * iFrameNum + iJointIndex); } SKeyframe *GetKeyframe(s32 iFrameNum) const { return m_pKeyframe + m_iJointNum * iFrameNum; } bool GetKeyframeIndex(f32 fTime,s32 &iFrameIndex0,s32 &iFrameIndex1,f32 &fScale,bool bLoop) const; private: f32 *m_pKeyframeTime; SKeyframe *m_pKeyframe; s32 m_iJointNum; s32 m_iFrameNum; f32 m_fFramePerSecond; }; class CActionMngr : public CResMngr { public: static CActionMngr *GetInstance(); }; inline CActionMngr *ActionMngr() { return CActionMngr::GetInstance(); } struct SJoint { s32 iFrameIndex; core::quaternion Rotation; //改为旋转四元数 core::vector3df Translation; core::matrix4 AbsoluteTransformationAnimated; //最终旋转矩阵 core::matrix4 RelativeTransformation; s32 Parent; //父节点 }; class CSkeletonAni; struct SJointInfo { core::stringc strName; core::matrix4 RelativeTransformation; core::matrix4 AbsoluteTransformation; u16 wParentIndex; core::vector3df Trans; core::quaternion Rotate; }; class CSkeleton : public CRes { friend class CSkeletonAni; public: CSkeleton(); ~CSkeleton(); void operator = (const CSkeleton &skl); public: //根据一个节点名字得到骨骼节点 int GetJointIndex(const core::stringc &NameFind) const; const SJointInfo &GetJointInfo(int iIndex) { return m_vecJointInfo[iIndex]; } core::array<SJointInfo> &GetJointInfoVector() { return m_vecJointInfo; } protected: core::array< SJointInfo > m_vecJointInfo; //在这里存储了当前变换的结果 public: CSkeleton *m_pResSkeleton; public: bool Export(io::IWriteFile *pWriteFile); bool Import(io::IReadFile *pReadFile); }; class CSkeletonMngr : public CResMngr { public: static CSkeletonMngr *GetInstance(); }; inline CSkeletonMngr *SkeletonMngr() { return CSkeletonMngr::GetInstance(); } class CSkinRes : public CRes { friend class CSkeletonAni; public: virtual ~CSkinRes(); public: struct SGroup { core::stringc Name; core::array<u16> VertexIds; u16 MaterialIdx; }; struct SBufferInfo { video::SMaterial Material; s8 Texture[128]; u16 IndexStart; u16 IndexCount; }; struct SSkinVertex : public video::S3DVertex { u16 BoneId; }; public: bool Export(io::IWriteFile *pFile); bool Import(io::IReadFile *pFile,video::IVideoDriver* driver); public: core::array<SBufferInfo> &GetBufferInfos() { return Buffers; } core::array<u16> &GetIndexBuffer() { return Indices; } core::aabbox3d<f32> GetBoundingBox() { return BoundingBox; } s32 GetVertexCount() const { return Vertices.size(); } core::array<SSkinVertex> &GetVertexVector() { return Vertices; } protected: core::array<SSkinVertex> Vertices; core::array<u16> Indices; core::aabbox3d<f32> BoundingBox; public: SBufferInfo *GetBufferFromMaterial(const video::SMaterial &mat); private: core::array<SBufferInfo> Buffers; }; class CSkinResMngr : public CResMngr { public: static CSkinResMngr *GetInstance(); }; inline CSkinResMngr *SkinResMngr() { return CSkinResMngr::GetInstance(); } class CSkin { friend class CSkeletonAni; public: CSkin(); ~CSkin(); public: bool SetSkinRes(CSkinRes *); public: struct CMeshBuffer : public IMeshBuffer { public: CMeshBuffer(); public: //! returns the material of this meshbuffer virtual const video::SMaterial& getMaterial() const { return m_Material; } //! returns the material of this meshbuffer virtual video::SMaterial& getMaterial() { return m_Material; } //! returns pointer to vertices virtual const void* getVertices() const; //! returns pointer to vertices virtual void* getVertices(); //! returns amount of vertices virtual u32 getVertexCount() const; //! returns pointer to Indices virtual const u16* getIndices() const; //! returns pointer to Indices virtual u16* getIndices(); //! returns amount of indices virtual u32 getIndexCount() const; //! returns an axis aligned bounding box virtual const core::aabbox3d<f32>& getBoundingBox() const; //! set user axis aligned bounding box virtual void setBoundingBox( const core::aabbox3df& box); //! returns which type of vertex data is stored. virtual video::E_VERTEX_TYPE getVertexType() const; //! returns the byte size (stride, pitch) of the vertex virtual u32 getVertexPitch() const; public: CSkin *m_pSkin; video::SMaterial m_Material; u16 *m_Indices; u16 m_IndexCount; }; protected: CSkinRes *m_pSkinRes; core::array<video::S3DVertex> AnimatedVertices; core::array<CMeshBuffer> MeshBuffer; core::aabbox3d<f32> BoundingBox; }; class CSkeletonAni : public IAnimatedMeshMS3D, public IMesh { public: enum PLAY_MODE {PLAY,PAUSE,TRANSPLAY}; public: CSkeletonAni(video::IVideoDriver* driver); ~CSkeletonAni(); public: bool Export(io::IWriteFile *pFile); bool Import(io::IReadFile *pFile); public: void SetAction(s32 frame,CAction_ *pAction,bool bLoop); void SetSkin(CSkin *pSkin); void SetSkeleton(CSkeleton *pSkeleton); CAction_ *GetAction() { return m_pAction_; } CSkin *GetSkin() { return m_pSkin; } CSkeleton *GetSkeleton() { return m_pSkeleton; } protected: CSkeleton *m_pSkeleton; //骨架描述 CAction_ *m_pAction_; CSkin *m_pSkin; // 以后支持换装的话,这里应该是一个array:) void animate(s32 frame); void animateJoint(s32 frame); void TransformMesh(); // 根据当前的骨架变换Mesh core::array<video::S3DVertex> m_vecVert; core::array<SJoint> m_vecJoint; // 在这里存Joint的数据的原因是保存当前的状态,便于以后动作过度功能的加入 core::aabbox3d<f32> m_BoundingBox; protected: private: core::array<video::S3DVertex> m_AnimatedVertices; //供渲染用 private: bool m_bNeedTransformNormal; s32 m_iframeActStart; bool m_bHasAnimation; f32 m_fTotalTime; //开始合并了 public: bool LoadOldMs3dMesh(io::IReadFile *pReadFile0); private: video::IVideoDriver* m_pDriver; bool m_bTransitionEnable; bool m_bTransiting; // 正在过渡 f32 m_fTransitionTimeEnd; f32 m_fTransitionTimeLast; bool m_bLoop; public: // IMesh Interface virtual s32 getFrameCount() { return s32(m_fTotalTime); } //! returns the animated mesh based on a detail level. 0 is the lowest, 255 the highest detail. Note, that some Meshes will ignore the detail level. virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1); //! returns amount of mesh buffers. virtual u32 getMeshBufferCount() const; //! returns pointer to a mesh buffer virtual IMeshBuffer* getMeshBuffer(u32 nr) const; //! Returns pointer to a mesh buffer which fits a material /** \param material: material to search for \return Returns the pointer to the mesh buffer or NULL if there is no such mesh buffer. */ virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const; //! returns an axis aligned bounding box virtual const core::aabbox3d<f32>& getBoundingBox() const { return m_BoundingBox; } //! set user axis aligned bounding box virtual void setBoundingBox( const core::aabbox3df& box); //! sets a flag of all contained materials to a new value virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue); //! Returns the type of the animated mesh. virtual E_ANIMATED_MESH_TYPE getMeshType() const; //! Returns a pointer to a transformation matrix of a part of the //! mesh based on a frame time. virtual core::matrix4* getMatrixOfJoint(s32 jointNumber, s32 frame); //! Gets joint count. virtual s32 getJointCount() const; //! Gets the name of a joint. virtual const c8* getJointName(s32 number) const; //! Gets a joint number from its name virtual s32 getJointNumber(const c8* name) const; }; } } };
[ [ [ 1, 469 ] ] ]
4a9a5a3faeddade486cff3e18d0e6595bdc81d6d
bdb1e38df8bf74ac0df4209a77ddea841045349e
/CapsuleSortor/Version 1.0 -2.0/CapsuleSortor-10-12-17/ToolSrc/TMfdArchive.cpp
6f12e9d80b318926b69da31af913dc9d15ac20cb
[]
no_license
Strongc/my001project
e0754f23c7818df964289dc07890e29144393432
07d6e31b9d4708d2ef691d9bedccbb818ea6b121
refs/heads/master
2021-01-19T07:02:29.673281
2010-12-17T03:10:52
2010-12-17T03:10:52
49,062,858
0
1
null
2016-01-05T11:53:07
2016-01-05T11:53:07
null
UTF-8
C++
false
false
2,855
cpp
// TMdfArchive.cpp : Interface of the TMdfArchive class // // Copyright (c) 2008 zhao_fsh PACS Group ////////////////////////////////////////////////////////////////////////// // Create Date : 2008.03.26 // Last Data : // A simple tool to solve the archive of Multi Frame image #include "TMfdArchive.h" TMfdArchive::TMfdArchive() { memcpy(m_mfdInfo.flag, "MFDI", 4); m_mfdInfo.frameCount = 0; } TMfdArchive::~TMfdArchive() { } bool TMfdArchive::SetSingleImage(void* pData, const TImgDim& dim) { m_imgBuff.ReInit(dim, 1); memcpy(m_imgBuff.FrameData(0), pData, dim.bytesPerRow * dim.height); return true; } bool TMfdArchive::SetMultiImage(const TImgBuffer& imgBuff) { m_imgBuff = imgBuff; return true; } TImgBuffer TMfdArchive::GetImgBuffer() { return m_imgBuff; } TImgDim TMfdArchive::Dimension() { return m_imgBuff.Dimension(); } bool TMfdArchive::Load(const TCHAR *fileName) { HANDLE hFile = CreateFile( fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL); if(INVALID_HANDLE_VALUE == hFile) { return false; } DWORD bytesRead = 0; BOOL success = FALSE; success = ReadFile( hFile, &m_mfdInfo, sizeof(MfdInfo), &bytesRead, NULL); if(!success || bytesRead != sizeof(MfdInfo)) { CloseHandle(hFile); return false; } if( 0 != memcmp( m_mfdInfo.flag, "MFDI", 4)) { CloseHandle(hFile); return false; } m_imgBuff.ReInit(m_mfdInfo.dimension, m_mfdInfo.frameCount); size_t buffSize = m_mfdInfo.dimension.bytesPerRow * m_mfdInfo.dimension.height * m_mfdInfo.frameCount; success = ReadFile( hFile, m_imgBuff.FrameData(0), buffSize, &bytesRead, NULL); if(!success || bytesRead != buffSize) { CloseHandle(hFile); return false; } CloseHandle(hFile); return true; } bool TMfdArchive::Save(const TCHAR *fileName) { memcpy(m_mfdInfo.flag, "MFDI", 4); m_mfdInfo.dimension = m_imgBuff.Dimension(); m_mfdInfo.frameCount = m_imgBuff.FrameCount(); size_t buffSize = m_mfdInfo.dimension.bytesPerRow * m_mfdInfo.dimension.height * m_mfdInfo.frameCount; HANDLE hFile = CreateFile( fileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); DWORD fileSize = 0; if(hFile != INVALID_HANDLE_VALUE) { DWORD bytesWrite = 0; WriteFile(hFile, &m_mfdInfo, sizeof(MfdInfo), &bytesWrite, NULL); WriteFile(hFile, m_imgBuff.FrameData(0),buffSize, &bytesWrite, NULL); fileSize = GetFileSize(hFile, NULL); CloseHandle(hFile); } if(fileSize != sizeof(MfdInfo) + buffSize) { DeleteFile(fileName); return false; } return true; }
[ "vincen.cn@66f52ff4-a261-11de-b161-9f508301ba8e" ]
[ [ [ 1, 129 ] ] ]
c4273489e6343b5d69eb10aa8e5bd10a0e5ef043
d54d8b1bbc9575f3c96853e0c67f17c1ad7ab546
/hlsdk-2.3-p3/singleplayer/game_shared/vgui_grid.cpp
23789feed11e1d459c9eda1fb0e909e5c5516668
[]
no_license
joropito/amxxgroup
637ee71e250ffd6a7e628f77893caef4c4b1af0a
f948042ee63ebac6ad0332f8a77393322157fa8f
refs/heads/master
2021-01-10T09:21:31.449489
2010-04-11T21:34:27
2010-04-11T21:34:27
47,087,485
1
0
null
null
null
null
WINDOWS-1252
C++
false
false
7,959
cpp
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // // $NoKeywords: $ //============================================================================= #include <assert.h> #include "vgui_grid.h" using namespace vgui; #define AssertCheck(expr, msg) \ if(!(expr))\ {\ assert(!msg);\ return 0;\ } // ------------------------------------------------------------------------------ // // CGrid::CGridEntry. // ------------------------------------------------------------------------------ // CGrid::CGridEntry::CGridEntry() { m_pPanel = NULL; m_bUnderline = false; } CGrid::CGridEntry::~CGridEntry() { } // ------------------------------------------------------------------------------ // // CGrid. // ------------------------------------------------------------------------------ // CGrid::CGrid() { Clear(); } CGrid::~CGrid() { Term(); } bool CGrid::SetDimensions(int xCols, int yRows) { Term(); m_GridEntries = new CGridEntry[xCols * yRows]; m_Widths = new int[xCols*2 + yRows*2]; m_Heights = m_Widths + xCols; m_ColOffsets = m_Heights + yRows; m_RowOffsets = m_ColOffsets + xCols; if(!m_GridEntries || !m_Widths) { Term(); return false; } memset(m_Widths, 0, sizeof(int) * (xCols*2 + yRows*2)); m_xCols = xCols; m_yRows = yRows; return true; } void CGrid::Term() { delete [] m_GridEntries; delete [] m_Widths; Clear(); } Panel* CGrid::GetEntry(int x, int y) { return GridEntry(x, y)->m_pPanel; } bool CGrid::SetEntry(int x, int y, Panel *pPanel) { CGridEntry *pEntry = GridEntry(x, y); if(!pEntry) return false; if(pEntry->m_pPanel) pEntry->m_pPanel->setParent(NULL); pEntry->m_pPanel = pPanel; if(pPanel) pPanel->setParent(this); m_bDirty = true; return true; } int CGrid::GetXSpacing() { return m_xSpacing; } int CGrid::GetYSpacing() { return m_ySpacing; } void CGrid::SetSpacing(int xSpacing, int ySpacing) { if(xSpacing != m_xSpacing) { m_xSpacing = xSpacing; CalcColOffsets(0); m_bDirty = true; } if(ySpacing != m_ySpacing) { m_ySpacing = ySpacing; CalcRowOffsets(0); m_bDirty = true; } } bool CGrid::SetColumnWidth(int iColumn, int width) { AssertCheck(iColumn >= 0 && iColumn < m_xCols, "CGrid::SetColumnWidth : invalid location specified"); m_Widths[iColumn] = width; CalcColOffsets(iColumn+1); m_bDirty = true; return true; } bool CGrid::SetRowHeight(int iRow, int height) { AssertCheck(iRow >= 0 && iRow < m_yRows, "CGrid::SetColumnWidth : invalid location specified"); m_Heights[iRow] = height; CalcRowOffsets(iRow+1); m_bDirty = true; return true; } int CGrid::GetColumnWidth(int iColumn) { AssertCheck(iColumn >= 0 && iColumn < m_xCols, "CGrid::GetColumnWidth: invalid location specified"); return m_Widths[iColumn]; } int CGrid::GetRowHeight(int iRow) { AssertCheck(iRow >= 0 && iRow < m_yRows, "CGrid::GetRowHeight: invalid location specified"); return m_Heights[iRow]; } int CGrid::CalcFitColumnWidth(int iColumn) { AssertCheck(iColumn >= 0 && iColumn < m_xCols, "CGrid::CalcFitColumnWidth: invalid location specified"); int maxSize = 0; for(int i=0; i < m_yRows; i++) { Panel *pPanel = GridEntry(iColumn, i)->m_pPanel; if(!pPanel) continue; int w, h; pPanel->getSize(w,h); if(w > maxSize) maxSize = w; } return maxSize; } int CGrid::CalcFitRowHeight(int iRow) { AssertCheck(iRow >= 0 && iRow < m_yRows, "CGrid::CalcFitRowHeight: invalid location specified"); int maxSize = 0; for(int i=0; i < m_xCols; i++) { Panel *pPanel = GridEntry(i, iRow)->m_pPanel; if(!pPanel) continue; int w, h; pPanel->getSize(w,h); if(h > maxSize) maxSize = h; } return maxSize; } void CGrid::AutoSetRowHeights() { for(int i=0; i < m_yRows; i++) SetRowHeight(i, CalcFitRowHeight(i)); } bool CGrid::GetEntryBox( int col, int row, int &x, int &y, int &w, int &h) { AssertCheck(col >= 0 && col < m_xCols && row >= 0 && row < m_yRows, "CGrid::GetEntryBox: invalid location specified"); x = m_ColOffsets[col]; w = m_Widths[col]; y = m_RowOffsets[row]; h = m_Heights[row]; return true; } bool CGrid::CopyColumnWidths(CGrid *pOther) { if(!pOther || pOther->m_xCols != m_xCols) return false; for(int i=0; i < m_xCols; i++) m_Widths[i] = pOther->m_Widths[i]; CalcColOffsets(0); m_bDirty = true; return true; } void CGrid::RepositionContents() { for(int x=0; x < m_xCols; x++) { for(int y=0; y < m_yRows; y++) { Panel *pPanel = GridEntry(x,y)->m_pPanel; if(!pPanel) continue; pPanel->setBounds( m_ColOffsets[x], m_RowOffsets[y], m_Widths[x], m_Heights[y]); } } m_bDirty = false; } int CGrid::CalcDrawHeight() { if(m_yRows > 0) { return m_RowOffsets[m_yRows-1] + m_Heights[m_yRows - 1] + m_ySpacing; } else { return 0; } } void CGrid::paint() { if(m_bDirty) RepositionContents(); Panel::paint(); // walk the grid looking for underlined rows int x = 0, y = 0; for (int row = 0; row < m_yRows; row++) { CGridEntry *cell = GridEntry(0, row); y += cell->m_pPanel->getTall() + m_ySpacing; if (cell->m_bUnderline) { drawSetColor(cell->m_UnderlineColor[0], cell->m_UnderlineColor[1], cell->m_UnderlineColor[2], cell->m_UnderlineColor[3]); drawFilledRect(0, y - (cell->m_iUnderlineOffset + 1), getWide(), y - cell->m_iUnderlineOffset); } } } void CGrid::paintBackground() { Panel::paintBackground(); } //----------------------------------------------------------------------------- // Purpose: sets underline color for a particular row //----------------------------------------------------------------------------- void CGrid::SetRowUnderline(int row, bool enabled, int offset, int r, int g, int b, int a) { CGridEntry *cell = GridEntry(0, row); cell->m_bUnderline = enabled; if (enabled) { cell->m_iUnderlineOffset = offset; cell->m_UnderlineColor[0] = r; cell->m_UnderlineColor[1] = g; cell->m_UnderlineColor[2] = b; cell->m_UnderlineColor[3] = a; } } void CGrid::Clear() { m_xCols = m_yRows = 0; m_Widths = NULL; m_GridEntries = NULL; m_xSpacing = m_ySpacing = 0; m_bDirty = false; } CGrid::CGridEntry* CGrid::GridEntry(int x, int y) { AssertCheck(x >= 0 && x < m_xCols && y >= 0 && y < m_yRows, "CGrid::GridEntry: invalid location specified"); return &m_GridEntries[y*m_xCols + x]; } void CGrid::CalcColOffsets(int iStart) { int cur = m_xSpacing; if(iStart != 0) cur += m_ColOffsets[iStart-1] + m_Widths[iStart-1]; for(int i=iStart; i < m_xCols; i++) { m_ColOffsets[i] = cur; cur += m_Widths[i] + m_xSpacing; } } void CGrid::CalcRowOffsets(int iStart) { int cur = m_ySpacing; if(iStart != 0) cur += m_RowOffsets[iStart-1]; for(int i=iStart; i < m_yRows; i++) { m_RowOffsets[i] = cur; cur += m_Heights[i] + m_ySpacing; } } bool CGrid::getCellAtPoint(int worldX, int worldY, int &row, int &col) { row = -1; col = -1; for(int x=0; x < m_xCols; x++) { for(int y=0; y < m_yRows; y++) { Panel *pPanel = GridEntry(x,y)->m_pPanel; if (!pPanel) continue; if (pPanel->isWithin(worldX, worldY)) { col = x; row = y; return true; } } } return false; }
[ "joropito@23c7d628-c96c-11de-a380-73d83ba7c083" ]
[ [ [ 1, 398 ] ] ]
b6c1f2edaffc9c1b550747166e9e15e0840a573c
5dc6c87a7e6459ef8e832774faa4b5ae4363da99
/vis_avs/r_waterbump.cpp
38f9c6ac63e192e214e26db5ef963bd61493ee64
[]
no_license
aidinabedi/avs4unity
407603d2fc44bc8b075b54cd0a808250582ee077
9b6327db1d092218e96d8907bd14d68b741dcc4d
refs/heads/master
2021-01-20T15:27:32.449282
2010-12-24T03:28:09
2010-12-24T03:28:09
90,773,183
5
2
null
null
null
null
UTF-8
C++
false
false
13,548
cpp
/* LICENSE ------- Copyright 2005 Nullsoft, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Nullsoft nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include <windows.h> #include <stdlib.h> #include <vfw.h> #include <commctrl.h> #include <math.h> #include "resource.h" #include "r_defs.h" #ifndef LASER #define MOD_NAME "Trans / Water Bump" #define C_THISCLASS C_WaterBumpClass class C_THISCLASS : public C_RBASE { protected: public: C_THISCLASS(); virtual ~C_THISCLASS(); virtual int render(char visdata[2][2][SAMPLES], int isBeat, int *framebuffer, int *fbout, int w, int h); virtual char *get_desc() { return MOD_NAME; } virtual HWND conf(HINSTANCE hInstance, HWND hwndParent); virtual void load_config(unsigned char *data, int len); virtual int save_config(unsigned char *data); void SineBlob(int x, int y, int radius, int height, int page); void CalcWater(int npage, int density); void CalcWaterSludge(int npage, int density); void HeightBlob(int x, int y, int radius, int height, int page); int enabled; int *buffers[2]; int buffer_w,buffer_h; int page; int density; int depth; int random_drop; int drop_position_x; int drop_position_y; int drop_radius; int method; }; static C_THISCLASS *g_ConfigThis; // global configuration dialog pointer static HINSTANCE g_hDllInstance; // global DLL instance pointer (not needed in this example, but could be useful) // configuration read/write C_THISCLASS::C_THISCLASS() // set up default configuration { int i; enabled=1; density=6; depth=600; random_drop=0; drop_position_x=1; drop_position_y=1; drop_radius=40; method=0; buffer_w=0; buffer_h=0; for(i=0;i<2;i++) buffers[i]=NULL; page=0; } C_THISCLASS::~C_THISCLASS() { int i; for(i=0;i<2;i++) { if(buffers[i]) GlobalFree(buffers[i]); buffers[i]=NULL; } } #define GET_INT() (data[pos]|(data[pos+1]<<8)|(data[pos+2]<<16)|(data[pos+3]<<24)) void C_THISCLASS::load_config(unsigned char *data, int len) // read configuration of max length "len" from data. { int pos=0; if (len-pos >= 4) { enabled=GET_INT(); pos+=4; } if (len-pos >= 4) { density=GET_INT(); pos+=4; } if (len-pos >= 4) { depth=GET_INT(); pos+=4; } if (len-pos >= 4) { random_drop=GET_INT(); pos+=4; } if (len-pos >= 4) { drop_position_x=GET_INT(); pos+=4; } if (len-pos >= 4) { drop_position_y=GET_INT(); pos+=4; } if (len-pos >= 4) { drop_radius=GET_INT(); pos+=4; } if (len-pos >= 4) { method=GET_INT(); pos+=4; } } #define PUT_INT(y) data[pos]=(y)&255; data[pos+1]=(y>>8)&255; data[pos+2]=(y>>16)&255; data[pos+3]=(y>>24)&255 int C_THISCLASS::save_config(unsigned char *data) // write configuration to data, return length. config data should not exceed 64k. { int pos=0; PUT_INT(enabled); pos+=4; PUT_INT(density); pos+=4; PUT_INT(depth); pos+=4; PUT_INT(random_drop); pos+=4; PUT_INT(drop_position_x); pos+=4; PUT_INT(drop_position_y); pos+=4; PUT_INT(drop_radius); pos+=4; PUT_INT(method); pos+=4; return pos; } void C_THISCLASS::SineBlob(int x, int y, int radius, int height, int page) { int cx, cy; int left,top,right,bottom; int square; double dist; int radsquare = radius * radius; double length = (1024.0/(float)radius)*(1024.0/(float)radius); if(x<0) x = 1+radius+ rand()%(buffer_w-2*radius-1); if(y<0) y = 1+radius+ rand()%(buffer_h-2*radius-1); radsquare = (radius*radius); left=-radius; right = radius; top=-radius; bottom = radius; // Perform edge clipping... if(x - radius < 1) left -= (x-radius-1); if(y - radius < 1) top -= (y-radius-1); if(x + radius > buffer_w-1) right -= (x+radius-buffer_w+1); if(y + radius > buffer_h-1) bottom-= (y+radius-buffer_h+1); for(cy = top; cy < bottom; cy++) { for(cx = left; cx < right; cx++) { square = cy*cy + cx*cx; if(square < radsquare) { dist = sqrt(square*length); buffers[page][buffer_w*(cy+y) + cx+x] += (int)((cos(dist)+0xffff)*(height)) >> 19; } } } } void C_THISCLASS::HeightBlob(int x, int y, int radius, int height, int page) { int rquad; int cx, cy, cyq; int left, top, right, bottom; rquad = radius * radius; // Make a randomly-placed blob... if(x<0) x = 1+radius+ rand()%(buffer_w-2*radius-1); if(y<0) y = 1+radius+ rand()%(buffer_h-2*radius-1); left=-radius; right = radius; top=-radius; bottom = radius; // Perform edge clipping... if(x - radius < 1) left -= (x-radius-1); if(y - radius < 1) top -= (y-radius-1); if(x + radius > buffer_w-1) right -= (x+radius-buffer_w+1); if(y + radius > buffer_h-1) bottom-= (y+radius-buffer_h+1); for(cy = top; cy < bottom; cy++) { cyq = cy*cy; for(cx = left; cx < right; cx++) { if(cx*cx + cyq < rquad) buffers[page][buffer_w*(cy+y) + (cx+x)] += height; } } } void C_THISCLASS::CalcWater(int npage, int density) { int newh; int count = buffer_w + 1; int *newptr = buffers[npage]; int *oldptr = buffers[!npage]; int x, y; for (y = (buffer_h-1)*buffer_w; count < y; count += 2) { for (x = count+buffer_w-2; count < x; count++) { // This does the eight-pixel method. It looks much better. newh = ((oldptr[count + buffer_w] + oldptr[count - buffer_w] + oldptr[count + 1] + oldptr[count - 1] + oldptr[count - buffer_w - 1] + oldptr[count - buffer_w + 1] + oldptr[count + buffer_w - 1] + oldptr[count + buffer_w + 1] ) >> 2 ) - newptr[count]; newptr[count] = newh - (newh >> density); } } } /* void C_THISCLASS::CalcWaterSludge(int npage, int density) { int newh; int count = buffer_w + 1; int *newptr = buffers[npage]; int *oldptr = buffers[!npage]; int x, y; for (y = (buffer_h-1)*buffer_w; count < y; count += 2) { for (x = count+buffer_w-2; count < x; count++) { // This is the "sludge" method... newh = (oldptr[count]<<2) + oldptr[count-1-buffer_w] + oldptr[count+1-buffer_w] + oldptr[count-1+buffer_w] + oldptr[count+1+buffer_w] + ((oldptr[count-1] + oldptr[count+1] + oldptr[count-buffer_w] + oldptr[count+buffer_w])<<1); newptr[count] = (newh-(newh>>6)) >> density; } } } */ // render function // render should return 0 if it only used framebuffer, or 1 if the new output data is in fbout. this is // used when you want to do something that you'd otherwise need to make a copy of the framebuffer. // w and h are the width and height of the screen, in pixels. // isBeat is 1 if a beat has been detected. // visdata is in the format of [spectrum:0,wave:1][channel][band]. int C_THISCLASS::render(char visdata[2][2][SAMPLES], int isBeat, int *framebuffer, int *fbout, int w, int h) { if (!enabled) return 0; int l,i; l=w*h; if(buffer_w!=w||buffer_h!=h) { for(i=0;i<2;i++) { if(buffers[i])GlobalFree(buffers[i]); buffers[i]=NULL; } } if(buffers[0]==NULL) { for(i=0;i<2;i++) { buffers[i]=(int *)GlobalAlloc(GPTR,w*h*sizeof(int)); } buffer_w=w; buffer_h=h; } if (isBeat&0x80000000) return 0; if(isBeat) { if(random_drop) { int max=w; if(h>w) max=h; SineBlob(-1,-1,drop_radius*max/100,-depth,page); } else { int x,y; switch(drop_position_x) { case 0: x=w/4; break; case 1: x=w/2; break; case 2: x=w*3/4; break; } switch(drop_position_y) { case 0: y=h/4; break; case 1: y=h/2; break; case 2: y=h*3/4; break; } SineBlob(x,y,drop_radius,-depth,page); } // HeightBlob(-1,-1,80/2,1400,page); } { int dx, dy; int x, y; int ofs,len=buffer_h*buffer_w; int offset=buffer_w + 1; int *ptr = buffers[page]; for (y = (buffer_h-1)*buffer_w; offset < y; offset += 2) { for (x = offset+buffer_w-2; offset < x; offset++) { dx = ptr[offset] - ptr[offset+1]; dy = ptr[offset] - ptr[offset+buffer_w]; ofs=offset + buffer_w*(dy>>3) + (dx>>3); if((ofs<len)&&(ofs>-1)) fbout[offset] = framebuffer[ofs]; else fbout[offset] = framebuffer[offset]; offset++; dx = ptr[offset] - ptr[offset+1]; dy = ptr[offset] - ptr[offset+buffer_w]; ofs=offset + buffer_w*(dy>>3) + (dx>>3); if((ofs<len)&&(ofs>-1)) fbout[offset] = framebuffer[ofs]; else fbout[offset] = framebuffer[offset]; } } } CalcWater(!page,density); page=!page; return 1; } // configuration dialog stuff static BOOL CALLBACK g_DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: if (g_ConfigThis->enabled) CheckDlgButton(hwndDlg,IDC_CHECK1,BST_CHECKED); SendDlgItemMessage(hwndDlg,IDC_DAMP,TBM_SETRANGEMIN,0,2); SendDlgItemMessage(hwndDlg,IDC_DAMP,TBM_SETRANGEMAX,0,10); SendDlgItemMessage(hwndDlg,IDC_DAMP,TBM_SETPOS,1,g_ConfigThis->density); SendDlgItemMessage(hwndDlg,IDC_DEPTH,TBM_SETRANGEMIN,0,100); SendDlgItemMessage(hwndDlg,IDC_DEPTH,TBM_SETRANGEMAX,0,2000); SendDlgItemMessage(hwndDlg,IDC_DEPTH,TBM_SETPOS,1,g_ConfigThis->depth); SendDlgItemMessage(hwndDlg,IDC_RADIUS,TBM_SETRANGEMIN,0,10); SendDlgItemMessage(hwndDlg,IDC_RADIUS,TBM_SETRANGEMAX,0,100); SendDlgItemMessage(hwndDlg,IDC_RADIUS,TBM_SETPOS,1,g_ConfigThis->drop_radius); CheckDlgButton(hwndDlg,IDC_RANDOM_DROP,g_ConfigThis->random_drop); CheckDlgButton(hwndDlg,IDC_DROP_LEFT,g_ConfigThis->drop_position_x==0); CheckDlgButton(hwndDlg,IDC_DROP_CENTER,g_ConfigThis->drop_position_x==1); CheckDlgButton(hwndDlg,IDC_DROP_RIGHT,g_ConfigThis->drop_position_x==2); CheckDlgButton(hwndDlg,IDC_DROP_TOP,g_ConfigThis->drop_position_y==0); CheckDlgButton(hwndDlg,IDC_DROP_MIDDLE,g_ConfigThis->drop_position_y==1); CheckDlgButton(hwndDlg,IDC_DROP_BOTTOM,g_ConfigThis->drop_position_y==2); return 1; case WM_DRAWITEM: return 0; case WM_COMMAND: if (LOWORD(wParam) == IDC_CHECK1) g_ConfigThis->enabled=IsDlgButtonChecked(hwndDlg,IDC_CHECK1)?1:0; if (LOWORD(wParam) == IDC_RANDOM_DROP) g_ConfigThis->random_drop=IsDlgButtonChecked(hwndDlg,IDC_RANDOM_DROP); if (LOWORD(wParam) == IDC_DROP_LEFT) g_ConfigThis->drop_position_x=0; if (LOWORD(wParam) == IDC_DROP_CENTER) g_ConfigThis->drop_position_x=1; if (LOWORD(wParam) == IDC_DROP_RIGHT) g_ConfigThis->drop_position_x=2; if (LOWORD(wParam) == IDC_DROP_TOP) g_ConfigThis->drop_position_y=0; if (LOWORD(wParam) == IDC_DROP_MIDDLE) g_ConfigThis->drop_position_y=1; if (LOWORD(wParam) == IDC_DROP_BOTTOM) g_ConfigThis->drop_position_y=2; return 0; case WM_HSCROLL: { HWND swnd = (HWND) lParam; int t = (int) SendMessage(swnd,TBM_GETPOS,0,0); if (swnd == GetDlgItem(hwndDlg,IDC_DAMP)) g_ConfigThis->density=t; if (swnd == GetDlgItem(hwndDlg,IDC_DEPTH)) g_ConfigThis->depth=t; if (swnd == GetDlgItem(hwndDlg,IDC_RADIUS)) g_ConfigThis->drop_radius=t; } return 0; } return 0; } HWND C_THISCLASS::conf(HINSTANCE hInstance, HWND hwndParent) // return NULL if no config dialog possible { g_ConfigThis = this; return CreateDialog(hInstance,MAKEINTRESOURCE(IDD_CFG_WATERBUMP),hwndParent,g_DlgProc); } // export stuff C_RBASE *R_WaterBump(char *desc) // creates a new effect object if desc is NULL, otherwise fills in desc with description { if (desc) { strcpy(desc,MOD_NAME); return NULL; } return (C_RBASE *) new C_THISCLASS(); } #else C_RBASE *R_WaterBump(char *desc) // creates a new effect object if desc is NULL, otherwise fills in desc with description {return NULL; } #endif
[ [ [ 1, 437 ] ] ]
a5194d9b3b5fb064cb712dba2aaf6b4c10ad3c61
971b000b9e6c4bf91d28f3723923a678520f5bcf
/PaperSizeScroll/href_gui.h
f167c6ec17144980605d55f0d21c0a8f3b33707e
[]
no_license
google-code-export/fop-miniscribus
14ce53d21893ce1821386a94d42485ee0465121f
966a9ca7097268c18e690aa0ea4b24b308475af9
refs/heads/master
2020-12-24T17:08:51.551987
2011-09-02T07:55:05
2011-09-02T07:55:05
32,133,292
2
0
null
null
null
null
UTF-8
C++
false
false
6,943
h
#ifndef HREF_GUI_H #define HREF_GUI_H #include <QStringList> #include <QActionGroup> #include <QColorDialog> #include <QPrinter> #include <QPrintDialog> #include <QFileDialog> #include <QFile> #include <QTextStream> #include <QMessageBox> #include <QTextDocumentFragment> #include <QTextCursor> #include <QFileDialog> #include <QString> #include <QTextStream> #include <QFontDatabase> #include <QTextBlockFormat> #include <QTextListFormat> #include <QTextFormat> #include <QTextList> #include <QTextCodec> #include <QByteArray> #include <QtCore/QVariant> #include <QtGui/QAction> #include <QtGui/QApplication> #include <QtGui/QButtonGroup> #include <QtGui/QComboBox> #include <QtGui/QDialog> #include <QtGui/QGridLayout> #include <QtGui/QHBoxLayout> #include <QtGui/QLabel> #include <QtGui/QLineEdit> #include <QtGui/QPushButton> #include <QtGui/QSpacerItem> #include <QtGui/QVBoxLayout> class Ui_Href_Gui { public: QGridLayout *gridLayout; QSpacerItem *spacerItem; QHBoxLayout *hboxLayout; QVBoxLayout *vboxLayout; QLabel *label; QLabel *label_2; QLabel *label_3; QVBoxLayout *vboxLayout1; QLineEdit *text_href; QComboBox *target_href; QComboBox *otext_href; QHBoxLayout *hboxLayout1; QSpacerItem *spacerItem1; QPushButton *okButton; QPushButton *cancelButton; void setupUi(QDialog *Href_Gui) { Href_Gui->setObjectName(QString::fromUtf8("Href_Gui")); Href_Gui->resize(QSize(420, 140).expandedTo(Href_Gui->minimumSizeHint())); QSizePolicy sizePolicy(static_cast<QSizePolicy::Policy>(0), static_cast<QSizePolicy::Policy>(0)); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(Href_Gui->sizePolicy().hasHeightForWidth()); Href_Gui->setSizePolicy(sizePolicy); Href_Gui->setMinimumSize(QSize(420, 140)); Href_Gui->setMaximumSize(QSize(420, 140)); gridLayout = new QGridLayout(Href_Gui); gridLayout->setSpacing(6); gridLayout->setMargin(9); gridLayout->setObjectName(QString::fromUtf8("gridLayout")); spacerItem = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); gridLayout->addItem(spacerItem, 1, 0, 1, 1); hboxLayout = new QHBoxLayout(); hboxLayout->setSpacing(6); hboxLayout->setMargin(0); hboxLayout->setObjectName(QString::fromUtf8("hboxLayout")); vboxLayout = new QVBoxLayout(); vboxLayout->setSpacing(6); vboxLayout->setMargin(0); vboxLayout->setObjectName(QString::fromUtf8("vboxLayout")); label = new QLabel(Href_Gui); label->setObjectName(QString::fromUtf8("label")); label->setTextFormat(Qt::PlainText); vboxLayout->addWidget(label); label_2 = new QLabel(Href_Gui); label_2->setObjectName(QString::fromUtf8("label_2")); label_2->setTextFormat(Qt::PlainText); vboxLayout->addWidget(label_2); label_3 = new QLabel(Href_Gui); label_3->setObjectName(QString::fromUtf8("label_3")); label_3->setTextFormat(Qt::PlainText); vboxLayout->addWidget(label_3); hboxLayout->addLayout(vboxLayout); vboxLayout1 = new QVBoxLayout(); vboxLayout1->setSpacing(6); vboxLayout1->setMargin(0); vboxLayout1->setObjectName(QString::fromUtf8("vboxLayout1")); text_href = new QLineEdit(Href_Gui); text_href->setObjectName(QString::fromUtf8("text_href")); vboxLayout1->addWidget(text_href); otext_href = new QComboBox(Href_Gui); otext_href->setObjectName(QString::fromUtf8("otext_href")); otext_href->setEditable (true); vboxLayout1->addWidget(otext_href); target_href = new QComboBox(Href_Gui); target_href->setObjectName(QString::fromUtf8("target_href")); vboxLayout1->addWidget(target_href); hboxLayout->addLayout(vboxLayout1); gridLayout->addLayout(hboxLayout, 0, 0, 1, 1); hboxLayout1 = new QHBoxLayout(); hboxLayout1->setSpacing(6); hboxLayout1->setMargin(0); hboxLayout1->setObjectName(QString::fromUtf8("hboxLayout1")); spacerItem1 = new QSpacerItem(131, 31, QSizePolicy::Expanding, QSizePolicy::Minimum); hboxLayout1->addItem(spacerItem1); okButton = new QPushButton(Href_Gui); okButton->setObjectName(QString::fromUtf8("okButton")); hboxLayout1->addWidget(okButton); cancelButton = new QPushButton(Href_Gui); cancelButton->setObjectName(QString::fromUtf8("cancelButton")); hboxLayout1->addWidget(cancelButton); gridLayout->addLayout(hboxLayout1, 2, 0, 1, 1); retranslateUi(Href_Gui); QMetaObject::connectSlotsByName(Href_Gui); } // setupUi void retranslateUi(QDialog *Href_Gui) { Href_Gui->setWindowTitle(QApplication::translate("Href_Gui", "Url / www", 0, QApplication::UnicodeUTF8)); label->setText(QApplication::translate("Href_Gui", "Text:", 0, QApplication::UnicodeUTF8)); label_2->setText(QApplication::translate("Href_Gui", "Url:", 0, QApplication::UnicodeUTF8)); label_3->setText(QApplication::translate("Href_Gui", "Target / Name:", 0, QApplication::UnicodeUTF8)); target_href->clear(); target_href->addItem(QApplication::translate("Href_Gui", "_top", 0, QApplication::UnicodeUTF8)); target_href->addItem(QApplication::translate("Href_Gui", "_self", 0, QApplication::UnicodeUTF8)); target_href->addItem(QApplication::translate("Href_Gui", "_blank", 0, QApplication::UnicodeUTF8)); target_href->addItem(QApplication::translate("Href_Gui", "_main", 0, QApplication::UnicodeUTF8)); target_href->addItem(QApplication::translate("Href_Gui", "_menu", 0, QApplication::UnicodeUTF8)); target_href->addItem(QApplication::translate("Href_Gui", "#name", 0, QApplication::UnicodeUTF8)); okButton->setText(QApplication::translate("Href_Gui", "OK", 0, QApplication::UnicodeUTF8)); cancelButton->setText(QApplication::translate("Href_Gui", "Cancel", 0, QApplication::UnicodeUTF8)); Q_UNUSED(Href_Gui); } // retranslateUi }; namespace Ui { class Href_Gui: public Ui_Href_Gui {}; } // namespace Ui // /* Save file as href_gui.h */ /* Class Href_Gui Created on Fri Jun 2 11:13:27 CEST 2006 */ // #include <QPointer> #include <QStringList> /* typedef QMap<int, QStringList> Userconf;*/ class Href_Gui : public QDialog, public Ui::Href_Gui { Q_OBJECT // public: Href_Gui( QWidget* = 0 ); static Href_Gui* self( QWidget* = 0 ); inline QComboBox *linker() { return otext_href; } QStringList GetUserConfig(); static QPointer<Href_Gui> _self; // protected: void closeEvent( QCloseEvent* ); // private: QStringList hrefconfisuser; // public slots: void Acceptvars(); void reject(); void urlChanged( const int index ); }; // #endif // HREF_GUI_H
[ "ppkciz@9af58faf-7e3e-0410-b956-55d145112073" ]
[ [ [ 1, 230 ] ] ]
f5dc2102c419a2a5ef571e04d14d47738938aff0
15732b8e4190ae526dcf99e9ffcee5171ed9bd7e
/SRC/Queue/dualqueue.cc
1558ebde058ed29b2b95fecd233089aee27f3009
[]
no_license
clovermwliu/whutnetsim
d95c07f77330af8cefe50a04b19a2d5cca23e0ae
924f2625898c4f00147e473a05704f7b91dac0c4
refs/heads/master
2021-01-10T13:10:00.678815
2010-04-14T08:38:01
2010-04-14T08:38:01
48,568,805
0
0
null
null
null
null
UTF-8
C++
false
false
14,589
cc
// GENERAL PUBLIC LICENSE AGREEMENT // // PLEASE READ THIS DOCUMENT CAREFULLY BEFORE UTILIZING THE PROGRAM // // BY UTILIZING THIS PROGRAM, YOU AGREE TO BECOME BOUND BY THE TERMS OF // THIS LICENSE. IF YOU DO NOT AGREE TO THE TERMS OF THIS LICENSE, DO // NOT USE THIS PROGRAM OR ANY PORTION THEREOF IN ANY FORM OR MANNER. // // This Program is licensed, not sold to you by GEORGIA TECH RESEARCH // CORPORATION ("GTRC"), owner of all code and accompanying documentation // (hereinafter "Program"), for use only under the terms of this License, // and GTRC reserves any rights not expressly granted to you. // // 1. This License allows you to: // // (a) make copies and distribute copies of the Program's source code // provide that any such copy clearly displays any and all appropriate // copyright notices and disclaimer of warranty as set forth in Article 5 // and 6 of this License. All notices that refer to this License and to // the absence of any warranty must be kept intact at all times. A copy // of this License must accompany any and all copies of the Program // distributed to third parties. // // A fee may be charged to cover the cost associated with the physical // act of transferring a copy to a third party. At no time shall the // program be sold for commercial gain either alone or incorporated with // other program(s) without entering into a separate agreement with GTRC. // // // (b) modify the original copy or copies of the Program or any portion // thereof ("Modification(s)"). Modifications may be copied and // distributed under the terms and conditions as set forth above, // provided the following conditions are met: // // i) any and all modified files must be affixed with prominent // notices that you have changed the files and the date that the changes // occurred. // // ii) any work that you distribute, publish, or make available, that // in whole or in part contains portions of the Program or derivative // work thereof, must be licensed at no charge to all third parties under // the terms of this License. // // iii) if the modified program normally reads commands interactively // when run, you must cause it, when started running for such interactive // use in the most ordinary way, to display and/or print an announcement // with all appropriate copyright notices and disclaimer of warranty as // set forth in Article 5 and 6 of this License to be clearly displayed. // In addition, you must provide reasonable access to this License to the // user. // // Any portion of a Modification that can be reasonably considered // independent of the Program and separate work in and of itself is not // subject to the terms and conditions set forth in this License as long // as it is not distributed with the Program or any portion thereof. // // // 2. This License further allows you to copy and distribute the Program // or a work based on it, as set forth in Article 1 Section b in // object code or executable form under the terms of Article 1 above // provided that you also either: // // i) accompany it with complete corresponding machine-readable source // code, which must be distributed under the terms of Article 1, on a // medium customarily used for software interchange; or, // // ii) accompany it with a written offer, valid for no less than three // (3) years from the time of distribution, to give any third party, for // no consideration greater than the cost of physical transfer, a // complete machine-readable copy of the corresponding source code, to be // distributed under the terms of Article 1 on a medium customarily used // for software interchange; or, // // // 3. Export Law Assurance. // // You agree that the Software will not be shipped, transferred or // exported, directly into any country prohibited by the United States // Export Administration Act and the regulations thereunder nor will be // used for any purpose prohibited by the Act. // // 4. Termination. // // If at anytime you are unable to comply with any portion of this // License you must immediately cease use of the Program and all // distribution activities involving the Program or any portion thereof. // // // 5. Disclaimer of Warranties and Limitation on Liability. // // YOU ACCEPT THE PROGRAM ON AN "AS IS" BASIS. GTRC MAKES NO WARRANTY // THAT ALL ERRORS CAN BE OR HAVE BEEN ELIMINATED FROM PROGRAM. GTRC // SHALL NOT BE RESPONSIBLE FOR LOSSES OF ANY KIND RESULTING FROM THE USE // OF PROGRAM AND ITS ACCOMPANYING DOCUMENT(S), AND CAN IN NO WAY PROVIDE // COMPENSATION FOR ANY LOSSES SUSTAINED, INCLUDING BUT NOT LIMITED TO // ANY OBLIGATION, LIABILITY, RIGHT, CLAIM OR REMEDY FOR TORT, OR FOR ANY // ACTUAL OR ALLEGED INFRINGEMENT OF PATENTS, COPYRIGHTS, TRADE SECRETS, // OR SIMILAR RIGHTS OF THIRD PARTIES, NOR ANY BUSINESS EXPENSE, MACHINE // DOWNTIME OR DAMAGES CAUSED TO YOU BY ANY DEFICIENCY, DEFECT OR ERROR // IN PROGRAM OR MALFUNCTION THEREOF, NOR ANY INCIDENTAL OR CONSEQUENTIAL // DAMAGES, HOWEVER CAUSED. GTRC DISCLAIMS ALL WARRANTIES, BOTH EXPRESS // AND IMPLIED RESPECTING THE USE AND OPERATION OF PROGRAM AND ITS // ACCOMPANYING DOCUMENTATION, INCLUDING ALL IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR PARTICULAR PURPOSE AND ANY IMPLIED // WARRANTY ARISING FROM COURSE OF PERFORMANCE, COURSE OF DEALING OR // USAGE OF TRADE. GTRC MAKES NO WARRANTY THAT PROGRAM IS ADEQUATELY OR // COMPLETELY DESCRIBED IN, OR BEHAVES IN ACCORDANCE WITH ANY // ACCOMPANYING DOCUMENTATION. THE USER OF PROGRAM IS EXPECTED TO MAKE // THE FINAL EVALUATION OF PROGRAM'S USEFULNESS IN USER'S OWN // ENVIRONMENT. // // GTRC represents that, to the best of its knowledge, the software // furnished hereunder does not infringe any copyright or patent. // // GTRC shall have no obligation for support or maintenance of Program. // // 6. Copyright Notice. // // THE SOFTWARE AND ACCOMPANYING DOCUMENTATION ARE COPYRIGHTED WITH ALL // RIGHTS RESERVED BY GTRC. UNDER UNITED STATES COPYRIGHT LAWS, THE // SOFTWARE AND ITS ACCOMPANYING DOCUMENTATION MAY NOT BE COPIED EXCEPT // AS GRANTED HEREIN. // // You acknowledge that GTRC is the sole owner of Program, including all // copyrights subsisting therein. Any and all copies or partial copies // of Program made by you shall bear the copyright notice set forth below // and affixed to the original version or such other notice as GTRC shall // designate. Such notice shall also be affixed to all improvements or // enhancements of Program made by you or portions thereof in such a // manner and location as to give reasonable notice of GTRC's copyright // as set forth in Article 1. // // Said copyright notice shall read as follows: // // Copyright 2004 // Dr. George F. Riley // Georgia Tech Research Corporation // Atlanta, Georgia 30332-0415 // All Rights Reserved // // $Id: dualqueue.cc,v 1.5 2004/09/17 16:11:02 riley Exp $ // Georgia Tech Network Simulator - Dual Queue Class Definition // George F. Riley. Georgia Tech, Spring 2003 // The "dual" queue implements a private queue for TCP traffic // and another queue for all others. The two queues are scheduled // in a work-conserving round-robin method. //#define DEBUG_MASK 0x02 #include "G_debug.h" #include "dualqueue.h" #include "ipv4.h" #include "tcp.h" #include "simulator.h" using namespace std; // DualQueue constructors DualQueue::DualQueue() : Queue(true), limit(Queue::DefaultLength()), pktLimit(0), lastTCP(true), tcpEmpty(0), udpEmpty(0) { pTCP = Queue::Default().Copy(); pNonTCP = Queue::Default().Copy(); } DualQueue::DualQueue(Count_t l) : Queue(true), limit(l), pktLimit(0), lastTCP(true), tcpEmpty(0), udpEmpty(0) { pTCP = Queue::Default().Copy(); pTCP->SetLimit(l); pNonTCP = Queue::Default().Copy(); pNonTCP->SetLimit(l); } // Specify the queues for tcp and non-tcp DualQueue::DualQueue(const Queue& t, const Queue& n) : Queue(true) { pTCP = t.Copy(); pNonTCP = n.Copy(); limit = t.GetLimit(); pktLimit = t.GetLimitPkts(); lastTCP = true; } // Copy constructor DualQueue::DualQueue(const DualQueue& c) : Queue(c), limit(c.limit), pktLimit(c.pktLimit) { pTCP = c.TCPQueue()->Copy(); pNonTCP = c.NonTCPQueue()->Copy(); lastTCP = c.LastTCP(); } // Destructor DualQueue::~DualQueue() { if (pTCP) delete pTCP; if (pNonTCP) delete pNonTCP; } // Inherited methods from Queue bool DualQueue::Enque(Packet* p) { // Return true if enqued, false if not DEBUG0((cout << "DQ " << this << " enquing size " << p->Size() << endl)); bool b; if (IsTCP(p)) { b = pTCP->Enque(p); DEBUG(1,(cout << "DQ " << this << " enqTCP, size " << pTCP->LengthPkts() << " time " << Simulator::Now() << endl)); if (!b) DEBUG0((cout << "DQ " << this << " dropping TCP pkt" << endl)); return b; } // Not TCP b = pNonTCP->Enque(p); DEBUG(1,(cout << "DQ " << this << " enqNonTCP, size " << pNonTCP->LengthPkts() << " time " << Simulator::Now() << endl)); if (!b) DEBUG(1,(cout << "DQ " << this << " dropping NonTCP pkt" << endl)); return b; } Packet* DualQueue::Deque() { // Return next element (NULL if none) bool useTCP; if (lastTCP) { // Try to use Non-TCP next, if non-empty useTCP = (pNonTCP->LengthPkts() == 0); // UDP is empty if (useTCP) udpEmpty++; // Count times UDP gave up slot } else { useTCP = (pTCP->LengthPkts()); // TCP is not empty if (!useTCP) tcpEmpty++; // Count times TCP gave up slot } if (useTCP) { DEBUG(1,(cout << "DQ " << this << " deque TCP" << " size " << pTCP->LengthPkts() << " time " << Simulator::Now() << endl)); lastTCP = true; return pTCP->Deque(); } else { DEBUG(1,(cout << "DQ " << this << " deque NonTCP" << " size " << pNonTCP->LengthPkts() << " time " << Simulator::Now() << endl)); lastTCP = false; return pNonTCP->Deque(); } } Packet* DualQueue::PeekDeque() { // Peek at next element (NULL if none) bool useTCP; if (lastTCP) { // Try to use Non-TCP next, if non-empty useTCP = (pNonTCP->LengthPkts() == 0); // UDP is empty } else { useTCP = (pTCP->LengthPkts()); // TCP is not empty } if (useTCP) { return pTCP->PeekDeque(); } else { return pNonTCP->PeekDeque(); } } // Most of the following should not be used for DualQueues. // Rather, the values should be retrived for the TCP/NonTCP queues directly Count_t DualQueue::Length() { // How many bytes are enqued? return pTCP->Length() + pNonTCP->Length(); } Count_t DualQueue::LengthPkts() { // How many packets are enqued? return pTCP->LengthPkts() + pNonTCP->LengthPkts(); } Queue* DualQueue::Copy() const { // Make a copy of this queue return new DualQueue(*this); } void DualQueue::SetLimit(Count_t l) { // Set new limit pTCP->SetLimit(l); pNonTCP->SetLimit(l); } Count_t DualQueue::GetLimit() const { // Get limit (bytes) return pTCP->GetLimit() + pNonTCP->GetLimit(); // ?? Is this right? } void DualQueue::SetLimitPkts(Count_t l) {// Set packets limit pTCP->SetLimitPkts(l); pNonTCP->SetLimitPkts(l); return; } Count_t DualQueue::GetLimitPkts() const { // Set packets limit return pTCP->GetLimitPkts() + pNonTCP->GetLimitPkts(); // ?? Is this right? } bool DualQueue::Check(Size_t s, Packet* p) { // Test if buffer space available if (IsTCP(p)) return pTCP->Check(s, p); return pNonTCP->Check(s, p); } bool DualQueue::Detailed() { // True if detailed model w/ local queing return true; } void DualQueue::Detailed(bool d) { // Set detailed on/off pTCP->Detailed(d); pNonTCP->Detailed(d); } Time_t DualQueue::QueuingDelay() { // Calculate queuing delay at current lth return 0.0; // Not sure here } DCount_t DualQueue::TotalWorkload() { // Return the byte-seconds (workload) return pTCP->TotalWorkload() + pNonTCP->TotalWorkload(); } void DualQueue::SetInterface(Interface* i) { // Let the q know which interface pTCP->SetInterface(i); pNonTCP->SetInterface(i); } Count_t DualQueue::DropCount() { // Number of dropped packets return pTCP->DropCount() + pNonTCP->DropCount(); } Count_t DualQueue:: EnqueueCount() { // Number of enqueued packets return pTCP->EnqueueCount() + pNonTCP->EnqueueCount(); } void DualQueue::CountEnq(Packet* p) { // Count an enque if (IsTCP(p)) return pTCP->CountEnq(p); return pNonTCP->CountEnq(p); } void DualQueue::ResetStats() { // Reset the statistics to zero pTCP->ResetStats(); pNonTCP->ResetStats(); tcpEmpty = 0; udpEmpty = 0; } Packet* DualQueue::GetPacket(Count_t k) { return nil; // Code this later } void DualQueue::GetPacketColors(ColorVec_t&) { // Code later } // Methods specific to DualQueue void DualQueue::TCPQueue(const Queue& q) { if (pTCP) delete pTCP; pTCP = q.Copy(); } void DualQueue::NonTCPQueue(const Queue& q) { if (pNonTCP) delete pNonTCP; pNonTCP = q.Copy(); } // Private Methods bool DualQueue::IsTCP(Packet* p) { if (!p) return false; // Can't tell if no packet // We need to inspect the PDU's to see this is TCP packet or not Count_t offset = 0; PDU* pdu; while((pdu = p->PeekPDU(offset++))) { Layer_t l = pdu->Layer(); switch(l) { case 0 : // Unknown break; case 3 : // IP { Count_t v = pdu->Version(); // Get version switch(v) { case 4 : { // Process IPV4 IPV4Header* h = (IPV4Header*)pdu; return h->protocol == 6; } break; case 6 : // Process IPV6, Not implemented yet return false; // Need to code this break; } } break; case 4 : // TCP or UDP { L4PDU* l4 = (L4PDU*)pdu; return l4->Proto() == 6; } break; } } // Can't find, assume not TCP return false; }
[ "pengelmer@f37e807c-cba8-11de-937e-2741d7931076" ]
[ [ [ 1, 442 ] ] ]
6f00dd205642b18f9fe818ae84b05184792eff85
b38ab5dcfb913569fc1e41e8deedc2487b2db491
/libraries/compromise/Registry.cpp
9604aa25e82a3a756634c45e2591314484816940
[]
no_license
santosh90n/Fury2
dacec86ab3972952e4cf6442b38e66b7a67edade
740a095c2daa32d33fdc24cc47145a1c13431889
refs/heads/master
2020-03-21T00:44:27.908074
2008-10-16T07:09:17
2008-10-16T07:09:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
14,625
cpp
/* Compromise (COM virtual registration library) Copyright (C) 2006 Kevin Gadd This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "global.hpp" extern unsigned GetRegistryRootCount(); extern const RegistryRoot& GetRegistryRoot(unsigned index); extern unsigned GetRegKeyHandle(); extern LONG WINAPI Real_RegOpenKeyExW(HKEY a0, LPCWSTR a1, DWORD a2, REGSAM a3, PHKEY a4); unsigned RegKeyDefine(VirtualRegKey *Key) { unsigned id = GetRegKeyHandle(); (*pRegistryHandles)[id] = new RegKeyHandle(id, Key, WString(Key->Name)); return id; } void RegKeyDefine(unsigned newID, unsigned oldID) { if (newID == oldID) return; assert(!((newID >= 0x80000000) && (newID < 0x90000000))); //RegKeyHandles::iterator iter = pRegistryHandles->find(newID); //if (iter != pRegistryHandles->end()) // assert(false); RegKeyHandles::iterator iter = pRegistryHandles->find(oldID); if (iter == pRegistryHandles->end()) { } else { (*pRegistryHandles)[newID] = new RegKeyHandle(*(iter->second)); (*pRegistryHandles)[newID]->ID = newID; } } void RegKeyDefine(unsigned ID, VirtualRegKey *Key) { assert(!((ID >= 0x80000000) && (ID < 0x90000000))); (*pRegistryHandles)[ID] = new RegKeyHandle(ID, Key, Key->Name); } void RegKeyNameDefine(unsigned ID, const WString& Name) { assert(!((ID >= 0x80000000) && (ID < 0x90000000))); RegKeyHandles::iterator iter = pRegistryHandles->find(ID); if (iter == pRegistryHandles->end()) { assert(Name.Length < 256); (*pRegistryHandles)[ID] = new RegKeyHandle(ID, Name); } else { // Already defined (*pRegistryHandles)[ID]->Name = Name; } return; } void RegKeyNameResolve(unsigned ID, WString** Out) { *Out = 0; RegKeyHandles::iterator iter = pRegistryHandles->find(ID); if (iter == pRegistryHandles->end()) { return; } else { *Out = &(iter->second->Name); return; } } VirtualRegKey* RegKeyGetPtr(unsigned ID) { RegKeyHandles::iterator iter = pRegistryHandles->find(ID); VirtualRegKey* ptr = Null; if (iter == pRegistryHandles->end()) { for (unsigned r = 0; r < GetRegistryRootCount(); r++) { if (ID == (unsigned)(GetRegistryRoot(r).ID)) { return VRegKeyResolve(GetRegistryRoot(r).Name); } } return Null; } else { ptr = iter->second->Key; //if (ptr) // ptr->Name = iter->second->Name; return ptr; } } bool RegKeyIsDeleted(unsigned ID) { RegKeyHandles::iterator iter = pRegistryHandles->find(ID); VirtualRegKey* ptr = Null; if (iter == pRegistryHandles->end()) { return false; } else { ptr = iter->second->Key; if (ptr) return ptr->Deleted; return false; } } void RegKeysInvalidate(VirtualRegKey *Key) { assert(false); RegKeyHandles::iterator iter = pRegistryHandles->begin(); while (!(iter == pRegistryHandles->end())) { if (iter->second->Key == Key) { iter->second->Key = Null; } ++iter; } } int RegKeyUndefine(unsigned ID) { if (ID >= 0x80000000 && ID < 0x90000000) return 0; RegKeyHandles::iterator iter = pRegistryHandles->find(ID); if (iter == pRegistryHandles->end()) { return ERROR_INVALID_HANDLE; } else { if (iter->second->ID == ID) { assert(!((iter->second->ID >= 0x80000000) && (iter->second->ID < 0x90000000))); RegKeyHandle* handle = iter->second; iter->second = 0; pRegistryHandles->erase(iter); handle->ID = 0; handle->Key = 0; handle->Name.Erase(); delete handle; return 0; } else { return ERROR_INVALID_HANDLE; } } } bool RegKeyGetVirtual(unsigned ID) { if (ID >= VirtualRegKeyBase) { return true; } else { RegKeyHandles::iterator iter = pRegistryHandles->find(ID); if (iter == pRegistryHandles->end()) { return false; } else { return (iter->second->Key != Null); } } } bool RegKeyGetVirtual(HKEY Key) { return RegKeyGetVirtual(unsigned(Key)); } VirtualRegKey* VRegKeyCreate(const WString& Path) { VirtualRegKey* key = Null;//VRegKeyResolve(Path); //if (key) { // return key; //} else { wstringstream buffer; vector<WString> *parts = Path.Split(L'\\'); vector<WString>::iterator iter; int i = 0; for (iter = parts->begin(); iter != parts->end(); ++iter) { if (iter->Length) { VirtualRegKey* ikey = Null; if (i) buffer << L"\\"; buffer << *iter; WString newName(buffer.str().c_str()); WString iterLow(iter->ToLower()); ikey = Null; if (!key) { ikey = get(pRegistry->Keys, iterLow); if (ikey) assert(ikey->Name.EndsWithI(iterLow)); } else { ikey = get(key->Children, iterLow); if (ikey) assert(ikey->Name.EndsWithI(iterLow)); } if (!ikey) { if (key == Null) { DebugOut_("key==Null at " << *iter << " in " << Path << "\n"); assert(false); } key->Deleted = false; VirtualRegKey newKey = VirtualRegKey(newName); newKey.Default.Text = WString(); key->Children[iterLow] = newKey; ikey = key = get(key->Children, iterLow); } else { if (ikey->Name.EqualsI(newName)) { if (ikey && ikey->Deleted) ikey->Deleted = false; key = ikey; } else { VRegDump(*key); assert(false); } } i++; } } delete parts; if (key == 0) assert(false); return key; //} } bool VRegKeyIsDeleted(const WString& Path) { vector<WString> *parts = Path.ToLower().Split(L'\\'); vector<WString>::iterator iter; VirtualRegKey* key = Null; VirtualRegKey* lastKey = Null; WString* part = Null; for (iter = parts->begin(); iter != parts->end(); ++iter) { VirtualRegKey* ikey = Null; if (!key) { ikey = get(pRegistry->Keys, iter->ToLower()); } else { ikey = get(key->Children, iter->ToLower()); } if (!ikey) { delete parts; return false; } else { if (ikey->Deleted) { delete parts; return true; } } key = ikey; } delete parts; return false; } int VRegKeyDelete(const WString& Path) { vector<WString> *parts = Path.ToLower().Split(L'\\'); vector<WString>::iterator iter; VirtualRegKey* key = Null; VirtualRegKey* lastKey = Null; WString* part = Null; for (iter = parts->begin(); iter != parts->end(); ++iter) { VirtualRegKey* ikey = Null; if (!key) { ikey = get(pRegistry->Keys, iter->ToLower()); } else { ikey = get(key->Children, iter->ToLower()); } if (!ikey) { delete parts; return 0; } lastKey = key; key = ikey; part = &(*iter); } if ((lastKey) && (key)) { key->Deleted = true; delete parts; return 1; } delete parts; return 0; } VirtualRegKey* VRegKeyResolve (const WString& Path) { if (Path.Find(L'\\') >= 0) { vector<WString> *parts = Path.ToLower().Split(L'\\'); vector<WString>::iterator iter; VirtualRegKey* key = Null; VirtualRegKey* result = Null; unsigned i = 0; unsigned c = parts->size(); for (iter = parts->begin(); iter != parts->end(); ++iter) { if (!key) { result = key = get(pRegistry->Keys, *iter); if (!key) break; } else { result = key = get(key->Children, *iter); if (!key) break; } i++; } delete parts; if (i < c) return Null; return result; } else { // Root name return &(pRegistry->Keys[Path]); } return Null; } VirtualRegKey* VRegKeyResolve (VirtualRegKey* Parent, const WString& Path) { assert(Parent); vector<WString> *parts = Path.ToLower().Split(L'\\'); vector<WString>::iterator iter; VirtualRegKey* key = Null; VirtualRegKey* result = Null; unsigned i = 0; unsigned c = parts->size(); for (iter = parts->begin(); iter != parts->end(); ++iter) { if (!key) { result = key = get(Parent->Children, *iter); if (!key) break; } else { result = key = get(key->Children, *iter); if (!key) break; } i++; } delete parts; if (i < c) return Null; return result; } VirtualRegValue* VRegValueGet (VirtualRegKey* Key, const WString& Name) { assert(Key); if (Name.size() == 0) { VirtualRegValue* ptr = &(Key->Default); return ptr; } else { VirtualRegKey* child = get(Key->Children, Name.ToLower()); VirtualRegValue* ptr = get(Key->Values, Name.ToLower()); if (child) ptr = &(child->Default); return ptr; } } VirtualRegValue* VRegValueSet (VirtualRegKey* Key, const VirtualRegValue& Value) { assert(Key); if (Value.Name.size() == 0) { Key->Default = Value; return &(Key->Default); } else { WString keyString = Value.Name.ToLower(); VirtualRegValue* ptr = get(Key->Values, keyString); if (ptr) { *ptr = Value; } else { Key->Values[keyString] = Value; ptr = get(Key->Values, keyString); } return ptr; } } LONG Virtual_RegOpenKeyEx(HKEY a0, WString a1, DWORD a2, REGSAM a3, PHKEY a4) { unsigned hKey = unsigned(a0); VirtualRegKey* key = RegKeyGetPtr(hKey); if (key) { if (key->Deleted) { *a4 = Null; return ERROR_ACCESS_DENIED; } key = VRegKeyResolve(key, a1); if (key) { if (key->Deleted) { *a4 = Null; return ERROR_ACCESS_DENIED; } else { *a4 = (HKEY)RegKeyDefine(key); return ERROR_SUCCESS; } } else { *a4 = Null; return ERROR_FILE_NOT_FOUND; } } else { *a4 = Null; return ERROR_INVALID_HANDLE; } } LONG Virtual_RegCreateKeyEx(HKEY a0, WString a1, DWORD a2, DWORD a3, DWORD a4, REGSAM a5, LPSECURITY_ATTRIBUTES a6, PHKEY a7, LPDWORD a8) { wstringstream buffer; WString *keyname = 0; RegKeyNameResolve(unsigned(a0), &keyname); if (keyname) assert(keyname->Length > 0); else return ERROR_INVALID_HANDLE; buffer << keyname; buffer << L"\\"; buffer << a1; WString sKey = WString(buffer.str().c_str()); VirtualRegKey* ptr = VRegKeyCreate(sKey); if (ptr) { unsigned key = RegKeyDefine(ptr); //RegKeyNameDefine(key, sKey); *a7 = reinterpret_cast<HKEY>(key); DebugOut_("Created " << sKey << "\n"); return ERROR_SUCCESS; } else { *a7 = Null; return ERROR_INVALID_HANDLE; } } LONG Virtual_RegSetValueEx(HKEY a0, WString a1, DWORD a2, DWORD a3, BYTE* a4, DWORD a5, bool wide) { unsigned hKey = unsigned(a0); VirtualRegKey* key = RegKeyGetPtr(hKey); if (!key) { wstringstream buffer; WString *keyname; RegKeyNameResolve(unsigned(a0), &keyname); buffer << keyname; key = VRegKeyCreate(WString(buffer.str().c_str())); } if (key) { VRegValueSet(key, VirtualRegValue(a1, getRegValueType(a3), a4, a5, wide)); return ERROR_SUCCESS; } else { return ERROR_INVALID_HANDLE; } } LONG Virtual_RegQueryValueEx(HKEY a0, WString a1, LPDWORD a2, LPDWORD a3, LPBYTE a4, LPDWORD a5, bool wide) { unsigned hKey = unsigned(a0); VirtualRegKey* key = RegKeyGetPtr(hKey); if (key) { VirtualRegValue* value = VRegValueGet(key, a1); if (value) { if (a3) *a3 = convertRegValueType(value->Type); switch (value->Type) { case RegString: { if (wide) { const wchar_t* src = value->Text.pointer(); DWORD sz = 4096; if (a5) { sz = *a5; if (a4) memset(a4, 0, sz); } sz = min(sz, (value->Text.size()+1) * sizeof(wchar_t)); if (a5) *a5 = sz; if (a4) { memcpy(a4, src, sz); } } else { AString temp(value->Text); const char* src = temp.pointer(); DWORD sz = 4096; if (a5) { sz = *a5; if (a4) memset(a4, 0, sz); } sz = min(sz, temp.size()+1); if (a5) *a5 = sz; if (a4) { memcpy(a4, src, sz); } } break; } case RegDWord: { DWORD temp = value->DWord; if (*a5 >= sizeof(DWORD)) { if (a4) memcpy(a4, &temp, sizeof(DWORD)); *a5 = sizeof(DWORD); } break; } } return ERROR_SUCCESS; } else { if (a4 && a5) memset(a4, 0, *a5); return ERROR_FILE_NOT_FOUND; } } else { if (a4 && a5) memset(a4, 0, *a5); return ERROR_INVALID_HANDLE; } } void VRegDump(const VirtualRegKey& key) { DebugOut_(key.Name << "\\\n"); { DebugOut_("Default=" << key.Default.Text << "\n"); VirtualRegValues::const_iterator iter = key.Values.begin(); while (iter != key.Values.end()) { DebugOut_(iter->second.Name << "=" << iter->second.Text << "\n"); ++iter; } } { VirtualRegKeys::const_iterator iter = key.Children.begin(); while (iter != key.Children.end()) { VRegDump(iter->second); ++iter; } } } void VRegDump() { VirtualRegKeys::const_iterator iter = pRegistry->Keys.begin(); while (iter != pRegistry->Keys.end()) { VRegDump(iter->second); ++iter; } } void VRegFree() { pRegistry->Keys.clear(); }
[ "janus@1af785eb-1c5d-444a-bf89-8f912f329d98" ]
[ [ [ 1, 529 ] ] ]
c847f4ce5065970ad690b08769df5f297ced5732
2d4221efb0beb3d28118d065261791d431f4518a
/OIDE源代码/OLIDE/Controls/scintilla/scintillawrappers/ScintillaCtrl.h
0b56bf0f96c12a892b48d6678af8ca7d27aa46d1
[]
no_license
ophyos/olanguage
3ea9304da44f54110297a5abe31b051a13330db3
38d89352e48c2e687fd9410ffc59636f2431f006
refs/heads/master
2021-01-10T05:54:10.604301
2010-03-23T11:38:51
2010-03-23T11:38:51
48,682,489
1
0
null
null
null
null
UTF-8
C++
false
false
30,882
h
/* Module : ScintillaCtrl.h Purpose: Defines the interface for an MFC wrapper class for the Scintilla edit control (www.scintilla.org) Created: PJN / 19-03-2004 Copyright (c) 2004 - 2008 by PJ Naughter. (Web: www.naughter.com, Email: [email protected]) All rights reserved. Copyright / Usage Details: You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise) when your product is released in binary form. You are allowed to modify the source code in any way you want except you cannot modify the copyright details at the top of each module. If you want to distribute source code with your application, then you are only allowed to distribute versions released by the author. This is to maintain a single distribution point for the source code. */ //////////////////// Macros / Defines ///////////////////////////////////////// #pragma once #ifndef __SCINTILLACTRL_H__ #define __SCINTILLACTRL_H__ #ifndef SCINTILLA_H #pragma message("To avoid this message, please put scintilla.h in your pre compiled header (normally stdafx.h)") #include <Scintilla.h> #endif #ifndef SCINTILLACTRL_EXT_CLASS #define SCINTILLACTRL_EXT_CLASS #endif //////////////////// Classes ////////////////////////////////////////////////// class SCINTILLACTRL_EXT_CLASS CScintillaCtrl : public CWnd { public: //Constructors / Destructors CScintillaCtrl(); virtual ~CScintillaCtrl(); //Creation BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, DWORD dwExStyle = 0, LPVOID lpParam = NULL); //Misc void SetupDirectAccess(); inline LRESULT Call(UINT message, WPARAM wParam, LPARAM lParam, BOOL bDirect = TRUE); LRESULT GetDirectFunction(); LRESULT GetDirectPointer(); CString GetSelText(); //Unicode support #ifdef _UNICODE void AddText(int length, const wchar_t* text, BOOL bDirect = TRUE); void InsertText(long pos, const wchar_t* text, BOOL bDirect = TRUE); int GetSelText(wchar_t* text, BOOL bDirect = TRUE); int GetCurLine(int length, wchar_t* text, BOOL bDirect = TRUE); void StyleSetFont(int style, const wchar_t* fontName, BOOL bDirect = TRUE); void SetWordChars(const wchar_t* characters, BOOL bDirect = TRUE); void AutoCShow(int lenEntered, const wchar_t* itemList, BOOL bDirect = TRUE); void AutoCStops(const wchar_t* characterSet, BOOL bDirect = TRUE); void AutoCSelect(const wchar_t* text, BOOL bDirect = TRUE); void AutoCSetFillUps(const wchar_t* characterSet, BOOL bDirect = TRUE); void UserListShow(int listType, const wchar_t* itemList, BOOL bDirect = TRUE); int GetLine(int line, wchar_t* text, BOOL bDirect = TRUE); void ReplaceSel(const wchar_t* text, BOOL bDirect = TRUE); void SetText(const wchar_t* text, BOOL bDirect = TRUE); int GetText(int length, wchar_t* text, BOOL bDirect = TRUE); int ReplaceTarget(int length, const wchar_t* text, BOOL bDirect = TRUE); int ReplaceTargetRE(int length, const wchar_t* text, BOOL bDirect = TRUE); int SearchInTarget(int length, const wchar_t* text, BOOL bDirect = TRUE); void CallTipShow(long pos, const wchar_t* definition, BOOL bDirect = TRUE); int TextWidth(int style, const wchar_t* text, BOOL bDirect = TRUE); void AppendText(int length, const wchar_t* text, BOOL bDirect = TRUE); int SearchNext(int flags, const wchar_t* text, BOOL bDirect = TRUE); int SearchPrev(int flags, const wchar_t* text, BOOL bDirect = TRUE); void CopyText(int length, const wchar_t* text, BOOL bDirect = TRUE); void SetWhitespaceChars(const wchar_t* characters, BOOL bDirect = TRUE); void SetProperty(const wchar_t* key, const wchar_t* value, BOOL bDirect = TRUE); void SetKeyWords(int keywordSet, const wchar_t* keyWords, BOOL bDirect = TRUE); void SetLexerLanguage(const wchar_t* language, BOOL bDirect = TRUE); void LoadLexerLibrary(const wchar_t* path, BOOL bDirect = TRUE); int GetProperty(const wchar_t* key, wchar_t* buf, BOOL bDirect = TRUE); int GetPropertyExpanded(const wchar_t* key, wchar_t* buf, BOOL bDirect = TRUE); int GetPropertyInt(const wchar_t* key, BOOL bDirect = TRUE); int StyleGetFont(int style, wchar_t* fontName, BOOL bDirect = TRUE); static int UTF82W(const char* pszText, int nLength, wchar_t*& pszWText); static int W2UTF8(const wchar_t* pszText, int nLength, char*& pszUTF8Text); #endif //A special version of GetLine which hides the weird semantics of the EM_GETLINE call. int GetLineEx(int line, TCHAR* text, int nMaxChars, BOOL bDirect = TRUE); //Auto generated using the "ConvertScintillaiface.js" script void AddText(int length, const char* text, BOOL bDirect = TRUE); void AddStyledText(int length, char* c, BOOL bDirect = TRUE); void InsertText(long pos, const char* text, BOOL bDirect = TRUE); void ClearAll(BOOL bDirect = TRUE); void ClearDocumentStyle(BOOL bDirect = TRUE); int GetLength(BOOL bDirect = TRUE); int GetCharAt(long pos, BOOL bDirect = TRUE); long GetCurrentPos(BOOL bDirect = TRUE); long GetAnchor(BOOL bDirect = TRUE); int GetStyleAt(long pos, BOOL bDirect = TRUE); void Redo(BOOL bDirect = TRUE); void SetUndoCollection(BOOL collectUndo, BOOL bDirect = TRUE); void SelectAll(BOOL bDirect = TRUE); void SetSavePoint(BOOL bDirect = TRUE); int GetStyledText(TextRange* tr, BOOL bDirect = TRUE); BOOL CanRedo(BOOL bDirect = TRUE); int MarkerLineFromHandle(int handle, BOOL bDirect = TRUE); void MarkerDeleteHandle(int handle, BOOL bDirect = TRUE); BOOL GetUndoCollection(BOOL bDirect = TRUE); int GetViewWS(BOOL bDirect = TRUE); void SetViewWS(int viewWS, BOOL bDirect = TRUE); long PositionFromPoint(int x, int y, BOOL bDirect = TRUE); long PositionFromPointClose(int x, int y, BOOL bDirect = TRUE); void GotoLine(int line, BOOL bDirect = TRUE); void GotoPos(long pos, BOOL bDirect = TRUE); void SetAnchor(long posAnchor, BOOL bDirect = TRUE); int GetCurLine(int length, char* text, BOOL bDirect = TRUE); long GetEndStyled(BOOL bDirect = TRUE); void ConvertEOLs(int eolMode, BOOL bDirect = TRUE); int GetEOLMode(BOOL bDirect = TRUE); void SetEOLMode(int eolMode, BOOL bDirect = TRUE); void StartStyling(long pos, int mask, BOOL bDirect = TRUE); void SetStyling(int length, int style, BOOL bDirect = TRUE); BOOL GetBufferedDraw(BOOL bDirect = TRUE); void SetBufferedDraw(BOOL buffered, BOOL bDirect = TRUE); void SetTabWidth(int tabWidth, BOOL bDirect = TRUE); int GetTabWidth(BOOL bDirect = TRUE); void SetCodePage(int codePage, BOOL bDirect = TRUE); void SetUsePalette(BOOL usePalette, BOOL bDirect = TRUE); void MarkerDefine(int markerNumber, int markerSymbol, BOOL bDirect = TRUE); void MarkerSetFore(int markerNumber, COLORREF fore, BOOL bDirect = TRUE); void MarkerSetBack(int markerNumber, COLORREF back, BOOL bDirect = TRUE); int MarkerAdd(int line, int markerNumber, BOOL bDirect = TRUE); void MarkerDelete(int line, int markerNumber, BOOL bDirect = TRUE); void MarkerDeleteAll(int markerNumber, BOOL bDirect = TRUE); int MarkerGet(int line, BOOL bDirect = TRUE); int MarkerNext(int lineStart, int markerMask, BOOL bDirect = TRUE); int MarkerPrevious(int lineStart, int markerMask, BOOL bDirect = TRUE); void MarkerDefinePixmap(int markerNumber, const char* pixmap, BOOL bDirect = TRUE); void MarkerAddSet(int line, int set, BOOL bDirect = TRUE); void MarkerSetAlpha(int markerNumber, int alpha, BOOL bDirect = TRUE); void SetMarginTypeN(int margin, int marginType, BOOL bDirect = TRUE); int GetMarginTypeN(int margin, BOOL bDirect = TRUE); void SetMarginWidthN(int margin, int pixelWidth, BOOL bDirect = TRUE); int GetMarginWidthN(int margin, BOOL bDirect = TRUE); void SetMarginMaskN(int margin, int mask, BOOL bDirect = TRUE); int GetMarginMaskN(int margin, BOOL bDirect = TRUE); void SetMarginSensitiveN(int margin, BOOL sensitive, BOOL bDirect = TRUE); BOOL GetMarginSensitiveN(int margin, BOOL bDirect = TRUE); void StyleClearAll(BOOL bDirect = TRUE); void StyleSetFore(int style, COLORREF fore, BOOL bDirect = TRUE); void StyleSetBack(int style, COLORREF back, BOOL bDirect = TRUE); void StyleSetBold(int style, BOOL bold, BOOL bDirect = TRUE); void StyleSetItalic(int style, BOOL italic, BOOL bDirect = TRUE); void StyleSetSize(int style, int sizePoints, BOOL bDirect = TRUE); void StyleSetFont(int style, const char* fontName, BOOL bDirect = TRUE); void StyleSetEOLFilled(int style, BOOL filled, BOOL bDirect = TRUE); void StyleResetDefault(BOOL bDirect = TRUE); void StyleSetUnderline(int style, BOOL underline, BOOL bDirect = TRUE); COLORREF StyleGetFore(int style, BOOL bDirect = TRUE); COLORREF StyleGetBack(int style, BOOL bDirect = TRUE); BOOL StyleGetBold(int style, BOOL bDirect = TRUE); BOOL StyleGetItalic(int style, BOOL bDirect = TRUE); int StyleGetSize(int style, BOOL bDirect = TRUE); int StyleGetFont(int style, char* fontName, BOOL bDirect = TRUE); BOOL StyleGetEOLFilled(int style, BOOL bDirect = TRUE); BOOL StyleGetUnderline(int style, BOOL bDirect = TRUE); int StyleGetCase(int style, BOOL bDirect = TRUE); int StyleGetCharacterSet(int style, BOOL bDirect = TRUE); BOOL StyleGetVisible(int style, BOOL bDirect = TRUE); BOOL StyleGetChangeable(int style, BOOL bDirect = TRUE); BOOL StyleGetHotSpot(int style, BOOL bDirect = TRUE); void StyleSetCase(int style, int caseForce, BOOL bDirect = TRUE); void StyleSetCharacterSet(int style, int characterSet, BOOL bDirect = TRUE); void StyleSetHotSpot(int style, BOOL hotspot, BOOL bDirect = TRUE); void SetSelFore(BOOL useSetting, COLORREF fore, BOOL bDirect = TRUE); void SetSelBack(BOOL useSetting, COLORREF back, BOOL bDirect = TRUE); int GetSelAlpha(BOOL bDirect = TRUE); void SetSelAlpha(int alpha, BOOL bDirect = TRUE); BOOL GetSelEOLFilled(BOOL bDirect = TRUE); void SetSelEOLFilled(BOOL filled, BOOL bDirect = TRUE); void SetCaretFore(COLORREF fore, BOOL bDirect = TRUE); void AssignCmdKey(DWORD km, int msg, BOOL bDirect = TRUE); void ClearCmdKey(DWORD km, BOOL bDirect = TRUE); void ClearAllCmdKeys(BOOL bDirect = TRUE); void SetStylingEx(int length, const char* styles, BOOL bDirect = TRUE); void StyleSetVisible(int style, BOOL visible, BOOL bDirect = TRUE); int GetCaretPeriod(BOOL bDirect = TRUE); void SetCaretPeriod(int periodMilliseconds, BOOL bDirect = TRUE); void SetWordChars(const char* characters, BOOL bDirect = TRUE); void BeginUndoAction(BOOL bDirect = TRUE); void EndUndoAction(BOOL bDirect = TRUE); void IndicSetStyle(int indic, int style, BOOL bDirect = TRUE); int IndicGetStyle(int indic, BOOL bDirect = TRUE); void IndicSetFore(int indic, COLORREF fore, BOOL bDirect = TRUE); COLORREF IndicGetFore(int indic, BOOL bDirect = TRUE); void IndicSetUnder(int indic, BOOL under, BOOL bDirect = TRUE); BOOL IndicGetUnder(int indic, BOOL bDirect = TRUE); void SetWhitespaceFore(BOOL useSetting, COLORREF fore, BOOL bDirect = TRUE); void SetWhitespaceBack(BOOL useSetting, COLORREF back, BOOL bDirect = TRUE); void SetStyleBits(int bits, BOOL bDirect = TRUE); int GetStyleBits(BOOL bDirect = TRUE); void SetLineState(int line, int state, BOOL bDirect = TRUE); int GetLineState(int line, BOOL bDirect = TRUE); int GetMaxLineState(BOOL bDirect = TRUE); BOOL GetCaretLineVisible(BOOL bDirect = TRUE); void SetCaretLineVisible(BOOL show, BOOL bDirect = TRUE); COLORREF GetCaretLineBack(BOOL bDirect = TRUE); void SetCaretLineBack(COLORREF back, BOOL bDirect = TRUE); void StyleSetChangeable(int style, BOOL changeable, BOOL bDirect = TRUE); void AutoCShow(int lenEntered, const char* itemList, BOOL bDirect = TRUE); void AutoCCancel(BOOL bDirect = TRUE); BOOL AutoCActive(BOOL bDirect = TRUE); long AutoCPosStart(BOOL bDirect = TRUE); void AutoCComplete(BOOL bDirect = TRUE); void AutoCStops(const char* characterSet, BOOL bDirect = TRUE); void AutoCSetSeparator(int separatorCharacter, BOOL bDirect = TRUE); int AutoCGetSeparator(BOOL bDirect = TRUE); void AutoCSelect(const char* text, BOOL bDirect = TRUE); void AutoCSetCancelAtStart(BOOL cancel, BOOL bDirect = TRUE); BOOL AutoCGetCancelAtStart(BOOL bDirect = TRUE); void AutoCSetFillUps(const char* characterSet, BOOL bDirect = TRUE); void AutoCSetChooseSingle(BOOL chooseSingle, BOOL bDirect = TRUE); BOOL AutoCGetChooseSingle(BOOL bDirect = TRUE); void AutoCSetIgnoreCase(BOOL ignoreCase, BOOL bDirect = TRUE); BOOL AutoCGetIgnoreCase(BOOL bDirect = TRUE); void UserListShow(int listType, const char* itemList, BOOL bDirect = TRUE); void AutoCSetAutoHide(BOOL autoHide, BOOL bDirect = TRUE); BOOL AutoCGetAutoHide(BOOL bDirect = TRUE); void AutoCSetDropRestOfWord(BOOL dropRestOfWord, BOOL bDirect = TRUE); BOOL AutoCGetDropRestOfWord(BOOL bDirect = TRUE); void RegisterImage(int type, const char* xpmData, BOOL bDirect = TRUE); void ClearRegisteredImages(BOOL bDirect = TRUE); int AutoCGetTypeSeparator(BOOL bDirect = TRUE); void AutoCSetTypeSeparator(int separatorCharacter, BOOL bDirect = TRUE); void AutoCSetMaxWidth(int characterCount, BOOL bDirect = TRUE); int AutoCGetMaxWidth(BOOL bDirect = TRUE); void AutoCSetMaxHeight(int rowCount, BOOL bDirect = TRUE); int AutoCGetMaxHeight(BOOL bDirect = TRUE); void SetIndent(int indentSize, BOOL bDirect = TRUE); int GetIndent(BOOL bDirect = TRUE); void SetUseTabs(BOOL useTabs, BOOL bDirect = TRUE); BOOL GetUseTabs(BOOL bDirect = TRUE); void SetLineIndentation(int line, int indentSize, BOOL bDirect = TRUE); int GetLineIndentation(int line, BOOL bDirect = TRUE); long GetLineIndentPosition(int line, BOOL bDirect = TRUE); int GetColumn(long pos, BOOL bDirect = TRUE); void SetHScrollBar(BOOL show, BOOL bDirect = TRUE); BOOL GetHScrollBar(BOOL bDirect = TRUE); void SetIndentationGuides(int indentView, BOOL bDirect = TRUE); int GetIndentationGuides(BOOL bDirect = TRUE); void SetHighlightGuide(int column, BOOL bDirect = TRUE); int GetHighlightGuide(BOOL bDirect = TRUE); int GetLineEndPosition(int line, BOOL bDirect = TRUE); int GetCodePage(BOOL bDirect = TRUE); COLORREF GetCaretFore(BOOL bDirect = TRUE); BOOL GetUsePalette(BOOL bDirect = TRUE); BOOL GetReadOnly(BOOL bDirect = TRUE); void SetCurrentPos(long pos, BOOL bDirect = TRUE); void SetSelectionStart(long pos, BOOL bDirect = TRUE); long GetSelectionStart(BOOL bDirect = TRUE); void SetSelectionEnd(long pos, BOOL bDirect = TRUE); long GetSelectionEnd(BOOL bDirect = TRUE); void SetPrintMagnification(int magnification, BOOL bDirect = TRUE); int GetPrintMagnification(BOOL bDirect = TRUE); void SetPrintColourMode(int mode, BOOL bDirect = TRUE); int GetPrintColourMode(BOOL bDirect = TRUE); long FindText(int flags, TextToFind* ft, BOOL bDirect = TRUE); long FormatRange(BOOL draw, RangeToFormat* fr, BOOL bDirect = TRUE); int GetFirstVisibleLine(BOOL bDirect = TRUE); int GetLine(int line, char* text, BOOL bDirect = TRUE); int GetLineCount(BOOL bDirect = TRUE); void SetMarginLeft(int pixelWidth, BOOL bDirect = TRUE); int GetMarginLeft(BOOL bDirect = TRUE); void SetMarginRight(int pixelWidth, BOOL bDirect = TRUE); int GetMarginRight(BOOL bDirect = TRUE); BOOL GetModify(BOOL bDirect = TRUE); void SetSel(long start, long end, BOOL bDirect = TRUE); int GetSelText(char* text, BOOL bDirect = TRUE); int GetTextRange(TextRange* tr, BOOL bDirect = TRUE); void HideSelection(BOOL normal, BOOL bDirect = TRUE); int PointXFromPosition(long pos, BOOL bDirect = TRUE); int PointYFromPosition(long pos, BOOL bDirect = TRUE); int LineFromPosition(long pos, BOOL bDirect = TRUE); long PositionFromLine(int line, BOOL bDirect = TRUE); void LineScroll(int columns, int lines, BOOL bDirect = TRUE); void ScrollCaret(BOOL bDirect = TRUE); void ReplaceSel(const char* text, BOOL bDirect = TRUE); void SetReadOnly(BOOL readOnly, BOOL bDirect = TRUE); void Null(BOOL bDirect = TRUE); BOOL CanPaste(BOOL bDirect = TRUE); BOOL CanUndo(BOOL bDirect = TRUE); void EmptyUndoBuffer(BOOL bDirect = TRUE); void Undo(BOOL bDirect = TRUE); void Cut(BOOL bDirect = TRUE); void Copy(BOOL bDirect = TRUE); void Paste(BOOL bDirect = TRUE); void Clear(BOOL bDirect = TRUE); void SetText(const char* text, BOOL bDirect = TRUE); int GetText(int length, char* text, BOOL bDirect = TRUE); int GetTextLength(BOOL bDirect = TRUE); void SetOvertype(BOOL overtype, BOOL bDirect = TRUE); BOOL GetOvertype(BOOL bDirect = TRUE); void SetCaretWidth(int pixelWidth, BOOL bDirect = TRUE); int GetCaretWidth(BOOL bDirect = TRUE); void SetTargetStart(long pos, BOOL bDirect = TRUE); long GetTargetStart(BOOL bDirect = TRUE); void SetTargetEnd(long pos, BOOL bDirect = TRUE); long GetTargetEnd(BOOL bDirect = TRUE); int ReplaceTarget(int length, const char* text, BOOL bDirect = TRUE); int ReplaceTargetRE(int length, const char* text, BOOL bDirect = TRUE); int SearchInTarget(int length, const char* text, BOOL bDirect = TRUE); void SetSearchFlags(int flags, BOOL bDirect = TRUE); int GetSearchFlags(BOOL bDirect = TRUE); void CallTipShow(long pos, const char* definition, BOOL bDirect = TRUE); void CallTipCancel(BOOL bDirect = TRUE); BOOL CallTipActive(BOOL bDirect = TRUE); long CallTipPosStart(BOOL bDirect = TRUE); void CallTipSetHlt(int start, int end, BOOL bDirect = TRUE); void CallTipSetBack(COLORREF back, BOOL bDirect = TRUE); void CallTipSetFore(COLORREF fore, BOOL bDirect = TRUE); void CallTipSetForeHlt(COLORREF fore, BOOL bDirect = TRUE); void CallTipUseStyle(int tabSize, BOOL bDirect = TRUE); int VisibleFromDocLine(int line, BOOL bDirect = TRUE); int DocLineFromVisible(int lineDisplay, BOOL bDirect = TRUE); int WrapCount(int line, BOOL bDirect = TRUE); void SetFoldLevel(int line, int level, BOOL bDirect = TRUE); int GetFoldLevel(int line, BOOL bDirect = TRUE); int GetLastChild(int line, int level, BOOL bDirect = TRUE); int GetFoldParent(int line, BOOL bDirect = TRUE); void ShowLines(int lineStart, int lineEnd, BOOL bDirect = TRUE); void HideLines(int lineStart, int lineEnd, BOOL bDirect = TRUE); BOOL GetLineVisible(int line, BOOL bDirect = TRUE); void SetFoldExpanded(int line, BOOL expanded, BOOL bDirect = TRUE); BOOL GetFoldExpanded(int line, BOOL bDirect = TRUE); void ToggleFold(int line, BOOL bDirect = TRUE); void EnsureVisible(int line, BOOL bDirect = TRUE); void SetFoldFlags(int flags, BOOL bDirect = TRUE); void EnsureVisibleEnforcePolicy(int line, BOOL bDirect = TRUE); void SetTabIndents(BOOL tabIndents, BOOL bDirect = TRUE); BOOL GetTabIndents(BOOL bDirect = TRUE); void SetBackSpaceUnIndents(BOOL bsUnIndents, BOOL bDirect = TRUE); BOOL GetBackSpaceUnIndents(BOOL bDirect = TRUE); void SetMouseDwellTime(int periodMilliseconds, BOOL bDirect = TRUE); int GetMouseDwellTime(BOOL bDirect = TRUE); int WordStartPosition(long pos, BOOL onlyWordCharacters, BOOL bDirect = TRUE); int WordEndPosition(long pos, BOOL onlyWordCharacters, BOOL bDirect = TRUE); void SetWrapMode(int mode, BOOL bDirect = TRUE); int GetWrapMode(BOOL bDirect = TRUE); void SetWrapVisualFlags(int wrapVisualFlags, BOOL bDirect = TRUE); int GetWrapVisualFlags(BOOL bDirect = TRUE); void SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation, BOOL bDirect = TRUE); int GetWrapVisualFlagsLocation(BOOL bDirect = TRUE); void SetWrapStartIndent(int indent, BOOL bDirect = TRUE); int GetWrapStartIndent(BOOL bDirect = TRUE); void SetLayoutCache(int mode, BOOL bDirect = TRUE); int GetLayoutCache(BOOL bDirect = TRUE); void SetScrollWidth(int pixelWidth, BOOL bDirect = TRUE); int GetScrollWidth(BOOL bDirect = TRUE); void SetScrollWidthTracking(BOOL tracking, BOOL bDirect = TRUE); BOOL GetScrollWidthTracking(BOOL bDirect = TRUE); int TextWidth(int style, const char* text, BOOL bDirect = TRUE); void SetEndAtLastLine(BOOL endAtLastLine, BOOL bDirect = TRUE); BOOL GetEndAtLastLine(BOOL bDirect = TRUE); int TextHeight(int line, BOOL bDirect = TRUE); void SetVScrollBar(BOOL show, BOOL bDirect = TRUE); BOOL GetVScrollBar(BOOL bDirect = TRUE); void AppendText(int length, const char* text, BOOL bDirect = TRUE); BOOL GetTwoPhaseDraw(BOOL bDirect = TRUE); void SetTwoPhaseDraw(BOOL twoPhase, BOOL bDirect = TRUE); void TargetFromSelection(BOOL bDirect = TRUE); void LinesJoin(BOOL bDirect = TRUE); void LinesSplit(int pixelWidth, BOOL bDirect = TRUE); void SetFoldMarginColour(BOOL useSetting, COLORREF back, BOOL bDirect = TRUE); void SetFoldMarginHiColour(BOOL useSetting, COLORREF fore, BOOL bDirect = TRUE); void LineDown(BOOL bDirect = TRUE); void LineDownExtend(BOOL bDirect = TRUE); void LineUp(BOOL bDirect = TRUE); void LineUpExtend(BOOL bDirect = TRUE); void CharLeft(BOOL bDirect = TRUE); void CharLeftExtend(BOOL bDirect = TRUE); void CharRight(BOOL bDirect = TRUE); void CharRightExtend(BOOL bDirect = TRUE); void WordLeft(BOOL bDirect = TRUE); void WordLeftExtend(BOOL bDirect = TRUE); void WordRight(BOOL bDirect = TRUE); void WordRightExtend(BOOL bDirect = TRUE); void Home(BOOL bDirect = TRUE); void HomeExtend(BOOL bDirect = TRUE); void LineEnd(BOOL bDirect = TRUE); void LineEndExtend(BOOL bDirect = TRUE); void DocumentStart(BOOL bDirect = TRUE); void DocumentStartExtend(BOOL bDirect = TRUE); void DocumentEnd(BOOL bDirect = TRUE); void DocumentEndExtend(BOOL bDirect = TRUE); void PageUp(BOOL bDirect = TRUE); void PageUpExtend(BOOL bDirect = TRUE); void PageDown(BOOL bDirect = TRUE); void PageDownExtend(BOOL bDirect = TRUE); void EditToggleOvertype(BOOL bDirect = TRUE); void Cancel(BOOL bDirect = TRUE); void DeleteBack(BOOL bDirect = TRUE); void Tab(BOOL bDirect = TRUE); void BackTab(BOOL bDirect = TRUE); void NewLine(BOOL bDirect = TRUE); void FormFeed(BOOL bDirect = TRUE); void VCHome(BOOL bDirect = TRUE); void VCHomeExtend(BOOL bDirect = TRUE); void ZoomIn(BOOL bDirect = TRUE); void ZoomOut(BOOL bDirect = TRUE); void DelWordLeft(BOOL bDirect = TRUE); void DelWordRight(BOOL bDirect = TRUE); void DelWordRightEnd(BOOL bDirect = TRUE); void LineCut(BOOL bDirect = TRUE); void LineDelete(BOOL bDirect = TRUE); void LineTranspose(BOOL bDirect = TRUE); void LineDuplicate(BOOL bDirect = TRUE); void LowerCase(BOOL bDirect = TRUE); void UpperCase(BOOL bDirect = TRUE); void LineScrollDown(BOOL bDirect = TRUE); void LineScrollUp(BOOL bDirect = TRUE); void DeleteBackNotLine(BOOL bDirect = TRUE); void HomeDisplay(BOOL bDirect = TRUE); void HomeDisplayExtend(BOOL bDirect = TRUE); void LineEndDisplay(BOOL bDirect = TRUE); void LineEndDisplayExtend(BOOL bDirect = TRUE); void HomeWrap(BOOL bDirect = TRUE); void HomeWrapExtend(BOOL bDirect = TRUE); void LineEndWrap(BOOL bDirect = TRUE); void LineEndWrapExtend(BOOL bDirect = TRUE); void VCHomeWrap(BOOL bDirect = TRUE); void VCHomeWrapExtend(BOOL bDirect = TRUE); void LineCopy(BOOL bDirect = TRUE); void MoveCaretInsideView(BOOL bDirect = TRUE); int LineLength(int line, BOOL bDirect = TRUE); void BraceHighlight(long pos1, long pos2, BOOL bDirect = TRUE); void BraceBadLight(long pos, BOOL bDirect = TRUE); long BraceMatch(long pos, BOOL bDirect = TRUE); BOOL GetViewEOL(BOOL bDirect = TRUE); void SetViewEOL(BOOL visible, BOOL bDirect = TRUE); int GetDocPointer(BOOL bDirect = TRUE); void SetDocPointer(int pointer, BOOL bDirect = TRUE); void SetModEventMask(int mask, BOOL bDirect = TRUE); int GetEdgeColumn(BOOL bDirect = TRUE); void SetEdgeColumn(int column, BOOL bDirect = TRUE); int GetEdgeMode(BOOL bDirect = TRUE); void SetEdgeMode(int mode, BOOL bDirect = TRUE); COLORREF GetEdgeColour(BOOL bDirect = TRUE); void SetEdgeColour(COLORREF edgeColour, BOOL bDirect = TRUE); void SearchAnchor(BOOL bDirect = TRUE); int SearchNext(int flags, const char* text, BOOL bDirect = TRUE); int SearchPrev(int flags, const char* text, BOOL bDirect = TRUE); int LinesOnScreen(BOOL bDirect = TRUE); void UsePopUp(BOOL allowPopUp, BOOL bDirect = TRUE); BOOL SelectionIsRectangle(BOOL bDirect = TRUE); void SetZoom(int zoom, BOOL bDirect = TRUE); int GetZoom(BOOL bDirect = TRUE); int CreateDocument(BOOL bDirect = TRUE); void AddRefDocument(int doc, BOOL bDirect = TRUE); void ReleaseDocument(int doc, BOOL bDirect = TRUE); int GetModEventMask(BOOL bDirect = TRUE); void SCISetFocus(BOOL focus, BOOL bDirect = TRUE); BOOL GetFocus(BOOL bDirect = TRUE); void SetStatus(int statusCode, BOOL bDirect = TRUE); int GetStatus(BOOL bDirect = TRUE); void SetMouseDownCaptures(BOOL captures, BOOL bDirect = TRUE); BOOL GetMouseDownCaptures(BOOL bDirect = TRUE); void SetCursor(int cursorType, BOOL bDirect = TRUE); int GetCursor(BOOL bDirect = TRUE); void SetControlCharSymbol(int symbol, BOOL bDirect = TRUE); int GetControlCharSymbol(BOOL bDirect = TRUE); void WordPartLeft(BOOL bDirect = TRUE); void WordPartLeftExtend(BOOL bDirect = TRUE); void WordPartRight(BOOL bDirect = TRUE); void WordPartRightExtend(BOOL bDirect = TRUE); void SetVisiblePolicy(int visiblePolicy, int visibleSlop, BOOL bDirect = TRUE); void DelLineLeft(BOOL bDirect = TRUE); void DelLineRight(BOOL bDirect = TRUE); void SetXOffset(int newOffset, BOOL bDirect = TRUE); int GetXOffset(BOOL bDirect = TRUE); void ChooseCaretX(BOOL bDirect = TRUE); void GrabFocus(BOOL bDirect = TRUE); void SetXCaretPolicy(int caretPolicy, int caretSlop, BOOL bDirect = TRUE); void SetYCaretPolicy(int caretPolicy, int caretSlop, BOOL bDirect = TRUE); void SetPrintWrapMode(int mode, BOOL bDirect = TRUE); int GetPrintWrapMode(BOOL bDirect = TRUE); void SetHotspotActiveFore(BOOL useSetting, COLORREF fore, BOOL bDirect = TRUE); COLORREF GetHotspotActiveFore(BOOL bDirect = TRUE); void SetHotspotActiveBack(BOOL useSetting, COLORREF back, BOOL bDirect = TRUE); COLORREF GetHotspotActiveBack(BOOL bDirect = TRUE); void SetHotspotActiveUnderline(BOOL underline, BOOL bDirect = TRUE); BOOL GetHotspotActiveUnderline(BOOL bDirect = TRUE); void SetHotspotSingleLine(BOOL singleLine, BOOL bDirect = TRUE); BOOL GetHotspotSingleLine(BOOL bDirect = TRUE); void ParaDown(BOOL bDirect = TRUE); void ParaDownExtend(BOOL bDirect = TRUE); void ParaUp(BOOL bDirect = TRUE); void ParaUpExtend(BOOL bDirect = TRUE); long PositionBefore(long pos, BOOL bDirect = TRUE); long PositionAfter(long pos, BOOL bDirect = TRUE); void CopyRange(long start, long end, BOOL bDirect = TRUE); void CopyText(int length, const char* text, BOOL bDirect = TRUE); void SetSelectionMode(int mode, BOOL bDirect = TRUE); int GetSelectionMode(BOOL bDirect = TRUE); long GetLineSelStartPosition(int line, BOOL bDirect = TRUE); long GetLineSelEndPosition(int line, BOOL bDirect = TRUE); void LineDownRectExtend(BOOL bDirect = TRUE); void LineUpRectExtend(BOOL bDirect = TRUE); void CharLeftRectExtend(BOOL bDirect = TRUE); void CharRightRectExtend(BOOL bDirect = TRUE); void HomeRectExtend(BOOL bDirect = TRUE); void VCHomeRectExtend(BOOL bDirect = TRUE); void LineEndRectExtend(BOOL bDirect = TRUE); void PageUpRectExtend(BOOL bDirect = TRUE); void PageDownRectExtend(BOOL bDirect = TRUE); void StutteredPageUp(BOOL bDirect = TRUE); void StutteredPageUpExtend(BOOL bDirect = TRUE); void StutteredPageDown(BOOL bDirect = TRUE); void StutteredPageDownExtend(BOOL bDirect = TRUE); void WordLeftEnd(BOOL bDirect = TRUE); void WordLeftEndExtend(BOOL bDirect = TRUE); void WordRightEnd(BOOL bDirect = TRUE); void WordRightEndExtend(BOOL bDirect = TRUE); void SetWhitespaceChars(const char* characters, BOOL bDirect = TRUE); void SetCharsDefault(BOOL bDirect = TRUE); int AutoCGetCurrent(BOOL bDirect = TRUE); void Allocate(int bytes, BOOL bDirect = TRUE); int TargetAsUTF8(char* s, BOOL bDirect = TRUE); void SetLengthForEncode(int bytes, BOOL bDirect = TRUE); int EncodedFromUTF8(const char* utf8, char* encoded, BOOL bDirect = TRUE); int FindColumn(int line, int column, BOOL bDirect = TRUE); BOOL GetCaretSticky(BOOL bDirect = TRUE); void SetCaretSticky(BOOL useCaretStickyBehaviour, BOOL bDirect = TRUE); void ToggleCaretSticky(BOOL bDirect = TRUE); void SetPasteConvertEndings(BOOL convert, BOOL bDirect = TRUE); BOOL GetPasteConvertEndings(BOOL bDirect = TRUE); void SelectionDuplicate(BOOL bDirect = TRUE); void SetCaretLineBackAlpha(int alpha, BOOL bDirect = TRUE); int GetCaretLineBackAlpha(BOOL bDirect = TRUE); void SetCaretStyle(int caretStyle, BOOL bDirect = TRUE); int GetCaretStyle(BOOL bDirect = TRUE); void SetIndicatorCurrent(int indicator, BOOL bDirect = TRUE); int GetIndicatorCurrent(BOOL bDirect = TRUE); void SetIndicatorValue(int value, BOOL bDirect = TRUE); int GetIndicatorValue(BOOL bDirect = TRUE); void IndicatorFillRange(int position, int fillLength, BOOL bDirect = TRUE); void IndicatorClearRange(int position, int clearLength, BOOL bDirect = TRUE); int IndicatorAllOnFor(int position, BOOL bDirect = TRUE); int IndicatorValueAt(int indicator, int position, BOOL bDirect = TRUE); int IndicatorStart(int indicator, int position, BOOL bDirect = TRUE); int IndicatorEnd(int indicator, int position, BOOL bDirect = TRUE); void SetPositionCache(int size, BOOL bDirect = TRUE); int GetPositionCache(BOOL bDirect = TRUE); void CopyAllowLine(BOOL bDirect = TRUE); void StartRecord(BOOL bDirect = TRUE); void StopRecord(BOOL bDirect = TRUE); void SetLexer(int lexer, BOOL bDirect = TRUE); int GetLexer(BOOL bDirect = TRUE); void Colourise(long start, long end, BOOL bDirect = TRUE); void SetProperty(const char* key, const char* value, BOOL bDirect = TRUE); void SetKeyWords(int keywordSet, const char* keyWords, BOOL bDirect = TRUE); void SetLexerLanguage(const char* language, BOOL bDirect = TRUE); void LoadLexerLibrary(const char* path, BOOL bDirect = TRUE); int GetProperty(const char* key, char* buf, BOOL bDirect = TRUE); int GetPropertyExpanded(const char* key, char* buf, BOOL bDirect = TRUE); int GetPropertyInt(const char* key, BOOL bDirect = TRUE); int GetStyleBitsNeeded(BOOL bDirect = TRUE); protected: DECLARE_DYNAMIC(CScintillaCtrl) //Member variables LRESULT m_DirectFunction; LRESULT m_DirectPointer; }; #endif //__SCINTILLACTRL_H__
[ [ [ 1, 587 ] ] ]
78f36cbffb3fc4dd746671e8a2e5cdbda8138610
99ad04658aa2063886d47f1a036c4e1a01f64e9a
/arq_comp/convencionales/INT.CPP
77e8fe614ebcf62f5582c7ef3df52472b353d4f9
[]
no_license
aguperezpala/2009-famaf-2011
fc0ab596c3a4e66fe93f7114dbd6f211ce4fba42
fb8f1259c582ba6aa1086f0804fcf870cc4dd531
refs/heads/master
2020-06-07T03:27:38.320806
2011-06-09T04:09:24
2011-06-09T04:09:24
33,814,995
1
1
null
null
null
null
UTF-8
C++
false
false
1,970
cpp
/* Parallel Port Interrupt Polarity Tester */ /* 2nd February 1998 */ /* Copyright 1997 Craig Peacock */ /* WWW - http://www.senet.com.au/~cpeacock */ /* Email - [email protected] */ #include <dos.h> #include <conio.h> #include <stdlib.h> #include <stdio.h> #define PORTADDRESS 0x378 /* Enter Your Port Address Here */ #define IRQ 7 /* IRQ Here */ #define DATA PORTADDRESS+0 #define STATUS PORTADDRESS+1 #define CONTROL PORTADDRESS+2 #define PIC1 0x20 #define PIC2 0xA0 int interflag; /* Interrupt Flag */ int picaddr; /* Programmable Interrupt Controller (PIC) Base Address */ void interrupt (*oldhandler)(...); void interrupt parisr(...) /* Interrupt Service Routine (ISR) */ { interflag = 1; outportb(picaddr,0x20); /* End of Interrupt (EOI) */ } void main(void) { int c; int intno; /* Interrupt Vector Number */ int picmask; /* PIC's Mask */ /* Calculate Interrupt Vector, PIC Addr & Mask. */ intno = IRQ + 0x08; picaddr = PIC1; picmask = 1; picmask = picmask << IRQ; outportb(CONTROL, inportb(CONTROL) & 0xDF); /* Make sure port is in Forward Direction */ outportb(DATA,0xFF); oldhandler = getvect(intno); /* Save Old Interrupt Vector */ setvect(intno, parisr); /* Set New Interrupt Vector Entry */ outportb(picaddr+1,inportb(picaddr+1) & (0xFF - picmask)); /* Un-Mask Pic */ outportb(CONTROL, inportb(CONTROL) | 0x10); /* Enable Parallel Port IRQ's */ clrscr(); printf("Parallel Port Interrupt Polarity Tester\n"); printf("IRQ %d : INTNO %02X : PIC Addr 0x%X : Mask 0x%02X\n", IRQ,intno,picaddr,picmask); interflag = 0; /* Reset Interrupt Flag */ delay(10); printf("esperando inter..."); while (interflag == 0); printf("Llego"); getch(); outportb(CONTROL, inportb(CONTROL) & 0xEF); /* Disable Parallel Port IRQ's */ outportb(picaddr+1,inportb(picaddr+1) | picmask); /* Mask Pic */ setvect(intno, oldhandler); /* Restore old Interrupt Vector Before Exit */ }
[ "Hobborg@02179a90-8b6e-11de-a519-b78fc8232508" ]
[ [ [ 1, 65 ] ] ]
98f6dac33858803356ed7befbb43bbccd0a214a2
cd0987589d3815de1dea8529a7705caac479e7e9
/webkit/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp
0dc954adaabd9c3ae598153be4f7e35f1cb3a6a8
[]
no_license
azrul2202/WebKit-Smartphone
0aab1ff641d74f15c0623f00c56806dbc9b59fc1
023d6fe819445369134dee793b69de36748e71d7
refs/heads/master
2021-01-15T09:24:31.288774
2011-07-11T11:12:44
2011-07-11T11:12:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
39,311
cpp
/* * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. * Copyright (C) 2006 Nikolas Zimmermann <[email protected]> * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ * * 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 Apple Computer, Inc. ("Apple") 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 APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "DumpRenderTreeQt.h" #include "../../../WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h" #include "EventSenderQt.h" #include "GCControllerQt.h" #include "LayoutTestControllerQt.h" #include "TextInputControllerQt.h" #include "testplugin.h" #include "WorkQueue.h" #include <QApplication> #include <QBuffer> #include <QCryptographicHash> #include <QDir> #include <QFile> #include <QFileInfo> #include <QFocusEvent> #include <QFontDatabase> #include <QLocale> #include <QNetworkAccessManager> #include <QNetworkReply> #include <QNetworkRequest> #include <QPaintDevice> #include <QPaintEngine> #ifndef QT_NO_PRINTER #include <QPrinter> #endif #include <QUndoStack> #include <QUrl> #include <qwebsettings.h> #include <qwebsecurityorigin.h> #ifndef QT_NO_UITOOLS #include <QtUiTools/QUiLoader> #endif #ifdef Q_WS_X11 #include <fontconfig/fontconfig.h> #endif #include <limits.h> #include <locale.h> #ifndef Q_OS_WIN #include <unistd.h> #endif #include <qdebug.h> namespace WebCore { NetworkAccessManager::NetworkAccessManager(QObject* parent) : QNetworkAccessManager(parent) { #ifndef QT_NO_OPENSSL connect(this, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), this, SLOT(sslErrorsEncountered(QNetworkReply*, const QList<QSslError>&))); #endif } #ifndef QT_NO_OPENSSL void NetworkAccessManager::sslErrorsEncountered(QNetworkReply* reply, const QList<QSslError>& errors) { if (reply->url().host() == "127.0.0.1" || reply->url().host() == "localhost") { bool ignore = true; // Accept any HTTPS certificate. foreach (const QSslError& error, errors) { if (error.error() < QSslError::UnableToGetIssuerCertificate || error.error() > QSslError::HostNameMismatch) { ignore = false; break; } } if (ignore) reply->ignoreSslErrors(); } } #endif #ifndef QT_NO_PRINTER class NullPrinter : public QPrinter { public: class NullPaintEngine : public QPaintEngine { public: virtual bool begin(QPaintDevice*) { return true; } virtual bool end() { return true; } virtual QPaintEngine::Type type() const { return QPaintEngine::User; } virtual void drawPixmap(const QRectF& r, const QPixmap& pm, const QRectF& sr) { } virtual void updateState(const QPaintEngineState& state) { } }; virtual QPaintEngine* paintEngine() const { return const_cast<NullPaintEngine*>(&m_engine); } NullPaintEngine m_engine; }; #endif WebPage::WebPage(QObject* parent, DumpRenderTree* drt) : QWebPage(parent) , m_webInspector(0) , m_drt(drt) { QWebSettings* globalSettings = QWebSettings::globalSettings(); globalSettings->setFontSize(QWebSettings::MinimumFontSize, 5); globalSettings->setFontSize(QWebSettings::MinimumLogicalFontSize, 5); globalSettings->setFontSize(QWebSettings::DefaultFontSize, 16); globalSettings->setFontSize(QWebSettings::DefaultFixedFontSize, 13); globalSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, true); globalSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); globalSettings->setAttribute(QWebSettings::LinksIncludedInFocusChain, false); globalSettings->setAttribute(QWebSettings::PluginsEnabled, true); globalSettings->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true); globalSettings->setAttribute(QWebSettings::JavascriptEnabled, true); globalSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false); globalSettings->setAttribute(QWebSettings::SpatialNavigationEnabled, false); connect(this, SIGNAL(geometryChangeRequested(const QRect &)), this, SLOT(setViewGeometry(const QRect & ))); setNetworkAccessManager(m_drt->networkAccessManager()); setPluginFactory(new TestPlugin(this)); connect(this, SIGNAL(requestPermissionFromUser(QWebFrame*, QWebPage::PermissionDomain)), this, SLOT(requestPermission(QWebFrame*, QWebPage::PermissionDomain))); connect(this, SIGNAL(checkPermissionFromUser(QWebFrame*, QWebPage::PermissionDomain, QWebPage::PermissionPolicy&)), this, SLOT(checkPermission(QWebFrame*, QWebPage::PermissionDomain, QWebPage::PermissionPolicy&))); connect(this, SIGNAL(cancelRequestsForPermission(QWebFrame*, QWebPage::PermissionDomain)), this, SLOT(cancelPermission(QWebFrame*, QWebPage::PermissionDomain))); } WebPage::~WebPage() { delete m_webInspector; } QWebInspector* WebPage::webInspector() { if (!m_webInspector) { m_webInspector = new QWebInspector; m_webInspector->setPage(this); } return m_webInspector; } void WebPage::resetSettings() { // After each layout test, reset the settings that may have been changed by // layoutTestController.overridePreference() or similar. settings()->resetFontSize(QWebSettings::DefaultFontSize); settings()->resetAttribute(QWebSettings::JavascriptCanOpenWindows); settings()->resetAttribute(QWebSettings::JavascriptEnabled); settings()->resetAttribute(QWebSettings::PrivateBrowsingEnabled); settings()->resetAttribute(QWebSettings::SpatialNavigationEnabled); settings()->resetAttribute(QWebSettings::LinksIncludedInFocusChain); settings()->resetAttribute(QWebSettings::OfflineWebApplicationCacheEnabled); settings()->resetAttribute(QWebSettings::LocalContentCanAccessRemoteUrls); settings()->resetAttribute(QWebSettings::PluginsEnabled); settings()->resetAttribute(QWebSettings::JavascriptCanAccessClipboard); settings()->resetAttribute(QWebSettings::AutoLoadImages); m_drt->layoutTestController()->setCaretBrowsingEnabled(false); m_drt->layoutTestController()->setFrameFlatteningEnabled(false); m_drt->layoutTestController()->setSmartInsertDeleteEnabled(true); m_drt->layoutTestController()->setSelectTrailingWhitespaceEnabled(false); // globalSettings must be reset explicitly. m_drt->layoutTestController()->setXSSAuditorEnabled(false); QWebSettings::setMaximumPagesInCache(0); // reset to default settings()->setUserStyleSheetUrl(QUrl()); // reset to default m_pendingGeolocationRequests.clear(); } QWebPage *WebPage::createWindow(QWebPage::WebWindowType) { return m_drt->createWindow(); } void WebPage::javaScriptAlert(QWebFrame*, const QString& message) { if (!isTextOutputEnabled()) return; fprintf(stdout, "ALERT: %s\n", message.toUtf8().constData()); } void WebPage::requestPermission(QWebFrame* frame, QWebPage::PermissionDomain domain) { switch (domain) { case NotificationsPermissionDomain: if (!m_drt->layoutTestController()->ignoreReqestForPermission()) setUserPermission(frame, domain, PermissionGranted); break; case GeolocationPermissionDomain: if (m_drt->layoutTestController()->isGeolocationPermissionSet()) if (m_drt->layoutTestController()->geolocationPermission()) setUserPermission(frame, domain, PermissionGranted); else setUserPermission(frame, domain, PermissionDenied); else m_pendingGeolocationRequests.append(frame); break; default: break; } } void WebPage::checkPermission(QWebFrame* frame, QWebPage::PermissionDomain domain, QWebPage::PermissionPolicy& policy) { switch (domain) { case NotificationsPermissionDomain: { QUrl url = frame->url(); policy = m_drt->layoutTestController()->checkDesktopNotificationPermission(url.scheme() + "://" + url.host()) ? PermissionGranted : PermissionDenied; break; } default: break; } } void WebPage::cancelPermission(QWebFrame* frame, QWebPage::PermissionDomain domain) { switch (domain) { case GeolocationPermissionDomain: m_pendingGeolocationRequests.removeOne(frame); break; default: break; } } void WebPage::permissionSet(QWebPage::PermissionDomain domain) { switch (domain) { case GeolocationPermissionDomain: { Q_ASSERT(m_drt->layoutTestController()->isGeolocationPermissionSet()); foreach (QWebFrame* frame, m_pendingGeolocationRequests) if (m_drt->layoutTestController()->geolocationPermission()) setUserPermission(frame, domain, PermissionGranted); else setUserPermission(frame, domain, PermissionDenied); m_pendingGeolocationRequests.clear(); break; } default: break; } } static QString urlSuitableForTestResult(const QString& url) { if (url.isEmpty() || !url.startsWith(QLatin1String("file://"))) return url; return QFileInfo(url).fileName(); } void WebPage::javaScriptConsoleMessage(const QString& message, int lineNumber, const QString&) { if (!isTextOutputEnabled()) return; QString newMessage; if (!message.isEmpty()) { newMessage = message; size_t fileProtocol = newMessage.indexOf(QLatin1String("file://")); if (fileProtocol != -1) { newMessage = newMessage.left(fileProtocol) + urlSuitableForTestResult(newMessage.mid(fileProtocol)); } } fprintf (stdout, "CONSOLE MESSAGE: line %d: %s\n", lineNumber, newMessage.toUtf8().constData()); } bool WebPage::javaScriptConfirm(QWebFrame*, const QString& msg) { if (!isTextOutputEnabled()) return true; fprintf(stdout, "CONFIRM: %s\n", msg.toUtf8().constData()); return true; } bool WebPage::javaScriptPrompt(QWebFrame*, const QString& msg, const QString& defaultValue, QString* result) { if (!isTextOutputEnabled()) return true; fprintf(stdout, "PROMPT: %s, default text: %s\n", msg.toUtf8().constData(), defaultValue.toUtf8().constData()); *result = defaultValue; return true; } bool WebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest& request, NavigationType type) { if (m_drt->layoutTestController()->waitForPolicy()) { QString url = QString::fromUtf8(request.url().toEncoded()); QString typeDescription; switch (type) { case NavigationTypeLinkClicked: typeDescription = "link clicked"; break; case NavigationTypeFormSubmitted: typeDescription = "form submitted"; break; case NavigationTypeBackOrForward: typeDescription = "back/forward"; break; case NavigationTypeReload: typeDescription = "reload"; break; case NavigationTypeFormResubmitted: typeDescription = "form resubmitted"; break; case NavigationTypeOther: typeDescription = "other"; break; default: typeDescription = "illegal value"; } if (isTextOutputEnabled()) fprintf(stdout, "Policy delegate: attempt to load %s with navigation type '%s'\n", url.toUtf8().constData(), typeDescription.toUtf8().constData()); m_drt->layoutTestController()->notifyDone(); } return QWebPage::acceptNavigationRequest(frame, request, type); } bool WebPage::supportsExtension(QWebPage::Extension extension) const { if (extension == QWebPage::ErrorPageExtension) return m_drt->layoutTestController()->shouldHandleErrorPages(); return false; } bool WebPage::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) { const QWebPage::ErrorPageExtensionOption* info = static_cast<const QWebPage::ErrorPageExtensionOption*>(option); // Lets handle error pages for the main frame for now. if (info->frame != mainFrame()) return false; QWebPage::ErrorPageExtensionReturn* errorPage = static_cast<QWebPage::ErrorPageExtensionReturn*>(output); errorPage->content = QString("data:text/html,<body/>").toUtf8(); return true; } QObject* WebPage::createPlugin(const QString& classId, const QUrl& url, const QStringList& paramNames, const QStringList& paramValues) { Q_UNUSED(url); Q_UNUSED(paramNames); Q_UNUSED(paramValues); #ifndef QT_NO_UITOOLS QUiLoader loader; return loader.createWidget(classId, view()); #else Q_UNUSED(classId); return 0; #endif } void WebPage::setViewGeometry(const QRect& rect) { if (WebViewGraphicsBased* v = qobject_cast<WebViewGraphicsBased*>(view())) v->scene()->setSceneRect(QRectF(rect)); else if (QWidget *v = view()) v->setGeometry(rect); } WebViewGraphicsBased::WebViewGraphicsBased(QWidget* parent) : m_item(new QGraphicsWebView) { setScene(new QGraphicsScene(this)); scene()->addItem(m_item); } DumpRenderTree::DumpRenderTree() : m_dumpPixels(false) , m_stdin(0) , m_enableTextOutput(false) , m_standAloneMode(false) , m_graphicsBased(false) , m_persistentStoragePath(QString(getenv("DUMPRENDERTREE_TEMP"))) { QByteArray viewMode = getenv("QT_DRT_WEBVIEW_MODE"); if (viewMode == "graphics") setGraphicsBased(true); DumpRenderTreeSupportQt::overwritePluginDirectories(); QWebSettings::enablePersistentStorage(m_persistentStoragePath); m_networkAccessManager = new NetworkAccessManager(this); // create our primary testing page/view. if (isGraphicsBased()) { WebViewGraphicsBased* view = new WebViewGraphicsBased(0); m_page = new WebPage(view, this); view->setPage(m_page); m_mainView = view; } else { QWebView* view = new QWebView(0); m_page = new WebPage(view, this); view->setPage(m_page); m_mainView = view; } m_mainView->setContextMenuPolicy(Qt::NoContextMenu); m_mainView->resize(QSize(LayoutTestController::maxViewWidth, LayoutTestController::maxViewHeight)); // clean up cache by resetting quota. qint64 quota = webPage()->settings()->offlineWebApplicationCacheQuota(); webPage()->settings()->setOfflineWebApplicationCacheQuota(quota); // create our controllers. This has to be done before connectFrame, // as it exports there to the JavaScript DOM window. m_controller = new LayoutTestController(this); connect(m_controller, SIGNAL(showPage()), this, SLOT(showPage())); connect(m_controller, SIGNAL(hidePage()), this, SLOT(hidePage())); // async geolocation permission set by controller connect(m_controller, SIGNAL(geolocationPermissionSet()), this, SLOT(geolocationPermissionSet())); connect(m_controller, SIGNAL(done()), this, SLOT(dump())); m_eventSender = new EventSender(m_page); m_textInputController = new TextInputController(m_page); m_gcController = new GCController(m_page); // now connect our different signals connect(m_page, SIGNAL(frameCreated(QWebFrame *)), this, SLOT(connectFrame(QWebFrame *))); connectFrame(m_page->mainFrame()); connect(m_page, SIGNAL(loadFinished(bool)), m_controller, SLOT(maybeDump(bool))); // We need to connect to loadStarted() because notifyDone should only // dump results itself when the last page loaded in the test has finished loading. connect(m_page, SIGNAL(loadStarted()), m_controller, SLOT(resetLoadFinished())); connect(m_page, SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); connect(m_page, SIGNAL(printRequested(QWebFrame*)), this, SLOT(dryRunPrint(QWebFrame*))); connect(m_page->mainFrame(), SIGNAL(titleChanged(const QString&)), SLOT(titleChanged(const QString&))); connect(m_page, SIGNAL(databaseQuotaExceeded(QWebFrame*,QString)), this, SLOT(dumpDatabaseQuota(QWebFrame*,QString))); connect(m_page, SIGNAL(statusBarMessage(const QString&)), this, SLOT(statusBarMessage(const QString&))); QObject::connect(this, SIGNAL(quit()), qApp, SLOT(quit()), Qt::QueuedConnection); DumpRenderTreeSupportQt::setDumpRenderTreeModeEnabled(true); QFocusEvent event(QEvent::FocusIn, Qt::ActiveWindowFocusReason); QApplication::sendEvent(m_mainView, &event); } DumpRenderTree::~DumpRenderTree() { delete m_mainView; delete m_stdin; } static void clearHistory(QWebPage* page) { // QWebHistory::clear() leaves current page, so remove it as well by setting // max item count to 0, and then setting it back to it's original value. QWebHistory* history = page->history(); int itemCount = history->maximumItemCount(); history->clear(); history->setMaximumItemCount(0); history->setMaximumItemCount(itemCount); } void DumpRenderTree::dryRunPrint(QWebFrame* frame) { #ifndef QT_NO_PRINTER NullPrinter printer; frame->print(&printer); #endif } void DumpRenderTree::resetToConsistentStateBeforeTesting() { // reset so that any current loads are stopped // NOTE: that this has to be done before the layoutTestController is // reset or we get timeouts for some tests. m_page->blockSignals(true); m_page->triggerAction(QWebPage::Stop); m_page->blockSignals(false); // reset the layoutTestController at this point, so that we under no // circumstance dump (stop the waitUntilDone timer) during the reset // of the DRT. m_controller->reset(); // reset mouse clicks counter m_eventSender->resetClickCount(); closeRemainingWindows(); m_page->resetSettings(); m_page->undoStack()->clear(); m_page->mainFrame()->setZoomFactor(1.0); clearHistory(m_page); DumpRenderTreeSupportQt::clearFrameName(m_page->mainFrame()); m_page->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded); m_page->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded); WorkQueue::shared()->clear(); WorkQueue::shared()->setFrozen(false); DumpRenderTreeSupportQt::resetOriginAccessWhiteLists(); // Qt defaults to Windows editing behavior. DumpRenderTreeSupportQt::setEditingBehavior(m_page, "win"); QLocale::setDefault(QLocale::c()); setlocale(LC_ALL, ""); } static bool isWebInspectorTest(const QUrl& url) { if (url.path().contains("inspector/")) return true; return false; } static bool shouldEnableDeveloperExtras(const QUrl& url) { return isWebInspectorTest(url) || url.path().contains("inspector-enabled/"); } void DumpRenderTree::open(const QUrl& url) { DumpRenderTreeSupportQt::dumpResourceLoadCallbacksPath(QFileInfo(url.toString()).path()); resetToConsistentStateBeforeTesting(); if (shouldEnableDeveloperExtras(m_page->mainFrame()->url())) { layoutTestController()->closeWebInspector(); layoutTestController()->setDeveloperExtrasEnabled(false); } if (shouldEnableDeveloperExtras(url)) { layoutTestController()->setDeveloperExtrasEnabled(true); if (isWebInspectorTest(url)) layoutTestController()->showWebInspector(); } // W3C SVG tests expect to be 480x360 bool isW3CTest = url.toString().contains("svg/W3C-SVG-1.1"); int width = isW3CTest ? 480 : LayoutTestController::maxViewWidth; int height = isW3CTest ? 360 : LayoutTestController::maxViewHeight; m_mainView->resize(QSize(width, height)); m_page->setPreferredContentsSize(QSize()); m_page->setViewportSize(QSize(width, height)); QFocusEvent ev(QEvent::FocusIn); m_page->event(&ev); QWebSettings::clearMemoryCaches(); #if !(defined(Q_OS_SYMBIAN) && QT_VERSION <= QT_VERSION_CHECK(4, 6, 2)) QFontDatabase::removeAllApplicationFonts(); #endif #if defined(Q_WS_X11) initializeFonts(); #endif DumpRenderTreeSupportQt::dumpFrameLoader(url.toString().contains("loading/")); setTextOutputEnabled(true); m_page->mainFrame()->load(url); } void DumpRenderTree::readLine() { if (!m_stdin) { m_stdin = new QFile; m_stdin->open(stdin, QFile::ReadOnly); if (!m_stdin->isReadable()) { emit quit(); return; } } QByteArray line = m_stdin->readLine().trimmed(); if (line.isEmpty()) { emit quit(); return; } processLine(QString::fromLocal8Bit(line.constData(), line.length())); } void DumpRenderTree::processArgsLine(const QStringList &args) { setStandAloneMode(true); for (int i = 1; i < args.size(); ++i) if (!args.at(i).startsWith('-')) m_standAloneModeTestList.append(args[i]); QFileInfo firstEntry(m_standAloneModeTestList.first()); if (firstEntry.isDir()) { QDir folderEntry(m_standAloneModeTestList.first()); QStringList supportedExt; // Check for all supported extensions (from Scripts/webkitpy/layout_tests/layout_package/test_files.py). supportedExt << "*.html" << "*.shtml" << "*.xml" << "*.xhtml" << "*.xhtmlmp" << "*.pl" << "*.php" << "*.svg"; m_standAloneModeTestList = folderEntry.entryList(supportedExt, QDir::Files); for (int i = 0; i < m_standAloneModeTestList.size(); ++i) m_standAloneModeTestList[i] = folderEntry.absoluteFilePath(m_standAloneModeTestList[i]); } processLine(m_standAloneModeTestList.first()); m_standAloneModeTestList.removeFirst(); connect(this, SIGNAL(ready()), this, SLOT(loadNextTestInStandAloneMode())); } void DumpRenderTree::loadNextTestInStandAloneMode() { if (m_standAloneModeTestList.isEmpty()) { emit quit(); return; } processLine(m_standAloneModeTestList.first()); m_standAloneModeTestList.removeFirst(); } void DumpRenderTree::processLine(const QString &input) { QString line = input; m_expectedHash = QString(); if (m_dumpPixels) { // single quote marks the pixel dump hash int i = line.indexOf('\''); if (i > -1) { m_expectedHash = line.mid(i + 1, line.length()); line.remove(i, line.length()); } } if (line.startsWith(QLatin1String("http:")) || line.startsWith(QLatin1String("https:")) || line.startsWith(QLatin1String("file:"))) { open(QUrl(line)); } else { QFileInfo fi(line); if (!fi.exists()) { QDir currentDir = QDir::currentPath(); // Try to be smart about where the test is located if (currentDir.dirName() == QLatin1String("LayoutTests")) fi = QFileInfo(currentDir, line.replace(QRegExp(".*?LayoutTests/(.*)"), "\\1")); else if (!line.contains(QLatin1String("LayoutTests"))) fi = QFileInfo(currentDir, line.prepend(QLatin1String("LayoutTests/"))); if (!fi.exists()) { emit ready(); return; } } open(QUrl::fromLocalFile(fi.absoluteFilePath())); } fflush(stdout); } void DumpRenderTree::setDumpPixels(bool dump) { m_dumpPixels = dump; } void DumpRenderTree::closeRemainingWindows() { foreach (QObject* widget, windows) delete widget; windows.clear(); } void DumpRenderTree::initJSObjects() { QWebFrame *frame = qobject_cast<QWebFrame*>(sender()); Q_ASSERT(frame); frame->addToJavaScriptWindowObject(QLatin1String("layoutTestController"), m_controller); frame->addToJavaScriptWindowObject(QLatin1String("eventSender"), m_eventSender); frame->addToJavaScriptWindowObject(QLatin1String("textInputController"), m_textInputController); frame->addToJavaScriptWindowObject(QLatin1String("GCController"), m_gcController); } void DumpRenderTree::showPage() { m_mainView->show(); // we need a paint event but cannot process all the events QPixmap pixmap(m_mainView->size()); m_mainView->render(&pixmap); } void DumpRenderTree::hidePage() { m_mainView->hide(); } QString DumpRenderTree::dumpFrameScrollPosition(QWebFrame* frame) { if (!frame || !DumpRenderTreeSupportQt::hasDocumentElement(frame)) return QString(); QString result; QPoint pos = frame->scrollPosition(); if (pos.x() > 0 || pos.y() > 0) { QWebFrame* parent = qobject_cast<QWebFrame *>(frame->parent()); if (parent) result.append(QString("frame '%1' ").arg(frame->title())); result.append(QString("scrolled to %1,%2\n").arg(pos.x()).arg(pos.y())); } if (m_controller->shouldDumpChildFrameScrollPositions()) { QList<QWebFrame*> children = frame->childFrames(); for (int i = 0; i < children.size(); ++i) result += dumpFrameScrollPosition(children.at(i)); } return result; } QString DumpRenderTree::dumpFramesAsText(QWebFrame* frame) { if (!frame || !DumpRenderTreeSupportQt::hasDocumentElement(frame)) return QString(); QString result; QWebFrame* parent = qobject_cast<QWebFrame*>(frame->parent()); if (parent) { result.append(QLatin1String("\n--------\nFrame: '")); result.append(frame->frameName()); result.append(QLatin1String("'\n--------\n")); } QString innerText = frame->toPlainText(); result.append(innerText); result.append(QLatin1String("\n")); if (m_controller->shouldDumpChildrenAsText()) { QList<QWebFrame *> children = frame->childFrames(); for (int i = 0; i < children.size(); ++i) result += dumpFramesAsText(children.at(i)); } return result; } static QString dumpHistoryItem(const QWebHistoryItem& item, int indent, bool current) { QString result; int start = 0; if (current) { result.append(QLatin1String("curr->")); start = 6; } for (int i = start; i < indent; i++) result.append(' '); QString url = item.url().toString(); if (url.contains("file://")) { static QString layoutTestsString("/LayoutTests/"); static QString fileTestString("(file test):"); QString res = url.mid(url.indexOf(layoutTestsString) + layoutTestsString.length()); if (res.isEmpty()) return result; result.append(fileTestString); result.append(res); } else { result.append(url); } QString target = DumpRenderTreeSupportQt::historyItemTarget(item); if (!target.isEmpty()) result.append(QString(QLatin1String(" (in frame \"%1\")")).arg(target)); if (DumpRenderTreeSupportQt::isTargetItem(item)) result.append(QLatin1String(" **nav target**")); result.append(QLatin1String("\n")); QMap<QString, QWebHistoryItem> children = DumpRenderTreeSupportQt::getChildHistoryItems(item); foreach (QWebHistoryItem item, children) result += dumpHistoryItem(item, 12, false); return result; } QString DumpRenderTree::dumpBackForwardList(QWebPage* page) { QWebHistory* history = page->history(); QString result; result.append(QLatin1String("\n============== Back Forward List ==============\n")); // FORMAT: // " (file test):fast/loader/resources/click-fragment-link.html **nav target**" // "curr-> (file test):fast/loader/resources/click-fragment-link.html#testfragment **nav target**" int maxItems = history->maximumItemCount(); foreach (const QWebHistoryItem item, history->backItems(maxItems)) { if (!item.isValid()) continue; result.append(dumpHistoryItem(item, 8, false)); } QWebHistoryItem item = history->currentItem(); if (item.isValid()) result.append(dumpHistoryItem(item, 8, true)); foreach (const QWebHistoryItem item, history->forwardItems(maxItems)) { if (!item.isValid()) continue; result.append(dumpHistoryItem(item, 8, false)); } result.append(QLatin1String("===============================================\n")); return result; } static const char *methodNameStringForFailedTest(LayoutTestController *controller) { const char *errorMessage; if (controller->shouldDumpAsText()) errorMessage = "[documentElement innerText]"; // FIXME: Add when we have support //else if (controller->dumpDOMAsWebArchive()) // errorMessage = "[[mainFrame DOMDocument] webArchive]"; //else if (controller->dumpSourceAsWebArchive()) // errorMessage = "[[mainFrame dataSource] webArchive]"; else errorMessage = "[mainFrame renderTreeAsExternalRepresentation]"; return errorMessage; } void DumpRenderTree::dump() { // Prevent any further frame load or resource load callbacks from appearing after we dump the result. DumpRenderTreeSupportQt::dumpFrameLoader(false); DumpRenderTreeSupportQt::dumpResourceLoadCallbacks(false); QWebFrame *mainFrame = m_page->mainFrame(); if (isStandAloneMode()) { QString markup = mainFrame->toHtml(); fprintf(stdout, "Source:\n\n%s\n", markup.toUtf8().constData()); } // Dump render text... QString resultString; if (m_controller->shouldDumpAsText()) resultString = dumpFramesAsText(mainFrame); else { resultString = mainFrame->renderTreeDump(); resultString += dumpFrameScrollPosition(mainFrame); } if (!resultString.isEmpty()) { fprintf(stdout, "Content-Type: text/plain\n"); fprintf(stdout, "%s", resultString.toUtf8().constData()); if (m_controller->shouldDumpBackForwardList()) { fprintf(stdout, "%s", dumpBackForwardList(webPage()).toUtf8().constData()); foreach (QObject* widget, windows) { QWebPage* page = qobject_cast<QWebPage*>(widget->findChild<QWebPage*>()); fprintf(stdout, "%s", dumpBackForwardList(page).toUtf8().constData()); } } } else printf("ERROR: nil result from %s", methodNameStringForFailedTest(m_controller)); // signal end of text block fputs("#EOF\n", stdout); fputs("#EOF\n", stderr); // FIXME: All other ports don't dump pixels, if generatePixelResults is false. if (m_dumpPixels) { QImage image(m_page->viewportSize(), QImage::Format_ARGB32); image.fill(Qt::white); QPainter painter(&image); mainFrame->render(&painter); painter.end(); QCryptographicHash hash(QCryptographicHash::Md5); for (int row = 0; row < image.height(); ++row) hash.addData(reinterpret_cast<const char*>(image.scanLine(row)), image.width() * 4); QString actualHash = hash.result().toHex(); fprintf(stdout, "\nActualHash: %s\n", qPrintable(actualHash)); bool dumpImage = true; if (!m_expectedHash.isEmpty()) { Q_ASSERT(m_expectedHash.length() == 32); fprintf(stdout, "\nExpectedHash: %s\n", qPrintable(m_expectedHash)); if (m_expectedHash == actualHash) dumpImage = false; } if (dumpImage) { QBuffer buffer; buffer.open(QBuffer::WriteOnly); image.save(&buffer, "PNG"); buffer.close(); const QByteArray &data = buffer.data(); printf("Content-Type: %s\n", "image/png"); printf("Content-Length: %lu\n", static_cast<unsigned long>(data.length())); const quint32 bytesToWriteInOneChunk = 1 << 15; quint32 dataRemainingToWrite = data.length(); const char *ptr = data.data(); while (dataRemainingToWrite) { quint32 bytesToWriteInThisChunk = qMin(dataRemainingToWrite, bytesToWriteInOneChunk); quint32 bytesWritten = fwrite(ptr, 1, bytesToWriteInThisChunk, stdout); if (bytesWritten != bytesToWriteInThisChunk) break; dataRemainingToWrite -= bytesWritten; ptr += bytesWritten; } } fflush(stdout); } puts("#EOF"); // terminate the (possibly empty) pixels block fflush(stdout); fflush(stderr); emit ready(); } void DumpRenderTree::titleChanged(const QString &s) { if (m_controller->shouldDumpTitleChanges()) printf("TITLE CHANGED: %s\n", s.toUtf8().data()); } void DumpRenderTree::connectFrame(QWebFrame *frame) { connect(frame, SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(initJSObjects())); connect(frame, SIGNAL(provisionalLoad()), layoutTestController(), SLOT(provisionalLoad())); } void DumpRenderTree::dumpDatabaseQuota(QWebFrame* frame, const QString& dbName) { if (!m_controller->shouldDumpDatabaseCallbacks()) return; QWebSecurityOrigin origin = frame->securityOrigin(); printf("UI DELEGATE DATABASE CALLBACK: exceededDatabaseQuotaForSecurityOrigin:{%s, %s, %i} database:%s\n", origin.scheme().toUtf8().data(), origin.host().toUtf8().data(), origin.port(), dbName.toUtf8().data()); origin.setDatabaseQuota(5 * 1024 * 1024); } void DumpRenderTree::statusBarMessage(const QString& message) { if (!m_controller->shouldDumpStatusCallbacks()) return; printf("UI DELEGATE STATUS CALLBACK: setStatusText:%s\n", message.toUtf8().constData()); } QWebPage *DumpRenderTree::createWindow() { if (!m_controller->canOpenWindows()) return 0; // Create a dummy container object to track the page in DRT. // QObject is used instead of QWidget to prevent DRT from // showing the main view when deleting the container. QObject* container = new QObject(m_mainView); // create a QWebPage we want to return QWebPage* page = static_cast<QWebPage*>(new WebPage(container, this)); // gets cleaned up in closeRemainingWindows() windows.append(container); // connect the needed signals to the page connect(page, SIGNAL(frameCreated(QWebFrame*)), this, SLOT(connectFrame(QWebFrame*))); connectFrame(page->mainFrame()); connect(page, SIGNAL(loadFinished(bool)), m_controller, SLOT(maybeDump(bool))); connect(page, SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); return page; } void DumpRenderTree::windowCloseRequested() { QWebPage* page = qobject_cast<QWebPage*>(sender()); QObject* container = page->parent(); windows.removeAll(container); container->deleteLater(); } int DumpRenderTree::windowCount() const { // include the main view in the count return windows.count() + 1; } void DumpRenderTree::geolocationPermissionSet() { m_page->permissionSet(QWebPage::GeolocationPermissionDomain); } void DumpRenderTree::switchFocus(bool focused) { QFocusEvent event((focused) ? QEvent::FocusIn : QEvent::FocusOut, Qt::ActiveWindowFocusReason); if (!isGraphicsBased()) QApplication::sendEvent(m_mainView, &event); else { if (WebViewGraphicsBased* view = qobject_cast<WebViewGraphicsBased*>(m_mainView)) view->scene()->sendEvent(view->graphicsView(), &event); } } #if defined(Q_WS_X11) void DumpRenderTree::initializeFonts() { static int numFonts = -1; // Some test cases may add or remove application fonts (via @font-face). // Make sure to re-initialize the font set if necessary. FcFontSet* appFontSet = FcConfigGetFonts(0, FcSetApplication); if (appFontSet && numFonts >= 0 && appFontSet->nfont == numFonts) return; QByteArray fontDir = getenv("WEBKIT_TESTFONTS"); if (fontDir.isEmpty() || !QDir(fontDir).exists()) { fprintf(stderr, "\n\n" "----------------------------------------------------------------------\n" "WEBKIT_TESTFONTS environment variable is not set correctly.\n" "This variable has to point to the directory containing the fonts\n" "you can clone from git://gitorious.org/qtwebkit/testfonts.git\n" "----------------------------------------------------------------------\n" ); exit(1); } char currentPath[PATH_MAX+1]; if (!getcwd(currentPath, PATH_MAX)) qFatal("Couldn't get current working directory"); QByteArray configFile = currentPath; FcConfig *config = FcConfigCreate(); configFile += "/WebKitTools/DumpRenderTree/qt/fonts.conf"; if (!FcConfigParseAndLoad (config, (FcChar8*) configFile.data(), true)) qFatal("Couldn't load font configuration file"); if (!FcConfigAppFontAddDir (config, (FcChar8*) fontDir.data())) qFatal("Couldn't add font dir!"); FcConfigSetCurrent(config); appFontSet = FcConfigGetFonts(config, FcSetApplication); numFonts = appFontSet->nfont; } #endif }
[ [ [ 1, 1123 ] ] ]
eaa54a7cc88c38aa5c984a076e95ef56d05539be
814b49df11675ac3664ac0198048961b5306e1c5
/Code/Engine/Graphics/PortalManager.cpp
9378ae6db5f66e9df16ae4aee945da638670628c
[]
no_license
Atridas/biogame
f6cb24d0c0b208316990e5bb0b52ef3fb8e83042
3b8e95b215da4d51ab856b4701c12e077cbd2587
refs/heads/master
2021-01-13T00:55:50.502395
2011-10-31T12:58:53
2011-10-31T12:58:53
43,897,729
0
0
null
null
null
null
IBM852
C++
false
false
21,289
cpp
#include "PortalManager.h" #include "RenderManager.h" #include "Camera.h" #include "Core.h" #include "EffectManager.h" #include "Portal.h" #include "RenderableObjectsManager.h" #include "RenderableObject.h" #include <XML\XMLTreeNode.h> bool CPortalManager::Init(const string& _szFileName) { SetOk(true); if(!m_UnlocatedROs.IsOk()) m_UnlocatedROs.Init(); CXMLTreeNode l_xmlLevel; if(l_xmlLevel.LoadFile(_szFileName.c_str())) { Init(l_xmlLevel); } else { SetOk(false); LOGGER->AddNewLog(ELL_ERROR, "CPortalManager::Init file \"%s\" not found or incorrect.", _szFileName.c_str()); } return IsOk(); } bool CPortalManager::Init(const vector<string>& _szFileNames) { SetOk(true); if(!m_UnlocatedROs.IsOk()) m_UnlocatedROs.Init(); set<string> l_UsedGameObjects; //vector<CXMLTreeNode> l_vxmlPortals; for(uint32 i = 0; i < _szFileNames.size(); ++i) { CXMLTreeNode l_xmlLevel; if(l_xmlLevel.LoadFile(_szFileNames[i].c_str())) { ReadRooms(l_xmlLevel["Rooms"], l_UsedGameObjects); ReadPortals(l_xmlLevel["Portals"]); //l_vxmlPortals.push_back(l_xmlLevel["Portals"]); } else { LOGGER->AddNewLog(ELL_WARNING, "CPortalManager::Init file \"%s\" not found or incorrect.", _szFileNames[i].c_str()); } } //Afegir la resta de RObjects. CRenderableObjectsManager* l_pROM = CORE->GetRenderableObjectsManager(); int l_iROn = l_pROM->GetRenderableVectorSize(); for(int i = 0; i < l_iROn; ++i) { CRenderableObject* l_pRO = l_pROM->GetRenderableObject(i); if(l_UsedGameObjects.find( l_pRO->GetName() ) == l_UsedGameObjects.end()) { m_UnlocatedROs.AddRendeableObject( l_pRO ); } } /*for(uint32 i = 0; i < l_vxmlPortals.size(); ++i) { ReadPortals(l_vxmlPortals[i]); }*/ return IsOk(); } bool CPortalManager::Init(CXMLTreeNode& _xmlLevel) { assert(strcmp(_xmlLevel.GetName(), "PortalManager") == 0); SetOk(true); if(!m_UnlocatedROs.IsOk()) m_UnlocatedROs.Init(); LOGGER->AddNewLog(ELL_INFORMATION, "CPortalManager::Init"); { CXMLTreeNode l_xmlRooms = _xmlLevel["Rooms"]; set<string> l_UsedGameObjects; if(l_xmlRooms.Exists()) { LOGGER->AddNewLog(ELL_INFORMATION, "CPortalManager::Init Recorrent Rooms"); int l_iRooms = l_xmlRooms.GetNumChildren(); for(int i = 0; i < l_iRooms; ++i) { CXMLTreeNode l_xmlRoom = l_xmlRooms(i); if(strcmp(l_xmlRoom.GetName(), "Room") == 0) { string l_szName = l_xmlRoom.GetPszISOProperty("name", "undefined", true); if(m_Rooms.find(l_szName) == m_Rooms.end()) { CRoom l_Room; if(l_Room.Init(l_xmlRoom, l_UsedGameObjects)) { m_Rooms[l_szName] = l_Room; m_RoomNames.insert(l_szName); } else { LOGGER->AddNewLog(ELL_WARNING, "CPortalManager::Init Room \"%s\" no OK", l_szName.c_str()); } } else { LOGGER->AddNewLog(ELL_WARNING, "CPortalManager::Init Room \"%s\" repetida", l_szName.c_str()); } } else if(!l_xmlRoom.IsComment()) { LOGGER->AddNewLog(ELL_WARNING, "CPortalManager::Init Element no reconegut! \"%s\"", l_xmlRoom.GetName()); } } } else { LOGGER->AddNewLog(ELL_ERROR, "CPortalManager::Init No Rooms!"); SetOk(false); } //Afegir la resta de RObjects. CRenderableObjectsManager* l_pROM = CORE->GetRenderableObjectsManager(); int l_iROn = l_pROM->GetRenderableVectorSize(); for(int i = 0; i < l_iROn; ++i) { CRenderableObject* l_pRO = l_pROM->GetRenderableObject(i); if(l_UsedGameObjects.find( l_pRO->GetName() ) == l_UsedGameObjects.end()) { m_UnlocatedROs.AddRendeableObject( l_pRO ); } } } { CXMLTreeNode l_xmlPortals = _xmlLevel["Portals"]; if(l_xmlPortals.Exists()) { LOGGER->AddNewLog(ELL_INFORMATION, "CPortalManager::Init Recorrent Portals"); int l_iPortals = l_xmlPortals.GetNumChildren(); for(int i = 0; i < l_iPortals; ++i) { CXMLTreeNode l_xmlPortal = l_xmlPortals(i); if(strcmp(l_xmlPortal.GetName(), "Portal") == 0) { string l_szName = l_xmlPortal.GetPszISOProperty("name", "", true); if(m_Portals.find(l_szName) == m_Portals.end()) { CPortal l_Portal; m_Portals[l_szName] = l_Portal; if(!m_Portals[l_szName].Init(l_xmlPortal, this)) { m_Portals.erase(l_szName); LOGGER->AddNewLog(ELL_WARNING, "CPortalManager::Init Portal \"%s\" no OK", l_szName.c_str()); } } else { LOGGER->AddNewLog(ELL_WARNING, "CPortalManager::Init Portal \"%s\" repetit", l_szName.c_str()); } } else if(!l_xmlPortal.IsComment()) { LOGGER->AddNewLog(ELL_WARNING, "CPortalManager::Init Element no reconegut! \"%s\"", l_xmlPortal.GetName()); } } } else { LOGGER->AddNewLog(ELL_ERROR, "CPortalManager::Init No Portals!"); SetOk(false); } } return IsOk(); } void CPortalManager::ReadRooms(CXMLTreeNode& _xmlRooms, set<string>& _UsedGameObjects) { if(_xmlRooms.Exists()) { LOGGER->AddNewLog(ELL_INFORMATION, "CPortalManager::ReadRooms Recorrent Rooms"); int l_iRooms = _xmlRooms.GetNumChildren(); for(int i = 0; i < l_iRooms; ++i) { CXMLTreeNode l_xmlRoom = _xmlRooms(i); if(strcmp(l_xmlRoom.GetName(), "Room") == 0) { string l_szName = l_xmlRoom.GetPszISOProperty("name", "undefined", true); if(m_Rooms.find(l_szName) == m_Rooms.end()) { CRoom l_Room; if(l_Room.Init(l_xmlRoom, _UsedGameObjects)) { m_Rooms[l_szName] = l_Room; m_RoomNames.insert(l_szName); } else { LOGGER->AddNewLog(ELL_WARNING, "CPortalManager::ReadRooms Room \"%s\" no OK", l_szName.c_str()); } } else { LOGGER->AddNewLog(ELL_WARNING, "CPortalManager::ReadRooms Room \"%s\" repetida", l_szName.c_str()); } } else if(!l_xmlRoom.IsComment()) { LOGGER->AddNewLog(ELL_WARNING, "CPortalManager::ReadRooms Element no reconegut! \"%s\"", l_xmlRoom.GetName()); } } } else { LOGGER->AddNewLog(ELL_ERROR, "CPortalManager::ReadRooms No Rooms!"); SetOk(false); } } void CPortalManager::ReadPortals(CXMLTreeNode& _xmlPortals) { if(_xmlPortals.Exists()) { LOGGER->AddNewLog(ELL_INFORMATION, "CPortalManager::ReadPortals Recorrent Portals"); int l_iPortals = _xmlPortals.GetNumChildren(); for(int i = 0; i < l_iPortals; ++i) { CXMLTreeNode l_xmlPortal = _xmlPortals(i); if(strcmp(l_xmlPortal.GetName(), "Portal") == 0) { string l_szName = l_xmlPortal.GetPszISOProperty("name", "", true); if(m_Portals.find(l_szName) == m_Portals.end()) { CPortal l_Portal; m_Portals[l_szName] = l_Portal; if(!m_Portals[l_szName].Init(l_xmlPortal, this)) { m_Portals.erase(l_szName); LOGGER->AddNewLog(ELL_WARNING, "CPortalManager::ReadPortals Portal \"%s\" no OK", l_szName.c_str()); } } else { LOGGER->AddNewLog(ELL_WARNING, "CPortalManager::ReadPortals Portal \"%s\" repetit", l_szName.c_str()); } } else if(!l_xmlPortal.IsComment()) { LOGGER->AddNewLog(ELL_WARNING, "CPortalManager::ReadPortals Element no reconegut! \"%s\"", l_xmlPortal.GetName()); } } } else { LOGGER->AddNewLog(ELL_ERROR, "CPortalManager::ReadPortals No Portals!"); SetOk(false); } } void CPortalManager::Release() { m_UnlocatedROs.Done(); m_Rooms.clear(); m_Portals.clear(); m_RoomNames.clear(); m_szCameraLastRoom=""; m_fLastUpdate=0; }; CRoom* CPortalManager::GetRoom (const string& _szName) { map<string,CRoom>::iterator l_it = m_Rooms.find(_szName); if(l_it == m_Rooms.cend()) { return 0; } else { return &(l_it->second); } } CPortal* CPortalManager::GetPortal(const string& _szName) { map<string,CPortal>::iterator l_it = m_Portals.find(_szName); if(l_it == m_Portals.cend()) { return 0; } else { return &(l_it->second); } } struct SRP { CRoom* r; CPortal* p; SRP(CRoom* _r, CPortal* _p):r(_r),p(_p) {}; }; void RenderPortals( CRoom *_pRoom, CRenderManager* _pRM, const CCamera* _vCamera, const CFrustum& _Frustum, set<CPortal*> _PrevPortals, CRoom::TBlendQueue& _BlendQueue, CRoom::TBlendQueue& _EmiterQueue, bool _bDebug) { if(!_bDebug) { _pRoom->Render(_pRM,_Frustum,_BlendQueue,_EmiterQueue); _pRoom->SetRendered(true); //la marquem com a renderitzada _pRoom->SetNeightbour(true); } const vector<CPortal*>& l_Portals = _pRoom->GetPortals(); vector<SRP> l_NextRooms; { vector<CPortal*>::const_iterator l_it = l_Portals.cbegin(); vector<CPortal*>::const_iterator l_end = l_Portals.cend(); for(; l_it != l_end; ++l_it) { CPortal* l_pPortal = *l_it; if(_PrevPortals.find(l_pPortal) == _PrevPortals.cend()) { _PrevPortals.insert(l_pPortal); if(l_pPortal->GetRoomA() == _pRoom) { assert(l_pPortal->GetRoomB() != _pRoom); l_NextRooms.push_back( SRP(l_pPortal->GetRoomB(),l_pPortal) ); } else { assert(l_pPortal->GetRoomB() == _pRoom); l_NextRooms.push_back( SRP(l_pPortal->GetRoomA(),l_pPortal) ); } } } } { vector<SRP>::const_iterator l_it = l_NextRooms.cbegin(); vector<SRP>::const_iterator l_end = l_NextRooms.cend(); for(; l_it != l_end; ++l_it) { const Vect3f * l_PortalPoints = l_it->p->GetBoundingBox()->GetBox(); Vect3f l_TransformedPoints[8]; Mat44f l_matPortal = l_it->p->GetMat44(); for(int i = 0; i < 8; ++i) { l_TransformedPoints[i] = l_matPortal * l_PortalPoints[i]; } if(_Frustum.BoxVisibleByVertexs(l_TransformedPoints)) { CFrustum l_Frustum(_Frustum); //l_Frustum.Update(_vCameraEye, l_TransformedPoints, 8); l_Frustum.Update(_vCamera, l_TransformedPoints); if(_bDebug) { Mat44f i; i.SetIdentity(); _pRM->SetTransform(i); _pRM->DrawFrustum(&l_Frustum, colYELLOW); } RenderPortals(l_it->r,_pRM,_vCamera,l_Frustum,_PrevPortals,_BlendQueue,_EmiterQueue,_bDebug); } else { l_it->r->SetNeightbour(true);//si no es renderitza, diem que es habitacio veina. } } } } void CPortalManager::Update(float _fDT) { m_fLastUpdate += _fDT; if(m_fLastUpdate < PORTAL_MANAGER_UPDATE_PERIOD) { return; } else { m_fLastUpdate = 0; } map<string,CRoom>::iterator l_it = m_Rooms.begin(); map<string,CRoom>::iterator l_end = m_Rooms.end(); for(; l_it != l_end; ++l_it) { l_it->second.Update(this); } m_UnlocatedROs.Update(this); } void CPortalManager::Render(CRenderManager* _pRM, bool _bDebug) { /* { // 0 resetejem l'estat de les habitacions map<string,CRoom>::iterator l_end = m_Rooms.end(); for(map<string,CRoom>::iterator l_it = m_Rooms.begin(); l_it != l_end; ++l_it) { l_it->second.SetRendered (false); l_it->second.SetNeightbour(false); } } // 1 busquem en quina habitaciˇ estÓ la camera. CCamera *l_pCamera = _pRM->GetCamera(); Vect3f l_vCameraEye = l_pCamera->GetEye(); map<string,CRoom>::iterator l_it = m_Rooms.find(m_szCameraLastRoom); CRoom *l_pCameraRoom = 0; CObject3D l_CameraObject; l_CameraObject.SetPosition( l_vCameraEye ); l_CameraObject.GetBoundingSphere()->Init(Vect3f(0,0,0),0.2f); if(l_it != m_Rooms.end()) { l_pCameraRoom = &(l_it->second); if(!l_pCameraRoom->IsObject3DSphereInRoom(&l_CameraObject)) { l_pCameraRoom = 0; } } if(!l_pCameraRoom) { map<string,CRoom>::iterator l_end = m_Rooms.end(); for(l_it = m_Rooms.begin(); l_it != l_end; ++l_it) { if(l_it->second.IsObject3DSphereInRoom(&l_CameraObject)) { m_szCameraLastRoom = l_it->first; l_pCameraRoom = &(l_it->second); break; } } } CFrustum l_Frustum = _pRM->GetFrustum(); Vect3f l_vEye = (l_pCamera)? l_pCamera->GetEye() : Vect3f(0,0,-1); CObject3DOrdering l_Ordering(l_vEye); CRoom::TBlendQueue l_BlendQueue(l_Ordering); CRoom::TBlendQueue l_EmiterQueue(l_Ordering); CORE->GetEffectManager()->ActivateDefaultRendering(); if(!l_pCameraRoom) { map<string,CRoom>::iterator l_end = m_Rooms.end(); for(l_it = m_Rooms.begin(); l_it != l_end; ++l_it) { l_it->second.Render(_pRM,l_Frustum,l_BlendQueue,l_EmiterQueue); l_it->second.SetRendered(true); l_it->second.SetNeightbour(true); } } else { set<CPortal*> l_PrevPortals; RenderPortals(l_pCameraRoom, _pRM, l_pCamera, l_Frustum, l_PrevPortals, l_BlendQueue,l_EmiterQueue,_bDebug); } m_UnlocatedROs.Render(_pRM,l_Frustum,l_BlendQueue,l_EmiterQueue); m_UnlocatedROs.SetRendered(true); m_UnlocatedROs.SetNeightbour(true); CORE->GetEffectManager()->ActivateAlphaRendering(); while(!l_BlendQueue.empty()) { CObject3DRenderable* l_pRenderableObject = l_BlendQueue.top(); //l_pRenderableObject->Render(_pRM); l_BlendQueue.pop(); } // particules ------------------------------------------------------- LPDIRECT3DDEVICE9 l_pd3dDevice = _pRM->GetDevice(); CEffectManager* l_pEM = CORE->GetEffectManager(); assert(l_pEM && l_pEM->IsOk()); CEffect* l_pPrevEffect = 0;//l_pEM->GetForcedStaticMeshEffect(); if(!l_pPrevEffect) { CEffect* l_pEffect = l_pEM->GetEffect("Particle"); //l_pEM->SetForcedStaticMeshEffect(l_pEffect); while(!l_EmiterQueue.empty()) { CRenderableObject3D* l_pRenderableObject = l_EmiterQueue.top(); l_pRenderableObject->Render(_pRM); l_EmiterQueue.pop(); } l_pd3dDevice->SetStreamSourceFreq(0, 1); l_pd3dDevice->SetStreamSourceFreq(1, 1); //l_pEM->SetForcedStaticMeshEffect(0); } // ------------------------------------------------------------------- */ } void GetRenderedObjectsPortals( CRoom *_pRoom, const CCamera* _vCamera, const CFrustum& _Frustum, set<CPortal*> _PrevPortals, vector<CRenderableObject*>& OpaqueObjects_, CRoom::TBlendQueue& BlendQueue_, CRoom::TBlendQueue& EmiterQueue_) { _pRoom->GetRenderedObjects(_Frustum,OpaqueObjects_,BlendQueue_,EmiterQueue_); _pRoom->SetRendered(true); //la marquem com a renderitzada _pRoom->SetNeightbour(true); const vector<CPortal*>& l_Portals = _pRoom->GetPortals(); vector<SRP> l_NextRooms; { vector<CPortal*>::const_iterator l_it = l_Portals.cbegin(); vector<CPortal*>::const_iterator l_end = l_Portals.cend(); for(; l_it != l_end; ++l_it) { CPortal* l_pPortal = *l_it; if(_PrevPortals.find(l_pPortal) == _PrevPortals.cend()) { _PrevPortals.insert(l_pPortal); if(l_pPortal->GetRoomA() == _pRoom) { assert(l_pPortal->GetRoomB() != _pRoom); l_NextRooms.push_back( SRP(l_pPortal->GetRoomB(),l_pPortal) ); } else { assert(l_pPortal->GetRoomB() == _pRoom); l_NextRooms.push_back( SRP(l_pPortal->GetRoomA(),l_pPortal) ); } } } } { vector<SRP>::const_iterator l_it = l_NextRooms.cbegin(); vector<SRP>::const_iterator l_end = l_NextRooms.cend(); for(; l_it != l_end; ++l_it) { const Vect3f * l_PortalPoints = l_it->p->GetBoundingBox()->GetBox(); Vect3f l_TransformedPoints[8]; Mat44f l_matPortal = l_it->p->GetMat44(); for(int i = 0; i < 8; ++i) { l_TransformedPoints[i] = l_matPortal * l_PortalPoints[i]; } if(_Frustum.BoxVisibleByVertexs(l_TransformedPoints)) { CFrustum l_Frustum(_Frustum); //l_Frustum.Update(_vCameraEye, l_TransformedPoints, 8); l_Frustum.Update(_vCamera, l_TransformedPoints); GetRenderedObjectsPortals(l_it->r, _vCamera, l_Frustum, _PrevPortals, OpaqueObjects_, BlendQueue_, EmiterQueue_); } else { l_it->r->SetNeightbour(true);//si no es renderitza, diem que es habitacio veina. } } } } void CPortalManager::GetRenderedObjects(CCamera *_pCamera, vector<CRenderableObject*>& OpaqueObjects_, CRoom::TBlendQueue& BlendQueue_, CRoom::TBlendQueue& EmiterQueue_) { { // 0 resetejem l'estat de les habitacions map<string,CRoom>::iterator l_end = m_Rooms.end(); for(map<string,CRoom>::iterator l_it = m_Rooms.begin(); l_it != l_end; ++l_it) { l_it->second.SetRendered (false); l_it->second.SetNeightbour(false); } } // 1 busquem en quina habitaciˇ estÓ la camera. Vect3f l_vCameraEye = _pCamera->GetEye(); map<string,CRoom>::iterator l_it = m_Rooms.find(m_szCameraLastRoom); CRoom *l_pCameraRoom = 0; CObject3D l_CameraObject; l_CameraObject.SetPosition( l_vCameraEye ); l_CameraObject.GetBoundingSphere()->Init(Vect3f(0,0,0),0.2f); if(l_it != m_Rooms.end()) { l_pCameraRoom = &(l_it->second); if(!l_pCameraRoom->IsObject3DSphereInRoom(&l_CameraObject)) { l_pCameraRoom = 0; } } if(!l_pCameraRoom) { map<string,CRoom>::iterator l_end = m_Rooms.end(); for(l_it = m_Rooms.begin(); l_it != l_end; ++l_it) { if(l_it->second.IsObject3DSphereInRoom(&l_CameraObject)) { m_szCameraLastRoom = l_it->first; l_pCameraRoom = &(l_it->second); break; } } } CFrustum l_Frustum; l_Frustum.Update(_pCamera); /* Vect3f l_vEye = _pCamera->GetEye(); CObject3DOrdering l_Ordering(l_vEye); CRoom::TBlendQueue l_BlendQueue(l_Ordering); CRoom::TBlendQueue l_EmiterQueue(l_Ordering); */ if(!l_pCameraRoom) { map<string,CRoom>::iterator l_end = m_Rooms.end(); for(l_it = m_Rooms.begin(); l_it != l_end; ++l_it) { l_it->second.GetRenderedObjects(l_Frustum,OpaqueObjects_,BlendQueue_,EmiterQueue_); l_it->second.SetRendered(true); l_it->second.SetNeightbour(true); } } else { set<CPortal*> l_PrevPortals; GetRenderedObjectsPortals(l_pCameraRoom, _pCamera, l_Frustum, l_PrevPortals, OpaqueObjects_, BlendQueue_, EmiterQueue_); } m_UnlocatedROs.GetRenderedObjects(l_Frustum,OpaqueObjects_,BlendQueue_,EmiterQueue_); m_UnlocatedROs.SetRendered(true); m_UnlocatedROs.SetNeightbour(true); } void CPortalManager::DebugRender(CRenderManager* _pRM) { map<string,CPortal>::const_iterator l_itP = m_Portals.cbegin(); map<string,CPortal>::const_iterator l_endP = m_Portals.cend(); for(; l_itP != l_endP; ++l_itP) { l_itP->second.DebugRender(_pRM); } map<string,CRoom>::const_iterator l_itR = m_Rooms.cbegin(); map<string,CRoom>::const_iterator l_endR = m_Rooms.cend(); for(; l_itR != l_endR; ++l_itR) { l_itR->second.DebugRender(_pRM); } Render(_pRM,true); } void CPortalManager::InsertRenderableObject(CRenderableObject* _pRO) { m_UnlocatedROs.AddRendeableObject( _pRO ); } void CPortalManager::RemoveRenderableObject(CRenderableObject* _pRO) { if(m_UnlocatedROs.RemoveRendeableObject(_pRO)) { return; } else { map<string,CRoom>::iterator l_itR = m_Rooms.begin(); map<string,CRoom>::iterator l_endR = m_Rooms.end(); for(; l_itR != l_endR; ++l_itR) { if(l_itR->second.RemoveRendeableObject(_pRO)) { return;//es trobava en aquesta habitaciˇ, no cal que continuem... } } } } void CPortalManager::InsertEmiter(CEmiterInstance* _pEmiter) { m_UnlocatedROs.AddEmiter( _pEmiter ); } void CPortalManager::RemoveEmiter(CEmiterInstance* _pEmiter) { if(m_UnlocatedROs.RemoveEmiter(_pEmiter)) { return; } else { map<string,CRoom>::iterator l_itR = m_Rooms.begin(); map<string,CRoom>::iterator l_endR = m_Rooms.end(); for(; l_itR != l_endR; ++l_itR) { if(l_itR->second.RemoveEmiter(_pEmiter)) { return;//es trobava en aquesta habitaciˇ, no cal que continuem... } } } }
[ "atridas87@576ee6d0-068d-96d9-bff2-16229cd70485", "Atridas87@576ee6d0-068d-96d9-bff2-16229cd70485", "sergivalls@576ee6d0-068d-96d9-bff2-16229cd70485" ]
[ [ [ 1, 1 ], [ 4, 15 ], [ 18, 36 ], [ 39, 75 ], [ 77, 77 ], [ 80, 274 ], [ 286, 310 ], [ 312, 318 ], [ 328, 328 ], [ 335, 376 ], [ 394, 421 ], [ 433, 435 ], [ 437, 441 ], [ 443, 452 ], [ 454, 470 ], [ 473, 473 ], [ 476, 481 ], [ 485, 489 ], [ 491, 492 ], [ 496, 500 ], [ 503, 504 ], [ 677, 678 ], [ 680, 696 ], [ 700, 725 ] ], [ [ 2, 3 ], [ 16, 17 ], [ 37, 38 ], [ 76, 76 ], [ 78, 79 ], [ 275, 285 ], [ 311, 311 ], [ 319, 327 ], [ 329, 334 ], [ 377, 393 ], [ 422, 423 ], [ 425, 432 ], [ 436, 436 ], [ 442, 442 ], [ 453, 453 ], [ 471, 472 ], [ 474, 475 ], [ 482, 484 ], [ 490, 490 ], [ 493, 495 ], [ 505, 511 ], [ 513, 515 ], [ 517, 526 ], [ 528, 529 ], [ 679, 679 ], [ 697, 699 ], [ 726, 752 ] ], [ [ 424, 424 ], [ 501, 502 ], [ 512, 512 ], [ 516, 516 ], [ 527, 527 ], [ 530, 676 ] ] ]
d03dba4603eccfb8f7cc16fa4e04392d02c1646b
c54f5a7cf6de3ed02d2e02cf867470ea48bd9258
/pyobjc/PyOpenGL-2.0.2.01/src/interface/GL.EXT._cull_vertex.0103.inc
ba777c62011f83901df2449de899ecd4c209e0b1
[]
no_license
orestis/pyobjc
01ad0e731fbbe0413c2f5ac2f3e91016749146c6
c30bf50ba29cb562d530e71a9d6c3d8ad75aa230
refs/heads/master
2021-01-22T06:54:35.401551
2009-09-01T09:24:47
2009-09-01T09:24:47
16,895
8
5
null
null
null
null
UTF-8
C++
false
false
53,760
inc
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 1.3.23 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make * changes to this file unless you know what you are doing--modify the SWIG * interface file instead. * ----------------------------------------------------------------------------- */ #define SWIGPYTHON #ifndef SWIG_TEMPLATE_DISAMBIGUATOR # if defined(__SUNPRO_CC) # define SWIG_TEMPLATE_DISAMBIGUATOR template # else # define SWIG_TEMPLATE_DISAMBIGUATOR # endif #endif #include <Python.h> /*********************************************************************** * common.swg * * This file contains generic SWIG runtime support for pointer * type checking as well as a few commonly used macros to control * external linkage. * * Author : David Beazley ([email protected]) * * Copyright (c) 1999-2000, The University of Chicago * * This file may be freely redistributed without license or fee provided * this copyright message remains intact. ************************************************************************/ #include <string.h> #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # if !defined(STATIC_LINKED) # define SWIGEXPORT(a) __declspec(dllexport) a # else # define SWIGEXPORT(a) a # endif #else # define SWIGEXPORT(a) a #endif #define SWIGRUNTIME(x) static x #ifndef SWIGINLINE #if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) # define SWIGINLINE inline #else # define SWIGINLINE #endif #endif /* This should only be incremented when either the layout of swig_type_info changes, or for whatever reason, the runtime changes incompatibly */ #define SWIG_RUNTIME_VERSION "1" /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE #define SWIG_QUOTE_STRING(x) #x #define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) #define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) #else #define SWIG_TYPE_TABLE_NAME #endif #ifdef __cplusplus extern "C" { #endif typedef void *(*swig_converter_func)(void *); typedef struct swig_type_info *(*swig_dycast_func)(void **); typedef struct swig_type_info { const char *name; swig_converter_func converter; const char *str; void *clientdata; swig_dycast_func dcast; struct swig_type_info *next; struct swig_type_info *prev; } swig_type_info; static swig_type_info *swig_type_list = 0; static swig_type_info **swig_type_list_handle = &swig_type_list; /* Compare two type names skipping the space characters, therefore "char*" == "char *" and "Class<int>" == "Class<int >", etc. Return 0 when the two name types are equivalent, as in strncmp, but skipping ' '. */ static int SWIG_TypeNameComp(const char *f1, const char *l1, const char *f2, const char *l2) { for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { while ((*f1 == ' ') && (f1 != l1)) ++f1; while ((*f2 == ' ') && (f2 != l2)) ++f2; if (*f1 != *f2) return *f1 - *f2; } return (l1 - f1) - (l2 - f2); } /* Check type equivalence in a name list like <name1>|<name2>|... */ static int SWIG_TypeEquiv(const char *nb, const char *tb) { int equiv = 0; const char* te = tb + strlen(tb); const char* ne = nb; while (!equiv && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } equiv = SWIG_TypeNameComp(nb, ne, tb, te) == 0; if (*ne) ++ne; } return equiv; } /* Register a type mapping with the type-checking */ static swig_type_info * SWIG_TypeRegister(swig_type_info *ti) { swig_type_info *tc, *head, *ret, *next; /* Check to see if this type has already been registered */ tc = *swig_type_list_handle; while (tc) { /* check simple type equivalence */ int typeequiv = (strcmp(tc->name, ti->name) == 0); /* check full type equivalence, resolving typedefs */ if (!typeequiv) { /* only if tc is not a typedef (no '|' on it) */ if (tc->str && ti->str && !strstr(tc->str,"|")) { typeequiv = SWIG_TypeEquiv(ti->str,tc->str); } } if (typeequiv) { /* Already exists in the table. Just add additional types to the list */ if (ti->clientdata) tc->clientdata = ti->clientdata; head = tc; next = tc->next; goto l1; } tc = tc->prev; } head = ti; next = 0; /* Place in list */ ti->prev = *swig_type_list_handle; *swig_type_list_handle = ti; /* Build linked lists */ l1: ret = head; tc = ti + 1; /* Patch up the rest of the links */ while (tc->name) { head->next = tc; tc->prev = head; head = tc; tc++; } if (next) next->prev = head; head->next = next; return ret; } /* Check the typename */ static swig_type_info * SWIG_TypeCheck(char *c, swig_type_info *ty) { swig_type_info *s; if (!ty) return 0; /* Void pointer */ s = ty->next; /* First element always just a name */ do { if (strcmp(s->name,c) == 0) { if (s == ty->next) return s; /* Move s to the top of the linked list */ s->prev->next = s->next; if (s->next) { s->next->prev = s->prev; } /* Insert s as second element in the list */ s->next = ty->next; if (ty->next) ty->next->prev = s; ty->next = s; s->prev = ty; return s; } s = s->next; } while (s && (s != ty->next)); return 0; } /* Cast a pointer up an inheritance hierarchy */ static SWIGINLINE void * SWIG_TypeCast(swig_type_info *ty, void *ptr) { if ((!ty) || (!ty->converter)) return ptr; return (*ty->converter)(ptr); } /* Dynamic pointer casting. Down an inheritance hierarchy */ static swig_type_info * SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { swig_type_info *lastty = ty; if (!ty || !ty->dcast) return ty; while (ty && (ty->dcast)) { ty = (*ty->dcast)(ptr); if (ty) lastty = ty; } return lastty; } /* Return the name associated with this type */ static SWIGINLINE const char * SWIG_TypeName(const swig_type_info *ty) { return ty->name; } /* Return the pretty name associated with this type, that is an unmangled type name in a form presentable to the user. */ static const char * SWIG_TypePrettyName(const swig_type_info *type) { /* The "str" field contains the equivalent pretty names of the type, separated by vertical-bar characters. We choose to print the last name, as it is often (?) the most specific. */ if (type->str != NULL) { const char *last_name = type->str; const char *s; for (s = type->str; *s; s++) if (*s == '|') last_name = s+1; return last_name; } else return type->name; } /* Search for a swig_type_info structure */ static swig_type_info * SWIG_TypeQuery(const char *name) { swig_type_info *ty = *swig_type_list_handle; while (ty) { if (ty->str && (SWIG_TypeEquiv(ty->str,name))) return ty; if (ty->name && (strcmp(name,ty->name) == 0)) return ty; ty = ty->prev; } return 0; } /* Set the clientdata field for a type */ static void SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { swig_type_info *tc, *equiv; if (ti->clientdata) return; /* if (ti->clientdata == clientdata) return; */ ti->clientdata = clientdata; equiv = ti->next; while (equiv) { if (!equiv->converter) { tc = *swig_type_list_handle; while (tc) { if ((strcmp(tc->name, equiv->name) == 0)) SWIG_TypeClientData(tc,clientdata); tc = tc->prev; } } equiv = equiv->next; } } /* Pack binary data into a string */ static char * SWIG_PackData(char *c, void *ptr, size_t sz) { static char hex[17] = "0123456789abcdef"; unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; register unsigned char uu; for (; u != eu; ++u) { uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } /* Unpack binary data from a string */ static char * SWIG_UnpackData(char *c, void *ptr, size_t sz) { register unsigned char uu = 0; register int d; unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { d = *(c++); if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); *u = uu; } return c; } /* This function will propagate the clientdata field of type to * any new swig_type_info structures that have been added into the list * of equivalent types. It is like calling * SWIG_TypeClientData(type, clientdata) a second time. */ static void SWIG_PropagateClientData(swig_type_info *type) { swig_type_info *equiv = type->next; swig_type_info *tc; if (!type->clientdata) return; while (equiv) { if (!equiv->converter) { tc = *swig_type_list_handle; while (tc) { if ((strcmp(tc->name, equiv->name) == 0) && !tc->clientdata) SWIG_TypeClientData(tc, type->clientdata); tc = tc->prev; } } equiv = equiv->next; } } #ifdef __cplusplus } #endif /* ----------------------------------------------------------------------------- * SWIG API. Portion that goes into the runtime * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif /* ----------------------------------------------------------------------------- * for internal method declarations * ----------------------------------------------------------------------------- */ #ifndef SWIGINTERN #define SWIGINTERN static #endif #ifndef SWIGINTERNSHORT #ifdef __cplusplus #define SWIGINTERNSHORT static inline #else /* C case */ #define SWIGINTERNSHORT static #endif /* __cplusplus */ #endif /* Common SWIG API */ #define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Python_ConvertPtr(obj, pp, type, flags) #define SWIG_NewPointerObj(p, type, flags) SWIG_Python_NewPointerObj(p, type, flags) #define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) /* Python-specific SWIG API */ #define SWIG_newvarlink() SWIG_Python_newvarlink() #define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) #define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags) #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) #define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) /* Exception handling in wrappers */ #define SWIG_fail goto fail #define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) #define SWIG_append_errmsg(msg) SWIG_Python_AddErrMesg(msg,0) #define SWIG_preppend_errmsg(msg) SWIG_Python_AddErrMesg(msg,1) #define SWIG_type_error(type,obj) SWIG_Python_TypeError(type,obj) #define SWIG_null_ref(type) SWIG_Python_NullRef(type) /* Contract support */ #define SWIG_contract_assert(expr, msg) \ if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg ); goto fail; } else /* ----------------------------------------------------------------------------- * Constant declarations * ----------------------------------------------------------------------------- */ /* Constant Types */ #define SWIG_PY_INT 1 #define SWIG_PY_FLOAT 2 #define SWIG_PY_STRING 3 #define SWIG_PY_POINTER 4 #define SWIG_PY_BINARY 5 /* Constant information structure */ typedef struct swig_const_info { int type; char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_const_info; /* ----------------------------------------------------------------------------- * Pointer declarations * ----------------------------------------------------------------------------- */ /* Use SWIG_NO_COBJECT_TYPES to force the use of strings to represent C/C++ pointers in the python side. Very useful for debugging, but not always safe. */ #if !defined(SWIG_NO_COBJECT_TYPES) && !defined(SWIG_COBJECT_TYPES) # define SWIG_COBJECT_TYPES #endif /* Flags for pointer conversion */ #define SWIG_POINTER_EXCEPTION 0x1 #define SWIG_POINTER_DISOWN 0x2 /* ----------------------------------------------------------------------------- * Alloc. memory flags * ----------------------------------------------------------------------------- */ #define SWIG_OLDOBJ 1 #define SWIG_NEWOBJ SWIG_OLDOBJ + 1 #define SWIG_PYSTR SWIG_NEWOBJ + 1 #ifdef __cplusplus } #endif /*********************************************************************** * pyrun.swg * * This file contains the runtime support for Python modules * and includes code for managing global variables and pointer * type checking. * * Author : David Beazley ([email protected]) ************************************************************************/ #ifdef __cplusplus extern "C" { #endif /* ----------------------------------------------------------------------------- * global variable support code. * ----------------------------------------------------------------------------- */ typedef struct swig_globalvar { char *name; /* Name of global variable */ PyObject *(*get_attr)(); /* Return the current value */ int (*set_attr)(PyObject *); /* Set the value */ struct swig_globalvar *next; } swig_globalvar; typedef struct swig_varlinkobject { PyObject_HEAD swig_globalvar *vars; } swig_varlinkobject; static PyObject * swig_varlink_repr(swig_varlinkobject *v) { v = v; return PyString_FromString("<Global variables>"); } static int swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) { swig_globalvar *var; flags = flags; fprintf(fp,"Global variables { "); for (var = v->vars; var; var=var->next) { fprintf(fp,"%s", var->name); if (var->next) fprintf(fp,", "); } fprintf(fp," }\n"); return 0; } static PyObject * swig_varlink_getattr(swig_varlinkobject *v, char *n) { swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { return (*var->get_attr)(); } var = var->next; } PyErr_SetString(PyExc_NameError,"Unknown C global variable"); return NULL; } static int swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { return (*var->set_attr)(p); } var = var->next; } PyErr_SetString(PyExc_NameError,"Unknown C global variable"); return 1; } static PyTypeObject varlinktype = { PyObject_HEAD_INIT(0) 0, /* Number of items in variable part (ob_size) */ (char *)"swigvarlink", /* Type name (tp_name) */ sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */ 0, /* Itemsize (tp_itemsize) */ 0, /* Deallocator (tp_dealloc) */ (printfunc) swig_varlink_print, /* Print (tp_print) */ (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */ (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */ 0, /* tp_compare */ (reprfunc) swig_varlink_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ 0, /* tp_flags */ 0, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #ifdef COUNT_ALLOCS /* these must be last */ 0, /* tp_alloc */ 0, /* tp_free */ 0, /* tp_maxalloc */ 0, /* tp_next */ #endif }; /* Create a variable linking object for use later */ static PyObject * SWIG_Python_newvarlink(void) { swig_varlinkobject *result = 0; result = PyMem_NEW(swig_varlinkobject,1); varlinktype.ob_type = &PyType_Type; /* Patch varlinktype into a PyType */ result->ob_type = &varlinktype; result->vars = 0; result->ob_refcnt = 0; Py_XINCREF((PyObject *) result); return ((PyObject*) result); } static void SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { swig_varlinkobject *v; swig_globalvar *gv; v= (swig_varlinkobject *) p; gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); gv->name = (char *) malloc(strlen(name)+1); strcpy(gv->name,name); gv->get_attr = get_attr; gv->set_attr = set_attr; gv->next = v->vars; v->vars = gv; } /* ----------------------------------------------------------------------------- * errors manipulation * ----------------------------------------------------------------------------- */ static void SWIG_Python_TypeError(const char *type, PyObject *obj) { if (type) { if (!PyCObject_Check(obj)) { const char *otype = (obj ? obj->ob_type->tp_name : 0); if (otype) { PyObject *str = PyObject_Str(obj); const char *cstr = str ? PyString_AsString(str) : 0; if (cstr) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", type, otype, cstr); } else { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", type, otype); } Py_DECREF(str); return; } } else { const char *otype = (char *) PyCObject_GetDesc(obj); if (otype) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PyCObject(%s)' is received", type, otype); return; } } PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); } else { PyErr_Format(PyExc_TypeError, "unexpected type is received"); } } static SWIGINLINE void SWIG_Python_NullRef(const char *type) { if (type) { PyErr_Format(PyExc_TypeError, "null reference of type '%s' was received",type); } else { PyErr_Format(PyExc_TypeError, "null reference was received"); } } static int SWIG_Python_AddErrMesg(const char* mesg, int infront) { if (PyErr_Occurred()) { PyObject *type = 0; PyObject *value = 0; PyObject *traceback = 0; PyErr_Fetch(&type, &value, &traceback); if (value) { PyObject *old_str = PyObject_Str(value); Py_XINCREF(type); PyErr_Clear(); if (infront) { PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); } else { PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); } Py_DECREF(old_str); } return 1; } else { return 0; } } static int SWIG_Python_ArgFail(int argnum) { if (PyErr_Occurred()) { /* add information about failing argument */ char mesg[256]; sprintf(mesg, "argument number %d:", argnum); return SWIG_Python_AddErrMesg(mesg, 1); } else { return 0; } } /* ----------------------------------------------------------------------------- * pointers/data manipulation * ----------------------------------------------------------------------------- */ /* Convert a pointer value */ static int SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) { swig_type_info *tc; char *c = 0; static PyObject *SWIG_this = 0; int newref = 0; PyObject *pyobj = 0; void *vptr; if (!obj) return 0; if (obj == Py_None) { *ptr = 0; return 0; } #ifdef SWIG_COBJECT_TYPES if (!(PyCObject_Check(obj))) { if (!SWIG_this) SWIG_this = PyString_FromString("this"); pyobj = obj; obj = PyObject_GetAttr(obj,SWIG_this); newref = 1; if (!obj) goto type_error; if (!PyCObject_Check(obj)) { Py_DECREF(obj); goto type_error; } } vptr = PyCObject_AsVoidPtr(obj); c = (char *) PyCObject_GetDesc(obj); if (newref) Py_DECREF(obj); goto type_check; #else if (!(PyString_Check(obj))) { if (!SWIG_this) SWIG_this = PyString_FromString("this"); pyobj = obj; obj = PyObject_GetAttr(obj,SWIG_this); newref = 1; if (!obj) goto type_error; if (!PyString_Check(obj)) { Py_DECREF(obj); goto type_error; } } c = PyString_AS_STRING(obj); /* Pointer values must start with leading underscore */ if (*c != '_') { if (strcmp(c,"NULL") == 0) { if (newref) { Py_DECREF(obj); } *ptr = (void *) 0; return 0; } else { if (newref) { Py_DECREF(obj); } goto type_error; } } c++; c = SWIG_UnpackData(c,&vptr,sizeof(void *)); if (newref) { Py_DECREF(obj); } #endif type_check: if (ty) { tc = SWIG_TypeCheck(c,ty); if (!tc) goto type_error; *ptr = SWIG_TypeCast(tc,vptr); } if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) { PyObject_SetAttrString(pyobj,(char*)"thisown",Py_False); } return 0; type_error: PyErr_Clear(); if (pyobj && !obj) { obj = pyobj; if (PyCFunction_Check(obj)) { /* here we get the method pointer for callbacks */ char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); c = doc ? strstr(doc, "swig_ptr: ") : 0; if (c) { c += 10; if (*c == '_') { c++; c = SWIG_UnpackData(c,&vptr,sizeof(void *)); goto type_check; } } } } if (flags & SWIG_POINTER_EXCEPTION) { if (ty) { SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); } else { SWIG_Python_TypeError("C/C++ pointer", obj); } } return -1; } /* Convert a pointer value, signal an exception on a type mismatch */ static void * SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { void *result; if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { PyErr_Clear(); if (flags & SWIG_POINTER_EXCEPTION) { SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); SWIG_Python_ArgFail(argnum); } } return result; } /* Convert a packed value value */ static int SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty, int flags) { swig_type_info *tc; char *c = 0; if ((!obj) || (!PyString_Check(obj))) goto type_error; c = PyString_AS_STRING(obj); /* Pointer values must start with leading underscore */ if (*c != '_') goto type_error; c++; c = SWIG_UnpackData(c,ptr,sz); if (ty) { tc = SWIG_TypeCheck(c,ty); if (!tc) goto type_error; } return 0; type_error: PyErr_Clear(); if (flags & SWIG_POINTER_EXCEPTION) { if (ty) { SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); } else { SWIG_Python_TypeError("C/C++ packed data", obj); } } return -1; } /* Create a new pointer string */ static char * SWIG_Python_PointerStr(char *buff, void *ptr, const char *name, size_t bsz) { char *r = buff; if ((2*sizeof(void *) + 2) > bsz) return 0; *(r++) = '_'; r = SWIG_PackData(r,&ptr,sizeof(void *)); if (strlen(name) + 1 > (bsz - (r - buff))) return 0; strcpy(r,name); return buff; } /* Create a new pointer object */ static PyObject * SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) { PyObject *robj; if (!ptr) { Py_INCREF(Py_None); return Py_None; } #ifdef SWIG_COBJECT_TYPES robj = PyCObject_FromVoidPtrAndDesc((void *) ptr, (char *) type->name, NULL); #else { char result[1024]; SWIG_Python_PointerStr(result, ptr, type->name, 1024); robj = PyString_FromString(result); } #endif if (!robj || (robj == Py_None)) return robj; if (type->clientdata) { PyObject *inst; PyObject *args = Py_BuildValue((char*)"(O)", robj); Py_DECREF(robj); inst = PyObject_CallObject((PyObject *) type->clientdata, args); Py_DECREF(args); if (inst) { if (own) { PyObject_SetAttrString(inst,(char*)"thisown",Py_True); } robj = inst; } } return robj; } static PyObject * SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { char result[1024]; char *r = result; if ((2*sz + 2 + strlen(type->name)) > 1024) return 0; *(r++) = '_'; r = SWIG_PackData(r,ptr,sz); strcpy(r,type->name); return PyString_FromString(result); } /* ----------------------------------------------------------------------------- * constants/methods manipulation * ----------------------------------------------------------------------------- */ /* Install Constants */ static void SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { int i; PyObject *obj; for (i = 0; constants[i].type; i++) { switch(constants[i].type) { case SWIG_PY_INT: obj = PyInt_FromLong(constants[i].lvalue); break; case SWIG_PY_FLOAT: obj = PyFloat_FromDouble(constants[i].dvalue); break; case SWIG_PY_STRING: if (constants[i].pvalue) { obj = PyString_FromString((char *) constants[i].pvalue); } else { Py_INCREF(Py_None); obj = Py_None; } break; case SWIG_PY_POINTER: obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); break; case SWIG_PY_BINARY: obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); break; default: obj = 0; break; } if (obj) { PyDict_SetItemString(d,constants[i].name,obj); Py_DECREF(obj); } } } /* Fix SwigMethods to carry the callback ptrs when needed */ static void SWIG_Python_FixMethods(PyMethodDef *methods, swig_const_info *const_table, swig_type_info **types, swig_type_info **types_initial) { int i; for (i = 0; methods[i].ml_name; ++i) { char *c = methods[i].ml_doc; if (c && (c = strstr(c, "swig_ptr: "))) { int j; swig_const_info *ci = 0; char *name = c + 10; for (j = 0; const_table[j].type; j++) { if (strncmp(const_table[j].name, name, strlen(const_table[j].name)) == 0) { ci = &(const_table[j]); break; } } if (ci) { size_t shift = (ci->ptype) - types; swig_type_info *ty = types_initial[shift]; size_t ldoc = (c - methods[i].ml_doc); size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; char *ndoc = (char*)malloc(ldoc + lptr + 10); char *buff = ndoc; void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue: (void *)(ci->lvalue); strncpy(buff, methods[i].ml_doc, ldoc); buff += ldoc; strncpy(buff, "swig_ptr: ", 10); buff += 10; SWIG_Python_PointerStr(buff, ptr, ty->name, lptr); methods[i].ml_doc = ndoc; } } } } /* ----------------------------------------------------------------------------- * Lookup type pointer * ----------------------------------------------------------------------------- */ #if PY_MAJOR_VERSION < 2 /* PyModule_AddObject function was introduced in Python 2.0. The following function is copied out of Python/modsupport.c in python version 2.3.4 */ static int PyModule_AddObject(PyObject *m, char *name, PyObject *o) { PyObject *dict; if (!PyModule_Check(m)) { PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg"); return -1; } if (!o) { PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value"); return -1; } dict = PyModule_GetDict(m); if (dict == NULL) { /* Internal error -- modules must have a dict! */ PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", PyModule_GetName(m)); return -1; } if (PyDict_SetItemString(dict, name, o)) return -1; Py_DECREF(o); return 0; } #endif static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} /* Sentinel */ }; static void SWIG_Python_LookupTypePointer(swig_type_info ***type_list_handle) { PyObject *module, *pointer; void *type_pointer; /* first check if module already created */ type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); if (type_pointer) { *type_list_handle = (swig_type_info **) type_pointer; } else { PyErr_Clear(); /* create a new module and variable */ module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); pointer = PyCObject_FromVoidPtr((void *) (*type_list_handle), NULL); if (pointer && module) { PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); } } } #ifdef __cplusplus } #endif /* -------- TYPES TABLE (BEGIN) -------- */ #define SWIGTYPE_p_GLsizei swig_types[0] #define SWIGTYPE_p_GLshort swig_types[1] #define SWIGTYPE_p_GLboolean swig_types[2] #define SWIGTYPE_size_t swig_types[3] #define SWIGTYPE_p_GLushort swig_types[4] #define SWIGTYPE_p_GLenum swig_types[5] #define SWIGTYPE_p_GLvoid swig_types[6] #define SWIGTYPE_p_GLint swig_types[7] #define SWIGTYPE_p_char swig_types[8] #define SWIGTYPE_p_GLclampd swig_types[9] #define SWIGTYPE_p_GLclampf swig_types[10] #define SWIGTYPE_p_GLuint swig_types[11] #define SWIGTYPE_ptrdiff_t swig_types[12] #define SWIGTYPE_p_GLbyte swig_types[13] #define SWIGTYPE_p_GLbitfield swig_types[14] #define SWIGTYPE_p_GLfloat swig_types[15] #define SWIGTYPE_p_GLubyte swig_types[16] #define SWIGTYPE_p_GLdouble swig_types[17] static swig_type_info *swig_types[19]; /* -------- TYPES TABLE (END) -------- */ /*----------------------------------------------- @(target):= _cull_vertex.so ------------------------------------------------*/ #define SWIG_init init_cull_vertex #define SWIG_name "_cull_vertex" SWIGINTERN PyObject * SWIG_FromCharPtr(const char* cptr) { if (cptr) { size_t size = strlen(cptr); if (size > INT_MAX) { return SWIG_NewPointerObj((char*)(cptr), SWIG_TypeQuery("char *"), 0); } else { if (size != 0) { return PyString_FromStringAndSize(cptr, size); } else { return PyString_FromString(cptr); } } } Py_INCREF(Py_None); return Py_None; } /*@C:\\bin\\SWIG-1.3.23\\Lib\\python\\pymacros.swg,66,SWIG_define@*/ #define SWIG_From_int PyInt_FromLong /*@@*/ /** * * GL.EXT.cull_vertex Module for PyOpenGL * * Date: May 2001 * * Authors: Tarn Weisner Burton <[email protected]> * ***/ GLint PyOpenGL_round(double x) { if (x >= 0) { return (GLint) (x+0.5); } else { return (GLint) (x-0.5); } } int __PyObject_AsArray_Size(PyObject* x); #ifdef NUMERIC #define _PyObject_AsArray_Size(x) ((x == Py_None) ? 0 : ((PyArray_Check(x)) ? PyArray_Size(x) : __PyObject_AsArray_Size(x))) #else /* NUMERIC */ #define _PyObject_AsArray_Size(x) ((x == Py_None) ? 0 : __PyObject_AsArray_Size(x)) #endif /* NUMERIC */ #define _PyObject_As(NAME, BASE) BASE* _PyObject_As##NAME(PyObject* source, PyObject** temp, int* len); #define _PyObject_AsArray_Cleanup(target, temp) if (temp) Py_XDECREF(temp); else PyMem_Del(target) _PyObject_As(FloatArray, float) _PyObject_As(DoubleArray, double) _PyObject_As(CharArray, signed char) _PyObject_As(UnsignedCharArray, unsigned char) _PyObject_As(ShortArray, short) _PyObject_As(UnsignedShortArray, unsigned short) _PyObject_As(IntArray, int) _PyObject_As(UnsignedIntArray, unsigned int) void* _PyObject_AsArray(GLenum type, PyObject* source, PyObject** temp, int* len); #define PyErr_XPrint() if (PyErr_Occurred()) PyErr_Print() #if HAS_DYNAMIC_EXT #define DECLARE_EXT(PROC_NAME, RET, ERROR_RET, PROTO, CALL)\ RET PROC_NAME PROTO\ {\ typedef RET (APIENTRY *proc_##PROC_NAME) PROTO;\ proc_##PROC_NAME proc = (proc_##PROC_NAME)GL_GetProcAddress(#PROC_NAME);\ if (proc) return proc CALL;\ PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\ return ERROR_RET;\ } #define DECLARE_VOID_EXT(PROC_NAME, PROTO, CALL)\ void PROC_NAME PROTO\ {\ typedef void (APIENTRY *proc_##PROC_NAME) PROTO;\ proc_##PROC_NAME proc = (proc_##PROC_NAME)GL_GetProcAddress(#PROC_NAME);\ if (proc) proc CALL;\ else {\ PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\ }\ } #else #define DECLARE_EXT(PROC_NAME, RET, ERROR_RET, PROTO, CALL)\ RET PROC_NAME PROTO\ {\ PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\ return ERROR_RET;\ } #define DECLARE_VOID_EXT(PROC_NAME, PROTO, CALL)\ void PROC_NAME PROTO\ {\ PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\ } #endif #define _PyTuple_From(NAME, BASE) PyObject* _PyTuple_From##NAME(int len, BASE* data); _PyTuple_From(UnsignedCharArray, unsigned char) _PyTuple_From(CharArray, signed char) _PyTuple_From(UnsignedShortArray, unsigned short) _PyTuple_From(ShortArray, short) _PyTuple_From(UnsignedIntArray, unsigned int) _PyTuple_From(IntArray, int) _PyTuple_From(FloatArray, float) _PyTuple_From(DoubleArray, double) #define _PyObject_From(NAME, BASE) PyObject* _PyObject_From##NAME(int nd, int* dims, BASE* data, int own); _PyObject_From(UnsignedCharArray, unsigned char) _PyObject_From(CharArray, signed char) _PyObject_From(UnsignedShortArray, unsigned short) _PyObject_From(ShortArray, short) _PyObject_From(UnsignedIntArray, unsigned int) _PyObject_From(IntArray, int) _PyObject_From(FloatArray, float) _PyObject_From(DoubleArray, double) PyObject* _PyObject_FromArray(GLenum type, int nd, int *dims, void* data, int own); void* SetupPixelRead(int rank, GLenum format, GLenum type, int *dims); void SetupPixelWrite(int rank); void* SetupRawPixelRead(GLenum format, GLenum type, int n, const int *dims, int* size); void* _PyObject_AsPointer(PyObject* x); /* The following line causes a warning on linux and cygwin The function is defined in interface_utils.c, which is linked to each extension module. For some reason, though, this declaration doesn't get recognised as a declaration prototype for that function. */ void init_util(); typedef void *PTR; typedef struct { void (*_decrement)(void* pointer); void (*_decrementPointer)(GLenum pname); int (*_incrementLock)(void *pointer); int (*_incrementPointerLock)(GLenum pname); void (*_acquire)(void* pointer); void (*_acquirePointer)(GLenum pname); #if HAS_DYNAMIC_EXT PTR (*GL_GetProcAddress)(const char* name); #endif int (*InitExtension)(const char *name, const char** procs); PyObject *_GLerror; PyObject *_GLUerror; } util_API; static util_API *_util_API = NULL; #define decrementLock(x) (*_util_API)._decrement(x) #define decrementPointerLock(x) (*_util_API)._decrementPointer(x) #define incrementLock(x) (*_util_API)._incrementLock(x) #define incrementPointerLock(x) (*_util_API)._incrementPointerLock(x) #define acquire(x) (*_util_API)._acquire(x) #define acquirePointer(x) (*_util_API)._acquirePointer(x) #define GLerror (*_util_API)._GLerror #define GLUerror (*_util_API)._GLUerror #if HAS_DYNAMIC_EXT #define GL_GetProcAddress(x) (*_util_API).GL_GetProcAddress(x) #endif #define InitExtension(x, y) (*_util_API).InitExtension(x, (const char**)y) #define PyErr_SetGLerror(code) PyErr_SetObject(GLerror, Py_BuildValue("is", code, gluErrorString(code))); #define PyErr_SetGLUerror(code) PyErr_SetObject(GLUerror, Py_BuildValue("is", code, gluErrorString(code))); int _PyObject_Dimension(PyObject* x, int rank); #define ERROR_MSG_SEP ", " #define ERROR_MSG_SEP_LEN 2 int GLErrOccurred() { if (PyErr_Occurred()) return 1; if (CurrentContextIsValid()) { GLenum error, *errors = NULL; char *msg = NULL; const char *this_msg; int count = 0; error = glGetError(); while (error != GL_NO_ERROR) { this_msg = gluErrorString(error); if (count) { msg = realloc(msg, (strlen(msg) + strlen(this_msg) + ERROR_MSG_SEP_LEN + 1)*sizeof(char)); strcat(msg, ERROR_MSG_SEP); strcat(msg, this_msg); errors = realloc(errors, (count + 1)*sizeof(GLenum)); } else { msg = malloc((strlen(this_msg) + 1)*sizeof(char)); strcpy(msg, this_msg); errors = malloc(sizeof(GLenum)); } errors[count++] = error; error = glGetError(); } if (count) { PyErr_SetObject(GLerror, Py_BuildValue("Os", _PyTuple_FromIntArray(count, (int*)errors), msg)); free(errors); free(msg); return 1; } } return 0; } void PyErr_SetGLErrorMessage( int id, char * message ) { /* set a GLerror with an ID and string message This tries pretty hard to look just like a regular error as produced by GLErrOccurred()'s formatter, save that there's only the single error being reported. Using id 0 is probably best for any future use where there isn't a good match for the exception description in the error-enumeration set. */ PyObject * args = NULL; args = Py_BuildValue( "(i)s", id, message ); if (args) { PyErr_SetObject( GLerror, args ); Py_XDECREF( args ); } else { PyErr_SetGLerror(id); } } #if !EXT_DEFINES_PROTO || !defined(GL_EXT_cull_vertex) DECLARE_VOID_EXT(glCullParameterfvEXT, (GLenum pname, GLfloat *params), (pname, params)) DECLARE_VOID_EXT(glCullParameterdvEXT, (GLenum pname, GLdouble *params), (pname, params)) #endif #define _glCullParameterfvEXT(pname, params) glCullParameterfvEXT(pname, (GLfloat*)params) #include <limits.h> SWIGINTERNSHORT int SWIG_CheckUnsignedLongInRange(unsigned long value, unsigned long max_value, const char *errmsg) { if (value > max_value) { if (errmsg) { PyErr_Format(PyExc_OverflowError, "value %lu is greater than '%s' minimum %lu", value, errmsg, max_value); } return 0; } return 1; } SWIGINTERN int SWIG_AsVal_unsigned_SS_long(PyObject *obj, unsigned long *val) { if (PyInt_Check(obj)) { long v = PyInt_AS_LONG(obj); if (v >= 0) { if (val) *val = v; return 1; } } if (PyLong_Check(obj)) { unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return 1; } else { if (!val) PyErr_Clear(); return 0; } } if (val) { SWIG_type_error("unsigned long", obj); } return 0; } #if UINT_MAX != ULONG_MAX SWIGINTERN int SWIG_AsVal_unsigned_SS_int(PyObject *obj, unsigned int *val) { const char* errmsg = val ? "unsigned int" : (char*)0; unsigned long v; if (SWIG_AsVal_unsigned_SS_long(obj, &v)) { if (SWIG_CheckUnsignedLongInRange(v, INT_MAX, errmsg)) { if (val) *val = (unsigned int)(v); return 1; } } else { PyErr_Clear(); } if (val) { SWIG_type_error(errmsg, obj); } return 0; } #else SWIGINTERNSHORT unsigned int SWIG_AsVal_unsigned_SS_int(PyObject *obj, unsigned int *val) { return SWIG_AsVal_unsigned_SS_long(obj,(unsigned long *)val); } #endif SWIGINTERNSHORT unsigned int SWIG_As_unsigned_SS_int(PyObject* obj) { unsigned int v; if (!SWIG_AsVal_unsigned_SS_int(obj, &v)) { /* this is needed to make valgrind/purify happier. */ memset((void*)&v, 0, sizeof(unsigned int)); } return v; } SWIGINTERNSHORT int SWIG_Check_unsigned_SS_int(PyObject* obj) { return SWIG_AsVal_unsigned_SS_int(obj, (unsigned int*)0); } static char _doc_glCullParameterfvEXT[] = "glCullParameterfvEXT(pname, params) -> None"; #define _glCullParameterdvEXT(pname, params) glCullParameterdvEXT(pname, (GLdouble*)params) static char _doc_glCullParameterdvEXT[] = "glCullParameterdvEXT(pname, params) -> None"; static char *proc_names[] = { #if !EXT_DEFINES_PROTO || !defined(GL_EXT_cull_vertex) "glCullParameterfvEXT", "glCullParameterdvEXT", #endif NULL }; #define glInitCullVertexEXT() InitExtension("GL_EXT_cull_vertex", proc_names) static char _doc_glInitCullVertexEXT[] = "glInitCullVertexEXT() -> bool"; PyObject *__info() { if (glInitCullVertexEXT()) { PyObject *info = PyList_New(0); return info; } Py_INCREF(Py_None); return Py_None; } #ifdef __cplusplus extern "C" { #endif static PyObject *_wrap_glCullParameterfvEXT(PyObject *self, PyObject *args) { PyObject *resultobj; GLenum arg1 ; GLfloat *arg2 = (GLfloat *) 0 ; PyObject *temp_2 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if(!PyArg_ParseTuple(args,(char *)"OO:glCullParameterfvEXT",&obj0,&obj1)) goto fail; { arg1 = (GLenum)(SWIG_As_unsigned_SS_int(obj0)); if (SWIG_arg_fail(1)) SWIG_fail; } { arg2 = _PyObject_AsFloatArray(obj1, &temp_2, NULL); } { _glCullParameterfvEXT(arg1,(GLfloat const *)arg2); if (GLErrOccurred()) { return NULL; } } Py_INCREF(Py_None); resultobj = Py_None; { _PyObject_AsArray_Cleanup(arg2, temp_2); } return resultobj; fail: { _PyObject_AsArray_Cleanup(arg2, temp_2); } return NULL; } static PyObject *_wrap_glCullParameterdvEXT(PyObject *self, PyObject *args) { PyObject *resultobj; GLenum arg1 ; GLdouble *arg2 = (GLdouble *) 0 ; PyObject *temp_2 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; if(!PyArg_ParseTuple(args,(char *)"OO:glCullParameterdvEXT",&obj0,&obj1)) goto fail; { arg1 = (GLenum)(SWIG_As_unsigned_SS_int(obj0)); if (SWIG_arg_fail(1)) SWIG_fail; } { arg2 = _PyObject_AsDoubleArray(obj1, &temp_2, NULL); } { _glCullParameterdvEXT(arg1,(GLdouble const *)arg2); if (GLErrOccurred()) { return NULL; } } Py_INCREF(Py_None); resultobj = Py_None; { _PyObject_AsArray_Cleanup(arg2, temp_2); } return resultobj; fail: { _PyObject_AsArray_Cleanup(arg2, temp_2); } return NULL; } static PyObject *_wrap_glInitCullVertexEXT(PyObject *self, PyObject *args) { PyObject *resultobj; int result; if(!PyArg_ParseTuple(args,(char *)":glInitCullVertexEXT")) goto fail; { result = (int)glInitCullVertexEXT(); if (GLErrOccurred()) { return NULL; } } { resultobj = SWIG_From_int((int)(result)); } return resultobj; fail: return NULL; } static PyObject *_wrap___info(PyObject *self, PyObject *args) { PyObject *resultobj; PyObject *result; if(!PyArg_ParseTuple(args,(char *)":__info")) goto fail; { result = (PyObject *)__info(); if (GLErrOccurred()) { return NULL; } } { resultobj= result; } return resultobj; fail: return NULL; } static PyMethodDef SwigMethods[] = { { (char *)"glCullParameterfvEXT", _wrap_glCullParameterfvEXT, METH_VARARGS, NULL}, { (char *)"glCullParameterdvEXT", _wrap_glCullParameterdvEXT, METH_VARARGS, NULL}, { (char *)"glInitCullVertexEXT", _wrap_glInitCullVertexEXT, METH_VARARGS, NULL}, { (char *)"__info", _wrap___info, METH_VARARGS, NULL}, { NULL, NULL, 0, NULL } }; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ static swig_type_info _swigt__p_GLsizei[] = {{"_p_GLsizei", 0, "int *|GLsizei *", 0, 0, 0, 0},{"_p_GLint", 0, 0, 0, 0, 0, 0},{"_p_GLsizei", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLshort[] = {{"_p_GLshort", 0, "short *|GLshort *", 0, 0, 0, 0},{"_p_GLshort", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLboolean[] = {{"_p_GLboolean", 0, "unsigned char *|GLboolean *", 0, 0, 0, 0},{"_p_GLboolean", 0, 0, 0, 0, 0, 0},{"_p_GLubyte", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__size_t[] = {{"_size_t", 0, "size_t", 0, 0, 0, 0},{"_size_t", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLushort[] = {{"_p_GLushort", 0, "unsigned short *|GLushort *", 0, 0, 0, 0},{"_p_GLushort", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLenum[] = {{"_p_GLenum", 0, "unsigned int *|GLenum *", 0, 0, 0, 0},{"_p_GLuint", 0, 0, 0, 0, 0, 0},{"_p_GLenum", 0, 0, 0, 0, 0, 0},{"_p_GLbitfield", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLvoid[] = {{"_p_GLvoid", 0, "void *|GLvoid *", 0, 0, 0, 0},{"_p_GLvoid", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLint[] = {{"_p_GLint", 0, "int *|GLint *", 0, 0, 0, 0},{"_p_GLint", 0, 0, 0, 0, 0, 0},{"_p_GLsizei", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_char[] = {{"_p_char", 0, "char *", 0, 0, 0, 0},{"_p_char", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLclampd[] = {{"_p_GLclampd", 0, "double *|GLclampd *", 0, 0, 0, 0},{"_p_GLclampd", 0, 0, 0, 0, 0, 0},{"_p_GLdouble", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLclampf[] = {{"_p_GLclampf", 0, "float *|GLclampf *", 0, 0, 0, 0},{"_p_GLfloat", 0, 0, 0, 0, 0, 0},{"_p_GLclampf", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLuint[] = {{"_p_GLuint", 0, "unsigned int *|GLuint *", 0, 0, 0, 0},{"_p_GLuint", 0, 0, 0, 0, 0, 0},{"_p_GLenum", 0, 0, 0, 0, 0, 0},{"_p_GLbitfield", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__ptrdiff_t[] = {{"_ptrdiff_t", 0, "ptrdiff_t", 0, 0, 0, 0},{"_ptrdiff_t", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLbyte[] = {{"_p_GLbyte", 0, "signed char *|GLbyte *", 0, 0, 0, 0},{"_p_GLbyte", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLbitfield[] = {{"_p_GLbitfield", 0, "unsigned int *|GLbitfield *", 0, 0, 0, 0},{"_p_GLuint", 0, 0, 0, 0, 0, 0},{"_p_GLbitfield", 0, 0, 0, 0, 0, 0},{"_p_GLenum", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLfloat[] = {{"_p_GLfloat", 0, "float *|GLfloat *", 0, 0, 0, 0},{"_p_GLfloat", 0, 0, 0, 0, 0, 0},{"_p_GLclampf", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLubyte[] = {{"_p_GLubyte", 0, "unsigned char *|GLubyte *", 0, 0, 0, 0},{"_p_GLboolean", 0, 0, 0, 0, 0, 0},{"_p_GLubyte", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLdouble[] = {{"_p_GLdouble", 0, "double *|GLdouble *", 0, 0, 0, 0},{"_p_GLclampd", 0, 0, 0, 0, 0, 0},{"_p_GLdouble", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info *swig_types_initial[] = { _swigt__p_GLsizei, _swigt__p_GLshort, _swigt__p_GLboolean, _swigt__size_t, _swigt__p_GLushort, _swigt__p_GLenum, _swigt__p_GLvoid, _swigt__p_GLint, _swigt__p_char, _swigt__p_GLclampd, _swigt__p_GLclampf, _swigt__p_GLuint, _swigt__ptrdiff_t, _swigt__p_GLbyte, _swigt__p_GLbitfield, _swigt__p_GLfloat, _swigt__p_GLubyte, _swigt__p_GLdouble, 0 }; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ static swig_const_info swig_const_table[] = { { SWIG_PY_POINTER, (char*)"__version__", 0, 0, (void *)"1.24.6.1", &SWIGTYPE_p_char}, { SWIG_PY_POINTER, (char*)"__date__", 0, 0, (void *)"2004/11/14 23:19:04", &SWIGTYPE_p_char}, { SWIG_PY_POINTER, (char*)"__author__", 0, 0, (void *)"Tarn Weisner Burton <[email protected]>", &SWIGTYPE_p_char}, { SWIG_PY_POINTER, (char*)"__doc__", 0, 0, (void *)"http://oss.sgi.com/projects/ogl-sample/registry/EXT/cull_vertex.txt", &SWIGTYPE_p_char}, {0, 0, 0, 0.0, 0, 0}}; #ifdef __cplusplus } #endif #ifdef SWIG_LINK_RUNTIME #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # if defined(_MSC_VER) || defined(__GNUC__) # define SWIGIMPORT(a) extern a # else # if defined(__BORLANDC__) # define SWIGIMPORT(a) a _export # else # define SWIGIMPORT(a) a # endif # endif #else # define SWIGIMPORT(a) a #endif #ifdef __cplusplus extern "C" #endif SWIGEXPORT(void *) SWIG_ReturnGlobalTypeList(void *); #endif #ifdef __cplusplus extern "C" #endif SWIGEXPORT(void) SWIG_init(void) { static PyObject *SWIG_globals = 0; static int typeinit = 0; PyObject *m, *d; int i; if (!SWIG_globals) SWIG_globals = SWIG_newvarlink(); /* Fix SwigMethods to carry the callback ptrs when needed */ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_types_initial); m = Py_InitModule((char *) SWIG_name, SwigMethods); d = PyModule_GetDict(m); if (!typeinit) { #ifdef SWIG_LINK_RUNTIME swig_type_list_handle = (swig_type_info **) SWIG_ReturnGlobalTypeList(swig_type_list_handle); #else # ifndef SWIG_STATIC_RUNTIME SWIG_Python_LookupTypePointer(&swig_type_list_handle); # endif #endif for (i = 0; swig_types_initial[i]; i++) { swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]); } typeinit = 1; } SWIG_InstallConstants(d,swig_const_table); PyDict_SetItemString(d,"__version__", SWIG_FromCharPtr("1.24.6.1")); PyDict_SetItemString(d,"__date__", SWIG_FromCharPtr("2004/11/14 23:19:04")); { PyDict_SetItemString(d,"__api_version__", SWIG_From_int((int)(259))); } PyDict_SetItemString(d,"__author__", SWIG_FromCharPtr("Tarn Weisner Burton <[email protected]>")); PyDict_SetItemString(d,"__doc__", SWIG_FromCharPtr("http://oss.sgi.com/projects/ogl-sample/registry/EXT/cull_vertex.txt")); #ifdef NUMERIC PyArray_API = NULL; import_array(); init_util(); PyErr_Clear(); #endif { PyObject *util = PyImport_ImportModule("OpenGL.GL._GL__init__"); if (util) { PyObject *api_object = PyDict_GetItemString(PyModule_GetDict(util), "_util_API"); if (PyCObject_Check(api_object)) _util_API = (util_API*)PyCObject_AsVoidPtr(api_object); } } { PyDict_SetItemString(d,"GL_CULL_VERTEX_EXT", SWIG_From_int((int)(0x81AA))); } { PyDict_SetItemString(d,"GL_CULL_VERTEX_EYE_POSITION_EXT", SWIG_From_int((int)(0x81AB))); } { PyDict_SetItemString(d,"GL_CULL_VERTEX_OBJECT_POSITION_EXT", SWIG_From_int((int)(0x81AC))); } }
[ "ronaldoussoren@f55f28a5-9edb-0310-a011-a803cfcd5d25" ]
[ [ [ 1, 1799 ] ] ]
e8ffdc996e7dc84b5fda0382047f9caf79ba8434
fd3f2268460656e395652b11ae1a5b358bfe0a59
/srchybrid/UPnP_IGDControlPoint.cpp
ca57ae5550c13c05d230d99e1f96a7a7e46f68da
[]
no_license
mikezhoubill/emule-gifc
e1cc6ff8b1bb63197bcfc7e67c57cfce0538ff60
46979cf32a313ad6d58603b275ec0b2150562166
refs/heads/master
2021-01-10T20:37:07.581465
2011-08-13T13:58:37
2011-08-13T13:58:37
32,465,033
4
2
null
null
null
null
ISO-8859-10
C++
false
false
54,117
cpp
//this file is part of eMule //Copyright (C)2002 Merkur ( [email protected] / http://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License //as published by the Free Software Foundation; either //version 2 of the License, or (at your option) any later version. // //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. // //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // // ---------------------------------------------------------------------- // // emulEspaņa. Added by MoNKi [MoNKi: -UPnPNAT Support-] #include "StdAfx.h" #include "emule.h" #include "preferences.h" #include "FirewallOpener.h" #include "otherfunctions.h" #include "upnp_igdcontrolpoint.h" #include "upnplib\upnp\inc\upnptools.h" #include "Log.h" #include "emuleDlg.h" // for WEBGUIIA_UPDATEMYINFO #include "UserMsgs.h" // for webguiintercation #include "resource.h" // for myinfo text #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif //Static Variables CUPnP_IGDControlPoint* CUPnP_IGDControlPoint::m_IGDControlPoint; UpnpClient_Handle CUPnP_IGDControlPoint::m_ctrlPoint; bool CUPnP_IGDControlPoint::m_bInit; CUPnP_IGDControlPoint::DEVICE_LIST CUPnP_IGDControlPoint::m_devices; CUPnP_IGDControlPoint::SERVICE_LIST CUPnP_IGDControlPoint::m_knownServices; CCriticalSection CUPnP_IGDControlPoint::m_devListLock; CUPnP_IGDControlPoint::MAPPING_LIST CUPnP_IGDControlPoint::m_Mappings; CCriticalSection CUPnP_IGDControlPoint::m_MappingsLock; CCriticalSection CUPnP_IGDControlPoint::m_ActionThreadCS; bool CUPnP_IGDControlPoint::m_bStopAtFirstService; bool CUPnP_IGDControlPoint::m_bClearOnClose; CEvent * CUPnP_IGDControlPoint::InitializingEvent; CString CUPnP_IGDControlPoint::StatusString; CUPnP_IGDControlPoint::CUPnP_IGDControlPoint(void) { // Initialize variables m_IGDControlPoint = NULL; m_ctrlPoint = 0; m_bInit = false; m_bStopAtFirstService = false; m_bClearOnClose = false; UpnpAcceptsPorts = true; InitializingEvent = NULL; } CUPnP_IGDControlPoint::~CUPnP_IGDControlPoint(void) { if(m_bClearOnClose) DeleteAllPortMappings(); //Unregister control point and finish UPnP if(m_ctrlPoint){ UpnpUnRegisterClient(m_ctrlPoint); UpnpFinish(); } if (InitializingEvent) { InitializingEvent->SetEvent(); delete InitializingEvent; InitializingEvent=NULL;} //Remove devices/services //Lock devices and mappings before use it m_devListLock.Lock(); m_MappingsLock.Lock(); POSITION pos = m_devices.GetHeadPosition(); while(pos){ UPNP_DEVICE *item; item = m_devices.GetNext(pos); if(item) RemoveDevice(item); } m_devices.RemoveAll(); m_knownServices.RemoveAll(); //Remove mappings m_Mappings.RemoveAll(); //Unlock devices and mappings m_MappingsLock.Unlock(); m_devListLock.Unlock(); } // Eanble or disbale upnp. Note that this is indepednge of accepting ports to map. bool CUPnP_IGDControlPoint::SetUPnPNat(bool upnpNat) { if (upnpNat==true && thePrefs.IsUPnPEnabled()==false ) { thePrefs.m_bUPnPNat=true; Init(thePrefs.GetUPnPLimitToFirstConnection()); UpdateAllMappings(true,false); // send any queued mappings to device. if (theApp.emuledlg->GetSafeHwnd()!= NULL) // display status window: PostMessage(theApp.emuledlg->GetSafeHwnd(),WEB_GUI_INTERACTION,WEBGUIIA_UPDATEMYINFO,0); // update myinfo if device detected. (from different thread!) } else if (upnpNat==false && thePrefs.IsUPnPEnabled()==true ){ DeleteAllPortMappingsOnClose(); // idependand of setting thePrefs.GetUPnPClearOnClose // Note that devices are not removed. thePrefs.m_bUPnPNat=false; if (theApp.emuledlg->GetSafeHwnd()!= NULL) // display status window: PostMessage(theApp.emuledlg->GetSafeHwnd(),WEB_GUI_INTERACTION,WEBGUIIA_UPDATEMYINFO,0); // update myinfo if device detected. (from different thread!) } return thePrefs.m_bUPnPNat; } // Initialize all UPnP thing bool CUPnP_IGDControlPoint::Init(bool bStopAtFirstConnFound){ if(m_bInit) return true; // Init UPnP int rc; //MORPH START leuk_he upnp bindaddr StatusString=L"Starting"; LPCSTR HostIp=NULL; if ( (thePrefs.GetBindAddrA()!=NULL) && IsLANIP((char *) thePrefs.GetBindAddrA()) ) HostIp=thePrefs.GetBindAddrA(); else if ( thePrefs.GetUpnpBindAddr()!= 0 ) HostIp=_strdup(ipstrA(htonl(thePrefs.GetUpnpBindAddr()))); //Fafner: avoid C4996 (as in 0.49b vanilla) - 080731 if ((HostIp!= NULL) && (inet_addr(HostIp)==INADDR_NONE)) HostIp=NULL; // prevent failing if in prev version there was no valid interface. rc = UpnpInit( HostIp, thePrefs.GetUPnPPort() ); /* rc = UpnpInit( NULL, thePrefs.GetUPnPPort() ); */ // MORPH END leuk_he upnp bindaddr if (UPNP_E_SUCCESS != rc) { AddLogLine(false, GetResString(IDS_UPNP_FAILEDINIT), thePrefs.GetUPnPPort(), GetErrDescription(rc) ); StatusString.Format(GetResString(IDS_UPNP_FAILEDINIT), thePrefs.GetUPnPPort(), GetErrDescription(rc) ); UpnpFinish(); thePrefs.SetUpnpDetect(UPNP_NOT_DETECTED);//leuk_he autodetect upnp in wizard return false; } // Check if you are in a LAN or directly connected to Internet if(!IsLANIP(UpnpGetServerIpAddress())){ AddLogLine(false, GetResString(IDS_UPNP_PUBLICIP)); StatusString=GetResString(IDS_UPNP_PUBLICIP); UpnpFinish(); thePrefs.SetUpnpDetect(UPNP_NOT_NEEDED) ;//leuk_he autodetect upnp in wizard UpnpAcceptsPorts=false; return false; } // Register us as a Control Point rc = UpnpRegisterClient( (Upnp_FunPtr)IGD_Callback, &m_ctrlPoint, &m_ctrlPoint ); if (UPNP_E_SUCCESS != rc) { AddLogLine(false, GetResString(IDS_UPNP_FAILEDREGISTER), GetErrDescription(rc) ); StatusString.Format(GetResString(IDS_UPNP_FAILEDREGISTER), GetErrDescription(rc)); UpnpFinish(); thePrefs.SetUpnpDetect(UPNP_NOT_DETECTED);//leuk_he autodetect upnp in wizard return false; } InitializingEvent = new CEvent(True,True); //Wait for upnp init completion to preven false low //Starts timer thread AfxBeginThread(TimerThreadFunc, this); //Open UPnP Server Port on Windows Firewall if(thePrefs.IsOpenPortsOnStartupEnabled()){ if (theApp.m_pFirewallOpener->OpenPort(UpnpGetServerPort(), NAT_PROTOCOL_UDP, EMULE_DEFAULTRULENAME_UPNP_UDP, true)) if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, GetResString(IDS_FO_TEMPUDP_S), UpnpGetServerPort()); else if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, GetResString(IDS_FO_TEMPUDP_F), UpnpGetServerPort()); if (theApp.m_pFirewallOpener->OpenPort(UpnpGetServerPort(), NAT_PROTOCOL_TCP, EMULE_DEFAULTRULENAME_UPNP_TCP, true)) if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, GetResString(IDS_FO_TEMPTCP_S), UpnpGetServerPort()); else if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, GetResString(IDS_FO_TEMPTCP_F), UpnpGetServerPort()); } m_bInit = true; AddLogLine(false, GetResString(IDS_UPNP_INIT), GetLocalIPStr(), UpnpGetServerPort()); m_bStopAtFirstService = bStopAtFirstConnFound; // Search Devices // Some routers only reply to one of this SSDP searchs: UpnpSearchAsync(m_ctrlPoint, 5, "upnp:rootdevice", &m_ctrlPoint); UpnpSearchAsync(m_ctrlPoint, 5, "urn:schemas-upnp-org:device:InternetGatewayDevice:1", &m_ctrlPoint); return m_bInit; } // Give upnp a little bit of time to startup before doing outbound connections // giving a unintend lowid: // return nonzero if succesful. int CUPnP_IGDControlPoint::PauseForUpnpCompletion() { if(!m_bInit) return 0; if(thePrefs.GetUPnPVerboseLog()) AddDebugLogLine(false, _T("Waiting short for upnp to complete registration.") ); if (InitializingEvent) return (InitializingEvent->Lock((MINIMUM_DELAY*1000)+1)==S_OK) ; // 10 secs... (should be UPNPTIMEOUT, btu 40 seconds is too long....) return 0; } // Returns the port used by UPnP unsigned int CUPnP_IGDControlPoint::GetPort(){ if(!m_bInit) return 0; return UpnpGetServerPort( ); } // Handles all UPnP Events int CUPnP_IGDControlPoint::IGD_Callback( Upnp_EventType EventType, void* Event, void* /*Cookie */){ switch (EventType){ //SSDP Stuff case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE: case UPNP_DISCOVERY_SEARCH_RESULT: { //New UPnP Device found struct Upnp_Discovery *d_event = ( struct Upnp_Discovery * )Event; IXML_Document *DescDoc = NULL; int ret; if( d_event->ErrCode != UPNP_E_SUCCESS ) { if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Error in Discovery Callback [%s]"), GetErrDescription(d_event->ErrCode) ); } CString devType; CString location = CA2CT(d_event->Location); // Download Device description if( ( ret = UpnpDownloadXmlDoc( d_event->Location, &DescDoc ) ) != UPNP_E_SUCCESS ) { if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Error obtaining device description from %s [%s]"), location, GetErrDescription(ret)); } if(DescDoc){ //Checks if is a InternetGatewayDevice and adds it to our list devType = GetFirstDocumentItem(DescDoc, _T("deviceType")); if(devType.CompareNoCase(IGD_DEVICE_TYPE) == 0){ thePrefs.SetUpnpDetect(UPNP_DETECTED);//leuk_he autodetect upnp in wizard AddDevice(DescDoc, location, d_event->Expires); } ixmlDocument_free( DescDoc ); } break; } case UPNP_DISCOVERY_SEARCH_TIMEOUT: if (thePrefs.GetUpnpDetect() != UPNP_DETECTED) { //leuk_he autodetect upnp in wizard StatusString=L"DeviceNotAutodetect"; thePrefs.SetUpnpDetect(UPNP_NOT_DETECTED);//leuk_he autodetect upnp in wizard } InitializingEvent->SetEvent(); break; case UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE: { // UPnP Device Removed struct Upnp_Discovery *d_event = ( struct Upnp_Discovery * )Event; if( d_event->ErrCode != UPNP_E_SUCCESS ) { if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Error in Discovery ByeBye Callback [%s]"), GetErrDescription(d_event->ErrCode) ); } CString devType = CA2CT(d_event->DeviceType); devType.Trim(); //Checks if is a InternetGatewayDevice and removes it from our list if(devType.CompareNoCase(IGD_DEVICE_TYPE) == 0){ RemoveDevice( CString(CA2CT(d_event->DeviceId))); } break; } case UPNP_EVENT_RECEIVED: { // Event reveived struct Upnp_Event *e_event = ( struct Upnp_Event * )Event; // Parses the event OnEventReceived( e_event->Sid, e_event->EventKey, e_event->ChangedVariables ); break; } } return 0; } // Adds a port mapping to all known/future devices // Returns: // UNAT_OK: If the mapping has been added to our mapping list. // (Maybe not to the device, because it runs in a different thread). // UNAT_ERROR: init did fail, not UpnpAcceptsPorts allowed. CUPnP_IGDControlPoint::UPNPNAT_RETURN CUPnP_IGDControlPoint::AddPortMapping(CUPnP_IGDControlPoint::UPNPNAT_MAPPING *mapping){ if (UpnpAcceptsPorts==False) return UNAT_ERROR; if(mapping->externalPort == 0){ mapping->externalPort = mapping->internalPort; } m_devListLock.Lock(); m_MappingsLock.Lock(); //Checks if we already have this mapping bool found = false; POSITION pos = m_Mappings.GetHeadPosition(); while(pos){ UPNPNAT_MAPPING item; item = m_Mappings.GetNext(pos); if(item.externalPort == mapping->externalPort && item.protocol== mapping->protocol ){ // 9.3: fix same port tcp/udp found = true; pos = NULL; } } if(!m_bInit ||thePrefs.IsUPnPEnabled()==false){ // if not initialized then just note the mappings for later adding. if(!found ){ //If we do not have this mapping, add it to our list when enabled //TODO use getresstring. if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("Upnp:queuing port for when upnp is enabled: %s"), mapping->description); m_Mappings.AddTail(*mapping); } m_MappingsLock.Unlock(); m_devListLock.Unlock(); return UNAT_OK; } //Checks if we have devices if(m_devices.GetCount()==0){ if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Action \"AddPortMapping\" queued until a device is found [%s]"), mapping->description); if(!found){ //If we do not have this mapping, add it to our list m_Mappings.AddTail(*mapping); } } else { if(!found){ //If we do not have this mapping, add it to our list //and try to add it to all known services. m_Mappings.AddTail(*mapping); POSITION srvpos = m_knownServices.GetHeadPosition(); while(srvpos){ UPNP_SERVICE *srv; srv = m_knownServices.GetNext(srvpos); if(srv && IsServiceEnabled(srv)){ UPNPNAT_ACTIONPARAM *action = new UPNPNAT_ACTIONPARAM; if(action){ action->type = UPNPNAT_ACTION_ADD; action->srv = *srv; action->mapping = *mapping; action->bUpdating = false; // Starts thread to add the mapping AfxBeginThread(ActionThreadFunc, action); } } } } } m_MappingsLock.Unlock(); m_devListLock.Unlock(); return UNAT_OK; } // Adds a port mapping to all known/future devices // Returns: // UNAT_OK: If the mapping has been added to our mapping list. // (Maybe not to the device, because it runs in a different thread). // UNAT_ERROR: If you have not Init() the class. CUPnP_IGDControlPoint::UPNPNAT_RETURN CUPnP_IGDControlPoint::AddPortMapping(WORD port, UPNPNAT_PROTOCOL protocol, CString description){ UPNPNAT_MAPPING mapping; mapping.internalPort = mapping.externalPort = port; mapping.protocol = protocol; mapping.description = description; return AddPortMapping(&mapping); } // Removes a port mapping from all known devices // Returns: // UNAT_OK: If the mapping has been removed from our mapping list. // (Maybe not from the device, because it runs in a different thread). // UNAT_ERROR: CUPnP_IGDControlPoint::UPNPNAT_RETURN CUPnP_IGDControlPoint::DeletePortMapping(CUPnP_IGDControlPoint::UPNPNAT_MAPPING mapping, bool removeFromList){ m_devListLock.Lock(); m_MappingsLock.Lock(); if(mapping.externalPort == 0){ mapping.externalPort = mapping.internalPort; } UPNPNAT_MAPPING item; if(!m_bInit || thePrefs.IsUPnPEnabled()==false) { // remove the queued mapping (only in queue, not in device) m_MappingsLock.Lock(); POSITION pos = m_Mappings.GetHeadPosition(); if (pos) (item = m_Mappings.GetNext(pos)); while(pos && (item.externalPort != mapping.externalPort ||item.protocol != mapping.protocol) ){ item = m_Mappings.GetNext(pos); } if( pos && removeFromList) m_Mappings.RemoveAt(pos); m_MappingsLock.Unlock(); m_devListLock.Unlock(); return UNAT_OK; } POSITION old_pos, pos = m_Mappings.GetHeadPosition(); while(pos){ old_pos = pos; item = m_Mappings.GetNext(pos); if(item.externalPort == mapping.externalPort && item.protocol== mapping.protocol ){ POSITION srvpos = m_knownServices.GetHeadPosition(); while(srvpos){ UPNP_SERVICE *srv; srv = m_knownServices.GetNext(srvpos); if(srv){ UPNPNAT_ACTIONPARAM *action = new UPNPNAT_ACTIONPARAM; if(action){ action->type = UPNPNAT_ACTION_DELETE; action->srv = *srv; action->mapping = mapping; action->bUpdating = false; AfxBeginThread(ActionThreadFunc, action); } } } if(removeFromList) m_Mappings.RemoveAt(old_pos); pos = NULL; } } m_MappingsLock.Unlock(); m_devListLock.Unlock(); return UNAT_OK; } // Removes a port mapping from all known devices // Returns: // UNAT_OK: If the mapping has been removed from our mapping list. // (Maybe not from the device, because it runs in a different thread). // UNAT_ERROR: If you have not Init() the class. CUPnP_IGDControlPoint::UPNPNAT_RETURN CUPnP_IGDControlPoint::DeletePortMapping(WORD port, UPNPNAT_PROTOCOL protocol, CString description, bool removeFromList){ UPNPNAT_MAPPING mapping; mapping.internalPort = mapping.externalPort = port; mapping.protocol = protocol; mapping.description = description; return DeletePortMapping(mapping, removeFromList); } // Removes all mapping we have in our list from all known devices bool CUPnP_IGDControlPoint::DeleteAllPortMappings(){ m_devListLock.Lock(); m_MappingsLock.Lock(); if(m_devices.GetCount()>0){ POSITION srvpos = m_knownServices.GetHeadPosition(); while(srvpos){ UPNP_SERVICE *srv; srv = m_knownServices.GetNext(srvpos); if(srv){ POSITION map_pos = m_Mappings.GetHeadPosition(); while(map_pos){ m_ActionThreadCS.Lock(); UPNPNAT_MAPPING mapping = m_Mappings.GetNext(map_pos); DeletePortMappingFromService(srv, &mapping); m_ActionThreadCS.Unlock(); } } } } m_MappingsLock.Unlock(); m_devListLock.Unlock(); return true; } bool CUPnP_IGDControlPoint::UpdateAllMappings( bool bLockDeviceList, bool bUpdating){ if (thePrefs.IsUPnPEnabled()==false) // upnp portmapping disabled. return true; if(bLockDeviceList) m_devListLock.Lock(); if(m_devices.GetCount()>0){ //Add mappings POSITION srvpos = m_knownServices.GetHeadPosition(); while(srvpos){ UPNP_SERVICE *srv; srv = m_knownServices.GetNext(srvpos); if(srv && IsServiceEnabled(srv)){ m_MappingsLock.Lock(); POSITION map_pos = m_Mappings.GetHeadPosition(); while(map_pos){ UPNPNAT_MAPPING mapping = m_Mappings.GetNext(map_pos); UPNPNAT_ACTIONPARAM *action = new UPNPNAT_ACTIONPARAM; if(action){ action->type = UPNPNAT_ACTION_ADD; action->srv = *srv; action->mapping= mapping; action->bUpdating = bUpdating; AfxBeginThread(ActionThreadFunc, action); } } m_MappingsLock.Unlock(); } } } if(bLockDeviceList) m_devListLock.Unlock(); return true; } CString CUPnP_IGDControlPoint::GetFirstDocumentItem(IXML_Document * doc, CString item ){ return GetFirstNodeItem( (IXML_Node *)doc, item ); } CString CUPnP_IGDControlPoint::GetFirstElementItem( IXML_Element * element, CString item ){ return GetFirstNodeItem( (IXML_Node *)element, item ); } CString CUPnP_IGDControlPoint::GetFirstNodeItem( IXML_Node * root_node, CString item ) { IXML_Node *node; CString nodeVal; CString node_name; node = root_node; while( node != NULL ) { if (ixmlNode_getNodeType( node ) == eELEMENT_NODE){ node_name = CA2CT(ixmlNode_getNodeName( node )); // match name if( node_name.CompareNoCase(item) == 0 ) { IXML_Node *text_node = NULL; text_node = ixmlNode_getFirstChild( node ); if( text_node == NULL ) { return CString(_T("")); } nodeVal = CA2CT(ixmlNode_getNodeValue( text_node )); return nodeVal; } else{ //Checks if we have something like "u:UPnPError" instead of "UPnPError" int pos = 0; pos = node_name.Find(_T(':')); if (pos != -1){ node_name = node_name.Right(node_name.GetLength() - pos - 1); if( node_name.CompareNoCase(item) == 0 ) { IXML_Node *text_node = NULL; text_node = ixmlNode_getFirstChild( node ); if( text_node == NULL ) { return CString(_T("")); } nodeVal = CA2CT(ixmlNode_getNodeValue( text_node )); return nodeVal; } } } } nodeVal = GetFirstNodeItem(ixmlNode_getFirstChild(node), item); if(!nodeVal.IsEmpty()) return nodeVal; // free and next node node = ixmlNode_getNextSibling( node ); // next node } return CString(_T("")); } IXML_NodeList *CUPnP_IGDControlPoint::GetElementsByName(IXML_Document *doc, CString name){ return GetElementsByName((IXML_Node*)doc, name); } IXML_NodeList *CUPnP_IGDControlPoint::GetElementsByName(IXML_Element *element, CString name){ return GetElementsByName((IXML_Node*)element, name); } IXML_NodeList *CUPnP_IGDControlPoint::GetElementsByName(IXML_Node *root_node, CString name){ IXML_NodeList *node_list = NULL; return GetElementsByName(root_node, name, &node_list); } IXML_NodeList *CUPnP_IGDControlPoint::GetElementsByName(IXML_Node *root_node, CString name, IXML_NodeList **nodelist){ IXML_Node *node; if(nodelist == NULL) return NULL; node = root_node; while( node != NULL ) { if (ixmlNode_getNodeType( node ) == eELEMENT_NODE){ CString node_name = CA2CT(ixmlNode_getNodeName( node )); // match name if( node_name.CompareNoCase(name) == 0 ) { ixmlNodeList_addToNodeList(nodelist, node); } else{ int pos = 0; pos = node_name.Find(_T(':')); if (pos != -1){ node_name = node_name.Right(node_name.GetLength() - pos - 1); if( node_name.CompareNoCase(name) == 0 ) { ixmlNodeList_addToNodeList(nodelist, node); } } } } GetElementsByName(ixmlNode_getFirstChild(node), name, nodelist); // free and next node node = ixmlNode_getNextSibling( node ); // next node } return *nodelist; } IXML_NodeList * CUPnP_IGDControlPoint::GetDeviceList( IXML_Document * doc ){ return GetDeviceList((IXML_Node*)doc); } IXML_NodeList * CUPnP_IGDControlPoint::GetDeviceList( IXML_Element * element ){ return GetDeviceList((IXML_Node*)element); } IXML_NodeList * CUPnP_IGDControlPoint::GetDeviceList( IXML_Node * root_node ){ IXML_NodeList *DeviceList = NULL; IXML_NodeList *devlistnodelist = NULL; IXML_Node *devlistnode = NULL; devlistnodelist = GetElementsByName( root_node, _T("deviceList") ); if( devlistnodelist && ixmlNodeList_length( devlistnodelist ) ) { devlistnode = ixmlNodeList_item( devlistnodelist, 0 ); DeviceList = GetElementsByName( devlistnode, _T("device") ); } if( devlistnodelist ) ixmlNodeList_free( devlistnodelist ); return DeviceList; } IXML_NodeList * CUPnP_IGDControlPoint::GetServiceList( IXML_Element * element ){ return GetServiceList((IXML_Node*) element); } IXML_NodeList * CUPnP_IGDControlPoint::GetServiceList( IXML_Node * root_node ){ IXML_NodeList *ServiceList = NULL; IXML_NodeList *servlistnodelist = NULL; IXML_Node *servlistnode = NULL; servlistnodelist = GetElementsByName( root_node, _T("serviceList") ); if( servlistnodelist && ixmlNodeList_length( servlistnodelist ) ) { servlistnode = ixmlNodeList_item( servlistnodelist, 0 ); ServiceList = GetElementsByName( servlistnode, _T("service") ); } if( servlistnodelist ) ixmlNodeList_free( servlistnodelist ); return ServiceList; } CUPnP_IGDControlPoint * CUPnP_IGDControlPoint::GetInstance(){ if (m_IGDControlPoint == NULL) { m_IGDControlPoint = new CUPnP_IGDControlPoint(); } return m_IGDControlPoint; } UINT CUPnP_IGDControlPoint::RemoveInstance(LPVOID /*pParam*/ ){ delete m_IGDControlPoint; m_IGDControlPoint = NULL; return 0; } void CUPnP_IGDControlPoint::AddDevice( IXML_Document * doc, CString location, int expires){ m_devListLock.Lock(); CString UDN; UDN = GetFirstDocumentItem(doc, _T("UDN")); POSITION pos = m_devices.GetHeadPosition(); bool found = false; while(pos){ UPNP_DEVICE *item; item = m_devices.GetNext(pos); if(item && item->UDN.CompareNoCase(UDN) == 0){ found = true; //Update advertisement timeout item->AdvrTimeOut = expires; pos = NULL; } } if(!found){ CString friendlyName = GetFirstDocumentItem(doc, _T("friendlyName")); theApp.QueueLogLine(false, GetResString(IDS_UPNP_NEWDEVICE), friendlyName); if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: New compatible device found: %s"), friendlyName); UPNP_DEVICE *device = new UPNP_DEVICE; if(device){ CString BaseURL; m_devices.AddTail(device); device->DevType = GetFirstDocumentItem(doc, _T("deviceType")); device->UDN = UDN; device->DescDocURL = location; device->FriendlyName = friendlyName; device->AdvrTimeOut = expires; BaseURL = GetFirstDocumentItem(doc, _T("URLBase")); if(BaseURL.IsEmpty()) BaseURL = location; IXML_NodeList* devlist1 = GetDeviceList(doc); int length1 = ixmlNodeList_length( devlist1 ); for( int n1 = 0; n1 < length1; n1++ ) { IXML_Element *dev1; dev1 = ( IXML_Element * ) ixmlNodeList_item( devlist1, n1 ); CString devType1 = GetFirstElementItem(dev1, _T("deviceType")); if(devType1.CompareNoCase(WAN_DEVICE_TYPE) == 0){ //WanDevice UPNP_DEVICE *wandevice = new UPNP_DEVICE; wandevice->DevType = devType1; wandevice->UDN = GetFirstElementItem(dev1, _T("UDN")); wandevice->FriendlyName = GetFirstElementItem(dev1, _T("friendlyName")); device->EmbededDevices.AddTail(wandevice); if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Added embedded device: %s [%s]"), wandevice->FriendlyName, wandevice->DevType); IXML_NodeList* devlist2 = GetDeviceList(dev1); int length2 = ixmlNodeList_length( devlist2 ); for( int n2 = 0; n2 < length2; n2++ ) { IXML_Element *dev2; dev2 = ( IXML_Element * ) ixmlNodeList_item( devlist2, n2 ); CString devType2 = GetFirstElementItem(dev2, _T("deviceType")); if(devType2.CompareNoCase(WANCON_DEVICE_TYPE) == 0){ //WanConnectionDevice, get services UPNP_DEVICE *wancondevice = new UPNP_DEVICE; wancondevice->DevType = devType2; wancondevice->UDN = GetFirstElementItem(dev2, _T("UDN")); wancondevice->FriendlyName = GetFirstElementItem(dev2, _T("friendlyName")); wandevice->EmbededDevices.AddTail(wancondevice); if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Added embedded device: %s [%s]"), wancondevice->FriendlyName, wancondevice->DevType); IXML_NodeList* services = GetServiceList(dev2); int length3 = ixmlNodeList_length( services ); int wanConnFounds = 0; bool enabledFound = false; UPNP_SERVICE *firstService = NULL; for( int n3 = 0; n3 < length3 && !(m_bStopAtFirstService && wanConnFounds == 1); n3++ ) { IXML_Element *srv; srv = ( IXML_Element * ) ixmlNodeList_item( services, n3 ); CString srvType = GetFirstElementItem(srv, _T("serviceType")); if(srvType.CompareNoCase(WANIP_SERVICE_TYPE) == 0 || srvType.CompareNoCase(WANPPP_SERVICE_TYPE) == 0) { //Compatible Service found wanConnFounds++; CString RelURL; char *cAbsURL; UPNP_SERVICE *service = new UPNP_SERVICE; if(wanConnFounds == 1) firstService = service; service->ServiceType = srvType; service->ServiceID = GetFirstElementItem(srv, _T("serviceId")); RelURL = GetFirstElementItem(srv, _T("eventSubURL")); cAbsURL = new char[BaseURL.GetLength() + RelURL.GetLength() + 1]; if(cAbsURL && UpnpResolveURL(CT2CA(BaseURL), CT2CA(RelURL), cAbsURL) == UPNP_E_SUCCESS) { service->EventURL = CA2CT(cAbsURL); } else{ service->EventURL = RelURL; } delete[] cAbsURL; RelURL = GetFirstElementItem(srv, _T("controlURL")); cAbsURL = new char[BaseURL.GetLength() + RelURL.GetLength() + 1]; if(cAbsURL && UpnpResolveURL(CT2CA(BaseURL), CT2CA(RelURL), cAbsURL) == UPNP_E_SUCCESS) { service->ControlURL = CA2CT(cAbsURL); } else{ service->ControlURL = RelURL; } delete[] cAbsURL; service->Enabled = -1; //Uninitialized wancondevice->Services.AddTail(service); m_knownServices.AddTail(service); if(IsServiceEnabled(service)){ enabledFound = true; if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Added service: %s (Enabled)"), service->ServiceType); } else{ if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Added service: %s (Disabled)"), service->ServiceType); } //Subscribe to events int TimeOut = expires; int subsRet; subsRet = UpnpSubscribe(m_ctrlPoint, CT2CA(service->EventURL), &TimeOut, service->SubscriptionID); if(subsRet == UPNP_E_SUCCESS){ if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Subscribed with service \"%s\" [SID=%s]"), service->ServiceType, CA2CT(service->SubscriptionID)); } else{ if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Failed to subscribe with service: %s [%s]"), service->ServiceType, GetErrDescription(subsRet)); } } } ixmlNodeList_free(services); // If no service is enabled, force // try with first one. if(!enabledFound && firstService){ if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: No enabled service found. Trying with first service [%s]"), firstService->ServiceType); firstService->Enabled = 1; } } } ixmlNodeList_free(devlist2); } } ixmlNodeList_free(devlist1); } UpdateAllMappings(false, false); } m_devListLock.Unlock(); } void CUPnP_IGDControlPoint::RemoveDevice( UPNP_DEVICE *dev ){ //Do not use the mutex here, is a recursive function CString fName = dev->FriendlyName; POSITION pos = dev->EmbededDevices.GetHeadPosition(); while(pos){ UPNP_DEVICE *item; item = dev->EmbededDevices.GetNext(pos); if(item){ RemoveDevice(item); } } pos = dev->Services.GetHeadPosition(); while(pos){ UPNP_SERVICE *item; item = dev->Services.GetNext(pos); POSITION srvpos = m_knownServices.GetHeadPosition(); while(srvpos){ UPNP_SERVICE *item2; POSITION curpos = srvpos; item2 = m_knownServices.GetNext(srvpos); if(item == item2){ m_knownServices.RemoveAt(curpos); srvpos = NULL; } } if(item) delete item; } delete dev; if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Device removed: %s"), fName); } void CUPnP_IGDControlPoint::RemoveDevice( CString devID ){ m_devListLock.Lock(); POSITION old_pos, pos = m_devices.GetHeadPosition(); while(pos){ UPNP_DEVICE *item; old_pos = pos; item = m_devices.GetNext(pos); if(item && item->UDN.CompareNoCase(devID) == 0){ if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Device removed: %s"), item->FriendlyName); RemoveDevice(item); m_devices.RemoveAt(old_pos); pos = NULL; } } m_devListLock.Unlock(); } void CUPnP_IGDControlPoint::CheckTimeouts(){ if(!m_bInit) return; m_devListLock.Lock(); POSITION old_pos, pos = m_devices.GetHeadPosition(); while(pos){ UPNP_DEVICE *item; old_pos = pos; item = m_devices.GetNext(pos); item->AdvrTimeOut -= UPNP_ADVERTISEMENT_DECREMENT; if(item->AdvrTimeOut <= 0){ RemoveDevice(item); m_devices.RemoveAt(old_pos); } else if(item->AdvrTimeOut < UPNP_ADVERTISEMENT_DECREMENT * 2){ //About to expire, send a search to try to renew UpnpSearchAsync( m_ctrlPoint, UPNP_ADVERTISEMENT_DECREMENT, CT2CA(item->UDN), &m_ctrlPoint); } } m_devListLock.Unlock(); } UINT CUPnP_IGDControlPoint::TimerThreadFunc( LPVOID /*pParam*/ ){ int sleepTime = UPNP_ADVERTISEMENT_DECREMENT * 1000; int updateTimeF = UPNP_PORT_LEASETIME * 800; static long int updateTime = updateTimeF; static long int testTime = sleepTime; //SiRoB while(m_IGDControlPoint){ // SiRoB >> /* Sleep(sleepTime); */ Sleep(1000); testTime-=1000; if (testTime <= 0) { testTime = sleepTime; // << SiRoB CheckTimeouts(); updateTime -= sleepTime; if(updateTime <= 0) { UpdateAllMappings(); updateTime = updateTimeF; } } // SiRoB }; return 1; } CUPnP_IGDControlPoint::UPNPNAT_RETURN CUPnP_IGDControlPoint::AddPortMappingToService(CUPnP_IGDControlPoint::UPNP_SERVICE *srv, CUPnP_IGDControlPoint::UPNPNAT_MAPPING *mapping, bool bIsUpdating){ if(!m_bInit) return UNAT_ERROR; UPNPNAT_RETURN Status = UNAT_ERROR; CString protocol; CString desc; CString intPort, extPort; bool bUpdate = false; if (mapping->protocol == UNAT_TCP){ protocol = _T("TCP"); } else { protocol = _T("UDP"); } desc.Format(UPNP_DESCRIPTION_FORMAT, mapping->description, protocol, mapping->externalPort); _itow(mapping->internalPort, intPort.GetBufferSetLength(10), 10); intPort.ReleaseBuffer(); _itow(mapping->externalPort, extPort.GetBufferSetLength(10), 10); extPort.ReleaseBuffer(); //Check if the portmaping already exists UPNPNAT_FULLMAPPING fullMapping; if((thePrefs.m_bUPnPForceUpdate==0) && GetSpecificPortMappingEntryFromService(srv, mapping, &fullMapping, false) == UNAT_OK){ if(fullMapping.internalClient == GetLocalIPStr()){ if(fullMapping.description.Left(7).MakeLower() != _T("emule (")){ if(thePrefs.GetUPnPVerboseLog()) { theApp.QueueDebugLogLine(false,_T("UPnP: Couldn't add mapping: \"%s\". The port %d is already mapped to other application (\"%s\" on %s:%d). [%s]"), desc, mapping->externalPort, fullMapping.description, fullMapping.internalClient, fullMapping.internalPort, srv->ServiceType); }; return UNAT_NOT_OWNED_PORTMAPPING; } else{ if(fullMapping.enabled == TRUE && fullMapping.leaseDuration == 0){ if(bIsUpdating){ if(thePrefs.GetUPnPVerboseLog()) { theApp.QueueDebugLogLine(false, _T("UPnP: The port mapping \"%s\" doesn't need an update. [%s]"), desc, srv->ServiceType); } } else if(thePrefs.GetUPnPVerboseLog()) { theApp.QueueDebugLogLine(false,_T("UPnP: The port mapping \"%s\" doesn't need to be recreated. [%s]"), desc, srv->ServiceType); }; //Mapping is already OK return UNAT_OK; } else{ bUpdate = true; } } } else{ if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Couldn't add mapping: \"%s\". The port %d is already mapped to other pc/application (\"%s\" on %s:%d). [%s]"), desc, mapping->externalPort, fullMapping.description, fullMapping.internalClient, fullMapping.internalPort, srv->ServiceType); return UNAT_NOT_OWNED_PORTMAPPING; } } IXML_Document *actionNode = NULL; char actionName[] = "AddPortMapping"; UpnpAddToAction( &actionNode, actionName , CT2CA(srv->ServiceType), "NewRemoteHost", ""); UpnpAddToAction( &actionNode, actionName , CT2CA(srv->ServiceType), "NewExternalPort", CT2CA(extPort)); UpnpAddToAction( &actionNode, actionName , CT2CA(srv->ServiceType), "NewProtocol", CT2CA(protocol.GetBuffer())); UpnpAddToAction( &actionNode, actionName , CT2CA(srv->ServiceType), "NewInternalPort", CT2CA(intPort)); UpnpAddToAction( &actionNode, actionName , CT2CA(srv->ServiceType), "NewInternalClient", CT2CA(GetLocalIPStr().GetBuffer())); UpnpAddToAction( &actionNode, actionName , CT2CA(srv->ServiceType), "NewEnabled", "1"); UpnpAddToAction( &actionNode, actionName , CT2CA(srv->ServiceType), "NewPortMappingDescription", CT2CA(desc)); //Only set a lease time if we want to remove it on close if(m_bClearOnClose){ UpnpAddToAction( &actionNode, actionName , CT2CA(srv->ServiceType), "NewLeaseDuration", UPNP_PORT_LEASETIME_STR); } else{ UpnpAddToAction( &actionNode, actionName , CT2CA(srv->ServiceType), "NewLeaseDuration", "0"); } IXML_Document* RespNode = NULL; int rc = UpnpSendAction( m_ctrlPoint,CT2CA(srv->ControlURL), CT2CA(srv->ServiceType), NULL, actionNode, &RespNode); if( rc != UPNP_E_SUCCESS) { // if m_bClearOnClose==TRUE we have already tried with an static port mapping if(m_bClearOnClose){ //Maybe the IGD do not support dynamic port mappings, //try with an static one (NewLeaseDuration = 0). if( RespNode ) ixmlDocument_free( RespNode ); IXML_NodeList *nodeList = NULL; IXML_Node *textNode = NULL; IXML_Node *tmpNode = NULL; nodeList = GetElementsByName( actionNode, _T("NewLeaseDuration")); if(nodeList) { tmpNode = ixmlNodeList_item( nodeList, 0 ); if(tmpNode) { textNode = ixmlNode_getFirstChild( tmpNode ); ixmlNode_setNodeValue( textNode , "0"); } ixmlNodeList_free(nodeList); } rc = UpnpSendAction( m_ctrlPoint,CT2CA(srv->ControlURL), CT2CA(srv->ServiceType), NULL, actionNode, &RespNode); } //This can be changed if we tried with an static port mapping if(rc == UPNP_E_SUCCESS){ Status = UNAT_OK; if(bUpdate) { if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Updated port mapping \"%s\" (%s). [%s]"), desc, _T("Static"), srv->ServiceType); } else{ if(thePrefs.GetUPnPVerboseLog()) { theApp.QueueDebugLogLine(false, _T( "UPnP: Added port mapping \"%s\" (%s). [%s]"), desc, _T("Static"), srv->ServiceType); } } } else{ if(bIsUpdating){ if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Failed to update port mapping \"%s\" [%s] [%s]"), desc, srv->ServiceType, GetErrDescription(RespNode, rc)); } else { if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Failed to add port mapping \"%s\" [%s] [%s]"), desc, srv->ServiceType, GetErrDescription(RespNode, rc)); } } } else{ Status = UNAT_OK; if(bUpdate) { if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false,_T("UPnP: Updated port mapping \"%s\" (%s). [%s]"), desc, _T("Dynamic"), srv->ServiceType); } else { if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false,_T( "UPnP: Added port mapping \"%s\" (%s). [%s]"), desc, _T("Dynamic"), srv->ServiceType); } } if( RespNode ) ixmlDocument_free( RespNode ); if( actionNode ) ixmlDocument_free( actionNode ); return Status; } CUPnP_IGDControlPoint::UPNPNAT_RETURN CUPnP_IGDControlPoint::DeletePortMappingFromService(CUPnP_IGDControlPoint::UPNP_SERVICE *srv, CUPnP_IGDControlPoint::UPNPNAT_MAPPING *mapping){ if(!m_bInit) return UNAT_ERROR; UPNPNAT_RETURN Status = UNAT_ERROR; CString protocol; CString desc; CString extPort; if (mapping->protocol == UNAT_TCP){ protocol = _T("TCP"); } else { protocol = _T("UDP"); } desc.Format(UPNP_DESCRIPTION_FORMAT, mapping->description, protocol, mapping->externalPort); _itow(mapping->externalPort, extPort.GetBufferSetLength(10), 10); extPort.ReleaseBuffer(); //Check if the portmapping belong to us UPNPNAT_FULLMAPPING fullMapping; UPNPNAT_RETURN ret = GetSpecificPortMappingEntryFromService(srv, mapping, &fullMapping, false); if( ret == UNAT_OK ){ if(fullMapping.internalClient == GetLocalIPStr()){ if(fullMapping.description.Left(7).MakeLower() != _T("emule (")){ return UNAT_NOT_OWNED_PORTMAPPING; } } else{ return UNAT_NOT_OWNED_PORTMAPPING; } } else if(ret == UNAT_NOT_FOUND){ if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Deleting port mapping \"%s\" aborted. [%s] [NoSuchEntryInArray (714)]"), desc, srv->ServiceType); return UNAT_NOT_FOUND; } IXML_Document *actionNode = NULL; char actionName[] = "DeletePortMapping"; UpnpAddToAction( &actionNode, actionName , CT2CA(srv->ServiceType), "NewRemoteHost", ""); UpnpAddToAction( &actionNode, actionName , CT2CA(srv->ServiceType), "NewExternalPort", CT2CA(extPort)); UpnpAddToAction( &actionNode, actionName , CT2CA(srv->ServiceType), "NewProtocol", CT2CA(protocol.GetBuffer())); IXML_Document* RespNode = NULL; int rc = UpnpSendAction( m_ctrlPoint,CT2CA(srv->ControlURL), CT2CA(srv->ServiceType), NULL, actionNode, &RespNode); if( rc != UPNP_E_SUCCESS) { if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false,_T("UPnP: Failed to delete port mapping \"%s\". [%s] [%s]"), desc, srv->ServiceType, GetErrDescription(RespNode, rc)); } else{ Status = UNAT_OK; if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Deleted port mapping \"%s\". [%s]"), desc, srv->ServiceType); } if( RespNode ) ixmlDocument_free( RespNode ); if( actionNode ) ixmlDocument_free( actionNode ); return Status; } CUPnP_IGDControlPoint::UPNPNAT_RETURN CUPnP_IGDControlPoint::GetSpecificPortMappingEntryFromService(CUPnP_IGDControlPoint::UPNP_SERVICE *srv, UPNPNAT_MAPPING *mapping, UPNPNAT_FULLMAPPING *fullMapping, bool bLog){ if(!m_bInit) return UNAT_ERROR; UPNPNAT_RETURN status = UNAT_ERROR; CString protocol; CString desc; CString extPort; if (mapping->protocol == UNAT_TCP){ protocol = _T("TCP"); } else { protocol = _T("UDP"); } desc.Format(UPNP_DESCRIPTION_FORMAT, mapping->description, protocol, mapping->externalPort); _itow(mapping->externalPort, extPort.GetBufferSetLength(10), 10); extPort.ReleaseBuffer(); IXML_Document *actionNode = NULL; char actionName[] = "GetSpecificPortMappingEntry"; UpnpAddToAction( &actionNode, actionName , CT2CA(srv->ServiceType), "NewRemoteHost", ""); UpnpAddToAction( &actionNode, actionName , CT2CA(srv->ServiceType), "NewExternalPort", CT2CA(extPort)); UpnpAddToAction( &actionNode, actionName , CT2CA(srv->ServiceType), "NewProtocol", CT2CA(protocol.GetBuffer())); IXML_Document* RespNode = NULL; int rc = UpnpSendAction( m_ctrlPoint,CT2CA(srv->ControlURL), CT2CA(srv->ServiceType), NULL, actionNode, &RespNode); if( rc != UPNP_E_SUCCESS) { if(rc == 714){ //NoSuchEntryInArray status = UNAT_NOT_FOUND; } else{ //Other error status = UNAT_ERROR; } if(bLog && thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Failed to get specific port mapping entry \"%s\". [%s]"), desc, GetErrDescription(RespNode, rc)); } else{ fullMapping->externalPort = mapping->externalPort; fullMapping->protocol = mapping->protocol; fullMapping->internalPort =(WORD) _ttoi(GetFirstDocumentItem(RespNode, _T("NewInternalPort"))); fullMapping->description = GetFirstDocumentItem(RespNode, _T("NewPortMappingDescription")); fullMapping->enabled = _ttoi(GetFirstDocumentItem(RespNode, _T("NewEnabled"))) == 0 ? false : true; fullMapping->leaseDuration = _ttoi(GetFirstDocumentItem(RespNode, _T("NewLeaseDuration"))); // WinXP returns the host name instead of the ip for the "NewInternalClient" var. // Try to get the ip using the host name. CString internalClient = GetFirstDocumentItem(RespNode, _T("NewInternalClient")); LPHOSTENT lphost; lphost = gethostbyname(CT2CA(internalClient)); if (lphost != NULL){ internalClient = CA2CT(inet_ntoa(*(in_addr*)lphost->h_addr_list[0])); } fullMapping->internalClient = internalClient; status = UNAT_OK; } if( RespNode ) ixmlDocument_free( RespNode ); if( actionNode ) ixmlDocument_free( actionNode ); return status; } /* Experimental CUPnP_IGDControlPoint::UPNPNAT_RETURN CUPnP_IGDControlPoint::GetExternalIPAddress(CUPnP_IGDControlPoint::UPNP_SERVICE *srv, bool bLog){ if(!m_bInit) return UNAT_ERROR; UPNPNAT_RETURN status = UNAT_ERROR; IXML_Document *actionNode = NULL; char actionName[] = "GetExternalIPAddress"; UpnpAddToAction( &actionNode, actionName , CT2CA(srv->ServiceType), "", ""); IXML_Document* RespNode = NULL; int rc = UpnpSendAction( m_ctrlPoint,CT2CA(srv->ControlURL), CT2CA(srv->ServiceType), NULL, actionNode, &RespNode); if( rc != UPNP_E_SUCCESS) { if(rc == 714){ //NoSuchEntryInArray status = UNAT_NOT_FOUND; } else{ //Other error status = UNAT_ERROR; } if(bLog && thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Failed to get external ip\"%s\". [%s]"), desc, GetErrDescription(RespNode, rc)); } else{ Cstring ExternalIp= GetFirstDocumentItem(RespNode, _T("ExternalIp"))); status = UNAT_OK; } if( RespNode ) ixmlDocument_free( RespNode ); if( actionNode ) ixmlDocument_free( actionNode ); return status; } Experimental */ ///////////////////////////////////////////////////////////////////////////////// // Returns a CString with the local IP in format xxx.xxx.xxx.xxx ///////////////////////////////////////////////////////////////////////////////// CString CUPnP_IGDControlPoint::GetLocalIPStr() { if(!m_bInit) return CString(_T("")); else return CString(CA2CT(UpnpGetServerIpAddress())); } ///////////////////////////////////////////////////////////////////////////////// // Returns true if nIP is a LAN ip, false otherwise ///////////////////////////////////////////////////////////////////////////////// bool CUPnP_IGDControlPoint::IsLANIP(unsigned long nIP){ // filter LAN IP's // ------------------------------------------- // 0.* // 10.0.0.0 - 10.255.255.255 class A // 172.16.0.0 - 172.31.255.255 class B // 192.168.0.0 - 192.168.255.255 class C unsigned char nFirst = (unsigned char)nIP; unsigned char nSecond = (unsigned char)(nIP >> 8); if (nFirst==192 && nSecond==168) // check this 1st, because those LANs IPs are mostly spreaded return true; if (nFirst==172 && nSecond>=16 && nSecond<=31) return true; if (nFirst==0 || nFirst==10) return true; return false; } bool CUPnP_IGDControlPoint::IsLANIP(char *cIP){ if(cIP == NULL) return false; return IsLANIP(inet_addr(cIP)); } UINT CUPnP_IGDControlPoint::ActionThreadFunc( LPVOID pParam ){ m_ActionThreadCS.Lock(); UPNPNAT_ACTIONPARAM *action = reinterpret_cast<UPNPNAT_ACTIONPARAM *>(pParam); if(action){ if(IsServiceEnabled(&(action->srv))){ switch(action->type){ case UPNPNAT_ACTION_ADD: AddPortMappingToService(&(action->srv), &(action->mapping), action->bUpdating); break; case UPNPNAT_ACTION_DELETE: DeletePortMappingFromService(&(action->srv), &(action->mapping)); break; } } delete action; } if (InitializingEvent) InitializingEvent->SetEvent();// ports added, tell main thead to continue. m_ActionThreadCS.Unlock(); return 1; } bool CUPnP_IGDControlPoint::IsServiceEnabled(CUPnP_IGDControlPoint::UPNP_SERVICE *srv){ if(!m_bInit) return false; if(srv->Enabled != -1) return (srv->Enabled == 1 ? true : false); bool status = false; IXML_Document *actionNode = NULL; char actionName[] = "GetStatusInfo"; actionNode = UpnpMakeAction(actionName, CT2CA(srv->ServiceType), 0, NULL); IXML_Document* RespNode = NULL; int rc = UpnpSendAction( m_ctrlPoint,CT2CA(srv->ControlURL), CT2CA(srv->ServiceType), NULL, actionNode, &RespNode); if( rc != UPNP_E_SUCCESS) { if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: Failed to get GetStatusInfo from [%s] [%s])"), srv->ServiceType, GetErrDescription(RespNode, rc)); } else{ CString strStatus = GetFirstDocumentItem(RespNode, _T("NewConnectionStatus")); if(strStatus.CompareNoCase(_T("Connected")) == 0) status = true; } if( RespNode ) ixmlDocument_free( RespNode ); if( actionNode ) ixmlDocument_free( actionNode ); srv->Enabled = (status == true ? 1 : 0); return status; } void CUPnP_IGDControlPoint::OnEventReceived(Upnp_SID sid, int /* evntkey */, IXML_Document * changes ){ bool update = false; m_devListLock.Lock(); POSITION srvpos = m_knownServices.GetHeadPosition(); while(srvpos){ UPNP_SERVICE *srv; srv = m_knownServices.GetNext(srvpos); if(srv){ if(strcmp(srv->SubscriptionID, sid) == 0){ //if(thePrefs.GetUPnPVerboseLog()) // theApp.QueueDebugLogLine(false, _T("UPnP: Event received from service \"%s\" [SID=%s]"), srv->ServiceType, CA2CT(srv->SubscriptionID)); //Parse Event IXML_NodeList *properties = NULL; properties = GetElementsByName( changes, _T("property") ); if(properties != NULL){ int length = ixmlNodeList_length( properties ); for( int i = 0; i < length; i++ ) { IXML_Element *property = NULL; property = ( IXML_Element * ) ixmlNodeList_item( properties, i ); if(property){ IXML_NodeList *variables = NULL; variables = GetElementsByName( property, _T("ConnectionStatus") ); if(variables){ int length2 = ixmlNodeList_length( variables ); if( length2 > 0 ) { IXML_Element *variable = NULL; CString value; variable = ( IXML_Element * ) ixmlNodeList_item( variables, 0 ); IXML_Node *child = ixmlNode_getFirstChild( ( IXML_Node * ) variable ); if( ( child != 0 ) && ( ixmlNode_getNodeType( child ) == eTEXT_NODE ) ) { value = CA2CT(ixmlNode_getNodeValue( child )); } if(value.CompareNoCase(_T("Connected")) == 0){ if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: New ConnectionStatus for \"%s\" (Connected) [SID=%s] "), srv->ServiceType, CA2CT(srv->SubscriptionID)); if(srv->Enabled != 1) update = true; srv->Enabled = 1; } else{ if(thePrefs.GetUPnPVerboseLog()) theApp.QueueDebugLogLine(false, _T("UPnP: New ConnectionStatus for \"%s\" (Disconnected) [SID=%s]"), srv->ServiceType, CA2CT(srv->SubscriptionID)); if(srv->Enabled != 0) update = true; srv->Enabled = 0; } } ixmlNodeList_free( variables ); } } } ixmlNodeList_free( properties ); } } } } m_devListLock.Unlock(); if(update) UpdateAllMappings(); } CString CUPnP_IGDControlPoint::GetErrDescription(int err){ CString errDesc; if(err < 0){ errDesc = CA2CT(UpnpGetErrorMessage(err)); } else{ errDesc = _T("HTTP_ERROR"); } errDesc.AppendFormat(_T(" (%d)"), err); return errDesc; } CString CUPnP_IGDControlPoint::GetErrDescription(IXML_Document* errDoc, int err){ CString errDesc; int err_n = 0; err_n = _ttoi(GetFirstDocumentItem(errDoc, _T("errorCode"))); if(err_n == 0){ errDesc = GetErrDescription(err); } else{ errDesc = GetFirstDocumentItem(errDoc, _T("errorDescription")); if(errDesc.IsEmpty()) errDesc = _T("Unknown Error"); errDesc.AppendFormat(_T(" (%d)"), err_n); } return errDesc; } void CUPnP_IGDControlPoint::DeleteAllPortMappingsOnClose(){ m_bClearOnClose = true; } int CUPnP_IGDControlPoint::GetStatusString(CString & displaystring,bool verbose) { if(!m_bInit){ if (StatusString.IsEmpty() ) displaystring=GetResString(IDS_UPNP_INFO_NONEED); else displaystring=StatusString; return (1); } CString upnpIpPort ; upnpIpPort .Format(_T("\t%s:%u\r\n"),CString(CA2CT(UpnpGetServerIpAddress())),(int)UpnpGetServerPort()); m_devListLock.Lock(); m_MappingsLock.Lock(); if(m_devices.GetCount()>0){ displaystring += GetResString(IDS_ENABLED) + _T("\r\n"); if (verbose) displaystring += GetResString(IDS_IP)+_T(":")+ GetResString(IDS_PORT) +upnpIpPort ; POSITION devpos; devpos= m_devices.GetHeadPosition(); while (devpos) { UPNP_DEVICE *item; item = m_devices.GetNext(devpos); displaystring += item->FriendlyName + _T("\r\n"); } if (verbose) { POSITION srvpos = m_knownServices.GetHeadPosition(); while(srvpos){ UPNP_SERVICE *srv; srv = m_knownServices.GetNext(srvpos); displaystring += _T("srv:") + srv->ServiceID + _T(":") + srv->ServiceType ; switch (srv->Enabled){ case -1: displaystring += GetResString(IDS_UPNP_INFOUNINIT); break; case 1: displaystring += GetResString(IDS_UPNP_INFOENABLED); break; case 0: default: displaystring += GetResString(IDS_UPNP_INFODISABLED); } } } POSITION map_pos = m_Mappings.GetHeadPosition(); while(map_pos){ UPNPNAT_MAPPING mapping = m_Mappings.GetNext(map_pos); CString port; port.Format(_T("%d"), mapping.externalPort ); if (verbose) displaystring += port + ((mapping.protocol == UNAT_UDP)?_T(":UDP\t"): _T(":TCP\t")) + mapping.description +_T("\r\n"); else { displaystring += port + ((mapping.protocol == UNAT_UDP)?_T(":UDP"): _T(":TCP")); if(map_pos) displaystring += _T(", "); } } } else { displaystring += GetResString(IDS_UPNP_INFOSTANDBY ); //No Device detected\r\n if (verbose) displaystring += GetResString(IDS_IP)+_T(":")+ GetResString(IDS_PORT) + upnpIpPort ; } m_MappingsLock.Unlock(); m_devListLock.Unlock(); return 0; }
[ "Mike.Ken.S@dd569cc8-ff36-11de-bbca-1111db1fd05b" ]
[ [ [ 1, 1658 ] ] ]
dd740eca9406826e3b1c998cc350751fe4e408e6
57dbf4f198610ef4d449f6b882d5ed1072cfb190
/ArpMatrix.h
84decc6e160d82804318ee565330c3eee1a86a2a
[]
no_license
safetydank/Arponaut
b3d53ca8153a9f1a1034ee8361517d3e4da880a8
b62e36a8590aa8ceb9c0a3d68664b74beb9fd40b
refs/heads/master
2021-01-21T19:28:40.512906
2011-02-11T00:15:30
2011-02-11T00:15:30
1,353,054
2
1
null
null
null
null
UTF-8
C++
false
false
1,141
h
#pragma once #include "IControl.h" class Sequence; class ArpMatrix : public IControl { public: /** * Constructor * * @param bgID background bitmap resource ID * @param cursorID cursor bitmap resource ID */ ArpMatrix(IPlugBase* pPlug, Sequence* sequence, int x, int y); virtual ~ArpMatrix() { }; virtual void OnMouseDown(int x, int y, IMouseMod* pMod); virtual void OnMouseDrag(int x, int y, int dX, int dY, IMouseMod* pMod); //virtual void OnMouseDblClick(int x, int y, IMouseMod* pMod); //virtual void OnMouseWheel(int x, int y, IMouseMod* pMod, int d); virtual bool Draw(IGraphics* pGraphics); virtual void SetDirty(bool pushParamToPlug); void Rebuild(); protected: // Track two parameters // int mParamXIdx; // double mValueX, mClampXLo, mClampXHi; // double mMaxPadX; // int mParamYIdx; // double mValueY, mClampYLo, mClampYHi; // double mMaxPadY; int mMouseX; int mMouseY; void DrawNote(IGraphics* pGraphics, int iseq, int note); private: Sequence* sequence_; };
[ [ [ 1, 47 ] ] ]
57f03639a6a2b23621a8465f622f7ec04813f520
d7df4671497eadc8f86567ed2631bcf2cdb1cd74
/MagicBowl/ClEventManager.h
b59f90bb66d8ff7b54f551350ac41688109d3d0e
[]
no_license
PSP-Archive/MagicBowl
6081838f014ebc7941896d57b01534c71e4d0ad4
0790e93f8072ea7169b6fcd9f20d1b66e5066c3d
refs/heads/master
2023-06-25T03:33:33.083679
2010-08-29T14:22:14
2010-08-29T14:22:14
388,950,939
0
0
null
null
null
null
WINDOWS-1250
C++
false
false
1,454
h
/* * ClEventManager.h * * Copyright (C) 2010 André Borrmann * * This program is free software; * you can redistribute it and/or modify it under the terms of the * GNU General Public License as published by the Free Software Foundation; * either version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * You should have received a copy of the GNU General Public License along with this program; * if not, see <http://www.gnu.org/licenses/>. */ #ifndef CLEVENTMANAGER_H_ #define CLEVENTMANAGER_H_ #include <vector> using namespace std; typedef unsigned int EventId; typedef void (*EventCallback)(void* object, void* parameter); typedef struct Event{ EventId id; EventCallback callback; void* cbTrigger; void* cbObject; void* cbParam; bool triggered; } Event; class ClEventManager { public: static EventId registerEvent(void* trigger, void* reciever, EventCallback evtCallback, void* cbParameter = 0); static bool triggerEvent(EventId evId); static bool triggerEvent(void* triggerObject); static void resetTrigger(void* triggerObject); protected: static std::vector<Event> events; }; #endif /* CLEVENTMANAGER_H_ */
[ "anmabagima@d0c0c054-8719-4030-88c3-0e07ff0e07ca" ]
[ [ [ 1, 50 ] ] ]
e76aea584618cbcf678f03f7ea7659635c332ea8
1193b8d2ab6bb40ce2adbf9ada5b3d1124f1abb3
/trunk/libsonetto/src/SonettoModule.cpp
6d9722fb8067c45cdffbc5d632f1600ba90a52b3
[]
no_license
sonetto/legacy
46bb60ef8641af618d22c08ea198195fd597240b
e94a91950c309fc03f9f52e6bc3293007c3a0bd1
refs/heads/master
2021-01-01T16:45:02.531831
2009-09-10T21:50:42
2009-09-10T21:50:42
32,183,635
0
2
null
null
null
null
UTF-8
C++
false
false
4,499
cpp
/*----------------------------------------------------------------------------- Copyright (c) 2009, Sonetto Project Developers 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 Sonetto Project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -----------------------------------------------------------------------------*/ #include "SonettoModule.h" #include "SonettoKernel.h" namespace Sonetto { // ---------------------------------------------------------------------- void Module::initialize() { Kernel *kernel = Kernel::getSingletonPtr(); if (kernel->getRenderWindow()->getNumViewports() > 0) { kernel->getRenderWindow()->removeAllViewports(); } // Create the scene manager for this module. mSceneMan = Ogre::Root::getSingleton(). createSceneManager(Ogre::ST_GENERIC); mCamera = mSceneMan->createCamera(Ogre::StringUtil::BLANK); mViewport = kernel->getRenderWindow()->addViewport(mCamera); mCamera->setAspectRatio(kernel->mAspectRatio); setBgColor(mBgColor); mOverlay = Ogre::OverlayManager::getSingleton().create(mOverlayName); mOverlay->show(); } // ---------------------------------------------------------------------- void Module::update() { mCamera->setAspectRatio(Kernel::getSingletonPtr()->mAspectRatio); } // ---------------------------------------------------------------------- void Module::deinitialize() { Kernel * kernel = Kernel::getSingletonPtr(); mOverlay->clear(); kernel->mOverlayMan->destroy(mOverlay); if (kernel->getRenderWindow()->getNumViewports() != 0) kernel->getRenderWindow()->removeAllViewports(); mViewport = NULL; mSceneMan->clearScene(); mSceneMan->destroyCamera(mCamera); Ogre::Root::getSingleton().destroySceneManager(mSceneMan); mSceneMan = NULL; } // ---------------------------------------------------------------------- void Module::halt() { Kernel * kernel = Kernel::getSingletonPtr(); if (kernel->getRenderWindow()->getNumViewports() != 0) kernel->getRenderWindow()->removeAllViewports(); mViewport = NULL; } // ---------------------------------------------------------------------- void Module::resume() { Kernel * kernel = Kernel::getSingletonPtr(); if (kernel->getRenderWindow()->getNumViewports() != 0) kernel->getRenderWindow()->removeAllViewports(); mViewport = kernel->getRenderWindow()->addViewport(mCamera); setBgColor(mBgColor); mCamera->setAspectRatio(kernel->mAspectRatio); } // ---------------------------------------------------------------------- void Module::setBgColor(const Ogre::ColourValue &col) { mBgColor = col; mViewport->setBackgroundColour(mBgColor); } // ---------------------------------------------------------------------- } // namespace
[ [ [ 1, 37 ], [ 42, 42 ], [ 44, 45 ], [ 48, 48 ], [ 50, 51 ], [ 53, 53 ], [ 55, 75 ], [ 77, 105 ] ], [ [ 38, 41 ], [ 43, 43 ], [ 46, 47 ], [ 49, 49 ], [ 52, 52 ], [ 54, 54 ], [ 76, 76 ] ] ]
43f6ed631256f3aa6c8f9e247c62016d5ff6b883
221e3e713891c951e674605eddd656f3a4ce34df
/core/OUE/Shape.cpp
90fe613d92cee5954af54d4c961554f51a23f4d3
[ "MIT" ]
permissive
zacx-z/oneu-engine
da083f817e625c9e84691df38349eab41d356b76
d47a5522c55089a1e6d7109cebf1c9dbb6860b7d
refs/heads/master
2021-05-28T12:39:03.782147
2011-10-18T12:33:45
2011-10-18T12:33:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,565
cpp
/* This source file is part of OneU Engine. Copyright (c) 2011 Ladace Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "Shape.h" #include "Impl/DXVideo.h" #include "Game.h" #include "Impl/DXLib/VertexUP.h" #include "Impl/DXLib/TStage.h" namespace OneU { class Shape_Rect : public IShape { rect m_Rect; color_t m_Color; bool m_bBorder; public: Shape_Rect(const rect& rc) : m_Rect(rc), m_Color(255, 255, 255), m_bBorder(false){ this->create2DTransform(); } void setColor(color_t color){ m_Color = color; } color_t getColor(){ return m_Color; } void setMode(bool bBorder){m_bBorder = bBorder; } bool getMode(){ return m_bBorder;} void paint(); void _describe(String& buffer, int depth){ buffer.append(L"<shape rect>\n"); } }; void Shape_Rect::paint(){ GetVideo().setBlendMode(video::BM_NORMAL); static DX::VertexUP< DX::FVF_XYZ | DX::FVF_DIFFUSE > v[5]; DX::TStage(0).DisableTexture(); v[0].SetPos(m_Rect.left, m_Rect.top); v[1].SetPos(m_Rect.left, m_Rect.bottom); v[2].SetPos(m_Rect.right, m_Rect.bottom); v[3].SetPos(m_Rect.right, m_Rect.top); v[4].SetPos(m_Rect.left, m_Rect.top); v[0].Diffuse() = v[1].Diffuse() = v[2].Diffuse() = v[3].Diffuse() = v[4].Diffuse() = m_Color; DX::Graphics.SetFVF(v); if(m_bBorder) g_pRD->RenderVertexUP(DX::RenderManip::PT_LINESTRIP, v, 4); else g_pRD->RenderVertexUP(DX::RenderManip::PT_TRIANGLEFAN, v, 2); } ONEU_API IShape* Shape_rect(const rect& rc){ return ONEU_NEW Shape_Rect(rc); } }
[ "[email protected]@d30a3831-f586-b1a3-add9-2db6dc386f9c" ]
[ [ [ 1, 77 ] ] ]
64c1b4f8cc30a0cee545fdf3db16efd2f00dd981
8d2ef01bfa0b7ed29cf840da33e8fa10f2a69076
/code/Materials/fxTexture_win.cpp
f7dc72a83f319d7f63aa6e430a23fb865455c943
[]
no_license
BackupTheBerlios/insane
fb4c5c6a933164630352295692bcb3e5163fc4bc
7dc07a4eb873d39917da61e0a21e6c4c843b2105
refs/heads/master
2016-09-05T11:28:43.517158
2001-01-31T20:46:38
2001-01-31T20:46:38
40,043,333
0
0
null
null
null
null
UTF-8
C++
false
false
1,053
cpp
#ifdef _WIN32 #include "fxTexture.h" // load a bitmap using windows api... bool fxTexture::LoadBMP(char * filename) { HBITMAP bmp = (HBITMAP)LoadImage(NULL,filename,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION); if (!bmp) return false; HDC dc = CreateCompatibleDC(NULL); SelectObject(dc, bmp); BITMAP bmi; GetObject(bmp, sizeof(BITMAP),&bmi); width = bmi.bmWidth; height = bmi.bmHeight; bpp = bmi.bmBitsPixel / 8; mem = (unsigned char*)malloc(width*height*bpp); BITMAPINFO bmp_info; bmp_info.bmiHeader.biSize=sizeof(BITMAPINFOHEADER); bmp_info.bmiHeader.biWidth=width; bmp_info.bmiHeader.biHeight=height; bmp_info.bmiHeader.biPlanes=1; bmp_info.bmiHeader.biBitCount=24; bmp_info.bmiHeader.biCompression=BI_RGB; GetDIBits(dc, bmp, 0, height, mem, &bmp_info,DIB_RGB_COLORS); unsigned char * c1 = (unsigned char *) mem; unsigned char * c3 = (unsigned char *) mem + 2; for (int i=0; i<width*height; i++) { unsigned char t; t = *c1; *c1 = *c3; *c3 = t; c1+=3; c3+=3; } return true; } #endif
[ "josef" ]
[ [ [ 1, 45 ] ] ]
78afa1958ddde0abd992903e72940565a822086f
b4bff7f61d078e3dddeb760e21174a781ed7f985
/Examples/Tutorial/Animation/23BlendXMLAnimations.cpp
fecdbe752d068d8412924e46c7c5661b72c7284e
[]
no_license
Langkamp/OpenSGToolbox
8283edb6074dffba477c2c4d632e954c3c73f4e3
5a4230441e68f001cdf3e08e9f97f9c0f3c71015
refs/heads/master
2021-01-16T18:15:50.951223
2010-05-19T20:24:52
2010-05-19T20:24:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
33,805
cpp
// // OpenSGToolbox Tutorial: 23BlendXMLAnimations // // Creates a SkeletonBlendedAnimation from skeleton // animations stored in two XML files. // #ifdef OSG_BUILD_ACTIVE // General OpenSG configuration, needed everywhere #include <OSGConfig.h> // Methods to create simple geometry: boxes, spheres, tori etc. #include <OSGSimpleGeometry.h> // A little helper to simplify scene management and interaction #include <OSGSimpleSceneManager.h> // Input #include <OSGKeyListener.h> #include <OSGWindowUtils.h> #include <OSGComponentTransform.h> #include <OSGTransform.h> #include <OSGGeometry.h> #include <OSGGradientBackground.h> #include <OSGViewport.h> #include <OSGDirectionalLight.h> #include <OSGBlendGeometry.h> #include <OSGFieldContainerUtils.h> #include <OSGSimpleAttachments.h> //User Interface #include <OSGUIForeground.h> #include <OSGInternalWindow.h> #include <OSGUIDrawingSurface.h> #include <OSGGraphics2D.h> #include <OSGFlowLayout.h> #include <OSGLookAndFeelManager.h> #include <OSGLayers.h> #include <OSGSlider.h> #include <OSGLabel.h> #include <OSGDefaultBoundedRangeModel.h> #include <OSGGLViewport.h> //Material #include <OSGLineChunk.h> #include <OSGBlendChunk.h> #include <OSGChunkMaterial.h> #include <OSGMaterialChunk.h> //Animation #include <OSGSkeleton.h> #include <OSGSkeletonDrawable.h> #include <OSGTime.h> #include <OSGKeyframeSequences.h> #include <OSGFieldAnimation.h> #include <OSGKeyframeAnimator.h> #include <OSGElapsedTimeAnimationAdvancer.h> #include <OSGSimpleAttachments.h> #include <OSGSkeletonAnimation.h> #include <OSGSkeletonBlendedAnimation.h> #include <OSGSkeleton.h> #include <OSGJoint.h> #include <OSGSimpleGeometry.h> #include <OSGSkeletonBlendedGeometry.h> // the general scene file loading handler #include <OSGSceneFileHandler.h> //IO #include <OSGFCFileHandler.h> #else // General OpenSG configuration, needed everywhere #include <OpenSG/OSGConfig.h> // Methods to create simple geometry: boxes, spheres, tori etc. #include <OpenSG/OSGSimpleGeometry.h> // A little helper to simplify scene management and interaction #include <OpenSG/OSGSimpleSceneManager.h> // Input #include <OpenSG/Input/OSGKeyListener.h> #include <OpenSG/Input/OSGWindowUtils.h> #include <OpenSG/OSGComponentTransform.h> #include <OpenSG/OSGTransform.h> #include <OpenSG/OSGGeometry.h> #include <OpenSG/OSGGradientBackground.h> #include <OpenSG/OSGViewport.h> #include <OpenSG/OSGDirectionalLight.h> #include <OpenSG/Animation/OSGBlendGeometry.h> #include <OpenSG/Toolbox/OSGFieldContainerUtils.h> #include <OpenSG/OSGSimpleAttachments.h> //User Interface #include <OpenSG/UserInterface/OSGUIForeground.h> #include <OpenSG/UserInterface/OSGInternalWindow.h> #include <OpenSG/UserInterface/OSGUIDrawingSurface.h> #include <OpenSG/UserInterface/OSGGraphics2D.h> #include <OpenSG/UserInterface/OSGFlowLayout.h> #include <OpenSG/UserInterface/OSGLookAndFeelManager.h> #include <OpenSG/UserInterface/OSGLayers.h> #include <OpenSG/UserInterface/OSGSlider.h> #include <OpenSG/UserInterface/OSGLabel.h> #include <OpenSG/UserInterface/OSGDefaultBoundedRangeModel.h> #include <OpenSG/UserInterface/OSGGLViewport.h> //Material #include <OpenSG/OSGLineChunk.h> #include <OpenSG/OSGBlendChunk.h> #include <OpenSG/OSGChunkMaterial.h> #include <OpenSG/OSGMaterialChunk.h> //Animation #include <OpenSG/Animation/OSGSkeleton.h> #include <OpenSG/Animation/OSGSkeletonDrawable.h> #include <OpenSG/OSGTime.h> #include <OpenSG/Animation/OSGKeyframeSequences.h> #include <OpenSG/Animation/OSGFieldAnimation.h> #include <OpenSG/Animation/OSGKeyframeAnimator.h> #include <OpenSG/Animation/OSGElapsedTimeAnimationAdvancer.h> #include <OpenSG/OSGSimpleAttachments.h> #include <OpenSG/Animation/OSGSkeletonAnimation.h> #include <OpenSG/Animation/OSGSkeletonBlendedAnimation.h> #include <OpenSG/Animation/OSGSkeleton.h> #include <OpenSG/Animation/OSGJoint.h> #include <OpenSG/OSGSimpleGeometry.h> #include <OpenSG/Animation/OSGSkeletonBlendedGeometry.h> // the general scene file loading handler #include <OpenSG/OSGSceneFileHandler.h> //IO #include <OpenSG/Toolbox/OSGFCFileHandler.h> #endif // Activate the OpenSG namespace // This is not strictly necessary, you can also prefix all OpenSG symbols // with OSG::, but that would be a bit tedious for this example OSG_USING_NAMESPACE // The SimpleSceneManager to manage simple applications SimpleSceneManager *mgr; WindowEventProducerPtr TutorialWindowEventProducer; // For the skeleton SkeletonBlendedAnimationPtr TheSkeletonBlendedAnimation; SkeletonAnimationPtr TheWalkingAnimation; SkeletonAnimationPtr TheSecondAnimation; Real32 BlendWalking = 1; Real32 BlendTouchScreen = 1; AnimationAdvancerPtr TheAnimationAdvancer; std::vector<NodePtr> UnboundGeometries; std::vector<NodePtr> SkeletonNodes; std::vector<NodePtr> MeshNodes; // forward declaration so we can have the interesting stuff upfront ComponentPtr createGLPanel(void); bool animationPaused = false; // Forward declaration so we can have the interesting stuff upfront void display(void); void reshape(Vec2f Size); // Create a class to allow for the use of the keyboard shortcuts class TutorialKeyListener : public KeyListener { public: virtual void keyPressed(const KeyEventPtr e) { //Exit if(e->getKey() == KeyEvent::KEY_Q && e->getModifiers() & KeyEvent::KEY_MODIFIER_CONTROL) { TutorialWindowEventProducer->closeWindow(); } //Toggle animation if(e->getKey() == KeyEvent::KEY_SPACE) { if(animationPaused) animationPaused = false; else animationPaused = true; } //Toggle bind pose if(e->getKey() == KeyEvent::KEY_B) { if(e->getModifiers() & KeyEvent::KEY_MODIFIER_SHIFT) { //Toggle mesh for(int i(0); i < UnboundGeometries.size(); ++i) { if(UnboundGeometries[i]->getTravMask() == 0) { beginEditCP(UnboundGeometries[i], Node::TravMaskFieldMask); UnboundGeometries[i]->setTravMask(1); endEditCP(UnboundGeometries[i], Node::TravMaskFieldMask); } else { beginEditCP(UnboundGeometries[i], Node::TravMaskFieldMask); UnboundGeometries[i]->setTravMask(0); endEditCP(UnboundGeometries[i], Node::TravMaskFieldMask); } } } else { //Toggle skeleton for(int i(0); i < SkeletonNodes.size(); ++i) { if(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore())->getDrawBindPose() == false) { beginEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore()), SkeletonDrawable::DrawBindPoseFieldMask); SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore())->setDrawBindPose(true); endEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore()), SkeletonDrawable::DrawBindPoseFieldMask); } else { beginEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore()), SkeletonDrawable::DrawBindPoseFieldMask); SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore())->setDrawBindPose(false); endEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore()), SkeletonDrawable::DrawBindPoseFieldMask); } } } } //Toggle current pose if(e->getKey() == KeyEvent::KEY_P) { if(e->getModifiers() & KeyEvent::KEY_MODIFIER_SHIFT) { //Toggle mesh for(int i(0); i < MeshNodes.size(); ++i) { if(MeshNodes[i]->getTravMask() == 0) { beginEditCP(MeshNodes[i], Node::TravMaskFieldMask); MeshNodes[i]->setTravMask(1); endEditCP(MeshNodes[i], Node::TravMaskFieldMask); } else { beginEditCP(MeshNodes[i], Node::TravMaskFieldMask); MeshNodes[i]->setTravMask(0); endEditCP(MeshNodes[i], Node::TravMaskFieldMask); } } } else { //Toggle skeleton for(int i(0); i < SkeletonNodes.size(); ++i) { if(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore())->getDrawPose() == false) { beginEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore()), SkeletonDrawable::DrawPoseFieldMask); SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore())->setDrawPose(true); endEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore()), SkeletonDrawable::DrawPoseFieldMask); } else { beginEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore()), SkeletonDrawable::DrawPoseFieldMask); SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore())->setDrawPose(false); endEditCP(SkeletonDrawable::Ptr::dcast(SkeletonNodes[i]->getCore()), SkeletonDrawable::DrawPoseFieldMask); } } } } //Toggle override status on second animation if(e->getKey() == KeyEvent::KEY_O) { if(TheSkeletonBlendedAnimation->getOverrideStatus(1)) { TheSkeletonBlendedAnimation->setOverrideStatus(1, false); } else { TheSkeletonBlendedAnimation->setOverrideStatus(1, true); } } } virtual void keyReleased(const KeyEventPtr e) { } virtual void keyTyped(const KeyEventPtr e) { } }; class TutorialMouseListener : public MouseListener { public: virtual void mouseClicked(const MouseEventPtr e) { } virtual void mouseEntered(const MouseEventPtr e) { } virtual void mouseExited(const MouseEventPtr e) { } virtual void mousePressed(const MouseEventPtr e) { mgr->mouseButtonPress(e->getButton(), e->getLocation().x(), e->getLocation().y()); } virtual void mouseReleased(const MouseEventPtr e) { mgr->mouseButtonRelease(e->getButton(), e->getLocation().x(), e->getLocation().y()); } }; class TutorialMouseMotionListener : public MouseMotionListener { public: virtual void mouseMoved(const MouseEventPtr e) { mgr->mouseMove(e->getLocation().x(), e->getLocation().y()); } virtual void mouseDragged(const MouseEventPtr e) { mgr->mouseMove(e->getLocation().x(), e->getLocation().y()); } }; class TutorialUpdateListener : public UpdateListener { public: virtual void update(const UpdateEventPtr e) { if(!animationPaused) { ElapsedTimeAnimationAdvancer::Ptr::dcast(TheAnimationAdvancer)->update(e->getElapsedTime()); TheSkeletonBlendedAnimation->update(TheAnimationAdvancer); } } }; //Create a listener to let us change the SkeletonBlendedAnimation's blend amounts at runtime class BlendAmountSliderChangeListener : public ChangeListener { public: BlendAmountSliderChangeListener(SkeletonBlendedAnimationPtr TheSkeletonBlendedAnimation, UInt32 BlendAmountIndex, SliderPtr TheSlider) : _SkeletonBlendedAnimation(TheSkeletonBlendedAnimation),_BlendAmountIndex(BlendAmountIndex),_Slider(TheSlider) { } virtual void stateChanged(const ChangeEventPtr e) { if(_Slider != NullFC && _SkeletonBlendedAnimation != NullFC) { _SkeletonBlendedAnimation->setBlendAmount(_BlendAmountIndex,static_cast<Real32>(_Slider->getValue())/100.0f); } } protected: SkeletonBlendedAnimationPtr _SkeletonBlendedAnimation; UInt32 _BlendAmountIndex; SliderPtr _Slider; }; class NamedNodeFinder { public: NamedNodeFinder(void) : _name(), _found() {} NodePtr operator() (NodePtr root, std::string name) { _name=&name; _found=NullFC; traverse(root, osgTypedMethodFunctor1ObjPtrCPtrRef( this, &NamedNodeFinder::check)); return _found; } static NodePtr find(NodePtr root, std::string name) { NamedNodeFinder f; return f(root,name); } private: Action::ResultE check(NodePtr& node) { if(getName(node) && *_name == getName(node)) { _found = node; return Action::Quit; } return Action::Continue; } NodePtr _found; std::string *_name; }; // Initialize OpenSG and set up the scene int main(int argc, char **argv) { // OSG init osgInit(argc,argv); // Set up Window TutorialWindowEventProducer = createDefaultWindowEventProducer(); WindowPtr MainWindow = TutorialWindowEventProducer->initWindow(); TutorialWindowEventProducer->setDisplayCallback(display); TutorialWindowEventProducer->setReshapeCallback(reshape); //Add Window Listener TutorialKeyListener TheKeyListener; TutorialWindowEventProducer->addKeyListener(&TheKeyListener); TutorialMouseListener TheTutorialMouseListener; TutorialMouseMotionListener TheTutorialMouseMotionListener; TutorialWindowEventProducer->addMouseListener(&TheTutorialMouseListener); TutorialWindowEventProducer->addMouseMotionListener(&TheTutorialMouseMotionListener); TutorialUpdateListener TheTutorialUpdateListener; TutorialWindowEventProducer->addUpdateListener(&TheTutorialUpdateListener); // Create the SimpleSceneManager helper mgr = new SimpleSceneManager; // Tell the Manager what to manage mgr->setWindow(MainWindow); //Print key command info std::cout << "\n\nKEY COMMANDS:" << std::endl; std::cout << "space Play/Pause the animation" << std::endl; std::cout << "B Show/Hide the bind pose skeleton" << std::endl; std::cout << "SHIFT-B Show/Hide the bind pose mesh" << std::endl; std::cout << "P Show/Hide the current pose skeleton" << std::endl; std::cout << "SHIFT-P Show/Hide the current pose mesh" << std::endl; std::cout << "O Toggle override status of TheSecondAnimation" << std::endl; std::cout << "CTRL-Q Exit\n\n" << std::endl; //Import scene from XML ChunkMaterialPtr ExampleMaterial; std::vector<SkeletonPtr> SkeletonPtrs; std::vector<SkeletonBlendedGeometryPtr> SkeletonBlendedGeometryPtrs; std::vector<GeometryPtr> GeometryPtrs; //Skeleton materaial LineChunkPtr SkelLineChunk = LineChunk::create(); beginEditCP(SkelLineChunk); SkelLineChunk->setWidth(0.0f); SkelLineChunk->setSmooth(true); endEditCP(SkelLineChunk); ChunkMaterialPtr SkelMaterial = ChunkMaterial::create(); beginEditCP(SkelMaterial, ChunkMaterial::ChunksFieldMask); SkelMaterial->addChunk(SkelLineChunk); endEditCP(SkelMaterial, ChunkMaterial::ChunksFieldMask); //LOAD FIRST ANIMATION FCFileType::FCPtrStore NewContainers; NewContainers = FCFileHandler::the()->read(BoostPath("./Data/23WalkingAnimation.xml")); FCFileType::FCPtrStore::iterator Itor; for(Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor) { if( (*Itor)->getType() == (ChunkMaterial::getClassType())) { //Set ExampleMaterial to the ChunkMaterial we just read in ExampleMaterial = (ChunkMaterial::Ptr::dcast(*Itor)); } if( (*Itor)->getType() == (Skeleton::getClassType())) { //Add the Skeleton we just read in to SkeletonPtrs SkeletonPtrs.push_back(Skeleton::Ptr::dcast(*Itor)); } if( (*Itor)->getType() == (SkeletonBlendedGeometry::getClassType())) { //Add the SkeletonBlendedGeometry we just read in to SkeletonBlendedGeometryPtrs SkeletonBlendedGeometryPtrs.push_back(SkeletonBlendedGeometry::Ptr::dcast(*Itor)); } if( (*Itor)->getType().isDerivedFrom(SkeletonAnimation::getClassType())) { //Set TheWalkingAnimation to the SkeletonAnimation we just read in TheWalkingAnimation = (SkeletonAnimation::Ptr::dcast(*Itor)); } if( (*Itor)->getType() == (Geometry::getClassType())) { //Add the Geometry we just read in to GeometryPtrs GeometryPtrs.push_back(Geometry::Ptr::dcast(*Itor)); } } //LOAD SECOND ANIMATION NewContainers = FCFileHandler::the()->read(BoostPath("./Data/23SamAnimation.xml")); for(Itor = NewContainers.begin() ; Itor != NewContainers.end() ; ++Itor) { //Import only the skeletonAnimation from the second XML file; we've already imported the skeleton and the geometry if( (*Itor)->getType().isDerivedFrom(SkeletonAnimation::getClassType())) { TheSecondAnimation = (SkeletonAnimation::Ptr::dcast(*Itor)); } } //Blend the two animations TheSkeletonBlendedAnimation = SkeletonBlendedAnimation::create(); beginEditCP(TheSkeletonBlendedAnimation); TheSkeletonBlendedAnimation->addAnimationBlending(TheWalkingAnimation, BlendWalking, false); TheSkeletonBlendedAnimation->addAnimationBlending(TheSecondAnimation, BlendTouchScreen, false); endEditCP(TheSkeletonBlendedAnimation); //Create unbound geometry Node (to show the mesh in its bind pose) for (int i(0); i < GeometryPtrs.size(); ++i) { NodePtr UnboundGeometry = Node::create(); beginEditCP(UnboundGeometry, Node::CoreFieldMask | Node::TravMaskFieldMask); UnboundGeometry->setCore(GeometryPtrs[i]); UnboundGeometry->setTravMask(0); //By default, we don't show the mesh in its bind pose. endEditCP(UnboundGeometry, Node::CoreFieldMask | Node::TravMaskFieldMask); UnboundGeometries.push_back(UnboundGeometry); } //Create skeleton nodes for (int i(0); i < SkeletonPtrs.size(); ++i) { //SkeletonDrawer SkeletonDrawablePtr ExampleSkeletonDrawable = osg::SkeletonDrawable::create(); beginEditCP(ExampleSkeletonDrawable, SkeletonDrawable::SkeletonFieldMask | SkeletonDrawable::MaterialFieldMask | SkeletonDrawable::DrawPoseFieldMask | SkeletonDrawable::PoseColorFieldMask | SkeletonDrawable::DrawBindPoseFieldMask | SkeletonDrawable::BindPoseColorFieldMask); ExampleSkeletonDrawable->setSkeleton(SkeletonPtrs[i]); ExampleSkeletonDrawable->setMaterial(SkelMaterial); ExampleSkeletonDrawable->setDrawPose(true); //By default we draw the current skeleton ExampleSkeletonDrawable->setPoseColor(Color4f(1.0, 0.0, 1.0, 1.0)); //Set color of current skeleton ExampleSkeletonDrawable->setDrawBindPose(false); //By default we don't draw the bind pose skeleton ExampleSkeletonDrawable->setBindPoseColor(Color4f(1.0, 1.0, 0.0, 1.0)); //Set color of bind pose skeleton endEditCP(ExampleSkeletonDrawable, SkeletonDrawable::SkeletonFieldMask | SkeletonDrawable::MaterialFieldMask | SkeletonDrawable::DrawPoseFieldMask | SkeletonDrawable::PoseColorFieldMask | SkeletonDrawable::DrawBindPoseFieldMask | SkeletonDrawable::BindPoseColorFieldMask); //Skeleton Node NodePtr SkeletonNode = osg::Node::create(); beginEditCP(SkeletonNode, Node::CoreFieldMask); SkeletonNode->setCore(ExampleSkeletonDrawable); endEditCP(SkeletonNode, Node::CoreFieldMask); SkeletonNodes.push_back(SkeletonNode); } //Create skeleton blended geometry nodes for (int i(0); i < SkeletonBlendedGeometryPtrs.size(); ++i) { NodePtr MeshNode = osg::Node::create(); beginEditCP(MeshNode, Node::CoreFieldMask); MeshNode->setCore(SkeletonBlendedGeometryPtrs[i]); endEditCP(MeshNode, Node::CoreFieldMask); MeshNodes.push_back(MeshNode); } //Setup scene NodePtr EmptyScene = osg::Node::create(); beginEditCP(EmptyScene, Node::CoreFieldMask); EmptyScene->setCore(Group::create()); endEditCP (EmptyScene, Node::CoreFieldMask); mgr->setRoot(EmptyScene); //User Interface // Create the Graphics GraphicsPtr TutorialGraphics = osg::Graphics2D::create(); // Initialize the LookAndFeelManager to enable default settings LookAndFeelManager::the()->getLookAndFeel()->init(); // Create the DefaultBoundedRangeModelPtr and // set its values DefaultBoundedRangeModelPtr UpperAnimationSliderRangeModel = DefaultBoundedRangeModel::create(); UpperAnimationSliderRangeModel->setMinimum(0); UpperAnimationSliderRangeModel->setMaximum(100); UpperAnimationSliderRangeModel->setValue(BlendWalking * 100); UpperAnimationSliderRangeModel->setExtent(0); //Create the upper animation blend amount slider LabelPtr TempLabel; SliderPtr UpperAnimationSlider = Slider::create(); beginEditCP(UpperAnimationSlider, Slider::LabelMapFieldMask | Slider::PreferredSizeFieldMask | Slider::MajorTickSpacingFieldMask | Slider::MinorTickSpacingFieldMask | Slider::SnapToTicksFieldMask | Slider::DrawLabelsFieldMask | Slider::RangeModelFieldMask); //Label the slider TempLabel = Label::Ptr::dcast(UpperAnimationSlider->getLabelPrototype()->shallowCopy()); beginEditCP(TempLabel, Label::TextFieldMask); TempLabel->setText("0.0"); endEditCP(TempLabel, Label::TextFieldMask); UpperAnimationSlider->getLabelMap()[0] = TempLabel; TempLabel = Label::Ptr::dcast(UpperAnimationSlider->getLabelPrototype()->shallowCopy()); beginEditCP(TempLabel, Label::TextFieldMask); TempLabel->setText("1.0"); endEditCP(TempLabel, Label::TextFieldMask); UpperAnimationSlider->getLabelMap()[100] = TempLabel; //Customize the slider UpperAnimationSlider->setPreferredSize(Vec2f(100, 300)); UpperAnimationSlider->setSnapToTicks(false); UpperAnimationSlider->setMajorTickSpacing(10); UpperAnimationSlider->setMinorTickSpacing(5); UpperAnimationSlider->setOrientation(Slider::VERTICAL_ORIENTATION); UpperAnimationSlider->setInverted(true); UpperAnimationSlider->setDrawLabels(true); UpperAnimationSlider->setRangeModel(UpperAnimationSliderRangeModel); endEditCP(UpperAnimationSlider, Slider::LabelMapFieldMask | Slider::PreferredSizeFieldMask | Slider::MajorTickSpacingFieldMask | Slider::MinorTickSpacingFieldMask | Slider::SnapToTicksFieldMask | Slider::DrawLabelsFieldMask | Slider::RangeModelFieldMask); DefaultBoundedRangeModelPtr LowerAnimationSliderRangeModel = DefaultBoundedRangeModel::create(); LowerAnimationSliderRangeModel->setMinimum(0); LowerAnimationSliderRangeModel->setMaximum(100); LowerAnimationSliderRangeModel->setValue(BlendTouchScreen * 100); LowerAnimationSliderRangeModel->setExtent(0); //Create the lower animation blend amount slider SliderPtr LowerAnimationSlider = Slider::create(); beginEditCP(LowerAnimationSlider, Slider::LabelMapFieldMask | Slider::PreferredSizeFieldMask | Slider::MajorTickSpacingFieldMask | Slider::MinorTickSpacingFieldMask | Slider::SnapToTicksFieldMask | Slider::DrawLabelsFieldMask | Slider::RangeModelFieldMask); //Label the slider TempLabel = Label::Ptr::dcast(LowerAnimationSlider->getLabelPrototype()->shallowCopy()); beginEditCP(TempLabel, Label::TextFieldMask); TempLabel->setText("0.0"); endEditCP(TempLabel, Label::TextFieldMask); LowerAnimationSlider->getLabelMap()[0] = TempLabel; TempLabel = Label::Ptr::dcast(LowerAnimationSlider->getLabelPrototype()->shallowCopy()); beginEditCP(TempLabel, Label::TextFieldMask); TempLabel->setText("1.0"); endEditCP(TempLabel, Label::TextFieldMask); LowerAnimationSlider->getLabelMap()[100] = TempLabel; //Customize the slider LowerAnimationSlider->setPreferredSize(Vec2f(100, 300)); LowerAnimationSlider->setSnapToTicks(false); LowerAnimationSlider->setMajorTickSpacing(10); LowerAnimationSlider->setMinorTickSpacing(5); LowerAnimationSlider->setOrientation(Slider::VERTICAL_ORIENTATION); LowerAnimationSlider->setInverted(true); LowerAnimationSlider->setDrawLabels(true); LowerAnimationSlider->setRangeModel(LowerAnimationSliderRangeModel); endEditCP(LowerAnimationSlider, Slider::LabelMapFieldMask | Slider::PreferredSizeFieldMask | Slider::MajorTickSpacingFieldMask | Slider::MinorTickSpacingFieldMask | Slider::SnapToTicksFieldMask | Slider::DrawLabelsFieldMask | Slider::RangeModelFieldMask); // Create Background to be used with the MainFrame ColorLayerPtr MainFrameBackground = osg::ColorLayer::create(); beginEditCP(MainFrameBackground, ColorLayer::ColorFieldMask); MainFrameBackground->setColor(Color4f(1.0,1.0,1.0,0.5)); endEditCP(MainFrameBackground, ColorLayer::ColorFieldMask); // Create The Main InternalWindow // Create Background to be used with the Main InternalWindow ColorLayerPtr MainInternalWindowBackground = osg::ColorLayer::create(); beginEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask); MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5)); endEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask); LayoutPtr MainInternalWindowLayout = osg::FlowLayout::create(); //GL Viewport ComponentPtr TheGLViewport = createGLPanel(); InternalWindowPtr MainInternalWindow = osg::InternalWindow::create(); beginEditCP(MainInternalWindow, InternalWindow::ChildrenFieldMask | InternalWindow::LayoutFieldMask | InternalWindow::BackgroundsFieldMask | InternalWindow::AlignmentInDrawingSurfaceFieldMask | InternalWindow::ScalingInDrawingSurfaceFieldMask | InternalWindow::DrawTitlebarFieldMask | InternalWindow::ResizableFieldMask); MainInternalWindow->getChildren().push_back(UpperAnimationSlider); MainInternalWindow->getChildren().push_back(LowerAnimationSlider); MainInternalWindow->getChildren().push_back(TheGLViewport); MainInternalWindow->setLayout(MainInternalWindowLayout); MainInternalWindow->setBackgrounds(MainInternalWindowBackground); MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f)); MainInternalWindow->setScalingInDrawingSurface(Vec2f(1.0f,1.0f)); MainInternalWindow->setDrawTitlebar(false); MainInternalWindow->setResizable(false); endEditCP(MainInternalWindow, InternalWindow::ChildrenFieldMask | InternalWindow::LayoutFieldMask | InternalWindow::BackgroundsFieldMask | InternalWindow::AlignmentInDrawingSurfaceFieldMask | InternalWindow::ScalingInDrawingSurfaceFieldMask | InternalWindow::DrawTitlebarFieldMask | InternalWindow::ResizableFieldMask); // Create the Drawing Surface UIDrawingSurfacePtr TutorialDrawingSurface = UIDrawingSurface::create(); beginEditCP(TutorialDrawingSurface, UIDrawingSurface::GraphicsFieldMask | UIDrawingSurface::EventProducerFieldMask); TutorialDrawingSurface->setGraphics(TutorialGraphics); TutorialDrawingSurface->setEventProducer(TutorialWindowEventProducer); endEditCP(TutorialDrawingSurface, UIDrawingSurface::GraphicsFieldMask | UIDrawingSurface::EventProducerFieldMask); TutorialDrawingSurface->openWindow(MainInternalWindow); // Create the UI Foreground Object UIForegroundPtr TutorialUIForeground = osg::UIForeground::create(); beginEditCP(TutorialUIForeground, UIForeground::DrawingSurfaceFieldMask); TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface); endEditCP(TutorialUIForeground, UIForeground::DrawingSurfaceFieldMask); ViewportPtr TutorialViewport = mgr->getWindow()->getPort(0); beginEditCP(TutorialViewport, Viewport::ForegroundsFieldMask); TutorialViewport->getForegrounds().push_back(TutorialUIForeground); beginEditCP(TutorialViewport, Viewport::ForegroundsFieldMask); //Attach the Slider Listeners BlendAmountSliderChangeListener UpperAnimationSliderListener(TheSkeletonBlendedAnimation, 0, UpperAnimationSlider); UpperAnimationSlider->addChangeListener(&UpperAnimationSliderListener); BlendAmountSliderChangeListener LowerAnimationSliderListener(TheSkeletonBlendedAnimation, 1, LowerAnimationSlider); LowerAnimationSlider->addChangeListener(&LowerAnimationSliderListener); //Animation Advancer TheAnimationAdvancer = ElapsedTimeAnimationAdvancer::create(); beginEditCP(TheAnimationAdvancer); ElapsedTimeAnimationAdvancer::Ptr::dcast(TheAnimationAdvancer)->setStartTime( 0.0 ); beginEditCP(TheAnimationAdvancer); // Show the whole Scene mgr->showAll(); TheAnimationAdvancer->start(); //Show window Vec2f WinSize(TutorialWindowEventProducer->getDesktopSize() * 0.85f); Pnt2f WinPos((TutorialWindowEventProducer->getDesktopSize() - WinSize) *0.5); TutorialWindowEventProducer->openWindow(WinPos, WinSize, "23BlendXMLAnimations"); //Enter main Loop TutorialWindowEventProducer->mainLoop(); osgExit(); return 0; } // redraw the window void display(void) { mgr->redraw(); } // React to size changes void reshape(Vec2f Size) { mgr->resize(Size.x(), Size.y()); } NodePtr createScene(void) { //Make Main Scene Node NodePtr scene = osg::Node::create(); osg::ComponentTransformPtr Trans; Trans = osg::ComponentTransform::create(); osg::setName(Trans, std::string("MainTransformationCore")); beginEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask); scene->setCore(Trans); for (int i(0); i < SkeletonNodes.size(); ++i) { scene->addChild(SkeletonNodes[i]); } for (int i(0); i < UnboundGeometries.size(); ++i) { scene->addChild(UnboundGeometries[i]); } for (int i(0); i < MeshNodes.size(); ++i) { scene->addChild(MeshNodes[i]); } endEditCP (scene, Node::CoreFieldMask | Node::ChildrenFieldMask); return scene; } ComponentPtr createGLPanel(void) { //Create the nessicary parts for a viewport //Camera Beacon Matrix TransformMatrix; TransformMatrix.setTranslate(0.0f,0.0f, 0.0f); TransformPtr CameraBeaconTransform = Transform::create(); beginEditCP(CameraBeaconTransform, Transform::MatrixFieldMask); CameraBeaconTransform->setMatrix(TransformMatrix); endEditCP(CameraBeaconTransform, Transform::MatrixFieldMask); NodePtr CameraBeaconNode = Node::create(); beginEditCP(CameraBeaconNode, Node::CoreFieldMask); CameraBeaconNode->setCore(CameraBeaconTransform); endEditCP(CameraBeaconNode, Node::CoreFieldMask); //Light Beacon Matrix LightTransformMatrix; LightTransformMatrix.setTranslate(0.0f,0.0f, 0.0f); TransformPtr LightBeaconTransform = Transform::create(); beginEditCP(LightBeaconTransform, Transform::MatrixFieldMask); LightBeaconTransform->setMatrix(TransformMatrix); endEditCP(LightBeaconTransform, Transform::MatrixFieldMask); NodePtr LightBeaconNode = Node::create(); beginEditCP(LightBeaconNode, Node::CoreFieldMask); LightBeaconNode->setCore(CameraBeaconTransform); endEditCP(LightBeaconNode, Node::CoreFieldMask); //Light Node DirectionalLightPtr TheDirectionLight = DirectionalLight::create(); beginEditCP(TheDirectionLight, DirectionalLight::DirectionFieldMask); TheDirectionLight->setDirection(0.0f,1.0f,0.0f); endEditCP(TheDirectionLight, DirectionalLight::DirectionFieldMask); NodePtr LightNode = Node::create(); beginEditCP(LightNode, Node::CoreFieldMask | Node::ChildrenFieldMask); LightNode->setCore(TheDirectionLight); LightNode->addChild(createScene()); endEditCP(LightNode, Node::CoreFieldMask | Node::ChildrenFieldMask); // Make Torus Node (creates Torus in background of scene) NodePtr GeometryNode = makeTorus(.5, 2, 32, 32); // Make Main Scene Node and add the Torus NodePtr DefaultRootNode = osg::Node::create(); beginEditCP(DefaultRootNode, Node::CoreFieldMask | Node::ChildrenFieldMask); DefaultRootNode->setCore(osg::Group::create()); DefaultRootNode->addChild(CameraBeaconNode); DefaultRootNode->addChild(LightBeaconNode); DefaultRootNode->addChild(LightNode); endEditCP(DefaultRootNode, Node::CoreFieldMask | Node::ChildrenFieldMask); //Camera PerspectiveCameraPtr DefaultCamera = PerspectiveCamera::create(); beginEditCP(DefaultCamera); DefaultCamera->setBeacon(CameraBeaconNode); DefaultCamera->setFov (deg2rad(60.f)); DefaultCamera->setNear (0.1f); DefaultCamera->setFar (100.f); endEditCP(DefaultCamera); //Background GradientBackgroundPtr DefaultBackground = GradientBackground::create(); beginEditCP(DefaultBackground, GradientBackground::ColorFieldMask | GradientBackground::PositionFieldMask); DefaultBackground->addLine(Color3f(0.0f,0.0f,0.0f), 0.0f); DefaultBackground->addLine(Color3f(0.0f,0.0f,1.0f), 1.0f); endEditCP(DefaultBackground, GradientBackground::ColorFieldMask | GradientBackground::PositionFieldMask); //Viewport ViewportPtr DefaultViewport = Viewport::create(); beginEditCP(DefaultViewport); DefaultViewport->setCamera (DefaultCamera); DefaultViewport->setRoot (DefaultRootNode); DefaultViewport->setSize (0.0f,0.0f, 1.0f,1.0f); DefaultViewport->setBackground (DefaultBackground); endEditCP(DefaultViewport); //GL Viewport Component GLViewportPtr TheGLViewport = GLViewport::create(); beginEditCP(TheGLViewport, GLViewport::PortFieldMask | GLViewport::PreferredSizeFieldMask | GLViewport::BordersFieldMask); TheGLViewport->setPort(DefaultViewport); TheGLViewport->setPreferredSize(Vec2f(1024.0f,768.0f)); endEditCP(TheGLViewport, GLViewport::PortFieldMask | GLViewport::PreferredSizeFieldMask | GLViewport::BordersFieldMask); TheGLViewport->showAll(); return TheGLViewport; }
[ [ [ 1, 7 ], [ 76, 141 ], [ 143, 150 ], [ 152, 177 ], [ 179, 180 ], [ 182, 182 ], [ 184, 186 ], [ 188, 196 ], [ 198, 198 ], [ 200, 239 ], [ 241, 241 ], [ 243, 282 ], [ 284, 295 ], [ 297, 299 ], [ 301, 307 ], [ 309, 310 ], [ 312, 313 ], [ 315, 316 ], [ 318, 318 ], [ 320, 320 ], [ 322, 322 ], [ 324, 329 ], [ 331, 331 ], [ 333, 334 ], [ 336, 336 ], [ 338, 343 ], [ 345, 347 ], [ 349, 363 ], [ 365, 426 ], [ 428, 482 ], [ 484, 514 ], [ 516, 732 ], [ 734, 735 ], [ 744, 883 ] ], [ [ 8, 75 ], [ 142, 142 ], [ 483, 483 ], [ 515, 515 ] ], [ [ 151, 151 ], [ 178, 178 ], [ 181, 181 ], [ 183, 183 ], [ 187, 187 ], [ 197, 197 ], [ 199, 199 ], [ 240, 240 ], [ 242, 242 ], [ 283, 283 ], [ 296, 296 ], [ 300, 300 ], [ 308, 308 ], [ 311, 311 ], [ 314, 314 ], [ 317, 317 ], [ 319, 319 ], [ 321, 321 ], [ 323, 323 ], [ 330, 330 ], [ 332, 332 ], [ 335, 335 ], [ 337, 337 ], [ 344, 344 ], [ 348, 348 ], [ 364, 364 ], [ 427, 427 ], [ 733, 733 ], [ 736, 743 ] ] ]
5cf8b3effd3a2a6af64667d1b6105cbe874d3387
8f5d0d23e857e58ad88494806bc60c5c6e13f33d
/Input System/cMouse.h
b3827e9adc24044c640365d674336e4b59bdbc4e
[]
no_license
markglenn/projectlife
edb14754118ec7b0f7d83bd4c92b2e13070dca4f
a6fd3502f2c2713a8a1a919659c775db5309f366
refs/heads/master
2021-01-01T15:31:30.087632
2011-01-30T16:03:41
2011-01-30T16:03:41
1,704,290
1
1
null
null
null
null
UTF-8
C++
false
false
680
h
#ifndef MOUSE_H #define MOUSE_H #define DIRECTINPUT_VERSION 0x0800 #include <dinput.h> class cMouse { public: cMouse(LPDIRECTINPUT8 pDI, HWND hwnd, bool isExclusive = true); ~cMouse(); bool ButtonDown(int button) { return (m_state.rgbButtons[button] & 0x80) ? true : false; } bool ButtonUp(int button) { return (m_state.rgbButtons[button] & 0x80) ? false : true; } int GetWheelMovement() { return m_state.lZ; } void GetMovement(int &dx, int &dy) { dx = m_state.lX; dy = m_state.lY; } bool Update(); bool Acquire(); bool Unacquire(); private: LPDIRECTINPUTDEVICE8 m_pDIDev; DIMOUSESTATE m_state; }; #endif
[ [ [ 1, 29 ] ] ]
394021fc30d6776d5f22b056b5f7b00e0a9ea1ae
ef23e388061a637f82b815d32f7af8cb60c5bb1f
/src/mame/includes/exedexes.h
117b99c586dc994b81b5b2a552de9ad0be584fa6
[]
no_license
marcellodash/psmame
76fd877a210d50d34f23e50d338e65a17deff066
09f52313bd3b06311b910ed67a0e7c70c2dd2535
refs/heads/master
2021-05-29T23:57:23.333706
2011-06-23T20:11:22
2011-06-23T20:11:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,236
h
/************************************************************************* Exed Exes *************************************************************************/ class exedexes_state : public driver_device { public: exedexes_state(running_machine &machine, const driver_device_config_base &config) : driver_device(machine, config) { } /* memory pointers */ UINT8 * m_videoram; UINT8 * m_colorram; UINT8 * m_bg_scroll; UINT8 * m_nbg_yscroll; UINT8 * m_nbg_xscroll; // UINT8 * m_spriteram; // currently this uses generic buffered_spriteram /* video-related */ tilemap_t *m_bg_tilemap; tilemap_t *m_fg_tilemap; tilemap_t *m_tx_tilemap; int m_chon; int m_objon; int m_sc1on; int m_sc2on; }; /*----------- defined in video/exedexes.c -----------*/ extern WRITE8_HANDLER( exedexes_videoram_w ); extern WRITE8_HANDLER( exedexes_colorram_w ); extern WRITE8_HANDLER( exedexes_c804_w ); extern WRITE8_HANDLER( exedexes_gfxctrl_w ); extern PALETTE_INIT( exedexes ); extern VIDEO_START( exedexes ); extern SCREEN_UPDATE( exedexes ); extern SCREEN_EOF( exedexes );
[ "Mike@localhost" ]
[ [ [ 1, 44 ] ] ]
024bee561d49e74b20e6432e48463df02c6c3677
ad33a51b7d45d8bf1aa900022564495bc08e0096
/DES/DES_GOBSTG/Process/frameEnd.cpp
320e2be964cb92300a6b58d8424a86867e428e04
[]
no_license
CBE7F1F65/e20671a6add96e9aa3551d07edee6bd4
31aff43df2571d334672929c88dfd41315a4098a
f33d52bbb59dfb758b24c0651449322ecd1b56b7
refs/heads/master
2016-09-11T02:42:42.116248
2011-09-26T04:30:32
2011-09-26T04:30:32
32,192,691
0
0
null
null
null
null
UTF-8
C++
false
false
1,525
cpp
#include "../Header/processPrep.h" void Process::frameEnd() { if(active) { framecounter++; WorldShake(); /* if (state == STATE_CLEAR) { for (int i=0; i<M_PL_MATCHMAXPLAYER; i++) { GameInput::SetKey(i, KSI_FIRE, false); GameInput::SetKey(i, KSI_QUICK, false); GameInput::SetKey(i, KSI_SLOW, false); GameInput::SetKey(i, KSI_DRAIN, false); } }*/ if (!Player::Action()) { // SetState(STATE_CLEAR, -1); // return; Scripter::scr.Execute(SCR_EVENT, SCR_EVENT_ONEMATCHOVER, SCRIPT_CON_INIT); if (Player::IsMatchEnd() >= 0) { SetState(STATE_CLEAR, -1); return; } else { Player::ClearRound(Player::round+1); clearPrep(); SetInputSwap(); return; } } Enemy::Action(); Bullet::Action(); EffectSp::Action(); Beam::Action(); PlayerBullet::Action(); Item::Action(); EventZone::Action(); /* if(BossInfo::flag) { if(BossInfo::bossinfo.action()) { time = 0; } } */ } if(active || !Player::CheckAble() && state != STATE_CONTINUE) { BGLayer::Action(active); Effectsys::Action(); } BGLayer::ActionSpecial(); SelectSystem::Action(); SpriteItemManager::FrontSpriteAction(); FrontDisplay::fdisp.action(); SE::play(); if (active) { for (int i=0; i<FRAME_STOPINFOMAX; i++) { if (stopflag[i]) { stoptimer[i]--; if (stoptimer[i] == 0) { stopflag[i] = 0; } } } } active = false; }
[ "CBE7F1F65@b503aa94-de59-8b24-8582-4b2cb17628fa" ]
[ [ [ 1, 86 ] ] ]
7f5d1668435251cf6e5f62c2ecb3232973621b90
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/config/test/has_tr1_ref_wrap_pass.cpp
ad3194a70f92b0e7300ac66c2d60224f3fbca13f
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
UTF-8
C++
false
false
1,083
cpp
// This file was automatically generated on Sun Jan 16 16:06:37 2005 // by libs/config/tools/generate.cpp // Copyright John Maddock 2002-4. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org/libs/config for the most recent version. // Test file for macro BOOST_HAS_TR1_REFERENCE_WRAPPER // This file should compile, if it does not then // BOOST_HAS_TR1_REFERENCE_WRAPPER should not be defined. // See file boost_has_tr1_ref_wrap.ipp for details // Must not have BOOST_ASSERT_CONFIG set; it defeats // the objective of this file: #ifdef BOOST_ASSERT_CONFIG # undef BOOST_ASSERT_CONFIG #endif #include <boost/config.hpp> #include "test.hpp" #ifdef BOOST_HAS_TR1_REFERENCE_WRAPPER #include "boost_has_tr1_ref_wrap.ipp" #else namespace boost_has_tr1_reference_wrapper = empty_boost; #endif int main( int, char *[] ) { return boost_has_tr1_reference_wrapper::test(); }
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 34 ] ] ]
d1e3d33f085d4ea587000fb19b0b5b3a345954ab
353bd39ba7ae46ed521936753176ed17ea8546b5
/src/layer1_system/system_info/src/axsi_state.h
c346dfd8f323bb984617867676aa0d6bb8a40905
[]
no_license
d0n3val/axe-engine
1a13e8eee0da667ac40ac4d92b6a084ab8a910e8
320b08df3a1a5254b776c81775b28fa7004861dc
refs/heads/master
2021-01-01T19:46:39.641648
2007-12-10T18:26:22
2007-12-10T18:26:22
32,251,179
1
0
null
null
null
null
UTF-8
C++
false
false
2,276
h
/** * @file * _state class include header * Used to store all data about current library state */ #ifndef __AXSI_STATE_H__ #define __AXSI_STATE_H__ #include "axsi_stdafx.h" #include <dxdiag.h> /** * This class stores all data related to the state of the library * @todo this must be a singleton */ class _state { public: int last_error; /// last error code char error_file[128]; /// file name of last error long error_line; /// line of last error int error_output; /// output send on set error int dump_output; /// output send on dump call int mode; /// indicates debug or release compilation mode unsigned long cpu_flags; /// last error code unsigned long cpu_extended_flags; /// last error code unsigned long cpu_info; /// last error code unsigned long cpu_info2; int os_version; int dx_version; IDxDiagProvider* dxdiag_provider; IDxDiagContainer* dxdiag_root; axsi_system system_data; axsi_cpu_flags cpu_flags_data; axsi_display display_data; axsi_input input_data; axsi_sound sound_data; axsi_network network_data; bool system_set; bool display_set; bool input_set; bool sound_set; bool network_set; bool cpu_flags_set; public: _state() { last_error = 0; mode = 1; error_output = AXSI_NONE; dump_output = AXSI_OUTPUT_DEBUG; error_line = 0; cpu_flags = cpu_extended_flags = cpu_info = cpu_info2 = 0; os_version = dx_version = -1; dxdiag_provider = NULL; dxdiag_root = NULL; system_set = display_set = input_set = false; sound_set = network_set = cpu_flags_set = false; } ~_state() { if( dxdiag_provider != NULL ) { stop_dxdiag(); } } }; #endif // __AXSI_STATE_H__ /* $Id: axsi_state.h,v 1.1 2004/06/09 18:23:57 doneval Exp $ */
[ "d0n3val@2cff7946-3f3c-0410-b79f-f9b517ddbf54" ]
[ [ [ 1, 80 ] ] ]
a7c580ef454f1d48e6df046e14da5cfeface3e4a
c0a577ec612a721b324bb615c08882852b433949
/antlr/src/CPP_parser/Main.cpp
e0e9295611fffc4134a01aaaf38972700063135e
[]
no_license
guojerry/cppxml
ca87ca2e3e62cbe2a132d376ca784f148561a4cc
a4f8b7439e37b6f1f421445694c5a735f8beda71
refs/heads/master
2021-01-10T10:57:40.195940
2010-04-21T13:25:29
2010-04-21T13:25:29
52,403,012
0
0
null
null
null
null
UTF-8
C++
false
false
6,821
cpp
/* * PUBLIC DOMAIN PCCTS-BASED C++ GRAMMAR (cplusplus.g, stat.g, expr.g) * * Authors: Sumana Srinivasan, NeXT Inc.; [email protected] * Terence Parr, Parr Research Corporation; [email protected] * Russell Quong, Purdue University; [email protected] * * VERSION 1.1 * * SOFTWARE RIGHTS * * This file is a part of the ANTLR-based C++ grammar and is free * software. We do not reserve any LEGAL rights to its use or * distribution, but you may NOT claim ownership or authorship of this * grammar or support code. An individual or company may otherwise do * whatever they wish with the grammar distributed herewith including the * incorporation of the grammar or the output generated by ANTLR into * commerical software. You may redistribute in source or binary form * without payment of royalties to us as long as this header remains * in all source distributions. * * We encourage users to develop parsers/tools using this grammar. * In return, we ask that credit is given to us for developing this * grammar. By "credit", we mean that if you incorporate our grammar or * the generated code into one of your programs (commercial product, * research project, or otherwise) that you acknowledge this fact in the * documentation, research report, etc.... In addition, you should say nice * things about us at every opportunity. * * As long as these guidelines are kept, we expect to continue enhancing * this grammar. Feel free to send us enhancements, fixes, bug reports, * suggestions, or general words of encouragement at [email protected]. * * NeXT Computer Inc. * 900 Chesapeake Dr. * Redwood City, CA 94555 * 12/02/1994 * * Restructured for public consumption by Terence Parr late February, 1995. * * Requires PCCTS 1.32b4 or higher to get past ANTLR. * * DISCLAIMER: we make no guarantees that this grammar works, makes sense, * or can be used to do anything useful. */ /* 1999-2004 Version 3.0 July 2004 * Modified by David Wigg at London South Bank University for CPP_parser.g */ /* 2004-2005 Version 3.1 November 2005 * Modified by David Wigg at London South Bank University for CPP_parser.g */ /* 2005-2007 Version 3.2 November 2007 * Modified by David Wigg at London South Bank University for CPP_parser.g * * This is the main program of the C++ parser * * Based on 'main.cpp' supplied with John Lilley's C++ parser and modified * by David Wigg at London South Bank University * * See MyReadMe.txt for further information * * This file is best viewed in courier font with tabs set to 4 spaces * * The input file must be pre-processed if any types used in the principal/user's program * to be parsed have been declared in any #include files. Otherwise the parser fails. * * To run in DOS window enter, * * >...\debug\CPP_parser program_name.i (/a or /A may be used to specify that included files should * also be processed by your application instead of just * the principal/user's file. See MyCode.cpp for coding) * * Error/Warning messages may be displayed in DOS window. */ #include <iostream> #include <fstream> #include <string> #include "conio.h" #include "windows.h" #include "CPPLexer.hpp" #include "CPPParser.hpp" #include "antlr/CommonAST.hpp" #ifdef MYCODE #include "MyCode.hpp" #endif MYCODE static FILE* g_hOutputFile = NULL; ANTLR_USING_NAMESPACE(std) ANTLR_USING_NAMESPACE(antlr) void myDebugOutputA(const char* format, ...) { va_list argptr; va_start(argptr, format); char szData[1024] = {0}; _vsnprintf(szData, 1023, format, argptr); va_end(argptr); if(g_hOutputFile) fprintf(g_hOutputFile, szData); else OutputDebugStringA(szData); } void indent(int indent_level) { if (indent_level > 0) { const size_t BUFSIZE = 127; char buf[ BUFSIZE+1 ]; int i; for (i = 0; i < indent_level && i < BUFSIZE; i++) { buf[i] = ' '; } buf[i] = '\0'; myDebugOutputA("%s", buf ); } } // pr_indent void trav_tree(RefPNode top, int ind ) { if (top != NULL) { myDebugOutputA("%03d ", top->getLine()); std::string str; indent( ind ); str = top->getText(); myDebugOutputA("%s\r\n", str.c_str()); if (top->getFirstChild() != NULL) { myDebugOutputA("kid: "); trav_tree( top->getFirstChild(), ind+2 ); } if (top->getNextSibling()) { myDebugOutputA("sib: "); trav_tree( top->getNextSibling(), ind); } } } int main(int argc,char* argv[]) { // Adapt the following if block to the requirements of your application if (argc < 2 || argc > 3) { cerr << "Usage:\n" << argv[0] << " filename.i (/a or /A)" << "\n"; exit(1); } // check for input file FILE *input_file_ptr = fopen(argv[1], "r"); if (input_file_ptr == NULL) { cerr << "Failed to open input file " << argv[1] << "\n"; exit(1); } else // close input file fclose(input_file_ptr); char szOutputFileName[MAX_PATH] = {0}; strcpy(szOutputFileName, argv[1]); int idx = strlen(szOutputFileName); while((szOutputFileName[idx] != '.') && (idx > 0)) { szOutputFileName[idx] = '\0'; idx -= 1; } strcat(szOutputFileName, "ast"); g_hOutputFile = fopen(szOutputFileName, "w"); char *f = argv[1]; try { ifstream s(f); if (!s) { cerr << "Input stream could not be opened for " << f << "\n"; exit(1); } // Create a scanner that reads from the input stream CPPLexer lexer(s); lexer.setFilename(f); #ifdef MYCODE // Create subclass of parser for MYCODE code that reads from scanner MyCode myCode(lexer); _PNodeFactory my_factory; // generates CommonAST per default.. // Do setup from the AST factory repeat this for all parsers using the AST myCode.initializeASTFactory(my_factory); myCode.setASTFactory(&my_factory); myCode.setFilename(f); myCode.init(); myCode.myCode_pre_processing(argc, argv); myCode.translation_unit(); RefPNode ast = RefPNode(myCode.getAST()); myDebugOutputA("sid: "); trav_tree(ast, 0); myCode.myCode_post_processing(); #else // Create a parser that reads from the scanner CPPParser parser(lexer); parser.setFilename(f); parser.init(); parser.translation_unit(); #endif MYCODE } catch(ANTLRException& e) // Put in 30/10/07 { cerr << "exception: " << e.getMessage() << endl; return -1; } catch (exception& e) { cerr << "parser exception: " << e.what() << endl; // e.printStackTrace(); // so we can get stack trace return -1; // Put in 30/10/07 } printf("\nParse ended\n"); fclose(g_hOutputFile); g_hOutputFile = NULL; // getch(); return 0; }
[ "oeichenwei@0e9f5f58-6d57-11de-950b-9fccee66d0d9" ]
[ [ [ 1, 238 ] ] ]
b028de587a20956b1b67ecd2c384c0a2882aa3d3
6188f1aaaf5508e046cde6da16b56feb3d5914bc
/CamFighter/Graphics/D3D/d3d.cpp
44f66241b5b2f0bdb8f58e3dd5a3e73ff0f67d05
[]
no_license
dogtwelve/fighter3d
7bb099f0dc396e8224c573743ee28c54cdd3d5a2
c073194989bc1589e4aa665714c5511f001e6400
refs/heads/master
2021-04-30T15:58:11.300681
2011-06-27T18:51:30
2011-06-27T18:51:30
33,675,635
1
0
null
null
null
null
UTF-8
C++
false
false
140
cpp
#include "d3d.h" #ifdef USE_D3D namespace Graphics { namespace D3D { LPDIRECT3DDEVICE9 d3ddev; // current d3d device }} #endif
[ "darekmac@f75eed02-8a0f-11dd-b20b-83d96e936561" ]
[ [ [ 1, 11 ] ] ]
36965e9834a18f36ab377f162250f6fcc0ad2c97
59ce53af7ad5a1f9b12a69aadbfc7abc4c4bfc02
/src/PropertyListViewTest/stdafx.cpp
97e205f9ea3f68f6e25573b622d659821f1948fe
[]
no_license
fingomajom/skinengine
444a89955046a6f2c7be49012ff501dc465f019e
6bb26a46a7edac88b613ea9a124abeb8a1694868
refs/heads/master
2021-01-10T11:30:51.541442
2008-07-30T07:13:11
2008-07-30T07:13:11
47,892,418
0
0
null
null
null
null
UTF-8
C++
false
false
297
cpp
// stdafx.cpp : source file that includes just the standard includes // PropertyListViewTest.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" #if (_ATL_VER < 0x0700) #include <atlimpl.cpp> #endif //(_ATL_VER < 0x0700)
[ [ [ 1, 9 ] ] ]
5c3de3710e5faf0e06c7714939fe961bf96f79e7
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/functional/hash/test/hash_list_test.cpp
58b3b7b9fddbac6dbbd75967cbff47c3bdaefd1d
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
UTF-8
C++
false
false
750
cpp
// Copyright Daniel James 2005-2006. Use, modification, and distribution are // subject to the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include "./config.hpp" #ifdef TEST_EXTENSIONS # ifdef TEST_STD_INCLUDES # include <functional> # else # include <boost/functional/hash.hpp> # endif #endif #include <boost/detail/lightweight_test.hpp> #ifdef TEST_EXTENSIONS #include <list> using std::list; #define CONTAINER_TYPE list #include "./hash_sequence_test.hpp" #endif // TEST_EXTENSIONS int main() { #ifdef TEST_EXTENSIONS list_tests::list_hash_integer_tests(); #endif return boost::report_errors(); }
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 35 ] ] ]
53c2c37980683e61125981384a85a17105e9b1a6
741b36f4ddf392c4459d777930bc55b966c2111a
/incubator/deeppurple/lwplugins/lwwrapper/LWcommon/FileLib.h
f31b526224b77986845e515ef4554836880b05fc
[]
no_license
BackupTheBerlios/lwpp-svn
d2e905641f60a7c9ca296d29169c70762f5a9281
fd6f80cbba14209d4ca639f291b1a28a0ed5404d
refs/heads/master
2021-01-17T17:01:31.802187
2005-10-16T22:12:52
2005-10-16T22:12:52
40,805,554
0
0
null
null
null
null
UTF-8
C++
false
false
105
h
#include <string> #include <fstream> namespace FileLib { bool FileExists(std::string ToCheck); }
[ "deeppurple@dac1304f-7ce9-0310-a59f-f2d444f72a61" ]
[ [ [ 1, 6 ] ] ]
501df6e630f0f70680d6c84ec9c87cfe3ed91d8b
8342f87cc7e048aa812910975c68babc6fb6c5d8
/server/Server.cpp
9966abb746de338270418b934859427767d27472
[]
no_license
espes/hoverrace
1955c00961af4bb4f5c846f20e65ec9312719c08
7d5fd39ba688e2c537f35f7c723dedced983a98c
refs/heads/master
2021-01-23T13:23:03.710443
2010-12-19T22:26:12
2010-12-19T22:26:12
2,005,364
0
1
null
null
null
null
UTF-8
C++
false
false
2,988
cpp
// GrokkSoft HoverRace SourceCode License v1.0, November 29, 2008 // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // - Redistributions in source code must retain the accompanying copyright notice, // this list of conditions, and the following disclaimer. // - Redistributions in binary form must reproduce the accompanying copyright // notice, this list of conditions, and the following disclaimer in the // documentation and/or other materials provided with the distribution. // - Names of the copyright holders (Richard Langlois and Grokksoft inc.) must not // be used to endorse or promote products derived from this software without // prior written permission from the copyright holders. // - This software, or its derivates must not be used for commercial activities // without prior written permission from the copyright holders. // - If any files are modified, you must cause the modified files to carry // prominent notices stating that you changed the files and the date of any // change. // // Disclaimer: // The author makes no representations about the suitability of this software for // any purpose. It is provided "AS IS", WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. // /*** * Server.cpp * * Implementation of the dedicated server. */ #include "Server.h" #include <boost/bind.hpp> using namespace std; using namespace boost::asio; using namespace boost::asio::ip; Server::Server(io_service &io_service, short tcpListenPort, short udpListenPort) { // TODO: make listen ports specifiable this->io_service = io_service; acceptor(io_service, tcp::endpoint(tcp::v4(), tcpListenPort)); // this is our connectionless UDP socket, which will get passed to all UDPConnection // objects udpSocket = udp::socket(io_service, udp::endpoint(udp::v4(), udpListenPort)); // "blank" connection that gets written to when someone tries to connect, and // then we deal with it tcpConnection = new TCPConnection(io_service); udpSender = udp::endpoint; // set up handler for a new received TCP connection tcpAcceptor.async_accept(tcpConnection->getSocket(), boost::bind(&Server::HandleTCPAccept, this, tcpConnection, placeholders::error)); // and a handler for a new received UDP connection udpSocket->getSocket().async_receive_from(buffer(udpSocket->getBuffer(), udpSocket->getMaxBufferLength()), udpSender, boost::bind(&Server::HandleUDPConnect, this, placeholders::error, placeholders::bytes_transferred)); } Server::HandleTCPAccept(TCPConnection *connection, const boost::system::error_code &error) { if(!error) { } else { // HOLY SHIT WHAT DO WE DO CAPTAIN? } } Server::HandleUDPConnect(UDPConnection *connection, const boost::system::error_code &error) { if(!error) { } else { // ??? } }
[ "ryan@7d5085ce-8879-48fc-b0cc-67565f2357fd" ]
[ [ [ 1, 80 ] ] ]
19aa930627b21940635b4d4ff2770984d41385dc
f56fed2ab7a4c9281386a6f8623af1b19de61cd1
/sudsolve.cpp
43512d524108910d9484a88ec23e9705c757f6c2
[]
no_license
allan3723/Sudoku-Solver
449085b2b8dcff46c6ec39842583b689e0fb3607
bf4bf897ed8626fb9fef0a74622c46dbb720d7c3
refs/heads/master
2020-05-16T22:27:40.250682
2011-01-25T00:08:20
2011-01-25T00:08:20
34,228,300
0
0
null
null
null
null
UTF-8
C++
false
false
18,078
cpp
// ache; Cheng, Allan #include <stack> #include <iostream> #include <set> using namespace std; #include <cctype> #include <stdlib.h> #include <stdio.h> #include <vector> class Table { private: set<char>::iterator it; int i; public: int row, col, area, count; char num; set<char> choice; void print() //temporary - use to print out possibilities { for (it = choice.begin(); it != choice.end(); i++) cout << " " << *it; cout << endl; } }; set<int> emptyCell; bool solutionFound = false; bool guessed = false; int areaZero[] = {0, 1, 2, 9, 10, 11, 18, 19, 20}, //3x3 grids areaOne[] = {3, 4, 5, 12, 13, 14, 21, 22, 23}, areaTwo[] = {6, 7, 8, 15, 16, 17, 24, 25, 26}, areaThree[] = {27, 28, 29, 36, 37, 38, 45, 46, 47}, areaFour[] = {30, 31, 32, 39, 40, 41, 48, 49, 50}, areaFive[] = {33, 34, 35, 42, 43, 44, 51, 52, 53}, areaSix[] = {54, 55, 56, 63, 64, 65, 72, 73, 74}, areaSeven[] = {57, 58, 59, 66, 67, 68, 75, 76, 77}, areaEight[] = {60, 61, 62, 69, 70, 71, 78, 79, 80}; void read_input(); void setSeen(Table* puzzle, int i); void findSimplifications(Table* puzzle); bool findDecidableCell(Table* puzzle); bool hiddenSingles(Table* puzzle, int cell); void guess(Table* puzzle); bool check(Table* puzzle); void printTable(Table* puzzle); bool guessCheck(Table* puzzle, int cell); int main() { read_input(); if (!solutionFound) cout << "No solution!\n"; } void read_input() { char temp, inp[82]; //9x9 sudo puzzle + \n int i, j, areacount, areamult; Table puzzle[81]; fgets(inp, 83, stdin); areacount = -1; for(i = 0; i < 81; i++) //check for error input { if ((!isdigit(inp[i]) && inp[i] != '.') || inp[i] == '0') { if (inp[i] == '\n') cout << "ERROR: expected <value> got \\n" << endl; else if (feof(stdin)) cout << "ERROR: expected <value> got <eof>" << endl; else cout << "ERROR: expected <value> got " << inp[i] << endl; exit(1); } puzzle[i].num = inp[i]; if (inp[i] == '.') { puzzle[i].choice.insert('1'); puzzle[i].choice.insert('2'); puzzle[i].choice.insert('3'); puzzle[i].choice.insert('4'); puzzle[i].choice.insert('5'); puzzle[i].choice.insert('6'); puzzle[i].choice.insert('7'); puzzle[i].choice.insert('8'); puzzle[i].choice.insert('9'); emptyCell.insert(i); } j = i / 9; // row number from row 0->8 puzzle[i].row = j; j = i % 9; // col num from 0->8 puzzle[i].col = j; if ((i%3) == 0) //3x3 location of the num areacount++; areamult = (i / 27) * 3; if (areacount >= 3) areacount = 0; puzzle[i].area = areacount + areamult; } if (inp[81] != '\n') { cout << "ERROR: expected \\n got " << inp[81] << endl; exit(1); } temp = fgetc(stdin); if (!feof(stdin)) { cout << "ERROR: expected <eof> got " << temp << endl; exit(1); } findSimplifications(puzzle); // printTable(); } void findSimplifications(Table* puzzle) { int i; set<int>::iterator it; for (it = emptyCell.begin(); it != emptyCell.end(); it++) setSeen(puzzle, *it); while ((findDecidableCell(puzzle) == true) && emptyCell.size() != 0) { for (it = emptyCell.begin(); it != emptyCell.end(); it++) setSeen(puzzle,*it); } // if (emptyCell.size() != 0) // guess(puzzle); // else // if (!guessed && check(puzzle)) if (emptyCell.empty()) printTable(puzzle); } void setSeen(Table* puzzle, int i) { int j; if (!isdigit(puzzle[i].num)) { for (j = 0; j < 9; j++) { puzzle[i].choice.erase(puzzle[puzzle[i].col + (j*9)].num); puzzle[i].choice.erase(puzzle[(puzzle[i].row * 9) + j].num); } switch(puzzle[i].area) { case 0: for (j = 0; j < 9; j++) puzzle[i].choice.erase(puzzle[areaZero[j]].num); break; case 1: for (j = 0; j < 9; j++) puzzle[i].choice.erase(puzzle[areaOne[j]].num); break; case 2: for (j = 0; j < 9; j++) puzzle[i].choice.erase(puzzle[areaTwo[j]].num); break; case 3: for (j = 0; j < 9; j++) { puzzle[i].choice.erase(puzzle[areaThree[j]].num); } break; case 4: for (j = 0; j < 9; j++) puzzle[i].choice.erase(puzzle[areaFour[j]].num); break; case 5: for (j = 0; j < 9; j++) puzzle[i].choice.erase(puzzle[areaFive[j]].num); break; case 6: for (j = 0; j < 9; j++) puzzle[i].choice.erase(puzzle[areaSix[j]].num); break; case 7: for (j = 0; j < 9; j++) puzzle[i].choice.erase(puzzle[areaSeven[j]].num); break; case 8: for (j = 0; j < 9; j++) puzzle[i].choice.erase(puzzle[areaEight[j]].num); break; } } } bool findDecidableCell(Table* puzzle) { set<int>::iterator i; set<char>::iterator it; for (i = emptyCell.begin(); i != emptyCell.end(); i++) { if (puzzle[*i].choice.size() == 1) //hidden single { it = puzzle[*i].choice.begin(); puzzle[*i].num = *it; puzzle[*i].choice.clear(); emptyCell.erase(*i); return true; } else if (puzzle[*i].choice.size() > 1) if(hiddenSingles(puzzle, *i) == true) return true; } //end for return false; } bool hiddenSingles(Table* puzzle, int cell) { int i, j; set<char>::iterator it; set<char>::iterator sec; bool repeat = false; for (it = puzzle[cell].choice.begin(); it != puzzle[cell].choice.end(); it++) { for (i = 1; ((cell + i) < 81) && puzzle[cell + i].row == puzzle[cell].row; i++) { for(sec = puzzle[cell + i].choice.begin(); sec != puzzle[cell + i].choice.end(); sec++) { if (*sec == *it) { repeat = true; break; } //if if (repeat == true) break; } //for } //for for (i = 1; ((cell - i) >= 0) && puzzle[cell - i].row == puzzle[cell].row; i++) { for(sec = puzzle[cell - i].choice.begin(); sec != puzzle[cell - i].choice.end(); sec++) { if (*sec == *it) { repeat = true; break; } //if if (repeat == true) break; } //for } //for -- ROW BACKWARDS if (repeat == false) { puzzle[cell].num = *it; puzzle[cell].choice.clear(); emptyCell.erase(cell); return true; } else repeat = false; //no H.S in row so check col for(i = 1; (cell + (i * 9)) < 81; i++) { for(sec = puzzle[cell + (i * 9)].choice.begin(); sec != puzzle[cell + (i * 9)].choice.end(); sec++) { if (*sec == *it) { repeat = true; break; } //if if (repeat == true) break; } //for } //for - COL FORWARD for (i = 1; (cell - (i * 9)) >= 0; i++) { for(sec = puzzle[cell - (i * 9)].choice.begin(); sec != puzzle[cell - (i * 9)].choice.end(); sec++) { if (*sec == *it) { repeat = true; break; } if (repeat == true) break; } // for } //for - COL BACKWARDS if (repeat == false) { puzzle[cell].num = *it; puzzle[cell].choice.clear(); emptyCell.erase(cell); return true; } else repeat = false; //no H.S. in col so check unit switch(puzzle[cell].area) { case 0: for (i = 0; i < 9; i++) { if (cell == areaZero[i]) continue; else for (sec = puzzle[areaZero[i]].choice.begin(); sec != puzzle[areaZero[i]].choice.end(); sec++) if (*it == *sec) { repeat = true; break; } if (repeat == true) break; } //for break; case 1: for (i = 0; i < 9; i++) { if (cell == areaOne[i]) continue; else for (sec = puzzle[areaOne[i]].choice.begin(); sec != puzzle[areaOne[i]].choice.end(); sec++) if (*it == *sec) { repeat = true; break; } if (repeat == true) break; } //for break; case 2: for (i = 0; i < 9; i++) { if (cell == areaTwo[i]) continue; else for (sec = puzzle[areaTwo[i]].choice.begin(); sec != puzzle[areaTwo[i]].choice.end(); sec++) if (*it == *sec) { repeat = true; break; } if (repeat == true) break; } //for break; case 3: for (i = 0; i < 9; i++) { if (cell == areaThree[i]) continue; else for (sec = puzzle[areaThree[i]].choice.begin(); sec != puzzle[areaThree[i]].choice.end(); sec++) if (*it == *sec) { repeat = true; break; } if (repeat == true) break; } //for break; case 4: for (i = 0; i < 9; i++) { if (cell == areaFour[i]) continue; else for (sec = puzzle[areaFour[i]].choice.begin(); sec != puzzle[areaFour[i]].choice.end(); sec++) if (*it == *sec) { repeat = true; break; } if (repeat == true) break; } //for break; case 5: for (i = 0; i < 9; i++) { if (cell == areaFive[i]) continue; else for (sec = puzzle[areaFive[i]].choice.begin(); sec != puzzle[areaFive[i]].choice.end(); sec++) if (*it == *sec) { repeat = true; break; } if (repeat == true) break; } //for break; case 6: for (i = 0; i < 9; i++) { if (cell == areaSix[i]) continue; else for (sec = puzzle[areaSix[i]].choice.begin(); sec != puzzle[areaSix[i]].choice.end(); sec++) if (*it == *sec) { repeat = true; break; } if (repeat == true) break; } //for break; case 7: for (i = 0; i < 9; i++) { if (cell == areaSeven[i]) continue; else for (sec = puzzle[areaSeven[i]].choice.begin(); sec != puzzle[areaSeven[i]].choice.end(); sec++) if (*it == *sec) { repeat = true; break; } if (repeat == true) break; } //for break; case 8: for (i = 0; i < 9; i++) { if (cell == areaEight[i]) continue; else for (sec = puzzle[areaEight[i]].choice.begin(); sec != puzzle[areaEight[i]].choice.end(); sec++) if (*it == *sec) { repeat = true; break; } if (repeat == true) break; } //for break; } if (repeat == false) { puzzle[cell].num = *it; puzzle[cell].choice.clear(); emptyCell.erase(cell); return true; } } //for - THE WHOLE FOR return false; } //end function void guess(Table* puzzle) { set<int>::iterator it; stack <set<int> > empty; vector<Table*> test; set<char>::iterator cit; stack<Table> alternatives; int cell, size, i = 0, j, k = 0, size2; guessed = true; /* if (emptyCell.size() == 0 && !alternatives.empty()) //no alts, no cell to try anymore { if (solutionFound = false) //didn't find any solutions at all { cout << "No solution!\n"; exit(1); } return; } */ size2 = emptyCell.size(); int cells[size2]; for (it = emptyCell.begin(); it != emptyCell.end(); it++) //goes through all empty Cell { cells[k] = *it; k++; } for (k = 0; k < size2; k++) { cell = cells[k]; size = puzzle[cell].choice.size(); char array[size]; if (puzzle[cell].choice.size() == 0) //not a solution so try next; continue; emptyCell.erase(cell); //since current cell will be filled, erase from list. for (cit = puzzle[cell].choice.begin(); cit != puzzle[cell].choice.end(); cit++) //all pos of cell { array[i] = *cit; i++; } for (i = 0; i < size; i++) { empty.push(emptyCell); for (j = 0; j < size2; j++) alternatives.push(puzzle[cells[j]]); //saves the affected cells puzzle[cell].num = array[i]; // fills current pos in the empty cell findSimplifications(puzzle); // if(guessCheck(puzzle, cell)) //tries to solve this guess if (emptyCell.size() == 0) //emptyCell.size() == 0) { for (k = 0; k < 81; k++) cout << puzzle[k].num; cout << endl; solutionFound = true; } for (j = size2-1; j >= 0; j--) { puzzle[cells[j]] = alternatives.top(); alternatives.pop(); } emptyCell = empty.top(); empty.pop(); } //for emptyCell.insert(cell); //inserts back into empty list } // big for } //end guess bool check(Table* puzzle) { // int i; // set<int>::iterator it; if (emptyCell.size() == 0) return true; else return false; /* for (i = 0; i < 81; i++) if (puzzle[i].num == '.' && puzzle[i].choice.size() == 0) return false; */ // return true; } bool guessCheck(Table* puzzle, int cell) { int j, count = 0; bool simp = true; set<int>::iterator it; /* while (simp == true) { //cout << "count = " << count << endl; for (j = 0; j < 9; j++) { if (puzzle[puzzle[cell].col + (j*9)].num == '.') { setSeen(puzzle, puzzle[cell].col + (j*9)); //cout << puzzle[cell].col + (j*9) << " - " << puzzle[puzzle[cell].col + (j*9)].choice.size() << endl; if (puzzle[puzzle[cell].col + (j*9)].choice.size() == 0) return false; } if (puzzle[puzzle[cell].row*9+j].num == '.') { setSeen(puzzle, puzzle[cell].row*9+j); //cout << puzzle[cell].row*9 + j << " - " << puzzle[puzzle[cell].row*9 + j].choice.size() << endl; if (puzzle[puzzle[cell].row*9 + j].choice.size() == 0) return false; } switch(puzzle[cell].area) { case 0: if (puzzle[areaZero[j]].num != '.') continue; setSeen(puzzle, areaZero[j]); if (puzzle[areaZero[j]].choice.size() == 0) return false; break; case 1: if (puzzle[areaOne[j]].num != '.') continue; setSeen(puzzle, areaOne[j]); if (puzzle[areaOne[j]].choice.size() == 0) return false; break; case 2: if (puzzle[areaTwo[j]].num != '.') continue; setSeen(puzzle, areaTwo[j]); if (puzzle[areaTwo[j]].choice.size() == 0) return false; break; case 3: if (puzzle[areaThree[j]].num != '.') continue; setSeen(puzzle, areaThree[j]); if (puzzle[areaThree[j]].choice.size() == 0) return false; break; case 4: if (puzzle[areaFour[j]].num != '.') continue; setSeen(puzzle, areaFour[j]); if (puzzle[areaFour[j]].choice.size() == 0) return false; break; case 5: if (puzzle[areaFive[j]].num != '.') continue; setSeen(puzzle, areaFive[j]); if (puzzle[areaFive[j]].choice.size() == 0) return false; break; case 6: if (puzzle[areaSix[j]].num != '.') continue; setSeen(puzzle, areaSix[j]); if (puzzle[areaSix[j]].choice.size() == 0) return false; break; case 7: if (puzzle[areaSeven[j]].num != '.') continue; setSeen(puzzle, areaSeven[j]); if (puzzle[areaSeven[j]].choice.size() == 0) return false; break; case 8: if (puzzle[areaEight[j]].num != '.') continue; setSeen(puzzle, areaEight[j]); if (puzzle[areaEight[j]].choice.size() == 0) return false; break; } }//for simp = findDecidableCell(puzzle); //cout << simp << endl; //printTable(puzzle); //count++; } //while */ if (emptyCell.size() != 0) guess(puzzle); else return true; } void printTable(Table* puzzle) { int i; for (i = 0; i < 81; i++) cout << puzzle[i].num; cout << endl; solutionFound = true; }
[ "Allan@.(none)" ]
[ [ [ 1, 689 ] ] ]
cdff79be0e98063809dfce66bf86fc2e64251309
a48646eddd0eec81c4be179511493cbaf22965b9
/src/sip/transport/sip_transport_const.inc
97ff436f14e7626e25f1ae651dbbdcaacfb83024
[]
no_license
lengue/tsip
0449f791a5cbe9e9fdaa1b4d7f1d1e28eff2f0ec
da8606bd7d865d4b4a389ec1594248a4044bc890
refs/heads/master
2021-01-10T08:40:32.925501
2010-06-05T12:44:10
2010-06-05T12:44:10
53,989,315
0
0
null
null
null
null
GB18030
C++
false
false
278
inc
/******************************************************************************* 功能 : 传输层消息管理(WIN32专用) 创建人 : 唐春平 创建日期: 200.01.10 修改记录: *******************************************************************************/
[ [ [ 1, 7 ] ] ]
121694526ecc794c09a8e97957341bcbcf27aa05
57508120082342c08bed234569434262b83557c2
/e3rtree.h
b361e7bd12b35acf3e6839d950d84978e56c5354
[]
no_license
chtlp/mv-tp-r-tree
a3214b074912f8e56a0e5fc8219fe9da97fa644a
f19fe09eb4966181739424b93e9de953f963840a
refs/heads/master
2020-07-22T01:00:47.582484
2011-05-02T05:36:58
2011-05-02T05:36:58
32,191,845
0
0
null
null
null
null
UTF-8
C++
false
false
5,684
h
#ifndef __E3RTREE #define __E3RTREE #include "e3rlinlist.h" #include "blk_file.h" #include "cache.h" #include "rtreeheader.h" ///////////////////////////////////////////////////////////////////////////// class E3RLinList; class SortedE3RLinList; class Cache; ///////////////////////////////////////////////////////////////////////////// class E3REntry : public AbsEntry { friend class E3RTNode; friend class E3RTree; public: int son; // block # of son //This variable is no longer necessary because it has been defined in the //rtree-header int dimension; // dimension of the box int level; float *bounces; // pointer to box E3RTree *my_tree; // pointer to my R-tree E3RTNode *son_ptr; // pointer to son if in main mem. //<---functions---> E3REntry(int dimension = E3RTREEDIMENSION, E3RTree *rt = NULL); virtual ~E3REntry(); bool check_valid(); int get_size(); // returns amount of needed buffer space E3RTNode *get_son(); // returns pointer to the son, void read_from_buffer(char *buffer);// reads data from buffer SECTION section(float *mbr); // tests, if mbr intersects the box bool section_circle(float *center, float radius); void write_to_buffer(char *buffer); // writes data to buffer virtual E3REntry & operator = (E3REntry &_d); bool operator == (E3REntry &_d); }; class E3RTNode : public AbsRTNode { friend class E3RTree; public: bool dirty; // TRUE, if node has to be written char level; // level of the node in the tree (0 means leaf) int block; // disc block int capacity; // max. # of entries int dimension; int num_entries; // # of used entries E3REntry *entries; // array of entries E3RTree *my_tree; // pointer to R-tree //<---functions---> E3RTNode(E3RTree *rt); E3RTNode(E3RTree *rt, int _block); virtual ~E3RTNode(); int choose_subtree(float *brm); // chooses best subtree for insertion R_DELETE delete_entry(E3REntry *e); void enter(E3REntry *de); // inserts new entry bool FindLeaf(E3REntry *e); int get_headersize() {return sizeof(char) + sizeof(int);} float *get_mbr(); // returns mbr enclosing whole page int get_num_of_data(); // returns number of data entries R_OVERFLOW insert(E3REntry *d, E3RTNode **sn); // inserts d recursively, if there // occurs a split, FALSE will be // returned and in sn a // pointer to the new node bool is_data_node() { return (level==0) ? TRUE : FALSE ;}; void print(); // prints rectangles void rangeQuery(float *mbr, SortedE3RLinList *res, char *rec, int *levelcount); void read_from_buffer(char *buffer);// reads data from buffer void split(E3RTNode *sn); // splits directory page to *this and sn int split(float **mbr, int **distribution); // splits an Array of mbr's into 2 // and returns in distribution // which *m mbr's are to be // moved void write_to_buffer(char *buffer); // writes data to buffer }; class E3RTree : public AbsRTree { public: friend class E3RTNode; bool *re_level; // if re_level[i] is TRUE, // there was a reinsert on level i bool root_is_data; // TRUE, if root is a data page char *header; int akt; // # of actually got data (get_next) int dimension; // dimension of the data's int num_of_data; // # of stored data int num_of_dnodes; // # of stored data pages int num_of_inodes; // # of stored directory pages int root; // block # of root node int *splitcount; //This variable is an array, which stores the number of splits for //each dimension. So the size of the array is the same as the dimension BlockFile *file; // storage manager for harddisc blocks Cache *cache; // LRU cache for managing blocks in memory E3RLinList *re_data_cands; // data entries to reinsert E3RLinList *deletelist; E3RTNode *root_ptr; // root-node //<---Functions---> E3RTree(char *fname, int _b_length, Cache* c, int _dimension); E3RTree(char *fname, Cache* c); E3RTree(char *inpname, char *fname, int _blength, Cache* c, int _dimension); virtual ~E3RTree(); bool delete_entry(E3REntry *d); bool FindLeaf(E3REntry *e); int get_num() // returns # of stored data { return num_of_data; } void insert(E3REntry *d); // inserts new data into tree void load_root(); // loads root_node into memory void rangeQuery(float *mbr, SortedE3RLinList *res, char *rec, int reclen, int *levelcount); void read_header(char *buffer); // reads Rtree header void write_header(char *buffer); // writes Rtree header }; #endif
[ "chnttlp@5fd1ae55-4be7-57d6-6470-c356376a0a7e" ]
[ [ [ 1, 134 ] ] ]
f6e66a29dc8145c922d83f06da6509cbe6a3560d
191d4160cba9d00fce9041a1cc09f17b4b027df5
/ZeroLag2/KUILib/Include/kscbase/kscconf.h
6920dc35f20d326b268408a720a8a963bae06b14
[]
no_license
zapline/zero-lag
f71d35efd7b2f884566a45b5c1dc6c7eec6577dd
1651f264c6d2dc64e4bdcb6529fb6280bbbfbcf4
refs/heads/master
2021-01-22T16:45:46.430952
2011-05-07T13:22:52
2011-05-07T13:22:52
32,774,187
3
2
null
null
null
null
GB18030
C++
false
false
2,049
h
// Copyright (c) 2010 Kingsoft Corporation. All rights reserved. // Copyright (c) 2010 The KSafe Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may 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. /******************************************************************** created: 2010/06/09 created: 9:6:2010 17:05 filename: kscconf.h author: Jiang Fengbing purpose: 读写配置文件 使用方法: KConfigure(szSettingPath).get("autorun", nAutorun).get("type", nType); *********************************************************************/ #ifndef KSCCONF_INC_ #define KSCCONF_INC_ ////////////////////////////////////////////////////////////////////////// #include <string> #include <map> ////////////////////////////////////////////////////////////////////////// class KConfigure { public: KConfigure(const std::wstring& strConf); ~KConfigure(); KConfigure& Instance(); KConfigure& Get(const std::string& strName, std::wstring& strValue); KConfigure& Get(const std::string& strName, int& nValue); KConfigure& Set(const std::string& strName, const std::wstring& strValue); KConfigure& Set(const std::string& strName, int nValue); private: bool Load(); bool Save(); typedef std::map<std::string, std::wstring> StringStore; typedef std::map<std::string, int> IntegerStore; StringStore m_vStringStore; IntegerStore m_vIntegerStore; std::wstring m_strConfPath; }; ////////////////////////////////////////////////////////////////////////// #endif // KSCCONF_INC_
[ "Administrator@PC-200201010241" ]
[ [ [ 1, 63 ] ] ]
89a48e9170ca85c18d4afcf1611ed89ed6f537ee
814b49df11675ac3664ac0198048961b5306e1c5
/Code/Engine/Input/include/ActionManager.h
9757635c1470cab7b3661c738a4336d78f52c573
[]
no_license
Atridas/biogame
f6cb24d0c0b208316990e5bb0b52ef3fb8e83042
3b8e95b215da4d51ab856b4701c12e077cbd2587
refs/heads/master
2021-01-13T00:55:50.502395
2011-10-31T12:58:53
2011-10-31T12:58:53
43,897,729
0
0
null
null
null
null
UTF-8
C++
false
false
1,058
h
#ifndef __ACTION_MANAGER_H__ #define __ACTION_MANAGER_H__ #pragma once #include "base.h" #include <Utils/MapManager.h> #include "InputAction.h" //forward declarations ------------- class CProcess; //---------------------------------- class CActionManager : public CMapManager<CInputAction> { public: CActionManager() : m_pProcess(0),m_szXMLFile(""),m_bReload(false) {}; ~CActionManager() {Done();}; bool Init(string _szXMLFile); bool Load(const string& _szXMLFile) {m_szXMLFile = _szXMLFile;Done();return Init(m_szXMLFile);}; void SetProcess(CProcess* _pProcess) {m_pProcess = _pProcess;}; void Update(float _fDeltaSeconds); void Reload() {m_bReload = true;}; bool IsActionActive(const string& _szActionName); private: virtual void Release(); void ExecuteAction(float _fDeltaSeconds, float _fDelta, const char* _pcAction); void ExecuteScript(float _fDeltaSeconds, float _fDelta, const char* _pcScript); bool m_bReload; string m_szXMLFile; CProcess* m_pProcess; }; #endif
[ "sergivalls@576ee6d0-068d-96d9-bff2-16229cd70485" ]
[ [ [ 1, 44 ] ] ]
7c4e3fe60929872daba1266bf7ca89935e1904ed
8b45808d12d2765889a9ac25bab98c0fa81a694b
/Kinect1.0Beta2inc/MSR_NuiProps.h
c7a76e67fc5122b25e2520f192e25d721dd5dafd
[]
no_license
sudogroot/kinect-activity-reaction-interface
bfe273eba3763e1ac80d781fb908b75f05ce9ee2
1b59139b04c66efaa758102478b28e3253463afd
refs/heads/master
2021-01-20T16:04:34.556584
2011-11-30T05:27:36
2011-11-30T05:27:36
46,866,739
1
0
null
null
null
null
UTF-8
C++
false
false
1,464
h
/************************************************************************ * * * MSR_NuiProps.h -- This module defines the APIs for the Natural * * User Interface(NUI) properties enumerator. * * * * Copyright (c) Microsoft Corp. All rights reserved. * * * ************************************************************************/ #pragma once #ifndef NUIAPI #error "You must include nuiapi.h rather than including nuiprops.h directly" #endif namespace MsrNui { typedef enum _NUI_PROPSINDEX { INDEX_UNIQUE_DEVICE_NAME = 0, INDEX_LAST // don't use! } NUI_PROPSINDEX; typedef enum _NUI_PROPSTYPE { PROPTYPE_UNKNOWN = 0, // don't use PROPTYPE_UINT, // no need to return anything smaller than an int PROPTYPE_FLOAT, PROPTYPE_BSTR, // returns new BSTR. Use SysFreeString( BSTR ) when you're done PROPTYPE_BLOB } NUI_PROPSTYPE; typedef struct _NUI_PROPTYPEANDSIZE { NUI_PROPSINDEX index; NUI_PROPSTYPE type; size_t size; } NUI_PROPTYPEANDSIZE; static const NUI_PROPTYPEANDSIZE g_spNuiPropsType [] = { { INDEX_UNIQUE_DEVICE_NAME, PROPTYPE_BSTR, sizeof( HANDLE ) }, }; }; // namespace MsrNui
[ [ [ 1, 45 ] ] ]
c18efc2e6d87cd735cc7d7ff5155e51d2cd0e3b8
27651c3f5f829bff0720d7f835cfaadf366ee8fa
/QBluetooth/DeviceDiscoverer/QBtDeviceDiscoverer_win32.h
42c832bdb5a45d326f4d28b2412563a3dc3794da
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
cpscotti/Push-Snowboarding
8883907e7ee2ddb9a013faf97f2d9673b9d0fad5
cc3cc940292d6d728865fe38018d34b596943153
refs/heads/master
2021-05-27T16:35:49.846278
2011-07-08T10:25:17
2011-07-08T10:25:17
1,395,155
1
1
null
null
null
null
UTF-8
C++
false
false
1,669
h
/* * QBtDeviceDiscoverer_stub.h * * * Author: Ftylitakis Nikolaos * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef QBTDEVICEDISCOVERER_STUB_H_ #define QBTDEVICEDISCOVERER_STUB_H_ #include <QBtTypes.h> #include <QBtDeviceDiscoverer.h> #include <QBtAuxFunctions.h> class QBtDeviceDiscovererPrivate { public: QBtDeviceDiscovererPrivate(QBtDeviceDiscoverer *publicClass = 0); ~QBtDeviceDiscovererPrivate(); public: void DiscoverDevices(); void StopDiscovery(); QBtDevice::List GetInquiredDevices(); bool IsBusy () const; protected: void Construct(); private: static void ReportInquiryResult(BTDEVHDL dev_hdl); static void InquiryCompleteResult(void); static void RegisterFoundDevice(BTDEVHDL dev_hdl); private: static QBtDevice::List deviceList; // handle of the win event used to indicate that discovery finished static HANDLE browseDevEventHandler; static QBtDeviceDiscoverer* sp_ptr; static bool isSearching; QBtDeviceDiscoverer *p_ptr; //Pointer to public interface }; #endif /* QBTDEVICEDISCOVERER_STUB_H_ */
[ "cpscotti@c819a03f-852d-4de4-a68c-c3ac47756727" ]
[ [ [ 1, 57 ] ] ]
c3a4a0860b114fc28699970bd38edf678d23c663
a70f708a62feb4d1b6f80d0a471b47ac584ea82b
/ arxlss --username quangvinh.ph/VLSS/LSS07.cpp
429fe468366b7bdd7d1f107f7276949f7ff28537
[]
no_license
presscad/arxlss
ae8a41acba416d20a1ec2aa4485d142912e6787d
d6d201bfc98b0d442c77b37b10ca5ac7ea5efcbb
refs/heads/master
2021-04-01T22:38:06.710239
2009-11-07T02:47:17
2009-11-07T02:47:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,789
cpp
#include "StdAfx.h" #include "Resource.h" #include "Lessons.h" #include "Logger.h" void LSS07() { CLogger::Print(_T("--------------------------| START LOGGING LESSON 07 |-----------------------------")); AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase(); browseAllAttributes(pDb); } void browseAllAttributes(AcDbDatabase* pDb) { CLogger::Print(_T("*Call: browseAllAttributes()")); Acad::ErrorStatus es; AcDbObjectIdArray idaBlockRefs; int nBlockRefCount = getBlockRefAll(pDb, idaBlockRefs); for (int nIdx = 0; nIdx < nBlockRefCount; nIdx++) { CLogger::Print(_T("---------[STT = %d]----------"), nIdx); AcDbBlockReference* pBlockRef = NULL; AcDbObjectId idBlockRef = idaBlockRefs[nIdx]; es = acdbOpenObject(pBlockRef, idBlockRef, AcDb::kForRead); if (Acad::eOk != es) { CLogger::Print(ACRX_T("Warn: Fail to open BlockReference! > Ignore"), nIdx); continue; } AcDbObjectIterator* pBlockRefIter = pBlockRef->attributeIterator(); for (; !pBlockRefIter->done(); pBlockRefIter->step()) { AcDbObjectId idObject = pBlockRefIter->objectId(); AcDbObject* pObject = NULL; es = acdbOpenAcDbObject(pObject, idObject, AcDb::kForRead); if (Acad::eOk != es) { CLogger::Print(ACRX_T("Warn: Fail to open the BlockReference's Attribute. > Ignore.")); continue; } AcDbAttribute* pAttribute = AcDbAttribute::cast(pObject); if (pAttribute) { ACHAR* szTag = pAttribute->tag(); CLogger::Print(ACRX_T("Tag = %s"), szTag); } else { CLogger::Print(ACRX_T("Warn: Fail to convert object to Attribute object.!")); } pObject->close(); } delete pBlockRefIter; pBlockRef->close(); } CLogger::Print(ACRX_T("*Exit: browseAllAttributes()")); }
[ "quangvinh.ph@29354a60-911c-11de-8f34-01a6ee357387" ]
[ [ [ 1, 59 ] ] ]
3d9325fa25d0042fd5199ea22c9985f4cfdf7d97
56d19e2be913ff0bf884b2a462374d9acb6f91ce
/WindObj.cpp
6a2ac1d6cb4db87db8d884ecf110b6bd32839b05
[]
no_license
cgoakley/laser-surfsprint
0169dddae05e0baf52cd86dc5d82ad6a32ecd402
52466d80978fb2530bcb6107196f089163d62ef4
refs/heads/master
2020-07-23T11:43:14.813042
2006-03-15T12:00:00
2016-11-17T15:57:36
73,809,817
0
0
null
null
null
null
UTF-8
C++
false
false
1,476
cpp
/* This source file should be incorporated into a project that uses WindObj in the NT environment. It provides the entry point & calls the InitApplication() function that needs to be supplied by the client to initialize the application ... */ #include <WindObj/WindObj.h> #include <windows.h> void * __cdecl clientMalloc(size_t size) { return malloc(size); } void * __cdecl clientRealloc(void *ptr, size_t size) { return realloc(ptr, size); } void __cdecl clientFree(void *ptr) { free(ptr); } typedef void * (__cdecl *MallocFunc)(size_t size); typedef void * (__cdecl *ReallocFunc)(void *ptr, size_t size); typedef void (__cdecl *FreeFunc)(void *ptr); WO_EXPORT void WindObjSetMemFuncs(MallocFunc clientMalloc, ReallocFunc clientRealloc, FreeFunc clientFree); // Exported by WindObj ... WO_EXPORT void InitAppParams(WindowVisibility &, BOOL &activated, int cmdshow, HINSTANCE hinst, HINSTANCE hinstprev); WO_EXPORT int WINAPI WindObjMain(void); int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, char *cmdLine, int cmdShow) { WindowVisibility wv; BOOL activated; InitAppParams(wv, activated, cmdShow, hInst, hInstPrev); WindObjSetMemFuncs(clientMalloc, clientRealloc, clientFree); InitApplication(cmdLine, wv, activated == TRUE); return WindObjMain(); }
[ [ [ 1, 47 ] ] ]
3f4ecc46ac3af146f00013a13ef6116f8ec4eb3f
62874cd4e97b2cfa74f4e507b798f6d5c7022d81
/src/PluginSystem/DllManager.h
b2e8019d885e0e062ba149133fd38f6dd4edf489
[]
no_license
rjaramih/midi-me
6a4047e5f390a5ec851cbdc1b7495b7fe80a4158
6dd6a1a0111645199871f9951f841e74de0fe438
refs/heads/master
2021-03-12T21:31:17.689628
2011-07-31T22:42:05
2011-07-31T22:42:05
36,944,802
0
0
null
null
null
null
UTF-8
C++
false
false
1,142
h
#ifndef PLUGIN_DLLMANAGER_H #define PLUGIN_DLLMANAGER_H // Includes #include "global.h" #include <map> namespace plugin { // Forward declarations class DynamicLibrary; /** This class is used to load/unload and manage dynamic libraries. Use this class if you want to load or unload dynamic libraries, as it makes sure that the libraries aren't loaded twice. */ class PLUGINSYSTEM_API DllManager { protected: // Typedefs typedef std::map<string, DynamicLibrary *> LibraryMap; // Member variables LibraryMap m_libraries; //!< A map containing the loaded dynamic libraries public: // Constructors and destructor DllManager(); virtual ~DllManager(); // Load / unload functions DynamicLibrary *loadLibrary(const string &filename); void unloadLibrary(const string &filename); bool isLoaded(const string &filename) const; void unloadLibraries(); // Other functions void *getSymbol(const string &library, const string &symbol) throw(); string getLastError() const; private: // Private functions void clear(); }; } #endif // PLUGIN_DLLMANAGER_H
[ "Jeroen.Dierckx@d8a2fbcc-2753-0410-82a0-8bc2cd85795f" ]
[ [ [ 1, 48 ] ] ]
766111ee0d859dbdbf2a47b6782009d87cbe1580
7b379862f58f587d9327db829ae4c6493b745bb1
/JuceLibraryCode/modules/juce_audio_basics/synthesisers/juce_Synthesiser.cpp
b81c89ddfc0d636774594a55ab15499d86730806
[]
no_license
owenvallis/Nomestate
75e844e8ab68933d481640c12019f0d734c62065
7fe7c06c2893421a3c77b5180e5f27ab61dd0ffd
refs/heads/master
2021-01-19T07:35:14.301832
2011-12-28T07:42:50
2011-12-28T07:42:50
2,950,072
2
0
null
null
null
null
UTF-8
C++
false
false
13,290
cpp
/* ============================================================================== This file is part of the JUCE library - "Jules' Utility Class Extensions" Copyright 2004-11 by Raw Material Software Ltd. ------------------------------------------------------------------------------ JUCE can be redistributed and/or modified under the terms of the GNU General Public License (Version 2), as published by the Free Software Foundation. A copy of the license is included in the JUCE distribution, or can be found online at www.gnu.org/licenses. JUCE 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. ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are available: visit www.rawmaterialsoftware.com/juce for more information. ============================================================================== */ BEGIN_JUCE_NAMESPACE //============================================================================== SynthesiserSound::SynthesiserSound() { } SynthesiserSound::~SynthesiserSound() { } //============================================================================== SynthesiserVoice::SynthesiserVoice() : currentSampleRate (44100.0), currentlyPlayingNote (-1), noteOnTime (0), keyIsDown (false), sostenutoPedalDown (false) { } SynthesiserVoice::~SynthesiserVoice() { } bool SynthesiserVoice::isPlayingChannel (const int midiChannel) const { return currentlyPlayingSound != nullptr && currentlyPlayingSound->appliesToChannel (midiChannel); } void SynthesiserVoice::setCurrentPlaybackSampleRate (const double newRate) { currentSampleRate = newRate; } void SynthesiserVoice::clearCurrentNote() { currentlyPlayingNote = -1; currentlyPlayingSound = nullptr; } //============================================================================== Synthesiser::Synthesiser() : sampleRate (0), lastNoteOnCounter (0), shouldStealNotes (true) { for (int i = 0; i < numElementsInArray (lastPitchWheelValues); ++i) lastPitchWheelValues[i] = 0x2000; } Synthesiser::~Synthesiser() { } //============================================================================== SynthesiserVoice* Synthesiser::getVoice (const int index) const { const ScopedLock sl (lock); return voices [index]; } void Synthesiser::clearVoices() { const ScopedLock sl (lock); voices.clear(); } void Synthesiser::addVoice (SynthesiserVoice* const newVoice) { const ScopedLock sl (lock); voices.add (newVoice); } void Synthesiser::removeVoice (const int index) { const ScopedLock sl (lock); voices.remove (index); } void Synthesiser::clearSounds() { const ScopedLock sl (lock); sounds.clear(); } void Synthesiser::addSound (const SynthesiserSound::Ptr& newSound) { const ScopedLock sl (lock); sounds.add (newSound); } void Synthesiser::removeSound (const int index) { const ScopedLock sl (lock); sounds.remove (index); } void Synthesiser::setNoteStealingEnabled (const bool shouldStealNotes_) { shouldStealNotes = shouldStealNotes_; } //============================================================================== void Synthesiser::setCurrentPlaybackSampleRate (const double newRate) { if (sampleRate != newRate) { const ScopedLock sl (lock); allNotesOff (0, false); sampleRate = newRate; for (int i = voices.size(); --i >= 0;) voices.getUnchecked (i)->setCurrentPlaybackSampleRate (newRate); } } void Synthesiser::renderNextBlock (AudioSampleBuffer& outputBuffer, const MidiBuffer& midiData, int startSample, int numSamples) { // must set the sample rate before using this! jassert (sampleRate != 0); const ScopedLock sl (lock); MidiBuffer::Iterator midiIterator (midiData); midiIterator.setNextSamplePosition (startSample); MidiMessage m (0xf4, 0.0); while (numSamples > 0) { int midiEventPos; const bool useEvent = midiIterator.getNextEvent (m, midiEventPos) && midiEventPos < startSample + numSamples; const int numThisTime = useEvent ? midiEventPos - startSample : numSamples; if (numThisTime > 0) { for (int i = voices.size(); --i >= 0;) voices.getUnchecked (i)->renderNextBlock (outputBuffer, startSample, numThisTime); } if (useEvent) handleMidiEvent (m); startSample += numThisTime; numSamples -= numThisTime; } } void Synthesiser::handleMidiEvent (const MidiMessage& m) { if (m.isNoteOn()) { noteOn (m.getChannel(), m.getNoteNumber(), m.getFloatVelocity()); } else if (m.isNoteOff()) { noteOff (m.getChannel(), m.getNoteNumber(), true); } else if (m.isAllNotesOff() || m.isAllSoundOff()) { allNotesOff (m.getChannel(), true); } else if (m.isPitchWheel()) { const int channel = m.getChannel(); const int wheelPos = m.getPitchWheelValue(); lastPitchWheelValues [channel - 1] = wheelPos; handlePitchWheel (channel, wheelPos); } else if (m.isController()) { handleController (m.getChannel(), m.getControllerNumber(), m.getControllerValue()); } } //============================================================================== void Synthesiser::noteOn (const int midiChannel, const int midiNoteNumber, const float velocity) { const ScopedLock sl (lock); for (int i = sounds.size(); --i >= 0;) { SynthesiserSound* const sound = sounds.getUnchecked(i); if (sound->appliesToNote (midiNoteNumber) && sound->appliesToChannel (midiChannel)) { // If hitting a note that's still ringing, stop it first (it could be // still playing because of the sustain or sostenuto pedal). for (int j = voices.size(); --j >= 0;) { SynthesiserVoice* const voice = voices.getUnchecked (j); if (voice->getCurrentlyPlayingNote() == midiNoteNumber && voice->isPlayingChannel (midiChannel)) stopVoice (voice, true); } startVoice (findFreeVoice (sound, shouldStealNotes), sound, midiChannel, midiNoteNumber, velocity); } } } void Synthesiser::startVoice (SynthesiserVoice* const voice, SynthesiserSound* const sound, const int midiChannel, const int midiNoteNumber, const float velocity) { if (voice != nullptr && sound != nullptr) { if (voice->currentlyPlayingSound != nullptr) voice->stopNote (false); voice->startNote (midiNoteNumber, velocity, sound, lastPitchWheelValues [midiChannel - 1]); voice->currentlyPlayingNote = midiNoteNumber; voice->noteOnTime = ++lastNoteOnCounter; voice->currentlyPlayingSound = sound; voice->keyIsDown = true; voice->sostenutoPedalDown = false; } } void Synthesiser::stopVoice (SynthesiserVoice* voice, const bool allowTailOff) { jassert (voice != nullptr); voice->stopNote (allowTailOff); // the subclass MUST call clearCurrentNote() if it's not tailing off! RTFM for stopNote()! jassert (allowTailOff || (voice->getCurrentlyPlayingNote() < 0 && voice->getCurrentlyPlayingSound() == 0)); } void Synthesiser::noteOff (const int midiChannel, const int midiNoteNumber, const bool allowTailOff) { const ScopedLock sl (lock); for (int i = voices.size(); --i >= 0;) { SynthesiserVoice* const voice = voices.getUnchecked (i); if (voice->getCurrentlyPlayingNote() == midiNoteNumber) { SynthesiserSound* const sound = voice->getCurrentlyPlayingSound(); if (sound != nullptr && sound->appliesToNote (midiNoteNumber) && sound->appliesToChannel (midiChannel)) { voice->keyIsDown = false; if (! (sustainPedalsDown [midiChannel] || voice->sostenutoPedalDown)) stopVoice (voice, allowTailOff); } } } } void Synthesiser::allNotesOff (const int midiChannel, const bool allowTailOff) { const ScopedLock sl (lock); for (int i = voices.size(); --i >= 0;) { SynthesiserVoice* const voice = voices.getUnchecked (i); if (midiChannel <= 0 || voice->isPlayingChannel (midiChannel)) voice->stopNote (allowTailOff); } sustainPedalsDown.clear(); } void Synthesiser::handlePitchWheel (const int midiChannel, const int wheelValue) { const ScopedLock sl (lock); for (int i = voices.size(); --i >= 0;) { SynthesiserVoice* const voice = voices.getUnchecked (i); if (midiChannel <= 0 || voice->isPlayingChannel (midiChannel)) voice->pitchWheelMoved (wheelValue); } } void Synthesiser::handleController (const int midiChannel, const int controllerNumber, const int controllerValue) { switch (controllerNumber) { case 0x40: handleSustainPedal (midiChannel, controllerValue >= 64); break; case 0x42: handleSostenutoPedal (midiChannel, controllerValue >= 64); break; case 0x43: handleSoftPedal (midiChannel, controllerValue >= 64); break; default: break; } const ScopedLock sl (lock); for (int i = voices.size(); --i >= 0;) { SynthesiserVoice* const voice = voices.getUnchecked (i); if (midiChannel <= 0 || voice->isPlayingChannel (midiChannel)) voice->controllerMoved (controllerNumber, controllerValue); } } void Synthesiser::handleSustainPedal (int midiChannel, bool isDown) { jassert (midiChannel > 0 && midiChannel <= 16); const ScopedLock sl (lock); if (isDown) { sustainPedalsDown.setBit (midiChannel); } else { for (int i = voices.size(); --i >= 0;) { SynthesiserVoice* const voice = voices.getUnchecked (i); if (voice->isPlayingChannel (midiChannel) && ! voice->keyIsDown) stopVoice (voice, true); } sustainPedalsDown.clearBit (midiChannel); } } void Synthesiser::handleSostenutoPedal (int midiChannel, bool isDown) { jassert (midiChannel > 0 && midiChannel <= 16); const ScopedLock sl (lock); for (int i = voices.size(); --i >= 0;) { SynthesiserVoice* const voice = voices.getUnchecked (i); if (voice->isPlayingChannel (midiChannel)) { if (isDown) voice->sostenutoPedalDown = true; else if (voice->sostenutoPedalDown) stopVoice (voice, true); } } } void Synthesiser::handleSoftPedal (int midiChannel, bool /*isDown*/) { (void) midiChannel; jassert (midiChannel > 0 && midiChannel <= 16); } //============================================================================== SynthesiserVoice* Synthesiser::findFreeVoice (SynthesiserSound* soundToPlay, const bool stealIfNoneAvailable) const { const ScopedLock sl (lock); for (int i = voices.size(); --i >= 0;) if (voices.getUnchecked (i)->getCurrentlyPlayingNote() < 0 && voices.getUnchecked (i)->canPlaySound (soundToPlay)) return voices.getUnchecked (i); if (stealIfNoneAvailable) { // currently this just steals the one that's been playing the longest, but could be made a bit smarter.. SynthesiserVoice* oldest = nullptr; for (int i = voices.size(); --i >= 0;) { SynthesiserVoice* const voice = voices.getUnchecked (i); if (voice->canPlaySound (soundToPlay) && (oldest == nullptr || oldest->noteOnTime > voice->noteOnTime)) oldest = voice; } jassert (oldest != nullptr); return oldest; } return nullptr; } END_JUCE_NAMESPACE
[ "ow3nskip" ]
[ [ [ 1, 439 ] ] ]
01d7e0cfd1e20dda135c5d3f84ec2c7af6b74774
9ad9345e116ead00be7b3bd147a0f43144a2e402
/Integration_WAH_&_Extraction/SMDataExtraction/Algorithm/Distribution.cpp
066a24f7709df9826a9b9e30b4077f2979cfe0b0
[]
no_license
asankaf/scalable-data-mining-framework
e46999670a2317ee8d7814a4bd21f62d8f9f5c8f
811fddd97f52a203fdacd14c5753c3923d3a6498
refs/heads/master
2020-04-02T08:14:39.589079
2010-07-18T16:44:56
2010-07-18T16:44:56
33,870,353
0
0
null
null
null
null
UTF-8
C++
false
false
6,190
cpp
#include "StdAfx.h" #include "Distribution.h" Distribution::Distribution(void) { m_perClassPerBag = NULL; m_perBag = NULL; m_perClass = NULL; m_perClassLength = 0; m_perClassPerBag = 0; } Distribution::Distribution(Distribution * toMerge) { totaL = toMerge->totaL; m_perClassLength = toMerge->m_perClassLength; m_perClass = new double [m_perClassLength]; memcpy(m_perClass,toMerge->m_perClass,m_perClassLength * sizeof(double)); m_perClassPerBag = new double*[1]; m_perClassPerBag[0] = new double [m_perClassLength]; memcpy(m_perClassPerBag[0],toMerge->m_perClassPerBag[0],m_perClassLength * sizeof(double)); m_perBag = new double [1]; m_perBagLength = 1; m_perBag[0] = totaL; } Distribution::Distribution(int _num_bags,int _num_classes) { int i; m_perClassPerBag = new double * [_num_bags]; m_perBagLength = _num_bags; m_perClassLength = _num_classes; m_perBag = new double [_num_bags]; m_perClass = new double [_num_classes]; for (i=0;i<_num_bags;i++) { m_perClassPerBag[i] = new double [_num_classes]; } initialiseArrays(); totaL = 0; } void Distribution::initialiseArrays() { for (size_t i = 0 ; i < m_perBagLength ; i++) { m_perBag[i] = 0; } for (size_t i = 0 ; i < m_perClassLength ; i++) { m_perClass[i] = 0; } for (size_t i = 0 ; i < m_perBagLength ; i++) { for (size_t j = 0 ; j < m_perClassLength ; j++) { m_perClassPerBag[i][j] = 0; } } } Distribution::~Distribution(void) { ClearClassPerBags(); ClearBags(); ClearClass(); } void Distribution::Print() { cout << "Printing distribution" << endl; if (m_perClass != NULL) { cout << "Perclass array :" ; for (size_t i = 0 ; i < m_perClassLength ; i++) { cout << m_perClass[i] << " , "; } cout << endl; } else { cout << "Perclass is NULL" << endl; } if (m_perBag != NULL) { cout << "PerBag array :" ; for (size_t i = 0 ; i < m_perBagLength ; i++) { cout << m_perBag[i] << " , "; } cout << endl; } else { cout << "Perclass is NULL" << endl; } if (m_perClassPerBag != NULL) { cout << "PerClassPerBag array :" ; for (size_t i = 0 ; i < m_perBagLength ; i++) { for (size_t j = 0 ; j < m_perClassLength ; j++) { cout << m_perClassPerBag[i][j] << " , "; } cout<< endl; } } else { cout << "Perclassperbag is NULL" << endl; } cout << endl; } double Distribution::numCorrect() { return m_perClass[maxClass()]; } int Distribution::maxBag() { double max; int maxIndex; int i; max = 0; maxIndex = -1; for (i=0;i<m_perBagLength;i++) if (Utils::grOrEq(m_perBag[i],max)) { max = m_perBag[i]; maxIndex = i; } return maxIndex; } double Distribution::numIncorrect() { return totaL-numCorrect(); } Distribution::Distribution(DataSource * source, BitStreamInfo * _existence_map) { m_perClassPerBag = new double * [1]; m_perBag = new double [1]; m_perBagLength = 1; m_perBag[0] = 0; totaL = 0; m_perClassLength = source->numClasses(); m_perClass = new double[m_perClassLength]; // for (size_t i = 0 ; i < m_perClassLength ; i++) // { // m_perClass[i] = 0; // } m_perClassPerBag[0] = new double[source->numClasses()]; // for (size_t i = 0 ; i < m_perBagLength ; i++) // { // for (size_t j = 0 ; j < m_perClassLength ; j++) // { // m_perClassPerBag[i][j] = 0; // } // } initialiseArrays(); add(0,source,_existence_map); } double Distribution::perBag(int bagIndex) { return m_perBag[bagIndex]; } double Distribution::perClass(int classIndex) { return m_perClass[classIndex]; } double Distribution::perClassPerBag(int bagIndex, int classIndex) { return m_perClassPerBag[bagIndex][classIndex]; } double Distribution::numIncorrect(int index) { return m_perBag[index]- numCorrect(index); } int Distribution::maxClass(int index) { double maxCount = 0; int maxIndex = 0; int i; if (Utils::gr(m_perBag[index],0)) { for (i=0;i<m_perClassLength;i++) if (Utils::gr(m_perClassPerBag[index][i],maxCount)) { maxCount = m_perClassPerBag[index][i]; maxIndex = i; } return maxIndex; }else return maxClass(); } double Distribution::numCorrect(int index) { return m_perClassPerBag[index][maxClass(index)]; } int Distribution::maxClass() { double maxCount = 0; int maxIndex = 0; int i; for (i=0;i<m_perClassLength;i++) if (Utils::gr(m_perClass[i],maxCount)) { maxCount = m_perClass[i]; maxIndex = i; } return maxIndex; } // double Distribution::perClass(int classIndex) // { // return m_perClass[classIndex]; // } bool Distribution::check(double minNoObj) { int counter = 0; int i; for (i=0;i<m_perBagLength;i++) { if (Utils::grOrEq(m_perBag[i],minNoObj)) counter++; } if (counter > 1) return true; else return false; } void Distribution::add(int bagIndex,DataSource * instance, BitStreamInfo * _existence_map) { size_t classIndex; double weight; Attribute * attribute = instance->Attributes()[instance->ClassIndex()]; vector<DistinctValue *> classes = attribute->UniqueValues(); weight = attribute->Weight(); BitStreamInfo * new_value = NULL; int count_val = 0; for (classIndex = 0 ; classIndex < classes.size() ; classIndex++) { new_value = *(_existence_map) & *(classes[classIndex]->Value()); count_val = new_value->Count(); m_perClassPerBag[bagIndex][classIndex] = m_perClassPerBag[bagIndex][classIndex] +count_val * weight; m_perBag[bagIndex] = m_perBag[bagIndex]+ count_val * weight; m_perClass[classIndex] = m_perClass[classIndex]+count_val * weight; delete new_value; } totaL = totaL + _existence_map->Count() * weight; } void Distribution::ClearClassPerBags() { if (m_perClassPerBag != NULL) { for (size_t i = 0 ; i < m_perBagLength ; i++) { delete m_perClassPerBag[i]; m_perClassPerBag[i] = NULL; } } delete m_perClassPerBag; } void Distribution::ClearBags() { delete m_perBag; } void Distribution::ClearClass() { delete m_perClass; }
[ "jaadds@c7f6ba40-6498-11de-987a-95e5a5a5d5f1" ]
[ [ [ 1, 298 ] ] ]
a66abe77bd171ed81ed8610190d45f241f9a3e33
4813a54584f8e8a8a2d541291a08b244640a7f77
/libxl/src/utilities.cpp
67c133523b505956fa8938877ce17b770ca6a221
[]
no_license
cyberscorpio/libxl
fcc0c67390dd8eae4bb7d36f6a459ffed368183a
8d27566f45234af214a7a1e19c455e9721073e8c
refs/heads/master
2021-01-19T16:56:51.990977
2010-06-30T08:18:41
2010-06-30T08:18:41
38,444,794
0
0
null
null
null
null
UTF-8
C++
false
false
2,938
cpp
#include <assert.h> #include <Windows.h> #include "../include/utilities.h" XL_BEGIN ////////////////////////////////////////////////////////////////////////// // trace void trace (const tchar *format, ...) { va_list args; int len; tchar *buffer, *bufferex; tchar buf[MAX_PATH]; tchar bufex[MAX_PATH]; tstring formatex; va_start(args, format); len = _vsctprintf(format, args) + 32; if (len > MAX_PATH) { buffer = (tchar *)malloc(len * sizeof(tchar)); bufferex = (tchar *)malloc(len * sizeof(tchar)); } else { buffer = buf; bufferex = bufex; } assert(buffer); _vstprintf_s(buffer, len, format, args); _stprintf_s(bufferex, len, _T("%d(tid:%d):\t%s"), ::GetTickCount(), ::GetCurrentThreadId(), buffer); OutputDebugString(bufferex); if (buffer != buf) { free(buffer); } if (bufferex != bufex) { free(bufferex); } } ////////////////////////////////////////////////////////////////////////// // CTimerLogger void CTimerLogger::_Init (const tchar *format, va_list args) { int len; tchar *buffer; tchar buf[MAX_PATH]; tstring formatex; len = _vsctprintf(format, args) + 1; if (len > MAX_PATH) { buffer = (tchar *)malloc(len * sizeof(tchar)); } else { buffer = buf; } assert(buffer); _vstprintf_s(buffer, len, format, args); m_msg = buffer; if (buffer != buf) { free(buffer); } } CTimerLogger::CTimerLogger (const tchar *format, ...) : m_logged(false) , m_tick(::GetTickCount()) { va_list args; va_start(args, format); _Init(format, args); } CTimerLogger::~CTimerLogger () { log(); } void CTimerLogger::log () { if (!m_logged) { m_logged = true; m_tick = ::GetTickCount() - m_tick; trace(_T("%s: %dms\n"), m_msg.c_str(), m_tick); } } void CTimerLogger::restart (const tchar *format, ...) { m_logged = false; va_list args; va_start(args, format); _Init(format, args); } ////////////////////////////////////////////////////////////////////////// // CScopeLock CScopeLock::CScopeLock (const ILockable *lock) : m_lock(NULL) { this->lock(lock); } CScopeLock::CScopeLock (ILockable *lock) : m_lock(NULL) { this->lock(lock); } CScopeLock::~CScopeLock () { unlock(); } void CScopeLock::lock (const ILockable *lock) { assert(lock != NULL); assert(m_lock == NULL); lock->lock(); m_lock = lock; } void CScopeLock::unlock () { if (m_lock) { m_lock->unlock(); m_lock = NULL; } } ////////////////////////////////////////////////////////////////////////// // OS Version #ifdef WIN32 bool os_is_xp () { OSVERSIONINFO osv; osv.dwOSVersionInfoSize = sizeof(osv); ::GetVersionEx(&osv); return osv.dwMajorVersion == 5; } bool os_is_vista_or_later () { OSVERSIONINFO osv; osv.dwOSVersionInfoSize = sizeof(osv); ::GetVersionEx(&osv); return osv.dwMajorVersion >= 6; } #endif XL_END
[ "doudehou@59b6eb50-eb15-11de-b362-3513cf04e977", "[email protected]" ]
[ [ [ 1, 1 ], [ 3, 3 ], [ 5, 5 ], [ 7, 8 ], [ 15, 18 ], [ 22, 29 ], [ 32, 32 ], [ 34, 34 ], [ 36, 41 ], [ 48, 48 ], [ 54, 54 ], [ 70, 116 ], [ 118, 119 ], [ 122, 129 ], [ 148, 149 ] ], [ [ 2, 2 ], [ 4, 4 ], [ 6, 6 ], [ 9, 14 ], [ 19, 21 ], [ 30, 31 ], [ 33, 33 ], [ 35, 35 ], [ 42, 47 ], [ 49, 53 ], [ 55, 69 ], [ 117, 117 ], [ 120, 121 ], [ 130, 147 ] ] ]
78d14d031228e2082f795436031928bc43e825df
5fb9b06a4bf002fc851502717a020362b7d9d042
/developertools/GumpEditor/ToolBarEx.h
59f8defc4cf77564e63f3a0ea7da8fb4e1c59a20
[]
no_license
bravesoftdz/iris-svn
8f30b28773cf55ecf8951b982370854536d78870
c03438fcf59d9c788f6cb66b6cb9cf7235fbcbd4
refs/heads/master
2021-12-05T18:32:54.525624
2006-08-21T13:10:54
2006-08-21T13:10:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,396
h
#ifndef __TOOLBAREX_H__ #define __TOOLBAREX_H__ ///////////////////////////////////////////////////////////////////////////// // CSmartComboBox class CSmartComboBox : public CComboBox { public: CSmartComboBox(); int m_nMaxStrings; BOOL CreateFont(LONG lfHeight, LONG lfWeight, LPCTSTR lpszFaceName); int AddString(LPCTSTR str); int InsertString(int index, LPCTSTR str); // Generated message map functions protected: afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); DECLARE_MESSAGE_MAP() public: virtual BOOL PreTranslateMessage(MSG* pMsg); afx_msg void OnEditPaste(); }; #define USE_SMART_COMBO_BOX class CToolBarWithCombo : public CToolBar { public: #ifdef USE_SMART_COMBO_BOX CSmartComboBox m_comboBox1; CSmartComboBox m_comboBox2; #else CComboBox m_comboBox1; CComboBox m_comboBox2; #endif // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CToolBarWithCombo) virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); //}}AFX_VIRTUAL BOOL CreateComboBox(class CComboBox& comboBox, UINT nIndex, UINT nID, int nWidth, int nDropHeight); // Generated message map functions protected: //{{AFX_MSG(CToolBarWithCombo) //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// #endif // __TOOLBAREX_H__
[ "sience@a725d9c3-d2eb-0310-b856-fa980ef11a19" ]
[ [ [ 1, 58 ] ] ]
bd90639b25601f49ee9d0a13833073d9ef4d254b
33f59b1ba6b12c2dd3080b24830331c37bba9fe2
/Depend/Foundation/Intersection/Wm4IntrPlane3Box3.h
fd849182a9d03f280974ce82f2f5540fc5bdd5b7
[]
no_license
daleaddink/flagship3d
4835c223fe1b6429c12e325770c14679c42ae3c6
6cce5b1ff7e7a2d5d0df7aa0594a70d795c7979a
refs/heads/master
2021-01-15T16:29:12.196094
2009-11-01T10:18:11
2009-11-01T10:18:11
37,734,654
1
0
null
null
null
null
UTF-8
C++
false
false
1,411
h
// Geometric Tools, Inc. // http://www.geometrictools.com // Copyright (c) 1998-2006. All Rights Reserved // // The Wild Magic Version 4 Foundation Library source code is supplied // under the terms of the license agreement // http://www.geometrictools.com/License/Wm4FoundationLicense.pdf // and may not be copied or disclosed except in accordance with the terms // of that agreement. #ifndef WM4INTRPLANE3BOX3_H #define WM4INTRPLANE3BOX3_H #include "Wm4FoundationLIB.h" #include "Wm4Intersector.h" #include "Wm4Plane3.h" #include "Wm4Box3.h" namespace Wm4 { template <class Real> class WM4_FOUNDATION_ITEM IntrPlane3Box3 : public Intersector<Real,Vector3<Real> > { public: IntrPlane3Box3 (const Plane3<Real>& rkPlane, const Box3<Real>& rkBox); // object access const Plane3<Real>& GetPlane () const; const Box3<Real>& GetBox () const; // static intersection query virtual bool Test (); // Culling support. The view frustum is assumed to be on the positive // side of the plane. The box is culled if it is on the negative side // of the plane. bool BoxIsCulled () const; protected: // the objects to intersect const Plane3<Real>& m_rkPlane; const Box3<Real>& m_rkBox; }; typedef IntrPlane3Box3<float> IntrPlane3Box3f; typedef IntrPlane3Box3<double> IntrPlane3Box3d; } #endif
[ "yf.flagship@e79fdf7c-a9d8-11de-b950-3d5b5f4ea0aa" ]
[ [ [ 1, 53 ] ] ]
f6d067445813b9d85e3e09309cbf5d20edda1b29
10bac563fc7e174d8f7c79c8777e4eb8460bc49e
/math/metric_utils.h
97596e4c0dcf87bdbd14a9607166bbc0be0abeca
[]
no_license
chenbk85/alcordev
41154355a837ebd15db02ecaeaca6726e722892a
bdb9d0928c80315d24299000ca6d8c492808f1d5
refs/heads/master
2021-01-10T13:36:29.338077
2008-10-22T15:57:50
2008-10-22T15:57:50
44,953,286
0
1
null
null
null
null
UTF-8
C++
false
false
953
h
#ifndef metric_utils_H_INCLUDED #define metric_utils_H_INCLUDED #include "alcor/math/all_math.h" #include "alcor/core/core.h" namespace all { namespace math { struct metric_utils { static double delta_angle_as_degree(math::pose2d pose_, math::point2d target_) { double delta1 = target_.get_x1() - pose_.get_x1(); double delta2 = target_.get_x2() - pose_.get_x2(); double delta_ang = ::atan2(-delta2, delta1); double delta_finale = delta_ang - pose_.get_th(math::rad_tag); return core::dconstants::rad_to_deg(delta_finale) ; }; static double target_tilt_angle_as_degree(math::point2d from, math::point2d to, double height) { double dist = math::distance(from, to); if(dist != 0) { double theta_rad = ::asin(height/dist); return core::dconstants::rad_to_deg(theta_rad); } else return 0; } }; }} //namespaces #endif //metric_utils_H_INCLUDED
[ "andrea.carbone@1c7d64d3-9b28-0410-bae3-039769c3cb81" ]
[ [ [ 1, 37 ] ] ]
ec534bf9e56f0cc89442af6c809b5a59afcfa957
3d7fc34309dae695a17e693741a07cbf7ee26d6a
/aluminizerSIM/simulator.cpp
9ee7813b2017d17774aceb4caef3a5934ea882d1
[ "LicenseRef-scancode-public-domain" ]
permissive
nist-ionstorage/ionizer
f42706207c4fb962061796dbbc1afbff19026e09
70b52abfdee19e3fb7acdf6b4709deea29d25b15
refs/heads/master
2021-01-16T21:45:36.502297
2010-05-14T01:05:09
2010-05-14T01:05:09
20,006,050
5
0
null
null
null
null
UTF-8
C++
false
false
1,460
cpp
#include "simulator.h" #include "MessageLoop.h" #include "host_interface.h" #include <malloc.h> #include <vector> #include <iostream> #ifndef ALUMINIZER_SIM #include <arpa/inet.h> #endif using namespace std; host_interface* host; extern QTcpSocket* pGbE_msg_TCP; simulator_connection::simulator_connection(QTcpServer* tcp_server, simulator* sim) : tcp_server(tcp_server), sim(sim) { unsigned msgSize = MIN_MSG_LENGTH; printf("Message length = %d bytes\r\n", msgSize); host = new host_interface(0); } simulator_connection::~simulator_connection() { delete host; host=0; } void simulator_connection::on_newConnection() { printf("Accepting new connection.\r\n"); tcp_sock = tcp_server->nextPendingConnection(); pGbE_msg_TCP = tcp_sock; QObject::connect(tcp_sock, SIGNAL(readyRead()), this, SLOT(on_readyRead())); } void simulator_connection::on_readyRead() { GbE_msg msg_in; GbE_msg msg_out; //read in linked-list of messages //printf("reading message ... \r\n"); msg_in.rcv(); unsigned iQuit = process_message(msg_in, msg_out, false); msg_out.snd(); if(iQuit) { printf("Closing socket.\r\n"); tcp_sock->close(); } } simulator::simulator() { } void SetDAC(unsigned iChannel, unsigned dacWord) { cout << "DAC<" << iChannel << "> = " << (0.05 + (((double)dacWord)/0x3FFF) * 2.95) * 3.52 - 0.05 * 2.52 << endl; }
[ "trosen@814e38a0-0077-4020-8740-4f49b76d3b44" ]
[ [ [ 1, 73 ] ] ]
0b90706d926b50b835fa93a0cbfb1b84d8d5b532
41e29f395da420f773dccb1728c07b4544aa9165
/stdset_wrapper.h
2b6c3c2af07e94f63dff10838bf98314ce48418a
[]
no_license
mleece/PyBW
98d038ba2480cc7ae23952186fc09f461fb06b2a
7bd880a670851e84f8730ca667a2368e83c6a266
refs/heads/master
2020-11-30T11:54:27.496576
2011-11-30T01:15:28
2011-11-30T01:15:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,366
h
#pragma once #include <set> template<class T> class SetWrapper { private: const std::set<T>& _set; typename std::set<T>::const_iterator _iter; public: SetWrapper(const std::set<T>& original) : _set( original ) { _iter = _set.begin(); } ~SetWrapper() { } int __len__() { return _set.size(); } bool __contains__(T item) { std::set<T>::const_iterator iter = this->_set.find(item); return iter != this->_set.end(); } SetWrapper<T>* __iter__() { _iter = _set.begin(); return new SetWrapper<T>(_set); } T next() { if (_iter == _set.end()) { return NULL; } return *(_iter++); } }; template<class T> class SetWrapper_PtrNext { private: const std::set<T>& _set; typename std::set<T>::const_iterator _iter; public: SetWrapper_PtrNext(const std::set<T>& original) : _set( original ) { _iter = _set.begin(); } ~SetWrapper_PtrNext() { } int __len__() { return _set.size(); } bool __contains__(T item) { std::set<T>::const_iterator iter = this->_set.find(item); return iter != this->_set.end(); } SetWrapper_PtrNext<T>* __iter__() { _iter = _set.begin(); return new SetWrapper_PtrNext<T>(_set); } const T* next() { if (_iter == _set.end()) { return NULL; } return &*(_iter++); } };
[ [ [ 1, 93 ] ] ]
24e912dd51475f0ed0d7feec69e10b4eb5b36499
b7c505dcef43c0675fd89d428e45f3c2850b124f
/Src/SimulatorQt/Util/qt/Win32/include/Qt/qxmlformatter.h
e05a8267a2765590aec77aa36726eaf547922314
[ "BSD-2-Clause" ]
permissive
pranet/bhuman2009fork
14e473bd6e5d30af9f1745311d689723bfc5cfdb
82c1bd4485ae24043aa720a3aa7cb3e605b1a329
refs/heads/master
2021-01-15T17:55:37.058289
2010-02-28T13:52:56
2010-02-28T13:52:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,444
h
/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information ([email protected]) ** ** This file is part of the QtXmlPatterns module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Commercial License Agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at [email protected]. ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QXMLFORMATTER_H #define QXMLFORMATTER_H #include <QtXmlPatterns/QXmlSerializer> QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(XmlPatterns) class QIODevice; class QTextCodec; class QXmlQuery; class QXmlFormatterPrivate; class Q_XMLPATTERNS_EXPORT QXmlFormatter : public QXmlSerializer { public: QXmlFormatter(const QXmlQuery &query, QIODevice *outputDevice); virtual void characters(const QStringRef &value); virtual void comment(const QString &value); virtual void startElement(const QXmlName &name); virtual void endElement(); virtual void attribute(const QXmlName &name, const QStringRef &value); virtual void processingInstruction(const QXmlName &name, const QString &value); virtual void atomicValue(const QVariant &value); virtual void startDocument(); virtual void endDocument(); virtual void startOfSequence(); virtual void endOfSequence(); int indentationDepth() const; void setIndentationDepth(int depth); /* The members below are internal, not part of the public API, and * unsupported. Using them leads to undefined behavior. */ virtual void item(const QPatternist::Item &item); private: inline void startFormattingContent(); Q_DECLARE_PRIVATE(QXmlFormatter) }; QT_END_NAMESPACE QT_END_HEADER #endif
[ "alon@rogue.(none)" ]
[ [ [ 1, 94 ] ] ]
50abe96065b6d1068c919ad0b5769eb49966476a
478570cde911b8e8e39046de62d3b5966b850384
/apicompatanamdw/bcdrivers/mw/web/browser_control_api/src/BrCtlBCTestDocument.cpp
2efbdb2e6581616567670ccbb3014d2b0e88064d
[]
no_license
SymbianSource/oss.FCL.sftools.ana.compatanamdw
a6a8abf9ef7ad71021d43b7f2b2076b504d4445e
1169475bbf82ebb763de36686d144336fcf9d93b
refs/heads/master
2020-12-24T12:29:44.646072
2010-11-11T14:03:20
2010-11-11T14:03:20
72,994,432
0
0
null
null
null
null
UTF-8
C++
false
false
1,599
cpp
/* * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: ?Description * */ // INCLUDE FILES #include "BrCtlBCTestDocument.h" #include "BrCtlBCTestAppUi.h" // ================= MEMBER FUNCTIONS ======================= // constructor CBrCtlBCTestDocument::CBrCtlBCTestDocument(CEikApplication& aApp) : CAknDocument(aApp) { } // destructor CBrCtlBCTestDocument::~CBrCtlBCTestDocument() { } // EPOC default constructor can leave. void CBrCtlBCTestDocument::ConstructL() { } // Two-phased constructor. CBrCtlBCTestDocument* CBrCtlBCTestDocument::NewL( CEikApplication& aApp) // CBrCtlBCTestApp reference { CBrCtlBCTestDocument* self = new (ELeave) CBrCtlBCTestDocument( aApp ); CleanupStack::PushL( self ); self->ConstructL(); CleanupStack::Pop(); return self; } // ---------------------------------------------------- // CBrCtlBCTestDocument::CreateAppUiL() // constructs CBrCtlBCTestAppUi // ---------------------------------------------------- // CEikAppUi* CBrCtlBCTestDocument::CreateAppUiL() { return new (ELeave) CBrCtlBCTestAppUi; } // End of File
[ "none@none" ]
[ [ [ 1, 65 ] ] ]