blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
5
146
content_id
stringlengths
40
40
detected_licenses
listlengths
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
listlengths
1
16
author_lines
listlengths
1
16
1f3a151d7016461983c54d797b4dd87a65ee43be
db4b7dac5ea1593f60229f4dd916e4d275d2f6ac
/Client.h
c52a95f3ffa13e951f68cac48aed3c2c7a8bee3f
[]
no_license
riyuexing/virtualdrafter
77337e757ea41bb2e3b184a123627a69cc47b5e6
1e8de27bb176b395c2220de71f8360424d85be9a
refs/heads/master
2022-04-05T12:19:08.060306
2009-05-09T11:21:02
2018-01-07T20:11:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,849
h
//--------------------------------------------------------------------------- #ifndef ClientH #define ClientH //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> #include "CurrEdit.hpp" #include "ToolEdit.hpp" #include <Mask.hpp> #include <ScktComp.hpp> #include "Placemnt.hpp" #include "CardData.h" #include <ComCtrls.hpp> class TDraftPlayer; //--------------------------------------------------------------------------- class TfmClient : public TForm { __published: // IDE-managed Components TClientSocket *ClientSocket1; TCurrencyEdit *edPort; TLabel *Label1; TLabel *Label2; TEdit *edHost; TButton *btGo; TFormStorage *FormStorage1; TStatusBar *StatusBar1; TButton *btCancel; void __fastcall btGoClick(TObject *Sender); void __fastcall ClientSocket1Connect(TObject *Sender, TCustomWinSocket *Socket); void __fastcall ClientSocket1Read(TObject *Sender, TCustomWinSocket *Socket); void __fastcall ClientSocket1Disconnect(TObject *Sender, TCustomWinSocket *Socket); void __fastcall ClientSocket1Error(TObject *Sender, TCustomWinSocket *Socket, TErrorEvent ErrorEvent, int &ErrorCode); private: // User declarations AnsiString Buffer; TCardPile Booster; //TCardPile Picked; public: // User declarations TDraftPlayer* Player; __fastcall TfmClient(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TfmClient *fmClient; void ClientDraft(); //--------------------------------------------------------------------------- #endif
[ [ [ 1, 57 ] ] ]
d5ee280f8212bd5c5eaad4695d5b2503d4b0b9dd
3d7fc34309dae695a17e693741a07cbf7ee26d6a
/aluminizer/Histogram.cpp
eb3b96e36c8ed1da84940cf20884c721b52970c0
[ "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,909
cpp
#ifdef PRECOMPILED_HEADER #include "common.h" #endif #include "AluminizerApp.h" #include "Histogram.h" #include "ExperimentPage.h" #include "FPGA_connection.h" DataChannel::DataChannel(const string& sName, bool bPlot, int precision) : value(0), sName(sName), CurrentData(0), bPlot(bPlot), NumPointsInAverage(0), NumShots(0), NumInStats(0), minValue(numeric_limits<int>::min()), maxValue(numeric_limits<int>::max()), precision(precision), total(0), mean(1), sum_squared_differences(0), std_dev(1) { } void DataChannel::StartNewAverage() { value = 0; NumShots = 0; NumPointsInAverage = 0; } double DataChannel::AcquireNewData() { NumShots++; return AverageCurrentData(); } double DataChannel::AcquireSingleShot() { NumShots++; return CurrentData; } double DataChannel::AverageCurrentData() { //average in the current data value = (value * NumPointsInAverage + CurrentData) / (NumPointsInAverage + 1); NumPointsInAverage++; return value; } void DataChannel::UpdateStats(double d) { NumInStats++; total += d; mean = total / NumInStats; sum_squared_differences += (d - mean) * (d - mean); std_dev = sqrt(sum_squared_differences / NumInStats); } double HistogramChannel::AcquireSingleShot() { return 0; } double HistogramChannel::InternalAverage() const { double average = 0; for (unsigned i = 0; i < data.size(); i++) average += i * data[i]; if (double sum = data.sum()) return average / sum; else return 0; } void HistogramChannel::StartNewAverage() { for (size_t j = 0; j < data.size(); j++) data[j] = 0; DataChannel::StartNewAverage(); } void HistogramChannel::SetHistogram(const std::vector<unsigned int>& r) { unsigned nMax = data.size(); for (size_t i = 0; i < r.size(); i++) if (r[i] < nMax) data[r[i]]++; NumShots = r.size(); }
[ "trosen@814e38a0-0077-4020-8740-4f49b76d3b44" ]
[ [ [ 1, 104 ] ] ]
2d6352a7a0f9ec9ac110ef8238c003b8a0468b8b
5e6ff9e6e8427078135a7b4d3b194bcbf631e9cd
/EngineSource/dpslim/dpslim/Simulation/Headers/Channel.h
1c5b264ba780c540f78e74fa58419435309a8f9d
[]
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
456
h
#include "stdafx.h" class Channel { public: CString iChanName; int iChannelIndex; int iChannelID; double iPctChanceChosen; double iCumPctChanceChosen; Channel() {;} Channel(const Channel* x) { iChanName = x->iChanName; iChannelIndex = x->iChannelIndex; iChannelID = x->iChannelID; iPctChanceChosen = x->iPctChanceChosen; iCumPctChanceChosen = x->iCumPctChanceChosen; } void InitializeChannel(void); };
[ "Isaac.Noble@fd82578e-0ebe-11df-96d9-85c6b80b8d9c" ]
[ [ [ 1, 23 ] ] ]
9a3dd3fe456ff2af38dc45ce22b6e915451473ec
fac8de123987842827a68da1b580f1361926ab67
/inc/physics/Common/SceneData/Skin/hkxSkinBinding.h
4889ca709dcc6a5820998f898e50ea7aff1f8461
[]
no_license
blockspacer/transporter-game
23496e1651b3c19f6727712a5652f8e49c45c076
083ae2ee48fcab2c7d8a68670a71be4d09954428
refs/heads/master
2021-05-31T04:06:07.101459
2009-02-19T20:59:59
2009-02-19T20:59:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,227
h
/* * * Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's * prior written consent.This software contains code, techniques and know-how which is confidential and proprietary to Havok. * Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2008 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement. * */ #ifndef HKSCENEDATA_SKIN_HKXSKINBINDING_HKCLASS_H #define HKSCENEDATA_SKIN_HKXSKINBINDING_HKCLASS_H /// hkxSkinBinding meta information extern const class hkClass hkxSkinBindingClass; /// A relationship between a given mesh and a set of 'bones' (nodes in the scene /// graph). Can be used to create more runtime specific structures after initial /// export. class hkxSkinBinding { public: HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_SCENE_DATA, hkxSkinBinding ); HK_DECLARE_REFLECTION(); // // Members // public: /// The mesh to be skinned. class hkxMesh* m_mesh; /// A mapping from mesh indices to hkxNodes. class hkxNode** m_mapping; hkInt32 m_numMapping; /// The world transforms for the bind pose for each of the referenced bones above. hkMatrix4* m_bindPose; hkInt32 m_numBindPose; /// The skin world transform when the skin was bound (world-from-skinMesh transform) hkMatrix4 m_initSkinTransform; }; #endif // HKSCENEDATA_SKIN_HKXSKINBINDING_HKCLASS_H /* * Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20080529) * * Confidential Information of Havok. (C) Copyright 1999-2008 * Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok * Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership * rights, and intellectual property rights in the Havok software remain in * Havok and/or its suppliers. * * Use of this software for evaluation purposes is subject to and indicates * acceptance of the End User licence Agreement for this product. A copy of * the license is included with this software and is also available at * www.havok.com/tryhavok * */
[ "uraymeiviar@bb790a93-564d-0410-8b31-212e73dc95e4" ]
[ [ [ 1, 60 ] ] ]
8f67ca2b5c97a72883b0d1def96986ddd601e1e2
a30b091525dc3f07cd7e12c80b8d168a0ee4f808
/EngineAll/Math/Matrix4.cpp
4585f099da1b831aad6768adff007b588f33b409
[]
no_license
ghsoftco/basecode14
f50dc049b8f2f8d284fece4ee72f9d2f3f59a700
57de2a24c01cec6dc3312cbfe200f2b15d923419
refs/heads/master
2021-01-10T11:18:29.585561
2011-01-23T02:25:21
2011-01-23T02:25:21
47,255,927
0
0
null
null
null
null
UTF-8
C++
false
false
22,464
cpp
/* Matrix4.cpp Written by Matthew Fisher a 4x4 Matrix4 structure. Used very often for affine vector transformations. */ #include "..\\..\\Main.h" #include "Matrix4.h" Matrix4::Matrix4() { } Matrix4::Matrix4(const Matrix4 &M) { for(UINT Row = 0; Row < 4; Row++) { for(UINT Col = 0; Col < 4; Col++) { _Entries[Row][Col] = M[Row][Col]; } } } Matrix4::Matrix4(const Vec3f &V0, const Vec3f &V1, const Vec3f &V2) { _Entries[0][0] = V0.x; _Entries[0][1] = V0.y; _Entries[0][2] = V0.z; _Entries[0][3] = 0.0f; _Entries[1][0] = V1.x; _Entries[1][1] = V1.y; _Entries[1][2] = V1.z; _Entries[1][3] = 0.0f; _Entries[2][0] = V2.x; _Entries[2][1] = V2.y; _Entries[2][2] = V2.z; _Entries[2][3] = 0.0f; _Entries[3][0] = 0.0f; _Entries[3][1] = 0.0f; _Entries[3][2] = 0.0f; _Entries[3][3] = 1.0f; } #ifdef USE_D3D Matrix4::Matrix4(const D3DXMATRIX &M) { for(UINT Row = 0; Row < 4; Row++) { for(UINT Col = 0; Col < 4; Col++) { _Entries[Row][Col] = M(Row, Col); } } } #endif Matrix4& Matrix4::operator = (const Matrix4 &M) { for(UINT Row = 0; Row < 4; Row++) { for(UINT Col = 0; Col < 4; Col++) { _Entries[Row][Col] = M[Row][Col]; } } return (*this); } String Matrix4::CommaSeperatedString() const { String Result; for(UINT i = 0; i < 4; i++) { for(UINT i2 = 0; i2 < 4; i2++) { Result += String(_Entries[i][i2]); if(i2 != 3) { Result += ", "; } } if(i != 3) { Result += "\n"; } } return Result; } String Matrix4::CommaSeperatedStringSingleLine() const { String Result; for(UINT i = 0; i < 4; i++) { Result += "("; for(UINT i2 = 0; i2 < 4; i2++) { Result += String(_Entries[i][i2]); if(i2 != 3) { Result += ", "; } } Result += ")"; } return Result; } String Matrix4::SpaceSeperatedStringSingleLine() const { String Result; for(UINT i = 0; i < 4; i++) { for(UINT i2 = 0; i2 < 4; i2++) { Result += String(_Entries[i][i2]); if(i2 != 3) { Result += " "; } } } return Result; } String Matrix4::TabSeperatedString() const { String Result; for(UINT i = 0; i < 4; i++) { for(UINT i2 = 0; i2 < 4; i2++) { Result += String(_Entries[i][i2]); if(i2 != 3) { Result += ", "; } } if(i != 3) { Result += "\n"; } } return Result; } Matrix4 Matrix4::Inverse() const { // // Inversion by Cramer's rule. Code taken from an Intel publication // double Result[4][4]; double tmp[12]; /* temp array for pairs */ double src[16]; /* array of transpose source matrix */ double det; /* determinant */ /* transpose matrix */ for (UINT i = 0; i < 4; i++) { src[i + 0 ] = (*this)[i][0]; src[i + 4 ] = (*this)[i][1]; src[i + 8 ] = (*this)[i][2]; src[i + 12] = (*this)[i][3]; } /* calculate pairs for first 8 elements (cofactors) */ tmp[0] = src[10] * src[15]; tmp[1] = src[11] * src[14]; tmp[2] = src[9] * src[15]; tmp[3] = src[11] * src[13]; tmp[4] = src[9] * src[14]; tmp[5] = src[10] * src[13]; tmp[6] = src[8] * src[15]; tmp[7] = src[11] * src[12]; tmp[8] = src[8] * src[14]; tmp[9] = src[10] * src[12]; tmp[10] = src[8] * src[13]; tmp[11] = src[9] * src[12]; /* calculate first 8 elements (cofactors) */ Result[0][0] = tmp[0]*src[5] + tmp[3]*src[6] + tmp[4]*src[7]; Result[0][0] -= tmp[1]*src[5] + tmp[2]*src[6] + tmp[5]*src[7]; Result[0][1] = tmp[1]*src[4] + tmp[6]*src[6] + tmp[9]*src[7]; Result[0][1] -= tmp[0]*src[4] + tmp[7]*src[6] + tmp[8]*src[7]; Result[0][2] = tmp[2]*src[4] + tmp[7]*src[5] + tmp[10]*src[7]; Result[0][2] -= tmp[3]*src[4] + tmp[6]*src[5] + tmp[11]*src[7]; Result[0][3] = tmp[5]*src[4] + tmp[8]*src[5] + tmp[11]*src[6]; Result[0][3] -= tmp[4]*src[4] + tmp[9]*src[5] + tmp[10]*src[6]; Result[1][0] = tmp[1]*src[1] + tmp[2]*src[2] + tmp[5]*src[3]; Result[1][0] -= tmp[0]*src[1] + tmp[3]*src[2] + tmp[4]*src[3]; Result[1][1] = tmp[0]*src[0] + tmp[7]*src[2] + tmp[8]*src[3]; Result[1][1] -= tmp[1]*src[0] + tmp[6]*src[2] + tmp[9]*src[3]; Result[1][2] = tmp[3]*src[0] + tmp[6]*src[1] + tmp[11]*src[3]; Result[1][2] -= tmp[2]*src[0] + tmp[7]*src[1] + tmp[10]*src[3]; Result[1][3] = tmp[4]*src[0] + tmp[9]*src[1] + tmp[10]*src[2]; Result[1][3] -= tmp[5]*src[0] + tmp[8]*src[1] + tmp[11]*src[2]; /* calculate pairs for second 8 elements (cofactors) */ tmp[0] = src[2]*src[7]; tmp[1] = src[3]*src[6]; tmp[2] = src[1]*src[7]; tmp[3] = src[3]*src[5]; tmp[4] = src[1]*src[6]; tmp[5] = src[2]*src[5]; tmp[6] = src[0]*src[7]; tmp[7] = src[3]*src[4]; tmp[8] = src[0]*src[6]; tmp[9] = src[2]*src[4]; tmp[10] = src[0]*src[5]; tmp[11] = src[1]*src[4]; /* calculate second 8 elements (cofactors) */ Result[2][0] = tmp[0]*src[13] + tmp[3]*src[14] + tmp[4]*src[15]; Result[2][0] -= tmp[1]*src[13] + tmp[2]*src[14] + tmp[5]*src[15]; Result[2][1] = tmp[1]*src[12] + tmp[6]*src[14] + tmp[9]*src[15]; Result[2][1] -= tmp[0]*src[12] + tmp[7]*src[14] + tmp[8]*src[15]; Result[2][2] = tmp[2]*src[12] + tmp[7]*src[13] + tmp[10]*src[15]; Result[2][2] -= tmp[3]*src[12] + tmp[6]*src[13] + tmp[11]*src[15]; Result[2][3] = tmp[5]*src[12] + tmp[8]*src[13] + tmp[11]*src[14]; Result[2][3] -= tmp[4]*src[12] + tmp[9]*src[13] + tmp[10]*src[14]; Result[3][0] = tmp[2]*src[10] + tmp[5]*src[11] + tmp[1]*src[9]; Result[3][0] -= tmp[4]*src[11] + tmp[0]*src[9] + tmp[3]*src[10]; Result[3][1] = tmp[8]*src[11] + tmp[0]*src[8] + tmp[7]*src[10]; Result[3][1] -= tmp[6]*src[10] + tmp[9]*src[11] + tmp[1]*src[8]; Result[3][2] = tmp[6]*src[9] + tmp[11]*src[11] + tmp[3]*src[8]; Result[3][2] -= tmp[10]*src[11] + tmp[2]*src[8] + tmp[7]*src[9]; Result[3][3] = tmp[10]*src[10] + tmp[4]*src[8] + tmp[9]*src[9]; Result[3][3] -= tmp[8]*src[9] + tmp[11]*src[10] + tmp[5]*src[8]; /* calculate determinant */ det=src[0]*Result[0][0]+src[1]*Result[0][1]+src[2]*Result[0][2]+src[3]*Result[0][3]; /* calculate matrix inverse */ det = 1.0f / det; Matrix4 FloatResult; for (UINT i = 0; i < 4; i++) { for (UINT j = 0; j < 4; j++) { FloatResult[i][j] = float(Result[i][j] * det); } } return FloatResult; // // Inversion by LU decomposition, alternate implementation // /*int i, j, k; for (i = 1; i < 4; i++) { _Entries[0][i] /= _Entries[0][0]; } for (i = 1; i < 4; i++) { for (j = i; j < 4; j++) { float sum = 0.0; for (k = 0; k < i; k++) { sum += _Entries[j][k] * _Entries[k][i]; } _Entries[j][i] -= sum; } if (i == 4-1) continue; for (j=i+1; j < 4; j++) { float sum = 0.0; for (int k = 0; k < i; k++) sum += _Entries[i][k]*_Entries[k][j]; _Entries[i][j] = (_Entries[i][j]-sum) / _Entries[i][i]; } } // // Invert L // for ( i = 0; i < 4; i++ ) { for ( int j = i; j < 4; j++ ) { float x = 1.0; if ( i != j ) { x = 0.0; for ( int k = i; k < j; k++ ) x -= _Entries[j][k]*_Entries[k][i]; } _Entries[j][i] = x / _Entries[j][j]; } } // // Invert U // for ( i = 0; i < 4; i++ ) { for ( j = i; j < 4; j++ ) { if ( i == j ) continue; float sum = 0.0; for ( int k = i; k < j; k++ ) sum += _Entries[k][j]*( (i==k) ? 1.0f : _Entries[i][k] ); _Entries[i][j] = -sum; } } // // Final Inversion // for ( i = 0; i < 4; i++ ) { for ( int j = 0; j < 4; j++ ) { float sum = 0.0; for ( int k = ((i>j)?i:j); k < 4; k++ ) sum += ((j==k)?1.0f:_Entries[j][k])*_Entries[k][i]; _Entries[j][i] = sum; } }*/ } Matrix4 Matrix4::Transpose() const { Matrix4 Result; for(UINT i = 0; i < 4; i++) { for(UINT i2 = 0; i2 < 4; i2++) { Result[i2][i] = _Entries[i][i2]; } } return Result; } Matrix4 Matrix4::Identity() { Matrix4 Result; for(UINT i = 0; i < 4; i++) { for(UINT i2 = 0; i2 < 4; i2++) { if(i == i2) { Result[i][i2] = 1.0f; } else { Result[i][i2] = 0.0f; } } } return Result; } Matrix4 Matrix4::Rotation(const Vec3f &_Basis1, const Vec3f &_Basis2, const Vec3f &_Basis3) { // // Verify everything is normalized // Vec3f Basis1 = Vec3f::Normalize(_Basis1); Vec3f Basis2 = Vec3f::Normalize(_Basis2); Vec3f Basis3 = Vec3f::Normalize(_Basis3); Matrix4 Result; Result[0][0] = Basis1.x; Result[1][0] = Basis1.y; Result[2][0] = Basis1.z; Result[3][0] = 0.0f; Result[0][1] = Basis2.x; Result[1][1] = Basis2.y; Result[2][1] = Basis2.z; Result[3][1] = 0.0f; Result[0][2] = Basis3.x; Result[1][2] = Basis3.y; Result[2][2] = Basis3.z; Result[3][2] = 0.0f; Result[0][3] = 0.0f; Result[1][3] = 0.0f; Result[2][3] = 0.0f; Result[3][3] = 1.0f; return Result; } Matrix4 Matrix4::Camera(const Vec3f &Eye, const Vec3f &_Look, const Vec3f &_Up, const Vec3f &_Right) { // // Verify everything is normalized // Vec3f Look = Vec3f::Normalize(_Look); Vec3f Up = Vec3f::Normalize(_Up); Vec3f Right = Vec3f::Normalize(_Right); Matrix4 Result; Result[0][0] = Right.x; Result[1][0] = Right.y; Result[2][0] = Right.z; Result[3][0] = -Vec3f::Dot(Right, Eye); Result[0][1] = Up.x; Result[1][1] = Up.y; Result[2][1] = Up.z; Result[3][1] = -Vec3f::Dot(Up, Eye); Result[0][2] = Look.x; Result[1][2] = Look.y; Result[2][2] = Look.z; Result[3][2] = -Vec3f::Dot(Look, Eye); Result[0][3] = 0.0f; Result[1][3] = 0.0f; Result[2][3] = 0.0f; Result[3][3] = 1.0f; return Result; } Matrix4 Matrix4::LookAt(const Vec3f &Eye, const Vec3f &At, const Vec3f &Up) { Vec3f XAxis, YAxis, ZAxis; ZAxis = Vec3f::Normalize(Eye - At); XAxis = Vec3f::Normalize(Vec3f::Cross(Up, ZAxis)); YAxis = Vec3f::Normalize(Vec3f::Cross(ZAxis, XAxis)); Matrix4 Result; Result[0][0] = XAxis.x; Result[1][0] = XAxis.y; Result[2][0] = XAxis.z; Result[3][0] = -Vec3f::Dot(XAxis,Eye); Result[0][1] = YAxis.x; Result[1][1] = YAxis.y; Result[2][1] = YAxis.z; Result[3][1] = -Vec3f::Dot(YAxis,Eye); Result[0][2] = ZAxis.x; Result[1][2] = ZAxis.y; Result[2][2] = ZAxis.z; Result[3][2] = -Vec3f::Dot(ZAxis,Eye); Result[0][3] = 0.0f; Result[1][3] = 0.0f; Result[2][3] = 0.0f; Result[3][3] = 1.0f; return Result; } Matrix4 Matrix4::Orthogonal(float Width, float Height, float ZNear, float ZFar) { Matrix4 Result; Result[0][0] = 2.0f / Width; Result[1][0] = 0.0f; Result[2][0] = 0.0f; Result[3][0] = 0.0f; Result[0][1] = 0.0f; Result[1][1] = 2.0f / Height; Result[2][1] = 0.0f; Result[3][1] = 0.0f; Result[0][2] = 0.0f; Result[1][2] = 0.0f; Result[2][2] = 1.0f / (ZNear - ZFar); Result[3][2] = ZNear / (ZNear - ZFar); Result[0][3] = 0.0f; Result[1][3] = 0.0f; Result[2][3] = 0.0f; Result[3][3] = 1.0f; return Result; } Matrix4 Matrix4::Perspective(float Width, float Height, float ZNear, float ZFar) { Matrix4 Result; Result[0][0] = 2.0f * ZNear / Width; Result[1][0] = 0.0f; Result[2][0] = 0.0f; Result[3][0] = 0.0f; Result[0][1] = 0.0f; Result[1][1] = 2.0f * ZNear / Height; Result[2][1] = 0.0f; Result[3][1] = 0.0f; Result[0][2] = 0.0f; Result[1][2] = 0.0f; Result[2][2] = ZFar / (ZNear - ZFar); Result[3][2] = ZFar * ZNear / (ZNear - ZFar); Result[0][3] = 0.0f; Result[1][3] = 0.0f; Result[2][3] = -1.0f; Result[3][3] = 0.0f; return Result; } Matrix4 Matrix4::PerspectiveFov(float FOV, float Aspect, float ZNear, float ZFar) { float Width = 1.0f / tanf(FOV/2.0f), Height = Aspect / tanf(FOV/2.0f); Matrix4 Result; Result[0][0] = Width; Result[1][0] = 0.0f; Result[2][0] = 0.0f; Result[3][0] = 0.0f; Result[0][1] = 0.0f; Result[1][1] = Height; Result[2][1] = 0.0f; Result[3][1] = 0.0f; Result[0][2] = 0.0f; Result[1][2] = 0.0f; Result[2][2] = ZFar / (ZNear - ZFar); Result[3][2] = ZFar * ZNear / (ZNear - ZFar); Result[0][3] = 0.0f; Result[1][3] = 0.0f; Result[2][3] = -1.0f; Result[3][3] = 0.0f; return Result; } Matrix4 Matrix4::PerspectiveMultiFov(float FovX, float FovY, float ZNear, float ZFar) { float Width = 1.0f / tanf(FovX / 2.0f), Height = 1.0f / tanf(FovY / 2.0f); Matrix4 Result; Result[0][0] = Width; Result[1][0] = 0.0f; Result[2][0] = 0.0f; Result[3][0] = 0.0f; Result[0][1] = 0.0f; Result[1][1] = Height; Result[2][1] = 0.0f; Result[3][1] = 0.0f; Result[0][2] = 0.0f; Result[1][2] = 0.0f; Result[2][2] = ZFar / (ZNear - ZFar); Result[3][2] = ZFar * ZNear / (ZNear - ZFar); Result[0][3] = 0.0f; Result[1][3] = 0.0f; Result[2][3] = -1.0f; Result[3][3] = 0.0f; return Result; } Matrix4 Matrix4::Rotation(const Vec3f &Axis, float Angle) { float c = cosf(Angle); float s = sinf(Angle); float t = 1.0f - c; Vec3f NormalizedAxis = Vec3f::Normalize(Axis); float x = NormalizedAxis.x; float y = NormalizedAxis.y; float z = NormalizedAxis.z; Matrix4 Result; Result[0][0] = 1 + t*(x*x-1); Result[0][1] = z*s+t*x*y; Result[0][2] = -y*s+t*x*z; Result[0][3] = 0.0f; Result[1][0] = -z*s+t*x*y; Result[1][1] = 1+t*(y*y-1); Result[1][2] = x*s+t*y*z; Result[1][3] = 0.0f; Result[2][0] = y*s+t*x*z; Result[2][1] = -x*s+t*y*z; Result[2][2] = 1+t*(z*z-1); Result[2][3] = 0.0f; Result[3][0] = 0.0f; Result[3][1] = 0.0f; Result[3][2] = 0.0f; Result[3][3] = 1.0f; return Result; } Matrix4 Matrix4::Rotation(float Yaw, float Pitch, float Roll) { return RotationY(Yaw) * RotationX(Pitch) * RotationZ(Roll); } Matrix4 Matrix4::Rotation(const Vec3f &Axis, float Angle, const Vec3f &Center) { return Translation(-Center) * Rotation(Axis, Angle) * Translation(Center); } Matrix4 Matrix4::RotationX(float Theta) { float CosT = cosf(Theta); float SinT = sinf(Theta); Matrix4 Result = Identity(); Result[1][1] = CosT; Result[1][2] = SinT; Result[2][1] = -SinT; Result[2][2] = CosT; return Result; } Matrix4 Matrix4::RotationY(float Theta) { float CosT = cosf(Theta); float SinT = sinf(Theta); Matrix4 Result = Identity(); Result[0][0] = CosT; Result[0][2] = SinT; Result[2][0] = -SinT; Result[2][2] = CosT; return Result; } Matrix4 Matrix4::RotationZ(float Theta) { float CosT = cosf(Theta); float SinT = sinf(Theta); Matrix4 Result = Identity(); Result[0][0] = CosT; Result[0][1] = SinT; Result[1][0] = -SinT; Result[1][1] = CosT; return Result; } Matrix4 Matrix4::Scaling(const Vec3f &ScaleFactors) { Matrix4 Result; Result[0][0] = ScaleFactors.x; Result[1][0] = 0.0f; Result[2][0] = 0.0f; Result[3][0] = 0.0f; Result[0][1] = 0.0f; Result[1][1] = ScaleFactors.y; Result[2][1] = 0.0f; Result[3][1] = 0.0f; Result[0][2] = 0.0f; Result[1][2] = 0.0f; Result[2][2] = ScaleFactors.z; Result[3][2] = 0.0f; Result[0][3] = 0.0f; Result[1][3] = 0.0f; Result[2][3] = 0.0f; Result[3][3] = 1.0f; return Result; } Matrix4 Matrix4::Translation(const Vec3f &Pos) { Matrix4 Result; Result[0][0] = 1.0f; Result[1][0] = 0.0f; Result[2][0] = 0.0f; Result[3][0] = Pos.x; Result[0][1] = 0.0f; Result[1][1] = 1.0f; Result[2][1] = 0.0f; Result[3][1] = Pos.y; Result[0][2] = 0.0f; Result[1][2] = 0.0f; Result[2][2] = 1.0f; Result[3][2] = Pos.z; Result[0][3] = 0.0f; Result[1][3] = 0.0f; Result[2][3] = 0.0f; Result[3][3] = 1.0f; return Result; } Matrix4 Matrix4::ChangeOfBasis(const Vec3f &Source0, const Vec3f &Source1, const Vec3f &Source2, const Vec3f &SourceOrigin, const Vec3f &Target0, const Vec3f &Target1, const Vec3f &Target2, const Vec3f &TargetOrigin) { Matrix4 RotationComponent = Matrix4(Source0, Source1, Source2).Inverse() * Matrix4(Target0, Target1, Target2); //Matrix4 TranslationComponent = Translation(TargetOrigin - SourceOrigin); Matrix4 Result = Translation(-SourceOrigin) * RotationComponent * Translation(TargetOrigin); return Result; //return Translation(TargetOrigin - SourceOrigin); } Matrix4 Matrix4::Face(const Vec3f &V0, const Vec3f &V1) { // // Rotate about the cross product of the two vectors by the angle between the two vectors // Vec3f Axis = Vec3f::Cross(V0, V1); float Angle = Vec3f::AngleBetween(V0, V1); if(Angle == 0.0f || Axis.Length() < 0.0f) { return Identity(); } else { return Rotation(Axis, Angle); } } Matrix4 Matrix4::Viewport(float Width, float Height) { return Matrix4::Scaling(Vec3f(Width * 0.5f, -Height * 0.5f, 1.0f)) * Matrix4::Translation(Vec3f(Width * 0.5f, Height * 0.5f, 0.0f)); } float Matrix4::CompareMatrices(const Matrix4 &Left, const Matrix4 &Right) { float Sum = 0.0f; for(UINT i = 0; i < 4; i++) { for(UINT i2 = 0; i2 < 4; i2++) { Sum += Math::Abs(Left[i][i2] - Right[i][i2]); } } return Sum / 16.0f; } Vec3f Matrix4::TransformPoint(const Vec3f &Point) const { Vec4f UnprojectedResult = Vec4f(Point, 1.0f) * (*this); if(UnprojectedResult.w == 0.0f || UnprojectedResult.w == 1.0f) { return Vec3f(UnprojectedResult.x, UnprojectedResult.y, UnprojectedResult.z); } else { return Vec3f(UnprojectedResult.x / UnprojectedResult.w, UnprojectedResult.y / UnprojectedResult.w, UnprojectedResult.z / UnprojectedResult.w); } } Vec3f Matrix4::TransformNormal(const Vec3f &Normal) const { Vec4f UnprojectedResult = Vec4f(Normal, 0.0f) * (*this); if(UnprojectedResult.w == 0.0f) { UnprojectedResult.w = 1.0f; } Vec3f Result(UnprojectedResult.x / UnprojectedResult.w, UnprojectedResult.y / UnprojectedResult.w, UnprojectedResult.z / UnprojectedResult.w); if(UnprojectedResult.w < 0.0f) { Result = -Result; } return Result; } #ifdef USE_D3D Matrix4::operator D3DXMATRIX() const { D3DXMATRIX M; int i,i2; for(i=0;i<4;i++) for(i2=0;i2<4;i2++) { M(i,i2) = _Entries[i][i2]; } return M; } #endif ostream& operator << (ostream &os, const Matrix4 &m) { os << setprecision(8) << setiosflags(ios::right | ios::showpoint); for(UINT i=0;i<4;i++) { for(UINT i2=0;i2<4;i2++) { os << setw(12) << m[i][i2]; } os << endl; } return os; } istream& operator >> (istream &is, Matrix4 &m) { for(UINT i=0;i<4;i++) { for(UINT i2=0;i2<4;i2++) { is >> m[i][i2]; } } return is; } Matrix4 operator * (const Matrix4 &Left, const Matrix4 &Right) { Matrix4 Result; for(UINT i = 0; i < 4; i++) { for(UINT i2 = 0; i2 < 4; i2++) { float Total = 0.0f; for(UINT i3 = 0; i3 < 4; i3++) { Total += Left[i][i3] * Right[i3][i2]; } Result[i][i2] = Total; } } return Result; } Matrix4 operator * (const Matrix4 &Left, float &Right) { Matrix4 Result; for(UINT i = 0; i < 4; i++) { for(UINT i2 = 0; i2 < 4; i2++) { Result[i][i2] = Left[i][i2] * Right; } } return Result; } Matrix4 operator * (float &Left, const Matrix4 &Right) { Matrix4 Result; for(UINT i = 0; i < 4; i++) { for(UINT i2 = 0; i2 < 4; i2++) { Result[i][i2] = Right[i][i2] * Left; } } return Result; } Matrix4 operator + (const Matrix4 &Left, const Matrix4 &Right) { Matrix4 Result; for(UINT i = 0; i < 4; i++) { for(UINT i2 = 0; i2 < 4; i2++) { Result[i][i2] = Left[i][i2] + Right[i][i2]; } } return Result; } Matrix4 operator - (const Matrix4 &Left, const Matrix4 &Right) { Matrix4 Result; for(UINT i = 0; i < 4; i++) { for(UINT i2 = 0; i2 < 4; i2++) { Result[i][i2] = Left[i][i2] - Right[i][i2]; } } return Result; }
[ "zhaodongmpii@7e7f00ea-7cf8-66b5-cf80-f378872134d2" ]
[ [ [ 1, 878 ] ] ]
605f3a02b3b3edc2e633b347c075fd7edb027cb4
6ed8a7f8102c2c90baee79e086e589f553f7d2d3
/main.cpp
acae90869c632bebc823cd3dd783be25ec8b1612
[]
no_license
snaill/sscs
3173c150c86b7dee7652c3547271b1f9c9b53c85
b89f0dd9d9d34ceeeea4988550614ed36bdb1a18
refs/heads/master
2021-01-23T13:28:47.551752
2009-05-25T10:16:23
2009-05-25T10:16:23
32,121,178
0
0
null
null
null
null
UTF-8
C++
false
false
3,694
cpp
/* * SDL_SimpleControls * Copyright (C) 2008 Snaill * SDL_SimpleControls is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SDL_SimpleControls is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. Snaill <[email protected]> */ #include "SDL_SimpleControls.h" SDL_Setting * SDL_Setting::m_this = 0; SDL_Glyph * CreateTestScreen() { // SDL_Image * pImage = new SDL_Image("cb.bmp"); // // SDL_Status status; // SDL_Text * pText = new SDL_Text( "cb.bmp" ); // pText->GetTextStatus( &status ); // status.type = SDL_TEXTSTATUS; // status.text.size = 13; // status.text.crText.r = 0; // status.text.crText.g = 0; // status.text.crText.b = 0; // pText->SetTextStatus( &status ); // SDL_Rect rc; rc.x = rc.y = 100; rc.w = rc.h = 200; // SDL_Button * pButton = new SDL_Button( pText ); //// SDL_Button * pButton = new SDL_Button( pImage ); // pButton->SetBounds( &rc ); // return pButton; SDL_MessageBox * pmsg = new SDL_MessageBox( "Test MessageBox", "This is a MessageBox" ); pmsg->SetBounds( &rc ); return pmsg; } int main ( int argc, char** argv ) { // SDL_Setting * _setting = SDL_Setting::Get(); // initialize SDL video if ( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { printf( "Unable to init SDL: %s\n", SDL_GetError() ); return 1; } // make sure SDL cleans up before exit atexit(SDL_Quit); // create a new window SDL_Surface* screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE|SDL_DOUBLEBUF); if ( !screen ) { printf("Unable to set 640x480 video: %s\n", SDL_GetError()); return 1; } // load an image SDL_Glyph * gWnd = CreateTestScreen(); // program main loop bool done = false; while (!done) { // message processing loop SDL_Event event; while (SDL_PollEvent(&event)) { if ( gWnd->HandleEvent( &event ) ) continue; // check for messages switch (event.type) { // exit if the window is closed case SDL_QUIT: done = true; break; // check for keypresses case SDL_KEYDOWN: { // exit if ESCAPE is pressed if (event.key.keysym.sym == SDLK_ESCAPE) done = true; break; } } // end switch } // end of message processing // DRAWING STARTS HERE // clear screen SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 255, 255, 255)); // draw bitmap gWnd->Draw( screen ); // DRAWING ENDS HERE // finally, update the screen :) SDL_Flip(screen); } // end main loop // free loaded bitmap gWnd->Release(); // _setting->Release(); // all is well ;) printf("Exited cleanly\n"); return 0; }
[ "com.chinaos.snaill@db7a99aa-9dca-11dd-b92e-bd4787f9249a" ]
[ [ [ 1, 131 ] ] ]
54b6ee838b60bd46178fbedef9908cdf688136ec
c70941413b8f7bf90173533115c148411c868bad
/plugins/D3D9Plugin/include/vtxd3d9.h
0c1c3107bd89549024c794b397f269f456a8066b
[]
no_license
cnsuhao/vektrix
ac6e028dca066aad4f942b8d9eb73665853fbbbe
9b8c5fa7119ff7f3dc80fb05b7cdba335cf02c1a
refs/heads/master
2021-06-23T11:28:34.907098
2011-03-27T17:39:37
2011-03-27T17:39:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,098
h
/* ----------------------------------------------------------------------------- This source file is part of "vektrix" (the rich media and vector graphics rendering library) For the latest info, see http://www.fuse-software.com/ Copyright (c) 2009-2010 Fuse-Software (tm) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------------- */ #ifndef __vtxd3d9_H__ #define __vtxd3d9_H__ #include "vtxPrerequisites.h" #if VTX_OS == VTX_WIN32 # ifdef VTX_STATIC_LIB # define vtxd3d9Export # else # ifdef VEKTRIX_D3D9PLUGIN_EXPORTS # define vtxd3d9Export __declspec(dllexport) # else # define vtxd3d9Export __declspec(dllimport) # endif # endif #endif #if VTX_OS == VTX_LINUX # define vtxd3d9Export #endif namespace vtx { namespace d3d9 { // MovableMovie class MovableMovie; class MovableMovieFactory; class MovableStrategy; // Instances class D3D9MovableShape; class D3D9MovableShapeFactory; // Generic class D3D9Texture; class D3D9TextureFactory; } } #endif
[ "stonecold_@9773a11d-1121-4470-82d2-da89bd4a628a", "fixxxeruk@9773a11d-1121-4470-82d2-da89bd4a628a" ]
[ [ [ 1, 31 ], [ 33, 68 ] ], [ [ 32, 32 ] ] ]
6a8f54abee84282b4e8a21d86e04d1ed1b66da5c
bfdfb7c406c318c877b7cbc43bc2dfd925185e50
/vcproj/hydll/hydll.h
78edd4f16336f12c250e47552e3681e10beb4d5a
[ "MIT" ]
permissive
ysei/Hayat
74cc1e281ae6772b2a05bbeccfcf430215cb435b
b32ed82a1c6222ef7f4bf0fc9dedfad81280c2c0
refs/heads/master
2020-12-11T09:07:35.606061
2011-08-01T12:38:39
2011-08-01T12:38:39
null
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
597
h
// hydll.h : hydll.DLL のメイン ヘッダー ファイル // #pragma once #ifndef __AFXWIN_H__ #error "PCH に対してこのファイルをインクルードする前に 'stdafx.h' をインクルードしてください" #endif #include "resource.h" // メイン シンボル #include "EngineControl.h" // ChydllApp // このクラスの実装に関しては hydll.cpp を参照してください。 // class ChydllApp : public CWinApp { public: ChydllApp(); // オーバーライド public: virtual BOOL InitInstance(); DECLARE_MESSAGE_MAP() };
[ [ [ 1, 30 ] ] ]
3988de610666c3b1ca9883183822ea8ff7edf556
05869e5d7a32845b306353bdf45d2eab70d5eddc
/soft/application/CoolSimulator/coolphone.h
a5035758a6c40fa54a8e60decbc739c152d5165c
[]
no_license
shenfahsu/sc-fix
beb9dc8034f2a8fd9feb384155fa01d52f3a4b6a
ccc96bfaa3c18f68c38036cf68d3cb34ca5b40cd
refs/heads/master
2020-07-14T16:13:47.424654
2011-07-22T16:46:45
2011-07-22T16:46:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,673
h
// Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++ // NOTE: Do not modify the contents of this file. If this class is regenerated by // Microsoft Visual C++, your modifications will be overwritten. // Dispatch interfaces referenced by this interface class CScreen; class CKeypad; ///////////////////////////////////////////////////////////////////////////// // CCoolPhone wrapper class class CCoolPhone : public CWnd { protected: DECLARE_DYNCREATE(CCoolPhone) public: CLSID const& GetClsid() { static CLSID const clsid = { 0xab9d831b, 0x277b, 0x4927, { 0x8f, 0x89, 0xc1, 0xcb, 0xbe, 0xb9, 0xe6, 0x11 } }; return clsid; } virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL) { return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID); } BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE, BSTR bstrLicKey = NULL) { return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID, pPersist, bStorage, bstrLicKey); } // Attributes public: // Operations public: CScreen Screen(); CScreen SubScreen(); CKeypad Keypad(); BOOL LoadPhoneScript(LPCTSTR lpszScript); BOOL SetBackgroundImage(LPCTSTR lpszImageFile); void LoadSkinProfile(LPCTSTR lpszSkinProfile); void ShowSkinSetupDlg(); void ShowExtendKeyboard(BOOL bShow); void ShowExtendKeyboardEx(long xPos, long yPos, BOOL bShow); void AboutBox(); };
[ "windyin@2490691b-6763-96f4-2dba-14a298306784" ]
[ [ [ 1, 54 ] ] ]
8d7da782942c15d6a3bba90d9fb42dfffdb5e54a
854ee643a4e4d0b7a202fce237ee76b6930315ec
/arcemu_svn/src/arcemu-world/VoiceChatHandler.cpp
eaccbd2b16943d2769d9184504ec77d86f6257a8
[]
no_license
miklasiak/projekt
df37fa82cf2d4a91c2073f41609bec8b2f23cf66
064402da950555bf88609e98b7256d4dc0af248a
refs/heads/master
2021-01-01T19:29:49.778109
2008-11-10T17:14:14
2008-11-10T17:14:14
34,016,391
2
0
null
null
null
null
UTF-8
C++
false
false
10,750
cpp
/* * arcemu MMORPG Server * Voice Chat Engine * Copyright (C) 2005-2007 Burlex <[email protected]> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ #include "StdAfx.h" #ifdef VOICE_CHAT void WorldSession::HandleEnableMicrophoneOpcode(WorldPacket & recv_data) { uint8 enabled, unk; recv_data >> enabled; recv_data >> unk; if(!enabled) { /* {SERVER} Packet: (0x039F) UNKNOWN PacketSize = 16 |------------------------------------------------|----------------| |00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |0123456789ABCDEF| |------------------------------------------------|----------------| |F3 0D 13 01 00 00 00 00 4A C5 00 00 00 00 D1 E1 |........J.......| ------------------------------------------------------------------- uint64 player_guid uint64 channel_id */ } else { /* {SERVER} Packet: (0x03D8) UNKNOWN PacketSize = 24 |------------------------------------------------|----------------| |00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |0123456789ABCDEF| |------------------------------------------------|----------------| |4B C5 00 00 00 00 D1 E1 00 6D 6F 6F 63 6F 77 00 |K........moocow.| |F3 0D 13 01 00 00 00 00 |........ | ------------------------------------------------------------------- uint8 channel_id? uint8 channel_type (00=custom channel, 03=party, 04=raid?) string channel_name (not applicable to party/raid) uint64 player_guid */ } } void WorldSession::HandleChannelVoiceQueryOpcode(WorldPacket & recv_data) { string name; recv_data >> name; // custom channel Channel * chn = channelmgr.GetChannel(name.c_str(), _player); if(chn == NULL || chn->voice_enabled == false || chn->m_general) return; WorldPacket data(SMSG_CHANNEL_NOTIFY_AVAILABLE_VOICE_SESSION, 17+chn->m_name.size()); data << uint32(0x00002e57); data << uint32(0xe0e10000); data << uint8(0); // 00=custom,03=party,04=raid data << chn->m_name; data << _player->GetGUID(); SendPacket(&data); } void WorldSession::HandleVoiceChatQueryOpcode(WorldPacket & recv_data) { if(!sVoiceChatHandler.CanUseVoiceChat()) return; uint32 type; string name; recv_data >> type >> name; if(type == 0) { // custom channel Channel * chn = channelmgr.GetChannel(name.c_str(), _player); if(chn == NULL) return; if(chn->m_general || !chn->voice_enabled) return; chn->JoinVoiceChannel(_player); } } /************************************************************************/ /* Singleton Stuff */ /************************************************************************/ initialiseSingleton(VoiceChatHandler); VoiceChatHandler::VoiceChatHandler() { request_high=1; next_connect = 0; m_client = 0; port =0; ip = 0; enabled=false; } void VoiceChatHandler::OnRead(WorldPacket* pck) { uint32 request_id; uint8 error; uint16 channel_id = 0; switch(pck->GetOpcode()) { case VOICECHAT_SMSG_PONG: { printf("!! VOICECHAT PONGZ!\n"); m_client->last_pong = UNIXTIME; }break; case VOICECHAT_SMSG_CHANNEL_CREATED: { *pck >> request_id; *pck >> error; Log.Debug("VoiceChatHandler", "Request ID %u, error %u", request_id, (int)error); for(vector<VoiceChatChannelRequest>::iterator itr = m_requests.begin(); itr != m_requests.end(); ++itr) { if(itr->id == request_id) { // zero = error, wehn we pass it to OnChannelCreated if( error == 0 ) *pck >> channel_id; VoiceChannel * chn = new VoiceChannel; chn->channelId = channel_id; chn->type = itr->groupid ? 3 : 0; chn->team = itr->team; if( itr->groupid == 0 ) { Channel * chan = channelmgr.GetChannel(itr->channel_name.c_str(), itr->team); if(chan != NULL) { chn->miscPointer = chan; m_voiceChannels.insert(make_pair((uint32)channel_id, chn)); chan->VoiceChannelCreated(channel_id); } else delete chn; } else { Group * grp = objmgr.GetGroupById( itr->groupid ); if( grp != NULL ) { chn->miscPointer = grp; m_voiceChannels.insert(make_pair((uint32)channel_id, chn)); grp->VoiceChannelCreated(channel_id); } else delete chn; } m_requests.erase(itr); break; } } }break; } } void VoiceChatHandler::SocketDisconnected() { m_lock.Acquire(); Log.Debug("VoiceChatHandler", "SocketDisconnected"); m_client = NULL; m_requests.clear(); WorldPacket data(SMSG_VOICE_SYSTEM_STATUS, 2); data << uint8(2); data << uint8(0); sWorld.SendGlobalMessage(&data, NULL); next_connect = UNIXTIME + 5; sWorld.SendWorldText("Channel/Party voice services are now offline."); // notify channels for(HM_NAMESPACE::hash_map<uint32, VoiceChannel*>::iterator itr = m_voiceChannels.begin(); itr != m_voiceChannels.end(); ++itr) { if( itr->second->type == 3 ) // party ((Group*)itr->second->miscPointer)->VoiceSessionDropped(); delete itr->second; } m_voiceChannels.clear(); m_lock.Release(); } bool VoiceChatHandler::CanUseVoiceChat() { return (enabled && m_client != NULL); } void VoiceChatHandler::CreateVoiceChannel(Channel * chn) { if(m_client == NULL) return; Log.Debug("VoiceChatHandler", "CreateVoiceChannel %s", chn->m_name.c_str()); VoiceChatChannelRequest req; m_lock.Acquire(); req.id = request_high++; req.channel_name = chn->m_name; req.team = chn->m_team; req.groupid = 0; m_requests.push_back(req); WorldPacket data(VOICECHAT_CMSG_CREATE_CHANNEL, 5); data << (uint8)0; data << req.id; m_client->SendPacket(&data); m_lock.Release(); } void VoiceChatHandler::CreateGroupChannel(Group * pGroup) { if( m_client == NULL ) return; Log.Debug("VoiceChatHandler", "CreateGroupChannel for group %u", pGroup->GetID()); ByteBuffer buf(50); VoiceChatChannelRequest req; m_lock.Acquire(); req.id = request_high++; req.groupid = pGroup->GetID(); req.team = 0; m_requests.push_back( req ); WorldPacket data(VOICECHAT_CMSG_CREATE_CHANNEL, 5); data << (uint8)3; data << req.id; m_client->SendPacket(&data); m_lock.Release(); } void VoiceChatHandler::DestroyGroupChannel(Group * pGroup) { if( pGroup->m_voiceChannelId <= 0 ) return; m_lock.Acquire(); HM_NAMESPACE::hash_map<uint32, VoiceChannel*>::iterator itr = m_voiceChannels.find(pGroup->m_voiceChannelId); if( itr != m_voiceChannels.end() ) { // cleanup channel structure m_voiceChannels.erase( itr ); } if( m_client == NULL ) { m_lock.Release(); return; } WorldPacket data(VOICECHAT_CMSG_DELETE_CHANNEL, 5); data << (uint8)3; data << (uint16)pGroup->m_voiceChannelId; m_client->SendPacket(&data); m_lock.Release(); } void VoiceChatHandler::ActivateChannelSlot(uint16 channel_id, uint8 slot_id) { if( m_client == NULL ) return; Log.Debug("VoiceChatHandler", "Channel %u activate slot %u", (int)channel_id, (int)slot_id); m_lock.Acquire(); WorldPacket data(VOICECHAT_CMSG_ADD_MEMBER, 5); data << channel_id; data << slot_id; m_client->SendPacket(&data); m_lock.Release(); } void VoiceChatHandler::DeactivateChannelSlot(uint16 channel_id, uint8 slot_id) { if( m_client == NULL ) return; Log.Debug("VoiceChatHandler", "Channel %u deactivate slot %u", (int)channel_id, (int)slot_id); m_lock.Acquire(); WorldPacket data(VOICECHAT_CMSG_REMOVE_MEMBER, 5); data << channel_id; data << slot_id; m_client->SendPacket(&data); m_lock.Release(); } void VoiceChatHandler::DestroyVoiceChannel(Channel * chn) { Log.Debug("VoiceChatHandler", "DestroyVoiceChannel %s", chn->m_name.c_str()); if(chn->i_voice_channel_id != (uint16)-1 && m_client) { ByteBuffer buf(15); buf << uint32(VOICECHAT_CMSG_DELETE_CHANNEL); buf << uint32(chn->i_voice_channel_id); m_client->Send(buf.contents(), 8); } chn->VoiceDied(); } void VoiceChatHandler::Startup() { ip_s = Config.MainConfig.GetStringDefault("VoiceChat", "ServerIP", "127.0.0.1"); port = Config.MainConfig.GetIntDefault("VoiceChat", "ServerPort", 3727); enabled = Config.MainConfig.GetBoolDefault("VoiceChat", "Enabled", false); if(!enabled) return; ip = inet_addr(ip_s.c_str()); next_connect = 0; Update(); } void VoiceChatHandler::Update() { if(!enabled) return; if( m_client == NULL ) { if(UNIXTIME > next_connect) { Log.Notice("VoiceChatHandler", "Attempting to connect to voicechat server %s:%u", ip_s.c_str(), port); VoiceChatClientSocket * s = ConnectTCPSocket<VoiceChatClientSocket>(ip_s.c_str(), port); if(s != NULL) { // connected! m_client = s; Log.Notice("VoiceChatHandler", "Connected to %s:%u.", ip_s.c_str(), port); WorldPacket data(SMSG_VOICE_SYSTEM_STATUS, 2); data << uint8(2) << uint8(1); sWorld.SendGlobalMessage(&data, NULL); objmgr.GroupVoiceReconnected(); sWorld.SendWorldText("Voice services are back online."); } else { Log.Notice("VoiceChatHandler", "Could not connect. Will try again later."); m_client = NULL; next_connect = UNIXTIME + 10; } } } else { if( UNIXTIME >= m_client->next_ping ) { m_client->next_ping = UNIXTIME + 15; WorldPacket data(VOICECHAT_CMSG_PING, 4); data << uint32(0); m_client->SendPacket(&data); } // because the above might kill m_client if( m_client != NULL && (UNIXTIME - m_client->last_pong) > (15 * 3) ) { // ping timeout printf("ping timeout on voice socket\n"); m_client->Disconnect(); } } } #else // VOICE_CHAT void WorldSession::HandleEnableMicrophoneOpcode(WorldPacket & recv_data) { } void WorldSession::HandleChannelVoiceQueryOpcode(WorldPacket & recv_data) { } void WorldSession::HandleVoiceChatQueryOpcode(WorldPacket & recv_data) { } #endif // VOICE_CHAT
[ "[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef", "[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef" ]
[ [ [ 1, 1 ], [ 3, 192 ], [ 194, 372 ], [ 374, 425 ] ], [ [ 2, 2 ], [ 193, 193 ], [ 373, 373 ] ] ]
ce80e56723fb5595bd816057bb8a582388c4281b
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/nGENE Proj/JointPointInPlane.cpp
8119ac936c04250d03711ec7bd0c9abbbe13e5d0
[]
no_license
svn2github/ngene
b2cddacf7ec035aa681d5b8989feab3383dac012
61850134a354816161859fe86c2907c8e73dc113
refs/heads/master
2023-09-03T12:34:18.944872
2011-07-27T19:26:04
2011-07-27T19:26:04
78,163,390
2
0
null
null
null
null
UTF-8
C++
false
false
3,370
cpp
/* --------------------------------------------------------------------------- This source file is part of nGENE Tech. Copyright (c) 2006- Wojciech Toman This program is free software. File: JointPointInPlane.cpp Version: 0.03 --------------------------------------------------------------------------- */ #include "PrecompiledHeaders.h" #include "JointPointInPlane.h" #include "JointEnumerator.h" #include "PhysXMapping.h" #include "PhysicsActor.h" #pragma warning(push) #pragma warning(disable:4512) #include "NxScene.h" #include "NxPointInPlaneJointDesc.h" #pragma warning(pop) namespace nGENE { // Initialize static members TypeInfo JointPointInPlane::Type(L"JointPointInPlane", &Joint::Type); JointPointInPlane::JointPointInPlane(NxScene* _scene, SJointDesc& _desc): Joint(_scene, _desc), m_pPointInPlaneDesc(new NxPointInPlaneJointDesc()) { } //---------------------------------------------------------------------- JointPointInPlane::~JointPointInPlane() { cleanup(); } //---------------------------------------------------------------------- void JointPointInPlane::init() { m_pPointInPlaneDesc->actor[0] = m_JointDesc.actor1 ? m_JointDesc.actor1->getActor() : NULL; m_pPointInPlaneDesc->actor[1] = m_JointDesc.actor2 ? m_JointDesc.actor2->getActor() : NULL; m_pPointInPlaneDesc->localAnchor[0] = PhysXMapping::vector3ToNxVec3(m_JointDesc.localAnchor1); m_pPointInPlaneDesc->localAnchor[1] = PhysXMapping::vector3ToNxVec3(m_JointDesc.localAnchor2); m_pPointInPlaneDesc->localAxis[0] = PhysXMapping::vector3ToNxVec3(m_JointDesc.localDirection1); m_pPointInPlaneDesc->localAxis[1] = PhysXMapping::vector3ToNxVec3(m_JointDesc.localDirection2); if(!m_pPointInPlaneDesc->isValid()) { Log::log(LET_ERROR, L"nGENE", __WFILE__, __WFUNCTION__, __LINE__, L"Point-in-Plane joint description is invalid"); return; } if(m_JointDesc.globalDirection != Vector3::ZERO_VECTOR) m_pPointInPlaneDesc->setGlobalAxis(PhysXMapping::vector3ToNxVec3(m_JointDesc.globalDirection)); if(m_JointDesc.globalAnchor != Vector3::ZERO_VECTOR) m_pPointInPlaneDesc->setGlobalAnchor(PhysXMapping::vector3ToNxVec3(m_JointDesc.globalAnchor)); m_pJoint = m_pScene->createJoint(*m_pPointInPlaneDesc); } //---------------------------------------------------------------------- void JointPointInPlane::cleanup() { NGENE_DELETE(m_pPointInPlaneDesc); } //---------------------------------------------------------------------- NxJointDesc* JointPointInPlane::getJointDesc() { return (static_cast<NxJointDesc*>(m_pPointInPlaneDesc)); } //---------------------------------------------------------------------- //---------------------------------------------------------------------- //---------------------------------------------------------------------- JointPointInPlaneFactory::JointPointInPlaneFactory() { } //---------------------------------------------------------------------- JointPointInPlaneFactory::~JointPointInPlaneFactory() { } //---------------------------------------------------------------------- Joint* JointPointInPlaneFactory::createJoint(NxScene* _scene, JOINT_DESC& _desc) { return (new JointPointInPlane(_scene, _desc)); } //---------------------------------------------------------------------- }
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 94 ] ] ]
e370047a6095956b8a37ba4a0fee8fdcdf1249e1
78c7ce1de17f51f638f930b0822f8199231c81b7
/myplot.cpp
e25beeef5dae1c9f21df30529e17b1f1a8bdc2e8
[]
no_license
eluqm/load-forescasting-ia2
c930debfa0b2404d757e66bb357013f9a912f915
76aa488ecdd7aea3ed019b2018d455599aaeaf4a
refs/heads/master
2020-12-24T18:50:54.365811
2011-08-29T03:13:50
2011-08-29T03:13:50
57,864,571
0
0
null
null
null
null
UTF-8
C++
false
false
1,204
cpp
#include "myplot.h" Myplot::Myplot(QWidget *parent=0,char *name=0):QwtPlot(parent,name) { setTitle( "This is an Example" ); // Show a legend at the bottom setAutoLegend( true ); setLegendPos( Qwt::Bottom ); // Show the axes setAxisTitle( xBottom, "x" ); setAxisTitle( yLeft, "y" ); // Insert two curves and get IDs for them long cSin = insertCurve( "y = sin(x)" ); long cSign = insertCurve( "y = sign(sin(x))" ); // Calculate the data, 500 points each const int points = 500; double x[ points ]; double sn[ points ]; double sg[ points ]; for( int i=0; i<points; i++ ) { x[i] = (3.0*3.14/double(points))*double(i); sn[i] = 2.0*sin( x[i] ); sg[i] = (sn[i]>0)?1:((sn[i]<0)?-1:0); } // Copy the data to the plot setCurveData( cSin, x, sn, points ); setCurveData( cSign, x, sg, points ); // Set the style of the curves setCurvePen( cSin, QPen( blue ) ); setCurvePen( cSign, QPen( green, 3 ) ); // Show the plots replot(); }
[ [ [ 1, 44 ] ] ]
9abd4a6bb46ba24365549a227d2e8d9bf44913a8
a48646eddd0eec81c4be179511493cbaf22965b9
/src/dns/dns_type.inc
0f4bb67b31156e9f9b0d0bffeef972cf294325d8
[]
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
852
inc
/* 域名解析控制块 */ typedef struct tagDNS_CB_S { UCHAR ucIsUsed; /* 控制块是否在使用 */ UCHAR aucDomainName[DNS_MAX_DOMAIN_NAME_LEN]; /* 待解析域名 */ DNS_TYPE_E eType; /* 域名类型 */ ULONG ulReqList; /* 请求列表 */ ULONG ulNext; /* 下一控制块索引 */ }DNS_CB_S; /* 域名请求记录结构,便于异步操作 */ typedef struct tagDNS_REQ_S { UCHAR ucIsUsed; /* 控制块是否在使用 */ DNS_FN_RESULT_NOTIFY pfnNotify; /* 解析结果通知函数 */ ULONG ulPara; /* 解析请求参数 */ ULONG ulNext; /* 下一控制块索引 */ }DNS_REQ_S;
[ [ [ 1, 19 ] ] ]
7f9bd8515342280be13df822156ce8cc0d088954
5ce47e25b441e9302470a3acf3935adda2a150df
/tibialua/tibialua_tibia.cpp
0df57165799667f91835a3a31b2be85ea1364ceb
[]
no_license
Google-Code-Fork/tibialua
9cc9efae49c1432e4f3066214cf7d0de5d0dd3d9
7a122cb49d25ff2c5a7e144913177d9154986f4b
refs/heads/master
2021-01-01T05:36:50.636599
2009-01-22T14:15:37
2009-01-22T14:15:37
32,895,512
1
1
null
null
null
null
UTF-8
C++
false
false
2,875
cpp
#include "tibialua_tibia.h" // get window HWND tibia_getwindow() { return FindWindow("tibiaclient", 0); } // get process id DWORD tibia_getprocessid() { // get tibia window HWND tibiaWindow = tibia_getwindow(); // get process id DWORD processId; GetWindowThreadProcessId(tibiaWindow, &processId); return processId; } // get process handle HANDLE tibia_getprocesshandle() { // get process id DWORD processId = tibia_getprocessid(); // get process handle HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS, 0, processId); return processHandle; } // write bytes to memory void tibia_writebytes(DWORD address, int value, int bytes) { // get process handle HANDLE processHandle = tibia_getprocesshandle(); // write to memory WriteProcessMemory(processHandle, (LPVOID)address, &value, bytes, 0); // close process handle CloseHandle(processHandle); } // write double to memory void tibia_writedouble(DWORD address, double value) { // get process handle HANDLE processHandle = tibia_getprocesshandle(); // write to memory WriteProcessMemory(processHandle, (LPVOID)address, &value, sizeof(value), 0); // close process handle CloseHandle(processHandle); } // write string to memory void tibia_writestring(DWORD address, char* text) { // get process handle HANDLE processHandle = tibia_getprocesshandle(); // write to memory WriteProcessMemory(processHandle, (LPVOID)address, text, strlen(text) + 1, 0); // close process handle CloseHandle(processHandle); } // write NOPs to memory void tibia_writenops(DWORD address, int nops) { // get process handle HANDLE processHandle = tibia_getprocesshandle(); // write to memory int i, j = 0; for (i = 0; i < nops; i++) { unsigned char nop = 0x90; WriteProcessMemory(processHandle, (LPVOID)(address + j), &nop, 1, 0); j++; // increment address } // close process handle CloseHandle(processHandle); } // read bytes from memory int tibia_readbytes(DWORD address, int bytes) { // get process handle HANDLE processHandle = tibia_getprocesshandle(); // read from memory int buffer = 0; ReadProcessMemory(processHandle, (LPVOID)address, &buffer, bytes, 0); // close process handle CloseHandle(processHandle); return buffer; } // read string from memory char* tibia_readstring(DWORD address) { // get process handle HANDLE processHandle = tibia_getprocesshandle(); // read from memory static char buffer[256]; ReadProcessMemory(processHandle, (LPVOID)address, &buffer, sizeof(buffer), 0); // close process handle CloseHandle(processHandle); return buffer; }
[ "[email protected]@6c450836-be4a-11dd-9405-3d0920048215" ]
[ [ [ 1, 120 ] ] ]
a4f97379be7007ffc0597492d15febe58cac6d2e
2b3ff42b129d9af57079558a41e826089ab570c2
/0.99.x/lib/Source/tb2k/TB2Consts.hpp
dd4c279012c8129e35d4094f148e557cf456faba
[]
no_license
bravesoftdz/contexteditor-1
07c242f7080846aa56b62b4d0e7790ecbb0167da
9f26c456cda4d7546217fed6557bf2440ca097fd
refs/heads/master
2020-03-25T18:36:18.350531
2009-08-25T01:34:08
2009-08-25T01:34:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,928
hpp
// CodeGear C++Builder // Copyright (c) 1995, 2008 by CodeGear // All rights reserved // (DO NOT EDIT: machine generated header) 'Tb2consts.pas' rev: 20.00 #ifndef Tb2constsHPP #define Tb2constsHPP #pragma delphiheader begin #pragma option push #pragma option -w- // All warnings off #pragma option -Vx // Zero-length empty class member functions #pragma pack(push,8) #include <System.hpp> // Pascal unit #include <Sysinit.hpp> // Pascal unit //-- user supplied ----------------------------------------------------------- namespace Tb2consts { //-- type declarations ------------------------------------------------------- //-- var, const, procedure --------------------------------------------------- extern PACKAGE System::ResourceString _STBToolbarIndexOutOfBounds; #define Tb2consts_STBToolbarIndexOutOfBounds System::LoadResourceString(&Tb2consts::_STBToolbarIndexOutOfBounds) extern PACKAGE System::ResourceString _STBToolbarItemReinserted; #define Tb2consts_STBToolbarItemReinserted System::LoadResourceString(&Tb2consts::_STBToolbarItemReinserted) extern PACKAGE System::ResourceString _STBToolbarItemParentInvalid; #define Tb2consts_STBToolbarItemParentInvalid System::LoadResourceString(&Tb2consts::_STBToolbarItemParentInvalid) extern PACKAGE System::ResourceString _STBViewerNotFound; #define Tb2consts_STBViewerNotFound System::LoadResourceString(&Tb2consts::_STBViewerNotFound) extern PACKAGE System::ResourceString _STBChevronItemMoreButtonsHint; #define Tb2consts_STBChevronItemMoreButtonsHint System::LoadResourceString(&Tb2consts::_STBChevronItemMoreButtonsHint) extern PACKAGE System::ResourceString _STBMRUListItemDefCaption; #define Tb2consts_STBMRUListItemDefCaption System::LoadResourceString(&Tb2consts::_STBMRUListItemDefCaption) extern PACKAGE System::ResourceString _STBMDIWindowItemDefCaption; #define Tb2consts_STBMDIWindowItemDefCaption System::LoadResourceString(&Tb2consts::_STBMDIWindowItemDefCaption) extern PACKAGE System::ResourceString _STBDockParentNotAllowed; #define Tb2consts_STBDockParentNotAllowed System::LoadResourceString(&Tb2consts::_STBDockParentNotAllowed) extern PACKAGE System::ResourceString _STBDockCannotChangePosition; #define Tb2consts_STBDockCannotChangePosition System::LoadResourceString(&Tb2consts::_STBDockCannotChangePosition) extern PACKAGE System::ResourceString _STBToolwinNameNotSet; #define Tb2consts_STBToolwinNameNotSet System::LoadResourceString(&Tb2consts::_STBToolwinNameNotSet) extern PACKAGE System::ResourceString _STBToolwinDockedToNameNotSet; #define Tb2consts_STBToolwinDockedToNameNotSet System::LoadResourceString(&Tb2consts::_STBToolwinDockedToNameNotSet) } /* namespace Tb2consts */ using namespace Tb2consts; #pragma pack(pop) #pragma option pop #pragma delphiheader end. //-- end unit ---------------------------------------------------------------- #endif // Tb2constsHPP
[ "[email protected]@5d03d0dc-17f0-11de-b413-eb0469710719" ]
[ [ [ 1, 54 ] ] ]
93b479d20e85faa084ee3f764f57a0e08a258a1b
651af48ec7badc8833ce01f5e3000646da87500b
/Snoop/ManagedInjector/Injector.h
4dc4d6c1502012cf6db463d00a4614cc8956f3c3
[]
no_license
RredCat/snoopmyversion
fa3fb6968446f562e84fda38ef48d7f69086f161
ea7a344ac8929e13f089007b5d5a2d9400f22ea0
refs/heads/master
2021-03-12T19:33:11.483966
2010-05-16T21:13:55
2010-05-16T21:13:55
32,183,792
0
0
null
null
null
null
UTF-8
C++
false
false
348
h
#pragma once __declspec( dllexport ) int __stdcall MessageHookProc(int nCode, WPARAM wparam, LPARAM lparam); namespace ManagedInjector { public ref class Injector: System::Object { public: static void Launch(System::IntPtr windowHandle, System::String^ assemblyName, System::String^ className, System::String^ methodName); }; }
[ "rredcat@aef2b62d-4553-0410-b098-a72ca8ef7944" ]
[ [ [ 1, 13 ] ] ]
d3140b3add63cdf62e1490434e8dbd5b4ba5d7a9
67b2def2fad324bcf3692447bee63c96b4f1bddd
/ visualattention/VisualAttention/saliency_map.cpp
02791bb22c4b9348d44bd0b55fac529ded29495e
[]
no_license
yyscamper/visualattention
3178e0f0f59c90219f8a59f5515b5a3f008e6856
ae51afa989635fc5718693e1711c007e4f712098
refs/heads/master
2020-05-05T03:22:24.126892
2010-06-20T15:01:33
2010-06-20T15:01:33
32,130,415
0
0
null
null
null
null
GB18030
C++
false
false
27,164
cpp
#include "saliency_map.h" VAMToolbox::VAMToolbox() { m_typeOfVAMNormalize = VAM_ITERATIVE; m_numOfPyrLevel = 9; m_numOfOri = 4; m_featWeight.val[0] = 1/3.0; m_featWeight.val[1] = 1/3.0; m_featWeight.val[2] = 1/3.0; m_gaborSize = 9; m_numOfGaborScale = 4; m_gaborUL = 0.04; m_gaborUH = 0.5; m_pOriginImg = NULL; m_ppImgPyr = NULL; m_ppIntPyr = NULL; m_pIntMap = NULL; m_pColorMap = NULL; m_pOriMap = NULL; m_pSaliencyMapOfInt = NULL; m_pSaliencyMapOfCol = NULL; m_pSaliencyMapOfOri = NULL; } VAMToolbox::~VAMToolbox() { Release(); } void VAMToolbox::Release() { cvReleaseMat(&m_pIntMap); cvReleaseMat(&m_pColorMap); cvReleaseMat(&m_pOriMap); ReleaseBatch(&m_ppImgPyr, m_numOfPyrLevel); ReleaseBatch(&m_ppIntPyr, m_numOfPyrLevel); cvReleaseMatHeader(&m_pSaliencyMapOfInt); cvReleaseMatHeader(&m_pSaliencyMapOfCol); cvReleaseMatHeader(&m_pSaliencyMapOfOri); } IplImage* VAMToolbox::LoadImage(char* path) { IplImage* img = cvLoadImage(path); if(img == NULL){ return NULL; } LoadImage(img); return img; } void VAMToolbox::LoadImage(IplImage* img) { if(m_pOriginImg != NULL){ cvReleaseImage(&m_pOriginImg); } CvSize imgSize = cvGetSize(img); int minLen = cvCeil(pow(2.0, m_numOfPyrLevel-1)); int minSrc = min(img->width, img->height); if(minSrc < minLen){ double zoom = (double)minLen / (double)minSrc; imgSize.height = cvCeil(imgSize.height * zoom); imgSize.width = cvCeil(imgSize.width * zoom); IplImage* zoomImg = cvCreateImage(imgSize, img->depth, img->nChannels); assert(zoomImg != NULL); cvResize(img, zoomImg); m_pOriginImg = cvCreateImage(imgSize, IPL_DEPTH_32F, img->nChannels); assert(m_pOriginImg != NULL); cvConvertScale(zoomImg, m_pOriginImg, 1.0/255.0); cvReleaseImage(&zoomImg); }else{ m_pOriginImg = cvCreateImage(imgSize, IPL_DEPTH_32F, img->nChannels); assert(m_pOriginImg != NULL); cvConvertScale(img, m_pOriginImg, 1.0/255.0); } } /** * 获取显著图 * @param * @return 失败返回NULL */ IplImage* VAMToolbox::GetSaliencyMap(IplImage* pSrcImg) { if(pSrcImg != NULL){ LoadImage(pSrcImg); }else if(m_pOriginImg == NULL){ return NULL; } CvMat *pDstMap; BuildImgPyr(); m_pSaliencyMapOfInt = GetIntMap(); m_pSaliencyMapOfCol = GetColMap(); m_pSaliencyMapOfOri = GetOriMap(); pDstMap = cvCreateMat(m_pSaliencyMapOfInt->rows, m_pSaliencyMapOfInt->cols, CV_32FC1); cvAddWeighted(m_pSaliencyMapOfInt, m_featWeight.val[0], m_pSaliencyMapOfCol, m_featWeight.val[1], 0, pDstMap); cvAddWeighted(m_pSaliencyMapOfOri, m_featWeight.val[2], pDstMap, 1.0, 0, pDstMap); CvMat* pDstMap_oriSize = cvCreateMat(cvGetSize(m_pOriginImg).height, cvGetSize(m_pOriginImg).width, CV_32FC1); cvResize(pDstMap, pDstMap_oriSize, CV_INTER_LINEAR); cvNormalize(pDstMap_oriSize, pDstMap_oriSize, 1.0, 0.0, CV_MINMAX, NULL); IplImage* pDstImg = MatToImage(pDstMap_oriSize); //cvReleaseMatHeader(&pDstMap_oriSize); return pDstImg; } IplImage* VAMToolbox::GetSaliencyMapOfIntensity(IplImage* pSrcImg) { if(m_pSaliencyMapOfInt == NULL){ LoadImage(pSrcImg); BuildImgPyr(); m_pSaliencyMapOfInt = GetIntMap(); } CvMat* pDstMap_oriSize = cvCreateMat(cvGetSize(m_pOriginImg).height, cvGetSize(m_pOriginImg).width, CV_32FC1); cvResize(m_pSaliencyMapOfInt, pDstMap_oriSize, CV_INTER_LINEAR); cvNormalize(pDstMap_oriSize, pDstMap_oriSize, 1.0, 0.0, CV_MINMAX, NULL); IplImage* pDstImg = MatToImage(pDstMap_oriSize); //cvReleaseMatHeader(&pDstMap_oriSize); return pDstImg; } IplImage* VAMToolbox::GetSaliencyMapOfColor(IplImage* pSrcImg) { if(m_pSaliencyMapOfCol == NULL){ LoadImage(pSrcImg); BuildImgPyr(); m_pSaliencyMapOfCol = GetColMap(); } CvMat* pDstMap_oriSize = cvCreateMat(cvGetSize(m_pOriginImg).height, cvGetSize(m_pOriginImg).width, CV_32FC1); cvResize(m_pSaliencyMapOfCol, pDstMap_oriSize, CV_INTER_LINEAR); cvNormalize(pDstMap_oriSize, pDstMap_oriSize, 1.0, 0.0, CV_MINMAX, NULL); IplImage* pDstImg = MatToImage(pDstMap_oriSize); //cvReleaseMatHeader(&pDstMap_oriSize); return pDstImg; } IplImage* VAMToolbox::GetSaliencyMapOfOrientation(IplImage* pSrcImg) { if(m_pSaliencyMapOfOri == NULL){ LoadImage(pSrcImg); BuildImgPyr(); m_pSaliencyMapOfOri = GetOriMap(); } CvMat* pDstMap_oriSize = cvCreateMat(cvGetSize(m_pOriginImg).height, cvGetSize(m_pOriginImg).width, CV_32FC1); cvResize(m_pSaliencyMapOfOri, pDstMap_oriSize, CV_INTER_LINEAR); cvNormalize(pDstMap_oriSize, pDstMap_oriSize, 1.0, 0.0, CV_MINMAX, NULL); IplImage* pDstImg = MatToImage(pDstMap_oriSize); //cvReleaseMatHeader(&pDstMap_oriSize); return pDstImg; } /** * 获取强度特征的显著图 * @param * @return 失败返回NULL */ CvMat* VAMToolbox::GetIntMap() { int numOfMaps; CvMat** ppIntFeatMap; CvMat *pTempMat, *pSumMat; BuildIntPyr(); ppIntFeatMap = CalcIntFeatMap(m_ppIntPyr, &numOfMaps); pTempMat = cvCreateMat(m_ppIntPyr[4]->rows, m_ppIntPyr[4]->cols, CV_32FC1); assert(pTempMat != NULL); pSumMat = cvCreateMat(m_ppIntPyr[4]->rows, m_ppIntPyr[4]->cols, CV_32FC1); assert(pSumMat != NULL); cvResize(ppIntFeatMap[0], pSumMat); for(int i=1; i < numOfMaps; i++){ if(ppIntFeatMap[i]->rows == m_ppIntPyr[4]->rows){ cvAdd(pSumMat, ppIntFeatMap[i], pSumMat); }else{ cvResize(ppIntFeatMap[i], pTempMat, CV_INTER_LINEAR); cvAdd(pSumMat, pTempMat, pSumMat); } } VAMNormalize(pSumMat, pSumMat); cvReleaseMat(&pTempMat); ReleaseBatch(&ppIntFeatMap, numOfMaps); return pSumMat; } /** * 获取颜色特征的显著图 * @param * @return 失败返回NULL */ CvMat* VAMToolbox::GetColMap() { int numOfMaps; CvMat** ppColFeatMap; CvMat *pTempMat, *pSumMat; CvMat **Rpyr, **Gpyr, **Bpyr, **Ypyr; if(m_ppIntPyr == NULL){ BuildIntPyr(); } BuildColPyr(&Rpyr, &Gpyr, &Bpyr, &Ypyr); ppColFeatMap = CalcColFeatMap(Rpyr, Gpyr, Bpyr, Ypyr, &numOfMaps); pTempMat = cvCreateMat(m_ppIntPyr[4]->rows, m_ppIntPyr[4]->cols, CV_32FC1); assert(pTempMat != NULL); pSumMat = cvCreateMat(m_ppIntPyr[4]->rows, m_ppIntPyr[4]->cols, CV_32FC1); assert(pSumMat != NULL); cvResize(ppColFeatMap[0], pSumMat); for(int i=1; i<numOfMaps; i++){ if(ppColFeatMap[i]->rows == m_ppIntPyr[4]->rows){ cvAdd(pSumMat, ppColFeatMap[i], pSumMat); }else{ cvResize(ppColFeatMap[i], pTempMat, CV_INTER_LINEAR); cvAdd(pSumMat, pTempMat, pSumMat); } } VAMNormalize(pSumMat, pSumMat); cvReleaseMat(&pTempMat); ReleaseBatch(&ppColFeatMap, numOfMaps); ReleaseBatch(&Rpyr, m_numOfPyrLevel); ReleaseBatch(&Gpyr, m_numOfPyrLevel); ReleaseBatch(&Bpyr, m_numOfPyrLevel); ReleaseBatch(&Ypyr, m_numOfPyrLevel); return pSumMat; } /** * 获取方向特征的显著图 * @param * @return 失败返回NULL */ CvMat* VAMToolbox::GetOriMap() { int numOfMaps; CvMat** ppOriFeatMap; CvMat ***pppOriPyr; CvMat *pTempMat, *pSumMat; if(m_ppIntPyr == NULL){ BuildIntPyr(); } pppOriPyr = BuildOriPyr(); ppOriFeatMap = CalcOriFeatMap(pppOriPyr, &numOfMaps); pTempMat = cvCreateMat(m_ppIntPyr[4]->rows, m_ppIntPyr[4]->cols, CV_32FC1); assert(pTempMat != NULL); pSumMat = cvCreateMat(m_ppIntPyr[4]->rows, m_ppIntPyr[4]->cols, CV_32FC1); assert(pSumMat != NULL); cvResize(ppOriFeatMap[0], pSumMat); for(int i=1; i<numOfMaps; i++){ if(ppOriFeatMap[i]->rows == m_ppIntPyr[4]->rows){ cvAdd(pSumMat, ppOriFeatMap[i], pSumMat); }else{ cvResize(ppOriFeatMap[i], pTempMat, CV_INTER_LINEAR); cvAdd(pSumMat, pTempMat, pSumMat); } } VAMNormalize(pSumMat, pSumMat); cvReleaseMat(&pTempMat); ReleaseBatch(&ppOriFeatMap, numOfMaps); for(int i=0; i<m_numOfOri; i++){ ReleaseBatch(&pppOriPyr[i], m_numOfPyrLevel); } ReleaseBatch(&pppOriPyr, m_numOfOri); return pSumMat; } /** * 获取注意力转换轨迹 * @param * @return 失败返回NULL */ void VAMToolbox::GetVisualPath() { return; } void VAMToolbox::BuildImgPyr() { assert(m_pOriginImg != NULL); m_ppImgPyr = (CvMat**)calloc(m_numOfPyrLevel, sizeof(CvMat*)); assert(m_ppImgPyr != NULL); //The first level of pyramid is origin image m_ppImgPyr[0] = cvCreateMatHeader(m_pOriginImg->height, m_pOriginImg->width, CV_32FC3); assert(m_ppImgPyr[0] != NULL); cvGetMat(m_pOriginImg, m_ppImgPyr[0]); CvSize levelSize = cvGetSize(m_pOriginImg); for(int i=1; i < m_numOfPyrLevel; i++){ levelSize.height /= 2; levelSize.width /= 2; m_ppImgPyr[i] = cvCreateMat(levelSize.height, levelSize.width, CV_32FC3); assert(m_ppImgPyr[i] != NULL); cvResize(m_ppImgPyr[i-1], m_ppImgPyr[i], CV_INTER_LINEAR); } } CvMat** VAMToolbox::BuildIntPyr() { if(m_ppImgPyr == NULL){ BuildImgPyr(); } m_ppIntPyr = (CvMat**)calloc(m_numOfPyrLevel, sizeof(CvMat*)); assert(m_ppIntPyr != NULL); for(int i=0; i < m_numOfPyrLevel; i++) { m_ppIntPyr[i] = cvCreateMat(m_ppImgPyr[i]->rows, m_ppImgPyr[i]->cols, CV_32FC1); assert(m_ppIntPyr[i] != NULL); cvCvtColor(m_ppImgPyr[i], m_ppIntPyr[i], CV_BGR2GRAY); } return m_ppIntPyr; } void VAMToolbox::DecoupleHue(CvMat *rMat, CvMat *gMat,CvMat *bMat, CvMat* iMat, CvMat *dstMat, uchar type) { int rows = rMat->rows; int cols = rMat->cols; int m, n; double val, r, g, b, max, threshold; cvMinMaxLoc(iMat, NULL, &max, NULL, NULL, NULL); threshold = 0.1 * max; switch(type) { case 'R': for(m=0; m < rMat->rows; m++){ for(n=0; n < rMat->cols; n++){ if(cvmGet(iMat, m, n) < threshold){ val = 0; }else{ r = cvmGet(rMat, m, n); g = cvmGet(gMat, m, n); b = cvmGet(bMat, m, n); val = r-(g+b)/2; } cvmSet(dstMat, m, n, val); } } break; case 'G': for(m=0; m < rows; m++){ for(n=0; n < cols; n++){ if(cvmGet(iMat, m, n) < threshold){ val = 0; }else{ r = cvmGet(rMat, m, n); g = cvmGet(gMat, m, n); b = cvmGet(bMat, m, n); val = g-(r+b)/2; } cvmSet(dstMat, m, n, val); } } break; case 'B': for(m=0; m < rows; m++){ for(n=0; n < cols; n++){ if(cvmGet(iMat, m, n) < threshold){ val = 0; }else{ r = cvmGet(rMat, m, n); g = cvmGet(gMat, m, n); b = cvmGet(bMat, m, n); val = b-(r+g)/2; } cvmSet(dstMat, m, n, val); } } break; case 'Y': for(m=0; m < rows; m++){ for(n=0; n < cols; n++){ if(cvmGet(iMat, m, n) < threshold){ val = 0; }else{ r = cvmGet(rMat, m, n); g = cvmGet(gMat, m, n); b = cvmGet(bMat, m, n); val = r+g-2*(abs(r-g)+b); } cvmSet(dstMat, m, n, val); } } break; default: return; } } void VAMToolbox::BuildColPyr(CvMat*** pppRpyr, CvMat*** pppGpyr, CvMat*** pppBpyr, CvMat*** pppYpyr) { CvMat** &R = *pppRpyr; CvMat** &G = *pppGpyr; CvMat** &B = *pppBpyr; CvMat** &Y = *pppYpyr; R = (CvMat**)calloc(m_numOfPyrLevel, sizeof(CvMat*)); assert(R != NULL); G = (CvMat**)calloc(m_numOfPyrLevel, sizeof(CvMat*)); assert(G != NULL); B = (CvMat**)calloc(m_numOfPyrLevel, sizeof(CvMat*)); assert(B != NULL); Y = (CvMat**)calloc(m_numOfPyrLevel, sizeof(CvMat*)); assert(Y != NULL); int rows, cols; CvMat *r, *g, *b; for(int i=0; i < m_numOfPyrLevel; i++){ rows = m_ppImgPyr[i]->rows; cols = m_ppImgPyr[i]->cols; r = cvCreateMat(rows, cols, CV_32FC1); assert(r != NULL); g = cvCreateMat(rows, cols, CV_32FC1); assert(g != NULL); b = cvCreateMat(rows, cols, CV_32FC1); assert(b != NULL); R[i] = cvCreateMat(rows, cols, CV_32FC1); assert(R[i] != NULL); G[i] = cvCreateMat(rows, cols, CV_32FC1); assert(G[i] != NULL); B[i] = cvCreateMat(rows, cols, CV_32FC1); assert(B[i] != NULL); Y[i] = cvCreateMat(rows, cols, CV_32FC1); assert(Y[i] != NULL); cvSplit(m_ppImgPyr[i], b, g, r, NULL); DecoupleHue(r, g, b, m_ppIntPyr[i], R[i], 'R'); DecoupleHue(r, g, b, m_ppIntPyr[i], G[i], 'G'); DecoupleHue(r, g, b, m_ppIntPyr[i], B[i], 'B'); DecoupleHue(r, g, b, m_ppIntPyr[i], Y[i], 'Y'); cvReleaseMat(&r); cvReleaseMat(&g); cvReleaseMat(&b); } } CvMat*** VAMToolbox::BuildOriPyr() { CvMat*** pppOriPyr = (CvMat***)calloc(m_numOfOri, sizeof(CvMat**)); assert(pppOriPyr != NULL); for(int i=0; i < m_numOfPyrLevel; i++){ pppOriPyr[i] = (CvMat**)calloc(m_numOfPyrLevel, sizeof(CvMat*)); assert(pppOriPyr[i] != NULL); } for(int i=0; i < m_numOfOri; i++){ for(int j=0; j < m_numOfPyrLevel; j++){ pppOriPyr[i][j] = cvCreateMat(m_ppIntPyr[j]->rows, m_ppIntPyr[j]->cols, CV_32FC1); assert(pppOriPyr[i][j] != NULL); GaborFilterImage(m_ppIntPyr[j], pppOriPyr[i][j], j, i); //DispMat(pppOriPyr[i][j]); } } return pppOriPyr; } CvMat** VAMToolbox::CalcIntFeatMap(CvMat** ppIntPyr, int* numOfMaps) { CvMat** ppIntFeatMap; CvMat *tempMap; int rows, cols; ppIntFeatMap = (CvMat**)calloc(6, sizeof(CvMat*)); assert(ppIntFeatMap != NULL); for(int i=2;i<5;i++){ rows = ppIntPyr[i]->rows; cols = ppIntPyr[i]->cols; tempMap = cvCreateMat(rows, cols, CV_32FC1); ppIntFeatMap[2*i-4] = cvCreateMat(rows, cols, CV_32FC1);//I:2-5 cvResize(ppIntPyr[i+3], tempMap); cvAbsDiff(ppIntPyr[i], tempMap,ppIntFeatMap[2*i-4]); ppIntFeatMap[2*i-3] = cvCreateMat(rows, cols, CV_32FC1);//I:2-6 cvResize(ppIntPyr[i+4], tempMap); cvAbsDiff(ppIntPyr[i], tempMap,ppIntFeatMap[2*i-3]); } cvReleaseMat(&tempMap); for(int i=0; i<6; i++){ VAMNormalize(ppIntFeatMap[i], ppIntFeatMap[i]); } *numOfMaps = 6; return ppIntFeatMap; } CvMat** VAMToolbox::CalcColFeatMap(CvMat** R, CvMat** G, CvMat** B, CvMat** Y, int* numOfMaps) { int rows, cols; CvMat **ppColFeatMap, **ppRGFeatMap, **ppBYFeatMap; CvMat *tempMap1, *tempMap2, *tempMap3, *tempMap4; ppColFeatMap = (CvMat**)calloc(12, sizeof(CvMat*)); assert(ppColFeatMap != NULL); ppRGFeatMap = ppColFeatMap; ppBYFeatMap = ppColFeatMap + 6; for(int i=2; i<5; i++){ rows = R[i]->rows; cols = R[i]->cols; tempMap1 = cvCreateMat(rows, cols, CV_32FC1); tempMap2 = cvCreateMat(rows, cols, CV_32FC1); tempMap3 = cvCreateMat(R[i+3]->rows, R[i+3]->cols, CV_32FC1); tempMap4 = cvCreateMat(R[i+4]->rows, R[i+4]->cols, CV_32FC1); ppRGFeatMap[2*i-4] = cvCreateMat(rows, cols, CV_32FC1); //RG:2-5 cvSub(R[i], G[i], tempMap1); cvSub(R[i+3], G[i+3], tempMap3); cvResize(tempMap3, tempMap2); cvAbsDiff(tempMap1, tempMap2, ppRGFeatMap[2*i-4]); ppRGFeatMap[2*i-3] = cvCreateMat(rows, cols, CV_32FC1); //RG:2-6 cvSub(R[i], G[i], tempMap1); cvSub(R[i+4], G[i+4], tempMap4); cvResize(tempMap4,tempMap2); cvAbsDiff(tempMap1, tempMap2, ppRGFeatMap[2*i-3]); ppBYFeatMap[2*i-4] = cvCreateMat(rows, cols, CV_32FC1); //BY:2-5 cvSub(B[i], Y[i], tempMap1); cvSub(B[i+3], Y[i+3], tempMap3); cvResize(tempMap3, tempMap2); cvAbsDiff(tempMap1, tempMap2, ppBYFeatMap[2*i-4]); ppBYFeatMap[2*i-3] = cvCreateMat(rows, cols, CV_32FC1); //BY:2-6 cvSub(B[i], Y[i], tempMap1); cvSub(B[i+4], Y[i+4], tempMap4); cvResize(tempMap4, tempMap2); cvAbsDiff(tempMap1, tempMap2, ppBYFeatMap[2*i-3]); } cvReleaseMat(&tempMap1); cvReleaseMat(&tempMap2); cvReleaseMat(&tempMap3); cvReleaseMat(&tempMap4); for(int i=0; i<12; i++){ VAMNormalize(ppColFeatMap[i], ppColFeatMap[i]); } *numOfMaps = 12; return ppColFeatMap; } CvMat** VAMToolbox::CalcOriFeatMap(CvMat*** pppOriPyr, int *numOfMaps) { CvMat** ppOriFeatMap; CvMat *tempMap; int rows, cols, pos; ppOriFeatMap = (CvMat**)calloc(24, sizeof(CvMat*)); assert(ppOriFeatMap != NULL); for(int i=2; i<5; i++){ rows = pppOriPyr[0][i]->rows; cols = pppOriPyr[0][i]->cols; tempMap = cvCreateMat(rows, cols, CV_32FC1); assert(tempMap != NULL); for(int j=0; j < m_numOfOri; j++){ pos = j*6 + 2*i - 4; ppOriFeatMap[pos] = cvCreateMat(rows, cols, CV_32FC1);//I:2-5 assert(ppOriFeatMap[pos] != NULL); cvResize(pppOriPyr[j][i+3], tempMap); cvAbsDiff(pppOriPyr[j][i], tempMap, ppOriFeatMap[pos]); pos = j*6 + 2*i - 3; ppOriFeatMap[pos] = cvCreateMat(rows, cols, CV_32FC1);//I:2-6 assert(ppOriFeatMap[pos] != NULL); cvResize(pppOriPyr[j][i+4], tempMap); cvAbsDiff(pppOriPyr[j][i], tempMap, ppOriFeatMap[pos]); } cvReleaseMat(&tempMap); } for(int i=0; i<24; i++){ VAMNormalize(ppOriFeatMap[i], ppOriFeatMap[i]); #ifdef _VAM_SHOW_ORI_FEATMAP_ CvMat* mm = cvCreateMat(m_pOriginImg->height, m_pOriginImg->width, CV_32FC1); cvResize(ppOriFeatMap[i], mm); DispMat(mm); cvReleaseMat(&mm); #endif } *numOfMaps = 24; return ppOriFeatMap; } void VAMToolbox::VAMNormalize(CvMat* src, CvMat* dst) { switch(m_typeOfVAMNormalize){ case VAM_NAVIE_SUM: cvNormalize(src, dst, 1.0, 0.0, CV_MINMAX, NULL); break; case VAM_LINEAR_COMBINATIOIN: break; case VAM_NON_LINEAR_AMPLIFICATION: NonLinearAmp(src, dst); break; case VAM_ITERATIVE: IterativeNorm(src, dst, 10); break; default: break; } } //DoGFilter CvMat* VAMToolbox::GetDogFilter(double exSigma, double exC, double inhSigma, double inhC, int radius) { int x, y, width; double exParm1, exParm2, inParm1, inParm2, val; exParm1 = 0.5 / (exSigma*exSigma); inParm1 = 0.5 / (inhSigma*inhSigma); exParm2 = exC * exC * exParm1 / CV_PI; inParm2 = inhC * inhC * inParm1 / CV_PI; width = radius+radius+1; CvMat *T = cvCreateMat(width, width, CV_32FC1); assert(T != NULL); for(x = -radius; x <= radius; x++){ for(y = -radius; y <= radius; y++){ val = exParm2 * exp(-(x*x + y*y) * exParm1) - inParm2 * exp(-(x*x + y*y) * inParm1); cvmSet(T, x + radius, y + radius, val); } } return T; } //Iterative Localized Interations void VAMToolbox::IterativeNorm(CvMat *src, CvMat *dst, int nIteration) { int sz, width, radius, i; double exSigma, inhSigma, exC, inhC; CvScalar constInh; sz = min(src->rows,src->cols); exSigma = 0.02*sz; inhSigma = 0.25*sz; exC = 0.5; inhC = 1.5; constInh.val[0] = 0.02; radius = sz/8; if(radius <= 0){ radius = 1; }else if(radius > 4){ radius = 4; } width = radius*2+1; CvMat *T = GetDogFilter(exSigma, exC, inhSigma, inhC, radius); CvMat *pResultMat = cvCloneMat(src); assert(pResultMat != NULL); cvNormalize(pResultMat, pResultMat, 1.0, 0.0, CV_MINMAX, NULL); CvMat *pTempMat = cvCreateMat(src->rows, src->cols, src->type); assert(pTempMat != NULL); for(i=0; i < nIteration; i++){ cvCopy(pResultMat, pTempMat, NULL); TrunConv(pTempMat, pResultMat, T); cvAdd(pTempMat, pResultMat, pResultMat); cvSubS(pResultMat, constInh, pResultMat); cvThreshold(pResultMat, pResultMat, 0.0, 0, CV_THRESH_TOZERO); } cvCopy(pResultMat, dst, NULL); cvReleaseMat(&pResultMat); } //Truncated Filter void VAMToolbox::TrunConv(CvMat *src, CvMat *dst, CvMat *T) { cvFilter2D(src, dst, T); // double minVal, maxVal; //cvMinMaxLoc(dst, &minVal, &maxVal, NULL, NULL, NULL); ////printf("\nMinVal = %f, maxVal = %f", minVal, maxVal);*/ //int radius = (T->rows-1)/2; //SetValInRectRange(dst, minVal, 0, 0, dst->cols, radius); //SetValInRectRange(dst, minVal, 0, dst->rows - radius, dst->cols, radius); //SetValInRectRange(dst, minVal, 0, radius, radius, dst->rows - 2*radius); //SetValInRectRange(dst, minVal, dst->cols - radius, radius, radius, dst->rows - 2*radius); //assert(src != NULL && dst != NULL && T != NULL); //CvMat* pResultMat = cvCreateMat(src->rows, src->cols, src->type); //assert(pResultMat != NULL); // //if(min(src->rows, src->cols) <= T->rows){ //the size of input mat is not larger the template // TrunConvInRange(src, pResultMat, T, 0, src->rows-1, 0, src->cols-1); //}else{ // cvFilter2D(src, pResultMat, T); // int radius = (T->rows-1)/2; // TrunConvInRange(src, pResultMat, T, 0, radius - 1, 0, src->cols - 1); // TrunConvInRange(src, pResultMat, T, src->rows - radius, src->rows - 1, 0, src->cols - 1); // TrunConvInRange(src, pResultMat, T, radius, src->rows - radius - 1, 0, radius - 1); // TrunConvInRange(src, pResultMat, T, radius, src->rows - radius - 1, // src->cols - radius - 1, src->cols - 1); // //} //cvCopy(pResultMat, dst, NULL); //cvReleaseMat(&pResultMat); /*int rCen, cCen, r, c, radius; double TSum, overlapTSum, overlapMulSum; CvScalar tempTSum; tempTSum = cvSum(T); TSum = tempTSum.val[0]; radius = (T->rows - 1) / 2; CvMat *pResultMat = cvCreateMat(src->rows, src->cols, src->type); assert(pResultMat != NULL); for(rCen=0; rCen < radius; rCen++){ for(cCen=0; cCen < src->cols; cCen++){ overlapTSum = 0.0; overlapMulSum = 0.0; for(r = -radius; r <= radius; r++){ for(c = -radius; c<= radius; c++){ if(r + rCen < 0 || r + rCen >= src->rows || c + cCen < 0 || c + cCen >= src->cols){ continue; } overlapTSum += cvmGet(T, r + radius, c + radius); overlapMulSum += cvmGet(T, r + radius, c+ radius) * cvmGet(src, r + rCen, c + cCen); } } cvmSet(pResultMat, rCen, cCen, TSum * overlapMulSum / overlapTSum); } } cvCopy(pResultMat, dst, NULL); cvReleaseMat(&pResultMat);*/ } void VAMToolbox::TrunConvInRange(CvMat* src, CvMat* dst, CvMat* T, int rowStart, int rowEnd, int colStart, int colEnd) { assert(src != dst); int rCen, cCen, r, c, radius; double TSum, overlapTSum, overlapMulSum; CvScalar tempTSum; tempTSum = cvSum(T); TSum = tempTSum.val[0]; radius = (T->rows - 1) / 2; for(rCen = rowStart; rCen <= rowEnd; rCen++){ for(cCen = colStart; cCen <= colEnd; cCen++){ overlapTSum = 0.0; overlapMulSum = 0.0; for(r = -radius; r <= radius; r++){ for(c = -radius; c<= radius; c++){ if(r + rCen < 0 || r + rCen >= src->rows || c + cCen < 0 || c + cCen >= src->cols){ continue; } overlapTSum += cvmGet(T, r + radius, c + radius); overlapMulSum += (cvmGet(T, r + radius, c+ radius) * cvmGet(src, r + rCen, c + cCen)); } } cvmSet(dst, rCen, cCen, TSum * overlapMulSum / overlapTSum); } } } //用全局的非线性放大法进行图像的正规化操作 void VAMToolbox::NonLinearAmp(CvMat *src,CvMat *dst) { int num; double avg, threshold = 0.1; cvNormalize(src, dst, 1.0, 0.0, CV_MINMAX, NULL); FindLocalMaxima(dst, threshold, &num, &avg); if(num > 1){ double parm = (1.0 - avg) * (1.0 - avg); cvScale(dst, dst, parm, 0); } } void VAMToolbox::FindLocalMaxima(CvMat* src, double threshold, int* num, double* avg) { double sum = 0.0; double val, temp; int lmaxCnt = 0; int i, j, m, n; bool flag = false; //ignore the pixel at boarder for(i=1; i < src->rows-1; i++){ for(j=1; j < src->cols-1; j++){ flag = true; val = cvmGet(src, i, j); if(val < threshold){ continue; } for(m=-1; flag && m <= 1; m++){ //compare with the neighbor for(n=-1; flag && n <= 1; n++){ temp = cvmGet(src, i+m, j+n); if(m !=0 && n != 0 && val < temp){ flag = false; } } } if(flag){ lmaxCnt++; sum += val; j++; //the next pixel is absolutely is not maxima } } } *avg = sum/lmaxCnt; *num = lmaxCnt; } //------------------------------------------------------------------------------------------------------ //The Gabor function generates a Gabor filter with the selected index 's' and 'n' (scale and orientation, //respectively) from a Gabor filter bank. This filter bank is designed by giving the range of spatial //frequency (Uh and Ul) and the total number of scales and orientations used to partition the spectrum. // //The returned filter is stored in 'Gr' (real part) and 'Gi' (imaginary part). //-------------------------------------------------------------------------------------------------------- void VAMToolbox::MakeGaborFilter(CvMat *Gr, CvMat *Gi, int s, int n, double Ul, double Uh, int scale, int orientation, int type) { /*float stdDev, elongation, angle, omega, filterPeriod; int filterSize; float major_stddev, minor_stddev, max_stddev, rtDeg, co, si, major_sigq, minor_sigq; int sz; major_stddev = stdDev; minor_stddev = major_stddev * elongation; max_stddev = max(major_stddev, minor_stddev); sz = filterSize; if(sz == -1){ sz = ceil(max_stddev*sqrt(10)); }else{ sz = floor(sz/2); } rtDeg = CV_PI / 180.0 * angle; omega = 2 * CV_PI / filterPeriod; co = cos(rtDeg); si = -sin(rtDeg); major_sigq = 2 * major_stddev * major_stddev; minor_sigq = 2 * minor_stddev * minor_stddev; int vlen = 2*sz + 1; float vco = vec * co vec = [-sz:sz]; vlen = length(vec); vco = vec*co; vsi = vec*si; major = repmat(vco',1,vlen) + repmat(vsi,vlen,1); major2 = major.^2; minor = repmat(vsi',1,vlen) - repmat(vco,vlen,1); minor2 = minor.^2; phase0 = exp(- major2 / major_sigq - minor2 / minor_sigq); % create the actual filters for p = 1:length(gaborParams.phases) psi = pi / 180 * gaborParams.phases(p); result = cos(omega * major + psi) .* phase0; % enforce disk shape? if (makeDisk) result((major2+minor2) > (gaborParams.filterSize/2)^2) = 0; end % normalization result = result - mean(result(:)); filter(:,:,p) = result / sqrt(sum(result(:).^2)); end*/ double base, a, u0, z, Uvar, Vvar, Xvar, Yvar, X, Y, G, t1, t2, m; int x, y, side; double temp; base = Uh/Ul; a = pow(base, 1.0/(double)(scale-1)); u0 = Uh/pow(a, (double) scale-s); Uvar = (a-1.0)*u0/((a+1.0)*sqrt(2.0*log(2.0))); z = -2.0*log(2.0)*(Uvar*Uvar)/u0; Vvar = tan(CV_PI/(2*orientation))*(u0+z)/sqrt(2.0*log(2.0)-z*z/(Uvar*Uvar)); Xvar = 1.0/(2.0*CV_PI*Uvar); Yvar = 1.0/(2.0*CV_PI*Vvar); t1 = cos(CV_PI/orientation*(n-1.0)); t2 = sin(CV_PI/orientation*(n-1.0)); side = (int) (Gr->height-1)/2; for (x=0;x<2*side+1;x++) { for (y=0;y<2*side+1;y++) { X = (double) (x-side)*t1+ (double) (y-side)*t2; Y = (double) -(x-side)*t2+ (double) (y-side)*t1; G = 1.0/(2.0*CV_PI*Xvar*Yvar)*pow(a, (double) scale-s)*exp(-0.5*((X*X)/(Xvar*Xvar)+(Y*Y)/(Yvar*Yvar))); cvmSet(Gr,x,y,G*cos(2.0*CV_PI*u0*X)); cvmSet(Gi,x,y,G*sin(2.0*CV_PI*u0*X)); } } //if flag = 1, then remove the DC from the filter if (type == 1) { m = 0; for (x=0;x<2*side+1;x++) for (y=0;y<2*side+1;y++) m += cvmGet(Gr,x,y); m /= pow((double) 2.0*side+1, 2.0); for (x=0;x<2*side+1;x++){ for (y=0;y<2*side+1;y++){ temp=cvmGet(Gr,x,y); temp -= m; cvmSet(Gr,x,y,temp); } } } } void VAMToolbox::GaborFilterImage(CvMat *src, CvMat *dst, int scale, int ori) { CvMat *Gr,*Gi; Gr = cvCreateMat(m_gaborSize, m_gaborSize, CV_32FC1); Gi = cvCreateMat(m_gaborSize, m_gaborSize,CV_32FC1); MakeGaborFilter(Gr, Gi, scale, ori, m_gaborUL, m_gaborUH, m_numOfGaborScale, m_numOfOri, 1); cvFilter2D(src,dst,Gr,cvPoint(-1,-1)); //cvNormalize(dst, dst, 1, 0, CV_MINMAX, NULL); }
[ "project.yuanyu@fa59803c-33d2-c71c-52d6-55324d2fc0e3", "yyscamper@fa59803c-33d2-c71c-52d6-55324d2fc0e3" ]
[ [ [ 1, 3 ], [ 613, 613 ], [ 615, 615 ], [ 618, 618 ], [ 632, 632 ], [ 635, 636 ], [ 638, 638 ], [ 641, 642 ], [ 644, 649 ], [ 655, 656 ], [ 672, 672 ], [ 676, 676 ], [ 687, 687 ], [ 706, 706 ], [ 726, 726 ], [ 730, 731 ], [ 733, 734 ], [ 737, 738 ], [ 768, 768 ], [ 770, 770 ], [ 780, 781 ], [ 816, 822 ], [ 824, 824 ], [ 879, 879 ], [ 881, 889 ], [ 891, 891 ], [ 894, 894 ], [ 897, 903 ], [ 907, 909 ], [ 911, 913 ], [ 915, 917 ], [ 921, 921 ], [ 923, 923 ], [ 925, 927 ], [ 929, 930 ], [ 934, 934 ] ], [ [ 4, 612 ], [ 614, 614 ], [ 616, 617 ], [ 619, 631 ], [ 633, 634 ], [ 637, 637 ], [ 639, 640 ], [ 643, 643 ], [ 650, 654 ], [ 657, 671 ], [ 673, 675 ], [ 677, 686 ], [ 688, 705 ], [ 707, 725 ], [ 727, 729 ], [ 732, 732 ], [ 735, 736 ], [ 739, 767 ], [ 769, 769 ], [ 771, 779 ], [ 782, 815 ], [ 823, 823 ], [ 825, 878 ], [ 880, 880 ], [ 890, 890 ], [ 892, 893 ], [ 895, 896 ], [ 904, 906 ], [ 910, 910 ], [ 914, 914 ], [ 918, 920 ], [ 922, 922 ], [ 924, 924 ], [ 928, 928 ], [ 931, 933 ], [ 935, 936 ] ] ]
dbb759fe71e5f58f56791efb434b0629bf3eead7
6c8c4728e608a4badd88de181910a294be56953a
/SupportModules/ConsoleManager.h
c53dd1cec6f39d69c725dc297743497cc4b47dbf
[ "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
3,383
h
// For conditions of distribution and use, see copyright notice in license.txt #ifndef incl_ConsoleConsoleManager_h #define incl_ConsoleConsoleManager_h #include <Poco/Channel.h> #include <Poco/Message.h> #include "ConsoleServiceInterface.h" #include "CommandManager.h" #include "LogListenerInterface.h" namespace Foundation { class Framework; } namespace Console { class ConsoleChannel; class LogListener; typedef boost::shared_ptr<LogListener> LogListenerPtr; typedef boost::shared_ptr<ConsoleChannel> PocoLogChannelPtr; //! Generic debug console manager, directs input and output to available consoles. /*! See \ref DebugConsole "Using the debug console". */ class ConsoleManager : public Console::ConsoleServiceInterface { friend class ConsoleModule; private: ConsoleManager(); ConsoleManager(const ConsoleManager &other); //! constructor that takes a parent module ConsoleManager(Foundation::ModuleInterface *parent); public: //! destructor virtual ~ConsoleManager(); __inline virtual void Update(f64 frametime); //! Print text in parameter __inline virtual void Print(const std::string &text); //! Execute command in parameter virtual void ExecuteCommand(const std::string &command); //! Toggle console on/off virtual void ToggleConsole(); //! Sets Ui initialized/uninitialized virtual void SetUiInitialized(bool initialized); //! Returns false if UI is not initialized, true otherwise virtual bool IsUiInitialized(){return ui_initialized_;} //! Returns command manager CommandManagerPtr GetCommandManager() const {return command_manager_; } private: //Console event category event_category_id_t console_category_id_; //! command manager CommandManagerPtr command_manager_; //! parent module Foundation::ModuleInterface *parent_; //! framework Foundation::Framework* framework_; //! Custom logger to get logmessages from Pogo PocoLogChannelPtr console_channel_; //! Listener to get logs from renderer LogListenerPtr log_listener_; //! This is a buffer for messages generated before actual console UI std::vector<std::string> early_messages_; //!indicates whether the UI is initialized bool ui_initialized_; }; //! loglistener is used to listen log messages from renderer class LogListener : public Foundation::LogListenerInterface { LogListener(); public: LogListener(ConsoleManager *console) : Foundation::LogListenerInterface(), mngr_(console) {} virtual ~LogListener() {} virtual void LogMessage(const std::string &message){ if(mngr_) mngr_->Print(message); } ConsoleManager* mngr_; }; //! Class to get messages from poco logger class ConsoleChannel: public Poco::Channel { public: ConsoleChannel(ConsoleManager* mngr){ mngr_ = mngr; } void log(const Poco::Message & msg){ if (mngr_) mngr_->Print(msg.getText()); } private: ConsoleManager* mngr_; }; } #endif
[ "cmayhem@5b2332b8-efa3-11de-8684-7d64432d61a3", "jujjyl@5b2332b8-efa3-11de-8684-7d64432d61a3", "[email protected]@5b2332b8-efa3-11de-8684-7d64432d61a3", "Stinkfist0@5b2332b8-efa3-11de-8684-7d64432d61a3", "loorni@5b2332b8-efa3-11de-8684-7d64432d61a3" ]
[ [ [ 1, 5 ], [ 9, 10 ], [ 17, 19 ], [ 26, 29 ], [ 31, 37 ], [ 40, 41 ], [ 60, 64 ], [ 67, 72 ], [ 111, 115 ] ], [ [ 6, 8 ], [ 11, 16 ] ], [ [ 20, 25 ], [ 30, 30 ], [ 38, 39 ], [ 42, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 59 ], [ 65, 66 ], [ 76, 78 ], [ 80, 84 ], [ 86, 93 ], [ 95, 98 ], [ 100, 106 ], [ 109, 110 ] ], [ [ 45, 45 ], [ 48, 48 ], [ 51, 51 ], [ 79, 79 ], [ 85, 85 ], [ 94, 94 ], [ 99, 99 ], [ 107, 108 ] ], [ [ 73, 75 ] ] ]
67bbb6d3285fe2f40a1726ebde5f860f26896747
25d9a28105493df10beeb96a6c9ba63264c6975c
/sqlite/CppSQLite3.cpp
41d4495c9b072b277ddee776ef4e3861c541c874
[]
no_license
daniel-white/mountain-cms
3d3da729a1da5dc31dd3ad1a7c1a9d885476807b
6249596d41d4544f4066d4a31282f9382bf5a4da
refs/heads/master
2021-01-10T12:47:37.315587
2008-05-09T03:26:26
2008-05-09T03:26:26
55,194,179
1
0
null
null
null
null
UTF-8
C++
false
false
33,591
cpp
//////////////////////////////////////////////////////////////////////////////// // CppSQLite3 - A C++ wrapper around the SQLite3 embedded database library. // // Copyright (c) 2004 Rob Groves. All Rights Reserved. [email protected] // // Permission to use, copy, modify, and distribute this software and its // documentation for any purpose, without fee, and without a written // agreement, is hereby granted, provided that the above copyright notice, // this paragraph and the following two paragraphs appear in all copies, // modifications, and distributions. // // IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, // INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST // PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, // EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A // PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF // ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". THE AUTHOR HAS NO OBLIGATION // TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. // // V3.0 03/08/2004 -Initial Version for sqlite3 // // V3.1 16/09/2004 -Implemented getXXXXField using sqlite3 functions // -Added CppSQLiteDB3::tableExists() //////////////////////////////////////////////////////////////////////////////// #include "CppSQLite3.h" #include <cstdlib> // Named constant for passing to CppSQLite3Exception when passing it a string // that cannot be deleted. static const bool DONT_DELETE_MSG=false; //////////////////////////////////////////////////////////////////////////////// // Prototypes for SQLite functions not included in SQLite DLL, but copied below // from SQLite encode.c //////////////////////////////////////////////////////////////////////////////// int sqlite3_encode_binary(const unsigned char *in, int n, unsigned char *out); int sqlite3_decode_binary(const unsigned char *in, unsigned char *out); //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// CppSQLite3Exception::CppSQLite3Exception(const int nErrCode, char* szErrMess, bool bDeleteMsg/*=true*/) : mnErrCode(nErrCode) { mpszErrMess = sqlite3_mprintf("%s[%d]: %s", errorCodeAsString(nErrCode), nErrCode, szErrMess ? szErrMess : ""); if (bDeleteMsg && szErrMess) { sqlite3_free(szErrMess); } } CppSQLite3Exception::CppSQLite3Exception(const CppSQLite3Exception& e) : mnErrCode(e.mnErrCode) { mpszErrMess = 0; if (e.mpszErrMess) { mpszErrMess = sqlite3_mprintf("%s", e.mpszErrMess); } } const char* CppSQLite3Exception::errorCodeAsString(int nErrCode) { switch (nErrCode) { case SQLITE_OK : return "SQLITE_OK"; case SQLITE_ERROR : return "SQLITE_ERROR"; case SQLITE_INTERNAL : return "SQLITE_INTERNAL"; case SQLITE_PERM : return "SQLITE_PERM"; case SQLITE_ABORT : return "SQLITE_ABORT"; case SQLITE_BUSY : return "SQLITE_BUSY"; case SQLITE_LOCKED : return "SQLITE_LOCKED"; case SQLITE_NOMEM : return "SQLITE_NOMEM"; case SQLITE_READONLY : return "SQLITE_READONLY"; case SQLITE_INTERRUPT : return "SQLITE_INTERRUPT"; case SQLITE_IOERR : return "SQLITE_IOERR"; case SQLITE_CORRUPT : return "SQLITE_CORRUPT"; case SQLITE_NOTFOUND : return "SQLITE_NOTFOUND"; case SQLITE_FULL : return "SQLITE_FULL"; case SQLITE_CANTOPEN : return "SQLITE_CANTOPEN"; case SQLITE_PROTOCOL : return "SQLITE_PROTOCOL"; case SQLITE_EMPTY : return "SQLITE_EMPTY"; case SQLITE_SCHEMA : return "SQLITE_SCHEMA"; case SQLITE_TOOBIG : return "SQLITE_TOOBIG"; case SQLITE_CONSTRAINT : return "SQLITE_CONSTRAINT"; case SQLITE_MISMATCH : return "SQLITE_MISMATCH"; case SQLITE_MISUSE : return "SQLITE_MISUSE"; case SQLITE_NOLFS : return "SQLITE_NOLFS"; case SQLITE_AUTH : return "SQLITE_AUTH"; case SQLITE_FORMAT : return "SQLITE_FORMAT"; case SQLITE_RANGE : return "SQLITE_RANGE"; case SQLITE_ROW : return "SQLITE_ROW"; case SQLITE_DONE : return "SQLITE_DONE"; case CPPSQLITE_ERROR : return "CPPSQLITE_ERROR"; default: return "UNKNOWN_ERROR"; } } CppSQLite3Exception::~CppSQLite3Exception() throw() { if (mpszErrMess) { sqlite3_free(mpszErrMess); mpszErrMess = 0; } } //////////////////////////////////////////////////////////////////////////////// CppSQLite3Buffer::CppSQLite3Buffer() { mpBuf = 0; } CppSQLite3Buffer::~CppSQLite3Buffer() { clear(); } void CppSQLite3Buffer::clear() { if (mpBuf) { sqlite3_free(mpBuf); mpBuf = 0; } } const char* CppSQLite3Buffer::format(const char* szFormat, ...) { clear(); va_list va; va_start(va, szFormat); mpBuf = sqlite3_vmprintf(szFormat, va); va_end(va); return mpBuf; } //////////////////////////////////////////////////////////////////////////////// CppSQLite3Binary::CppSQLite3Binary() : mpBuf(0), mnBinaryLen(0), mnBufferLen(0), mnEncodedLen(0), mbEncoded(false) { } CppSQLite3Binary::~CppSQLite3Binary() { clear(); } void CppSQLite3Binary::setBinary(const unsigned char* pBuf, int nLen) { mpBuf = allocBuffer(nLen); memcpy(mpBuf, pBuf, nLen); } void CppSQLite3Binary::setEncoded(const unsigned char* pBuf) { clear(); mnEncodedLen = (int)strlen((const char*)pBuf); mnBufferLen = mnEncodedLen + 1; // Allow for NULL terminator mpBuf = (unsigned char*)malloc(mnBufferLen); if (!mpBuf) { throw CppSQLite3Exception(CPPSQLITE_ERROR, "Cannot allocate memory", DONT_DELETE_MSG); } memcpy(mpBuf, pBuf, mnBufferLen); mbEncoded = true; } const unsigned char* CppSQLite3Binary::getEncoded() { if (!mbEncoded) { unsigned char* ptmp = (unsigned char*)malloc(mnBinaryLen); memcpy(ptmp, mpBuf, mnBinaryLen); mnEncodedLen = sqlite3_encode_binary(ptmp, mnBinaryLen, mpBuf); free(ptmp); mbEncoded = true; } return mpBuf; } const unsigned char* CppSQLite3Binary::getBinary() { if (mbEncoded) { // in/out buffers can be the same mnBinaryLen = sqlite3_decode_binary(mpBuf, mpBuf); if (mnBinaryLen == -1) { throw CppSQLite3Exception(CPPSQLITE_ERROR, "Cannot decode binary", DONT_DELETE_MSG); } mbEncoded = false; } return mpBuf; } int CppSQLite3Binary::getBinaryLength() { getBinary(); return mnBinaryLen; } unsigned char* CppSQLite3Binary::allocBuffer(int nLen) { clear(); // Allow extra space for encoded binary as per comments in // SQLite encode.c See bottom of this file for implementation // of SQLite functions use 3 instead of 2 just to be sure ;-) mnBinaryLen = nLen; mnBufferLen = 3 + (257*nLen)/254; mpBuf = (unsigned char*)malloc(mnBufferLen); if (!mpBuf) { throw CppSQLite3Exception(CPPSQLITE_ERROR, "Cannot allocate memory", DONT_DELETE_MSG); } mbEncoded = false; return mpBuf; } void CppSQLite3Binary::clear() { if (mpBuf) { mnBinaryLen = 0; mnBufferLen = 0; free(mpBuf); mpBuf = 0; } } //////////////////////////////////////////////////////////////////////////////// CppSQLite3Query::CppSQLite3Query() { mpVM = 0; mbEof = true; mnCols = 0; mbOwnVM = false; } CppSQLite3Query::CppSQLite3Query(const CppSQLite3Query& rQuery) { mpVM = rQuery.mpVM; // Only one object can own the VM const_cast<CppSQLite3Query&>(rQuery).mpVM = 0; mbEof = rQuery.mbEof; mnCols = rQuery.mnCols; mbOwnVM = rQuery.mbOwnVM; } CppSQLite3Query::CppSQLite3Query(sqlite3* pDB, sqlite3_stmt* pVM, bool bEof, bool bOwnVM/*=true*/) { mpDB = pDB; mpVM = pVM; mbEof = bEof; mnCols = sqlite3_column_count(mpVM); mbOwnVM = bOwnVM; } CppSQLite3Query::~CppSQLite3Query() { try { finalize(); } catch (...) { } } CppSQLite3Query& CppSQLite3Query::operator=(const CppSQLite3Query& rQuery) { try { finalize(); } catch (...) { } mpVM = rQuery.mpVM; // Only one object can own the VM const_cast<CppSQLite3Query&>(rQuery).mpVM = 0; mbEof = rQuery.mbEof; mnCols = rQuery.mnCols; mbOwnVM = rQuery.mbOwnVM; return *this; } int CppSQLite3Query::numFields() { checkVM(); return mnCols; } const char* CppSQLite3Query::fieldValue(int nField) { checkVM(); if (nField < 0 || nField > mnCols-1) { throw CppSQLite3Exception(CPPSQLITE_ERROR, "Invalid field index requested", DONT_DELETE_MSG); } return (const char*)sqlite3_column_text(mpVM, nField); } const char* CppSQLite3Query::fieldValue(const char* szField) { int nField = fieldIndex(szField); return (const char*)sqlite3_column_text(mpVM, nField); } int CppSQLite3Query::getIntField(int nField, int nNullValue/*=0*/) { if (fieldDataType(nField) == SQLITE_NULL) { return nNullValue; } else { return sqlite3_column_int(mpVM, nField); } } int CppSQLite3Query::getIntField(const char* szField, int nNullValue/*=0*/) { int nField = fieldIndex(szField); return getIntField(nField, nNullValue); } double CppSQLite3Query::getFloatField(int nField, double fNullValue/*=0.0*/) { if (fieldDataType(nField) == SQLITE_NULL) { return fNullValue; } else { return sqlite3_column_double(mpVM, nField); } } double CppSQLite3Query::getFloatField(const char* szField, double fNullValue/*=0.0*/) { int nField = fieldIndex(szField); return getFloatField(nField, fNullValue); } const char* CppSQLite3Query::getStringField(int nField, const char* szNullValue/*=""*/) { if (fieldDataType(nField) == SQLITE_NULL) { return szNullValue; } else { return (const char*)sqlite3_column_text(mpVM, nField); } } const char* CppSQLite3Query::getStringField(const char* szField, const char* szNullValue/*=""*/) { int nField = fieldIndex(szField); return getStringField(nField, szNullValue); } const unsigned char* CppSQLite3Query::getBlobField(int nField, int& nLen) { checkVM(); if (nField < 0 || nField > mnCols-1) { throw CppSQLite3Exception(CPPSQLITE_ERROR, "Invalid field index requested", DONT_DELETE_MSG); } nLen = sqlite3_column_bytes(mpVM, nField); return (const unsigned char*)sqlite3_column_blob(mpVM, nField); } const unsigned char* CppSQLite3Query::getBlobField(const char* szField, int& nLen) { int nField = fieldIndex(szField); return getBlobField(nField, nLen); } bool CppSQLite3Query::fieldIsNull(int nField) { return (fieldDataType(nField) == SQLITE_NULL); } bool CppSQLite3Query::fieldIsNull(const char* szField) { int nField = fieldIndex(szField); return (fieldDataType(nField) == SQLITE_NULL); } int CppSQLite3Query::fieldIndex(const char* szField) { checkVM(); if (szField) { for (int nField = 0; nField < mnCols; nField++) { const char* szTemp = sqlite3_column_name(mpVM, nField); if (strcmp(szField, szTemp) == 0) { return nField; } } } throw CppSQLite3Exception(CPPSQLITE_ERROR, "Invalid field name requested", DONT_DELETE_MSG); } const char* CppSQLite3Query::fieldName(int nCol) { checkVM(); if (nCol < 0 || nCol > mnCols-1) { throw CppSQLite3Exception(CPPSQLITE_ERROR, "Invalid field index requested", DONT_DELETE_MSG); } return sqlite3_column_name(mpVM, nCol); } const char* CppSQLite3Query::fieldDeclType(int nCol) { checkVM(); if (nCol < 0 || nCol > mnCols-1) { throw CppSQLite3Exception(CPPSQLITE_ERROR, "Invalid field index requested", DONT_DELETE_MSG); } return sqlite3_column_decltype(mpVM, nCol); } int CppSQLite3Query::fieldDataType(int nCol) { checkVM(); if (nCol < 0 || nCol > mnCols-1) { throw CppSQLite3Exception(CPPSQLITE_ERROR, "Invalid field index requested", DONT_DELETE_MSG); } return sqlite3_column_type(mpVM, nCol); } bool CppSQLite3Query::eof() { checkVM(); return mbEof; } void CppSQLite3Query::nextRow() { checkVM(); int nRet = sqlite3_step(mpVM); if (nRet == SQLITE_DONE) { // no rows mbEof = true; } else if (nRet == SQLITE_ROW) { // more rows, nothing to do } else { nRet = sqlite3_finalize(mpVM); mpVM = 0; const char* szError = sqlite3_errmsg(mpDB); throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG); } } void CppSQLite3Query::finalize() { if (mpVM && mbOwnVM) { int nRet = sqlite3_finalize(mpVM); mpVM = 0; if (nRet != SQLITE_OK) { const char* szError = sqlite3_errmsg(mpDB); throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG); } } } void CppSQLite3Query::checkVM() { if (mpVM == 0) { throw CppSQLite3Exception(CPPSQLITE_ERROR, "Null Virtual Machine pointer", DONT_DELETE_MSG); } } //////////////////////////////////////////////////////////////////////////////// CppSQLite3Table::CppSQLite3Table() { mpaszResults = 0; mnRows = 0; mnCols = 0; mnCurrentRow = 0; } CppSQLite3Table::CppSQLite3Table(const CppSQLite3Table& rTable) { mpaszResults = rTable.mpaszResults; // Only one object can own the results const_cast<CppSQLite3Table&>(rTable).mpaszResults = 0; mnRows = rTable.mnRows; mnCols = rTable.mnCols; mnCurrentRow = rTable.mnCurrentRow; } CppSQLite3Table::CppSQLite3Table(char** paszResults, int nRows, int nCols) { mpaszResults = paszResults; mnRows = nRows; mnCols = nCols; mnCurrentRow = 0; } CppSQLite3Table::~CppSQLite3Table() { try { finalize(); } catch (...) { } } CppSQLite3Table& CppSQLite3Table::operator=(const CppSQLite3Table& rTable) { try { finalize(); } catch (...) { } mpaszResults = rTable.mpaszResults; // Only one object can own the results const_cast<CppSQLite3Table&>(rTable).mpaszResults = 0; mnRows = rTable.mnRows; mnCols = rTable.mnCols; mnCurrentRow = rTable.mnCurrentRow; return *this; } void CppSQLite3Table::finalize() { if (mpaszResults) { sqlite3_free_table(mpaszResults); mpaszResults = 0; } } int CppSQLite3Table::numFields() { checkResults(); return mnCols; } int CppSQLite3Table::numRows() { checkResults(); return mnRows; } const char* CppSQLite3Table::fieldValue(int nField) { checkResults(); if (nField < 0 || nField > mnCols-1) { throw CppSQLite3Exception(CPPSQLITE_ERROR, "Invalid field index requested", DONT_DELETE_MSG); } int nIndex = (mnCurrentRow*mnCols) + mnCols + nField; return mpaszResults[nIndex]; } const char* CppSQLite3Table::fieldValue(const char* szField) { checkResults(); if (szField) { for (int nField = 0; nField < mnCols; nField++) { if (strcmp(szField, mpaszResults[nField]) == 0) { int nIndex = (mnCurrentRow*mnCols) + mnCols + nField; return mpaszResults[nIndex]; } } } throw CppSQLite3Exception(CPPSQLITE_ERROR, "Invalid field name requested", DONT_DELETE_MSG); } int CppSQLite3Table::getIntField(int nField, int nNullValue/*=0*/) { if (fieldIsNull(nField)) { return nNullValue; } else { return atoi(fieldValue(nField)); } } int CppSQLite3Table::getIntField(const char* szField, int nNullValue/*=0*/) { if (fieldIsNull(szField)) { return nNullValue; } else { return atoi(fieldValue(szField)); } } double CppSQLite3Table::getFloatField(int nField, double fNullValue/*=0.0*/) { if (fieldIsNull(nField)) { return fNullValue; } else { return atof(fieldValue(nField)); } } double CppSQLite3Table::getFloatField(const char* szField, double fNullValue/*=0.0*/) { if (fieldIsNull(szField)) { return fNullValue; } else { return atof(fieldValue(szField)); } } const char* CppSQLite3Table::getStringField(int nField, const char* szNullValue/*=""*/) { if (fieldIsNull(nField)) { return szNullValue; } else { return fieldValue(nField); } } const char* CppSQLite3Table::getStringField(const char* szField, const char* szNullValue/*=""*/) { if (fieldIsNull(szField)) { return szNullValue; } else { return fieldValue(szField); } } bool CppSQLite3Table::fieldIsNull(int nField) { checkResults(); return (fieldValue(nField) == 0); } bool CppSQLite3Table::fieldIsNull(const char* szField) { checkResults(); return (fieldValue(szField) == 0); } const char* CppSQLite3Table::fieldName(int nCol) { checkResults(); if (nCol < 0 || nCol > mnCols-1) { throw CppSQLite3Exception(CPPSQLITE_ERROR, "Invalid field index requested", DONT_DELETE_MSG); } return mpaszResults[nCol]; } void CppSQLite3Table::setRow(int nRow) { checkResults(); if (nRow < 0 || nRow > mnRows-1) { throw CppSQLite3Exception(CPPSQLITE_ERROR, "Invalid row index requested", DONT_DELETE_MSG); } mnCurrentRow = nRow; } void CppSQLite3Table::checkResults() { if (mpaszResults == 0) { throw CppSQLite3Exception(CPPSQLITE_ERROR, "Null Results pointer", DONT_DELETE_MSG); } } //////////////////////////////////////////////////////////////////////////////// CppSQLite3Statement::CppSQLite3Statement() { mpDB = 0; mpVM = 0; } CppSQLite3Statement::CppSQLite3Statement(const CppSQLite3Statement& rStatement) { mpDB = rStatement.mpDB; mpVM = rStatement.mpVM; // Only one object can own VM const_cast<CppSQLite3Statement&>(rStatement).mpVM = 0; } CppSQLite3Statement::CppSQLite3Statement(sqlite3* pDB, sqlite3_stmt* pVM) { mpDB = pDB; mpVM = pVM; } CppSQLite3Statement::~CppSQLite3Statement() { try { finalize(); } catch (...) { } } CppSQLite3Statement& CppSQLite3Statement::operator=(const CppSQLite3Statement& rStatement) { mpDB = rStatement.mpDB; mpVM = rStatement.mpVM; // Only one object can own VM const_cast<CppSQLite3Statement&>(rStatement).mpVM = 0; return *this; } int CppSQLite3Statement::execDML() { checkDB(); checkVM(); const char* szError=0; int nRet = sqlite3_step(mpVM); if (nRet == SQLITE_DONE) { int nRowsChanged = sqlite3_changes(mpDB); nRet = sqlite3_reset(mpVM); if (nRet != SQLITE_OK) { szError = sqlite3_errmsg(mpDB); throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG); } return nRowsChanged; } else { nRet = sqlite3_reset(mpVM); szError = sqlite3_errmsg(mpDB); throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG); } } CppSQLite3Query CppSQLite3Statement::execQuery() { checkDB(); checkVM(); int nRet = sqlite3_step(mpVM); if (nRet == SQLITE_DONE) { // no rows return CppSQLite3Query(mpDB, mpVM, true/*eof*/, false); } else if (nRet == SQLITE_ROW) { // at least 1 row return CppSQLite3Query(mpDB, mpVM, false/*eof*/, false); } else { nRet = sqlite3_reset(mpVM); const char* szError = sqlite3_errmsg(mpDB); throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG); } } void CppSQLite3Statement::bind(int nParam, const char* szValue) { checkVM(); int nRes = sqlite3_bind_text(mpVM, nParam, szValue, -1, SQLITE_TRANSIENT); if (nRes != SQLITE_OK) { throw CppSQLite3Exception(nRes, "Error binding string param", DONT_DELETE_MSG); } } void CppSQLite3Statement::bind(int nParam, const int nValue) { checkVM(); int nRes = sqlite3_bind_int(mpVM, nParam, nValue); if (nRes != SQLITE_OK) { throw CppSQLite3Exception(nRes, "Error binding int param", DONT_DELETE_MSG); } } void CppSQLite3Statement::bind(int nParam, const double dValue) { checkVM(); int nRes = sqlite3_bind_double(mpVM, nParam, dValue); if (nRes != SQLITE_OK) { throw CppSQLite3Exception(nRes, "Error binding double param", DONT_DELETE_MSG); } } void CppSQLite3Statement::bind(int nParam, const unsigned char* blobValue, int nLen) { checkVM(); int nRes = sqlite3_bind_blob(mpVM, nParam, (const void*)blobValue, nLen, SQLITE_TRANSIENT); if (nRes != SQLITE_OK) { throw CppSQLite3Exception(nRes, "Error binding blob param", DONT_DELETE_MSG); } } void CppSQLite3Statement::bindNull(int nParam) { checkVM(); int nRes = sqlite3_bind_null(mpVM, nParam); if (nRes != SQLITE_OK) { throw CppSQLite3Exception(nRes, "Error binding NULL param", DONT_DELETE_MSG); } } int CppSQLite3Statement::getColumnCount() { checkVM(); return sqlite3_column_count(mpVM); } const char* CppSQLite3Statement::getColumnName(int nColumn) { checkVM(); return sqlite3_column_name(mpVM, nColumn); } const char* CppSQLite3Statement::getColumnType(int nColumn) { checkVM(); return sqlite3_column_decltype(mpVM, nColumn); } void CppSQLite3Statement::reset() { if (mpVM) { int nRet = sqlite3_reset(mpVM); if (nRet != SQLITE_OK) { const char* szError = sqlite3_errmsg(mpDB); throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG); } } } void CppSQLite3Statement::finalize() { if (mpVM) { int nRet = sqlite3_finalize(mpVM); mpVM = 0; if (nRet != SQLITE_OK) { const char* szError = sqlite3_errmsg(mpDB); throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG); } } } void CppSQLite3Statement::checkDB() { if (mpDB == 0) { throw CppSQLite3Exception(CPPSQLITE_ERROR, "Database not open", DONT_DELETE_MSG); } } void CppSQLite3Statement::checkVM() { if (mpVM == 0) { throw CppSQLite3Exception(CPPSQLITE_ERROR, "Null Virtual Machine pointer", DONT_DELETE_MSG); } } //////////////////////////////////////////////////////////////////////////////// CppSQLite3DB::CppSQLite3DB() { mpDB = 0; mnBusyTimeoutMs = 60000; // 60 seconds } CppSQLite3DB::CppSQLite3DB(const CppSQLite3DB& db) { mpDB = db.mpDB; mnBusyTimeoutMs = 60000; // 60 seconds } CppSQLite3DB::~CppSQLite3DB() { close(); } CppSQLite3DB& CppSQLite3DB::operator=(const CppSQLite3DB& db) { mpDB = db.mpDB; mnBusyTimeoutMs = 60000; // 60 seconds return *this; } void CppSQLite3DB::open(const char* szFile) { int nRet = sqlite3_open(szFile, &mpDB); if (nRet != SQLITE_OK) { const char* szError = sqlite3_errmsg(mpDB); throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG); } setBusyTimeout(mnBusyTimeoutMs); } void CppSQLite3DB::close() { if (mpDB) { sqlite3_close(mpDB); mpDB = 0; } } CppSQLite3Statement CppSQLite3DB::compileStatement(const char* szSQL) { checkDB(); sqlite3_stmt* pVM = compile(szSQL); return CppSQLite3Statement(mpDB, pVM); } bool CppSQLite3DB::tableExists(const char* szTable) { char szSQL[128]; sprintf(szSQL, "select count(*) from sqlite_master where type='table' and name='%s'", szTable); int nRet = execScalar(szSQL); return (nRet > 0); } int CppSQLite3DB::execDML(const char* szSQL) { checkDB(); char* szError=0; int nRet = sqlite3_exec(mpDB, szSQL, 0, 0, &szError); if (nRet == SQLITE_OK) { return sqlite3_changes(mpDB); } else { throw CppSQLite3Exception(nRet, szError); } } CppSQLite3Query CppSQLite3DB::execQuery(const char* szSQL) { checkDB(); sqlite3_stmt* pVM = compile(szSQL); int nRet = sqlite3_step(pVM); if (nRet == SQLITE_DONE) { // no rows return CppSQLite3Query(mpDB, pVM, true/*eof*/); } else if (nRet == SQLITE_ROW) { // at least 1 row return CppSQLite3Query(mpDB, pVM, false/*eof*/); } else { nRet = sqlite3_finalize(pVM); const char* szError= sqlite3_errmsg(mpDB); throw CppSQLite3Exception(nRet, (char*)szError, DONT_DELETE_MSG); } } int CppSQLite3DB::execScalar(const char* szSQL) { CppSQLite3Query q = execQuery(szSQL); if (q.eof() || q.numFields() < 1) { throw CppSQLite3Exception(CPPSQLITE_ERROR, "Invalid scalar query", DONT_DELETE_MSG); } return atoi(q.fieldValue(0)); } CppSQLite3Table CppSQLite3DB::getTable(const char* szSQL) { checkDB(); char* szError=0; char** paszResults=0; int nRet; int nRows(0); int nCols(0); nRet = sqlite3_get_table(mpDB, szSQL, &paszResults, &nRows, &nCols, &szError); if (nRet == SQLITE_OK) { return CppSQLite3Table(paszResults, nRows, nCols); } else { throw CppSQLite3Exception(nRet, szError); } } sqlite_int64 CppSQLite3DB::lastRowId() { return sqlite3_last_insert_rowid(mpDB); } void CppSQLite3DB::setBusyTimeout(int nMillisecs) { mnBusyTimeoutMs = nMillisecs; sqlite3_busy_timeout(mpDB, mnBusyTimeoutMs); } void CppSQLite3DB::checkDB() { if (!mpDB) { throw CppSQLite3Exception(CPPSQLITE_ERROR, "Database not open", DONT_DELETE_MSG); } } sqlite3_stmt* CppSQLite3DB::compile(const char* szSQL) { checkDB(); char* szError=0; const char* szTail=0; sqlite3_stmt* pVM; int nRet = sqlite3_prepare(mpDB, szSQL, -1, &pVM, &szTail); if (nRet != SQLITE_OK) { throw CppSQLite3Exception(nRet, szError); } return pVM; } //////////////////////////////////////////////////////////////////////////////// // SQLite encode.c reproduced here, containing implementation notes and source // for sqlite3_encode_binary() and sqlite3_decode_binary() //////////////////////////////////////////////////////////////////////////////// /* ** 2002 April 25 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains helper routines used to translate binary data into ** a null-terminated string (suitable for use in SQLite) and back again. ** These are convenience routines for use by people who want to store binary ** data in an SQLite database. The code in this file is not used by any other ** part of the SQLite library. ** ** $Id: encode.c,v 1.10 2004/01/14 21:59:23 drh Exp $ */ /* ** How This Encoder Works ** ** The output is allowed to contain any character except 0x27 (') and ** 0x00. This is accomplished by using an escape character to encode ** 0x27 and 0x00 as a two-byte sequence. The escape character is always ** 0x01. An 0x00 is encoded as the two byte sequence 0x01 0x01. The ** 0x27 character is encoded as the two byte sequence 0x01 0x03. Finally, ** the escape character itself is encoded as the two-character sequence ** 0x01 0x02. ** ** To summarize, the encoder works by using an escape sequences as follows: ** ** 0x00 -> 0x01 0x01 ** 0x01 -> 0x01 0x02 ** 0x27 -> 0x01 0x03 ** ** If that were all the encoder did, it would work, but in certain cases ** it could double the size of the encoded string. For example, to ** encode a string of 100 0x27 characters would require 100 instances of ** the 0x01 0x03 escape sequence resulting in a 200-character output. ** We would prefer to keep the size of the encoded string smaller than ** this. ** ** To minimize the encoding size, we first add a fixed offset value to each ** byte in the sequence. The addition is modulo 256. (That is to say, if ** the sum of the original character value and the offset exceeds 256, then ** the higher order bits are truncated.) The offset is chosen to minimize ** the number of characters in the string that need to be escaped. For ** example, in the case above where the string was composed of 100 0x27 ** characters, the offset might be 0x01. Each of the 0x27 characters would ** then be converted into an 0x28 character which would not need to be ** escaped at all and so the 100 character input string would be converted ** into just 100 characters of output. Actually 101 characters of output - ** we have to record the offset used as the first byte in the sequence so ** that the string can be decoded. Since the offset value is stored as ** part of the output string and the output string is not allowed to contain ** characters 0x00 or 0x27, the offset cannot be 0x00 or 0x27. ** ** Here, then, are the encoding steps: ** ** (1) Choose an offset value and make it the first character of ** output. ** ** (2) Copy each input character into the output buffer, one by ** one, adding the offset value as you copy. ** ** (3) If the value of an input character plus offset is 0x00, replace ** that one character by the two-character sequence 0x01 0x01. ** If the sum is 0x01, replace it with 0x01 0x02. If the sum ** is 0x27, replace it with 0x01 0x03. ** ** (4) Put a 0x00 terminator at the end of the output. ** ** Decoding is obvious: ** ** (5) Copy encoded characters except the first into the decode ** buffer. Set the first encoded character aside for use as ** the offset in step 7 below. ** ** (6) Convert each 0x01 0x01 sequence into a single character 0x00. ** Convert 0x01 0x02 into 0x01. Convert 0x01 0x03 into 0x27. ** ** (7) Subtract the offset value that was the first character of ** the encoded buffer from all characters in the output buffer. ** ** The only tricky part is step (1) - how to compute an offset value to ** minimize the size of the output buffer. This is accomplished by testing ** all offset values and picking the one that results in the fewest number ** of escapes. To do that, we first scan the entire input and count the ** number of occurances of each character value in the input. Suppose ** the number of 0x00 characters is N(0), the number of occurances of 0x01 ** is N(1), and so forth up to the number of occurances of 0xff is N(255). ** An offset of 0 is not allowed so we don't have to test it. The number ** of escapes required for an offset of 1 is N(1)+N(2)+N(40). The number ** of escapes required for an offset of 2 is N(2)+N(3)+N(41). And so forth. ** In this way we find the offset that gives the minimum number of escapes, ** and thus minimizes the length of the output string. */ /* ** Encode a binary buffer "in" of size n bytes so that it contains ** no instances of characters '\'' or '\000'. The output is ** null-terminated and can be used as a string value in an INSERT ** or UPDATE statement. Use sqlite3_decode_binary() to convert the ** string back into its original binary. ** ** The result is written into a preallocated output buffer "out". ** "out" must be able to hold at least 2 +(257*n)/254 bytes. ** In other words, the output will be expanded by as much as 3 ** bytes for every 254 bytes of input plus 2 bytes of fixed overhead. ** (This is approximately 2 + 1.0118*n or about a 1.2% size increase.) ** ** The return value is the number of characters in the encoded ** string, excluding the "\000" terminator. */ int sqlite3_encode_binary(const unsigned char *in, int n, unsigned char *out){ int i, j, e, m; int cnt[256]; if( n<=0 ){ out[0] = 'x'; out[1] = 0; return 1; } memset(cnt, 0, sizeof(cnt)); for(i=n-1; i>=0; i--){ cnt[in[i]]++; } m = n; for(i=1; i<256; i++){ int sum; if( i=='\'' ) continue; sum = cnt[i] + cnt[(i+1)&0xff] + cnt[(i+'\'')&0xff]; if( sum<m ){ m = sum; e = i; if( m==0 ) break; } } out[0] = e; j = 1; for(i=0; i<n; i++){ int c = (in[i] - e)&0xff; if( c==0 ){ out[j++] = 1; out[j++] = 1; }else if( c==1 ){ out[j++] = 1; out[j++] = 2; }else if( c=='\'' ){ out[j++] = 1; out[j++] = 3; }else{ out[j++] = c; } } out[j] = 0; return j; } /* ** Decode the string "in" into binary data and write it into "out". ** This routine reverses the encoding created by sqlite3_encode_binary(). ** The output will always be a few bytes less than the input. The number ** of bytes of output is returned. If the input is not a well-formed ** encoding, -1 is returned. ** ** The "in" and "out" parameters may point to the same buffer in order ** to decode a string in place. */ int sqlite3_decode_binary(const unsigned char *in, unsigned char *out){ int i, c, e; e = *(in++); i = 0; while( (c = *(in++))!=0 ){ if( c==1 ){ c = *(in++); if( c==1 ){ c = 0; }else if( c==2 ){ c = 1; }else if( c==3 ){ c = '\''; }else{ return -1; } } out[i++] = (c + e)&0xff; } return i; }
[ "thetrueaplus@a6c76449-3c4b-0410-9e40-efb2f4630036" ]
[ [ [ 1, 1500 ] ] ]
005fc7781d921c9effc76556a86ebef9a246e811
36d0ddb69764f39c440089ecebd10d7df14f75f3
/プログラム/Ngllib/src/Line3.cpp
784dee6e4299090fa168772c0a4aec437f66c7d7
[]
no_license
weimingtom/tanuki-mo-issyo
3f57518b4e59f684db642bf064a30fc5cc4715b3
ab57362f3228354179927f58b14fa76b3d334472
refs/heads/master
2021-01-10T01:36:32.162752
2009-04-19T10:37:37
2009-04-19T10:37:37
48,733,344
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
5,262
cpp
/*******************************************************************************/ /** * @file Line3.cpp. * * @brief 3次元線分構造体ソースファイル. * * @date 2008/07/12. * * @version 2.00. * * @author Kentarou Nishimura. */ /******************************************************************************/ #include "Ngl/Line3.h" #include "Ngl/Collision.h" #include "Ngl/Vector3.h" #include "Ngl/MathUtility.h" #include <cfloat> using namespace Ngl; /*=========================================================================*/ /** * @brief コンストラクタ * * @param[in] なし. */ Line3::Line3() {} /*=========================================================================*/ /** * @brief コンストラクタ * * @param[in] Begin 開始位置3D座標. * @param[in] End 終了位置3D座標. */ Line3::Line3( const Vector3& Begin, const Vector3& End ): begin( Begin ), end( End ) {} /*=========================================================================*/ /** * @brief コンストラクタ * * @param[in] Begin 開始位置座標配列. * @param[in] End 終了位置座標配列. */ Line3::Line3( const float* Begin, const float* End ) { begin.initialize( Begin[ 0 ], Begin[ 1 ], Begin[ 2 ] ); end.initialize( End[ 0 ], End[ 1 ], End[ 2 ] ); } /*=========================================================================*/ /** * @brief 初期化する * * @param[in] x 始点x座標. * @param[in] y 始点y座標. * @param[in] z 始点z座標. * @param[in] eX 終点x座標. * @param[in] eY 終点y座標. * @param[in] eZ 終点z座標. * @return なし. */ void Line3::initialize( float x, float y, float z, float eX, float eY, float eZ ) { begin.initialize( x, y, z ); end.initialize( eX, eY, eZ ); } /*=========================================================================*/ /** * @brief 初期化する * * @param[in] Begin 開始位置3D座標. * @param[in] End 終了位置3D座標. * @return なし. */ void Line3::initialize( const Vector3& Begin, const Vector3& End ) { begin = Begin; end = End; } /*=========================================================================*/ /** * @brief 線分のベクトルを求める * * @param[in] なし. * @return 線分のベクトル. */ Vector3 Line3::getVector() { Vector3 result = begin - end; return result; } /*=========================================================================*/ /** * @brief 3D線分との衝突判定 * * @param[in] otherBegin 判定する3D線分の始点座標. * @param[in] otherEnd 判定する3D線分の終点座標. * @param[in] epsilon 判定の閾値. * @return 衝突判定結果構造体. */ const LineCollisionReport& Line3::collision( const Vector3& otherBegin, const Vector3& otherEnd, float epsilon ) { Collision collision; return collision.lineAndLine( begin, end, otherBegin, otherEnd, false, epsilon ); } /*=========================================================================*/ /** * @brief 3D線分との衝突判定 * * @param[in] other 判定する3D線分. * @param[in] epsilon 判定の閾値. * @return 衝突判定結果構造体. */ const LineCollisionReport& Line3::collision( const Line3& other, float epsilon ) { return collision( other.begin, other.end, epsilon ); } /*=========================================================================*/ /** * @brief 線分と、指定座標の最も隣接する線分上の座標パラメータを求める * * @param[in] x, 求める座標のx座標. * @param[in] y, 求める座標のy座標. * @param[in] z, 求める座標のz座標. * @return 座標パラメータ. */ float Line3::getNearestPointParameter( float x, float y, float z ) { // 線分のベクトルを求める Vector3 vec = getVector(); // ベクトルの長さを求める float length = vec.lengthSq(); // 線分の長さが閾値よりも小さいか if( length < FLT_EPSILON ){ return 0.0f; } // 線分の始点から指定座標へのベクトルを求める Vector3 point( x, y, z ); Vector3 lp = point - begin; // 調べたい座標に最も近い座標へのパラメータを求める float t = vec.dot( lp ) / length; // パラメータをクランプ return clamp( t, 0.0f, 1.0f ); } /*=========================================================================*/ /** * @brief 線分と、指定座標に最も隣接する線分上の座標を求める * * @param[in] x, 求める座標のx座標. * @param[in] y, 求める座標のy座標. * @param[in] z, 求める座標のz座標. * @return 最も隣接する座標. */ Vector3 Line3::findNearestPoint( float x, float y, float z ) { // 最も近い座標へのパラメータを求める float t = getNearestPointParameter( x, y, z ); // 求めたパラメータから最も近い座標を求める Vector3 result; result.linearEquation( begin, getVector(), t ); return result; } /*===== EOF ==================================================================*/
[ "rs.drip@aa49b5b2-a402-11dd-98aa-2b35b7097d33" ]
[ [ [ 1, 203 ] ] ]
f818be8b67161e28ff06f2798859b24bf0a62cea
ddc9569f4950c83f98000a01dff485aa8fa67920
/naikai/test/src/nkTest.cpp
01ed984745acedc371fad9c2e40806289ab9184b
[]
no_license
chadaustin/naikai
0a291ddabe725504cdd80c6e2c7ccb85dc5109da
83b590b049a7e8a62faca2b0ca1d7d33e2013301
refs/heads/master
2021-01-10T13:28:48.743787
2003-02-19T19:56:24
2003-02-19T19:56:24
36,420,940
0
0
null
null
null
null
UTF-8
C++
false
false
2,704
cpp
#include <stdio.h> #include <stdlib.h> #include "nsCOMPtr.h" #include "nsIGenericFactory.h" #include "nsIServiceManagerUtils.h" #include "nsLiteralString.h" #include "nsString2.h" #include "nkIRenderer.h" #include "nkIRunnable.h" #include "nkIWindow.h" #include "nkIWindowingService.h" class ExitCommand : public nkICommand { public: ExitCommand() { NS_INIT_REFCNT(); } NS_DECL_ISUPPORTS NS_DECL_NKICOMMAND }; NS_IMPL_ISUPPORTS1(ExitCommand, nkICommand) NS_IMETHODIMP ExitCommand::Execute(nsISupports* /*caller*/) { exit(0); return NS_OK; } // 028baccc-1dd2-11b2-b297-9e0223120227 #define NK_TEST_CID \ { 0x028baccc, 0x1dd2, 0x11b2, \ { 0xb2, 0x97, 0x9e, 0x02, 0x23, 0x12, 0x02, 0x27 } } #define NK_TEST_CONTRACTID "@naikai.aegisknight.org/test;1" class Runnable : public nkIRunnable { public: Runnable(); NS_DECL_ISUPPORTS NS_DECL_NKIRUNNABLE }; Runnable::Runnable() { NS_INIT_REFCNT(); } NS_IMPL_ISUPPORTS1(Runnable, nkIRunnable) NS_IMETHODIMP Runnable::Run() { nsresult rv; nsCOMPtr<nkIWindowingService> ws = do_GetService("@naikai.aegisknight.org/windowing;1", &rv); if (!ws) { return NS_ERROR_FAILURE; } // create window nsCOMPtr<nkIWindow> window; rv = ws->CreateFrameWindow(getter_AddRefs(window)); if (!window || NS_FAILED(rv)) { return NS_ERROR_FAILURE; } // create menu nsCOMPtr<nkIMenu> menu; rv = ws->CreateMenu(getter_AddRefs(menu)); if (!menu || NS_FAILED(rv)) { return NS_ERROR_FAILURE; } nsCOMPtr<nkIMenu> submenu; rv = ws->CreateMenu(getter_AddRefs(submenu)); if (!submenu || NS_FAILED(rv)) { return NS_ERROR_FAILURE; } submenu->AppendItem(NS_LITERAL_STRING("New").get(), NULL); submenu->AppendSeparator(); nsCOMPtr<nkICommand> ec(new ExitCommand()); submenu->AppendItem(NS_LITERAL_STRING("Exit").get(), ec); menu->AppendSubMenu(NS_LITERAL_STRING("Game").get(), submenu); rv = window->SetMenu(menu); if (NS_FAILED(rv)) { return NS_ERROR_FAILURE; } // create renderer nsCOMPtr<nkIRenderer> renderer( do_CreateInstance("@naikai.aegisknight.org/renderer;1", &rv)); if (!renderer) { return NS_ERROR_FAILURE; } rv = renderer->Attach(window); if (NS_FAILED(rv)) { return NS_ERROR_FAILURE; } return ws->Run(); } NS_GENERIC_FACTORY_CONSTRUCTOR(Runnable); static nsModuleComponentInfo components[] = { { "Naikai Test Component", NK_TEST_CID, NK_TEST_CONTRACTID, RunnableConstructor, NULL, NULL, NULL, NULL, NULL, NULL, } }; NS_IMPL_NSGETMODULE(nkTestModule, components)
[ "aegis@ed5ae262-7be1-47e3-824f-6ab8bb33c1ce" ]
[ [ [ 1, 139 ] ] ]
9a8cdb3b380623095b074a8bde3310de5d9d6b21
8d466583574663248d9197c83d490f8de6914f01
/George.Koshelev/task5/Stack.h
876e1f46d992d8c140bd3bd6f9663b4c6a1b32e9
[]
no_license
andrey-malets/usuoop
186b421080d7ff1fbaed2b230f2f2c77eb081138
5ae5876f3622ab8a4598a67a414d544c4d6a7bcb
refs/heads/master
2021-01-25T10:15:48.239369
2011-06-18T08:03:42
2011-06-18T08:03:42
32,697,629
0
0
null
null
null
null
UTF-8
C++
false
false
1,198
h
template <class T,int pol> class Stack{ private: int maxValue; T *currentPointer; int currentValue; int policy; MemoryManager<T,pol> manager; public: Stack(){ policy = pol; currentPointer = 0; currentValue = 0; maxValue = 0; } ~Stack(){}; void push(T pushValue){ if (isEmpty()){ currentPointer = manager.giveEmptyMemory(); currentPointer[currentValue] = pushValue; currentValue++; maxValue = policy; } else{ if (currentValue==maxValue){ currentPointer = manager.increaseMaxSize(currentPointer,maxValue); currentPointer[currentValue] = pushValue; maxValue*=policy; currentValue++; } else{ currentPointer[currentValue] = pushValue; currentValue++; } } } T pop(){ if (currentValue==0){ throw "Stack is empty\n"; } if (maxValue == currentValue*policy){ currentPointer = manager.decreaseMaxSize(currentPointer,currentValue); maxValue = currentValue; } currentValue--; return currentPointer[currentValue]; } bool isEmpty(){ if (currentValue==0){ return true; } return false; } T lastOf(){ return currentPointer[currentValue-1]; } };
[ "george.koshelev@fe86108a-a7a1-bde3-b2d4-a6a6cc998503" ]
[ [ [ 1, 57 ] ] ]
7941333a8bc37c631119dbfc77c523b14233079a
7b4c786d4258ce4421b1e7bcca9011d4eeb50083
/_统计专用/C++Primer中文版(第4版)/第一次-代码集合-20090414/第十五章 面向对象编程/20090308_习题15.32_实现一个debug函数.cpp
ebf4c573a5cb3e3282d61b40fc06ca012b3799d0
[]
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
328
cpp
class Item_base { //... public: virtual void debug(ostream& os = cout) const { os << isbn << "\t" << price; } }; //... class Disc_item : public Item_base { //... public: virtual void debug(ostream& os = cout) const { Item_base::debug(os); os << "\t" << quantity << "\t" << discount; } };
[ "baicaibang@70501136-4834-11de-8855-c187e5f49513" ]
[ [ [ 1, 21 ] ] ]
709c6bdb9a8246a2c8f363304c08c7f063169d77
d752d83f8bd72d9b280a8c70e28e56e502ef096f
/Shared/Utility/Threading/ThreadPool.h
c65956db8df13b76abf370fa4959036ecfa5d158
[]
no_license
apoch/epoch-language.old
f87b4512ec6bb5591bc1610e21210e0ed6a82104
b09701714d556442202fccb92405e6886064f4af
refs/heads/master
2021-01-10T20:17:56.774468
2010-03-07T09:19:02
2010-03-07T09:19:02
34,307,116
0
0
null
null
null
null
UTF-8
C++
false
false
1,861
h
// // The Epoch Language Project // Shared Library Code // // Wrappers for creating thread pools and feeding them work // #pragma once // Dependencies #include "Utility/Threading/Synchronization.h" #include "Utility/Threading/Threads.h" #include <map> // Forward declarations namespace VM { class Program; } namespace Threads { // // Wrapper interface for work items that can be fed to a thread pool // struct PoolWorkItem { virtual ~PoolWorkItem() { } virtual void PerformWork() = 0; }; // // Wrapper for managing a pool of threads // class ThreadPool { // Construction and destruction public: ThreadPool(unsigned threadcount, VM::Program* runningprogram); ~ThreadPool(); // Make pools uncopyable (since a deep copy doesn't make sense) private: ThreadPool(const ThreadPool& other); ThreadPool& operator=(const ThreadPool& other); // Interface for supplying work to the pool public: void AddWorkItem(const std::wstring& taskname, PoolWorkItem* item); // Interface for dispatching work items to the pool threads public: PoolWorkItem* ClaimWorkItem(HANDLE threadhandle); // Thread tracking helpers public: struct ThreadDetails { ThreadPool* OwningPool; HANDLE ThreadHandle; HANDLE ThreadWakeEvent; Threads::ThreadInfo Info; }; HANDLE GetShutdownEvent() const { return ShutdownEvent; } // Internal helpers private: void Clean(); void ResumeAllThreads(); // Internal tracking private: typedef std::map<HANDLE, ThreadDetails*> ThreadDetailMap; ThreadDetailMap Details; typedef std::map<std::wstring, PoolWorkItem*> WorkItemMap; WorkItemMap UnassignedWorkItems; std::map<HANDLE, WorkItemMap> AssignedWorkItems; HANDLE ShutdownEvent; CriticalSection WorkItemCritSec; }; }
[ "don.apoch@localhost" ]
[ [ [ 1, 91 ] ] ]
d9931e3210b13cd0d1d75b8da6f98418cf17a883
71b601e499aa3f2c18797cca5ec16ea312f5f61d
/BCB5_WinInetIntro/Ejecutar.h
ca1bf42d79d7490b2c7cb4ebe8f38bafd85b18fd
[]
no_license
jmnavarro/BCB_LosRinconesDelAPIWinInet
e9186b88bfe4266443a3fcf290cd10b214b0bd5c
b6b58658866370274ea0cbfb4facbcf03f682dec
refs/heads/master
2016-08-07T20:41:23.277852
2011-07-01T08:43:59
2011-07-01T08:43:59
1,982,567
0
0
null
null
null
null
ISO-8859-1
C++
false
false
1,811
h
//--------------------------------------------------------------------------------------------- // // Archivo: Ejecutar.h // // Propósito: // Interfaz del Frame para la ejecución de cada una de las funciones. // Este frame lo que hace es simplificar el código del formulario principal. // // Autor: José Manuel Navarro ([email protected]) // Fecha: 01/04/2003 // Observaciones: Unidad creada en C++ Builder 6 para Síntesis nº 14 (http://www.grupoalbor.com) // Copyright: Este código es de dominio público y se puede utilizar y/o mejorar siempre que // SE HAGA REFERENCIA AL AUTOR ORIGINAL, ya sea a través de estos comentarios // o de cualquier otro modo. // //--------------------------------------------------------------------------------------------- #ifndef EjecutarH #define EjecutarH //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> #include <ExtCtrls.hpp> #include <ActnList.hpp> //--------------------------------------------------------------------------- class TEjecutarFrame : public TFrame { __published: // IDE-managed Components TPanel *p_pie; TLabel *l_retorno2; TLabel *l_retorno; TBevel *Bevel1; TButton *b_ejecutar; void __fastcall Execute(TObject *Sender); private: TCustomAction *FAccion; public: __fastcall TEjecutarFrame(TComponent* Owner); void __fastcall Init(TCustomAction *accion); }; //--------------------------------------------------------------------------- extern PACKAGE TEjecutarFrame *EjecutarFrame; //--------------------------------------------------------------------------- #endif
[ [ [ 1, 52 ] ] ]
7162a7ec669dca559ca5b47bf1d77ecb51f31930
2112057af069a78e75adfd244a3f5b224fbab321
/branches/refactor/src_root/src/ireon_cm/net/cm_server.cpp
a8b444e5c28882158bf0178d0db2b5ee40390f78
[]
no_license
blockspacer/ireon
120bde79e39fb107c961697985a1fe4cb309bd81
a89fa30b369a0b21661c992da2c4ec1087aac312
refs/heads/master
2023-04-15T00:22:02.905112
2010-01-07T20:31:07
2010-01-07T20:31:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,785
cpp
/* Copyright (C) 2005 ireon.org developers council * $Id: cm_server.cpp 287 2005-11-26 09:34:33Z zak $ * 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. */ /** * @file world_server.cpp * World server */ #include "stdafx.h" #include "net/cm_world_context.h" #include "net/cm_server.h" #include "db/cm_db.h" bool CCMServer::start(ushort maximumNumberOfPeers, ushort localPort ) { if( !CNetServer::start(maximumNumberOfPeers,localPort) ) return false; CCMWorldContext::initSignals(); return true; } CNetClient* CCMServer::newContext(TCPsocket sock) { assert(sock); CCMWorldContext* p = new CCMWorldContext(sock,m_socketSet); return p; } CCMWorldContext* CCMServer::findContext(uint id) { std::list<CNetClient*>::iterator i; for( i = m_contexts.begin(); i != m_contexts.end(); i++ ) if( ((CCMWorldContext*)(*i))->getWorldId() == id ) return (CCMWorldContext*)(*i); return NULL; }; void CCMServer::closeContext(CNetClient* context) { CCMDB::instance()->removeWaitAccount((CCMWorldContext*)context); CNetServer::closeContext(context); };
[ [ [ 1, 57 ] ] ]
6b2910fdf142ad6aedc408aa48aafbbc660128c6
91c26ff18209dfb8f00fd6e26dc46c0693976b79
/PakEdit/mainwindow.h
1cc1f2d421e2560b13e1ef890f03760359252b42
[]
no_license
mpapierski/openhelbreath
0f74dd4d89a736d5aa33ca912086826ed3834b33
858a2932ad954ce60168bcde07c305cb7bec0a84
refs/heads/master
2021-03-12T23:33:57.810704
2011-08-15T21:31:22
2011-08-15T21:31:22
2,193,913
11
5
null
null
null
null
UTF-8
C++
false
false
869
h
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QLabel> #include <QMdiSubWindow> #include <QMessageBox> #include <QFileDialog> #include "GlobalDef.h" #include "childwin.h" namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: QLabel * statusLabel; MainWindow(QWidget *parent = 0); ~MainWindow(); public slots: void action_open(); void action_aboutQt(); void action_new(); void action_save(); void action_saveAs(); void action_about(); void action_sprite_add(); void action_sprite_remove(); protected: void changeEvent(QEvent *e); void showEvent (QShowEvent *e); private: Ui::MainWindow *ui; private slots: void on_mdiArea_subWindowActivated(QMdiSubWindow* w); }; #endif // MAINWINDOW_H
[ [ [ 1, 43 ] ] ]
83ec66578dc8af9392d77860cc32f0801f5c936b
a01b67b20207e2d31404262146763d3839ee833d
/trunk/Projet/tags/Monofin_20090606_release/Drawing/paintingview.cpp
d1bfb3fbcec41e4a15af507d6d471445452f1565
[]
no_license
BackupTheBerlios/qtfin-svn
49b59747b6753c72a035bf1e2e95601f91f5992c
ee18d9eb4f80a57a9121ba32dade96971196a3a2
refs/heads/master
2016-09-05T09:42:14.189410
2010-09-21T17:34:43
2010-09-21T17:34:43
40,801,620
0
0
null
null
null
null
ISO-8859-1
C++
false
false
2,030
cpp
#include "paintingview.h" //PUBLIC PaintingView::PaintingView(PaintingScene* scene, QWidget* parent) :QGraphicsView(scene, parent), //_hasAPixmapToDraw(false), _scene(scene){ //_pixmap = 0; this->scale(1,-1); } /*void PaintingView::drawPixmap(PixmapItem* pixmap){ _pixmap = pixmap; _hasAPixmapToDraw = true; }*/ //PUBLIC SLOTS void PaintingView::zoom(qreal factor){ //on évite de zoomer trop pour éviter les bugs... if(_scene->scaleFactor() < ZOOMMAX && //au-delà de certaines valeurs, ça ne sert plus à rien de dézoomer... _scene->scaleFactor() > ZOOMMIN){ this->scale(factor, factor); _scene->scale(factor); } } //PROTECTED //void PaintingView::drawBackground(QPainter* painter, const QRectF& rect){ // // Q_UNUSED(rect); // // //painter->drawRect(_scene->itemsBoundingRect()); // // /*if(_hasAPixmapToDraw){ // painter->drawPixmap(QPointF(0,0), _pixmap->pixmap()); // }*/ // // painter->setPen(Qt::DashDotLine); // painter->drawRect(_scene->sceneRect()); // painter->drawRect(_scene->pointsBoundingZone()); // // painter->setPen(Qt::DotLine); // painter->setOpacity(0.2); // QRect r = _scene->sceneRect().toRect(); // qreal gridUnit = _scene->gridUnit(); // for(qreal i = 0; i < r.bottomRight().x(); i+=gridUnit){ // painter->drawLine(QLineF(i, r.bottomLeft().y(), i, r.topLeft().y())); // } // for(qreal i = 0; i > r.topLeft().y(); i-=gridUnit){ // painter->drawLine(QLineF(r.bottomLeft().x(), i, r.bottomRight().x(), i)); // } // for(qreal i = 0; i < r.bottomLeft().y(); i+=gridUnit){ // painter->drawLine(QLineF(r.bottomLeft().x(), i, r.bottomRight().x(), i)); // } // //} void PaintingView::wheelEvent(QWheelEvent* event){ //QPointF p = this->mapFromScene(event->pos()); if(event->delta() > 0){ this->zoom(ZOOMINFACTOR); }else{ this->zoom(ZOOMOUTFACTOR); } }
[ "kryptos@314bda93-af5c-0410-b653-d297496769b1" ]
[ [ [ 1, 72 ] ] ]
4920c4d6c3aacc716cba82da28b4c630ac4faf22
5d8b6e61055b3b335175348ea9215e31b6a4665c
/src/wmomodel.h
e07b6fa259dffb1a69995b240fff7646957e4cdc
[]
no_license
edwardcharleslloyd/wowmapper
a6b03690d3ff154821c89e6c9751e42b75dc86a5
1a99b69ced8505b59aa1744c09229b5f770c51a0
refs/heads/master
2021-01-10T20:21:58.838400
2011-08-23T07:48:35
2011-08-23T07:48:35
35,194,525
0
0
null
null
null
null
UTF-8
C++
false
false
7,186
h
/* wowmapper - World of Warcraft MAP ParsER Copyright (C) 2010 PferdOne aka Flowerew 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/>. */ #pragma once #include "common.h" #include "mverchunk.h" #include "mpqhandler.h" #include "wmogroup.h" //------------------------------------------------------------------------------ /** WMO header information chunk. **/ struct MohdChunk_s { char id[4]; uint32_t size; uint32_t numMaterials; uint32_t numGroups; uint32_t numPortals; uint32_t numLights; uint32_t numModels; uint32_t numDoodads; uint32_t numSets; uint32_t ambientColor; uint32_t wmoId; glm::vec3 bboxMin, bboxMax; uint32_t liquidType; }; //------------------------------------------------------------------------------ /** Texture names chunk. **/ struct MotxChunk_s { char id[4]; uint32_t size; std::string textureNames; }; //------------------------------------------------------------------------------ /** MOMT contains material informations. **/ struct MomtChunk_s { struct Materials_s { uint32_t flags; uint32_t specularMode; uint32_t blendMode; uint32_t texture0; uint32_t color0; uint32_t flags0; uint32_t texture1; uint32_t color1; uint32_t flags1; uint32_t color2; private: uint32_t pad[6]; }; typedef std::vector<Materials_s> Materials_t; char id[4]; uint32_t size; Materials_t materials; }; //------------------------------------------------------------------------------ /** Group names, not really used. **/ struct MognChunk_s { char id[4]; uint32_t size; std::string groupNames; }; //------------------------------------------------------------------------------ /** Group information chunks, again not really used. **/ struct MogiChunk_s { struct GroupInformation_s { uint32_t flags; glm::vec3 bboxMin, bboxMax; int32_t nameOffset; }; typedef std::vector<GroupInformation_s> GroupInformations_t; char id[4]; uint32_t size; GroupInformations_t infos; }; //------------------------------------------------------------------------------ /** Sky box chunk. **/ struct MosbChunk_s { char id[4]; uint32_t size; uint32_t unknown; }; //------------------------------------------------------------------------------ /** Portal verices. **/ struct MopvChunk_s { struct PortalVertices_s { glm::vec3 vertex[4]; }; typedef std::vector<PortalVertices_s> PortalVertices_t; char id[4]; uint32_t size; PortalVertices_t vertices; }; //------------------------------------------------------------------------------ /** Portal geometry informatin. **/ struct MoptChunk_s { struct PortalInformation_s { uint16_t startVertex; uint16_t numVertices; glm::vec3 normal; uint32_t unknown; }; typedef std::vector<PortalInformation_s> PortalInformations_t; char id[4]; uint32_t size; PortalInformations_t infos; }; //------------------------------------------------------------------------------ /** Portal references. **/ struct MoprChunk_s { struct PortalReference_s { uint16_t index; uint16_t groupIndex; uint16_t side; uint16_t pad; }; typedef std::vector<PortalReference_s> PortalReferences_t; char id[4]; uint32_t size; PortalReferences_t references; }; //------------------------------------------------------------------------------ struct MovvChunk_s { char id[4]; uint32_t size; std::vector<char> content; }; //------------------------------------------------------------------------------ struct MovbChunk_s { char id[4]; uint32_t size; uint16_t firstVertex; uint16_t count; }; //------------------------------------------------------------------------------ /** Lighting information. **/ struct MoltChunk_s { struct LightInformation_s { uint8_t lightType; uint8_t type; uint8_t useAttenuation; uint8_t pad; uint32_t color; glm::vec3 position; float intensity; float attenuationStart; float attenuationEnd; private: float unknown[4]; }; typedef std::vector<LightInformation_s> LightInformations_t; char id[4]; uint32_t size; LightInformations_t infos; }; //------------------------------------------------------------------------------ /** Doodad sets. **/ struct ModsChunk_s { struct DoodadSet_s { char name[20]; uint32_t firstIndex; uint32_t numDoodads; private: uint32_t unknown; }; typedef std::vector<DoodadSet_s> DoodadSets_t; char id[4]; uint32_t size; DoodadSets_t doodadSets; }; //------------------------------------------------------------------------------ /** Doodad names. **/ struct ModnChunk_s { char id[4]; uint32_t size; std::string doodadNames; }; //------------------------------------------------------------------------------ /** Doodad information/definition. **/ struct ModdChunk_s { struct DoodadInformation_s { uint32_t id; glm::vec3 position; glm::quat rotation; float scale; uint32_t color; }; typedef std::vector<DoodadInformation_s> DoodadInformations_t; char id[4]; uint32_t size; DoodadInformations_t infos; }; //------------------------------------------------------------------------------ //struct MfogChunk_s { }; //struct McvpChunk_s { }; typedef std::vector<WmoGroup*> WmoGroups_t; //------------------------------------------------------------------------------ /** WmoModel is the parent structure for WmoGroups. **/ class WmoModel { public: WmoModel( const BufferS_t &wmo_buf ); ~WmoModel(); void loadGroups( const std::string wmo_name, MpqHandler &mpq_h ); void getIndices( Indices32_t *indices, uint32_t filter = 0xff, uint32_t off = 0 ) const; void getVertices( Vertices_t *vertices ) const; void getNormals( Normals_t *normals ) const; const ModdChunk_s& getModdChunk() const; const ModnChunk_s& getModnChunk() const; private: MverChunk_s _mverChunk; MohdChunk_s _mohdChunk; MotxChunk_s _motxChunk; MomtChunk_s _momtChunk; MognChunk_s _mognChunk; MogiChunk_s _mogiChunk; MosbChunk_s _mosbChunk; MopvChunk_s _mopvChunk; MoptChunk_s _moptChunk; MoprChunk_s _moprChunk; MovvChunk_s _movvChunk; MovbChunk_s _movbChunk; MoltChunk_s _moltChunk; ModsChunk_s _modsChunk; ModnChunk_s _modnChunk; ModdChunk_s _moddChunk; WmoGroups_t _wmoGroups; };
[ "PferdOne@42403f9c-0d9a-11df-aac2-bbd07866f500" ]
[ [ [ 1, 271 ] ] ]
fb2e78f7ffd83bbf589891b0284917f37c9c498f
9e2c39ce4b2a226a6db1f5a5d361dea4b2f02345
/tools/LePlatz/Widgets/FocusComboBox.h
dd4ff1fa8e8cb1007e4c6a6ec7871b31cbf28c4d
[]
no_license
gonzalodelgado/uzebox-paul
38623933e0fb34d7b8638b95b29c4c1d0b922064
c0fa12be79a3ff6bbe70799f2e8620435ce80a01
refs/heads/master
2016-09-05T22:24:29.336414
2010-07-19T07:37:17
2010-07-19T07:37:17
33,088,815
0
0
null
null
null
null
UTF-8
C++
false
false
383
h
#ifndef FOCUSCOMBOBOX_H #define FOCUSCOMBOBOX_H #include <QComboBox> class FocusComboBox : public QComboBox { Q_OBJECT public: FocusComboBox(QWidget *parent = 0); signals: void receivedFocus(); void focusLost(); protected: void focusInEvent (QFocusEvent *event); void focusOutEvent (QFocusEvent *event); }; #endif // FOCUSCOMBOBOX_H
[ "[email protected]@08aac7ea-4340-11de-bfec-d9b18e096ff9" ]
[ [ [ 1, 21 ] ] ]
b44075c004e6b08a6fc3175058d131f0c76df876
e4bad8b090b8f2fd1ea44b681e3ac41981f50220
/trunk/gui/abeetlesgui/Environment.h
a93d2f7a134499565a5a18f5aedbe099f4d1f89e
[]
no_license
BackupTheBerlios/abeetles-svn
92d1ce228b8627116ae3104b4698fc5873466aff
803f916bab7148290f55542c20af29367ef2d125
refs/heads/master
2021-01-22T12:02:24.457339
2007-08-15T11:18:14
2007-08-15T11:18:14
40,670,857
0
0
null
null
null
null
UTF-8
C++
false
false
2,092
h
#pragma once #include "Beetle.h" #include "Grid.h" #include "CfgManager.h" #include "StatisticsEnv.h" #include <QWidget> #include <QString> #include "defines.h" //make globals visible extern CfgManager CfgMng; class QImage; class CEnvironment: public QObject { Q_OBJECT public: CEnvironment(void); CEnvironment::CEnvironment(COneRun * oneRun); //CEnvironment(char * fname);//constructor for loading environment from file //CEnvironment::CEnvironment(int seed); // creation of random environment ~CEnvironment(void); //bool pom;//DEBUG!!!!!!!!!!!!!!!!! bool IsEmpty; //CGrid Grid_Past; //actual grid CGrid Grid; //grid for the following time value int Time; int StepCost;int RotCost;int CopulCost;int WaitCost; bool LearningOn; int FlowerGrowingRatio; int NumFreeCells; bool IsFlowersDie; CStatisticsEnv Statist; //Statistics of the environment //QString MapFilePath; //QString EffFilePath; //QString BeetlesFilePath; void Make1Update(); void MakeBeetleAction(int x, int y); void NextTime(void); // increases time by 1 bool PrintEnv(void); bool CleanEnv(); bool LoadEnv(char * filename=0); bool SaveEnv(char * filename); //bool CreateDefaultEnv(void); bool MakeFlowerGrow(int x, int y); bool MakeFlowerDie(int x, int y); void CountStatistics(void); bool FillEmptyEnvRandomly(int seed,int numBeetles=DEFAULT_NUM_BEETLES, char * mapFN=0, char * effFN=0, bool isStepOnFlower=true, bool isNoExpectations=true); void SetEnv(COneRun * oneRun); private: bool A_Copulate(int x, int y, CBeetle * beetle); bool A_Step(int x, int y, char direction); void A_RotateLeft(CBeetle * beetle); void A_RotateRight(CBeetle * beetle); char RotateDirection(char direction, char L_R); int GetBeetleNeighborCell(int x, int y, char direction, char L_R_F, CBeetle ** beetle =0); char * getMapFileName(char *fname); char * getFlowersFileName(char *fname); char * getBeetlesFileName(char *fname); char * getTimeStatsFileName(char *fname); char * getEffFileName(char *fname); };
[ "ibart@60a5a0de-1a2f-0410-942a-f28f22aea592" ]
[ [ [ 1, 76 ] ] ]
6690b05920b2526b49a035fe663316edfa17606e
eaa64a4b73fe76125d34177c33e1aadedfaf4e46
/src/videocapture/VideoCaptureDeviceManagerFactory.cpp
4cf769b3b5993749fe4f8a8f7eb0ddee9b37462f
[ "Apache-2.0" ]
permissive
brianfcoleman/libvideocapture
1d856f3f8658a7d834fad5d094927783092897bc
3357c0d31603c94890960676a38253275a52c1b3
refs/heads/master
2020-04-28T01:55:24.483921
2010-10-10T20:23:32
2010-10-10T20:23:32
35,434,467
0
1
null
null
null
null
UTF-8
C++
false
false
618
cpp
#include "VideoCaptureDeviceManagerFactory.hpp" #include "VideoCaptureDeviceManagerImpl.hpp" #include "MessageSenderInterfaceFactory.hpp" namespace VideoCapture { VideoCaptureDeviceManagerFactory::VideoCaptureDeviceManagerFactory() { } VideoCaptureDeviceManager VideoCaptureDeviceManagerFactory::createVideoCaptureDeviceManager() { typedef MessageSenderInterfaceFactory<VideoCaptureDeviceManager> FactoryType; FactoryType factory; VideoCaptureDeviceManager videoCaptureDeviceManager( factory(s_kMaxSizeMessageQueue)); return videoCaptureDeviceManager; } } // VideoCapture
[ [ [ 1, 21 ] ] ]
15a530e3ddd2ee8ee7b95c5dfa7663b7f33cecc0
c702a7cfde317b06c0dba966c8b45918e6127144
/Estado.h
d66f1f9767daf2c233d2c072e550132c088b7752
[]
no_license
cmdalbem/titiapus
1210d2c45a53a5cdfbe1d72e10ef2c5dd87d668d
567fc84f8203698e16401f7e178df5bd979adcfb
refs/heads/master
2021-01-22T14:32:47.033180
2010-11-25T13:20:53
2010-11-25T13:20:53
32,189,770
0
0
null
null
null
null
UTF-8
C++
false
false
2,012
h
#pragma once #include <vector> using namespace std; #include "constantes.h" #include "utils.h" typedef unsigned short int u_int16; class Linha { public: Linha() {} Linha(const Linha& other) { set(other.get()); } Linha(const u_int16 lin) { set(lin); } ~Linha() {} u_int16 get() const { return _linha; } void set (u_int16 lin) { _linha = lin; } void set(int index, casa valor); void limpaReservadas(); casa operator[] (int index) const; Linha& operator= (const Linha& outro) { set(outro.get()); return *this; } //bool operator< (const Linha& outro) const { return this->get() < outro.get(); } private: u_int16 _linha; }; //---------------------------------------------------------- class Estado { public: Estado(); Estado(const Estado & _estado); ~Estado(); Linha pecas[NLIN]; //casa pecas[NLIN][NCOL]; int npecas[TOTAL_COR]; void setaCasa(int x, int y, casa valor); void limpaReservadas(); vector<Jogada> ultimasJogadas; pair<Estado,bool> movePeca( Ponto origem, Ponto destino ) const; void print() const; vector<Estado> listaSucessoresObrigatorios( Ponto peca ) const; vector<Estado> listaSucessoresPossiveis( Ponto peca ) const; vector<Estado> listaSucessores( cor cor_pecas ) const; vector<Jogada> getJogadasObrigatorias( cor cor_pecas ) const; vector<Jogada> getJogadasPossiveis( cor cor_pecas ) const; vector<Jogada> getJogadasObrigatorias( Ponto peca ) const; vector<Jogada> getJogadasPossiveis( Ponto peca ) const; private: vector<Jogada> jogadasObrigatorias( cor cor_pecas ) const; vector<Jogada> jogadasObrigatorias( Ponto peca ) const; vector<Jogada> listaPossibilidades( Ponto peca ) const; vector<Jogada> listaPossibilidades( cor cor_pecas ) const; vector<Jogada> tiraJogadasRepetidas( vector<Jogada> jogadas ) const; };
[ "ninja.dalbem@5e43c5b1-3cc6-e38b-4c49-94f38ad1f185", "lucapus@5e43c5b1-3cc6-e38b-4c49-94f38ad1f185" ]
[ [ [ 1, 8 ], [ 34, 40 ], [ 42, 43 ], [ 48, 48 ], [ 50, 50 ], [ 52, 69 ] ], [ [ 9, 33 ], [ 41, 41 ], [ 44, 47 ], [ 49, 49 ], [ 51, 51 ] ] ]
33c2018c24d1cc9457fbe208cafb0b8fcd43b083
0bab4267636e3b06cb0e73fe9d31b0edd76260c2
/freewar-alpha/src/give_info_to_game.cpp
9fbfdca372bbbaf8327a816207af1a4135ec41fd
[]
no_license
BackupTheBerlios/freewar-svn
15fafedeed3ea1d374500d3430ff16b412b2f223
aa1a28f19610dbce12be463d5ccd98f712631bc3
refs/heads/master
2021-01-10T19:54:11.599797
2006-12-10T21:45:11
2006-12-10T21:45:11
40,725,388
0
0
null
null
null
null
UTF-8
C++
false
false
889
cpp
// // give_info_to_game.cpp for freewar in /u/ept2/huot_j/Freewar/src // // Made by jonathan huot // Login <[email protected]> // // Started on Thu May 6 11:12:41 2004 jonathan huot // Last update Tue Jun 29 19:51:49 2004 jonathan huot // #include "freewar.h" int give_info_to_game(t_db_info *db_info) { int first; Uint32 ticks; ticks = SDL_GetTicks(); first = cnt->clients[0].pos_send; stock_msg(&cnt->clients[0], TAG_INFO, sizeof(*db_info), (void*)db_info); fflush(fd_log); while (32) { printf("pif\n");fflush(stdout); check_select(5313); printf("pof\n");fflush(stdout); if (cnt->clients[0].pos_send != first) { fprintf(fd_log, "db sent!\n"); return (0); } if (SDL_GetTicks() - ticks > 9320) { fprintf(fd_log, "db not send\n"); return (0); } } return (0); }
[ "doomsday@b2c3ed95-53e8-0310-b220-efb193137011" ]
[ [ [ 1, 39 ] ] ]
c4b66adf433525cc1275b4da1a452abddba2f938
7c3b9e8e05236a05de3a5097b70160dfde0313e3
/firmware/pc_apps/pcmonitor_udp/nt_service.cpp
e68d956735ba36e9bc5b5b1c456efb247873a065
[]
no_license
yisea123/moonlight
e1c228ad063cf39b8b85e163d90d1ca185bfad85
377b8370f2bab42980389c664ac84d43c2299291
refs/heads/master
2020-06-28T06:34:51.039649
2011-01-27T02:13:38
2011-01-27T02:13:38
200,165,435
1
0
null
2019-08-02T04:32:02
2019-08-02T04:32:02
null
UTF-8
C++
false
false
5,756
cpp
#include "nt_service.h" using namespace win; //----------------------------------------------------------------------------- // meyer's singletom implementation //----------------------------------------------------------------------------- nt_service& nt_service::instance( const char_ * const name_ , std::ostream * const log_ ) { m_name = name_; m_log = log_; static nt_service obj; return obj; } //----------------------------------------------------------------------------- void nt_service::register_service_main( LPSERVICE_MAIN_FUNCTION service_main_ ) { m_user_service_main = service_main_; } //----------------------------------------------------------------------------- void nt_service::register_control_handler( NTSERVICE_CONTROL ctrl_, NTSERVICE_CALLBACK_FUNCTION ctrl_handler_ ) { if ( ctrl_handler_ ) { m_callback_map[ ctrl_ ] = ctrl_handler_; m_accepted_controls << convert_control_to_accept( ctrl_ ); } } //----------------------------------------------------------------------------- void nt_service::register_init_function( NTSERVICE_CALLBACK_FUNCTION init_fcn_ ) { m_service_init_fcn = init_fcn_; } //----------------------------------------------------------------------------- void nt_service::accept_control( NTSERVICE_ACCEPT control_ ) { m_accepted_controls << control_; } //----------------------------------------------------------------------------- void nt_service::start() { SERVICE_TABLE_ENTRY service_table[2]; service_table[0].lpServiceName = const_cast<char_*>( m_name ); service_table[0].lpServiceProc = & nt_service_main; service_table[1].lpServiceName = 0; service_table[1].lpServiceProc = 0; StartServiceCtrlDispatcher(service_table); } //----------------------------------------------------------------------------- void nt_service::stop( DWORD exit_code_ ) { if ( m_handle ) { m_status.dwCurrentState = SERVICE_STOPPED; m_status.dwWin32ExitCode = exit_code_; SetServiceStatus ( m_handle, & m_status ); } } //----------------------------------------------------------------------------- NTSERVICE_ACCEPT nt_service::convert_control_to_accept( NTSERVICE_CONTROL control_ ) { switch( control_ ) { case SERVICE_CONTROL_STOP: return SERVICE_ACCEPT_STOP; case SERVICE_CONTROL_PAUSE: case SERVICE_CONTROL_CONTINUE: return SERVICE_ACCEPT_PAUSE_CONTINUE; case SERVICE_CONTROL_SHUTDOWN: return SERVICE_ACCEPT_SHUTDOWN; case SERVICE_CONTROL_PARAMCHANGE: return SERVICE_ACCEPT_PARAMCHANGE; case SERVICE_CONTROL_NETBINDADD: case SERVICE_CONTROL_NETBINDREMOVE: case SERVICE_CONTROL_NETBINDENABLE: case SERVICE_CONTROL_NETBINDDISABLE: return SERVICE_ACCEPT_NETBINDCHANGE; case SERVICE_CONTROL_HARDWAREPROFILECHANGE: return SERVICE_ACCEPT_HARDWAREPROFILECHANGE; case SERVICE_CONTROL_POWEREVENT: return SERVICE_ACCEPT_POWEREVENT; case SERVICE_CONTROL_SESSIONCHANGE: return SERVICE_ACCEPT_SESSIONCHANGE; case SERVICE_CONTROL_INTERROGATE: case SERVICE_CONTROL_DEVICEEVENT: default: return NTSERVICE_ACCEPT( 0 ); } } //----------------------------------------------------------------------------- VOID WINAPI nt_service::service_control_handler( NTSERVICE_CONTROL control_ ) { if ( m_callback_map.find( control_ ) != m_callback_map.end() ) { m_callback_map[ control_ ](); } switch( control_ ) { case SERVICE_CONTROL_STOP: m_status.dwCurrentState = SERVICE_STOPPED; break; case SERVICE_CONTROL_SHUTDOWN: m_status.dwCurrentState = SERVICE_STOPPED; break; case SERVICE_CONTROL_PAUSE: m_status.dwCurrentState = SERVICE_PAUSED; default: m_status.dwCurrentState = SERVICE_RUNNING; break; } m_status.dwWin32ExitCode = 0; SetServiceStatus ( m_handle, & m_status ); } //----------------------------------------------------------------------------- VOID WINAPI nt_service::nt_service_main( DWORD argc_, char_* argv_[] ) { m_status.dwServiceType = SERVICE_WIN32; m_status.dwCurrentState = SERVICE_START_PENDING; m_status.dwControlsAccepted = m_accepted_controls.to_dword(); m_handle = RegisterServiceCtrlHandler( m_name, service_control_handler ); if ( m_handle == 0 ) { if ( m_log )*m_log<<"[E] - nt_service: RegisterServiceCtrlHandler failed\n"; return; } if ( m_service_init_fcn ) { try { m_service_init_fcn(); } catch(...) { if ( m_log )*m_log<<"[E] - nt_service: m_service_init_fcn failed\n"; nt_service::stop(-1); return; } } // We report the running status to SCM. m_status.dwCurrentState = SERVICE_RUNNING; SetServiceStatus( m_handle, & m_status); // The worker loop of a service while ( m_status.dwCurrentState == SERVICE_RUNNING ) { try { m_user_service_main( argc_, argv_ ); } catch(...) { if ( m_log )*m_log<<"[E] - nt_service: in service main\n"; nt_service::stop( -1 ); } } return; } //----------------------------------------------------------------------------- const char_* nt_service::m_name = 0; SERVICE_STATUS nt_service::m_status; SERVICE_STATUS_HANDLE nt_service::m_handle = 0; LPSERVICE_MAIN_FUNCTION nt_service::m_user_service_main = 0; NTSERVICE_CALLBACK_FUNCTION nt_service::m_service_init_fcn = 0; map< NTSERVICE_CONTROL , NTSERVICE_CALLBACK_FUNCTION > nt_service::m_callback_map; bitmask< NTSERVICE_ACCEPT > nt_service::m_accepted_controls = 0; ostream * nt_service::m_log = 0;
[ [ [ 1, 185 ] ] ]
eeabb066649c5d5ddfbf63cb501756463b85fc28
216ae2fd7cba505c3690eaae33f62882102bd14a
/utils/nxogre/include/NxOgreSpringDescription.h
012c87de4ffabfcc0dc982b7106addbcf9e0f460
[]
no_license
TimelineX/balyoz
c154d4de9129a8a366c1b8257169472dc02c5b19
5a0f2ee7402a827bbca210d7c7212a2eb698c109
refs/heads/master
2021-01-01T05:07:59.597755
2010-04-20T19:53:52
2010-04-20T19:53:52
56,454,260
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
2,249
h
/** File: NxOgreSpringDescription.h Created on: 16-Apr-09 Author: Robin Southern "betajaen" SVN: $Id$ © Copyright, 2008-2009 by Robin Southern, http://www.nxogre.org This file is part of NxOgre. NxOgre is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. NxOgre 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 NxOgre. If not, see <http://www.gnu.org/licenses/>. */ #ifndef NXOGRE_SPRINGDESCRIPTION_H #define NXOGRE_SPRINGDESCRIPTION_H #include "NxOgreStable.h" #include "NxOgreCommon.h" namespace NxOgre_Namespace { /** \brief Describes a Joint Spring */ class NxOgrePublicClass SpringDescription { public: /** \brief Constructor and calls reset. */ SpringDescription(); /** \brief Reset function */ void reset(); /** \brief Spring coefficient \see NxSpringDesc::spring \default 0 */ Real mSpring; /** \brief Damper coefficient \see NxSpringDesc::damper \default 0 */ Real mDamper; /** \brief Target value (either in radians or positional) of spring where the spring force is zero. \see NxSpringDesc::targetValue \default 0 */ Real mTargetValue; }; // class SpringDescription } // namespace NxOgre_Namespace #endif
[ "umutert@b781d008-8b8c-11de-b664-3b115b7b7a9b" ]
[ [ [ 1, 80 ] ] ]
6bfd77209a78da166b2e863d2be40a1eb62fce19
c9630df0e019e54a19edd09e0ae2736102709d62
/jacobi/trunk/jacobiMPI/jacobiMPIMain.cpp
b88300904177481b5f0e98169ee72f18728773a6
[]
no_license
shaowei-su/jacobi-in-parallel
45df2fdab6e32083b486ac088e1036fd085d4c1c
8c772afd412945735d15f771f200c6cff30bdae3
refs/heads/master
2021-01-13T01:31:07.625534
2010-04-13T10:46:20
2010-04-13T10:46:20
33,940,298
0
0
null
null
null
null
GB18030
C++
false
false
783
cpp
// jacobiMPI.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" //******************************************************************************** int main(int argc, char* argv[]) { //paramenters int n; double epsilon; struct boundary b; long step; char *outFile = (char *)malloc(sizeof(char) * 128); //input int ok = input(argc, argv, &n, &epsilon, &step, &b, outFile); if (ok != 0) { getchar(); return 0; } b.averageValue = (b.left + b.up + b.right + b.down) / 4; //MPI_Init(&argc,&argv); //jacobi serial 1D jacobiMPI_1D(argc, argv, n, epsilon, step, b, outFile); //jacobi serial 2D //jacobiSerial_2D(n, epsilon, step, b, outFile); //MPI_Finalize(); getchar(); return 0; }
[ "Snigoal@aed88cc7-7f53-aada-5582-5968519015a4" ]
[ [ [ 1, 41 ] ] ]
af90cfb2481c80a1d296bef24101762b4fcd1aa4
d5f525c995dd321375a19a8634a391255f0e5b6f
/graphic_front_end/sp/sp/spTreeView.h
f13168dac449a6e931d60fcb7ce0c0d730ae74f5
[]
no_license
shangdawei/cortex-simulator
bac4b8f19be3e2df622ad26e573330642ec97bae
d343b66a88a5b78d5851a3ee5dc2a4888ff00b20
refs/heads/master
2016-09-05T19:45:32.930832
2009-03-19T06:07:47
2009-03-19T06:07:47
42,106,205
1
1
null
null
null
null
GB18030
C++
false
false
756
h
#pragma once // CspTreeView 视图 class CspTreeView : public CTreeView { DECLARE_DYNCREATE(CspTreeView) protected: CspTreeView(); // 动态创建所使用的受保护的构造函数 virtual ~CspTreeView(); protected: HTREEITEM root; //The node of the tree HTREEITEM m_subtree[4]; public: #ifdef _DEBUG virtual void AssertValid() const; #ifndef _WIN32_WCE virtual void Dump(CDumpContext& dc) const; #endif #endif protected: DECLARE_MESSAGE_MAP() protected: //User reload function void CspTreeView::OnInitialUpdate(); public: afx_msg void OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult); protected: virtual void OnUpdate(CView* /*pSender*/, LPARAM /*lHint*/, CObject* /*pHint*/); };
[ "yihengw@3e89f612-834b-0410-bb31-dbad55e6f342" ]
[ [ [ 1, 38 ] ] ]
6bc2ab120deac0c7c7408860388130e82042b273
9a48be80edc7692df4918c0222a1640545384dbb
/Libraries/Boost1.40/libs/spirit/phoenix/test/algorithm/querying.cpp
9edb417ca0e51533cd492b9e4ae3bade04d5d3cc
[ "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
8,600
cpp
/*============================================================================= Copyright (c) 2005 Dan Marsden Copyright (c) 2005-2007 Joel de Guzman Copyright (c) 2007 Hartmut Kaiser 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) ==============================================================================*/ #include <boost/spirit/home/phoenix/stl/algorithm/querying.hpp> #include <boost/spirit/include/phoenix_core.hpp> #include <boost/detail/lightweight_test.hpp> #include <set> #include <functional> namespace { struct even { bool operator()(const int i) const { return i % 2 == 0; } }; struct mod_2_comparison { bool operator()( const int lhs, const int rhs) { return lhs % 2 == rhs % 2; }; }; void find_test() { using namespace boost::phoenix; using namespace boost::phoenix::arg_names; int array[] = {1,2,3}; BOOST_TEST(find(arg1,2)(array) == array + 1); std::set<int> s(array, array + 3); BOOST_TEST(find(arg1, 2)(s) == s.find(2)); return; } void find_if_test() { using namespace boost::phoenix; using namespace boost::phoenix::arg_names; int array[] = {1,2,3}; BOOST_TEST(find_if(arg1, even())(array) == array + 1); return; } void find_end_test() { using namespace boost::phoenix; using namespace boost::phoenix::arg_names; int array[] = {1,2,3,1,2,3,1}; int pattern[] = {1,2,3}; BOOST_TEST(find_end(arg1, arg2)(array, pattern) == array + 3); int pattern2[] = {5,6,5}; BOOST_TEST(find_end(arg1, arg2, mod_2_comparison())(array, pattern2) == array + 3); return; } void find_first_of_test() { using namespace boost::phoenix; using namespace boost::phoenix::arg_names; int array[] = {1,2,3}; int search_for[] = {2,3,4}; BOOST_TEST(find_first_of(arg1, arg2)(array, search_for) == array + 1); int search_for2[] = {0}; BOOST_TEST(find_first_of(arg1, arg2, mod_2_comparison())(array, search_for2) == array + 1); return; } void adjacent_find_test() { using namespace boost::phoenix; using namespace boost::phoenix::arg_names; int array[] = {0,1,3,4,4}; BOOST_TEST(adjacent_find(arg1)(array) == array + 3); BOOST_TEST(adjacent_find(arg1, mod_2_comparison())(array) == array + 1); return; } void count_test() { using namespace boost::phoenix; using namespace boost::phoenix::arg_names; int array[] = {1,1,0,1,1}; BOOST_TEST(count(arg1, 1)(array) == 4); return; } void count_if_test() { using namespace boost::phoenix; using namespace boost::phoenix::arg_names; int array[] = {1,2,3,4,5}; BOOST_TEST(count_if(arg1, even())(array) == 2); return; } void distance_test() { using namespace boost::phoenix; using namespace boost::phoenix::arg_names; int array[] = {1,1,0,1,1}; BOOST_TEST(distance(arg1)(array) == 5); return; } void mismatch_test() { using namespace boost::phoenix; using namespace boost::phoenix::arg_names; int array[] = {1,2,3,4,5}; int search[] = {1,2,4}; BOOST_TEST( mismatch(arg1, arg2)(array, search) == std::make_pair(array + 2, search + 2)); int search2[] = {1,2,1,1}; BOOST_TEST( mismatch(arg1, arg2, mod_2_comparison())(array, search2) == std::make_pair(array + 3, search2 + 3)); return; } void equal_test() { using namespace boost::phoenix; using namespace boost::phoenix::arg_names; int array[] = {1,2,3}; int array2[] = {1,2,3}; int array3[] = {1,2,4}; BOOST_TEST( equal(arg1, arg2)(array, array2)); BOOST_TEST( !equal(arg1, arg2)(array, array3)); BOOST_TEST( equal(arg1, arg2, mod_2_comparison())(array, array2)); BOOST_TEST( !equal(arg1, arg2, mod_2_comparison())(array, array3)); return; } void search_test() { using namespace boost::phoenix; using namespace boost::phoenix::arg_names; int array[] = {1,2,3,1,2,3}; int pattern[] = {2,3}; BOOST_TEST( search(arg1, arg2)(array, pattern) == array + 1); int pattern2[] = {1,1}; BOOST_TEST( search(arg1, arg2, mod_2_comparison())(array, pattern2) == array + 2); return; } void lower_bound_test() { using namespace boost::phoenix; using namespace boost::phoenix::arg_names; int array[] = {1,2,3}; const std::set<int> test_set(array, array + 3); BOOST_TEST(lower_bound(arg1, 2)(array) == array + 1); BOOST_TEST(lower_bound(arg1, 2)(test_set) == test_set.lower_bound(2)); int array2[] = {3,2,1}; const std::set<int, std::greater<int> > test_set2(array2, array2 + 3); BOOST_TEST(boost::phoenix::lower_bound(arg1, 2, std::greater<int>())(array2) == array2 + 1); BOOST_TEST(boost::phoenix::lower_bound(arg1, 2, std::greater<int>())(test_set2) == test_set2.lower_bound(2)); return; } void upper_bound_test() { using namespace boost::phoenix; using namespace boost::phoenix::arg_names; int array[] = {1,2,3}; const std::set<int> test_set(array, array + 3); BOOST_TEST(upper_bound(arg1, 2)(array) == array + 2); BOOST_TEST(upper_bound(arg1, 2)(test_set) == test_set.upper_bound(2)); int array2[] = {3,2,1}; const std::set<int, std::greater<int> > test_set2(array2, array2 + 3); BOOST_TEST(boost::phoenix::upper_bound(arg1, 2, std::greater<int>())(array2) == array2 + 2); BOOST_TEST(boost::phoenix::upper_bound(arg1, 2, std::greater<int>())(test_set2) == test_set2.upper_bound(2)); return; } void equal_range_test() { using namespace boost::phoenix; using namespace boost::phoenix::arg_names; int array[] = {1,2,2,3}; const std::set<int> test_set(array, array + 4); BOOST_TEST(equal_range(arg1, 2)(array).first == array + 1); BOOST_TEST(equal_range(arg1, 2)(array).second == array + 3); BOOST_TEST(equal_range(arg1, 2)(test_set).first == test_set.equal_range(2).first); BOOST_TEST(equal_range(arg1, 2)(test_set).second == test_set.equal_range(2).second); int array2[] = {3,2,2,1}; const std::set<int, std::greater<int> > test_set2(array2, array2 + 4); BOOST_TEST(boost::phoenix::equal_range(arg1, 2, std::greater<int>())(array2).first == array2 + 1); BOOST_TEST(boost::phoenix::equal_range(arg1, 2, std::greater<int>())(array2).second == array2 + 3); BOOST_TEST(boost::phoenix::equal_range(arg1, 2, std::greater<int>())(test_set2).first == test_set2.equal_range(2).first); BOOST_TEST(boost::phoenix::equal_range(arg1, 2, std::greater<int>())(test_set2).second == test_set2.equal_range(2).second); return; } void binary_search_test() { using namespace boost::phoenix; using namespace boost::phoenix::arg_names; int array[] = {1,2,3}; BOOST_TEST(binary_search(arg1, 2)(array)); BOOST_TEST(!binary_search(arg1, 4)(array)); return; } } int main() { find_test(); find_if_test(); find_end_test(); find_first_of_test(); adjacent_find_test(); count_test(); count_if_test(); distance_test(); mismatch_test(); equal_test(); search_test(); lower_bound_test(); upper_bound_test(); equal_range_test(); binary_search_test(); return boost::report_errors(); }
[ "metrix@Blended.(none)" ]
[ [ [ 1, 270 ] ] ]
d190dc8fa554e6c8caf3559cfd3bf66604d94110
6e563096253fe45a51956dde69e96c73c5ed3c18
/dhnetsdk/Demo/ConfigAlarm.cpp
919d92cc5f1f3b757f699b1aba650513f056bef5
[]
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
UTF-8
C++
false
false
5,643
cpp
// ConfigAlarm.cpp : implementation file // #include "stdafx.h" #include "netsdkdemo.h" #include "ConfigAlarm.h" #include "NetSDKDemoDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CConfigAlarm dialog CConfigAlarm::CConfigAlarm(CWnd* pParent /*=NULL*/) : CDialog(CConfigAlarm::IDD, pParent) { //{{AFX_DATA_INIT(CConfigAlarm) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_pDev = 0; memset(&m_almCFG, 0, sizeof(DEV_ALARM_SCHEDULE)); m_bInited = FALSE; } void CConfigAlarm::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CConfigAlarm) DDX_Control(pDX, IDC_TAB_ALARMBOARD, m_alarmBoard); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CConfigAlarm, CDialog) //{{AFX_MSG_MAP(CConfigAlarm) ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_ALARMBOARD, OnSelchangeTabAlarmboard) ON_WM_SHOWWINDOW() ON_BN_CLICKED(IDC_UNDO_ALL, OnUndoAll) ON_BN_CLICKED(IDC_APPLY, OnApply) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CConfigAlarm message handlers #define ALARM_UPLOAD 0x00000001 #define ALARM_RECORD 0x00000002 #define ALARM_PTZ 0x00000004 #define ALARM_MAIL 0x00000008 #define ALARM_TOUR 0x00000010 #define ALARM_TIP 0x00000020 #define ALARM_OUT 0x00000040 // #define MOTION_ROW 12 // #define MOTION_COL 16 void CConfigAlarm::OnSelchangeTabAlarmboard(NMHDR* pNMHDR, LRESULT* pResult) { switch(m_alarmBoard.GetCurSel()) { case 0: //alarm in m_alarmInDlg.ShowWindow(SW_SHOW); m_blindDlg.ShowWindow(SW_HIDE); m_diskDlg.ShowWindow(SW_HIDE); m_motionDlg.ShowWindow(SW_HIDE); m_vlostDlg.ShowWindow(SW_HIDE); break; case 1: //motion m_motionDlg.ShowWindow(SW_SHOW); m_alarmInDlg.ShowWindow(SW_HIDE); m_blindDlg.ShowWindow(SW_HIDE); m_diskDlg.ShowWindow(SW_HIDE); m_vlostDlg.ShowWindow(SW_HIDE); break; case 2: //video lost m_vlostDlg.ShowWindow(SW_SHOW); m_alarmInDlg.ShowWindow(SW_HIDE); m_blindDlg.ShowWindow(SW_HIDE); m_diskDlg.ShowWindow(SW_HIDE); m_motionDlg.ShowWindow(SW_HIDE); break; case 3: //blind m_blindDlg.ShowWindow(SW_SHOW); m_alarmInDlg.ShowWindow(SW_HIDE); m_diskDlg.ShowWindow(SW_HIDE); m_motionDlg.ShowWindow(SW_HIDE); m_vlostDlg.ShowWindow(SW_HIDE); break; case 4: //disk m_diskDlg.ShowWindow(SW_SHOW); m_alarmInDlg.ShowWindow(SW_HIDE); m_blindDlg.ShowWindow(SW_HIDE); m_motionDlg.ShowWindow(SW_HIDE); m_vlostDlg.ShowWindow(SW_HIDE); break; default: break; } *pResult = 0; } BOOL CConfigAlarm::OnInitDialog() { CDialog::OnInitDialog(); g_SetWndStaticText(this); m_alarmBoard.InsertItem(0, ConvertString(MSG_ALARMCFG_ALARMIN)); m_alarmBoard.InsertItem(1, ConvertString(MSG_ALARMCFG_MOTION)); m_alarmBoard.InsertItem(2, ConvertString(MSG_ALARMCFG_VIDEOLOST)); m_alarmBoard.InsertItem(3, ConvertString(MSG_ALARMCFG_BLINE)); // m_alarmBoard.InsertItem(4, MSG_ALARMCFG_DISK); m_alarmInDlg.SetDevice(m_pDev); m_blindDlg.SetDevice(m_pDev); // m_diskDlg.SetDevice(m_pDev); m_motionDlg.SetDevice(m_pDev); m_vlostDlg.SetDevice(m_pDev); m_alarmInDlg.Create(IDD_CONFIG_ALARM_ALARM, &m_alarmBoard); m_blindDlg.Create(IDD_CONFIG_ALARM_BLIND, &m_alarmBoard); m_diskDlg.Create(IDD_CONFIG_ALARM_DISK, &m_alarmBoard); m_motionDlg.Create(IDD_CONFIG_ALARM_MOTION, &m_alarmBoard); m_vlostDlg.Create(IDD_CONFIG_ALARM_VLOST, &m_alarmBoard); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CConfigAlarm::GetConfig() { if (!m_pDev || m_bInited) { return; } DWORD retlen = 0; BOOL bRet = CLIENT_GetDevConfig(m_pDev->LoginID, DEV_ALARMCFG, 0, &m_almCFG, sizeof(DEV_ALARM_SCHEDULE), &retlen, CONFIG_WAITTIME); if (!bRet || retlen != sizeof(DEV_ALARM_SCHEDULE)) { ((CNetSDKDemoDlg*)AfxGetMainWnd())->LastError(); return; } else { m_bInited = TRUE; } m_alarmInDlg.SetAlarmInCFG(m_almCFG.struLocalAlmIn); m_blindDlg.SetBlindCFG(m_almCFG.struBlind); // m_diskDlg.SetAlarmInCFG(m_almCFG.struAlarmIn); m_motionDlg.SetMotionCFG(m_almCFG.struMotion); m_vlostDlg.SetVlostCFG(m_almCFG.struVideoLost); m_alarmBoard.SetCurSel(0); m_alarmInDlg.ShowWindow(SW_SHOW); m_blindDlg.ShowWindow(SW_HIDE); m_diskDlg.ShowWindow(SW_HIDE); m_motionDlg.ShowWindow(SW_HIDE); m_vlostDlg.ShowWindow(SW_HIDE); } void CConfigAlarm::SetDevice(DeviceNode *pDev) { m_pDev = pDev; } void CConfigAlarm::OnShowWindow(BOOL bShow, UINT nStatus) { CDialog::OnShowWindow(bShow, nStatus); GetConfig(); } void CConfigAlarm::OnUndoAll() { m_bInited = FALSE; m_alarmInDlg.UndoAll(); m_blindDlg.UndoAll(); // m_diskDlg.UndoAll(); m_motionDlg.UndoAll(); m_vlostDlg.UndoAll(); GetConfig(); } void CConfigAlarm::OnApply() { m_alarmInDlg.GetAlarmInCFG(m_almCFG.struLocalAlmIn); m_blindDlg.GetBlindCFG(m_almCFG.struBlind); // m_diskDlg.SetAlarmInCFG(m_almCFG.struAlarmIn); m_motionDlg.GetMotionCFG(m_almCFG.struMotion); m_vlostDlg.GetVlostCFG(m_almCFG.struVideoLost); BOOL bRet = CLIENT_SetDevConfig(m_pDev->LoginID, DEV_ALARMCFG, 0, &m_almCFG, sizeof(DEV_ALARM_SCHEDULE), CONFIG_WAITTIME); if (!bRet) { ((CNetSDKDemoDlg*)AfxGetMainWnd())->LastError(); return; } else { MessageBox(ConvertString(MSG_CONFIG_SUCCESS), "OK"); } }
[ "guoqiao@a83c37f4-16cc-5f24-7598-dca3a346d5dd" ]
[ [ [ 1, 216 ] ] ]
99bb83a74e5c0d535ac72d067d937b611bd0775f
d826e0dcc5b51f57101f2579d65ce8e010f084ec
/transcad/StdSolidChamferFeatureAuto.h
fa9b6f5d7209a7e62b8531330f8a434302310f7a
[]
no_license
crazyhedgehog/macro-parametric
308d9253b96978537a26ade55c9c235e0442d2c4
9c98d25e148f894b45f69094a4031b8ad938bcc9
refs/heads/master
2020-05-18T06:01:30.426388
2009-06-26T15:00:02
2009-06-26T15:00:02
38,305,994
0
0
null
null
null
null
UHC
C++
false
false
1,689
h
// StdSolidChamferFeatureAuto.h : CStdSolidChamferFeatureAuto의 선언입니다. #pragma once #include "resource.h" // 주 기호입니다. #include "TransCAD.h" #include ".\DispatchImplEx.h" #include ".\FeatureImpl.h" typedef IDispatchImplEx<IStdSolidChamferFeature, &IID_IStdSolidChamferFeature, &LIBID_TransCAD, /*wMajor =*/ 1, /*wMinor =*/ 0> IStdSolidChamferFeatureType; // CStdSolidChamferFeatureAuto class ATL_NO_VTABLE CStdSolidChamferFeatureAuto : public CComObjectRootEx<CComSingleThreadModel>, // public CComCoClass<CStdSolidChamferFeatureAuto, &CLSID_StdSolidChamferFeature>, public IFeatureImpl<IStdSolidChamferFeatureType> { public: CStdSolidChamferFeatureAuto() { } DECLARE_REGISTRY_RESOURCEID(IDR_STDSOLIDCHAMFERFEATURE) BEGIN_COM_MAP(CStdSolidChamferFeatureAuto) COM_INTERFACE_ENTRY(IStdSolidChamferFeature) COM_INTERFACE_ENTRY(IFeature) COM_INTERFACE_ENTRY(IDispatch) END_COM_MAP() DECLARE_PROTECT_FINAL_CONSTRUCT() HRESULT FinalConstruct() { return S_OK; } void FinalRelease() { ReleaseDispatchImplEx(); } public: STDMETHOD(get_ChamferType)(ChamferType *pVal); STDMETHOD(get_SelectedEdge)(IReference **ppVal); STDMETHOD(get_SelectedFace)(IReference **ppVal); STDMETHOD(get_Length)(double *pVal); STDMETHOD(get_Value)(double *pVal); STDMETHOD(get_StartPosX)(double *pVal); STDMETHOD(get_StartPosY)(double *pVal); STDMETHOD(get_StartPosZ)(double *pVal); STDMETHOD(get_EndPosX)(double *pVal); STDMETHOD(get_EndPosY)(double *pVal); STDMETHOD(get_EndPosZ)(double *pVal); }; // OBJECT_ENTRY_AUTO(__uuidof(StdSolidChamferFeature), CStdSolidChamferFeatureAuto)
[ "surplusz@2d8c97fe-2f4b-11de-8e0c-53a27eea117e" ]
[ [ [ 1, 61 ] ] ]
e66de96f97ee4fc41ac889b09b998950024b5deb
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/regex/test/regress/test_escapes.cpp
e4d2d5144c87e9167f9afb7310bb859efe253ebf
[ "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
9,079
cpp
/* * * Copyright (c) 2004 * John Maddock * * 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 "test.hpp" #ifdef BOOST_MSVC #pragma warning(disable:4127) #endif void test_character_escapes() { using namespace boost::regex_constants; // characters by code TEST_REGEX_SEARCH("\\0101", perl, "A", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("\\00", perl, "\0", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("\\0", perl, "\0", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("\\0172", perl, "z", match_default, make_array(0, 1, -2, -2)); // extra escape sequences: TEST_REGEX_SEARCH("\\a", perl, "\a", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("\\f", perl, "\f", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("\\n", perl, "\n", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("\\r", perl, "\r", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("\\v", perl, "\v", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("\\t", perl, "\t", match_default, make_array(0, 1, -2, -2)); // updated tests for version 2: TEST_REGEX_SEARCH("\\x41", perl, "A", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("\\xff", perl, "\xff", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("\\xFF", perl, "\xff", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("\\c@", perl, "\0", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("\\cA", perl, "\x1", match_default, make_array(0, 1, -2, -2)); //TEST_REGEX_SEARCH("\\cz", perl, "\x3A", match_default, make_array(0, 1, -2, -2)); //TEST_INVALID_REGEX("\\c=", extended); //TEST_INVALID_REGEX("\\c?", extended); TEST_REGEX_SEARCH("=:", perl, "=:", match_default, make_array(0, 2, -2, -2)); TEST_REGEX_SEARCH("\\e", perl, "\x1B", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("\\x1b", perl, "\x1B", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("\\x{1b}", perl, "\x1B", match_default, make_array(0, 1, -2, -2)); TEST_INVALID_REGEX("\\x{}", perl); TEST_INVALID_REGEX("\\x{", perl); TEST_INVALID_REGEX("\\", perl); TEST_INVALID_REGEX("\\c", perl); TEST_INVALID_REGEX("\\x}", perl); TEST_INVALID_REGEX("\\x", perl); TEST_INVALID_REGEX("\\x{yy", perl); TEST_INVALID_REGEX("\\x{1b", perl); // \Q...\E sequences: TEST_INVALID_REGEX("\\Qabc\\", perl); TEST_REGEX_SEARCH("\\Qabc\\E", perl, "abcd", match_default, make_array(0, 3, -2, -2)); TEST_REGEX_SEARCH("\\Qabc\\Ed", perl, "abcde", match_default, make_array(0, 4, -2, -2)); TEST_REGEX_SEARCH("\\Q+*?\\\\E", perl, "+*?\\", match_default, make_array(0, 4, -2, -2)); TEST_REGEX_SEARCH("a\\Q+*?\\\\Eb", perl, "a+*?\\b", match_default, make_array(0, 6, -2, -2)); TEST_REGEX_SEARCH("\\C+", perl, "abcde", match_default, make_array(0, 5, -2, -2)); TEST_REGEX_SEARCH("\\X+", perl, "abcde", match_default, make_array(0, 5, -2, -2)); #if !BOOST_WORKAROUND(__BORLANDC__, < 0x560) TEST_REGEX_SEARCH_W(L"\\X", perl, L"a\x0300\x0301", match_default, make_array(0, 3, -2, -2)); #endif // unknown escape sequences match themselves: TEST_REGEX_SEARCH("\\~", perl, "~", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("\\~", basic, "~", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("\\~", extended, "~", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("\\j", extended, "j", match_default, make_array(0, 1, -2, -2)); } void test_assertion_escapes() { using namespace boost::regex_constants; // word start: TEST_REGEX_SEARCH("\\<abcd", perl, " abcd", match_default, make_array(2, 6, -2, -2)); TEST_REGEX_SEARCH("\\<ab", perl, "cab", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("\\<ab", perl, "\nab", match_default, make_array(1, 3, -2, -2)); TEST_REGEX_SEARCH("\\<tag", perl, "::tag", match_default, make_array(2, 5, -2, -2)); TEST_REGEX_SEARCH("\\<abcd", perl, "abcd", match_default|match_not_bow, make_array(-2, -2)); TEST_REGEX_SEARCH("\\<abcd", perl, " abcd", match_default|match_not_bow, make_array(2, 6, -2, -2)); TEST_REGEX_SEARCH("\\<", perl, "ab ", match_default|match_not_bow, make_array(-2, -2)); TEST_REGEX_SEARCH(".\\<.", perl, "ab", match_default|match_not_bow, make_array(-2, -2)); TEST_REGEX_SEARCH(".\\<.", perl, " b", match_default|match_not_bow, make_array(0, 2, -2, -2)); // word end: TEST_REGEX_SEARCH("abc\\>", perl, "abc", match_default, make_array(0, 3, -2, -2)); TEST_REGEX_SEARCH("abc\\>", perl, "abcd", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("abc\\>", perl, "abc\n", match_default, make_array(0, 3, -2, -2)); TEST_REGEX_SEARCH("abc\\>", perl, "abc::", match_default, make_array(0,3, -2, -2)); TEST_REGEX_SEARCH("abc(?:\\>..|$)", perl, "abc::", match_default, make_array(0, 5, -2, -2)); TEST_REGEX_SEARCH("\\>", perl, " ", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH(".\\>.", perl, " ", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("abc\\>", perl, "abc", match_default|match_not_eow, make_array(-2, -2)); // word boundary: TEST_REGEX_SEARCH("\\babcd", perl, " abcd", match_default, make_array(2, 6, -2, -2)); TEST_REGEX_SEARCH("\\bab", perl, "cab", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("\\bab", perl, "\nab", match_default, make_array(1, 3, -2, -2)); TEST_REGEX_SEARCH("\\btag", perl, "::tag", match_default, make_array(2, 5, -2, -2)); TEST_REGEX_SEARCH("abc\\b", perl, "abc", match_default, make_array(0, 3, -2, -2)); TEST_REGEX_SEARCH("abc\\b", perl, "abcd", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("abc\\b", perl, "abc\n", match_default, make_array(0, 3, -2, -2)); TEST_REGEX_SEARCH("abc\\b", perl, "abc::", match_default, make_array(0, 3, -2, -2)); TEST_REGEX_SEARCH("\\babcd", perl, "abcd", match_default|match_not_bow, make_array(-2, -2)); // within word: TEST_REGEX_SEARCH("\\B", perl, "ab", match_default, make_array(1, 1, -2, -2)); TEST_REGEX_SEARCH("a\\Bb", perl, "ab", match_default, make_array(0, 2, -2, -2)); TEST_REGEX_SEARCH("a\\B", perl, "ab", match_default, make_array(0, 1, -2, -2)); TEST_REGEX_SEARCH("a\\B", perl, "a", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("a\\B", perl, "a ", match_default, make_array(-2, -2)); // buffer operators: TEST_REGEX_SEARCH("\\`abc", perl, "abc", match_default, make_array(0, 3, -2, -2)); TEST_REGEX_SEARCH("\\`abc", perl, "\nabc", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("\\`abc", perl, " abc", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("abc\\'", perl, "abc", match_default, make_array(0, 3, -2, -2)); TEST_REGEX_SEARCH("abc\\'", perl, "abc\n", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("abc\\'", perl, "abc ", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("abc(?:\\'|$)", perl, "abc", match_default, make_array(0, 3, -2, -2)); // word start: TEST_REGEX_SEARCH("[[:<:]]abcd", perl, " abcd", match_default, make_array(2, 6, -2, -2)); TEST_REGEX_SEARCH("[[:<:]]ab", perl, "cab", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("[[:<:]]ab", perl, "\nab", match_default, make_array(1, 3, -2, -2)); TEST_REGEX_SEARCH("[[:<:]]tag", perl, "::tag", match_default, make_array(2, 5, -2, -2)); // word end TEST_REGEX_SEARCH("abc[[:>:]]", perl, "abc", match_default, make_array(0, 3, -2, -2)); TEST_REGEX_SEARCH("abc[[:>:]]", perl, "abcd", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("abc[[:>:]]", perl, "abc\n", match_default, make_array(0, 3, -2, -2)); TEST_REGEX_SEARCH("abc[[:>:]]", perl, "abc::", match_default, make_array(0, 3, -2, -2)); TEST_REGEX_SEARCH("\\Aabc", perl, "abc", match_default, make_array(0, 3, -2, -2)); TEST_REGEX_SEARCH("\\Aabc", perl, "aabc", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("abc\\z", perl, "abc", match_default, make_array(0, 3, -2, -2)); TEST_REGEX_SEARCH("abc\\z", perl, "abcd", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("abc\\Z", perl, "abc\n\n", match_default, make_array(0, 3, -2, -2)); TEST_REGEX_SEARCH("abc\\Z", perl, "abc\n\n", match_default|match_not_eob, make_array(-2, -2)); TEST_REGEX_SEARCH("abc\\Z", perl, "abc", match_default, make_array(0, 3, -2, -2)); TEST_REGEX_SEARCH("\\Gabc", perl, "abc", match_default, make_array(0, 3, -2, -2)); TEST_REGEX_SEARCH("\\Gabc", perl, "dabcd", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("a\\Gbc", perl, "abc", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("a\\Aab", perl, "abc", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("abc(?:\\Z|$)", perl, "abc\n\n", match_default, make_array(0, 3, -2, -2)); }
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 145 ] ] ]
78987c0f50892ffdeffb066d7c15ee524c19bd35
e8d9619e262531453688550db22d0e78f1b51dab
/yapp/notify_imp.cpp
2f2ca9967bbe1c7cdcda6831105773ba2ee9fde2
[]
no_license
sje397/sje-miranda-plugins
e9c562f402daef2cfbe333ce9a8a888cd81c9573
effb7ea736feeab1c68db34a86da8a2be2b78626
refs/heads/master
2016-09-05T16:42:34.162442
2011-05-22T14:48:15
2011-05-22T14:48:15
1,784,020
2
1
null
null
null
null
UTF-8
C++
false
false
4,146
cpp
#include "common.h" #include "resource.h" #include "notify.h" #include "message_pump.h" #include "docs/m_popup2.h" HANDLE hhkShow=0, hhkUpdate=0, hhkRemove=0; //struct int Popup2Show(WPARAM wParam, LPARAM lParam) { HANDLE hNotify = (HANDLE)lParam; PopupData *pd_out = (PopupData *)mir_alloc(sizeof(PopupData)); memset(pd_out, 0, sizeof(PopupData)); PostMPMessage(MUM_CREATEPOPUP, (WPARAM)hNotify, (LPARAM)pd_out); PostMPMessage(MUM_NMUPDATE, (WPARAM)hNotify, (LPARAM)0); return 0; } INT_PTR svcPopup2Show(WPARAM wParam, LPARAM lParam) { return Popup2Show(wParam, lParam); } int Popup2Update(WPARAM wParam, LPARAM lParam) { HANDLE hNotify = (HANDLE)lParam; PostMPMessage(MUM_NMUPDATE, (WPARAM)hNotify, (LPARAM)0); return 0; } int AvatarChanged(WPARAM wParam, LPARAM lParam) { PostMPMessage(MUM_NMAVATAR, (WPARAM)0, (LPARAM)0); return 0; } INT_PTR svcPopup2Update(WPARAM wParam, LPARAM lParam) { return Popup2Update(wParam, lParam); } int Popup2Remove(WPARAM wParam, LPARAM lParam) { HANDLE hNotify = (HANDLE)lParam; PostMPMessage(MUM_NMREMOVE, (WPARAM)hNotify, (LPARAM)0); return 0; } INT_PTR svcPopup2Remove(WPARAM wParam, LPARAM lParam) { return Popup2Remove(wParam, lParam); } INT_PTR svcPopup2DefaultActions(WPARAM wParam, LPARAM lParam) { //PopupWindow *wnd = (PopupWindow *)MNotifyGetDWord((HANDLE)lParam, "Popup2/data", (DWORD)NULL); //if (!wnd) return 0; switch (wParam) { case 0: { // send message //if (wnd->lchContact) CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)wnd->lchContact, 0); //SendMessage(wnd->lchMain, UM_DESTROYPOPUP, 0, 0); break; } case 1: { // dismiss popup //SendMessage(wnd->lchMain, UM_DESTROYPOPUP, 0, 0); break; } } return 0; } INT_PTR CALLBACK DlgProcPopUps(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { /* To change options use MNotifySet*(hNotify, ....) Apply/Cancel is implemented in notify.dll */ HANDLE hNotify = (HANDLE)GetWindowLongPtr(hwnd, GWLP_USERDATA); switch (msg) { case WM_USER+100: { // This will be extendet to handle array of handles for multiselect lParam // will be HANDLE * and wParam wil; store amount of handles passed hNotify = (HANDLE)lParam; SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam); return TRUE; } case WM_COMMAND: // This in different from Miranda options! SendMessage(GetParent(GetParent(hwnd)), PSM_CHANGED, 0, 0); break; } return FALSE; } int NotifyOptionsInitialize(WPARAM wParam,LPARAM lParam) { OPTIONSDIALOGPAGE odp = {0}; odp.cbSize = sizeof(odp); odp.hInstance = hInst; odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_NOTIFY); odp.pszTitle = LPGEN("YAPP Popups"); odp.flags=ODPF_BOLDGROUPS; odp.pfnDlgProc = DlgProcPopUps; CallService(MS_NOTIFY_OPT_ADDPAGE, wParam, (LPARAM)&odp); return 0; } HANDLE hEventNotifyOptInit, hEventNotifyModulesLoaded; HANDLE hAvChangeEvent; int NotifyModulesLoaded(WPARAM wParam,LPARAM lParam) { hEventNotifyOptInit = HookEvent(ME_NOTIFY_OPT_INITIALISE, NotifyOptionsInitialize); hAvChangeEvent = HookEvent(ME_AV_AVATARCHANGED, AvatarChanged); return 0; } HANDLE hServicesNotify[4]; void InitNotify() { hhkShow = HookEvent(ME_NOTIFY_SHOW, Popup2Show); hhkUpdate = HookEvent(ME_NOTIFY_UPDATE, Popup2Update); hhkRemove = HookEvent(ME_NOTIFY_REMOVE, Popup2Remove); hServicesNotify[0] = CreateServiceFunction("Popup2/DefaultActions", svcPopup2DefaultActions); hServicesNotify[1] = CreateServiceFunction(MS_POPUP2_SHOW, svcPopup2Show); hServicesNotify[2] = CreateServiceFunction(MS_POPUP2_UPDATE, svcPopup2Update); hServicesNotify[3] = CreateServiceFunction(MS_POPUP2_REMOVE, svcPopup2Remove); hEventNotifyModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, NotifyModulesLoaded); } void DeinitNotify() { UnhookEvent(hhkShow); UnhookEvent(hhkUpdate); UnhookEvent(hhkRemove); UnhookEvent(hAvChangeEvent); UnhookEvent(hEventNotifyOptInit); UnhookEvent(hEventNotifyModulesLoaded); for(int i = 0; i < 4; i++) DestroyServiceFunction(hServicesNotify[i]); }
[ [ [ 1, 146 ] ] ]
7440eefdba7a095ca0979971dbf7da970247a7a3
38664d844d9fad34e88160f6ebf86c043db9f1c5
/branches/initialize/tagpath/parser/anchor_extract.h
b33c5bebfe7cd88270c93db572e86c289770e1ed
[]
no_license
cnsuhao/jezzitest
84074b938b3e06ae820842dac62dae116d5fdaba
9b5f6cf40750511350e5456349ead8346cabb56e
refs/heads/master
2021-05-28T23:08:59.663581
2010-11-25T13:44:57
2010-11-25T13:44:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,783
h
#ifndef __ANCHOR_EXTRACT_H__ #define __ANCHOR_EXTRACT_H__ #include <iostream> #include <iterator> #include <iomanip> #include <boost/algorithm/string.hpp> #include "tagsax.h" namespace { attr_array::const_iterator find_attribute(const attr_array& arr, const std::string& key_name) { attr_array::const_iterator i = arr.begin(); for (; i!=arr.end(); ++i) { if (boost::iequals(i->first, key_name)) break; } return i; } template<typename T> std::ostream& filter_crlf(std::ostream& os_, T& t) { for (typename T::const_iterator i = t.begin(); i != t.end(); ++i) { if (*i != '\r' && *i != '\n') { os_ << *i; } } return os_; } } struct anchor { std::string title; std::string url; }; template<class Container> class anchor_extract { public: anchor_extract(Container & cont) : care_data_(false) , inserter_(cont) { } bool start_document() { return true; } bool start_element(const crange& name, const attr_array& arr) { if (!name.empty() && boost::iequals(name, "A")) { care_data_ = true; // read href attr_array::const_iterator i = find_attribute(arr, "HREF"); if (i != arr.end()) { current_anchor_.url = i->second.to_string(); // filter_crlf(os_, i->second); // os_ << '\n'; } #if 0 else { i = find_attribute(arr, "NAME"); assert((arr.size() && i != arr.end()) || !arr.size()); for (attr_array::const_iterator i=arr.begin(); i!=arr.end(); ++i) { os_ << i->first << "=" << i->second << "\n"; } } #endif } return true; } bool characters(const crange& text) { if (care_data_) { current_anchor_.title = text.to_string(); // os_ << " "; // filter_crlf(os_, text) << '\n'; } return true; } bool end_element(const crange& name) { if (care_data_) { care_data_ = false; *inserter_ = current_anchor_; } return true; } bool entities(const crange& text) { return true; } bool script(const crange& text, const attr_array&) { return true; } bool end_document() { return true; } std::back_insert_iterator<Container> inserter_; anchor current_anchor_; bool care_data_; }; #endif // __ANCHOR_EXTRACT_H__
[ "ken.shao@ba8f1dc9-3c1c-0410-9eed-0f8a660c14bd" ]
[ [ [ 1, 124 ] ] ]
4824d02b4fede750c2432ed687351a79c50e4e40
3d7fc34309dae695a17e693741a07cbf7ee26d6a
/aluminizer/scan_variable.cpp
224fa4c3c0fe0d581d8e0cf001bde456394e79fe
[ "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
347
cpp
#ifdef PRECOMPILED_HEADER #include "common.h" #endif #include "scan_variable.h" #include "ScanSource.h" void source_scan_variable::set_scan_positionI(double d) { pSource->SetScanOutput(d); } void source_scan_variable::set_default_state(double d) { scan_variable::set_default_state(d); pSource->setNonScanningValue(d); }
[ "trosen@814e38a0-0077-4020-8740-4f49b76d3b44" ]
[ [ [ 1, 19 ] ] ]
d661aba12073fa29ea4ec8675478ead9cab39f8f
9f2d447c69e3e86ea8fd8f26842f8402ee456fb7
/shooting2011/shooting2011/__patternComposer.h
b871bee0dc3fa0da5a9c199ca1079d958bc8ca46
[]
no_license
nakao5924/projectShooting2011
f086e7efba757954e785179af76503a73e59d6aa
cad0949632cff782f37fe953c149f2b53abd706d
refs/heads/master
2021-01-01T18:41:44.855790
2011-11-07T11:33:44
2011-11-07T11:33:44
2,490,410
0
1
null
null
null
null
UTF-8
C++
false
false
2,246
h
template<class PatternType> void PatternComposer<PatternType>::init(){ currentPattern = patterns.begin(); frameCounter = 0; } template<class PatternType> PatternType *PatternComposer<PatternType>::getCurrentPattern(){ return currentPattern->second; } template<class PatternType> void PatternComposer<PatternType>::countUp(){ if(currentPattern->first >= 0 && ++frameCounter >= currentPattern->first){ frameCounter = 0; if(++currentPattern == patterns.end()){ currentPattern = patterns.begin(); } } } template<class PatternType> PatternComposer<PatternType>::PatternComposer():isInitialized(false){} template<class PatternType> PatternComposer<PatternType>::~PatternComposer(){ for(typename deque<pair<int, PatternType *> >::iterator i = patterns.begin(); i != patterns.end(); ++i){ delete i->second; } } template<class PatternType> PatternComposer<PatternType> *PatternComposer<PatternType>::add(int frame, PatternType *pattern){ if(frame != 0){ patterns.push_back(make_pair(frame, pattern)); } return this; } template<class PatternType> void PatternComposer<PatternType>::action(MovingObject *owner){ if(patterns.empty()){ return; } if(!isInitialized){ init(); isInitialized = true; // bug fix arai tabunhituyou } currentPattern->second->action(owner); countUp(); } /* template<class PatternType> void PatternComposer<PatternType>::vanishAction(MovingObject *owner){ if(patterns.empty()){ return; } if(!isInitialized){ init(); isInitialized = true; // bug fix arai tabunhituyou } currentPattern->second->vanishAction(owner); countUp(); } //*/ /* template<class PatternType> ParallelPatternComposer<PatternType>::~ParallelPatternComposer(){ for(typename deque<PatternType *>::iterator i = patterns_.begin(); i != patterns_.end(); ++i){ delete *i; } } */ template<class PatternType> ParallelPatternComposer<PatternType> *ParallelPatternComposer<PatternType>::add(PatternType *pattern){ patterns_.push_back(pattern); } template<class PatternType> void ParallelPatternComposer<PatternType>::action(MovingObject *owner){ for(size_t i = 0; i < patterns_.size(); ++i){ patterns_[i]->action(owner); } }
[ [ [ 1, 3 ], [ 6, 9 ], [ 11, 14 ], [ 21, 27 ], [ 31, 34 ], [ 39, 42 ], [ 52, 55 ], [ 65, 66 ] ], [ [ 4, 5 ], [ 10, 10 ], [ 15, 20 ], [ 28, 30 ], [ 35, 38 ], [ 43, 51 ], [ 56, 64 ], [ 71, 73 ], [ 78, 78 ], [ 83, 85 ] ], [ [ 67, 70 ], [ 74, 77 ], [ 79, 82 ], [ 86, 86 ] ] ]
b2dc1e05f251d99e3f549fcc14354e99138772fe
d37a1d5e50105d82427e8bf3642ba6f3e56e06b8
/DVR/DVRMD_Filter/DVRMD_Filter/FilePlaybackSettings.h
c6eed0d488c516c03fea200a80a376af0f237fd3
[]
no_license
080278/dvrmd-filter
176f4406dbb437fb5e67159b6cdce8c0f48fe0ca
b9461f3bf4a07b4c16e337e9c1d5683193498227
refs/heads/master
2016-09-10T21:14:44.669128
2011-10-17T09:18:09
2011-10-17T09:18:09
32,274,136
0
0
null
null
null
null
UTF-8
C++
false
false
660
h
#pragma once // CFilePlaybackSettings dialog class CPlayerDlg; class CFilePlaybackSettingsDlg : public CPropertyPage { DECLARE_DYNAMIC(CFilePlaybackSettingsDlg) public: CFilePlaybackSettingsDlg(CPlayerDlg* pMainDlg); virtual ~CFilePlaybackSettingsDlg(); // Dialog Data enum { IDD = IDD_FILE_SETTINGS }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support DECLARE_MESSAGE_MAP() public: afx_msg void OnBnClickedOpenfile(); CString GetPathName(); void SetPathName(LPCTSTR szPath); protected: CString m_csMediaFile; CPlayerDlg* m_pMainDlg; public: virtual BOOL OnInitDialog(); };
[ "[email protected]@27769579-7047-b306-4d6f-d36f87483bb3" ]
[ [ [ 1, 33 ] ] ]
77edbc433a10ce8f53f0ed92133e1f8c024eed98
b03f367d0c655c7776c8474c5e21a44d0890ea3d
/magnet/cpp/magnet.cpp
8255de45dfeea2d32f66099fb48a641131ae968a
[]
no_license
Jacobi20/nano-vis
0f94c77c5a03a5d1185f654528c69e5841571cb9
9c713a5f20c5b8c676e0a0847c8131e2a996d784
refs/heads/master
2021-01-20T11:31:23.350419
2011-08-09T13:22:57
2011-08-09T13:22:57
37,013,226
0
0
null
null
null
null
UTF-8
C++
false
false
9,450
cpp
/* The MIT License Copyright (c) 2011 Escience Research Institute 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 "../../engine/engine.h" #include "../../engine/core/windows/win_key_list.h" #include "magnet.h" DLL_EXPORT IGame *CreateGame() { return new MagnetGame(); } /*----------------------------------------------------------------------------- MAGNET -----------------------------------------------------------------------------*/ // // MagnetGame::MagnetGame // MagnetGame::MagnetGame( void ) { time = 0; current_item = -1; srand( sys()->Milliseconds() ); //view.center = EPoint(-15,-15, 5); view.yaw = 45; view.pitch = 15; rs()->Install(); //InputSystem()->SetInputMode( IN_KB_SCAN ); InputSystem()->SetInputMode( 0 ); CoreExecuteString("require('shaders')"); // load base mesh : IPxTriMesh base_mesh = ge()->LoadMeshFromFile("scene.esx|base"); // create visible base object : base_rend = rs()->GetFRScene()->AddEntity(); base_rend->SetMesh( base_mesh ); // create physical base object base_phys = phys()->AddEntity(); base_phys->SetMesh( base_mesh ); base_phys->SetStatic(); base_phys->Spawn(); // create light : rs()->GetFRScene()->SetAmbientLevel( (EColor::kWhite + EColor::kBlue) * 0.0 ) ; light = rs()->GetFRScene()->AddLight(); light->SetColor( EColor::kWhite * 4 ); light->SetPose( EPoint(0,0,15), EQuaternion::kIdentity ); light->SetRadius( 30, 30 ); light->SetType( RS_LIGHT_SPOT_SHADOW ); light->SetMask("mask.tga"); //light->SetType( RS_LIGHT_OMNI ); EMath::Randf(); // create magnets : for ( float x=-5; x<=5; x+=10 ) { for ( float y=-5; y<=5; y+=11 ) { Magnet magnet; IPxTriMesh vis_mesh = ge()->LoadMeshFromFile("scene.esx|vis_magnet"); IPxTriMesh phys_mesh = ge()->LoadMeshFromFile("scene.esx|phys_magnet"); EPoint p = EPoint(x,y,EMath::Randf(2,5)); EQuaternion q = EQuaternion::FromAngles(EMath::Randf(-180,180), EMath::Randf(-180,180), EMath::Randf(-180,180)); //EQuaternion q = EQuaternion::FromAngles(EMath::Randf(-5,5), EMath::Randf(-5,5), EMath::Randf(-5,5)); magnet.rend_obj = rs()->GetFRScene()->AddEntity(); magnet.rend_obj->SetMesh( vis_mesh ); magnet.rend_obj->SetPose( p, q ); magnet.phys_obj = phys()->AddEntity(); magnet.phys_obj->SetMass( 10 ); magnet.phys_obj->SetMesh( phys_mesh ); magnet.phys_obj->SetPose( p, q ); magnet.phys_obj->SetDynamic(); magnet.phys_obj->Spawn(); magnets.push_back( magnet ); } } volume = rs()->GetFRScene()->AddVolume(); volume->LoadColormap("volume/green.tga"); volume->SetBounds(EBBox(EPoint(), 20, 20, 20)); volume->SetResolution(32, 32, 32); volume->SetInterestRange(0, 10.0f); //volume->LoadColormap("volume/iso.png"); //volume->LoadFromCube("volume/test01.cube"); //volume->LoadFromRAW("volume/bonsai_turn.raw", 256, 256, 256); //volume->SetPose(EPoint(0, 0, 2), EQuaternion::FromAngles(0, 90, 0)); //phys()->SetGravity( EVector::kNegZ ); } // // MagnetGame::~MagnetGame // MagnetGame::~MagnetGame( void ) { rs()->Uninstall(); } // INFO : change this value : const float MAGNETIC_CONST = 200.0f; EVector MagneticForce( const EPoint &a, const EPoint &b ) { EVector ab = EVector(a, b); float len2 = ab.LengthSqr(); ab.NormalizeSelf(); ab = ab * (MAGNETIC_CONST / (1+len2)); return ab; } // // MagnetGame::Frame // void MagnetGame::Frame( uint dtime ) { time += dtime; float ftime = dtime / 1000.0f; DEBUG_STRING("fps : %f", 1000.0f / dtime ); DEBUG_STRING("View mode : [Space]"); DEBUG_STRING("Switch dipoles : [<] [>]"); IInputSystem::S3DMouseInput s3dmin; InputSystem()->GetS3DMouseInput( &s3dmin ); if (current_item < 0) { // update camera direction, if no dipole chosen view.yaw += 0.01f * s3dmin.rotate[2]; view.pitch += 0.01f * s3dmin.rotate[0]; view.roll += 0.01f * s3dmin.rotate[1]; } if (InputSystem()->IsKeyPressed( KEY_LEFT )) view.yaw += (90 * ftime); if (InputSystem()->IsKeyPressed( KEY_RIGHT )) view.yaw -= (90 * ftime); if (InputSystem()->IsKeyPressed( KEY_UP )) view.pitch += (45 * ftime); if (InputSystem()->IsKeyPressed( KEY_DOWN )) view.pitch -= (45 * ftime); view.pitch = clamp<float>( view.pitch, 5, 90 ); EPoint cam_p; EQuaternion cam_q; SetupCamera(cam_p, cam_q); // calculate 3d mouse motion vector in camera space EVector move_direction = EVector(s3dmin.translate[0], -s3dmin.translate[2],s3dmin.translate[1]).Rotate(cam_q); char ch = InputSystem()->GetKbChar(); if (ch == '.') current_item = (current_item + 1) % magnets.size(); if (ch == ',') current_item = (current_item - 1) % magnets.size(); if (ch == ' ') current_item = -1; if (current_item >= 0) { IPxPhysEntity phys_obj = magnets[current_item].phys_obj; // add force phys_obj->AddForce(move_direction * 0.1f); float yaw = s3dmin.rotate[2] * ftime; float pitch = s3dmin.rotate[0] * ftime; float roll = s3dmin.rotate[1] * ftime; // compute torque EQuaternion q = EQuaternion::FromAngles(yaw, pitch, roll); EVector vn(q.x, q.y, q.z); if (vn.Length() > 1e-4) { vn.NormalizeSelf(); vn = vn * acos(q.w)*2.0 * 50.0; phys_obj->AddTorque(vn); } EPoint p; phys_obj->GetPose(p, q); rs()->GetDVScene()->DrawBox(EBBox(p, 2, 2, 2), EColor(1, 1, 1, 1)); } // update dipole positions : for (uint i=0; i<magnets.size(); i++) { EPoint p; EQuaternion q; magnets[i].phys_obj->GetPose(p, q); magnets[i].rend_obj->SetPose(p, q); } // update dipole forces : for (uint i=0; i<magnets.size(); i++) { IPxPhysEntity a = magnets[i].phys_obj; EPoint p; EQuaternion q; a->GetPose(p, q); EPoint pp_a = EPoint( 0.5,0,0).Transform( EMatrix::FromPose(p,q) ); EPoint pn_a = EPoint(-0.5,0,0).Transform( EMatrix::FromPose(p,q) ); magnets[i].pp = pp_a; magnets[i].pn = pn_a; //rs()->GetDVScene()->DrawPoint( pp_a, 0.25, EColor::kRed ); //rs()->GetDVScene()->DrawPoint( pn_a, 0.25, EColor::kBlue ); for (uint j=0; j<magnets.size(); j++) { IPxPhysEntity b = magnets[j].phys_obj; EPoint p; EQuaternion q; b->GetPose(p, q); EPoint pp_b = EPoint( 0.5,0,0).Transform( EMatrix::FromPose(p,q) ); EPoint pn_b = EPoint(-0.5,0,0).Transform( EMatrix::FromPose(p,q) ); EVector fpp = MagneticForce(pp_a, pp_b); EVector fnn = MagneticForce(pn_a, pn_b); EVector fpn = MagneticForce(pp_a, pn_b) * (-1); EVector fnp = MagneticForce(pn_a, pp_b) * (-1); b->AddForceAtPos( fpp, pp_b ); b->AddForceAtPos( fnn, pn_b ); b->AddForceAtPos( fnp, pp_b ); b->AddForceAtPos( fpn, pn_b ); } } // update volume data : volume->UpdateData(this); } /*----------------------------------------------------------------------------- Internal stuff : -----------------------------------------------------------------------------*/ void MagnetGame::SetupCamera( EPoint & p, EQuaternion & q ) { uint w, h; rs()->GetScreenSize(w, h); float t = time / 1000.0f; float a = view.yaw; float b = view.pitch; float x = 18 * cos(EMath::Rad(a)) * cos(EMath::Rad(b)); float y = 18 * sin(EMath::Rad(a)) * cos(EMath::Rad(b)); float z = 18 * sin(EMath::Rad(b)); EQuaternion z_up = EQuaternion::RotateAroundAxis( -PI/2.0f, EVector(0,0,1)) * EQuaternion::RotateAroundAxis(PI/2.0, EVector(1,0,0)); p = EPoint( x,y,z ) + EVector(view.center); q = EQuaternion::FromAngles( 180+a, b, 0) * z_up; rs()->GetFRScene()->SetProjection( 0.1f, 1000.0f, 2000.0f, 2000.0f / w * h ); rs()->GetFRScene()->SetView( p, q ); rs()->GetDVScene()->SetProjection( 0.1f, 1000.0f, 2000.0f, 2000.0f / w * h ); rs()->GetDVScene()->SetView( p, q ); } /*----------------------------------------------------------------------------- FRVolume::DataProvider : -----------------------------------------------------------------------------*/ float MagnetGame::Value( const EPoint &local_point ) const { //return 0.5; return local_point.Distance( EPoint(0,0,0) ); /*float val = 0.0; for (int i = 0; i < (int)magnets.size(); ++i) { float dn = magnets[i].pn.Distance(local_point); float dp = magnets[i].pp.Distance(local_point); val += ( 1.0 / dp + 1.0 / dn ); } return val;*/ }
[ "demiurghg@6d03c5d0-0fef-11df-8179-3f26cfb4ba5f", "zzznah@6d03c5d0-0fef-11df-8179-3f26cfb4ba5f" ]
[ [ [ 1, 40 ], [ 42, 44 ], [ 46, 50 ], [ 53, 79 ], [ 83, 108 ], [ 111, 111 ], [ 115, 115 ], [ 123, 164 ], [ 170, 176 ], [ 186, 190 ], [ 213, 222 ], [ 224, 235 ], [ 238, 264 ], [ 266, 272 ], [ 274, 285 ], [ 288, 293 ], [ 296, 300 ], [ 303, 306 ], [ 309, 309 ], [ 311, 312 ] ], [ [ 41, 41 ], [ 45, 45 ], [ 51, 52 ], [ 80, 82 ], [ 109, 110 ], [ 112, 114 ], [ 116, 122 ], [ 165, 169 ], [ 177, 185 ], [ 191, 212 ], [ 223, 223 ], [ 236, 237 ], [ 265, 265 ], [ 273, 273 ], [ 286, 287 ], [ 294, 295 ], [ 301, 302 ], [ 307, 308 ], [ 310, 310 ] ] ]
302956f86183b6296662b7a1e6855e8408aed1ef
6f62b87010214a4a77d66c1df0d758ba65cd428c
/allocator_test.cpp
835c82dd88c9cf04c0bc3dc4023af64aa892cd60
[]
no_license
cutepig/alligator
94eaa20ae1416fc1dc18e36e7ae3ba4e359410ac
8816de6f2c3eefdcd881bda7f30373b7026c7055
refs/heads/master
2021-01-01T18:37:23.331664
2011-09-16T09:40:12
2011-09-16T09:40:12
2,398,229
0
0
null
null
null
null
UTF-8
C++
false
false
5,896
cpp
#include <iostream> #include "allocator.h" #include <list> #include <vector> #include <map> #include <cstdlib> #include <cstring> template<typename T> void print_container(const T &container) { for(typename T::const_iterator it = container.begin(); it != container.end(); it++ ) std::cout << *it << " "; } int main() { int i, j; // predeclare some looping variables const int COUNT_I = 5, COUNT_J = 10; //=================================== std::cout << "list block_allocator test" << std::endl; std::list<int, cutepig::block_allocator<int> > iblist; for(i=0; i<COUNT_I; i++) { std::cout << "inserting 10 values into list" << std::endl; for(j=0; j<COUNT_J; j++) { iblist.push_back(i*COUNT_J+j); } } for(i=0; i<COUNT_I; i++) { std::cout << "removing 10 values from list" << std::endl; for(j=0; j<COUNT_J; j++) { // little confusing trick if(j&1) iblist.pop_front(); else iblist.pop_back(); print_container(iblist); std::cout << std::endl; } } //=================================== // on gcc, list allocates elements at a time std::cout << "list test" << std::endl; std::list<int, cutepig::malloc_allocator<int> > ilist; for(i=0; i<COUNT_I; i++) { std::cout << "inserting 10 values into list" << std::endl; for(j=0; j<COUNT_J; j++) { ilist.push_back(i); } } for(i=0; i<COUNT_I; i++) { std::cout << "removing 10 values from list" << std::endl; for(j=0; j<COUNT_J; j++) { // little confusing trick if(i&1) ilist.pop_front(); else ilist.pop_back(); } } //==================================== // test what happens when we "copy" a sequence of elements std::cout << "list test 2" << std::endl; for(i=0; i<COUNT_I; i++) { std::cout << "inserting 10 values into list" << std::endl; for(j=0; j<COUNT_J; j++) { ilist.push_back(i); } } std::list<int, cutepig::malloc_allocator<int> > ilist2; std::cout << "list::assign( begin, end)" << std::endl; // on gcc, this copies elements 1 by 1 ilist2.assign( ilist.begin(), ilist.end() ); std::cout << "list copy ctor" << std::endl; // on gcc, this copies elements 1 by 1 std::list<int, cutepig::malloc_allocator<int> > ilist3( ilist2 ); return 0; //==================================== // on gcc, vector allocation policy seems to be N rounded to next 2^x std::cout << "vector test" << std::endl; std::vector<float, cutepig::malloc_allocator<float> > ivector; for(i=0; i<COUNT_I; i++) { std::cout << "inserting 10 values into vector" << std::endl; for(j=0; j<COUNT_J; j++) { ivector.push_back(i); } } for(i=0; i<COUNT_I; i++) { std::cout << "removing 10 values from vector" << std::endl; for(j=0; j<COUNT_J; j++) { // HMM, random remove? ivector.pop_back(); } } //==================================== #if 0 // vector test 2, initialize with many values std::cout << "vector test 2" << std::endl; const int LARGE_SIZE = 100000000; const int LARGE_CHUNKS = 16; std::vector<int, cutepig::malloc_allocator<int> > ivector2( LARGE_SIZE, 12345678 ); for(i=0; i < LARGE_CHUNKS; i++) { std::size_t offset = (((LARGE_CHUNKS - 1) - i ) * (LARGE_SIZE / LARGE_CHUNKS)); std::cout << "removing from vector range " << std::dec << offset << " " << ivector2.size() << std::endl; // on gcc, this doesnt free any memory // ivector2.erase( ivector2.begin() + offset, ivector2.end()); // on gcc, this doesnt free any memory ivector2.resize( offset ); } // on gcc, even this doesnt free memory! ivector2.resize(0); #endif //==================================== // lets see what map does for allocation // on gcc, map allocates elements at a time std::cout << "map test" << std::endl; std::map< int, int, std::less<int>, cutepig::malloc_allocator<std::pair<int, int> > > imap; for(i = 0; i < COUNT_I; i++ ) { std::cout << "inserting 10 values to map" << std::endl; for(j = 0; j < COUNT_J; j++ ) { imap[ rand() & 0xffff ] = rand(); } } //==================================== // gcc string seems to keep minimum 30 elements and then allocates more when needed // doesnt seem to release memory when shortened (or even cleared) // basically similar allocation strategy than with vector // string test.. override stl string with this std::cout << "string test" << std::endl; typedef std::basic_string<char, std::char_traits<char>, cutepig::malloc_allocator<char> > string; string s; // just some random stuff std::cout << "appending.. " << s << " " << s.size() << std::endl; s += "jees jees dfadfadf khhk"; std::cout << "appending.. " << s << " " << s.size() << std::endl; s += "kdhafhadfhkadfh lkjkljdf"; std::cout << "replacing.. " << s << " " << s.size() << std::endl; s = "dafljdhfhfd"; std::cout << "appending.. " << s << " " << s.size() << std::endl; s += "jkldfljdflkjdafadfadfadfadffg f gfg fasgsfgf fg"; std::cout << "appending.. " << s << " " << s.size() << std::endl; s += "adfkjdfllkjkjdfdfdff gsfg sfg sfg sfgfsgsfgfsgsfg fg fgfgfg"; std::cout << "erasing.. " << s << " " << s.size() << std::endl; s.erase( s.size() / 2 ); std::cout << "erasing.. " << s << " " << s.size() << std::endl; s.erase( s.size() / 2 ); std::cout << "erasing.. " << s << " " << s.size() << std::endl; s.erase( s.size() / 2 ); std::cout << "erasing.. " << s << " " << s.size() << std::endl; s.erase( s.size() / 2 ); std::cout << "erasing.. " << s << " " << s.size() << std::endl; s.erase( s.size() / 2 ); std::cout << "clearing out.. " << s << " " << s.size() << std::endl; s.clear(); std::cout << "ok..?" << std::endl; s = "dippidappa"; std::cout << "ok.." << std::endl; }
[ [ [ 1, 186 ] ] ]
4d9493e534a895f42bebf9e521286dd9d818639d
051ee8974ba920bf92c4456ce7fd92154068764f
/boolib/algo/Karatsuba.h
709c9051128a0efd7be61327612ad1f8fedc24ac
[]
no_license
k06a/boolib
ab0f379ad9079434e91452d7287509b843dc2641
9b154e6d54b7e54b6fe847d53580ec61fd358c20
refs/heads/master
2016-09-06T18:25:02.912776
2010-12-26T19:11:21
2010-12-26T19:11:21
32,887,618
0
0
null
null
null
null
UTF-8
C++
false
false
3,245
h
#ifndef KARATSUBA_H #define KARATSUBA_H #include <stdlib.h> #include <util/LittleBigEndian.h> namespace boolib { namespace algo { // // Karatsuba multiplication algorhytm // // high low high low high low // +------+------+------+------+ +------+------+ +------+------+ // | r3 | r2 | r1 | r0 | = | x1 | x0 | * | y1 | y0 | // +------+------+------+------+ +------+------+ +------+------+ // | | | // +-------------+-------------+ // add | x1*y1 | x0*y0 | // +----+-+------+------+------+ // | | | // +-+------+------+ // add | x0*y1 + x1*y0 | // +-+------+------+ // // // Params: // T - is type of x0, x1, y0 and y1 halves // T2 - is type of x, y and half of res // template<typename T, typename T2> inline void Karatsuba_multiply(const T * x, const T * y, T2 * res) { if (IS_LITTLE_ENDIAN) return Karatsuba_multiply_little_endian(x,y,res); if (IS_BIG_ENDIAN) return Karatsuba_multiply_big_endian(x,y,res); } template<typename T, typename T2> inline void Karatsuba_multiply_little_endian(const T * x, const T * y, T2 * res) { // Define vars (differs from byte order) #define ptrRes ((T*)res) T2 & lowWord = (T2&)(ptrRes[0]); T2 & midWord = (T2&)(ptrRes[1]); T2 & highWord = (T2&)(ptrRes[2]); T & highByte = (T &)(ptrRes[3]); const T & x0 = x[0]; const T & x1 = x[1]; const T & y0 = y[0]; const T & y1 = y[1]; // Multiply action lowWord = x0 * y0; highWord = x1 * y1; T2 m1 = x0 * y1; T2 m2 = x1 * y0; midWord += m1; if (midWord < m1) highByte++; midWord += m2; if (midWord < m2) highByte++; } template<typename T, typename T2> inline void Karatsuba_multiply_big_endian(const T * x, const T * y, T2 * res) { // Define vars (differs from byte order) #define ptrRes ((T*)res) T2 & highWord = *(T2*)(ptrRes+0); T2 & midWord = *(T2*)(ptrRes+1); T2 & lowWord = *(T2*)(ptrRes+2); T & highByte = *(T *)(ptrRes+0); const T & x0 = x[1]; const T & x1 = x[0]; const T & y0 = y[1]; const T & y1 = y[0]; // Multiply action lowWord = x0 * y0; highWord = x1 * y1; T m1 = x0 * y1; T m2 = x1 * y0; midWord += m1; if (midWord < m1) highByte++; midWord += m2; if (midWord < m2) highByte++; } } // namespace algo } // namespace boolib #endif // KARATSUBA_H
[ "k06a@localhost" ]
[ [ [ 1, 109 ] ] ]
f9b66183ac73301091ea5448a925d140239bd961
8b3186e126ac2d19675dc19dd473785de97068d2
/bmt_prod/core/scene.h
d33a5d22930812492b66eb0372f76f3cad7e337c
[]
no_license
leavittx/revenge
e1fd7d6cd1f4a1fb1f7a98de5d16817a0c93da47
3389148f82e6434f0619df47c076c60c8647ed86
refs/heads/master
2021-01-01T17:28:26.539974
2011-08-25T20:25:14
2011-08-25T20:25:14
618,159
2
0
null
null
null
null
UTF-8
C++
false
false
868
h
#pragma once /* An abstract base class for a single scene/effect in the demo. The timeline contains references to these. */ class Scene { public: Scene(); //pure virtual destructor so the correct one will be called once the effect is deleted. virtual ~Scene() = 0; //does all the initialization in the effect. Allocation etc. should be put here virtual void init() = 0; //frees all memory etc. virtual void release() = 0; //updates the effect visuals. Called at a constant framerate so fixed values can and should be used. virtual void update() = 0; //draws the effect virtual void draw() = 0; //sets the normalized position of the effect (pos == 0 is the beginning of the effect, pos == 1 is the end) void setPosition(const float t); protected: float m_pos; //normalized position in the effect private: };
[ [ [ 1, 35 ] ] ]
5afcb3f06ce6182b82cd562117a37394aab2ded0
a31e04e907e1d6a8b24d84274d4dd753b40876d0
/MortScript/FunctionsSystem.cpp
77473ebf1182086491eeb69ba40ffd2cf93f1c48
[]
no_license
RushSolutions/jscripts
23c7d6a82046dafbba3c4e060ebe3663821b3722
869cc681f88e1b858942161d9d35f4fbfedcfd6d
refs/heads/master
2021-01-10T15:31:24.018830
2010-02-26T07:41:17
2010-02-26T07:41:17
47,889,373
0
0
null
null
null
null
UTF-8
C++
false
false
24,545
cpp
#ifdef SMARTPHONE #include <windows.h> #include "smartphone/mortafx.h" #else #include "stdafx.h" #endif #include <string.h> #include "winuser.h" #include "inifile.h" #include "interpreter.h" #include "deelx.h" #ifdef SMARTPHONE #include <bthutil.h> #include "FctFlight.h" #endif BOOL CALLBACK SearchWindowText( HWND hwnd, LPARAM lParam ); time_t SystemTimeToUnixTime( const SYSTEMTIME &st ); void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst); time_t FileTimeToUnixTime( const FILETIME &ft ); #ifndef SMARTPHONE #include "mortscriptapp.h" extern CMortScriptApp theApp; #else extern HINSTANCE g_hInst; #endif extern CInterpreter *CurrentInterpreter; //jwz::add #ifndef PNA extern CStr Proxy; #include "wininet.h" #endif #ifdef SMARTPHONE #define LoadStdCursor(x) LoadCursor(NULL,x) #else #define LoadStdCursor(x) theApp.LoadStandardCursor(x) #endif #include "deelx.h" //RegExLib #if !defined( PNA ) && !defined( DESKTOP ) #include "ras.h" #endif #ifdef DESKTOP #include "vc6\stdafx.h" #include "vc6\resource.h" #include <math.h> #endif #include "ValueArray.h" #include "FunctionsSystem.h" #include "Interpreter.h" #include "variables.h" CValue FctExternalPowered( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; #ifdef DESKTOP rc = 1L; #else SYSTEM_POWER_STATUS_EX pwrStatus; GetSystemPowerStatusEx( &pwrStatus, TRUE ); if ( pwrStatus.ACLineStatus == 1 || pwrStatus.BatteryFlag == 8 /*charging*/ || pwrStatus.BatteryFlag == 128 /* no battery */ || pwrStatus.BatteryLifePercent > 100 ) rc = 1L; else rc = 0L; #endif return rc; } CValue FctBatteryPercentage( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; #ifdef DESKTOP rc = 100L; #else SYSTEM_POWER_STATUS_EX pwrStatus; GetSystemPowerStatusEx( &pwrStatus, TRUE ); if ( pwrStatus.BatteryLifePercent > 100 ) pwrStatus.BatteryLifePercent = 100; rc = (long)pwrStatus.BatteryLifePercent; #endif return rc; } CValue FctBackupBatteryPercentage( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; #ifdef DESKTOP rc = 100L; #else SYSTEM_POWER_STATUS_EX pwrStatus; GetSystemPowerStatusEx( &pwrStatus, TRUE ); if ( pwrStatus.BackupBatteryLifePercent > 100 ) pwrStatus.BackupBatteryLifePercent = 100; rc = (long)pwrStatus.BackupBatteryLifePercent; #endif return rc; } CValue FctActiveProcess( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; if ( params.GetSize() > 1 ) { errorMessage = InvalidParameterCount + L"'ActiveProcess'"; error = 9; return CValue(); } //if ( LoadToolhelp() ) //{ HWND hwnd = ::GetForegroundWindow(); // Sometimes, after a window was closed, Windows isn't able to return the active window. // So wait until one becomes active... for ( int retry = 0; hwnd == NULL && retry < 10; retry++ ) { Sleep(10); hwnd = ::GetForegroundWindow(); } CStr procName; DWORD dwProcessID; ::GetWindowThreadProcessId(hwnd,&dwProcessID); int e = GetLastError(); if (dwProcessID) { procName = GetProcessExePath( dwProcessID ); if ( params.GetSize() == 0 || (long)params[0] == 0 ) { int pos = procName.ReverseFind( '\\' ); if ( pos == -1 ) rc = procName; else rc = procName.Mid( pos+1 ); } else { rc = procName; } } //} //else //{ // errorMessage = L"'ActiveProcess' requires toolhelp.dll on your device"; // error = 9; // return CValue(); //} return rc; } CValue FctWindowProcess( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; if ( params.GetSize() < 1 || params.GetSize() > 2 ) { errorMessage = InvalidParameterCount + L"'WindowProcess'"; error = 9; return CValue(); } //if ( LoadToolhelp() ) //{ HWND hwnd = FindWindowMy( params[0] ,0); CStr procName; DWORD dwProcessID; ::GetWindowThreadProcessId(hwnd,&dwProcessID); if (dwProcessID) { procName = GetProcessExePath( dwProcessID ); if ( params.GetSize() == 1 || (long)params[1] == 0 ) { int pos = procName.ReverseFind( '\\' ); if ( pos == -1 ) rc = procName; else rc = procName.Mid( pos+1 ); } else { rc = procName; } } //} //else //{ // errorMessage = L"'WindowProcess' requires toolhelp.dll on your device"; // error = 9; // return CValue(); //} return rc; } CValue FctProcExists( CValueArray &params, int &error, CStr &errorMessage ) { if ( params.GetSize() != 1 ) { errorMessage = InvalidParameterCount + L"'ProcExists'"; error = 9; return CValue(); } CValue rc; rc = 0L; if ( LoadToolhelp() ) { CStr search = params[0]; BOOL fullPath = FALSE; if ( search.Find('\\') != -1 ) fullPath = TRUE; HANDLE procSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS|TH32CS_SNAPNOHEAPS, 0 ); if ( procSnap == NULL || (int)procSnap == -1 ) { error = GetLastError(); errorMessage.Format( L"ProcExists failed, error code %d", error ); error = 9; } PROCESSENTRY32 procEntry; procEntry.dwSize = sizeof( procEntry ); if ( procSnap != NULL && (int)procSnap != -1 && Process32First( procSnap, &procEntry ) ) { CStr procName; do { if ( fullPath ) { procName = GetProcessExePath( (DWORD)procEntry.th32ProcessID, procEntry.szExeFile ); } else { procName = procEntry.szExeFile; } //Debug(procName,(long)procEntry.th32ProcessID); if ( procName.CompareNoCase( search ) == 0 ) { rc = 1L; break; } procEntry.dwSize = sizeof( procEntry ); } while ( Process32Next( procSnap, &procEntry ) ); } if ( procSnap != NULL && (int)procSnap != -1 ) #ifndef DESKTOP CloseToolhelp32Snapshot( procSnap ); #else CloseHandle( procSnap ); #endif } else { errorMessage = L"'ProcExists' requires toolhelp.dll on your device"; error = 9; return CValue(); } return rc; } //jwz::add CValue FctGetWindowFromProc( CValueArray &params, int &error, CStr &errorMessage ) { if ( params.GetSize() != 1 ) { errorMessage = InvalidParameterCount + L"'GetWindowFromProc'"; error = 9; return CValue(); } CValue rc=L""; if ( LoadToolhelp() ) { CStr search = params[0]; BOOL fullPath = FALSE; if ( search.Find('\\') != -1 ) fullPath = TRUE; HANDLE procSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS|TH32CS_SNAPNOHEAPS, 0 ); if ( procSnap == NULL || (int)procSnap == -1 ) { error = GetLastError(); errorMessage.Format( L"GetWindowFromProc failed, error code %d", error ); error = 9; } PROCESSENTRY32 procEntry; procEntry.dwSize = sizeof( procEntry ); if ( procSnap != NULL && (int)procSnap != -1 && Process32First( procSnap, &procEntry ) ) { CStr procName; do { if ( fullPath ) { procName = GetProcessExePath( (DWORD)procEntry.th32ProcessID, procEntry.szExeFile ); } else { procName = procEntry.szExeFile; } if ( procName.CompareNoCase( search ) == 0 && (DWORD)procEntry.th32ParentProcessID == 0) { rc = GetWindowFromProcess((DWORD)procEntry.th32ProcessID); break; } procEntry.dwSize = sizeof( procEntry ); } while ( Process32Next( procSnap, &procEntry ) ); } if ( procSnap != NULL && (int)procSnap != -1 ) #ifndef DESKTOP CloseToolhelp32Snapshot( procSnap ); #else CloseHandle( procSnap ); #endif } else { errorMessage = L"'GetWindowFromProc' requires toolhelp.dll on your device"; error = 9; return CValue(); } return rc; } //jwz::add end CValue FctScriptProcExists( CValueArray &params, int &error, CStr &errorMessage ) { if ( params.GetSize() != 1 ) { errorMessage = InvalidParameterCount + L"'ScriptProcExists'"; error = 9; return CValue(); } CValue rc; if ( GetRunningScriptProcId( params[0] ) == 0 ) rc = 0L; else rc = 1L; return rc; } CValue FctClipText( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; OpenClipboard(NULL); HANDLE clip=GetClipboardData(CF_UNICODETEXT); if ( clip != NULL ) { CStr str; str.Format( L"%s", clip ); rc = str; } CloseClipboard(); return rc; } CValue FctVolume( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; DWORD volume; waveOutGetVolume( 0, &volume ); BYTE *volBytes = (BYTE*)&volume; // direct access to bytes rc = (long)( (volBytes[1]+volBytes[3]) / 2 ); // Average of left and right channel return rc; } CValue FctTimeStamp( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; SYSTEMTIME now; GetLocalTime( &now ); rc = (long)SystemTimeToUnixTime( now ); return rc; } CValue FctTimeStampUTC( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; SYSTEMTIME now; GetSystemTime( &now ); rc = (long)SystemTimeToUnixTime( now ); return rc; } CValue FctTimeZoneBias( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; TIME_ZONE_INFORMATION tzi; int type = GetTimeZoneInformation( &tzi ); if ( type == TIME_ZONE_ID_DAYLIGHT ) rc = -tzi.Bias-tzi.DaylightBias; else rc = -tzi.Bias-tzi.StandardBias; return rc; } CValue FctTimeZoneName( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; TIME_ZONE_INFORMATION tzi; int type = GetTimeZoneInformation( &tzi ); if ( type == TIME_ZONE_ID_DAYLIGHT ) rc = tzi.DaylightName; else rc = tzi.StandardName; return rc; } CValue FctTimeZoneDST( CValueArray &params, int &error, CStr &errorMessage ) { TIME_ZONE_INFORMATION tzi; int type = GetTimeZoneInformation( &tzi ); return CValue( (long)(type == TIME_ZONE_ID_DAYLIGHT) ); } CValue FctFormatTime( CValueArray &params, int &error, CStr &errorMessage ) { if ( params.GetSize() != 1 && params.GetSize() != 2 ) { errorMessage = InvalidParameterCount + L"'FormatTime'"; error = 9; return CValue(); } ULONG time; SYSTEMTIME now; if ( params.GetSize() == 2 ) { time = (long)params[1]; UnixTimeToSystemTime( time, &now ); } else { GetLocalTime( &now ); time = SystemTimeToUnixTime( now ); } CStr hour24, hour12, ampm, minute, second, day, month, year, wday, unix, dayShort, dayLong, monthShort, monthLong; LCTYPE abbrevDays[] = { LOCALE_SABBREVDAYNAME7, LOCALE_SABBREVDAYNAME1, LOCALE_SABBREVDAYNAME2, LOCALE_SABBREVDAYNAME3, LOCALE_SABBREVDAYNAME4, LOCALE_SABBREVDAYNAME5, LOCALE_SABBREVDAYNAME6 }; LCTYPE longDays[] = { LOCALE_SDAYNAME7, LOCALE_SDAYNAME1, LOCALE_SDAYNAME2, LOCALE_SDAYNAME3, LOCALE_SDAYNAME4, LOCALE_SDAYNAME5, LOCALE_SDAYNAME6, }; TCHAR output[256]; GetLocaleInfo( LOCALE_USER_DEFAULT, longDays[now.wDayOfWeek], output, 256 ); dayLong = output; GetLocaleInfo( LOCALE_USER_DEFAULT, abbrevDays[now.wDayOfWeek], output, 256 ); dayShort = output; GetLocaleInfo( LOCALE_USER_DEFAULT, LOCALE_SMONTHNAME1 + now.wMonth - 1, output, 256 ); monthLong = output; GetLocaleInfo( LOCALE_USER_DEFAULT, LOCALE_SABBREVMONTHNAME1 + now.wMonth - 1, output, 256 ); monthShort = output; CStr result = params.GetAt(0); hour24.Format( L"%02d", now.wHour ); int hour = now.wHour % 12; if ( hour == 0 ) hour = 12; hour12.Format( L"%02d", hour ); minute.Format( L"%02d", now.wMinute ); second.Format( L"%02d", now.wSecond ); ampm = (now.wHour < 12) ? L"AM" : L"PM"; day.Format( L"%02d", now.wDay ); month.Format( L"%02d", now.wMonth ); year.Format( L"%02d", now.wYear ); wday.Format( L"%d", now.wDayOfWeek ); unix.Format( L"%d", time ); result.Replace( L"H", hour24 ); result.Replace( L"h", hour12 ); result.Replace( L"i", minute ); result.Replace( L"s", second ); result.Replace( L"d", day ); result.Replace( L"m", month ); result.Replace( L"Y", year ); year = year.Mid(2); result.Replace( L"y", year ); result.Replace( L"w", wday ); result.Replace( L"u", unix ); result.Replace( L"A", ampm ); ampm.MakeLower(); result.Replace( L"a", ampm ); result.Replace( L"{MM}", monthLong ); result.Replace( L"{M}", monthShort ); result.Replace( L"{WW}", dayLong ); result.Replace( L"{W}", dayShort ); CValue rc; rc = result; return rc; } CValue FctMortScriptType( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; #ifdef POCKETPC rc = L"PPC"; #endif #ifdef SMARTPHONE #ifdef PNA rc = L"PNA"; #else rc = L"SP"; #endif #endif #ifdef DESKTOP rc = L"PC"; #endif return rc; } CValue FctScreenWidth( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; rc = (long)GetSystemMetrics( SM_CXSCREEN ); return rc; } CValue FctScreenHeight( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; rc = (long)GetSystemMetrics( SM_CYSCREEN ); return rc; } CValue FctCurrentCursor( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; HWND wnd; if ( params.GetSize() > 1 ) { errorMessage = InvalidParameterCount + L"'CurrentCursor'"; error = 9; return CValue(); } else if ( params.GetSize() == 1 ) { CStr wndName = params[0]; wnd = FindWindowMy( wndName ,0); } else { wnd = ::GetForegroundWindow(); } if ( wnd != NULL ) { DWORD actCursor = GetClassLong(wnd,GCL_HCURSOR); HCURSOR compare; #ifdef DESKTOP LPCTSTR curList[] = { IDC_ARROW, IDC_WAIT, IDC_APPSTARTING, IDC_CROSS, IDC_HELP, IDC_UPARROW, NULL }; LPCTSTR curName[] = { L"arrow", L"wait", L"appstart", L"cross", L"help", L"uparrow" }; #else LPCTSTR curList[] = { IDC_ARROW, IDC_WAIT, IDC_APPSTARTING, IDC_CROSS, IDC_HELP, IDC_UPARROW, NULL }; LPCTSTR curName[] = { L"arrow", L"wait", L"appstart", L"cross", L"help", L"uparrow" }; #endif for ( int i=0; curList[i] != NULL; i++ ) { compare = LoadStdCursor( curList[i] ); if ( compare != NULL ) { if ( actCursor == (DWORD)compare ) { rc = curName[i]; } } } if ( rc.IsNull() ) rc = L"other"; } return rc; } #if !defined( PNA ) && !defined( DESKTOP ) CValue FctConnected( CValueArray &params, int &error, CStr &errorMessage ) { CValue result; result = 0L; RASCONN rsconn[10]; DWORD dwcb, dwConnections; RASCONNSTATUS rasStatus; // Enumerate active connections dwcb = sizeof(rsconn); rsconn[0].dwSize = sizeof(RASCONN); if ( RasEnumConnections(rsconn, &dwcb, &dwConnections) == 0 ) { if ( dwConnections != 0 && rsconn[0].hrasconn != NULL ) { // Get first RAS connection status rasStatus.dwSize = sizeof( rasStatus ); if ( RasGetConnectStatus( rsconn[0].hrasconn, &rasStatus ) == 0 ) { if ( rasStatus.rasconnstate == RASCS_Connected ) { result = 1L; } } } } return result; } #endif #ifndef PNA CValue FctInternetConnected( CValueArray &params, int &error, CStr &errorMessage ) { CValue result; result = 0L; HINTERNET web = NULL; if ( Proxy.IsEmpty() ) { #ifdef DESKTOP web = InternetOpen( L"JScripts", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 ); #else web = InternetOpen( L"JScripts", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 ); #endif } else { web = InternetOpen( L"JScripts", INTERNET_OPEN_TYPE_PROXY, (LPCTSTR)Proxy, NULL, 0 ); } if ( web != NULL ) { if ( params.GetSize() > 0 ) { HINTERNET file = InternetOpenUrl( web, params[0], NULL, 0, INTERNET_FLAG_RELOAD, 0 ); if ( file != NULL ) { result = 1L; InternetCloseHandle( file ); } } else { result = 1L; } InternetCloseHandle( web ); } return result; } #endif CValue FctFreeMemory( CValueArray &params, int &error, CStr &errorMessage ) { CValue result; MEMORYSTATUS mems; mems.dwLength = sizeof(MEMORYSTATUS); GlobalMemoryStatus(&mems); int shift = 1; if ( params.GetSize() >= 1 ) { shift = (long)params[0]; } for( int i = 0; i < shift; i++ ) { mems.dwAvailPhys = mems.dwAvailPhys >> 10; } if ( mems.dwAvailPhys > 0x0fffffff ) mems.dwAvailPhys = 0x0fffffff; result = (long)(mems.dwAvailPhys); return result; } CValue FctTotalMemory( CValueArray &params, int &error, CStr &errorMessage ) { CValue result; MEMORYSTATUS mems; mems.dwLength = sizeof(MEMORYSTATUS); GlobalMemoryStatus(&mems); int shift = 1; if ( params.GetSize() >= 1 ) { shift = (long)params[0]; } for( int i = 0; i < shift; i++ ) { mems.dwTotalPhys = mems.dwTotalPhys >> 10; } if ( mems.dwTotalPhys > 0x0fffffff ) mems.dwTotalPhys = 0x0fffffff; result = (long)(mems.dwTotalPhys); return result; } CValue FctSystemVersion( CValueArray &params, int &error, CStr &errorMessage ) { if ( params.GetSize() > 1 ) { errorMessage = InvalidParameterCount + L"'FileModified'"; error = 9; return CValue(); } OSVERSIONINFO ver; ver.dwOSVersionInfoSize = sizeof(ver); GetVersionEx( &ver ); CValue retVal; if ( params.GetSize() > 0 ) { if ( ((CStr)params[0]).CompareNoCase( L"major" ) == 0 ) retVal = (long)ver.dwMajorVersion; if ( ((CStr)params[0]).CompareNoCase( L"minor" ) == 0 ) retVal = (long)ver.dwMinorVersion; if ( ((CStr)params[0]).CompareNoCase( L"build" ) == 0 ) retVal = (long)ver.dwBuildNumber; if ( ((CStr)params[0]).CompareNoCase( L"platform" ) == 0 ) { switch ( ver.dwPlatformId ) { case VER_PLATFORM_WIN32s: retVal = L"Win32s"; break; case VER_PLATFORM_WIN32_WINDOWS: retVal = L"Win95"; break; case VER_PLATFORM_WIN32_NT: retVal = L"WinNT"; break; #ifndef DESKTOP case VER_PLATFORM_WIN32_CE: retVal = L"WinCE"; break; #endif default: retVal = L"unknown"; } } } if ( params.GetSize() == 0 || retVal.IsNull() ) { CStr retStr; retStr.Format( L"%d.%d.%d", ver.dwMajorVersion, ver.dwMinorVersion, ver.dwBuildNumber ); retVal = retStr; } return retVal; } CValue FctSupportsProcHandling( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; if ( LoadToolhelp() ) rc = 1L; else rc = 0L; return rc; } CValue FctRunWait( CValueArray &params, int &error, CStr &errorMessage ) { if ( params.GetSize() < 1 || params.GetSize() > 2 ) { errorMessage = InvalidParameterCount + L"'RunWait'"; error = 9; return CValue(); } CValue rc; PROCESS_INFORMATION inf; CStr exe = params[0]; CStr param; if ( params.GetSize() == 2 ) param = (CStr)params[1]; GetRunData( exe, param ); if ( ! exe.IsEmpty() ) { STARTUPINFO info; memset(&info, 0, sizeof(info)); info.cb = sizeof(info); info.wShowWindow = SW_SHOW; #ifdef DESKTOP info.dwFlags = STARTF_USESHOWWINDOW; memset(&inf, 0, sizeof(inf)); if ( ! param.IsEmpty() ) param = L"\"" + exe + L"\" " + param; #endif BOOL created = CreateProcess( (LPCTSTR)exe, (param.IsEmpty()) ? NULL : (LPTSTR)(LPCTSTR)param, NULL, NULL, FALSE, 0, NULL, NULL, &info, &inf ); if ( created ) { DWORD exitCode; while ( GetExitCodeProcess( inf.hProcess, &exitCode ) != FALSE && exitCode == STILL_ACTIVE ) { ::Sleep( 100 ); } rc = (long)exitCode; CloseHandle( inf.hProcess ); } else rc = -1L; } else rc = -1L; return rc; } //jwz:add regular expression for string CValue FctRegEx( CValueArray &params, int &error, CStr &errorMessage ){ if ( params.GetSize() < 2 || params.GetSize() > 4 ) { errorMessage = InvalidParameterCount + L"'RegEx'"; error = 9; return CValue(); } CStr text = params[0]; CStr pattern = params[1]; long RegFlag = 0,lStart=0; if (params.GetSize()>=3) RegFlag = params[2]; if (params.GetSize()>=4) lStart = params[3]; static CRegexpT <WCHAR> regexp(pattern,RegFlag); //RegEx Compile MatchResult result = regexp.Match(text,lStart); //RegEx Match //Save result as Array! CValue res; CMapStrToValue *map = res.GetMap(); CStr tStr,tVar; long MaxIndex = result.MaxGroupNumber()+1; CStrArray elements; if (result.IsMatched()){ //MessageBox(NULL,index,L"GroupNumber",MB_SETFOREGROUND); tStr = text.Mid(result.GetStart() , result.GetEnd() - result.GetStart()); tVar = L"$&"; SetVariable( tVar, tStr ); tVar = L"$`"; SetVariable( tVar, text.Left(result.GetStart())); tVar = L"$'"; SetVariable( tVar, text.Mid(result.GetEnd())); tVar = L"$0"; tStr.Format(L"%d",result.MaxGroupNumber()); SetVariable( tVar, tStr ); tStr.Format( L"%d", MaxIndex ); elements.Add(tStr); for (int i=0;i<=result.MaxGroupNumber();i++){ tVar.Format( L"$%d",i+1 ); tStr = text.Mid(result.GetGroupStart(i) , result.GetGroupEnd(i) - result.GetGroupStart(i)); SetVariable( tVar, text.Mid(result.GetGroupStart(i+1) , result.GetGroupEnd(i+1) - result.GetGroupStart(i+1))); elements.Add(tStr); if ( tStr.GetLength() > 0 ){ tVar = L"$+"; tStr.Format(L"%d",i); SetVariable( tVar, tStr ); } } }else{ tVar = L"$0"; SetVariable( tVar, L"0" ); tStr = L"0"; elements.Add(tStr); } //CStr index; for (int i=0; i<elements.GetSize(); i++ ) { tStr.Format( L"%d", i ); map->SetAt( tStr, elements[i] ); } return res; } CValue FctRegExReplace( CValueArray &params, int &error, CStr &errorMessage ){ if ( params.GetSize() < 3 || params.GetSize() > 5 ) { errorMessage = InvalidParameterCount + L"'RegExReplace'"; error = 9; return CValue(); } CStr text = params[0]; CStr pattern = params[1]; CStr rplStr = params[2]; long regStart= -1; long regTimes= -1; if (params.GetSize()>=4 ) regStart = (long) params[3]; if (params.GetSize()>=5 ) regTimes = (long) params[4]; CStr tStr; tStr.Format(L"%d-%d",regStart,regTimes); static CRegexpT <WCHAR> regexp(pattern,regStart); //RegEx Compile CStr result = regexp.Replace(text,rplStr,regStart,regTimes); //RegEx Match //Save result as Array! return (CValue)result; } #ifdef SMARTPHONE //Get Bluetooth state, //0-Poweroff //1-Connectable //2-Discoverable CValue FctGetBTState( CValueArray &params, int &error, CStr &errorMessage ){ if ( params.GetSize() !=0 ) { errorMessage = InvalidParameterCount + L"'Get Bluetooth State'"; error = 9; return CValue(); } DWORD BthMode; CValue result=-1L; if (BthGetMode(&BthMode)==ERROR_SUCCESS){ result = (long)BthMode; } return result; } CValue FctGetRadioMode( CValueArray &params, int &error, CStr &errorMessage ){ if ( params.GetSize() !=0 ) { errorMessage = InvalidParameterCount + L"'Get Bluetooth State'"; error = 9; return CValue(); } CValue rc = L"On"; if (Flight(3)!=5) rc = L"Off"; return rc; } #endif //jwz:add end.
[ "frezgo@c2805876-21d7-11df-8c35-9da929d3dec4" ]
[ [ [ 1, 1009 ] ] ]
dc098e17c13a8fc96d31ba68c7cd72d9295da82c
4891542ea31c89c0ab2377428e92cc72bd1d078f
/GameEditor/OkCancel.h
dd5d2c69e1f9cd0ca79b385e40fb42a5ba99ce7e
[]
no_license
koutsop/arcanoid
aa32c46c407955a06c6d4efe34748e50c472eea8
5bfef14317e35751fa386d841f0f5fa2b8757fb4
refs/heads/master
2021-01-18T14:11:00.321215
2008-07-17T21:50:36
2008-07-17T21:50:36
33,115,792
0
0
null
null
null
null
UTF-8
C++
false
false
1,573
h
#ifndef OKCANCEL_H #define OKCANCEL_H #include <iostream> #include <allegro.h> #include <cassert> #include <string.h> #include "Point.h" using namespace std; class OkCancel { private: friend class LoadData; Point imageCort; Point okUpCort; Point okDownCort; Point cancelUpCort; Point cancelDownCort; bool pushOk, pushCancel; int imageHeight; int imageWidth; string imageFileName; public: OkCancel(void); ~OkCancel(void); string GetImageFileName(void) const { return imageFileName; } Point GetImageCort(void) const { return imageCort; } Point GetOkUpCort(void) const { return okUpCort; } Point GetOkDownCort(void) const { return okDownCort;} Point GetCancelUpCort(void) const { return cancelUpCort; } Point GetCancelDownCort(void) const { return cancelDownCort; } bool PushOk(void) const { return pushOk; } bool PushCancel(void) const { return pushCancel; } void SetPushOk(bool choice) { pushOk = choice; } void SetPushCancel(bool choice) { pushCancel = choice; } /* @target: Na kanei load to bitmap gia to ok cancel. An den mporesei stamata h * :diadikasia h ektelesh. * @param : To bitmap sto opoio 8a ginei ti load * @return: To source pou 8a exei plewn ginei to load. */ BITMAP *LoadBitmapOkCancel(BITMAP *source); /* @target: kanei blit to bitmap tou ok cancel * @input : source einai to bitmap pou exei thn pliroforia gia to ok cancel * :dest einai se poio shmeio 8a ginei to blit. */ void BlitOkCancel(BITMAP *source, BITMAP *dest); }; #endif
[ "koutsop@5c4dd20e-9542-0410-abe3-ad2d610f3ba4" ]
[ [ [ 1, 57 ] ] ]
fcf44b80ed8e50345d4c6e68b8a3a5b06e3b94f3
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/serialization/test/test_vector.cpp
bb7eae992c62f5243db2743a323134b4cb070e05
[ "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,504
cpp
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 // test_vector.cpp // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // should pass compilation and execution #include <fstream> #include <cstdio> // remove #include <boost/config.hpp> #if defined(BOOST_NO_STDC_NAMESPACE) namespace std{ using ::remove; } #endif #include "test_tools.hpp" #include <boost/preprocessor/stringize.hpp> #include BOOST_PP_STRINGIZE(BOOST_ARCHIVE_TEST) #include <boost/serialization/vector.hpp> #include "A.hpp" int test_main( int /* argc */, char* /* argv */[] ) { const char * testfile = boost::archive::tmpnam(NULL); BOOST_REQUIRE(NULL != testfile); // test array of objects std::vector<A> avector; avector.push_back(A()); avector.push_back(A()); { test_ostream os(testfile, TEST_STREAM_FLAGS); test_oarchive oa(os); oa << boost::serialization::make_nvp("avector", avector); } std::vector<A> avector1; { test_istream is(testfile, TEST_STREAM_FLAGS); test_iarchive ia(is); ia >> boost::serialization::make_nvp("avector", avector1); } BOOST_CHECK(avector == avector1); std::remove(testfile); return EXIT_SUCCESS; } // EOF
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 54 ] ] ]
29bb552a1ea9e3a9f28afe2c4eca04d151571027
e53e3f6fac0340ae0435c8e60d15d763704ef7ec
/WDL/IPlug/IControl.h
725bc31788646203680aa71e5cce601f8b97737f
[]
no_license
b-vesco/vfx-wdl
906a69f647938b60387d8966f232a03ce5b87e5f
ee644f752e2174be2fefe43275aec2979f0baaec
refs/heads/master
2020-05-30T21:37:06.356326
2011-01-04T08:54:45
2011-01-04T08:54:45
848,136
2
0
null
null
null
null
UTF-8
C++
false
false
13,878
h
#ifndef _ICONTROL_ #define _ICONTROL_ #include "IPlugBase.h" #include "IGraphics.h" // A control is anything on the GUI, it could be a static bitmap, or // something that moves or changes. The control could manipulate // canned bitmaps or do run-time vector drawing, or whatever. // // Some controls respond to mouse actions, either by moving a bitmap, // transforming a bitmap, or cycling through a set of bitmaps. // Other controls are readouts only. class IControl { public: // If paramIdx is > -1, this control will be associated with a plugin parameter. IControl(IPlugBase* pPlug, IRECT* pR, int paramIdx = -1, IChannelBlend blendMethod = IChannelBlend::kBlendNone) : mPlug(pPlug), mRECT(*pR), mTargetRECT(*pR), mParamIdx(paramIdx), mValue(0.0), mDefaultValue(-1.0), mBlend(blendMethod), mDirty(true), mHide(false), mGrayed(false), mDisablePrompt(false), mDblAsSingleClick(false), mClampLo(0.0), mClampHi(1.0) {} virtual ~IControl() {} virtual void OnMouseDown(int x, int y, IMouseMod* pMod); virtual void OnMouseUp(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 void OnKeyDown(int x, int y, int key) {} // For efficiency, mouseovers/mouseouts are ignored unless you call IGraphics::HandleMouseOver. virtual void OnMouseOver(int x, int y, IMouseMod* pMod) {} virtual void OnMouseOut() {} // By default, mouse double click has its own handler. A control can set mDblAsSingleClick to true to change, // which maps double click to single click for this control (and also causes the mouse to be // captured by the control on double click). bool MouseDblAsSingleClick() { return mDblAsSingleClick; } virtual bool Draw(IGraphics* pGraphics) = 0; // Ask the IGraphics object to open an edit box so the user can enter a value for this control. void PromptUserInput(); int ParamIdx() { return mParamIdx; } virtual void SetValueFromPlug(double value); void SetValueFromUserInput(double value); double GetValue() { return mValue; } IRECT* GetRECT() { return &mRECT; } // The draw area for this control. IRECT* GetTargetRECT() { return &mTargetRECT; } // The mouse target area (default = draw area). void SetTargetArea(IRECT* pR) { mTargetRECT = *pR; } virtual void Hide(bool hide); bool IsHidden() const { return mHide; } virtual void GrayOut(bool gray); bool IsGrayed() { return mGrayed; } // Override if you want the control to be hit only if a visible part of it is hit, or whatever. virtual bool IsHit(int x, int y) { return mTargetRECT.Contains(x, y); } void SetBlendMethod(IChannelBlend::EBlendMethod blendMethod) { mBlend = IChannelBlend(blendMethod); } virtual void SetDirty(bool pushParamToPlug = true); virtual void SetClean(); virtual bool IsDirty() { return mDirty; } void Clamp(double lo, double hi) { mClampLo = lo; mClampHi = hi; } void DisablePrompt(bool disable) { mDisablePrompt = disable; } // Disables the right-click manual value entry. // Sometimes a control changes its state as part of its Draw method. // Redraw() prevents the control from being cleaned immediately after drawing. void Redraw() { mRedraw = true; } // This is an idle call from the GUI thread, as opposed to // IPlugBase::OnIdle which is called from the audio processing thread. // Only active if USE_IDLE_CALLS is defined. virtual void OnGUIIdle() {} protected: IPlugBase* mPlug; IRECT mRECT, mTargetRECT; int mParamIdx; double mValue, mDefaultValue, mClampLo, mClampHi; bool mDirty, mHide, mGrayed, mRedraw, mDisablePrompt, mClamped, mDblAsSingleClick; IChannelBlend mBlend; }; enum EDirection { kVertical, kHorizontal }; // Draws a bitmap, or one frame of a stacked bitmap depending on the current value. class IBitmapControl : public IControl { public: IBitmapControl(IPlugBase* pPlug, int x, int y, int paramIdx, IBitmap* pBitmap, IChannelBlend::EBlendMethod blendMethod = IChannelBlend::kBlendNone) : IControl(pPlug, &IRECT(x, y, pBitmap), paramIdx, blendMethod), mBitmap(*pBitmap) {} IBitmapControl(IPlugBase* pPlug, int x, int y, IBitmap* pBitmap, IChannelBlend::EBlendMethod blendMethod = IChannelBlend::kBlendNone) : IControl(pPlug, &IRECT(x, y, pBitmap), -1, blendMethod), mBitmap(*pBitmap) {} virtual ~IBitmapControl() {} virtual bool Draw(IGraphics* pGraphics); protected: IBitmap mBitmap; }; // A switch. Click to cycle through the bitmap states. class ISwitchControl : public IBitmapControl { public: ISwitchControl(IPlugBase* pPlug, int x, int y, int paramIdx, IBitmap* pBitmap, IChannelBlend::EBlendMethod blendMethod = IChannelBlend::kBlendNone) : IBitmapControl(pPlug, x, y, paramIdx, pBitmap, blendMethod) {} ~ISwitchControl() {} void OnMouseDown(int x, int y, IMouseMod* pMod); }; // On/off switch that has a target area only. class IInvisibleSwitchControl : public IControl { public: IInvisibleSwitchControl(IPlugBase* pPlug, IRECT* pR, int paramIdx); ~IInvisibleSwitchControl() {} void OnMouseDown(int x, int y, IMouseMod* pMod); virtual bool Draw(IGraphics* pGraphics) { return true; } }; // A set of buttons that maps to a single selection. Bitmap has 2 states, off and on. class IRadioButtonsControl : public IControl { public: IRadioButtonsControl(IPlugBase* pPlug, IRECT* pR, int paramIdx, int nButtons, IBitmap* pBitmap, EDirection direction = kVertical); ~IRadioButtonsControl() {} void OnMouseDown(int x, int y, IMouseMod* pMod); bool Draw(IGraphics* pGraphics); protected: WDL_TypedBuf<IRECT> mRECTs; IBitmap mBitmap; }; // A switch that reverts to 0.0 when released. class IContactControl : public ISwitchControl { public: IContactControl(IPlugBase* pPlug, int x, int y, int paramIdx, IBitmap* pBitmap) : ISwitchControl(pPlug, x, y, paramIdx, pBitmap) {} ~IContactControl() {} void OnMouseUp(int x, int y, IMouseMod* pMod); }; // A fader. The bitmap snaps to a mouse click or drag. class IFaderControl : public IControl { public: IFaderControl(IPlugBase* pPlug, int x, int y, int len, int paramIdx, IBitmap* pBitmap, EDirection direction = kVertical); ~IFaderControl() {} int GetLength() const { return mLen; } // Size of the handle in pixels. int GetHandleHeadroom() const { return mHandleHeadroom; } // Size of the handle in terms of the control value. double GetHandleValueHeadroom() const { return (double) mHandleHeadroom / (double) mLen; } // Where is the handle right now? IRECT GetHandleRECT(double value = -1.0) const; virtual void OnMouseDown(int x, int y, IMouseMod* pMod); virtual void OnMouseDrag(int x, int y, int dX, int dY, IMouseMod* pMod); virtual bool Draw(IGraphics* pGraphics); protected: void SnapToMouse(int x, int y); int mLen, mHandleHeadroom; IBitmap mBitmap; EDirection mDirection; }; const double DEFAULT_GEARING = 4.0; // Parent for knobs, to handle mouse action and ballistics. class IKnobControl : public IControl { public: IKnobControl(IPlugBase* pPlug, IRECT* pR, int paramIdx, EDirection direction = kVertical, double gearing = DEFAULT_GEARING) : IControl(pPlug, pR, paramIdx), mDirection(direction), mGearing(gearing) {} virtual ~IKnobControl() {} void SetGearing(double gearing) { mGearing = gearing; } virtual void OnMouseDrag(int x, int y, int dX, int dY, IMouseMod* pMod); protected: EDirection mDirection; double mGearing; }; // A knob that is just a line. class IKnobLineControl : public IKnobControl { public: IKnobLineControl(IPlugBase* pPlug, IRECT* pR, int paramIdx, const IColor* pColor, double innerRadius = 0.0, double outerRadius = 0.0, double minAngle = -0.75 * PI, double maxAngle = 0.75 * PI, EDirection direction = kVertical, double gearing = DEFAULT_GEARING); ~IKnobLineControl() {} bool Draw(IGraphics* pGraphics); private: IColor mColor; float mMinAngle, mMaxAngle, mInnerRadius, mOuterRadius; }; // A rotating knob. The bitmap rotates with any mouse drag. class IKnobRotaterControl : public IKnobControl { public: IKnobRotaterControl(IPlugBase* pPlug, int x, int y, int paramIdx, IBitmap* pBitmap, double minAngle = -0.75 * PI, double maxAngle = 0.75 * PI, int yOffsetZeroDeg = 0, EDirection direction = kVertical, double gearing = DEFAULT_GEARING) : IKnobControl(pPlug, &IRECT(x, y, pBitmap), paramIdx, direction, gearing), mBitmap(*pBitmap), mMinAngle(minAngle), mMaxAngle(maxAngle), mYOffset(yOffsetZeroDeg) {} ~IKnobRotaterControl() {} bool Draw(IGraphics* pGraphics); private: IBitmap mBitmap; double mMinAngle, mMaxAngle; int mYOffset; }; // A multibitmap knob. The bitmap cycles through states as the mouse drags. class IKnobMultiControl : public IKnobControl { public: IKnobMultiControl(IPlugBase* pPlug, int x, int y, int paramIdx, IBitmap* pBitmap, EDirection direction = kVertical, double gearing = DEFAULT_GEARING) : IKnobControl(pPlug, &IRECT(x, y, pBitmap), paramIdx, direction, gearing), mBitmap(*pBitmap) {} ~IKnobMultiControl() {} bool Draw(IGraphics* pGraphics); private: IBitmap mBitmap; }; // A knob that consists of a static base, a rotating mask, and a rotating top. // The bitmaps are assumed to be symmetrical and identical sizes. class IKnobRotatingMaskControl : public IKnobControl { public: IKnobRotatingMaskControl(IPlugBase* pPlug, int x, int y, int paramIdx, IBitmap* pBase, IBitmap* pMask, IBitmap* pTop, double minAngle = -0.75 * PI, double maxAngle = 0.75 * PI, EDirection direction = kVertical, double gearing = DEFAULT_GEARING) : IKnobControl(pPlug, &IRECT(x, y, pBase), paramIdx, direction, gearing), mBase(*pBase), mMask(*pMask), mTop(*pTop), mMinAngle(minAngle), mMaxAngle(maxAngle) {} ~IKnobRotatingMaskControl() {} bool Draw(IGraphics* pGraphics); private: IBitmap mBase, mMask, mTop; double mMinAngle, mMaxAngle; }; // Bitmap shows when value = 0, then toggles its target area to the whole bitmap // and waits for another click to hide itself. class IBitmapOverlayControl : public ISwitchControl { public: IBitmapOverlayControl(IPlugBase* pPlug, int x, int y, int paramIdx, IBitmap* pBitmap, IRECT* pTargetArea) : ISwitchControl(pPlug, x, y, paramIdx, pBitmap), mTargetArea(*pTargetArea) {} IBitmapOverlayControl(IPlugBase* pPlug, int x, int y, IBitmap* pBitmap, IRECT* pTargetArea) : ISwitchControl(pPlug, x, y, -1, pBitmap), mTargetArea(*pTargetArea) {} ~IBitmapOverlayControl() {} bool Draw(IGraphics* pGraphics); private: IRECT mTargetArea; // Keep this around to swap in & out. }; // Output text to the screen. class ITextControl : public IControl { public: ITextControl(IPlugBase* pPlug, IRECT* pR, IText* pText, const char* str = "") : IControl(pPlug, pR), mText(*pText) { mStr.Set(str); } ~ITextControl() {} void SetTextFromPlug(char* str); void ClearTextFromPlug() { SetTextFromPlug(""); } bool Draw(IGraphics* pGraphics); protected: IText mText; WDL_String mStr; }; // If paramIdx is specified, the text is automatically set to the output // of Param::GetDisplayForHost(). If showParamLabel = true, Param::GetLabelForHost() is appended. class ICaptionControl : public ITextControl { public: ICaptionControl(IPlugBase* pPlug, IRECT* pR, int paramIdx, IText* pText, bool showParamLabel = true); ~ICaptionControl() {} virtual void OnMouseDown(int x, int y, IMouseMod* pMod); virtual void OnMouseDblClick(int x, int y, IMouseMod* pMod); bool Draw(IGraphics* pGraphics); protected: bool mShowParamLabel; }; #define MAX_URL_LEN 256 #define MAX_NET_ERR_MSG_LEN 1024 class IURLControl : public IControl { public: IURLControl(IPlugBase* pPlug, IRECT* pR, const char* url, const char* backupURL = 0, const char* errMsgOnFailure = 0); ~IURLControl() {} void OnMouseDown(int x, int y, IMouseMod* pMod); bool Draw(IGraphics* pGraphics) { return true; } protected: char mURL[MAX_URL_LEN], mBackupURL[MAX_URL_LEN], mErrMsg[MAX_NET_ERR_MSG_LEN]; }; // This is a weird control for a few reasons. // - Although its numeric mValue is not meaningful, it needs to be associated with a plugin parameter // so it can inform the plug when the file selection has changed. If the associated plugin parameter is // declared after kNumParams in the EParams enum, the parameter will be a dummy for this purpose only. // - Because it puts up a modal window, it needs to redraw itself twice when it's dirty, // because moving the modal window will clear the first dirty state. class IFileSelectorControl : public IControl { public: enum EFileSelectorState { kFSNone, kFSSelecting, kFSDone }; IFileSelectorControl(IPlugBase* pPlug, IRECT* pR, int paramIdx, IBitmap* pBitmap, IGraphics::EFileAction action, char* dir = "", char* extensions = "") // extensions = "txt wav" for example. : IControl(pPlug, pR, paramIdx), mBitmap(*pBitmap), mFileAction(action), mDir(dir), mExtensions(extensions), mState(kFSNone) {} ~IFileSelectorControl() {} void OnMouseDown(int x, int y, IMouseMod* pMod); void GetLastSelectedFileForPlug(WDL_String* pStr); void SetLastSelectedFileFromPlug(char* file); bool Draw(IGraphics* pGraphics); bool IsDirty(); private: IBitmap mBitmap; WDL_String mDir, mFile, mExtensions; IGraphics::EFileAction mFileAction; EFileSelectorState mState; }; #endif
[ [ [ 1, 345 ], [ 349, 405 ] ], [ [ 346, 348 ] ] ]
c661d1368163dc5731174a29282785e2a3a9adb5
ed56fa6aaaf46c4b4b6df8bf79a62f45864e05b5
/level.h
39194e29a3a3dd672a349774512b86ca806beb10
[]
no_license
hrr4/Blasteroids
1711bd9b1bbdf36b5ebc1dbd949e3f560a86ba29
1c0179083d11cf8d0e412ff68332371baf629d5e
refs/heads/master
2021-01-20T12:21:03.060388
2011-02-21T07:03:21
2011-02-21T07:03:21
1,263,961
0
0
null
null
null
null
UTF-8
C++
false
false
978
h
#ifndef LEVEL_H #define LEVEL_H #include "gamescreen.h" #include "player.h" #include "comet.h" #include "Projectile.h" #include "starfield.h" #include "icollide.h" #include "hud.h" #include "IParticle.h" #include <string> #include <vector> class Level : public IGameScreen { public: Level(int _levelNum); virtual ~Level(); virtual void Logic(); virtual void Draw(); virtual void Handle_Events(); private: void ScoreIncrease(); Vectorf randOutside(float _xMax, float _yMax, float _min, float _dist); void createCometChild(Vectorf& _parentVec, int _n); Starfield stars; ICollide* iCollide; HUD* hud; Player* mainPlayer; IParticle particleEngine; std::vector<Collider*> projVec; std::vector<Comet*> cometVec; unsigned int numPoints, untilNext, kills, announceSize, levelNum, cometScore, cometSpawn; bool callAnnouncement; static int playerLives, score; }; #endif
[ [ [ 1, 39 ] ] ]
c9b17b117cfdecbc7a32b8131812b4b111e1ca29
ce28ec891a0d502e7461fd121b4d96a308c9dab7
/main.h
563a24974f689afa78531fc64245ef72ae1615cd
[]
no_license
aktau/Tangerine
fe84f6578ce918d1fa151138c0cc5780161b3b8f
179ac9901513f90b17c5cd4add35608a7101055b
refs/heads/master
2020-06-08T17:07:53.860642
2011-08-14T09:41:41
2011-08-14T09:41:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
900
h
#ifndef MAIN_H_ #define MAIN_H_ #define SETTINGS_DB_ROOT_KEY "db/root" #define SETTINGS_DB_IMAGECACHE_KEY "matchdb/images" #define SETTINGS_DB_LASTMATCHDB_KEY "matchdb/root" #define SETTINGS_APP_AUTOLOAD_MATCHDB_KEY "app/autoload/matchdb" #define DEV_PHASE "Alpha" #define MAJ_VERSION 0 #define MIN_VERSION 5 #include <QtGui/QApplication> #include <QEvent> #include <QtDebug> class TangerineApplication : public QApplication { Q_OBJECT public: TangerineApplication(int argc, char * argv[]) : QApplication( argc, argv ) {} bool event(QEvent * pEvent) { if (pEvent->type() == QEvent::ApplicationActivate) { emit activated(); } else if (pEvent->type() == QEvent::ApplicationDeactivate) { emit deactivated(); } return QApplication::event(pEvent); } signals: void activated(); void deactivated(); }; #endif /* MAIN_H_ */
[ [ [ 1, 39 ] ] ]
97dd6d1f7e7e865d09470f9ce63b43a801aacbe1
e7c45d18fa1e4285e5227e5984e07c47f8867d1d
/SMDK/RTTS/RioTintoTS/TSMath.h
86219887a5d0ff803c736ddb92ec1b497bbc168b
[]
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
1,596
h
//-- TSMath.h: Math Definitions for the RioTintoTS namespace ---------------- #if !defined(TSMATH_H__7D19A5F6_17B5_4A41_8E62_8BEA3AF78740) #define TSMATH_H__7D19A5F6_17B5_4A41_8E62_8BEA3AF78740 #pragma once /**************************************************************************** * * Forward declare RioTintoTS namespace contents * ****************************************************************************/ namespace RioTintoTS { // Various math constants - note: *insane* precision const double EPSILON = 1e-10; const double BIG_NUMBER = 1e100; const double ROOT2_TWO = 1.414213562373095048801688724209698079; const double ROOT4_TWO = 1.189207115002721066717499970560475915; const double PI = 3.141592653589793238462643383279502884; const double HALF_PI = ( PI * 0.5 ); const double TWO_PI = ( PI * 2.0 ); const double RADIAN_PER_DEGREE = ( PI / 180.0 ); const double DEGREE_PER_RADIAN = ( 180.0 / PI ); // Forward declare classes that are inside this namespace class VectorView; class Vector; class TableVector; class MatrixView; class Matrix; class PointVec; class Curve; class CoordSystem; // Hide templated min and max inside this namespace template<typename T> T Minimum( T x, T y ) { return ( x < y ) ? x : y; } template<typename T> T Maximum( T x, T y ) { return ( x > y ) ? x : y; } } // RioTintoTS namespace #endif // TSMATH_H__7D19A5F6_17B5_4A41_8E62_8BEA3AF78740
[ [ [ 1, 52 ] ] ]
9a7fb7a2460e35e7c40d36151a4f63ddcf70c959
dd5c8920aa0ea96607f2498701c81bb1af2b3c96
/stlplus/source/error_handler.cpp
40b2a87b9abe18218ad8d80507718d87fad8a25e
[]
no_license
BackupTheBerlios/multicrew-svn
913279401e9cf886476a3c912ecd3d2b8d28344c
5087f07a100f82c37d2b85134ccc9125342c58d1
refs/heads/master
2021-01-23T13:36:03.990862
2005-06-10T16:52:32
2005-06-10T16:52:32
40,747,367
0
0
null
null
null
null
UTF-8
C++
false
false
66,142
cpp
/*------------------------------------------------------------------------------ Author: Andy Rushton Copyright: (c) Andy Rushton, 2004 License: BSD License, see ../docs/license.html ------------------------------------------------------------------------------*/ #include "error_handler.hpp" #include "fileio.hpp" #include "file_system.hpp" #include "debug.hpp" #include <ctype.h> //////////////////////////////////////////////////////////////////////////////// static char* information_id = "INFORMATION"; static char* context_id = "CONTEXT"; static char* supplement_id = "SUPPLEMENT"; static char* warning_id = "WARNING"; static char* error_id = "ERROR"; static char* fatal_id = "FATAL"; static char* position_id = "POSITION"; static char* default_information_format = "@0"; static char* default_context_format = "context: @0"; static char* default_supplement_format = "supplement: @0"; static char* default_warning_format = "warning: @0"; static char* default_error_format = "error: @0"; static char* default_fatal_format = "FATAL: @0"; static char* default_position_format = "\"@1\" (@2,@3) : @0"; //////////////////////////////////////////////////////////////////////////////// // position class error_position::error_position(void) : m_filename(std::string()), m_line(0), m_column(0) { } error_position::error_position(const std::string& filename, unsigned line, unsigned column) : m_filename(filename), m_line(line), m_column(column) { } error_position::~error_position(void) { } const std::string& error_position::filename(void) const { return m_filename; } unsigned error_position::line(void) const { return m_line; } unsigned error_position::column(void) const { return m_column; } error_position error_position::operator + (unsigned offset) const { error_position result(*this); result += offset; return result; } error_position& error_position::operator += (unsigned offset) { m_column += offset; return *this; } bool error_position::empty(void) const { return m_filename.empty(); } bool error_position::valid(void) const { return !empty(); } std::vector<std::string> error_position::show(void) const { std::vector<std::string> result; if (valid()) { // skip row-1 lines of the file and print out the resultant line iftext source(filename()); std::string current_line; for (unsigned i = 0; i < line(); i++) if (source.error() || !source.getline(current_line)) break; result.push_back(current_line); // now put an up-arrow at the appropriate column // preserve any tabs in the original line result.push_back(std::string()); for (unsigned j = 0; j < column(); j++) { if (j < current_line.size() && current_line[j] == '\t') result.back() += '\t'; else result.back() += ' '; } result.back() += '^'; } return result; } std::string to_string(const error_position& where) { return "{" + filespec_to_relative_path(where.filename()) + ":" + to_string(where.line()) + ":" + to_string(where.column()) + "}"; } otext& operator << (otext& output, const error_position& where) { return output << to_string(where); } //////////////////////////////////////////////////////////////////////////////// // exceptions // read_error error_handler_read_error::error_handler_read_error(const error_position& position, const std::string& reason) : std::runtime_error(to_string(position) + std::string(": Error handler read error - ") + reason), m_position(position) { } error_handler_read_error::~error_handler_read_error(void) throw() { } const error_position& error_handler_read_error::where(void) const { return m_position; } // format error error_handler_format_error::error_handler_format_error(const std::string& format, unsigned offset) : std::runtime_error(std::string("Error handler formatting error in \"") + format + std::string("\"")), m_position("",0,0), m_format(format), m_offset(offset) { } error_handler_format_error::error_handler_format_error(const error_position& pos, const std::string& format, unsigned offset) : std::runtime_error(to_string(pos) + std::string(": Error handler formatting error in \"") + format + std::string("\"")), m_position(pos), m_format(format), m_offset(offset) { } error_handler_format_error::~error_handler_format_error(void) throw() { } const error_position& error_handler_format_error::where(void) const { return m_position; } const std::string& error_handler_format_error::format(void) const { return m_format; } unsigned error_handler_format_error::offset(void) const { return m_offset; } // id_error error_handler_id_error::error_handler_id_error(const std::string& id) : std::runtime_error(std::string("Error handler message ID not found: ") + id), m_id(id) { } error_handler_id_error::~error_handler_id_error(void) throw() { } const std::string& error_handler_id_error::id(void) const { return m_id; } // limit_error error_handler_limit_error::error_handler_limit_error(unsigned limit) : std::runtime_error(std::string("Error handler limit error: ") + to_string(limit) + std::string(" reached")), m_limit(limit) { } error_handler_limit_error::~error_handler_limit_error(void) throw() { } unsigned error_handler_limit_error::limit(void) const { return m_limit; } // fatal_error error_handler_fatal_error::error_handler_fatal_error(const std::string& id) : std::runtime_error(std::string("Fatal error: ") + id), m_id(id) { } error_handler_fatal_error::~error_handler_fatal_error(void) throw() { } const std::string& error_handler_fatal_error::id(void) const { return m_id; } //////////////////////////////////////////////////////////////////////////////// class message { private: unsigned m_index; // index into message files unsigned m_line; // line unsigned m_column; // column std::string m_text; // text public: message(unsigned index = (unsigned)-1,unsigned line = 0,unsigned column = 0, const std::string& text = "") : m_index(index),m_line(line),m_column(column),m_text(text) {} message(const std::string& text) : m_index((unsigned)-1),m_line(0),m_column(0),m_text(text) {} ~message(void) {} unsigned index(void) const {return m_index;} unsigned line(void) const {return m_line;} unsigned column(void) const {return m_column;} const std::string& text(void) const {return m_text;} }; //////////////////////////////////////////////////////////////////////////////// class pending_message { private: error_position m_position; std::string m_id; std::vector<std::string> m_args; public: pending_message(const error_position& position, const std::string& id, const std::vector<std::string>& args) : m_position(position), m_id(id), m_args(args) {} pending_message(const std::string& id, const std::vector<std::string>& args) : m_position(error_position()), m_id(id), m_args(args) {} ~pending_message(void) {} const error_position& position(void) const {return m_position;} const std::string& id(void) const {return m_id;} const std::vector<std::string>& args(void) const {return m_args;} }; //////////////////////////////////////////////////////////////////////////////// class error_handler_base_body { public: std::vector<std::string> m_files; // message files in the order they were added std::map<std::string,message> m_messages; // messages stored as id:message pairs bool m_show; // show source std::list<pending_message> m_context; // context message stack std::list<pending_message> m_supplement; // supplementary message stack public: error_handler_base_body(void) { // preload with default formats add_message(information_id,default_information_format); add_message(warning_id,default_warning_format); add_message(error_id,default_error_format); add_message(fatal_id,default_fatal_format); add_message(position_id,default_position_format); add_message(context_id,default_context_format); add_message(supplement_id,default_supplement_format); } ~error_handler_base_body(void) { } void set_show(bool show) { m_show = show; } void add_message_file(const std::string& file) throw(error_handler_read_error) { if (!file_exists(file)) throw error_handler_read_error(error_position(file,0,0), "file not found"); m_files.push_back(file); iftext input(file); std::string line; unsigned l = 0; while(input.getline(line)) { l++; if (line.size() > 0 && isalpha(line[0])) { // Get the id field which starts with an alphabetic and contains alphanumerics and underscore std::string id; unsigned i = 0; for (; i < line.size(); i++) { if (isalnum(line[i]) || line[i] == '_') id += line[i]; else break; } // check this ID is unique within the files - however it is legal to override a hard-coded message if (m_messages.find(id) != m_messages.end() && m_messages.find(id)->second.index() != (unsigned)-1) throw error_handler_read_error(error_position(file,l,i), std::string("repeated ID ") + id); // check for at least one whitespace if (i >= line.size() || !isspace(line[i])) throw error_handler_read_error(error_position(file,l,i), "Missing whitespace"); // skip whitespace for (; i < line.size(); i++) { if (!isspace(line[i])) break; } // now get the text part and add the message to the message map std::string text = line.substr(i, line.size()-i); m_messages[id] = message(m_files.size()-1, l, i, text); } } } void add_message(const std::string& id, const std::string& text) throw() { m_messages[id] = message((unsigned)-1, 0, 0, text); } void push_supplement(const error_position& position, const std::string& message_id, const std::vector<std::string>& args) { m_supplement.push_back(pending_message(position,message_id,args)); } void push_context(const error_position& position, const std::string& message_id, const std::vector<std::string>& args) { m_context.push_back(pending_message(position,message_id,args)); } void pop_context(unsigned depth) { while (depth < m_context.size()) m_context.pop_back(); } unsigned context_depth(void) const { return m_context.size(); } std::vector<std::string> format_report(const error_position& position, const std::string& message_id, const std::string& status_id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { // gathers everything together into a full multi-line report std::vector<std::string> result; // the first part of the report is the status message (info/warning/error/fatal) result.push_back(format_id(position, message_id, status_id, args)); // now append any supplemental messages that have been stacked // these are printed in FIFO order i.e. the order that they were added to the handler for (std::list<pending_message>::iterator j = m_supplement.begin(); j != m_supplement.end(); j++) result.push_back(format_id(j->position(),j->id(),supplement_id,j->args())); // now discard any supplementary messages because they only persist until they are printed once m_supplement.clear(); // now append any context messages that have been stacked // these are printed in LIFO order i.e. closest context first for (std::list<pending_message>::reverse_iterator i = m_context.rbegin(); i != m_context.rend(); i++) result.push_back(format_id(i->position(),i->id(),context_id,i->args())); return result; } std::string format_id(const error_position& position, const std::string& message_id, const std::string& status_id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { // This function creates a fully-formatted single-line message from a // combination of the position format and the status format plus the message // ID and its arguments. There are up to three levels of substitution // required to do this. // get the status format from the status_id std::map<std::string,message>::iterator status_found = m_messages.find(status_id); if (status_found == m_messages.end()) throw error_handler_id_error(status_id); // similarly get the message format std::map<std::string,message>::iterator message_found = m_messages.find(message_id); if (message_found == m_messages.end()) throw error_handler_id_error(message_id); // format the message contents std::string message_text = format_message(message_found->second, args); // now format the message in the status string (informational, warning etc). std::vector<std::string> status_args; status_args.push_back(message_text); std::string result = format_message(status_found->second, status_args); // finally, if the message is positional, format the status message in the positional string if (position.valid()) { // get the position format from the message set std::map<std::string,message>::iterator position_found = m_messages.find(position_id); if (position_found == m_messages.end()) throw error_handler_id_error(position_id); // now format the message std::vector<std::string> position_args; position_args.push_back(result); position_args.push_back(filespec_to_relative_path(position.filename())); position_args.push_back(to_string(position.line())); position_args.push_back(to_string(position.column())); result = format_message(position_found->second, position_args); // add the source file text and position if that option is on if (m_show) { std::vector<std::string> show = position.show(); for (unsigned i = 0; i < show.size(); i++) { result += std::string("\n"); result += show[i]; } } } return result; } std::string format_message(const message& mess, const std::vector<std::string>& args) throw(error_handler_format_error) { // this function creates a formatted string from the stored message text and // the arguments. Most of the work is done in format_string. However, if a // formatting error is found, this function uses extra information stored in // the message data structure to improve the reporting of the error try { // This is the basic string formatter which performs parameter substitution // into a message. Parameter placeholders are in the form @0, @1 etc, where // the number is the index of the argument in the args vector. At present, // no field codes are supported as in printf formats Algorithm: scan the // input string and transfer it into the result. When an @nnn appears, // substitute the relevant argument from the args vector. Throw an exception // if its out of range. Also convert C-style escaped characters of the form // \n. std::string format = mess.text(); std::string result; for (unsigned i = 0; i < format.size(); ) { if (format[i] == '@') { // an argument substitution has been found - now find the argument number if (i+1 == format.size()) throw error_handler_format_error(format, i); i++; // check for @@ which is an escaped form of '@' if (format[i] == '@') { result += '@'; i++; } else { // there must be at least one digit in the substitution number if (!isdigit(format[i])) throw error_handler_format_error(format,i); unsigned a = 0; for (; i < format.size() && isdigit(format[i]); i++) { a *= 10; a += (format[i] - '0'); } // check for an argument request out of the range of the set of arguments if (a >= args.size()) throw error_handler_format_error(format,i-1); result += args[a]; } } else if (format[i] == '\\') { // an escaped character has been found if (i+1 == format.size()) throw error_handler_format_error(format, i); i++; // do the special ones first, then all the others just strip off the \ and leave the following characters switch(format[i]) { case '\\': result += '\\'; break; case 't': result += '\t'; break; case 'n': result += '\n'; break; case 'r': result += '\r'; break; case 'a': result += '\a'; break; default: result += format[i]; break; } i++; } else { // plain text found - just append to the result result += format[i++]; } } return result; } catch(error_handler_format_error& exception) { // if the message came from a message file, improve the error reporting by adding file positional information // Also adjust the position from the start of the text (stored in the message field) to the column of the error if (mess.index() != (unsigned)-1) throw error_handler_format_error(error_position(m_files[mess.index()], mess.line(), mess.column()+exception.offset()), exception.format(), exception.offset()); else throw exception; } } }; //////////////////////////////////////////////////////////////////////////////// // context subclass error_context_body::error_context_body(error_handler_base& handler) : m_depth(0), m_handler(0) { set(handler); } error_context_body::~error_context_body(void) { pop(); } void error_context_body::set(error_handler_base& handler) { m_handler = &handler; m_depth = m_handler->context_depth(); } void error_context_body::pop(void) { if (m_handler) m_handler->pop_context(m_depth); } //////////////////////////////////////////////////////////////////////////////// error_handler_base::error_handler_base(bool show) throw() : m_base_body(new error_handler_base_body) { m_base_body->set_show(show); } error_handler_base::error_handler_base(const std::string& file, bool show) throw(error_handler_read_error) : m_base_body(new error_handler_base_body) { m_base_body->set_show(show); add_message_file(file); } error_handler_base::error_handler_base(const std::vector<std::string>& files, bool show) throw(error_handler_read_error) : m_base_body(new error_handler_base_body) { m_base_body->set_show(show); add_message_files(files); } error_handler_base::~error_handler_base(void) throw() { } //////////////////////////////////////////////////////////////////////////////// void error_handler_base::add_message_file(const std::string& file) throw(error_handler_read_error) { m_base_body->add_message_file(file); } void error_handler_base::add_message_files(const std::vector<std::string>& files) throw(error_handler_read_error) { for (unsigned i = 0; i < files.size(); i++) add_message_file(files[i]); } void error_handler_base::add_message(const std::string& id, const std::string& text) throw() { m_base_body->add_message(id,text); } //////////////////////////////////////////////////////////////////////////////// void error_handler_base::set_information_format(const std::string& format) throw() { add_message(information_id, format); } void error_handler_base::set_warning_format(const std::string& format) throw() { add_message(warning_id, format); } void error_handler_base::set_error_format(const std::string& format) throw() { add_message(error_id, format); } void error_handler_base::set_fatal_format(const std::string& format) throw() { add_message(fatal_id, format); } void error_handler_base::set_position_format(const std::string& format) throw() { add_message(position_id, format); } void error_handler_base::set_context_format(const std::string& format) throw() { add_message(context_id, format); } void error_handler_base::set_supplement_format(const std::string& format) throw() { add_message(supplement_id, format); } //////////////////////////////////////////////////////////////////////////////// void error_handler_base::show_position(void) throw() { m_base_body->set_show(true); } void error_handler_base::hide_position(void) throw() { m_base_body->set_show(false); } //////////////////////////////////////////////////////////////////////////////// // information messages std::vector<std::string> error_handler_base::information_message(const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { return information_message(error_position(), id, args); } std::vector<std::string> error_handler_base::information_message(const std::string& id) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; return information_message(id, args); } std::vector<std::string> error_handler_base::information_message(const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); return information_message(id, args); } std::vector<std::string> error_handler_base::information_message(const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); return information_message(id, args); } std::vector<std::string> error_handler_base::information_message(const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); args.push_back(arg3); return information_message(id, args); } std::vector<std::string> error_handler_base::information_message(const error_position& position, const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { return m_base_body->format_report(position, id, information_id, args); } std::vector<std::string> error_handler_base::information_message(const error_position& position, const std::string& id) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; return information_message(position, id, args); } std::vector<std::string> error_handler_base::information_message(const error_position& position, const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); return information_message(position, id, args); } std::vector<std::string> error_handler_base::information_message(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); return information_message(position, id, args); } std::vector<std::string> error_handler_base::information_message(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); args.push_back(arg3); return information_message(position, id, args); } //////////////////////////////////////////////////////////////////////////////// // warning messages std::vector<std::string> error_handler_base::warning_message(const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { return warning_message(error_position(), id, args); } std::vector<std::string> error_handler_base::warning_message(const std::string& id) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; return warning_message(id, args); } std::vector<std::string> error_handler_base::warning_message(const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); return warning_message(id, args); } std::vector<std::string> error_handler_base::warning_message(const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); return warning_message(id, args); } std::vector<std::string> error_handler_base::warning_message(const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); args.push_back(arg3); return warning_message(id, args); } std::vector<std::string> error_handler_base::warning_message(const error_position& position, const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { return m_base_body->format_report(position, id, warning_id, args); } std::vector<std::string> error_handler_base::warning_message(const error_position& position, const std::string& id) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; return warning_message(position, id, args); } std::vector<std::string> error_handler_base::warning_message(const error_position& position, const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); return warning_message(position, id, args); } std::vector<std::string> error_handler_base::warning_message(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); return warning_message(position, id, args); } std::vector<std::string> error_handler_base::warning_message(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); args.push_back(arg3); return warning_message(position, id, args); } //////////////////////////////////////////////////////////////////////////////// // error messages std::vector<std::string> error_handler_base::error_message(const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { return error_message(error_position(), id, args); } std::vector<std::string> error_handler_base::error_message(const std::string& id) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; return error_message(id, args); } std::vector<std::string> error_handler_base::error_message(const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); return error_message(id, args); } std::vector<std::string> error_handler_base::error_message(const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); return error_message(id, args); } std::vector<std::string> error_handler_base::error_message(const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); args.push_back(arg3); return error_message(id, args); } std::vector<std::string> error_handler_base::error_message(const error_position& position, const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { return m_base_body->format_report(position, id, error_id, args); } std::vector<std::string> error_handler_base::error_message(const error_position& position, const std::string& id) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; return error_message(position, id, args); } std::vector<std::string> error_handler_base::error_message(const error_position& position, const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); return error_message(position, id, args); } std::vector<std::string> error_handler_base::error_message(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); return error_message(position, id, args); } std::vector<std::string> error_handler_base::error_message(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); args.push_back(arg3); return error_message(position, id, args); } //////////////////////////////////////////////////////////////////////////////// // fatal messages std::vector<std::string> error_handler_base::fatal_message(const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { return fatal_message(error_position(), id, args); } std::vector<std::string> error_handler_base::fatal_message(const std::string& id) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; return fatal_message(id, args); } std::vector<std::string> error_handler_base::fatal_message(const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); return fatal_message(id, args); } std::vector<std::string> error_handler_base::fatal_message(const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); return fatal_message(id, args); } std::vector<std::string> error_handler_base::fatal_message(const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); args.push_back(arg3); return fatal_message(id, args); } std::vector<std::string> error_handler_base::fatal_message(const error_position& position, const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { return m_base_body->format_report(position, id, fatal_id, args); } std::vector<std::string> error_handler_base::fatal_message(const error_position& position, const std::string& id) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; return fatal_message(position, id, args); } std::vector<std::string> error_handler_base::fatal_message(const error_position& position, const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); return fatal_message(position, id, args); } std::vector<std::string> error_handler_base::fatal_message(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); return fatal_message(position, id, args); } std::vector<std::string> error_handler_base::fatal_message(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); args.push_back(arg3); return fatal_message(position, id, args); } //////////////////////////////////////////////////////////////////////////////// // supplemental messages void error_handler_base::push_supplement(const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { push_supplement(error_position(), id, args); } void error_handler_base::push_supplement(const std::string& id) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; push_supplement(id, args); } void error_handler_base::push_supplement(const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); push_supplement(id, args); } void error_handler_base::push_supplement(const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); push_supplement(id, args); } void error_handler_base::push_supplement(const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); args.push_back(arg3); push_supplement(id, args); } void error_handler_base::push_supplement(const error_position& position, const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { m_base_body->push_supplement(position, id, args); } void error_handler_base::push_supplement(const error_position& position, const std::string& id) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; push_supplement(position, id, args); } void error_handler_base::push_supplement(const error_position& position, const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); push_supplement(position, id, args); } void error_handler_base::push_supplement(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); push_supplement(position, id, args); } void error_handler_base::push_supplement(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); args.push_back(arg3); push_supplement(position, id, args); } //////////////////////////////////////////////////////////////////////////////// // context void error_handler_base::push_context (const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { push_context(error_position(), id, args); } void error_handler_base::push_context (const std::string& id) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; push_context(id, args); } void error_handler_base::push_context (const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); push_context(id, args); } void error_handler_base::push_context (const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); push_context(id, args); } void error_handler_base::push_context (const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); args.push_back(arg3); push_context(id, args); } void error_handler_base::push_context (const error_position& position, const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { m_base_body->push_context(position, id, args); } void error_handler_base::push_context (const error_position& position, const std::string& id) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; push_context(position, id, args); } void error_handler_base::push_context (const error_position& position, const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); push_context(position, id, args); } void error_handler_base::push_context (const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); push_context(position, id, args); } void error_handler_base::push_context (const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); args.push_back(arg3); push_context(position, id, args); } void error_handler_base::pop_context(void) throw() { m_base_body->pop_context(m_base_body->context_depth()-1); } void error_handler_base::pop_context(unsigned depth) throw() { m_base_body->pop_context(depth); } unsigned error_handler_base::context_depth(void) const throw() { return m_base_body->context_depth(); } error_context error_handler_base::auto_push_context(const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { return auto_push_context(error_position(), id, args); } error_context error_handler_base::auto_push_context(const std::string& id) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; return auto_push_context(id, args); } error_context error_handler_base::auto_push_context(const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); return auto_push_context(id, args); } error_context error_handler_base::auto_push_context (const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); return auto_push_context(id, args); } error_context error_handler_base::auto_push_context(const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); args.push_back(arg3); return auto_push_context(id, args); } error_context error_handler_base::auto_push_context(const error_position& position, const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { error_context result(new error_context_body(*this)); m_base_body->push_context(position, id, args); return result; } error_context error_handler_base::auto_push_context(const error_position& position, const std::string& id) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; return auto_push_context(position, id, args); } error_context error_handler_base::auto_push_context(const error_position& position, const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); return auto_push_context(position, id, args); } error_context error_handler_base::auto_push_context(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); return auto_push_context(position, id, args); } error_context error_handler_base::auto_push_context(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error) { std::vector<std::string> args; args.push_back(arg1); args.push_back(arg2); args.push_back(arg3); return auto_push_context(position, id, args); } //////////////////////////////////////////////////////////////////////////////// // textio-based derivative uses the above base class to generate messages then uses textio to print them //////////////////////////////////////////////////////////////////////////////// class error_handler_body { private: otext m_device; // TextIO output device unsigned m_limit; // error limit unsigned m_count; // error count public: error_handler_body(otext& device, unsigned limit) : m_device(device), m_limit(limit), m_count(0) { } ~error_handler_body(void) {} otext& device(void) {return m_device;} unsigned limit(void) const {return m_limit;} void set_limit(unsigned limit) {m_limit = limit;} unsigned count(void) const {return m_count;} void set_count(unsigned count) {m_count = count;} void increment(void) {++m_count;} bool limit_reached(void) const {return m_limit > 0 && m_count >= m_limit;} }; //////////////////////////////////////////////////////////////////////////////// error_handler::error_handler(otext& device, unsigned limit, bool show) throw() : error_handler_base(show), m_body(new error_handler_body(device, limit)) { } error_handler::error_handler(otext& device, const std::string& message_file, unsigned limit, bool show) throw(error_handler_read_error) : error_handler_base(message_file,show), m_body(new error_handler_body(device, limit)) { } error_handler::error_handler(otext& device, const std::vector<std::string>& message_files, unsigned limit, bool show) throw(error_handler_read_error) : error_handler_base(message_files,show), m_body(new error_handler_body(device, limit)) { } error_handler::~error_handler(void) throw() { m_body->device().flush(); } //////////////////////////////////////////////////////////////////////////////// // error count void error_handler::set_error_limit(unsigned error_limit) throw() { m_body->set_limit(error_limit); } unsigned error_handler::error_limit(void) const throw() { return m_body->limit(); } void error_handler::reset_error_count(void) throw() { m_body->set_count(0); } unsigned error_handler::error_count(void) const throw() { return m_body->count(); } otext& error_handler::device(void) { return m_body->device(); } //////////////////////////////////////////////////////////////////////////////// // information messages bool error_handler::information(const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { device() << information_message(id, args) << flush; return true; } bool error_handler::information(const std::string& id) throw(error_handler_id_error,error_handler_format_error) { device() << information_message(id) << flush; return true; } bool error_handler::information(const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error) { device() << information_message(id, arg1) << flush; return true; } bool error_handler::information(const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error) { device() << information_message(id, arg1, arg2) << flush; return true; } bool error_handler::information(const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error) { device() << information_message(id, arg1, arg2, arg3) << flush; return true; } bool error_handler::information(const error_position& position, const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { device() << information_message(position, id, args) << flush; return true; } bool error_handler::information(const error_position& position, const std::string& id) throw(error_handler_id_error,error_handler_format_error) { device() << information_message(position, id) << flush; return true; } bool error_handler::information(const error_position& position, const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error) { device() << information_message(position, id, arg1) << flush; return true; } bool error_handler::information(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error) { device() << information_message(position, id, arg1, arg2) << flush; return true; } bool error_handler::information(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error) { device() << information_message(position, id, arg1, arg2, arg3) << flush; return true; } //////////////////////////////////////////////////////////////////////////////// // warning messages bool error_handler::warning(const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { device() << warning_message(id, args) << flush; return true; } bool error_handler::warning(const std::string& id) throw(error_handler_id_error,error_handler_format_error) { device() << warning_message(id) << flush; return true; } bool error_handler::warning(const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error) { device() << warning_message(id, arg1) << flush; return true; } bool error_handler::warning(const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error) { device() << warning_message(id, arg1, arg2) << flush; return true; } bool error_handler::warning(const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error) { device() << warning_message(id, arg1, arg2, arg3) << flush; return true; } bool error_handler::warning(const error_position& position, const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error) { device() << warning_message(position, id, args) << flush; return true; } bool error_handler::warning(const error_position& position, const std::string& id) throw(error_handler_id_error,error_handler_format_error) { device() << warning_message(position, id) << flush; return true; } bool error_handler::warning(const error_position& position, const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error) { device() << warning_message(position, id, arg1) << flush; return true; } bool error_handler::warning(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error) { device() << warning_message(position, id, arg1, arg2) << flush; return true; } bool error_handler::warning(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error) { device() << warning_message(position, id, arg1, arg2, arg3) << flush; return true; } //////////////////////////////////////////////////////////////////////////////// // error messages bool error_handler::error(const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error,error_handler_limit_error) { device() << error_message(id, args) << flush; m_body->increment(); if (m_body->limit_reached()) throw error_handler_limit_error(m_body->limit()); return false; } bool error_handler::error(const std::string& id) throw(error_handler_id_error,error_handler_format_error,error_handler_limit_error) { device() << error_message(id) << flush; m_body->increment(); if (m_body->limit_reached()) throw error_handler_limit_error(m_body->limit()); return false; } bool error_handler::error(const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error,error_handler_limit_error) { device() << error_message(id, arg1) << flush; m_body->increment(); if (m_body->limit_reached()) throw error_handler_limit_error(m_body->limit()); return false; } bool error_handler::error(const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error,error_handler_limit_error) { device() << error_message(id, arg1, arg2) << flush; m_body->increment(); if (m_body->limit_reached()) throw error_handler_limit_error(m_body->limit()); return false; } bool error_handler::error(const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error,error_handler_limit_error) { device() << error_message(id, arg1, arg2, arg3) << flush; m_body->increment(); if (m_body->limit_reached()) throw error_handler_limit_error(m_body->limit()); return false; } bool error_handler::error(const error_position& position, const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error,error_handler_limit_error) { device() << error_message(position, id, args) << flush; m_body->increment(); if (m_body->limit_reached()) throw error_handler_limit_error(m_body->limit()); return false; } bool error_handler::error(const error_position& position, const std::string& id) throw(error_handler_id_error,error_handler_format_error,error_handler_limit_error) { device() << error_message(position, id) << flush; m_body->increment(); if (m_body->limit_reached()) throw error_handler_limit_error(m_body->limit()); return false; } bool error_handler::error(const error_position& position, const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error,error_handler_limit_error) { device() << error_message(position, id, arg1) << flush; m_body->increment(); if (m_body->limit_reached()) throw error_handler_limit_error(m_body->limit()); return false; } bool error_handler::error(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error,error_handler_limit_error) { device() << error_message(position, id, arg1, arg2) << flush; m_body->increment(); if (m_body->limit_reached()) throw error_handler_limit_error(m_body->limit()); return false; } bool error_handler::error(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error,error_handler_limit_error) { device() << error_message(position, id, arg1, arg2, arg3) << flush; m_body->increment(); if (m_body->limit_reached()) throw error_handler_limit_error(m_body->limit()); return false; } //////////////////////////////////////////////////////////////////////////////// // fatal messages bool error_handler::fatal(const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error,error_handler_fatal_error) { device() << fatal_message(id, args) << flush; throw error_handler_fatal_error(id); } bool error_handler::fatal(const std::string& id) throw(error_handler_id_error,error_handler_format_error,error_handler_fatal_error) { device() << fatal_message(id) << flush; throw error_handler_fatal_error(id); } bool error_handler::fatal(const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error,error_handler_fatal_error) { device() << fatal_message(id, arg1) << flush; throw error_handler_fatal_error(id); } bool error_handler::fatal(const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error,error_handler_fatal_error) { device() << fatal_message(id, arg1, arg2) << flush; throw error_handler_fatal_error(id); } bool error_handler::fatal(const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error,error_handler_fatal_error) { device() << fatal_message(id, arg1, arg2, arg3) << flush; throw error_handler_fatal_error(id); } bool error_handler::fatal(const error_position& position, const std::string& id, const std::vector<std::string>& args) throw(error_handler_id_error,error_handler_format_error,error_handler_fatal_error) { device() << fatal_message(position, id, args) << flush; throw error_handler_fatal_error(id); } bool error_handler::fatal(const error_position& position, const std::string& id) throw(error_handler_id_error,error_handler_format_error,error_handler_fatal_error) { device() << fatal_message(position, id) << flush; throw error_handler_fatal_error(id); } bool error_handler::fatal(const error_position& position, const std::string& id, const std::string& arg1) throw(error_handler_id_error,error_handler_format_error,error_handler_fatal_error) { device() << fatal_message(position, id, arg1) << flush; throw error_handler_fatal_error(id); } bool error_handler::fatal(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2) throw(error_handler_id_error,error_handler_format_error,error_handler_fatal_error) { device() << fatal_message(position, id, arg1, arg2) << flush; throw error_handler_fatal_error(id); } bool error_handler::fatal(const error_position& position, const std::string& id, const std::string& arg1, const std::string& arg2, const std::string& arg3) throw(error_handler_id_error,error_handler_format_error,error_handler_fatal_error) { device() << fatal_message(position, id, arg1, arg2, arg3) << flush; throw error_handler_fatal_error(id); } /////////////////////////////////////////////////////////////////////////////// // plain text bool error_handler::plaintext(const std::string& text) { device() << text << endl << flush; return true; } ////////////////////////////////////////////////////////////////////////////////
[ "schimmi@cb9ff89a-abed-0310-8fc6-a4cabe7d48c9" ]
[ [ [ 1, 1830 ] ] ]
19e597a4f48a2e9b5138c70a45d4438b8d3da5a7
dd007771e947dbed60fe6a80d4f325c4ed006f8c
/WarMode.cpp
e249e173431ab44be6ab614672f107abd2b94eb3
[]
no_license
chenzhi/CameraGame
fccea24426ea5dacbe140b11adc949e043e84ef7
914e1a2b8bb45b729e8d55b4baebc9ba18989b55
refs/heads/master
2016-09-05T20:06:11.694787
2011-09-09T09:09:39
2011-09-09T09:09:39
2,005,632
0
0
null
null
null
null
GB18030
C++
false
false
7,950
cpp
#include "pch.h" #include "WarMode.h" #include "Widget.h" #include "UIWarTwo.h" #include "Application.h" #include "enemy.h" #include "Config.h" #include "WarManager.h" #include "UIWarTwoBalance.h" #include "ogreapp/inputListen.h" #include "EnemyQueue.h" //-------------------------------------------------------- WarModeTwo::WarModeTwo(GameState* pGameState) :WarMode(pGameState),m_pSceneMrg(NULL),m_KillCount(0),m_LostCount(0), m_pUIBalance(NULL),m_Minx(-90.0f),m_Maxx(90.0f), m_Miny(-60.0f),m_Maxy(60.0f),m_Minz(1.5f),m_Maxz(5.0f),m_EnemyLeftTime(3.0f), m_Score(0),m_ContinualKill(0) { m_pSceneMrg=Application::getSingleton().getMainSceneManager(); initUI(); } //-------------------------------------------------------- WarModeTwo::~WarModeTwo() { destroyUI(); } //-------------------------------------------------------- void WarModeTwo::start() { ///重置杀死人数 m_KillCount=0; m_LostCount=0; m_ContinualKill=0; m_Score=0; m_pFireBulletCollect.clear(); ///初始化所有的阵列 initEmemyFormat(); WarManager::getSingleton().addListener(this); WarManager::getSingleton().startWar(); createEnemyQueue(); m_pUIBalance->setVisible(false); m_pUI->setVisible(true); m_pUI->reset(); ///得置摄像机位置 Application::getSingleton().getMainCamera()->getParentSceneNode()->resetOrientation(); } //-------------------------------------------------------- void WarModeTwo::end() { WarManager::getSingleton().removeListener(this); //WarManager::getSingleton().destroyAllEnemyQueue(); } //-------------------------------------------------------- void WarModeTwo::update(float time) { if(m_needCreate) { _createEnemyQueue(); } } //-------------------------------------------------------- void WarModeTwo::beginTouch(int x,int y) { } //-------------------------------------------------------- void WarModeTwo::endTouch(int x,int y) { } ///-------------------------------------------------------- void WarModeTwo::moveTouch(int x,int y) { } //--------------------------------------------------------- void WarModeTwo::initUI() { m_pUI=new UIWarModeTwo(); m_pUI->init(); Application::getSingleton().registerUI(m_pUI); m_pUIBalance=new UIWarTowModeBalance(this); m_pUIBalance->init(); m_pUIBalance->setVisible(false); Application::getSingleton().registerUI(m_pUIBalance); m_pUIBalance->setVisible(false); m_pUI->setVisible(true); m_pUI->reset(); } //--------------------------------------------------------- void WarModeTwo::destroyUI() { Application::getSingleton().destroyUI(m_pUI); m_pUI=NULL; Application::getSingleton().destroyUI(m_pUIBalance); m_pUIBalance=NULL; } //---------------------------------------------------------------- void WarModeTwo::onKillEnemyQueue(EnemyQueue* pEnemyQueue) { m_pUI->onKillEnemyQueue(pEnemyQueue); ++m_KillCount; ///继续创建新的队列 createEnemyQueue(); } //---------------------------------------------------------------- void WarModeTwo::onLostEnemyQueue(EnemyQueue* pEnemyQueue) { m_pUI->onLostEnemyQueue(pEnemyQueue); ++m_LostCount; ///如果大于三个逃跑游戏结束。 //*/ if(m_LostCount>=3) { ///结束比赛 WarManager::getSingleton().endWar(); ///显示结算界面 m_pUIBalance->setVisible(true); m_pUIBalance->setScore(m_Score); m_pUI->setVisible(false); }///继续创建新的队列 else //*/ { createEnemyQueue(); } } //---------------------------------------------------------------- void WarModeTwo::onCrateEnemyQueue(EnemyQueue* pEnemyQueue) { m_pUI->onCrateEnemyQueue(pEnemyQueue); } //---------------------------------------------------------------- void WarModeTwo::onHitFriend(Enemy* pEnemy) { return ; } void WarModeTwo::onHitEnemy(Enemy* pEnemy,bool hitMouth,Bullet* pBullet) { if(m_pFireBulletCollect.empty()==false&&pBullet==m_pFireBulletCollect[0]&&m_pFireBulletCollect.size()<10) { ++m_ContinualKill; m_pFireBulletCollect.erase(m_pFireBulletCollect.begin()); }else { m_ContinualKill=1; m_pFireBulletCollect.clear(); } int Score=50; if(hitMouth==true) { Score=100; } m_Score+=Score*m_ContinualKill; m_pUI->setScore(m_Score); } void WarModeTwo::onfire(Bullet* pBullet) { m_pFireBulletCollect.push_back(pBullet); return; } //----------------------------------------------------------------------- void WarModeTwo::_createEnemyQueue() { ///逃跑数和打死数之合就是创建的队数总数 unsigned int createindex=m_LostCount+m_KillCount; ///如果小于队列数就按队列出 if(createindex>=m_EnemyFormatCollect.size()) { ::srand( time(0) ); //设定随机数种子 createindex=::rand()%m_EnemyFormatCollect.size(); } EnemyQueue* pQueue= WarManager::getSingleton().createEnemyQueue(m_Minx,m_Maxx,m_Miny,m_Maxy,m_Minz,m_Maxz,m_EnemyFormatCollect[createindex].m_EnemyCollect, m_EnemyFormatCollect[createindex].m_FriendCollect); pQueue->setLeftTime(m_EnemyLeftTime); m_needCreate=false; return ; } //----------------------------------------------------------------------- void WarModeTwo::updateAccelerometer() { Ogre::SceneNode* pCameraNode=Application::getSingleton().getMainCameraNode(); Ogre::Vector3 gyrco=InputListen::getSingleton().getGyroscopeData(); float yawtem=gyrco.y; float pitch=gyrco.z; pitch+=Ogre::Math::PI*0.5f; if(pCameraNode!=NULL ) { pCameraNode->resetOrientation(); pCameraNode->yaw(Ogre::Radian(yawtem),Ogre::Node::TS_WORLD); pCameraNode->pitch(Ogre::Radian(-pitch)); } return ; } //----------------------------------------------------------------------- void WarModeTwo::initEmemyFormat() { Ogre::DataStreamPtr pDataStream=Ogre::ResourceGroupManager::getSingleton().openResource("EnemyFormatMode2.cfg","General"); if(pDataStream.isNull()) { OGRE_EXCEPT(0,"can't find warmode1 enemyFormat file","WarModeOne::initEmemyFormat()"); } m_EnemyFormatCollect.clear(); Ogre::ConfigFile cf; cf.load(pDataStream); ///循环取出所有的队列和位置信息 Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); Ogre::String sec, type, arch; //获取所有阵型 while (seci.hasMoreElements()) { sec = seci.peekNextKey(); Ogre::ConfigFile::SettingsMultiMap* settings = seci.getNext(); Ogre::ConfigFile::SettingsMultiMap::iterator i; if(settings->empty()) continue; if(sec.find("Format")!=Ogre::String::npos) { EnemyFormat enemyFormat; m_EnemyFormatCollect.push_back(enemyFormat); } for (i = settings->begin(); i != settings->end(); i++) { type = i->first; arch = i->second; ///如果是设置范围大小的 if(sec=="Enemylimits") { if(type=="Minx") { m_Minx=Ogre::StringConverter::parseReal(arch); }else if(type=="Maxx") { m_Maxx=Ogre::StringConverter::parseReal(arch); }else if(type=="Miny") { m_Miny=Ogre::StringConverter::parseReal(arch); }else if(type=="Maxy") { m_Maxy=Ogre::StringConverter::parseReal(arch); }else if(type=="Minz") { m_Minz=Ogre::StringConverter::parseReal(arch); }else if(type=="Maxz") { m_Maxz=Ogre::StringConverter::parseReal(arch); }else if(type=="LeftTime") { m_EnemyLeftTime=Ogre::StringConverter::parseReal(arch); } }else { Ogre::Vector3 Pos=Ogre::StringConverter::parseVector3(arch); if(type=="Enemy") { m_EnemyFormatCollect.back().m_EnemyCollect.push_back(Pos); }else if(type=="Friend") { m_EnemyFormatCollect.back().m_FriendCollect.push_back(Pos); } } } } return ; }
[ "chenzhi@aee8fb6d-90e1-2f42-9ce8-abdac5710353", "[email protected]" ]
[ [ [ 1, 270 ], [ 272, 381 ] ], [ [ 271, 271 ] ] ]
34ffd52be8bcaa197d37908b01947d68fe8116e3
0043aea568b672f34df4e80015a14f6b03f33ef1
/example/src/example.cpp
a606a58ac063081a74da2a5a111e0fee0d8712de
[]
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
5,302
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 Files #include "example.h" #include <e32base.h> #include <e32std.h> #include <e32cons.h> // Console #include "Json.h" // Constants _LIT(KTextConsoleTitle, "Console"); _LIT(KTextFailed, " failed, leave code = %d"); _LIT(KTextPressAnyKey, " [press any key]\n"); // Global Variables LOCAL_D CConsoleBase* console; // write all messages to this _LIT(KTestFormatedJson, "{\t\"message\":\"test1\r\ntest2\r\n\t\t\ttest3\"}"); // Local Functions LOCAL_C void MainL() { // to json RBuf jsonString; { CJsonObject* root = new (ELeave) CJsonObject(); CJsonObject* project = new (ELeave) CJsonObject(); // this will transfer ownership of project to root object root->AddL(_L("project"), project); project->AddL(_L("name"), _L("s60-json-library")); root->AddBoolL(_L("booleanVariable"), ETrue); root->AddL(_L("nullValue"), (CJsonObject*)NULL); root->AddBoolL(_L("booleanVariable"), ETrue); CJsonArray* values = new (ELeave) CJsonArray(); // this will transfer ownership of values to root object root->AddL(_L("arrayOfValues"), values); values->AddBoolL(ETrue); values->AddIntL(123); values->AddL(_L("string")); values->AddReal32L(1.23); values->AddL((CJsonObject*)NULL); jsonString.Create(256); // convert in memory structure to json string format root->ToStringL(jsonString); // this will release all objects delete root; } // from json { CJsonBuilder* jsonBuilder = CJsonBuilder::NewL(); // this will create json string representation in memory jsonBuilder->BuildFromJsonStringL(jsonString); CJsonObject* rootObject; jsonBuilder->GetDocumentObject(rootObject); if(rootObject) { CJsonObject* project; // this will not transfer ownership, owner of project is rootObject rootObject->GetObjectL(_L("project"), project); if(project) { TBuf<256> name; project->GetStringL(_L("name"), name); } } // we need manually release created object delete rootObject; // releases only jsonBuilder object, not objects which was created by him delete jsonBuilder; } // from formatted json { CJsonBuilder* jsonBuilder = CJsonBuilder::NewL(); // this will create json string representation in memory jsonBuilder->BuildFromJsonStringL(KTestFormatedJson); CJsonObject* rootObject; jsonBuilder->GetDocumentObject(rootObject); if(rootObject) { TBuf<256> message; rootObject->GetStringL(_L("message"), message); } // we need manually release created object delete rootObject; // releases only jsonBuilder object, not objects which was created by him delete jsonBuilder; } // release json string jsonString.Close(); } LOCAL_C void DoStartL() { // Create active scheduler (to run active objects) CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); CleanupStack::PushL(scheduler); CActiveScheduler::Install(scheduler); MainL(); // Delete active scheduler CleanupStack::PopAndDestroy(scheduler); } // Global Functions GLDEF_C TInt E32Main() { // Create cleanup stack __UHEAP_MARK; CTrapCleanup* cleanup = CTrapCleanup::New(); // Create output console TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize( KConsFullScreen, KConsFullScreen))); if (createError) return createError; // Run application code inside TRAP harness, wait keypress when terminated TRAPD(mainError, DoStartL()); if (mainError) console->Printf(KTextFailed, mainError); console->Printf(KTextPressAnyKey); console->Getch(); delete console; delete cleanup; __UHEAP_MARKEND; return KErrNone; }
[ "wach.piotrek@b73fb3d4-a2a3-11de-a23d-972bf86d3223" ]
[ [ [ 1, 180 ] ] ]
3bdf86e9f4235dd6d60e6791b88ab2ac91dda62d
305f56324b8c1625a5f3ba7966d1ce6c540e9d97
/src/Urp/UrpGrid.h
8568fb98c6117e23b4c76a05e38363facf65c1e6
[]
no_license
radtek/lister
be45f7ac67da72c1c2ac0d7cd878032c9648af7b
71418c72b31823624f545ad86cc804c43b6e9426
refs/heads/master
2021-01-01T19:56:30.878680
2011-06-22T17:04:13
2011-06-22T17:04:13
41,946,076
0
0
null
null
null
null
UTF-8
C++
false
false
4,884
h
#ifndef _Urp_UrpGrid_h_ #define _Urp_UrpGrid_h_ #include "UrpShared.h" #include "UrpGridCommon.h" #include <lister/GridCtrl/GridCtrl.h> class Connection; // Urp has no connection class (yet) so lister, our primary user, defines it. #define HIDDEN_COLUMN -2 #define NOSELECTION -4 //============================================================================================== // abstract base class; ye canna instantiate class UrpGrid: public GridCtrl, public UrpGridCommon { public: typedef UrpGrid CLASSNAME; // action taken within grid and passed back to updator enum GridAction { ADDEDROWSFROMDB, USERADDEDROW, ADDEDSTRUCTURE, USERCHANGEDDATA, DELETEDROWS }; // Build function of subclass should set to true, but no biggy; Its more for the subclasses. Urp doesn't use yet or expect any settings. // TaskDefWin does look at this flag. bool built; // Load function of subclass should set to true; The idea is to reduce work of reloading unnecessarily, but hard to get it to work bool loaded; // Loose add so grids like TestGrid will call TestWin to update its // toolbar when testrows are added, columns added, etc. Callback1<GridAction> WhenToolBarNeedsUpdating; UrpGrid (); // Mandatory implementations (pure virtual functions) virtual void Build (Connection * pconnection) = 0; virtual void Load () = 0; virtual void BuildBase (Connection * pconnection); // Call this from your implementor to do general stuff virtual void LoadBase (); // Call this from your implementor to do general stuff virtual void BuildComplete (); virtual void LoadComplete (); virtual bool Key (dword key, int count) { return GridCtrl::Key(key, count); }; // Old windows have coked-up XML with bizarre widths. This should help (menu item) void NormalizeColumnWidth (); // Obviously, U++ developer Uno was being a total dickwad when he refused to give a function // to extract column widths, so I've created it. int GetFloatingColumnWidth (int colno); // Series of corrective functions to deal with Lamo Uno's confusion about when and when not to adjust references for fixed columns int GetFloatingColumnCount (); void UnhideFloatingColumnSilently(int colno); void HideFloatingColumn (int colno); void SetFloatingColumnWidth (int colno, int w); Id GetFloatingColumnId (int colno) const; // Strange that this function was not present in U++ before. int GetFloatingColumnNo (Id id); GridCtrl::ItemRect& GetFloatingColumn (int colno); int GetFirstSelection (); int CalcCorrectRow (int row); int GetProcessOrder (int row = -1); int GetMaxProcessOrder (); // After the last(max) one, that is. int GetNextProcessOrder (); // Find an available "hole" after the one passed, needed for renumbering int GetNextFreeProcessOrder (int startAfterRow, int startAtProcessOrder); // Called when rows were dragged and dropped back in the same grid. void MovedRows (); void HideColumnUnderMouse (); // Trick: Impementor must implement SaveRow or any reordering by drag/drop won't be persisted to the database. virtual void SaveRow (int row, int newProcessOrder); void StdMenuBar (Bar &bar); // GridCtrl is supposed to Xmlize, but I don't see it doing anything, so I've written my own. // Have to save by column name so that the adding or subtracting of // columns does not cause corruption. // Also, we save hidden state by name instead of position, which can really mess with a grid. // Needs work. Gets confused around hiding/unhiding of columns with negative widths. void Xmlize (XmlIO xml); }; #endif
[ "jeffshumphreys@97668ed5-8355-0e3d-284e-ab2976d7b0b4" ]
[ [ [ 1, 93 ] ] ]
d91dcb486161b5b58966242ae459c198fea5ed90
cfcd2a448c91b249ea61d0d0d747129900e9e97f
/thirdparty/OpenCOLLADA/COLLADAFramework/include/COLLADAFWShaderPhong.h
689ecaddd454a7835c83bd576ca0420136f66465
[]
no_license
fire-archive/OgreCollada
b1686b1b84b512ffee65baddb290503fb1ebac9c
49114208f176eb695b525dca4f79fc0cfd40e9de
refs/heads/master
2020-04-10T10:04:15.187350
2009-05-31T15:33:15
2009-05-31T15:33:15
268,046
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
2,924
h
/* Copyright (c) 2008 NetAllied Systems GmbH This file is part of COLLADAFramework. Licensed under the MIT Open Source License, for details please see LICENSE file or the website http://www.opensource.org/licenses/mit-license.php */ #ifndef __COLLADAFW_SHADERPHONG_H__ #define __COLLADAFW_SHADERPHONG_H__ #include "COLLADAFWPrerequisites.h" #include "COLLADAFWShaderLambert.h" namespace COLLADAFW { /** Produces a specularly shaded surface where the specular reflection is shaded according the Phong BRDF approximation. Used inside a <profile_COMMON> effect, declares a fixed-function pipeline that produces a specularly shaded surface that reflects ambient, diffuse, and specular reflection, where the specular reflection is shaded according the Phong BRDF approximation. The <phong> shader uses the common Phong shading equation, that is: color = <emission> + <ambient> * al + <diffuse> * max ( N * L, 0 ) + <specular> * max ( R * I, 0 )^<shininess> where: • al — A constant amount of ambient light contribution coming from the scene. In the COMMON profile, this is the sum of all the <light><technique_common><ambient><color> values in the <visual_scene>. • N — Normal vector • L — Light vector • I — Eye vector • R — Perfect reflection vector (reflect (L around N)) */ class ShaderPhong : public ShaderLambert { private: /** Declares the color of light specularly reflected from the surface of this object. */ ColorOrTexture mSpecular; /** Declares the specularity or roughness of the specular reflection lobe. */ FloatOrParam mShininess; public: /** Constructor. */ ShaderPhong() {}; /** Destructor. */ virtual ~ShaderPhong() {}; /** Declares the color of light specularly reflected from the surface of this object. */ const COLLADAFW::ColorOrTexture getSpecular () const { return mSpecular; } /** Declares the color of light specularly reflected from the surface of this object. */ void setSpecular ( const COLLADAFW::ColorOrTexture Specular ) { mSpecular = Specular; } /** Declares the specularity or roughness of the specular reflection lobe. */ const COLLADAFW::FloatOrParam getShininess () const { return mShininess; } /** Declares the specularity or roughness of the specular reflection lobe. */ void setShininess ( const COLLADAFW::FloatOrParam Shininess ) { mShininess = Shininess; } private: /** Disable default copy ctor. */ ShaderPhong( const ShaderPhong& pre ); /** Disable default assignment operator. */ const ShaderPhong& operator= ( const ShaderPhong& pre ); }; } // namespace COLLADAFW #endif // __COLLADAFW_SHADERPHONG_H__
[ [ [ 1, 83 ] ] ]
0d41e239cabd2c0ffcbc333bab5a36b0012d7230
b4d726a0321649f907923cc57323942a1e45915b
/CODE/SOUND/winmidi_base.cpp
7d7be2220ed2216131a9b04a6edc78b0b4b024bc
[]
no_license
chief1983/Imperial-Alliance
f1aa664d91f32c9e244867aaac43fffdf42199dc
6db0102a8897deac845a8bd2a7aa2e1b25086448
refs/heads/master
2016-09-06T02:40:39.069630
2010-10-06T22:06:24
2010-10-06T22:06:24
967,775
2
0
null
null
null
null
UTF-8
C++
false
false
1,048
cpp
/* * Copyright (C) Volition, Inc. 1999. All rights reserved. * * All source code herein is the property of Volition, Inc. You may not sell * or otherwise commercially exploit the source or things you created based on the * source. * */ /* * $Logfile: /Freespace2/code/Sound/winmidi_base.cpp $ * $Revision: 1.1.1.1 $ * $Date: 2004/08/13 22:47:43 $ * $Author: Spearhawk $ * * C module that contains mid-level MIDI functions for streaming data * * $Log: winmidi_base.cpp,v $ * Revision 1.1.1.1 2004/08/13 22:47:43 Spearhawk * no message * * Revision 1.1.1.1 2004/08/13 21:34:38 Darkhill * no message * * Revision 2.0 2002/06/03 04:02:29 penguin * Warpcore CVS sync * * Revision 1.1 2002/05/02 18:03:13 mharris * Initial checkin - converted filenames and includes to lower case * * * 2 10/07/98 10:54a Dave * Initial checkin. * * 1 10/07/98 10:51a Dave * * 3 1/19/98 11:37p Lawrance * Fixing Optimization build warnings * * * $NoKeywords: $ */
[ [ [ 1, 42 ] ] ]
2d782033c2ccba72640dded50e66af44697d1816
143ada25a90b28c2ee28d2105d4584c0f2a7480d
/include/detail/datasource.hpp
02a454bcc8d24e8101c7b2788dc1b52add4672bc
[]
no_license
brightman/mapreduce
a311285c13db5c4f93d4a6ec2adfb1a3ac14d271
9b93a7300f0c7ffc8896f92f83cdd4d3321aa4e7
refs/heads/master
2021-01-20T22:59:51.992563
2011-04-30T13:14:26
2011-04-30T13:14:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,813
hpp
// MapReduce library // // Copyright (C) 2009 Craig Henderson. // [email protected] // // Use, modification and distribution is subject to the // Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // For more information, see http://craighenderson.co.uk/mapreduce/ // #ifndef DATASOURCE_SCHEDULE_POLICY_HPP #define DATASOURCE_SCHEDULE_POLICY_HPP #include <boost/iostreams/device/mapped_file.hpp> namespace mapreduce { namespace datasource { namespace detail { template<typename Key, typename Value> class file_handler : boost::noncopyable { public: file_handler(mapreduce::specification const &spec) : specification_(spec), data_(new data) { } bool const get_data(Key const &key, Value &value) const; bool const setup_key(Key &/*key*/) const { return false; } private: mapreduce::specification const &specification_; struct data; boost::shared_ptr<data> data_; }; template<> struct file_handler< std::string, std::ifstream>::data { }; template<> bool const file_handler< std::string, std::ifstream>::get_data( std::string const &key, std::ifstream &value) const { value.open(key.c_str()); return value.is_open(); } template<> struct file_handler< std::string, std::pair< char const *, char const *> >::data { struct detail { boost::iostreams::mapped_file mmf; // memory mapped file boost::uintmax_t size; // size of the file boost::uintmax_t offset; // offset to map next time }; typedef std::map<std::string, boost::shared_ptr<detail> > maps_t; maps_t maps; boost::mutex mutex; std::string current_file; }; template<> bool const file_handler< std::string, std::pair< char const *, char const *> >::get_data( std::string const &key, std::pair<char const *, char const *> &value) const { // we need to hold the lock for the duration of this function boost::mutex::scoped_lock l(data_->mutex); data::maps_t::iterator it; if (data_->current_file.empty()) { data_->current_file = key; it = data_->maps.insert(std::make_pair(key, boost::shared_ptr<data::detail>(new data::detail))).first; it->second->mmf.open(key, BOOST_IOS::in); if (!it->second->mmf.is_open()) { std::cout << "\nFailed to map file into memory: " << key; return false; } it->second->size = boost::filesystem::file_size(key); it->second->offset = std::min(specification_.max_file_segment_size, it->second->size); value.first = it->second->mmf.const_data(); value.second = value.first + it->second->offset; } else { BOOST_ASSERT(key == data_->current_file); it = data_->maps.find(key); BOOST_ASSERT(it != data_->maps.end()); value.first = it->second->mmf.const_data() + it->second->offset; it->second->offset = std::min(it->second->offset+specification_.max_file_segment_size, it->second->size); value.second = it->second->mmf.const_data() + it->second->offset; } if (it->second->offset == it->second->size) data_->current_file.clear(); // break on a line boundary while (*value.second != '\n' && *value.second != '\r' && it->second->offset != it->second->size) { ++value.second; ++it->second->offset; } return true; } template<> bool const file_handler< std::string, std::pair< char const *, char const *> >::setup_key(std::string &key) const { boost::mutex::scoped_lock l(data_->mutex); if (data_->current_file.empty()) return false; key = data_->current_file; return true; } } // namespace detail template< typename MapTask, typename FileHandler = detail::file_handler< typename MapTask::key_type, typename MapTask::value_type> > class directory_iterator : boost::noncopyable { public: directory_iterator(mapreduce::specification const &spec) : specification_(spec), file_handler_(spec) { it_dir_ = boost::filesystem::basic_directory_iterator<path_t>(specification_.input_directory); } bool const setup_key(typename MapTask::key_type &key) const { if (!file_handler_.setup_key(key)) { while (it_dir_ != boost::filesystem::basic_directory_iterator<path_t>() && boost::filesystem::is_directory(*it_dir_)) { ++it_dir_; } if (it_dir_ == boost::filesystem::basic_directory_iterator<path_t>()) return false; path_t path = *it_dir_++; key = path.external_file_string(); } return true; } bool const get_data(typename MapTask::key_type &key, typename MapTask::value_type &value) const { return file_handler_.get_data(key, value); } private: typedef boost::filesystem::basic_path<std::string, boost::filesystem::path_traits> path_t; mutable boost::filesystem::basic_directory_iterator<path_t> it_dir_; std::string directory_; mapreduce::specification const &specification_; FileHandler file_handler_; }; } // namespace datasource } // namespace mapreduce #endif // DATASOURCE_SCHEDULE_POLICY_HPP
[ [ [ 1, 210 ] ] ]
74dd265a468b60fb921648f6559539f6badbf81b
9eaa698f624abd80019ac7e3c53304950daa66ba
/ui/widgets/talkwidget.h
ea2f7b26c484adec9e6e83f9fbed7484a1082bc1
[]
no_license
gan7488/happ-talk-jchat
8f2e3f1437a683ec16d3bc4d0d36e409df088a94
182cec6e496401b4ea8f108fb711b05a775232b4
refs/heads/master
2021-01-10T11:14:23.607688
2011-05-17T17:30:57
2011-05-17T17:30:57
52,271,940
0
0
null
null
null
null
UTF-8
C++
false
false
1,760
h
/****************************************************************************** ** Author: Svirskiy Sergey Nickname: Happ ******************************************************************************/ #ifndef TALKWIDGET_H #define TALKWIDGET_H #include <QWidget> #include <gloox/jid.h> class QTextEdit; class MessageWidget; class QPushButton; class QWidget; using namespace gloox; /** * @brief Widget that implements the conversation. */ class TalkWidget : public QWidget { Q_OBJECT public: explicit TalkWidget(QWidget *parent = 0, QWidget *info = 0); /** * @brief Set companion. * @param target Companions JID. */ void setTarget(const JID &target) { m_jid = target; } /** * @brief Get companion. */ JID target() { return m_jid; } signals: /** * @brief Send message. * @param target For whom the message is intended. * @param msg Message to send. */ void sendMessage(const JID& target, const QString &msg); public slots: /** * @brief Message recieved from @ref target(); * @param msg Recieved message. */ void messageReceived(const QString &msg); private slots: void sendMessage(); private: /** * @brief Creating widgets. */ void createElements(); /** * @brief Layout widgets. */ void layoutElements(); /* Elements */ JID m_jid; QTextEdit *story; MessageWidget *message; QPushButton *send; QPushButton *bold; QPushButton *italic; QPushButton *underline; QPushButton *strikeout; QPushButton *fontSize; QWidget *info; }; #endif // TALKWIDGET_H
[ [ [ 1, 86 ] ] ]
18d6276285a3a946f820b7703e1cd380304c4373
3187b0dd0d7a7b83b33c62357efa0092b3943110
/src/dlib/svm/svm.h
7cb8f263109268b5f08b8e717ad66efc97dbce04
[ "BSL-1.0" ]
permissive
exi/gravisim
8a4dad954f68960d42f1d7da14ff1ca7a20e92f2
361e70e40f58c9f5e2c2f574c9e7446751629807
refs/heads/master
2021-01-19T17:45:04.106839
2010-10-22T09:11:24
2010-10-22T09:11:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
37,978
h
// Copyright (C) 2007 Davis E. King ([email protected]) // License: Boost Software License See LICENSE.txt for the full license. #ifndef DLIB_SVm_ #define DLIB_SVm_ #include "svm_abstract.h" #include <cmath> #include <limits> #include <sstream> #include "../matrix.h" #include "../algs.h" #include "../serialize.h" #include "../rand.h" #include "../std_allocator.h" #include "function.h" #include "kernel.h" namespace dlib { // ---------------------------------------------------------------------------------------- template < typename T > typename T::type maximum_nu ( const T& y ) { typedef typename T::type scalar_type; // make sure requires clause is not broken DLIB_ASSERT(y.nr() > 1 && y.nc() == 1, "\ttypedef T::type maximum_nu(y)" << "\n\ty should be a column vector with more than one entry" << "\n\ty.nr(): " << y.nr() << "\n\ty.nc(): " << y.nc() ); long pos_count = 0; long neg_count = 0; for (long r = 0; r < y.nr(); ++r) { if (y(r) == 1.0) { ++pos_count; } else if (y(r) == -1.0) { ++neg_count; } else { // make sure requires clause is not broken DLIB_ASSERT(y(r) == -1.0 || y(r) == 1.0, "\ttypedef T::type maximum_nu(y)" << "\n\ty should contain only 1 and 0 entries" << "\n\tr: " << r << "\n\ty(r): " << y(r) ); } } return static_cast<scalar_type>(2.0*(scalar_type)std::min(pos_count,neg_count)/(scalar_type)y.nr()); } // ---------------------------------------------------------------------------------------- template < typename K > class kernel_matrix_cache { typedef typename K::scalar_type scalar_type; typedef typename K::sample_type sample_type; typedef typename K::mem_manager_type mem_manager_type; const matrix<sample_type,0,1,mem_manager_type>& x; const matrix<scalar_type,0,1,mem_manager_type>& y; K kernel_function; mutable matrix<scalar_type,0,0,mem_manager_type> cache; mutable matrix<scalar_type,0,1,mem_manager_type> diag_cache; mutable matrix<long,0,1,mem_manager_type> lookup; mutable matrix<long,0,1,mem_manager_type> rlookup; mutable long next; /*! INITIAL VALUE - for all valid x: - lookup(x) == -1 - rlookup(x) == -1 CONVENTION - if (lookup(c) != -1) then - cache(lookup(c),*) == the cached column c of the kernel matrix - rlookup(lookup(c)) == c - if (rlookup(x) != -1) then - lookup(rlookup(x)) == x - cache(x,*) == the cached column rlookup(x) of the kernel matrix - next == the next row in the cache table to use to cache something !*/ public: kernel_matrix_cache ( const matrix<sample_type,0,1,mem_manager_type>& x_, const matrix<scalar_type,0,1,mem_manager_type>& y_, K kernel_function_, long max_size_megabytes ) : x(x_), y(y_), kernel_function(kernel_function_) { // figure out how many rows of the kernel matrix we can have // with the given amount of memory. long max_size = (max_size_megabytes*1024*1024)/(x.nr()*sizeof(scalar_type)); // don't let it be 0 if (max_size == 0) max_size = 1; long size = std::min(max_size,x.nr()); diag_cache.set_size(x.nr(),1); cache.set_size(size,x.nr()); lookup.set_size(x.nr(),1); rlookup.set_size(size,1); set_all_elements(lookup,-1); set_all_elements(rlookup,-1); next = 0; for (long i = 0; i < diag_cache.nr(); ++i) diag_cache(i) = kernel_function(x(i),x(i)); } inline bool is_cached ( long r ) const { return (lookup(r) != -1); } inline scalar_type operator () ( long r, long c ) const { if (lookup(c) != -1) { return cache(lookup(c),r); } else if (r == c) { return diag_cache(r); } else if (lookup(r) != -1) { // the kernel is symmetric so this is legit return cache(lookup(r),c); } else { // if the lookup table is pointing to cache(next,*) then clear lookup(next) if (rlookup(next) != -1) lookup(rlookup(next)) = -1; // make the lookup table os that it says c is now cached at the spot indicated by next lookup(c) = next; rlookup(next) = c; // compute this column in the kernel matrix and store it in the cache for (long i = 0; i < cache.nc(); ++i) cache(next,i) = y(c)*y(i)*kernel_function(x(c),x(i)); scalar_type val = cache(next,r); next = (next + 1)%cache.nr(); return val; } } }; // ---------------------------------------------------------------------------------------- template < typename scalar_type, typename scalar_vector_type > inline void set_initial_alpha ( const scalar_vector_type& y, const scalar_type nu, scalar_vector_type& alpha ) { set_all_elements(alpha,0); const scalar_type l = y.nr(); scalar_type temp = nu*l/2; long num = (long)std::floor(temp); long num_total = (long)std::ceil(temp); int count = 0; for (int i = 0; i < alpha.nr(); ++i) { if (y(i) == 1) { if (count < num) { ++count; alpha(i) = 1; } else { if (temp > num) { ++count; alpha(i) = temp - std::floor(temp); } break; } } } if (count != num_total) { std::ostringstream sout; sout << "invalid nu of " << nu << ". Must be between 0 and " << (scalar_type)count/y.nr(); throw error(sout.str()); } count = 0; for (int i = 0; i < alpha.nr(); ++i) { if (y(i) == -1) { if (count < num) { ++count; alpha(i) = 1; } else { if (temp > num) { ++count; alpha(i) = temp - std::floor(temp); } break; } } } if (count != num_total) { std::ostringstream sout; sout << "invalid nu of " << nu << ". Must be between 0 and " << (scalar_type)count/y.nr(); throw error(sout.str()); } } // ---------------------------------------------------------------------------------------- template < typename K, typename scalar_vector_type, typename scalar_type > inline bool find_working_group ( const scalar_vector_type& y, const scalar_vector_type& alpha, const kernel_matrix_cache<K>& Q, const scalar_vector_type& df, const scalar_type tau, const scalar_type eps, long& i_out, long& j_out ) { using namespace std; long ip = -1; long jp = -1; long in = -1; long jn = -1; scalar_type ip_val = -numeric_limits<scalar_type>::infinity(); scalar_type jp_val = numeric_limits<scalar_type>::infinity(); scalar_type in_val = -numeric_limits<scalar_type>::infinity(); scalar_type jn_val = numeric_limits<scalar_type>::infinity(); // loop over the alphas and find the maximum ip and in indices. for (long i = 0; i < alpha.nr(); ++i) { if (y(i) == 1) { if (alpha(i) < 1.0) { if (-df(i) > ip_val) { ip_val = -df(i); ip = i; } } } else { if (alpha(i) > 0.0) { if (df(i) > in_val) { in_val = df(i); in = i; } } } } scalar_type Mp = numeric_limits<scalar_type>::infinity(); scalar_type Mn = numeric_limits<scalar_type>::infinity(); scalar_type bp = -numeric_limits<scalar_type>::infinity(); scalar_type bn = -numeric_limits<scalar_type>::infinity(); // now we need to find the minimum jp and jn indices for (long j = 0; j < alpha.nr(); ++j) { if (y(j) == 1) { if (alpha(j) > 0.0) { scalar_type b = ip_val + df(j); if (-df(j) < Mp) Mp = -df(j); if (b > 0 && (Q.is_cached(j) || b > bp || jp == -1 )) { bp = b; scalar_type a = Q(ip,ip) + Q(j,j) - 2*Q(j,ip); if (a <= 0) a = tau; scalar_type temp = -b*b/a; if (temp < jp_val) { jp_val = temp; jp = j; } } } } else { if (alpha(j) < 1.0) { scalar_type b = in_val - df(j); if (df(j) < Mn) Mn = df(j); if (b > 0 && (Q.is_cached(j) || b > bn || jn == -1 )) { bn = b; scalar_type a = Q(in,in) + Q(j,j) - 2*Q(j,in); if (a <= 0) a = tau; scalar_type temp = -b*b/a; if (temp < jn_val) { jn_val = temp; jn = j; } } } } } // if we are at the optimal point then return false so the caller knows // to stop optimizing if (std::max(ip_val - Mp, in_val - Mn) < eps) return false; if (jp_val < jn_val) { i_out = ip; j_out = jp; } else { i_out = in; j_out = jn; } if (j_out >= 0 && i_out >= 0) return true; else return false; } // ---------------------------------------------------------------------------------------- template < typename scalar_vector_type, typename scalar_type > void calculate_rho_and_b( const scalar_vector_type& y, const scalar_vector_type& alpha, const scalar_vector_type& df, scalar_type& rho, scalar_type& b ) { using namespace std; long num_p_free = 0; long num_n_free = 0; scalar_type sum_p_free = 0; scalar_type sum_n_free = 0; scalar_type upper_bound_p = -numeric_limits<scalar_type>::infinity(); scalar_type upper_bound_n = -numeric_limits<scalar_type>::infinity(); scalar_type lower_bound_p = numeric_limits<scalar_type>::infinity(); scalar_type lower_bound_n = numeric_limits<scalar_type>::infinity(); for(long i = 0; i < alpha.nr(); ++i) { if(y(i) == 1) { if(alpha(i) == 1) { if (df(i) > upper_bound_p) upper_bound_p = df(i); } else if(alpha(i) == 0) { if (df(i) < lower_bound_p) lower_bound_p = df(i); } else { ++num_p_free; sum_p_free += df(i); } } else { if(alpha(i) == 1) { if (df(i) > upper_bound_n) upper_bound_n = df(i); } else if(alpha(i) == 0) { if (df(i) < lower_bound_n) lower_bound_n = df(i); } else { ++num_n_free; sum_n_free += df(i); } } } scalar_type r1,r2; if(num_p_free > 0) r1 = sum_p_free/num_p_free; else r1 = (upper_bound_p+lower_bound_p)/2; if(num_n_free > 0) r2 = sum_n_free/num_n_free; else r2 = (upper_bound_n+lower_bound_n)/2; rho = (r1+r2)/2; b = (r1-r2)/2/rho; } // ---------------------------------------------------------------------------------------- template < typename K, typename scalar_vector_type, typename scalar_type > inline void optimize_working_pair ( const scalar_vector_type& y, scalar_vector_type& alpha, const kernel_matrix_cache<K>& Q, const scalar_vector_type& df, const scalar_type tau, const long i, const long j ) { scalar_type quad_coef = Q(i,i)+Q(j,j)-2*Q(j,i); if (quad_coef <= 0) quad_coef = tau; scalar_type delta = (df(i)-df(j))/quad_coef; scalar_type sum = alpha(i) + alpha(j); alpha(i) -= delta; alpha(j) += delta; if(sum > 1) { if(alpha(i) > 1) { alpha(i) = 1; alpha(j) = sum - 1; } else if(alpha(j) > 1) { alpha(j) = 1; alpha(i) = sum - 1; } } else { if(alpha(j) < 0) { alpha(j) = 0; alpha(i) = sum; } else if(alpha(i) < 0) { alpha(i) = 0; alpha(j) = sum; } } } // ---------------------------------------------------------------------------------------- template < typename K > const decision_function<K> svm_nu_train ( const typename decision_function<K>::sample_vector_type& x, const typename decision_function<K>::scalar_vector_type& y, const K& kernel_function, const typename K::scalar_type nu, const long cache_size = 200, const typename K::scalar_type eps = 0.001 ) { typedef typename K::scalar_type scalar_type; typedef typename decision_function<K>::sample_vector_type sample_vector_type; typedef typename decision_function<K>::scalar_vector_type scalar_vector_type; // make sure requires clause is not broken #ifdef ENABLE_ASSERTS for (long r = 0; r < y.nr(); ++r) { DLIB_ASSERT(y(r) == -1.0 || y(r) == 1.0, "\tdecision_function svm_nu_train()" << "\n\tinvalid inputs were given to this function" << "\n\tr: " << r << "\n\ty(r): " << y(r) ); } #endif DLIB_ASSERT(x.nr() > 1 && y.nr() == x.nr(), "\tdecision_function svm_nu_train()" << "\n\tinvalid inputs were given to this function" << "\n\tx.nr(): " << x.nr() << "\n\ty.nr(): " << y.nr() << "\n\tx.nc(): " << x.nc() << "\n\ty.nc(): " << y.nc() ); DLIB_ASSERT(eps > 0 && cache_size > 0 && 0 < nu && nu < maximum_nu(y), "\tdecision_function svm_nu_train()" << "\n\tinvalid inputs were given to this function" << "\n\teps: " << eps << "\n\tcache_size: " << cache_size << "\n\tnu: " << nu << "\n\tmaximum_nu(y): " << maximum_nu(y) ); const scalar_type tau = 1e-12; scalar_vector_type df; // delta f(alpha) scalar_vector_type alpha; kernel_matrix_cache<K> Q(x,y,kernel_function,cache_size); alpha.set_size(x.nr()); df.set_size(x.nr()); // now initialize alpha set_initial_alpha(y, nu, alpha); // initialize df. Compute df = Q*alpha for (long r = 0; r < df.nr(); ++r) { df(r) = 0; for (long c = 0; c < alpha.nr(); ++c) { if (alpha(c) != 0) df(r) += Q(c,r)*alpha(c); } } // now perform the actual optimization of alpha long i, j; while (find_working_group(y,alpha,Q,df,tau,eps,i,j)) { const scalar_type old_alpha_i = alpha(i); const scalar_type old_alpha_j = alpha(j); optimize_working_pair(y,alpha,Q,df,tau,i,j); // update the df vector now that we have modified alpha(i) and alpha(j) scalar_type delta_alpha_i = alpha(i) - old_alpha_i; scalar_type delta_alpha_j = alpha(j) - old_alpha_j; for(long k = 0; k < df.nr(); ++k) df(k) += Q(k,i)*delta_alpha_i + Q(k,j)*delta_alpha_j; } scalar_type rho, b; calculate_rho_and_b(y,alpha,df,rho,b); alpha = pointwise_multiply(alpha,y)/rho; // count the number of support vectors long sv_count = 0; for (long i = 0; i < alpha.nr(); ++i) { if (alpha(i) != 0) ++sv_count; } scalar_vector_type sv_alpha; sample_vector_type support_vectors; // size these column vectors so that they have an entry for each support vector sv_alpha.set_size(sv_count); support_vectors.set_size(sv_count); // load the support vectors and their alpha values into these new column matrices long idx = 0; for (long i = 0; i < alpha.nr(); ++i) { if (alpha(i) != 0) { sv_alpha(idx) = alpha(i); support_vectors(idx) = x(i); ++idx; } } // now return the decision function return decision_function<K> (sv_alpha, b, kernel_function, support_vectors); } // ---------------------------------------------------------------------------------------- template < typename K > const matrix<typename K::scalar_type, 1, 2, typename K::mem_manager_type> svm_nu_cross_validate ( const typename decision_function<K>::sample_vector_type& x, const typename decision_function<K>::scalar_vector_type& y, const K& kernel_function, const typename K::scalar_type nu, const long folds, const long cache_size = 200, const typename K::scalar_type eps = 0.001 ) { typedef typename K::scalar_type scalar_type; typedef typename decision_function<K>::sample_vector_type sample_vector_type; typedef typename decision_function<K>::scalar_vector_type scalar_vector_type; // make sure requires clause is not broken #ifdef ENABLE_ASSERTS for (long r = 0; r < y.nr(); ++r) { DLIB_ASSERT(y(r) == -1.0 || y(r) == 1.0, "\tdecision_function svm_nu_cross_validate()" << "\n\tinvalid inputs were given to this function" << "\n\tr: " << r << "\n\ty(r): " << y(r) ); } #endif DLIB_ASSERT(x.nr() > 1 && y.nr() == x.nr(), "\tdecision_function svm_nu_cross_validate()" << "\n\tinvalid inputs were given to this function" << "\n\tx.nr(): " << x.nr() << "\n\ty.nr(): " << y.nr() << "\n\tx.nc(): " << x.nc() << "\n\ty.nc(): " << y.nc() ); DLIB_ASSERT(eps > 0 && folds > 1 && folds <= x.nr() && cache_size > 0 && 0 < nu && nu < maximum_nu(y), "\tdecision_function svm_nu_cross_validate()" << "\n\tinvalid inputs were given to this function" << "\n\teps: " << eps << "\n\tfolds: " << folds << "\n\tcache_size: " << cache_size << "\n\tnu: " << nu << "\n\tmaximum_nu(y): " << maximum_nu(y) ); // count the number of positive and negative examples long num_pos = 0; long num_neg = 0; for (long r = 0; r < y.nr(); ++r) { if (y(r) == +1.0) ++num_pos; else ++num_neg; } // figure out how many positive and negative examples we will have in each fold const long num_pos_test_samples = num_pos/folds; const long num_pos_train_samples = num_pos - num_pos_test_samples; const long num_neg_test_samples = num_neg/folds; const long num_neg_train_samples = num_neg - num_neg_test_samples; long num_pos_correct = 0; long num_neg_correct = 0; decision_function<K> d; typename decision_function<K>::sample_vector_type x_test, x_train; typename decision_function<K>::scalar_vector_type y_test, y_train; x_test.set_size (num_pos_test_samples + num_neg_test_samples); y_test.set_size (num_pos_test_samples + num_neg_test_samples); x_train.set_size(num_pos_train_samples + num_neg_train_samples); y_train.set_size(num_pos_train_samples + num_neg_train_samples); long pos_idx = 0; long neg_idx = 0; for (long i = 0; i < folds; ++i) { long cur = 0; // load up our positive test samples while (cur < num_pos_test_samples) { if (y(pos_idx) == +1.0) { x_test(cur) = x(pos_idx); y_test(cur) = +1.0; ++cur; } pos_idx = (pos_idx+1)%x.nr(); } // load up our negative test samples while (cur < x_test.nr()) { if (y(neg_idx) == -1.0) { x_test(cur) = x(neg_idx); y_test(cur) = -1.0; ++cur; } neg_idx = (neg_idx+1)%x.nr(); } // load the training data from the data following whatever we loaded // as the testing data long train_pos_idx = pos_idx; long train_neg_idx = neg_idx; cur = 0; // load up our positive train samples while (cur < num_pos_train_samples) { if (y(train_pos_idx) == +1.0) { x_train(cur) = x(train_pos_idx); y_train(cur) = +1.0; ++cur; } train_pos_idx = (train_pos_idx+1)%x.nr(); } // load up our negative train samples while (cur < x_train.nr()) { if (y(train_neg_idx) == -1.0) { x_train(cur) = x(train_neg_idx); y_train(cur) = -1.0; ++cur; } train_neg_idx = (train_neg_idx+1)%x.nr(); } // do the training d = svm_nu_train (x_train,y_train,kernel_function,nu,cache_size,eps); // now test this fold for (long i = 0; i < x_test.nr(); ++i) { // if this is a positive example if (y_test(i) == +1.0) { if (d(x_test(i)) >= 0) ++num_pos_correct; } else if (y_test(i) == -1.0) { if (d(x_test(i)) < 0) ++num_neg_correct; } else { throw dlib::error("invalid input labels to the svm_nu_cross_validate() function"); } } } // for (long i = 0; i < folds; ++i) matrix<typename K::scalar_type, 1, 2, typename K::mem_manager_type> res; res(0) = (scalar_type)num_pos_correct/(scalar_type)(num_pos_test_samples*folds); res(1) = (scalar_type)num_neg_correct/(scalar_type)(num_neg_test_samples*folds); return res; } // ---------------------------------------------------------------------------------------- template < typename K > const probabilistic_decision_function<K> svm_nu_train_prob ( const typename decision_function<K>::sample_vector_type& x, const typename decision_function<K>::scalar_vector_type& y, const K& kernel_function, const typename K::scalar_type nu, const long folds, const long cache_size = 200, const typename K::scalar_type eps = 0.001 ) { typedef typename K::scalar_type scalar_type; typedef typename K::mem_manager_type mem_manager_type; typedef typename decision_function<K>::sample_vector_type sample_vector_type; typedef typename decision_function<K>::scalar_vector_type scalar_vector_type; /* This function fits a sigmoid function to the output of the svm trained by svm_nu_train(). The technique used is the one described in the paper: Probabilistic Outputs for Support Vector Machines and Comparisons to Regularized Likelihood Methods by John C. Platt. Match 26, 1999 */ // make sure requires clause is not broken #ifdef ENABLE_ASSERTS for (long r = 0; r < y.nr(); ++r) { DLIB_ASSERT(y(r) == -1.0 || y(r) == 1.0, "\tdecision_function svm_nu_train()" << "\n\tinvalid inputs were given to this function" << "\n\tr: " << r << "\n\ty(r): " << y(r) ); } #endif DLIB_ASSERT(x.nr() > 1 && y.nr() == x.nr(), "\tdecision_function svm_nu_train()" << "\n\tinvalid inputs were given to this function" << "\n\tx.nr(): " << x.nr() << "\n\ty.nr(): " << y.nr() << "\n\tx.nc(): " << x.nc() << "\n\ty.nc(): " << y.nc() ); DLIB_ASSERT(eps > 0 && folds > 1 && folds <= x.nr() && cache_size > 0 && 0 < nu && nu < maximum_nu(y), "\tdecision_function svm_nu_train()" << "\n\tinvalid inputs were given to this function" << "\n\teps: " << eps << "\n\tfolds: " << folds << "\n\tcache_size: " << cache_size << "\n\tnu: " << nu << "\n\tmaximum_nu(y): " << maximum_nu(y) ); // count the number of positive and negative examples long num_pos = 0; long num_neg = 0; for (long r = 0; r < y.nr(); ++r) { if (y(r) == +1.0) ++num_pos; else ++num_neg; } // figure out how many positive and negative examples we will have in each fold const long num_pos_test_samples = num_pos/folds; const long num_pos_train_samples = num_pos - num_pos_test_samples; const long num_neg_test_samples = num_neg/folds; const long num_neg_train_samples = num_neg - num_neg_test_samples; decision_function<K> d; typename decision_function<K>::sample_vector_type x_test, x_train; typename decision_function<K>::scalar_vector_type y_test, y_train; x_test.set_size (num_pos_test_samples + num_neg_test_samples); y_test.set_size (num_pos_test_samples + num_neg_test_samples); x_train.set_size(num_pos_train_samples + num_neg_train_samples); y_train.set_size(num_pos_train_samples + num_neg_train_samples); typedef std_allocator<scalar_type, mem_manager_type> alloc_scalar_type_vector; typedef std::vector<scalar_type, alloc_scalar_type_vector > dvector; typedef std_allocator<int, mem_manager_type> alloc_int_vector; typedef std::vector<int, alloc_int_vector > ivector; dvector out; ivector target; long pos_idx = 0; long neg_idx = 0; for (long i = 0; i < folds; ++i) { long cur = 0; // load up our positive test samples while (cur < num_pos_test_samples) { if (y(pos_idx) == +1.0) { x_test(cur) = x(pos_idx); y_test(cur) = +1.0; ++cur; } pos_idx = (pos_idx+1)%x.nr(); } // load up our negative test samples while (cur < x_test.nr()) { if (y(neg_idx) == -1.0) { x_test(cur) = x(neg_idx); y_test(cur) = -1.0; ++cur; } neg_idx = (neg_idx+1)%x.nr(); } // load the training data from the data following whatever we loaded // as the testing data long train_pos_idx = pos_idx; long train_neg_idx = neg_idx; cur = 0; // load up our positive train samples while (cur < num_pos_train_samples) { if (y(train_pos_idx) == +1.0) { x_train(cur) = x(train_pos_idx); y_train(cur) = +1.0; ++cur; } train_pos_idx = (train_pos_idx+1)%x.nr(); } // load up our negative train samples while (cur < x_train.nr()) { if (y(train_neg_idx) == -1.0) { x_train(cur) = x(train_neg_idx); y_train(cur) = -1.0; ++cur; } train_neg_idx = (train_neg_idx+1)%x.nr(); } // do the training d = svm_nu_train (x_train,y_train,kernel_function,nu,cache_size,eps); // now test this fold for (long i = 0; i < x_test.nr(); ++i) { out.push_back(d(x_test(i))); // if this was a positive example if (y_test(i) == +1.0) { target.push_back(1); } else if (y_test(i) == -1.0) { target.push_back(0); } else { throw dlib::error("invalid input labels to the svm_nu_train_prob() function"); } } } // for (long i = 0; i < folds; ++i) // Now find the parameters of the sigmoid. Do so using the method from the // above referenced paper. scalar_type prior0 = num_pos_test_samples*folds; scalar_type prior1 = num_neg_test_samples*folds; scalar_type A = 0; scalar_type B = std::log((prior0+1)/(prior1+1)); const scalar_type hiTarget = (prior1+1)/(prior1+2); const scalar_type loTarget = 1.0/(prior0+2); scalar_type lambda = 1e-3; scalar_type olderr = std::numeric_limits<scalar_type>::max();; dvector pp(out.size(),(prior1+1)/(prior1+prior0+2)); const scalar_type min_log = -200.0; scalar_type t = 0; int count = 0; for (int it = 0; it < 100; ++it) { scalar_type a = 0; scalar_type b = 0; scalar_type c = 0; scalar_type d = 0; scalar_type e = 0; // First, compute Hessian & gradient of error function with // respect to A & B for (unsigned long i = 0; i < out.size(); ++i) { if (target[i]) t = hiTarget; else t = loTarget; const scalar_type d1 = pp[i] - t; const scalar_type d2 = pp[i]*(1-pp[i]); a += out[i]*out[i]*d2; b += d2; c += out[i]*d2; d += out[i]*d1; e += d1; } // If gradient is really tiny, then stop. if (std::abs(d) < 1e-9 && std::abs(e) < 1e-9) break; scalar_type oldA = A; scalar_type oldB = B; scalar_type err = 0; // Loop until goodness of fit increases while (true) { scalar_type det = (a+lambda)*(b+lambda)-c*c; // if determinant of Hessian is really close to zero then increase stabilizer. if (std::abs(det) <= std::numeric_limits<scalar_type>::epsilon()) { lambda *= 10; continue; } A = oldA + ((b+lambda)*d-c*e)/det; B = oldB + ((a+lambda)*e-c*d)/det; // Now, compute the goodness of fit err = 0; for (unsigned long i = 0; i < out.size(); ++i) { if (target[i]) t = hiTarget; else t = loTarget; scalar_type p = 1.0/(1.0+std::exp(out[i]*A+B)); pp[i] = p; // At this step, make sure log(0) returns min_log err -= t*std::max(std::log(p),min_log) + (1-t)*std::max(std::log(1-p),min_log); } if (err < olderr*(1+1e-7)) { lambda *= 0.1; break; } // error did not decrease: increase stabilizer by factor of 10 // & try again lambda *= 10; if (lambda >= 1e6) // something is broken. Give up break; } scalar_type diff = err-olderr; scalar_type scale = 0.5*(err+olderr+1.0); if (diff > -1e-3*scale && diff < 1e-7*scale) ++count; else count = 0; olderr = err; if (count == 3) break; } return probabilistic_decision_function<K>( A, B, svm_nu_train (x,y,kernel_function,nu,cache_size,eps) ); } // ---------------------------------------------------------------------------------------- template < typename T, typename U > void randomize_samples ( T& t, U& u ) { rand::kernel_1a r; long n = t.nr()-1; while (n > 0) { // put a random integer into idx unsigned long idx = r.get_random_32bit_number(); // make idx be less than n idx %= n; // swap our randomly selected index into the n position exchange(t(idx), t(n)); exchange(u(idx), u(n)); --n; } } // ---------------------------------------------------------------------------------------- } #endif // DLIB_SVm_
[ [ [ 1, 1155 ] ] ]
b5b53ab21d4a962a6988767e48f591c11da39db8
9b3df03cb7e134123cf6c4564590619662389d35
/Ray.h
3016ab6be546e3821bc156e245b31089c7116830
[]
no_license
CauanCabral/Computacao_Grafica
a32aeff2745f40144a263c16483f53db7375c0ba
d8673aed304573415455d6a61ab31b68420b6766
refs/heads/master
2016-09-05T16:48:36.944139
2010-12-09T19:32:05
2010-12-09T19:32:05
null
0
0
null
null
null
null
ISO-8859-10
C++
false
false
2,413
h
#ifndef __Ray_h #define __Ray_h //[]------------------------------------------------------------------------[] //| | //| GVSG Foundation Classes | //| Version 1.0 | //| | //| CopyrightŪ 2007-2009, Paulo Aristarco Pagliosa | //| All Rights Reserved. | //| | //[]------------------------------------------------------------------------[] // // OVERVIEW: Ray.h // ======== // Class definition for ray. #ifndef __Transform3_h #include "Transform3.h" #endif #ifndef __Typedefs_h #include "Typedefs.h" #endif ////////////////////////////////////////////////////////// // // Ray: ray class // === struct Ray { Vec3 origin; Vec3 direction; // Constructors Ray() { // do nothing } Ray(const Vec3& origin, const Vec3& direction) { set(origin, direction); } Ray(const Ray& ray, const Transf3& m) { set(m.transform(ray.origin), m.transformVector(ray.direction)); } void set(const Vec3& origin, const Vec3& direction) { this->origin = origin; this->direction = direction; } void transform(const Transf3& m) { m.transformRef(origin); m.transformVectorRef(direction); } }; // Ray // // Make ray point // inline Vec3 makeRayPoint(const Vec3& origin, const Vec3& direction, REAL t) { return origin + direction * t; } inline Vec3 makeRayPoint(const Ray& ray, REAL t) { return makeRayPoint(ray.origin, ray.direction, t); } namespace Graphics { // begin namespace Graphics // // Forward definition // class Model; ////////////////////////////////////////////////////////// // // IntersectInfo: intersection ray/object info class // ============= struct IntersectInfo { // The intersection point Vec3 p; // The distance from the ray's origin to the intersection point REAL distance; // The object intercepted by the ray Model* object; // Flags int flags; // Any user data void* userData; }; // IntersectInfo } // end namespace Graphics #endif // __Ray_h
[ [ [ 1, 108 ] ] ]
baa774698181fa247a02d5111329eda9590f8fc0
2fdbf2ba994ba3ed64f0e2dc75cd2dfce4936583
/spectre/data/basemove.cpp
4a00d25aad48b74b1fefde625ec5b80674b86174
[]
no_license
TERRANZ/terragraph
36219a4e512e15a925769512a6b60637d39830bf
ea8c36070f532ad0a4af08e46b19f4ee1b85f279
refs/heads/master
2020-05-25T10:31:26.994233
2011-01-29T21:23:04
2011-01-29T21:23:04
1,047,237
0
0
null
null
null
null
UTF-8
C++
false
false
931
cpp
#include "basemove.h" BaseMove::BaseMove(DomElement domElement, XmlData *xmlData) : Base(domElement, xmlData) { } BaseMove::~BaseMove() { } bool BaseMove::moveUp() { // if(m_DomElement.previousElement().isNull()) // { // return false; // } // DomElement result = m_DomElement.parentNode().insertBefore(m_DomElement, m_DomElement.previousElement()).toElement(); // if(result.isNull()) // { // return false; // } // m_DomElement = result; // return true; return false; } bool BaseMove::moveDown() { // if(domElement().nextElement().isNull()) // { // return false; // } // DomElement result = domElement().parentNode().insertAfter(domElement(), domElement().nextElement()).toElement(); // if(result.isNull()) // { // return false; // } // setDomElement(result); // return true; return false; }
[ [ [ 1, 42 ] ] ]
20a7f9a98317db9be3319c941decc2e7fb1f7511
fa91c4da9ef3edd0f6f2216462d313dda0e3829d
/lib/EffectsDLL/EffectsDLL.cpp
c1ed9b148e26d7fcde7bddd1b519640bf4ae5681
[]
no_license
ElenaSmirnova/virtualdj
2f08527dfe841121b7899e8db3f73811af10c2e6
810726f5f30af8562dd8836cb82ff3742a1dd923
refs/heads/master
2021-01-22T13:12:17.090038
2007-07-20T10:14:04
2007-07-20T10:14:04
32,134,534
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
8,962
cpp
// EffectsDLL.cpp : Defines the entry point for the DLL application. // #include "stdafx.h" #include "EffectsDLL.h" #include <iostream> using namespace std; #define DELAY 2 BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { return TRUE; } /*************************************** Эффект Дисторшн дистошн (distortion - искажение) - намеpенное искажение фоpмы звука, что пpидает ему pезкий, скpежещущий оттенок. Hаибольшее пpименение получил в качестве гитаpного эффекта (классическая гитаpа heavy metal). Получается пеpеусилением исходного сигнала до появления огpаничений в усилителе (сpеза веpхушек импульсов) и даже его самовозбуждения. Благодаpя этому исходный сигнал становится похож на пpямоугольный, отчего в нем появляется большое количество новых частотных составляющих, pезко pасшиpяющих спектp. Входные параметры: highLimit - верхний предел амплитуд lowLimit - нижний предел амплитуд buffer - массив с данными (вообще, как я поняла, у буффера размер должен быть 16384 (из слов Оксаны), а 16 это просто для тестирования) Выходные параметры: buffer - массив с уже обрезанными амплитудами ***************************************/ bool distortion(int highLimit, int lowLimit, int buffer[CANALS][LENGTH]){ for (int i = 0; i < CANALS; i++){ for (int j = 0; j < LENGTH; j++){ if (buffer[i][j] != NULL) { if (buffer[i][j] > highLimit) { buffer[i][j] = highLimit; } else{ if (buffer[i][j] < lowLimit) { buffer[i][j] = lowLimit; } } }/*else{ cout << "one element of buffer is empty\n"; return false; }*/ } } return true; } int setHighLimit(){ int highLimit; cout << "\nEnter the high limit of the amplitude\n"; cin >> highLimit; return highLimit; } int setLowLimit(){ int lowLimit; cout << "\nEnter the low limit of the amplitude\n"; cin >> lowLimit; return lowLimit; } extern "C" __declspec(dllexport) int mainDistortion(int highLimit, int lowLimit, int buffer[CANALS][LENGTH]) { bool distResult = false; while (highLimit <= lowLimit) { cout << "\nSorry, but you have entered wrong limits. Try again, please\n"; highLimit = setHighLimit(); lowLimit = setLowLimit(); } if (buffer != NULL) { distResult = distortion(highLimit, lowLimit, buffer); }else{ cout << "buffer is empty\n"; return 1; } if (!distResult) { return 1; } return 0; } /*************************************** Эхо На использовании метода задержки построено создание эффекта "эхо" (echo). Фактически для получения эха необходимо на оригинальный входной сигнал наложить его задержанную во времени копию. Для того, чтобы человеческое ухо воспринимало вторую копию сигнала как повторение, а не как отзвук основного сигнала, необходимо время задержки установить равным примерно 50 мс. Кроме того, на основной сигнал можно наложить не одну его копию, а несколько, что позволит на выходе получить эффект многократного повторения звука (многоголосного эха). Чтобы эхо казалось затухающим, необходимо на исходный сигнал накладывать не просто задержанные копии сигнала, а и приглушенные по амплитуде. Входные параметры: buffer - массив с данными coefficient - коэффициент эха, т. е. коэффициент, на который будет домножаться входной буффер flagOfFirstUse - флажок того, первый ли это буффер или нет (потому, что если не первый, то надо прибывлять эхо от предыдущего буффера) memoryBuffer - предшествующий буффер. используется, если это не первый вызов функции mainEcho для данного файла Выходные параметры: buffer - уже обработанный массив memoryBuffer - буффер, который был послан на обработку. может использоваться для дальнейшей обработки звукового файла эффектом эхо ***************************************/ float coeff = 1; void appropriate(int* toArray, const int* fromArray, int columns){ for (int j=0; j<columns; j++){ toArray[j] = fromArray[j]; } }//приравнивает одномерные массивы void echo(int* toBuffer,const int* fromBuffer, int length){ for (int j=0; j<length; j++){ toBuffer[j] = (int) (coeff*fromBuffer[j]); } }//умножаем одномерный массив на коэффициент int sumBuffers(int* buffer,const int* memoryBuffer){ int firstEcho[LENGTH];//массив для первого эха int secondEcho[LENGTH];//массив для второго эха int firstMemoryBuffer[DELAY];//массив для остатка от первого эха int secondMemoryBuffer[2*DELAY];//массив для остатка от второго эха if (memoryBuffer != NULL) {//если уже не первый буффер со звуком for (int i=0; i<2*DELAY; i++){ secondMemoryBuffer[i] = memoryBuffer[LENGTH - 2*DELAY + i]; } for (int i=0; i<DELAY; i++){ firstMemoryBuffer[i] = memoryBuffer[LENGTH - DELAY +i]; } }else{//если начало песни, то есть обрабатываем первый буффер со свуком for (int i=0; i<2*DELAY; i++){ secondMemoryBuffer[i] = 0; } for (int i=0; i<DELAY; i++){ firstMemoryBuffer[i] = 0; } } if (NULL != buffer){ echo((int*)firstEcho, (const int*)buffer, LENGTH);//получили первое эхо echo((int*)secondEcho,(const int*)firstEcho, LENGTH);//получили второе эхо echo((int*)firstMemoryBuffer, (const int*)firstMemoryBuffer,DELAY);//получили первое эхо остатка echo((int*)secondMemoryBuffer, (const int*)secondMemoryBuffer, 2*DELAY); echo((int*)secondMemoryBuffer, (const int*)secondMemoryBuffer, 2*DELAY);//получили второе эхо остатка for (int j=0; j<LENGTH; j++){ if (j<DELAY) {buffer[j] = buffer[j] + firstMemoryBuffer[j];} if (j<2*DELAY) {buffer[j] = buffer[j] + secondMemoryBuffer[j];} if (j>=DELAY) {buffer[j] = buffer[j] + firstEcho[j-DELAY];} if (j>=2*DELAY) {buffer[j] = buffer[j] + secondEcho[j-2*DELAY];} }//создаем выходной буффер }else{ cout << "buffer is empty\n"; return 1; } return 0; } void setMemory(int buffer[CANALS][LENGTH], bool flagOfFirstUse, int memoryBuffer[CANALS][LENGTH]){ if (flagOfFirstUse){ for (int i=0; i<CANALS; i++){ for (int j=0; j<LENGTH; j++){ memoryBuffer[i][j] = NULL; } } } int tempMemoryBuffer[CANALS][LENGTH]; for (int i=0; i<CANALS; i++){ appropriate((int*)tempMemoryBuffer[i],(const int*)buffer[i],LENGTH); if (!flagOfFirstUse) { sumBuffers((int*)buffer[i],memoryBuffer[i]); }else{ sumBuffers((int*)buffer[i], (int*)NULL); } } for (int i=0; i<CANALS; i++){ appropriate((int*)memoryBuffer[i],(const int*)tempMemoryBuffer[i],LENGTH); } } extern "C" __declspec(dllexport) int mainEcho(int buffer[CANALS][LENGTH], float coefficient, bool flagOfFirstUse, int memoryBuffer[CANALS][LENGTH]){ while ((coefficient < 0) || (coefficient >1)){ cout << "\nSorry, but coefficient must be in [0,1]. Try again please\n"; cin >> coefficient; } coeff = coefficient; if (buffer != NULL){ setMemory(buffer, flagOfFirstUse, memoryBuffer); }else{ return 1; } return 0; } #ifdef _MANAGED #pragma managed(pop) #endif
[ "belkaitil@8565f2c5-1a2c-0410-8cfb-91c1cb6fbed1" ]
[ [ [ 1, 210 ] ] ]
f737af81f7f86734549174f093ac4738f92a2d15
f64b888affed8c6db2cc56d4618c72c923fe1a7c
/tests/test005.cxx
70885217f2fcb003700964f0973c0604b176230a
[ "BSD-2-Clause" ]
permissive
wilx/lockmgr
64ca319f87ccf96214d9c4a3e1095f783fb355d8
9932287c6a49199730abfb4332f85c9ca05d9511
refs/heads/master
2021-01-10T02:19:35.039497
2008-06-09T11:24:32
2008-06-09T11:24:32
36,984,337
0
0
null
null
null
null
UTF-8
C++
false
false
3,381
cxx
// Copyright (c) 2008, Václav Haisman // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided // with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // 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 "lockmgr/config.hxx" #if defined (WIN32) || defined (__CYGWIN__) #include <windows.h> #include <iostream> #include <boost/test/auto_unit_test.hpp> #include "lockmgr/clockmgr.h" namespace { volatile bool thread1_throwed = false; volatile bool thread2_throwed = false; HANDLE mtx1, mtx2; HANDLE thread1, thread2; #define CHECK(x) \ if ((x) == WAIT_FAILED) \ goto deadlock; DWORD WINAPI thread1_proc (LPVOID) { for (size_t i = 0; i < 2 && ! thread2_throwed; ++i) { CHECK (::LockMgrMutexLock (mtx1)); ::Sleep (30); CHECK (::LockMgrMutexLock (mtx2)); ::Sleep (30); ::LockMgrMutexUnlock (mtx2); ::Sleep (30); ::LockMgrMutexUnlock (mtx1); ::Sleep (30); } BOOST_CHECK (thread2_throwed); return 0; deadlock: thread1_throwed = true; std::cerr << "Thread 1 throwed.\n"; return 0; } DWORD WINAPI thread2_proc (LPVOID) { for (size_t i = 0; i < 2 && ! thread1_throwed; ++i) { CHECK (::LockMgrMutexLock (mtx2)); ::Sleep (50); CHECK (::LockMgrMutexLock (mtx1)); ::Sleep (50); ::LockMgrMutexUnlock (mtx1); ::Sleep (50); ::LockMgrMutexUnlock (mtx2); ::Sleep (50); } BOOST_CHECK (thread1_throwed); return 0; deadlock: thread2_throwed = true; std::cerr << "Thread 2 throwed.\n"; return 0; } } // namespace BOOST_AUTO_TEST_CASE (test_deadlock_win32_mutex_c) { std::cerr << ">> test_deadlock_win32_mutex_c <<\n"; BOOST_REQUIRE ((mtx1 = ::CreateMutex (0, false, TEXT ("mtx1")))); BOOST_REQUIRE ((mtx2 = ::CreateMutex (0, false, TEXT ("mtx2")))); BOOST_REQUIRE ((thread1 = ::CreateThread (0, 0, thread1_proc, 0, 0, 0))); BOOST_REQUIRE ((thread2 = ::CreateThread (0, 0, thread2_proc, 0, 0, 0))); Sleep (300); BOOST_CHECK (thread1_throwed || thread2_throwed); } #endif // WIN32
[ [ [ 1, 120 ] ] ]
a10de156a7df8351add9e1b27c3238a166301a2d
f55665c5faa3d79d0d6fe91fcfeb8daa5adf84d0
/LoginServer/NetworkService.cpp
1ed0e4ff74dac8b09bc7dde9f6186783a8a72c26
[]
no_license
lxinhcn/starworld
79ed06ca49d4064307ae73156574932d6185dbab
86eb0fb8bd268994454b0cfe6419ffef3fc0fc80
refs/heads/master
2021-01-10T07:43:51.858394
2010-09-15T02:38:48
2010-09-15T02:38:48
47,859,019
2
1
null
null
null
null
GB18030
C++
false
false
4,553
cpp
#include "StdAfx.h" #include "NetworkService.h" #include <process.h> using namespace XGC::net; BEGIN_DISPATCHER_TABLE( CNetworkService, message_type ) DECLARE_DISPATCH( SYSTEM_MESSAGE_TYPE, OnSystemMessage ) //DECLARE_DISPATCH( MMO_LOGON_CLIENT_MESSAGE_TYPE, OnServerMessage ) END_DISPATCHER_TABLE( CNetworkService, message_type ) BEGIN_DISPATCHER_TABLE( CNetworkService, system_code ) DECLARE_DISPATCH( EVENT_ACCEPT, OnNetworkAccept ) DECLARE_DISPATCH( EVENT_CLOSE, OnNetworkClose ) END_DISPATCHER_TABLE( CNetworkService, system_code ) BEGIN_DISPATCHER_TABLE( CNetworkService, server_code ) //DECLARE_DISPATCH( C2S_REGIST_REQUEST, OnRegistRequest ) //DECLARE_DISPATCH( C2S_LOGON_REQUEST, OnLogonRequest ) END_DISPATCHER_TABLE( CNetworkService, server_code ) CNetworkService::CNetworkService( _uint16 nPort ) : m_nPort( nPort ) , m_bWork( false ) { for( int i = 0; i < _countof(database); ++i ) { database[i].start( "Driver=SQL Server;Server=Albert\\SQLEXPRESS;UID=Albert;PWD=winner;Database=LogonDB" ); } m_thread_h = _beginthreadex( NULL, 0, Svc, (void*)this, 0, NULL ); } CNetworkService::~CNetworkService(void) { m_bWork = false; WaitForSingleObject( (HANDLE)m_thread_h, INFINITE ); for( int i = 0; i < _countof(database); ++i ) { database[i].stop(); } } __declspec( thread ) _uint32 network_h = -1; __declspec( thread ) userdata_ptr puserdata = 0; unsigned int __stdcall CNetworkService::Svc( _lpvoid pParam ) { IMessageQueue *message_queue_ptr = NULL; CNetworkService *pService = (CNetworkService*)pParam; long_ptr server_h = StartServer( "0.0.0.0", pService->m_nPort, &message_queue_ptr, 0 ); pService->m_bWork = true; INetPacket *pPacket = NULL; while( pService->m_bWork ) { pPacket = message_queue_ptr->PopMessage(); if( pPacket ) { network_h = pPacket->handle(); puserdata = (userdata_ptr)pPacket->userdata(); if( puserdata == 0 ) { long_ptr param[1] = { (long_ptr)&network_h }; ExecuteState( Operator_GetUserdata, (long_ptr)param ); puserdata = (userdata_ptr)param[0]; } // 处理数据 pService->Process( pPacket->data(), pPacket->size() ); pPacket->release(); } } CloseServer( server_h ); message_queue_ptr->Release(); return 0; } void CNetworkService::Process( const char* data, size_t size ) { unsigned char type = *data; func pFunc = DISPATCHER_GET( message_type, type ); if( pFunc ) return (this->*pFunc)( data+1, size-1 ); } void CNetworkService::OnSystemMessage( const char* data, size_t size ) { unsigned char type = *data; func pFunc = DISPATCHER_GET( system_code, type ); if( pFunc ) return (this->*pFunc)( data+1, size-1 ); } void CNetworkService::OnServerMessage( const char* data, size_t size ) { unsigned char type = *data; func pFunc = DISPATCHER_GET( server_code, type ); if( pFunc ) return (this->*pFunc)( data+1, size-1 ); } ////////////////////////////////////////////////////////////////////////// // 系统消息 ////////////////////////////////////////////////////////////////////////// //--------------------------------------------------------// // created: 8:12:2009 17:56 // filename: NetworkService // author: Albert.xu // // purpose: 用户建立连接 //--------------------------------------------------------// void CNetworkService::OnNetworkAccept( const char* data, size_t size ) { userdata_ptr pud = new userdata(); pud->id = 0; pud->order = 0; long_ptr param[2] = { (long_ptr)&network_h, (long_ptr)pud }; ExecuteState( Operator_SetUserdata, (long_ptr)param ); } //--------------------------------------------------------// // created: 8:12:2009 17:56 // filename: NetworkService // author: Albert.xu // // purpose: 用户断开连接 //--------------------------------------------------------// void CNetworkService::OnNetworkClose( const char* data, size_t size ) { long_ptr param[1] = { (long_ptr)&network_h }; ExecuteState( Operator_GetUserdata, (long_ptr)param ); userdata_ptr ud = (userdata_ptr)param[0]; delete ud; } ////////////////////////////////////////////////////////////////////////// // 服务器逻辑消息 ////////////////////////////////////////////////////////////////////////// void CNetworkService::OnRegistRequest( const char *data, size_t size ) { //MMO_RegistRequest msg; //bufstream bsf( data, size, 0 ); //bsf >> msg; } void CNetworkService::OnLogonRequest( const char *data, size_t size ) { }
[ "albertclass@a94d7126-06ea-11de-b17c-0f1ef23b492c" ]
[ [ [ 1, 153 ] ] ]
5220ab11cf271d78b57f8b44de8e2198f29d6ef9
a2904986c09bd07e8c89359632e849534970c1be
/topcoder/PrimeContainers.cpp
ac34427edb4b91187d48d503ad39ccba09bfe186
[]
no_license
naturalself/topcoder_srms
20bf84ac1fd959e9fbbf8b82a93113c858bf6134
7b42d11ac2cc1fe5933c5bc5bc97ee61b6ec55e5
refs/heads/master
2021-01-22T04:36:40.592620
2010-11-29T17:30:40
2010-11-29T17:30:40
444,669
1
0
null
null
null
null
UTF-8
C++
false
false
2,715
cpp
// BEGIN CUT HERE // END CUT HERE #line 5 "PrimeContainers.cpp" #include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <numeric> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> using namespace std; #define forv(i, v) for (int i = 0; i < (int)(v.size()); ++i) #define fors(i, s) for (int i = 0; i < (int)(s.length()); ++i) #define all(a) a.begin(), a.end() class PrimeContainers { public: int containerSize(int N) { int ret = 0; int k=0; set <int> nums; for(int i=0;i<N;i++){ k = (int)pow(2.0,i); nums.insert(N/k); } set<int>::iterator it = nums.begin(); while( it != nums.end() ){ if(IsPrime(*it)){ ret++; } ++it; } return ret; } private: int IsPrime(int n){ int i=0; if(n < 2){ return 0; }else if(n == 2){ return 1; } if(n % 2 == 0){ return 0; } for(i = 3; i * i <= n; i += 2){ if(n % i == 0){ return 0; } } return 1; } // BEGIN CUT HERE public: void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); } private: template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); } void verify_case(int Case, const int &Expected, const int &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } } void test_case_0() { int Arg0 = 10; int Arg1 = 2; verify_case(0, Arg1, containerSize(Arg0)); } void test_case_1() { int Arg0 = 42; int Arg1 = 2; verify_case(1, Arg1, containerSize(Arg0)); } void test_case_2() { int Arg0 = 47; int Arg1 = 5; verify_case(2, Arg1, containerSize(Arg0)); } void test_case_3() { int Arg0 = 959; int Arg1 = 6; verify_case(3, Arg1, containerSize(Arg0)); } void test_case_4() { int Arg0 = 421337; int Arg1 = 2; verify_case(4, Arg1, containerSize(Arg0)); } // END CUT HERE }; // BEGIN CUT HERE int main() { PrimeContainers ___test; ___test.run_test(-1); } // END CUT HERE
[ "shin@CF-7AUJ41TT52JO.(none)" ]
[ [ [ 1, 97 ] ] ]
40003fd14605d8a12df0a29eb8b908224de746a7
c4312eeac88e4aa5d213cb144dd7cddf2c01c7e1
/trunk/plugins/dmsscanner/src/dmsscanner.cpp
a7302213a4fa81c41b6801e62b9f02489307b2ce
[]
no_license
BackupTheBerlios/dms-svn
42d734c441a3d738191659ca5651f54a2576ebfb
468e254605ab57826493668558abea57215202f7
refs/heads/master
2021-01-18T17:17:57.265462
2009-05-01T11:23:55
2009-05-01T11:23:55
40,671,124
0
0
null
null
null
null
UTF-8
C++
false
false
11,167
cpp
/*************************************************************************** * Copyright (C) 2008 by Alexander Saal * * [email protected] * * * * File: dmsscanner.h * * Desc: ${description} * * * * This file is part of DMS - Documnet Management System * * * * 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 <QtCore> #include <QtGui> #include <dmsscanner.h> #include <libdms.h> #ifdef Q_OS_WIN32 #include <qtwaininterface.h> #include <qtwain.h> #include <dib.h> #else #include <sane_widget.h> #endif DMSScanner *dmsscanner = NULL; DMSScanner::DMSScanner( QWidget *parent ) : QWidget( parent ) { dmsscanner = this; setObjectName( "UiDocScannerPluginBase" ); _dms = LibDMS::libdms_instcance(); QDesktopWidget *desktop = qApp->desktop(); const QRect rect = desktop->availableGeometry( desktop->primaryScreen() ); int left = ( rect.width() - width() ) / 2; int top = ( rect.height() - height() ) / 2; int height = this->height(); int width = this->width(); setGeometry( left, top, width, height ); #ifdef Q_OS_WIN32 m_pTwain = new QTwain(); connect( m_pTwain, SIGNAL( dibAcquired( CDIB* ) ), this, SLOT( acquired( CDIB* ) ) ); #endif scannedDoc = 0; scannedDoc = _dms->getApplicationSettings( "UiPreferenceBase", "General", "DocCounter", QVariant( scannedDoc ) ).toInt(); initScan(); } DMSScanner::~DMSScanner() { #ifdef Q_OS_WIN32 m_pTwain = NULL; #else m_sanew = NULL; #endif dmsscanner = NULL; } #ifdef Q_OS_WIN32 void DMSScanner::showEvent( QShowEvent *event ) { m_pTwain->setParent( this ); } bool DMSScanner::winEvent( MSG *pMsg, long * result ) { return (m_pTwain->processMessage(*pMsg) == TRUE); } void DMSScanner::selectedSource() { m_pTwain->selectSource(); } void DMSScanner::acquired( CDIB *pDib ) { m_pImage = QTwainInterface::convertToImage( pDib, pDib->Width(), pDib->Height() ); m_pImageAcquire->setPixmap( QPixmap::fromImage( m_pImage ) ); setMaximumSize( pDib->Width(), pDib->Height() ); delete pDib; } #endif void DMSScanner::initScan() { #ifdef Q_OS_WIN32 gridLayout = new QGridLayout( this ); gridLayout->setObjectName( "gridLayout" ); m_pImageAcquire = new QLabel( this ); m_pImageAcquire->setObjectName( "pImageAcquire" ); m_pImageAcquire->setFrameShape(QFrame::StyledPanel); m_pImageAcquire->setFrameShadow(QFrame::Sunken); gridLayout->addWidget( m_pImageAcquire, 0, 0, 1, 1 ); hboxLayout = new QHBoxLayout(); hboxLayout->setObjectName( "hboxLayout" ); btnAcquire = new QPushButton( this ); btnAcquire->setObjectName( "btnAcquire" ); btnAcquire->setText( tr( "St&art scan" ) ); connect( btnAcquire, SIGNAL( clicked() ), this, SLOT( scanStart() ) ); hboxLayout->addWidget(btnAcquire); spacerItem = new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); hboxLayout->addItem(spacerItem); btnSource = new QPushButton( this ); btnSource->setObjectName(QString::fromUtf8("btnSource")); btnSource->setText( tr( "&Select Source" ) ); connect( btnSource, SIGNAL( clicked() ), this, SLOT( selectedSource() ) ); hboxLayout->addWidget( btnSource ); gridLayout->addLayout( hboxLayout, 1, 0, 1, 1 ); #else QApplication::setOverrideCursor( Qt::WaitCursor ); qApp->processEvents(); m_progressDialog = NULL; QString device( "" ); // Scanning dialog QVBoxLayout *vlayout = new QVBoxLayout( dmsscanner ); QHBoxLayout *hlayout = new QHBoxLayout; QFrame *separator = new QFrame( dmsscanner ); separator->setFrameShape( QFrame::HLine ); separator->setFrameShadow( QFrame::Sunken ); m_sanew = new SaneWidget( dmsscanner ); if ( m_sanew->openDevice( device ) == false ) { QApplication::restoreOverrideCursor(); QString dev = m_sanew->selectDevice( NULL ); if ( m_sanew->openDevice( dev ) == false ) { if ( dmsscanner != NULL ) { dmsscanner = NULL; dmsscanner->close(); } if ( m_sanew != NULL ) { m_sanew = NULL; dmsscanner->close(); } return; } this->setWindowTitle( tr( "Scan document on [ %1 ]" ).arg( dev ) ); } connect( m_sanew, SIGNAL( scanStart() ), this, SLOT( scanStart() ) ); connect( m_sanew, SIGNAL( scanFaild() ), this, SLOT( scanFailed() ) ); connect( m_sanew, SIGNAL( scanDone() ), this, SLOT( scanEnd() ) ); connect( m_sanew, SIGNAL( imageReady() ), this, SLOT( imageReady() ) ); m_sanew->setIconColorMode( QIcon( ":/scanimages/images/scanimages/color.png" ) ); m_sanew->setIconGrayMode( QIcon( ":/scanimages/images/scanimages/gray.png" ) ); m_sanew->setIconBWMode( QIcon( ":/scanimages/images/scanimages/black_white.png" ) ); m_sanew->setIconPreview( QIcon( ":/scanimages/images/scanimages/eye.png" ) ); m_sanew->setIconFinal( QIcon( ":/scanimages/images/scanimages/filesave.png" ) ); m_sanew->setIconZoomIn( QIcon( ":/scanimages/images/scanimages/viewmag+.png" ) ); m_sanew->setIconZoomOut( QIcon( ":/scanimages/images/scanimages/viewmag-.png" ) ); m_sanew->setIconZoomSel( QIcon( ":/scanimages/images/scanimages/viewmagfit.png" ) ); m_sanew->setIconZoomFit( QIcon( ":/scanimages/images/scanimages/view_fit_window.png" ) ); vlayout->setMargin( 2 ); vlayout->setSpacing( 2 ); vlayout->addWidget( m_sanew ); vlayout->addWidget( separator ); vlayout->addLayout( hlayout ); dmsscanner->show(); QApplication::restoreOverrideCursor(); #endif } void DMSScanner::scanStart() { #ifdef Q_OS_WIN32 if (!m_pTwain->acquire()) { qWarning("acquire() call not successful!"); } #else QApplication::setOverrideCursor( Qt::WaitCursor ); if ( m_progressDialog == NULL ) { m_progressDialog = new QProgressDialog( NULL ); } m_progressDialog->setWindowTitle( tr( "Scanning document ..." ) ); m_progressDialog->setCancelButtonText( tr( "Cancel" ) ); m_progressDialog->setMaximum( PROGRESS_MAX ); m_progressDialog->setMinimum( PROGRESS_MIN ); if ( m_sanew ) { connect( m_progressDialog, SIGNAL( canceled() ), m_sanew, SLOT( scanCancel() ) ); connect( m_sanew, SIGNAL( scanProgress( int ) ), m_progressDialog, SLOT( setValue( int ) ) ); } m_progressDialog->show(); QApplication::restoreOverrideCursor(); #endif } void DMSScanner::scanEnd() { #ifdef Q_OS_WIN32 // nothing to do ... #else if ( m_progressDialog != NULL ) { delete( m_progressDialog ); m_progressDialog = NULL; } #endif } void DMSScanner::scanFailed() { #ifdef Q_OS_WIN32 // nothing to do ... #else if ( m_progressDialog != NULL ) { delete( m_progressDialog ); m_progressDialog = NULL; } QMessageBox mb( "SaneWidget", "Scanning failed!\n", QMessageBox::Critical, QMessageBox::Ok | QMessageBox::Default, QMessageBox::NoButton, QMessageBox::NoButton ); mb.exec(); #endif } void DMSScanner::imageReady() { #ifdef Q_OS_WIN32 // nothing to do ... #else qApp->processEvents(); bool ok; QString imagename = QInputDialog::getText( this, tr( "New name for scanned file" ), tr( "Enter a valid name!\n\nName:" ), QLineEdit::Normal, tr( "DMS_SCANNED_IMAGE_%1" ).arg( scannedDoc ), &ok ); if ( !ok && (imagename.isEmpty() || imagename.isNull() || imagename == "" ) ) return; QApplication::setOverrideCursor( Qt::WaitCursor ); QPixmap pix = QPixmap::fromImage( *( m_sanew->getFinalImage() ) ); if ( !pix.isNull() ) { qApp->processEvents(); dmsscanner->close(); documentarchive = _dms->getApplicationSettings( "UiPreferenceBase", "General", "Documentarchive" ).toString(); if ( documentarchive.isNull() || documentarchive.isEmpty() ) { QApplication::restoreOverrideCursor(); documentarchive = QDir::homePath() + QDir::separator() + ".dms" + QDir::separator() + "documents"; showErrorMsg( tr( "No document archive was set, use default.\n\nArchive: %1" ).arg( documentarchive ) ); QApplication::setOverrideCursor( Qt::WaitCursor ); } /* PDF Portable Document Format Write Supported image formats (from Qt4 Documentation) BMP Windows Bitmap Read/write JPG Joint Photographic Experts Group Read/write JPEG Joint Photographic Experts Group Read/write PNG Portable Network Graphics Read/write PPM Portable Pixmap Read/write XBM X11 Bitmap Read/write XPM X11 Pixmap Read/write */ QString imageformat = _dms->getApplicationSettings( "UiPreferenceBase", "General", "ImageFormat", QVariant( "PNG" ) ).toString(); if( imageformat.toLower() == "pdf" ) { documentarchive += imagename + "." + imageformat.toLower(); QPrinter printer( QPrinter::HighResolution ); printer.setPageSize( QPrinter::A4 ); printer.setFullPage( true ); printer.setOutputFormat( QPrinter::PdfFormat ); printer.setDocName( documentarchive ); printer.setOutputFileName( documentarchive ); QPainter p; p.begin( &printer ); p.drawImage( 0, 0, pix.toImage() ); p.end(); } else { documentarchive += imagename + "." + imageformat.toLower(); qDebug() << imageformat.toUpper().toAscii().data(); pix.save( documentarchive, imageformat.toUpper().toAscii().data() ); } scannedDoc++; _dms->insertApplicationSettings( "UiPreferenceBase", "General", "DocCounter", QString( "%1" ).arg( scannedDoc ) ); } m_sanew = NULL; dmsscanner = NULL; QApplication::restoreOverrideCursor(); close(); #endif } void DMSScanner::showErrorMsg( const QString &error ) { QMessageBox::critical( this, tr( "DMS - Scannerplugin" ), error ); }
[ "chmaster@ff0c6f71-da43-0410-abee-ea3d5be7fece" ]
[ [ [ 1, 371 ] ] ]
fca8acc36bca832258f13e0786ef384094ba83b2
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/zombie/nphysics/src/nphysics/ncphywaterpool_cmds.cc
476e1b6d6302a3eb6cfdb8703e091dc84fa51ffc
[]
no_license
ugozapad/TheZombieEngine
832492930df28c28cd349673f79f3609b1fe7190
8e8c3e6225c2ed93e07287356def9fbdeacf3d6a
refs/heads/master
2020-04-30T11:35:36.258363
2011-02-24T14:18:43
2011-02-24T14:18:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,670
cc
//----------------------------------------------------------------------------- // ncphywaterpool_cmds.cc // (C) 2005 Conjurer Services, S.A. //----------------------------------------------------------------------------- #include "precompiled/pchnphysics.h" #include "nphysics/ncphywaterpool.h" #include "kernel/npersistserver.h" //----------------------------------------------------------------------------- NSCRIPT_INITCMDS_BEGIN(ncPhyWaterPool) NSCRIPT_ADDCMD_COMPOBJECT('DSPL', void, SetPoolsLength, 1, (const vector3&), 0, ()); NSCRIPT_ADDCMD_COMPOBJECT('DGPL', const vector3&, GetPoolsLength, 0, (), 0, ()); NSCRIPT_INITCMDS_END() //------------------------------------------------------------------------------ /** Object persistency. */ bool ncPhyWaterPool::SaveCmds(nPersistServer* ps) { // area density nCmd* cmd(ps->GetCmd( this->entityObject, 'DARR')); n_assert2( cmd, "Error command not found" ); cmd->In()->SetF(this->GetResistance()); ps->PutCmd(cmd); // this entity cmd = ps->GetCmd( this->entityObject, 'DSPL'); n_assert2( cmd, "Error command not found" ); cmd->In()->SetF(this->lengthsPool.x); cmd->In()->SetF(this->lengthsPool.y); cmd->In()->SetF(this->lengthsPool.z); ps->PutCmd(cmd); // nphysicsobj cmd = ps->GetCmd( this->entityObject, 'DITW'); n_assert2( cmd, "Error command not found" ); ps->PutCmd(cmd); return true; } //----------------------------------------------------------------------------- // EOF //-----------------------------------------------------------------------------
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 57 ] ] ]
1b22350995405379b93c92047f64bf75dd149471
e2e49023f5a82922cb9b134e93ae926ed69675a1
/tools/aoslcpp/include/aosl/stage_ref.inl
af2a31910c44599c7676bf7756f80531496cc70b
[]
no_license
invy/mjklaim-freewindows
c93c867e93f0e2fe1d33f207306c0b9538ac61d6
30de8e3dfcde4e81a57e9059dfaf54c98cc1135b
refs/heads/master
2021-01-10T10:21:51.579762
2011-12-12T18:56:43
2011-12-12T18:56:43
54,794,395
1
0
null
null
null
null
UTF-8
C++
false
false
644
inl
// Copyright (C) 2005-2010 Code Synthesis Tools CC // // This program was generated by CodeSynthesis XSD, an XML Schema // to C++ data binding compiler, in the Proprietary License mode. // You should have received a proprietary license from Code Synthesis // Tools CC prior to generating this code. See the license text for // conditions. // #ifndef AOSLCPP_AOSL__STAGE_REF_INL #define AOSLCPP_AOSL__STAGE_REF_INL // Begin prologue. // // // End prologue. #include "aosl/unique_ref.inl" namespace aosl { // Stage_ref // } // Begin epilogue. // // // End epilogue. #endif // AOSLCPP_AOSL__STAGE_REF_INL
[ "klaim@localhost" ]
[ [ [ 1, 31 ] ] ]
1a35e1b5a9b30c2e664e1d9299087b395838b975
b8ac0bb1d1731d074b7a3cbebccc283529b750d4
/Code/controllers/OdometryCalibration/robotapi/webts/WebotsCamera.h
7214adfc5890b78243e1e25b83291db8623132ee
[]
no_license
dh-04/tpf-robotica
5efbac38d59fda0271ac4639ea7b3b4129c28d82
10a7f4113d5a38dc0568996edebba91f672786e9
refs/heads/master
2022-12-10T18:19:22.428435
2010-11-05T02:42:29
2010-11-05T02:42:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
736
h
#ifndef robotapi_webts_WebotsCamera_h #define robotapi_webts_WebotsCamera_h #include <robotapi/ICamera.h> #include <robotapi/webts/WebotsDevice.h> #include <webots/Camera.hpp> namespace robotapi { namespace webts { class WebotsCamera : virtual public robotapi::ICamera, public robotapi::webts::WebotsDevice { public: void enable(int ms); void disable(); IImage &getImage(); int saveImage(std::string filename, int quality); // Change parameter to Webots API camera WebotsCamera( webots::Camera & cam ); private: webots::Camera * mycam; }; } /* End of namespace robotapi::webts */ } /* End of namespace robotapi */ #endif // robotapi_webts_WebotsCamera_h
[ "guicamest@d69ea68a-f96b-11de-8cdf-e97ad7d0f28a" ]
[ [ [ 1, 35 ] ] ]
c6659dab9738b2953fbdefa67f01e436fabe18bf
709cd826da3ae55945fd7036ecf872ee7cdbd82a
/Term/Assignment/BasicFunctions/OpenGlException.cpp
553bbcf67cef7e696d0dbbf82479772a7bdb0221
[]
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
248
cpp
#include "OpenGlException.h" namespace OpenGl { OpenGlException::OpenGlException(void) { } OpenGlException::OpenGlException(const String& message) : Exception(message) { } OpenGlException::~OpenGlException(void) { } }
[ [ [ 1, 20 ] ] ]
77af450fcaff90c230ac4ed33c27a501ac778402
463c3b62132d215e245a097a921859ecb498f723
/lib/dlib/binary_search_tree/binary_search_tree_kernel_1.h
e29ec64d96e2f0f40182a157eebfd32eca24f1f7
[ "LicenseRef-scancode-unknown-license-reference", "BSL-1.0" ]
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
63,370
h
// Copyright (C) 2003 Davis E. King ([email protected]) // License: Boost Software License See LICENSE.txt for the full license. #ifndef DLIB_BINARY_SEARCH_TREE_KERNEl_1_ #define DLIB_BINARY_SEARCH_TREE_KERNEl_1_ #include "binary_search_tree_kernel_abstract.h" #include "../algs.h" #include "../interfaces/map_pair.h" #include "../interfaces/enumerable.h" #include "../interfaces/remover.h" #include "../serialize.h" #include <cstdlib> #include <functional> namespace dlib { template < typename domain, typename range, typename mem_manager, typename compare = std::less<domain> > class binary_search_tree_kernel_1 : public enumerable<map_pair<domain,range> >, public asc_pair_remover<domain,range,compare> { /*! INITIAL VALUE tree_size == 0 tree_root == 0 tree_height == 0 at_start_ == true current_element == 0 stack == array of 50 node pointers stack_pos == 0 CONVENTION tree_size == size() tree_height == height() stack[stack_pos-1] == pop() current_element_valid() == (current_element != 0) if (current_element_valid()) then element() == current_element->d and current_element->r at_start_ == at_start() if (current_element != 0 && current_element != tree_root) then stack[stack_pos-1] == the parent of the node pointed to by current_element if (tree_size != 0) tree_root == pointer to the root node of the binary search tree else tree_root == 0 for all nodes: { left points to the left subtree or 0 if there is no left subtree and right points to the right subtree or 0 if there is no right subtree and all elements in a left subtree are <= the root and all elements in a right subtree are >= the root and d is the item in the domain of *this contained in the node r is the item in the range of *this contained in the node balance: balance == 0 if both subtrees have the same height balance == -1 if the left subtree has a height that is greater than the height of the right subtree by 1 balance == 1 if the right subtree has a height that is greater than the height of the left subtree by 1 for all trees: the height of the left and right subtrees differ by at most one } !*/ class node { public: node* left; node* right; domain d; range r; signed char balance; }; class mpair : public map_pair<domain,range> { public: const domain* d; range* r; const domain& key( ) const { return *d; } const range& value( ) const { return *r; } range& value( ) { return *r; } }; public: typedef domain domain_type; typedef range range_type; typedef compare compare_type; typedef mem_manager mem_manager_type; binary_search_tree_kernel_1( ) : tree_size(0), tree_root(0), current_element(0), tree_height(0), at_start_(true), stack_pos(0), stack(ppool.allocate_array(50)) { } virtual ~binary_search_tree_kernel_1( ); inline void clear( ); inline short height ( ) const; inline unsigned long count ( const domain& item ) const; inline void add ( domain& d, range& r ); void remove ( const domain& d, domain& d_copy, range& r ); void destroy ( const domain& item ); inline const range* operator[] ( const domain& item ) const; inline range* operator[] ( const domain& item ); inline void swap ( binary_search_tree_kernel_1& item ); // function from the asc_pair_remover interface void remove_any ( domain& d, range& r ); // functions from the enumerable interface inline unsigned long size ( ) const; bool at_start ( ) const; inline void reset ( ) const; bool current_element_valid ( ) const; const map_pair<domain,range>& element ( ) const; map_pair<domain,range>& element ( ); bool move_next ( ) const; void remove_last_in_order ( domain& d, range& r ); void remove_current_element ( domain& d, range& r ); void position_enumerator ( const domain& d ) const; private: inline void rotate_left ( node*& t ); /*! requires - t->balance == 2 - t->right->balance == 0 or 1 - t == reference to the pointer in t's parent node that points to t ensures - #t is still a binary search tree - #t->balance is between 1 and -1 - #t now has a height smaller by 1 if #t->balance == 0 !*/ inline void rotate_right ( node*& t ); /*! requires - t->balance == -2 - t->left->balance == 0 or -1 - t == reference to the pointer in t's parent node that points to t ensures - #t is still a binary search tree - #t->balance is between 1 and -1 - #t now has a height smaller by 1 if #t->balance == 0 !*/ inline void double_rotate_right ( node*& t ); /*! requires - t->balance == -2 - t->left->balance == 1 - t == reference to the pointer in t's parent node that points to t ensures - #t is still a binary search tree - #t now has a balance of 0 - #t now has a height smaller by 1 !*/ inline void double_rotate_left ( node*& t ); /*! requires - t->balance == 2 - t->right->balance == -1 - t == reference to the pointer in t's parent node that points to t ensures - #t is still a binary search tree - #t now has a balance of 0 - #t now has a height smaller by 1 !*/ bool remove_biggest_element_in_tree ( node*& t, domain& d, range& r ); /*! requires - t != 0 (i.e. there must be something in the tree to remove) - t == reference to the pointer in t's parent node that points to t ensures - the biggest node in t has been removed - the biggest node domain element in t has been put into #d - the biggest node range element in t has been put into #r - #t is still a binary search tree - returns false if the height of the tree has not changed - returns true if the height of the tree has shrunk by one !*/ bool remove_least_element_in_tree ( node*& t, domain& d, range& r ); /*! requires - t != 0 (i.e. there must be something in the tree to remove) - t == reference to the pointer in t's parent node that points to t ensures - the least node in t has been removed - the least node domain element in t has been put into #d - the least node range element in t has been put into #r - #t is still a binary search tree - returns false if the height of the tree has not changed - returns true if the height of the tree has shrunk by one !*/ bool add_to_tree ( node*& t, domain& d, range& r ); /*! requires - t == reference to the pointer in t's parent node that points to t ensures - the mapping (d --> r) has been added to #t - #d and #r have initial values for their types - #t is still a binary search tree - returns false if the height of the tree has not changed - returns true if the height of the tree has grown by one !*/ bool remove_from_tree ( node*& t, const domain& d, domain& d_copy, range& r ); /*! requires - return_reference(t,d) != 0 - t == reference to the pointer in t's parent node that points to t ensures - #d_copy is equivalent to d - an element in t equivalent to d has been removed and swapped into #d_copy and its associated range object has been swapped into #r - #t is still a binary search tree - returns false if the height of the tree has not changed - returns true if the height of the tree has shrunk by one !*/ bool remove_from_tree ( node*& t, const domain& item ); /*! requires - return_reference(t,item) != 0 - t == reference to the pointer in t's parent node that points to t ensures - an element in t equivalent to item has been removed - #t is still a binary search tree - returns false if the height of the tree has not changed - returns true if the height of the tree has shrunk by one !*/ const range* return_reference ( const node* t, const domain& d ) const; /*! ensures - if (there is a domain element equivalent to d in t) then - returns a pointer to the element in the range equivalent to d - else - returns 0 !*/ range* return_reference ( node* t, const domain& d ); /*! ensures - if (there is a domain element equivalent to d in t) then - returns a pointer to the element in the range equivalent to d - else - returns 0 !*/ inline bool keep_node_balanced ( node*& t ); /*! requires - t != 0 - t == reference to the pointer in t's parent node that points to t ensures - if (t->balance is < 1 or > 1) then - keep_node_balanced() will ensure that #t->balance == 0, -1, or 1 - #t is still a binary search tree - returns true if it made the tree one height shorter - returns false if it didn't change the height !*/ unsigned long get_count ( const domain& item, node* tree_root ) const; /*! requires - tree_root == the root of a binary search tree or 0 ensures - if (tree_root == 0) then - returns 0 - else - returns the number of elements in tree_root that are equivalent to item !*/ void delete_tree ( node* t ); /*! requires - t != 0 ensures - deallocates the node pointed to by t and all of t's left and right children !*/ void push ( node* n ) const { stack[stack_pos] = n; ++stack_pos; } /*! ensures - pushes n onto the stack !*/ node* pop ( ) const { --stack_pos; return stack[stack_pos]; } /*! ensures - pops the top of the stack and returns it !*/ bool fix_stack ( node* t, unsigned char depth = 0 ); /*! requires - current_element != 0 - depth == 0 - t == tree_root ensures - makes the stack contain the correct set of parent pointers. also adjusts stack_pos so it is correct. - #t is still a binary search tree !*/ bool remove_current_element_from_tree ( node*& t, domain& d, range& r, unsigned long cur_stack_pos = 1 ); /*! requires - t == tree_root - cur_stack_pos == 1 - current_element != 0 ensures - removes the data in the node given by current_element and swaps it into #d and #r. - #t is still a binary search tree - the enumerator is advances on to the next element but its stack is potentially corrupted. so you must call fix_stack(tree_root) to fix it. - returns false if the height of the tree has not changed - returns true if the height of the tree has shrunk by one !*/ // data members mutable mpair p; unsigned long tree_size; node* tree_root; mutable node* current_element; typename mem_manager::template rebind<node>::other pool; typename mem_manager::template rebind<node*>::other ppool; short tree_height; mutable bool at_start_; mutable unsigned char stack_pos; mutable node** stack; compare comp; // restricted functions binary_search_tree_kernel_1(binary_search_tree_kernel_1&); binary_search_tree_kernel_1& operator=(binary_search_tree_kernel_1&); }; template < typename domain, typename range, typename mem_manager, typename compare > inline void swap ( binary_search_tree_kernel_1<domain,range,mem_manager,compare>& a, binary_search_tree_kernel_1<domain,range,mem_manager,compare>& b ) { a.swap(b); } template < typename domain, typename range, typename mem_manager, typename compare > void deserialize ( binary_search_tree_kernel_1<domain,range,mem_manager,compare>& item, std::istream& in ) { try { item.clear(); unsigned long size; deserialize(size,in); domain d; range r; for (unsigned long i = 0; i < size; ++i) { deserialize(d,in); deserialize(r,in); item.add(d,r); } } catch (serialization_error e) { item.clear(); throw serialization_error(e.info + "\n while deserializing object of type binary_search_tree_kernel_1"); } } // ---------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------- // member function definitions // ---------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: ~binary_search_tree_kernel_1 ( ) { ppool.deallocate_array(stack); if (tree_size != 0) { delete_tree(tree_root); } } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > void binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: clear ( ) { if (tree_size > 0) { delete_tree(tree_root); tree_root = 0; tree_size = 0; tree_height = 0; } // reset the enumerator reset(); } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > unsigned long binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: size ( ) const { return tree_size; } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > short binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: height ( ) const { return tree_height; } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > unsigned long binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: count ( const domain& item ) const { return get_count(item,tree_root); } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > void binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: add ( domain& d, range& r ) { tree_height += add_to_tree(tree_root,d,r); ++tree_size; // reset the enumerator reset(); } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > void binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: remove ( const domain& d, domain& d_copy, range& r ) { tree_height -= remove_from_tree(tree_root,d,d_copy,r); --tree_size; // reset the enumerator reset(); } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > void binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: destroy ( const domain& item ) { tree_height -= remove_from_tree(tree_root,item); --tree_size; // reset the enumerator reset(); } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > void binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: remove_any ( domain& d, range& r ) { tree_height -= remove_least_element_in_tree(tree_root,d,r); --tree_size; // reset the enumerator reset(); } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > range* binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: operator[] ( const domain& item ) { return return_reference(tree_root,item); } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > const range* binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: operator[] ( const domain& item ) const { return return_reference(tree_root,item); } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > void binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: swap ( binary_search_tree_kernel_1<domain,range,mem_manager,compare>& item ) { pool.swap(item.pool); ppool.swap(item.ppool); exchange(p,item.p); exchange(stack,item.stack); exchange(stack_pos,item.stack_pos); exchange(comp,item.comp); node* tree_root_temp = item.tree_root; unsigned long tree_size_temp = item.tree_size; short tree_height_temp = item.tree_height; node* current_element_temp = item.current_element; bool at_start_temp = item.at_start_; item.tree_root = tree_root; item.tree_size = tree_size; item.tree_height = tree_height; item.current_element = current_element; item.at_start_ = at_start_; tree_root = tree_root_temp; tree_size = tree_size_temp; tree_height = tree_height_temp; current_element = current_element_temp; at_start_ = at_start_temp; } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > void binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: remove_last_in_order ( domain& d, range& r ) { tree_height -= remove_biggest_element_in_tree(tree_root,d,r); --tree_size; // reset the enumerator reset(); } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > void binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: remove_current_element ( domain& d, range& r ) { tree_height -= remove_current_element_from_tree(tree_root,d,r); --tree_size; // fix the enumerator stack if we need to if (current_element) fix_stack(tree_root); } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > void binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: position_enumerator ( const domain& d ) const { // clear the enumerator state and make sure the stack is empty reset(); at_start_ = false; node* t = tree_root; bool went_left = false; while (t != 0) { if ( comp(d , t->d) ) { push(t); // if item is on the left then look in left t = t->left; went_left = true; } else if (comp(t->d , d)) { push(t); // if item is on the right then look in right t = t->right; went_left = false; } else { current_element = t; return; } } // if we didn't find any matches but there might be something after the // d in this tree. if (stack_pos > 0) { current_element = pop(); // if we went left from this node then this node is the next // biggest. if (went_left) { return; } else { move_next(); } } } // ---------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------- // enumerable function definitions // ---------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > bool binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: at_start ( ) const { return at_start_; } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > void binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: reset ( ) const { at_start_ = true; current_element = 0; stack_pos = 0; } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > bool binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: current_element_valid ( ) const { return (current_element != 0); } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > const map_pair<domain,range>& binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: element ( ) const { p.d = &(current_element->d); p.r = &(current_element->r); return p; } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > map_pair<domain,range>& binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: element ( ) { p.d = &(current_element->d); p.r = &(current_element->r); return p; } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > bool binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: move_next ( ) const { // if we haven't started iterating yet if (at_start_) { at_start_ = false; if (tree_size == 0) { return false; } else { // find the first element in the tree current_element = tree_root; node* temp = current_element->left; while (temp != 0) { push(current_element); current_element = temp; temp = current_element->left; } return true; } } else { if (current_element == 0) { return false; } else { node* temp; bool went_up; // true if we went up the tree from a child node to parent bool from_left = false; // true if we went up and were coming from a left child node // find the next element in the tree if (current_element->right != 0) { // go right and down temp = current_element; push(current_element); current_element = temp->right; went_up = false; } else { // go up to the parent if we can if (current_element == tree_root) { // in this case we have iterated over all the element of the tree current_element = 0; return false; } went_up = true; node* parent = pop(); from_left = (parent->left == current_element); // go up to parent current_element = parent; } while (true) { if (went_up) { if (from_left) { // in this case we have found the next node break; } else { if (current_element == tree_root) { // in this case we have iterated over all the elements // in the tree current_element = 0; return false; } // we should go up node* parent = pop(); from_left = (parent->left == current_element); current_element = parent; } } else { // we just went down to a child node if (current_element->left != 0) { // go left went_up = false; temp = current_element; push(current_element); current_element = temp->left; } else { // if there is no left child then we have found the next node break; } } } return true; } } } // ---------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------- // private member function definitions // ---------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > void binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: delete_tree ( node* t ) { if (t->left != 0) delete_tree(t->left); if (t->right != 0) delete_tree(t->right); pool.deallocate(t); } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > void binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: rotate_left ( node*& t ) { // set the new balance numbers if (t->right->balance == 1) { t->balance = 0; t->right->balance = 0; } else { t->balance = 1; t->right->balance = -1; } // perform the rotation node* temp = t->right; t->right = temp->left; temp->left = t; t = temp; } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > void binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: rotate_right ( node*& t ) { // set the new balance numbers if (t->left->balance == -1) { t->balance = 0; t->left->balance = 0; } else { t->balance = -1; t->left->balance = 1; } // preform the rotation node* temp = t->left; t->left = temp->right; temp->right = t; t = temp; } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > void binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: double_rotate_right ( node*& t ) { node* temp = t; t = t->left->right; temp->left->right = t->left; t->left = temp->left; temp->left = t->right; t->right = temp; if (t->balance < 0) { t->left->balance = 0; t->right->balance = 1; } else if (t->balance > 0) { t->left->balance = -1; t->right->balance = 0; } else { t->left->balance = 0; t->right->balance = 0; } t->balance = 0; } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > void binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: double_rotate_left ( node*& t ) { node* temp = t; t = t->right->left; temp->right->left = t->right; t->right = temp->right; temp->right = t->left; t->left = temp; if (t->balance < 0) { t->left->balance = 0; t->right->balance = 1; } else if (t->balance > 0) { t->left->balance = -1; t->right->balance = 0; } else { t->left->balance = 0; t->right->balance = 0; } t->balance = 0; } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > bool binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: remove_biggest_element_in_tree ( node*& t, domain& d, range& r ) { // make a reference to the current node so we don't have to dereference a // pointer a bunch of times node& tree = *t; // if the right tree is an empty tree if ( tree.right == 0) { // swap nodes domain and range elements into d and r exchange(d,tree.d); exchange(r,tree.r); // plug hole left by removing this node t = tree.left; // delete the node that was just removed pool.deallocate(&tree); // return that the height of this part of the tree has decreased return true; } else { // keep going right // if remove made the tree one height shorter if ( remove_biggest_element_in_tree(tree.right,d,r) ) { // if this caused the current tree to strink then report that if ( tree.balance == 1) { --tree.balance; return true; } else { --tree.balance; return keep_node_balanced(t); } } return false; } } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > bool binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: remove_least_element_in_tree ( node*& t, domain& d, range& r ) { // make a reference to the current node so we don't have to dereference a // pointer a bunch of times node& tree = *t; // if the left tree is an empty tree if ( tree.left == 0) { // swap nodes domain and range elements into d and r exchange(d,tree.d); exchange(r,tree.r); // plug hole left by removing this node t = tree.right; // delete the node that was just removed pool.deallocate(&tree); // return that the height of this part of the tree has decreased return true; } else { // keep going left // if remove made the tree one height shorter if ( remove_least_element_in_tree(tree.left,d,r) ) { // if this caused the current tree to strink then report that if ( tree.balance == -1) { ++tree.balance; return true; } else { ++tree.balance; return keep_node_balanced(t); } } return false; } } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > bool binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: add_to_tree ( node*& t, domain& d, range& r ) { // if found place to add if (t == 0) { // create a node to add new item into t = pool.allocate(); // make a reference to the current node so we don't have to dereference a // pointer a bunch of times node& tree = *t; // set left and right pointers to NULL to indicate that there are no // left or right subtrees tree.left = 0; tree.right = 0; tree.balance = 0; // put d and r into t exchange(tree.d,d); exchange(tree.r,r); // indicate that the height of this tree has increased return true; } else // keep looking for a place to add the new item { // make a reference to the current node so we don't have to dereference // a pointer a bunch of times node& tree = *t; signed char old_balance = tree.balance; // add the new item to whatever subtree it should go into if (comp( d , tree.d) ) tree.balance -= add_to_tree(tree.left,d,r); else tree.balance += add_to_tree(tree.right,d,r); // if the tree was balanced to start with if (old_balance == 0) { // if its not balanced anymore then it grew in height if (tree.balance != 0) return true; else return false; } else { // if the tree is now balanced then it didn't grow if (tree.balance == 0) { return false; } else { // if the tree needs to be balanced if (tree.balance != old_balance) { return !keep_node_balanced(t); } // if there has been no change in the heights else { return false; } } } } } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > bool binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: fix_stack ( node* t, unsigned char depth ) { // if we found the node we were looking for if (t == current_element) { stack_pos = depth; return true; } else if (t == 0) { return false; } if (!( comp(t->d , current_element->d))) { // go left if (fix_stack(t->left,depth+1)) { stack[depth] = t; return true; } } if (!(comp(current_element->d , t->d))) { // go right if (fix_stack(t->right,depth+1)) { stack[depth] = t; return true; } } return false; } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > bool binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: remove_current_element_from_tree ( node*& t, domain& d, range& r, unsigned long cur_stack_pos ) { // make a reference to the current node so we don't have to dereference // a pointer a bunch of times node& tree = *t; // if we found the node we were looking for if (t == current_element) { // swap nodes domain and range elements into d_copy and r exchange(d,tree.d); exchange(r,tree.r); // if there is no left node if (tree.left == 0) { // move the enumerator on to the next element before we mess with the // tree move_next(); // plug hole left by removing this node and free memory t = tree.right; // plug hole with right subtree // delete old node pool.deallocate(&tree); // indicate that the height has changed return true; } // if there is no right node else if (tree.right == 0) { // move the enumerator on to the next element before we mess with the // tree move_next(); // plug hole left by removing this node and free memory t = tree.left; // plug hole with left subtree // delete old node pool.deallocate(&tree); // indicate that the height of this tree has changed return true; } // if there are both a left and right sub node else { // in this case the next current element is going to get swapped back // into this t node. current_element = t; // get an element that can replace the one being removed and do this // if it made the right subtree shrink by one if (remove_least_element_in_tree(tree.right,tree.d,tree.r)) { // adjust the tree height --tree.balance; // if the height of the current tree has dropped by one if (tree.balance == 0) { return true; } else { return keep_node_balanced(t); } } // else this remove did not effect the height of this tree else { return false; } } } else if ( (cur_stack_pos < stack_pos && stack[cur_stack_pos] == tree.left) || tree.left == current_element ) { // go left if (tree.balance == -1) { int balance = tree.balance; balance += remove_current_element_from_tree(tree.left,d,r,cur_stack_pos+1); tree.balance = balance; return !tree.balance; } else { int balance = tree.balance; balance += remove_current_element_from_tree(tree.left,d,r,cur_stack_pos+1); tree.balance = balance; return keep_node_balanced(t); } } else if ( (cur_stack_pos < stack_pos && stack[cur_stack_pos] == tree.right) || tree.right == current_element ) { // go right if (tree.balance == 1) { int balance = tree.balance; balance -= remove_current_element_from_tree(tree.right,d,r,cur_stack_pos+1); tree.balance = balance; return !tree.balance; } else { int balance = tree.balance; balance -= remove_current_element_from_tree(tree.right,d,r,cur_stack_pos+1); tree.balance = balance; return keep_node_balanced(t); } } // this return should never happen but do it anyway to suppress compiler warnings return false; } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > bool binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: remove_from_tree ( node*& t, const domain& d, domain& d_copy, range& r ) { // make a reference to the current node so we don't have to dereference // a pointer a bunch of times node& tree = *t; // if item is on the left if (comp(d , tree.d)) { // if the left side of the tree has the greatest height if (tree.balance == -1) { int balance = tree.balance; balance += remove_from_tree(tree.left,d,d_copy,r); tree.balance = balance; return !tree.balance; } else { int balance = tree.balance; balance += remove_from_tree(tree.left,d,d_copy,r); tree.balance = balance; return keep_node_balanced(t); } } // if item is on the right else if (comp(tree.d , d)) { // if the right side of the tree has the greatest height if (tree.balance == 1) { int balance = tree.balance; balance -= remove_from_tree(tree.right,d,d_copy,r); tree.balance = balance; return !tree.balance; } else { int balance = tree.balance; balance -= remove_from_tree(tree.right,d,d_copy,r); tree.balance = balance; return keep_node_balanced(t); } } // if item is found else { // swap nodes domain and range elements into d_copy and r exchange(d_copy,tree.d); exchange(r,tree.r); // if there is no left node if (tree.left == 0) { // plug hole left by removing this node and free memory t = tree.right; // plug hole with right subtree // delete old node pool.deallocate(&tree); // indicate that the height has changed return true; } // if there is no right node else if (tree.right == 0) { // plug hole left by removing this node and free memory t = tree.left; // plug hole with left subtree // delete old node pool.deallocate(&tree); // indicate that the height of this tree has changed return true; } // if there are both a left and right sub node else { // get an element that can replace the one being removed and do this // if it made the right subtree shrink by one if (remove_least_element_in_tree(tree.right,tree.d,tree.r)) { // adjust the tree height --tree.balance; // if the height of the current tree has dropped by one if (tree.balance == 0) { return true; } else { return keep_node_balanced(t); } } // else this remove did not effect the height of this tree else { return false; } } } } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > bool binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: remove_from_tree ( node*& t, const domain& d ) { // make a reference to the current node so we don't have to dereference // a pointer a bunch of times node& tree = *t; // if item is on the left if (comp(d , tree.d)) { // if the left side of the tree has the greatest height if (tree.balance == -1) { int balance = tree.balance; balance += remove_from_tree(tree.left,d); tree.balance = balance; return !tree.balance; } else { int balance = tree.balance; balance += remove_from_tree(tree.left,d); tree.balance = balance; return keep_node_balanced(t); } } // if item is on the right else if (comp(tree.d , d)) { // if the right side of the tree has the greatest height if (tree.balance == 1) { int balance = tree.balance; balance -= remove_from_tree(tree.right,d); tree.balance = balance; return !tree.balance; } else { int balance = tree.balance; balance -= remove_from_tree(tree.right,d); tree.balance = balance; return keep_node_balanced(t); } } // if item is found else { // if there is no left node if (tree.left == 0) { // plug hole left by removing this node and free memory t = tree.right; // plug hole with right subtree // delete old node pool.deallocate(&tree); // indicate that the height has changed return true; } // if there is no right node else if (tree.right == 0) { // plug hole left by removing this node and free memory t = tree.left; // plug hole with left subtree // delete old node pool.deallocate(&tree); // indicate that the height of this tree has changed return true; } // if there are both a left and right sub node else { // get an element that can replace the one being removed and do this // if it made the right subtree shrink by one if (remove_least_element_in_tree(tree.right,tree.d,tree.r)) { // adjust the tree height --tree.balance; // if the height of the current tree has dropped by one if (tree.balance == 0) { return true; } else { return keep_node_balanced(t); } } // else this remove did not effect the height of this tree else { return false; } } } } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > range* binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: return_reference ( node* t, const domain& d ) { while (t != 0) { if ( comp(d , t->d )) { // if item is on the left then look in left t = t->left; } else if (comp(t->d , d)) { // if item is on the right then look in right t = t->right; } else { // if it's found then return a reference to it return &(t->r); } } return 0; } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > const range* binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: return_reference ( const node* t, const domain& d ) const { while (t != 0) { if ( comp(d , t->d) ) { // if item is on the left then look in left t = t->left; } else if (comp(t->d , d)) { // if item is on the right then look in right t = t->right; } else { // if it's found then return a reference to it return &(t->r); } } return 0; } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > bool binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: keep_node_balanced ( node*& t ) { // make a reference to the current node so we don't have to dereference // a pointer a bunch of times node& tree = *t; // if tree does not need to be balanced then return false if (tree.balance == 0) return false; // if tree needs to be rotated left if (tree.balance == 2) { if (tree.right->balance >= 0) rotate_left(t); else double_rotate_left(t); } // else if the tree needs to be rotated right else if (tree.balance == -2) { if (tree.left->balance <= 0) rotate_right(t); else double_rotate_right(t); } if (t->balance == 0) return true; else return false; } // ---------------------------------------------------------------------------------------- template < typename domain, typename range, typename mem_manager, typename compare > unsigned long binary_search_tree_kernel_1<domain,range,mem_manager,compare>:: get_count ( const domain& d, node* tree_root ) const { if (tree_root != 0) { if (comp(d , tree_root->d)) { // go left return get_count(d,tree_root->left); } else if (comp(tree_root->d , d)) { // go right return get_count(d,tree_root->right); } else { // go left and right to look for more matches return get_count(d,tree_root->left) + get_count(d,tree_root->right) + 1; } } return 0; } // ---------------------------------------------------------------------------------------- } #endif // DLIB_BINARY_SEARCH_TREE_KERNEl_1_
[ "jimmy@DGJ3X3B1.(none)" ]
[ [ [ 1, 2064 ] ] ]
226acf2e2cc0c59777398e2eaceae06f4dfa6864
cfa6cdfaba310a2fd5f89326690b5c48c6872a2a
/References/My SQL/tutorialSQL/Tutorial/sql_01/stdafx.h
022e47e9b995b1a27af4c725e54f01b0d87be036
[]
no_license
asdlei00/project-jb
1cc70130020a5904e0e6a46ace8944a431a358f6
0bfaa84ddab946c90245f539c1e7c2e75f65a5c0
refs/heads/master
2020-05-07T21:41:16.420207
2009-09-12T03:40:17
2009-09-12T03:40:17
40,292,178
0
0
null
null
null
null
UTF-8
C++
false
false
289
h
// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once #include <iostream> #include <tchar.h> // TODO: reference additional headers your program requires here
[ [ [ 1, 10 ] ], [ [ 11, 11 ] ] ]
9273c7f2fbc68266847b3065ee00782979ee1d11
998a318796a237601e06616d94d671dedb66d810
/include/grids/matrix4.h
ded23ff56e3816b4359c18465b646d62ef7c7d98
[]
no_license
ptierney/Kaleidoscope
f80e57c5e26a3e03d498855a4a4e956e9ff0ae30
19991163f2d63427caa3a43f3524f8d53f52b945
refs/heads/master
2021-01-22T23:53:39.659132
2010-08-22T02:55:56
2010-08-22T02:55:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
50,069
h
// Copyright (C) 2002-2008 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h #ifndef __IRR_MATRIX_H_INCLUDED__ #define __IRR_MATRIX_H_INCLUDED__ #include "irrTypes.h" #include "vector3d.h" #include "vector2d.h" #include "plane3d.h" #include "aabbox3d.h" #include "rect.h" #include "irrString.h" namespace irr { namespace core { //! 4x4 matrix. Mostly used as transformation matrix for 3d calculations. /** The matrix is a D3D style matrix, row major with translations in the 4th row. */ template <class T> class CMatrix4 { public: //! Constructor Flags enum eConstructor { EM4CONST_NOTHING = 0, EM4CONST_COPY, EM4CONST_IDENTITY, EM4CONST_TRANSPOSED, EM4CONST_INVERSE, EM4CONST_INVERSE_TRANSPOSED }; //! Default constructor /** \param constructor Choose the initialization style */ CMatrix4( eConstructor constructor = EM4CONST_IDENTITY ); //! Copy constructor /** \param other Other matrix to copy from \param constructor Choose the initialization style */ CMatrix4( const CMatrix4<T>& other,eConstructor constructor = EM4CONST_COPY); //! Simple operator for directly accessing every element of the matrix. T& operator()(const s32 row, const s32 col) { definitelyIdentityMatrix=false; return M[ row * 4 + col ]; } //! Simple operator for directly accessing every element of the matrix. const T& operator()(const s32 row, const s32 col) const { return M[row * 4 + col]; } //! Simple operator for linearly accessing every element of the matrix. T& operator[](u32 index) { definitelyIdentityMatrix=false; return M[index]; } //! Simple operator for linearly accessing every element of the matrix. const T& operator[](u32 index) const { return M[index]; } //! Sets this matrix equal to the other matrix. inline CMatrix4<T>& operator=(const CMatrix4<T> &other); //! Sets all elements of this matrix to the value. inline CMatrix4<T>& operator=(const T& scalar); //! Returns pointer to internal array const T* pointer() const { return M; } T* pointer() { definitelyIdentityMatrix=false; return M; } //! Returns true if other matrix is equal to this matrix. bool operator==(const CMatrix4<T> &other) const; //! Returns true if other matrix is not equal to this matrix. bool operator!=(const CMatrix4<T> &other) const; //! Add another matrix. CMatrix4<T> operator+(const CMatrix4<T>& other) const; //! Add another matrix. CMatrix4<T>& operator+=(const CMatrix4<T>& other); //! Subtract another matrix. CMatrix4<T> operator-(const CMatrix4<T>& other) const; //! Subtract another matrix. CMatrix4<T>& operator-=(const CMatrix4<T>& other); //! set this matrix to the product of two matrices inline CMatrix4<T>& setbyproduct(const CMatrix4<T>& other_a,const CMatrix4<T>& other_b ); //! Set this matrix to the product of two matrices /** no optimization used, use it if you know you never have a identity matrix */ CMatrix4<T>& setbyproduct_nocheck(const CMatrix4<T>& other_a,const CMatrix4<T>& other_b ); //! Multiply by another matrix. CMatrix4<T> operator*(const CMatrix4<T>& other) const; //! Multiply by another matrix. CMatrix4<T>& operator*=(const CMatrix4<T>& other); //! Multiply by scalar. CMatrix4<T> operator*(const T& scalar) const; //! Multiply by scalar. CMatrix4<T>& operator*=(const T& scalar); //! Set matrix to identity. inline CMatrix4<T>& makeIdentity(); //! Returns true if the matrix is the identity matrix inline bool isIdentity() const; //! Returns true if the matrix is the identity matrix bool isIdentity_integer_base () const; //! Set the translation of the current matrix. Will erase any previous values. CMatrix4<T>& setTranslation( const vector3d<T>& translation ); //! Gets the current translation vector3d<T> getTranslation() const; //! Set the inverse translation of the current matrix. Will erase any previous values. CMatrix4<T>& setInverseTranslation( const vector3d<T>& translation ); //! Make a rotation matrix from Euler angles. The 4th row and column are unmodified. inline CMatrix4<T>& setRotationRadians( const vector3d<T>& rotation ); //! Make a rotation matrix from Euler angles. The 4th row and column are unmodified. CMatrix4<T>& setRotationDegrees( const vector3d<T>& rotation ); //! Returns the rotation, as set by setRotation(). /** This code was orginally written by by Chev. */ core::vector3d<T> getRotationDegrees() const; //! Make an inverted rotation matrix from Euler angles. /** The 4th row and column are unmodified. */ inline CMatrix4<T>& setInverseRotationRadians( const vector3d<T>& rotation ); //! Make an inverted rotation matrix from Euler angles. /** The 4th row and column are unmodified. */ CMatrix4<T>& setInverseRotationDegrees( const vector3d<T>& rotation ); //! Set Scale CMatrix4<T>& setScale( const vector3d<T>& scale ); //! Set Scale CMatrix4<T>& setScale( const T scale ) { return setScale(core::vector3d<T>(scale,scale,scale)); } //! Get Scale core::vector3d<T> getScale() const; //! Translate a vector by the inverse of the translation part of this matrix. void inverseTranslateVect( vector3df& vect ) const; //! Rotate a vector by the inverse of the rotation part of this matrix. void inverseRotateVect( vector3df& vect ) const; //! Rotate a vector by the rotation part of this matrix. void rotateVect( vector3df& vect ) const; //! An alternate transform vector method, writing into a second vector void rotateVect(core::vector3df& out, const core::vector3df& in) const; //! An alternate transform vector method, writing into an array of 3 floats void rotateVect(T *out,const core::vector3df &in) const; //! Transforms the vector by this matrix void transformVect( vector3df& vect) const; //! Transforms input vector by this matrix and stores result in output vector void transformVect( vector3df& out, const vector3df& in ) const; //! An alternate transform vector method, writing into an array of 4 floats void transformVect(T *out,const core::vector3df &in) const; //! Translate a vector by the translation part of this matrix. void translateVect( vector3df& vect ) const; //! Transforms a plane by this matrix void transformPlane( core::plane3d<f32> &plane) const; //! Transforms a plane by this matrix ( some problems to solve..) void transformPlane_new( core::plane3d<f32> &plane) const; //! Transforms a plane by this matrix void transformPlane( const core::plane3d<f32> &in, core::plane3d<f32> &out) const; //! Transforms a axis aligned bounding box /** The result box of this operation may not be very accurate. For accurate results, use transformBoxEx() */ void transformBox(core::aabbox3d<f32>& box) const; //! Transforms a axis aligned bounding box more accurately than transformBox() /** The result box of this operation should by quite accurate, but this operation is slower than transformBox(). */ void transformBoxEx(core::aabbox3d<f32>& box) const; //! Multiplies this matrix by a 1x4 matrix void multiplyWith1x4Matrix(T* matrix) const; //! Calculates inverse of matrix. Slow. /** \return Returns false if there is no inverse matrix.*/ bool makeInverse(); //! Inverts a primitive matrix which only contains a translation and a rotation /** \param out: where result matrix is written to. */ bool getInversePrimitive ( CMatrix4<T>& out ) const; //! Gets the inversed matrix of this one /** \param out: where result matrix is written to. \return Returns false if there is no inverse matrix. */ bool getInverse(CMatrix4<T>& out) const; //! Builds a right-handed perspective projection matrix based on a field of view CMatrix4<T>& buildProjectionMatrixPerspectiveFovRH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar); //! Builds a left-handed perspective projection matrix based on a field of view CMatrix4<T>& buildProjectionMatrixPerspectiveFovLH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar); //! Builds a right-handed perspective projection matrix. CMatrix4<T>& buildProjectionMatrixPerspectiveRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); //! Builds a left-handed perspective projection matrix. CMatrix4<T>& buildProjectionMatrixPerspectiveLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); //! Builds a left-handed orthogonal projection matrix. CMatrix4<T>& buildProjectionMatrixOrthoLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); //! Builds a right-handed orthogonal projection matrix. CMatrix4<T>& buildProjectionMatrixOrthoRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar); //! Builds a left-handed look-at matrix. CMatrix4<T>& buildCameraLookAtMatrixLH( const vector3df& position, const vector3df& target, const vector3df& upVector); //! Builds a right-handed look-at matrix. CMatrix4<T>& buildCameraLookAtMatrixRH( const vector3df& position, const vector3df& target, const vector3df& upVector); //! Builds a matrix that flattens geometry into a plane. /** \param light: light source \param plane: plane into which the geometry if flattened into \param point: value between 0 and 1, describing the light source. If this is 1, it is a point light, if it is 0, it is a directional light. */ CMatrix4<T>& buildShadowMatrix(const core::vector3df& light, core::plane3df plane, f32 point=1.0f); //! Builds a matrix which transforms a normalized Device Coordinate to Device Coordinates. /** Used to scale <-1,-1><1,1> to viewport, for example from von <-1,-1> <1,1> to the viewport <0,0><0,640> */ CMatrix4<T>& buildNDCToDCMatrix( const core::rect<s32>& area, f32 zScale); //! Creates a new matrix as interpolated matrix from two other ones. /** \param b: other matrix to interpolate with \param time: Must be a value between 0 and 1. */ CMatrix4<T> interpolate(const core::CMatrix4<T>& b, f32 time) const; //! Gets transposed matrix CMatrix4<T> getTransposed() const; //! Gets transposed matrix inline void getTransposed( CMatrix4<T>& dest ) const; /* construct 2D Texture transformations rotate about center, scale, and transform. */ //! Set to a texture transformation matrix with the given parameters. CMatrix4<T>& buildTextureTransform( f32 rotateRad, const core::vector2df &rotatecenter, const core::vector2df &translate, const core::vector2df &scale); //! Set texture transformation rotation /** Rotate about z axis, recenter at (0.5,0.5). Doesn't clear other elements than those affected \param radAngle Angle in radians \return Altered matrix */ CMatrix4<T>& setTextureRotationCenter( f32 radAngle ); //! Set texture transformation translation /** Doesn't clear other elements than those affected. \param x Offset on x axis \param y Offset on y axis \return Altered matrix */ CMatrix4<T>& setTextureTranslate( f32 x, f32 y ); //! Set texture transformation translation, using a transposed representation /** Doesn't clear other elements than those affected. \param x Offset on x axis \param y Offset on y axis \return Altered matrix */ CMatrix4<T>& setTextureTranslateTransposed( f32 x, f32 y ); //! Set texture transformation scale /** Doesn't clear other elements than those affected. \param sx Scale factor on x axis \param sy Scale factor on y axis \return Altered matrix. */ CMatrix4<T>& setTextureScale( f32 sx, f32 sy ); //! Set texture transformation scale, and recenter at (0.5,0.5) /** Doesn't clear other elements than those affected. \param sx Scale factor on x axis \param sy Scale factor on y axis \return Altered matrix. */ CMatrix4<T>& setTextureScaleCenter( f32 sx, f32 sy ); //! Sets all matrix data members at once CMatrix4<T>& setM(const T* data); //! Sets if the matrix is definitely identity matrix void setDefinitelyIdentityMatrix( bool isDefinitelyIdentityMatrix); //! Gets if the matrix is definitely identity matrix bool getDefinitelyIdentityMatrix() const; private: //! Matrix data, stored in row-major order T M[16]; //! Flag is this matrix is identity matrix mutable bool definitelyIdentityMatrix; }; // Default constructor template <class T> inline CMatrix4<T>::CMatrix4( eConstructor constructor ) : definitelyIdentityMatrix(false) { switch ( constructor ) { case EM4CONST_NOTHING: case EM4CONST_COPY: break; case EM4CONST_IDENTITY: case EM4CONST_INVERSE: default: makeIdentity(); break; } } // Copy constructor template <class T> inline CMatrix4<T>::CMatrix4( const CMatrix4<T>& other, eConstructor constructor) : definitelyIdentityMatrix(false) { switch ( constructor ) { case EM4CONST_IDENTITY: makeIdentity(); break; case EM4CONST_NOTHING: break; case EM4CONST_COPY: *this = other; break; case EM4CONST_TRANSPOSED: other.getTransposed(*this); break; case EM4CONST_INVERSE: if (!other.getInverse(*this)) memset(M, 0, 16*sizeof(T)); break; case EM4CONST_INVERSE_TRANSPOSED: if (!other.getInverse(*this)) memset(M, 0, 16*sizeof(T)); else *this=getTransposed(); break; } } //! Add another matrix. template <class T> inline CMatrix4<T> CMatrix4<T>::operator+(const CMatrix4<T>& other) const { CMatrix4<T> temp ( EM4CONST_NOTHING ); temp[0] = M[0]+other[0]; temp[1] = M[1]+other[1]; temp[2] = M[2]+other[2]; temp[3] = M[3]+other[3]; temp[4] = M[4]+other[4]; temp[5] = M[5]+other[5]; temp[6] = M[6]+other[6]; temp[7] = M[7]+other[7]; temp[8] = M[8]+other[8]; temp[9] = M[9]+other[9]; temp[10] = M[10]+other[10]; temp[11] = M[11]+other[11]; temp[12] = M[12]+other[12]; temp[13] = M[13]+other[13]; temp[14] = M[14]+other[14]; temp[15] = M[15]+other[15]; return temp; } //! Add another matrix. template <class T> inline CMatrix4<T>& CMatrix4<T>::operator+=(const CMatrix4<T>& other) { M[0]+=other[0]; M[1]+=other[1]; M[2]+=other[2]; M[3]+=other[3]; M[4]+=other[4]; M[5]+=other[5]; M[6]+=other[6]; M[7]+=other[7]; M[8]+=other[8]; M[9]+=other[9]; M[10]+=other[10]; M[11]+=other[11]; M[12]+=other[12]; M[13]+=other[13]; M[14]+=other[14]; M[15]+=other[15]; return *this; } //! Subtract another matrix. template <class T> inline CMatrix4<T> CMatrix4<T>::operator-(const CMatrix4<T>& other) const { CMatrix4<T> temp ( EM4CONST_NOTHING ); temp[0] = M[0]-other[0]; temp[1] = M[1]-other[1]; temp[2] = M[2]-other[2]; temp[3] = M[3]-other[3]; temp[4] = M[4]-other[4]; temp[5] = M[5]-other[5]; temp[6] = M[6]-other[6]; temp[7] = M[7]-other[7]; temp[8] = M[8]-other[8]; temp[9] = M[9]-other[9]; temp[10] = M[10]-other[10]; temp[11] = M[11]-other[11]; temp[12] = M[12]-other[12]; temp[13] = M[13]-other[13]; temp[14] = M[14]-other[14]; temp[15] = M[15]-other[15]; return temp; } //! Subtract another matrix. template <class T> inline CMatrix4<T>& CMatrix4<T>::operator-=(const CMatrix4<T>& other) { M[0]-=other[0]; M[1]-=other[1]; M[2]-=other[2]; M[3]-=other[3]; M[4]-=other[4]; M[5]-=other[5]; M[6]-=other[6]; M[7]-=other[7]; M[8]-=other[8]; M[9]-=other[9]; M[10]-=other[10]; M[11]-=other[11]; M[12]-=other[12]; M[13]-=other[13]; M[14]-=other[14]; M[15]-=other[15]; return *this; } //! Multiply by scalar. template <class T> inline CMatrix4<T> CMatrix4<T>::operator*(const T& scalar) const { CMatrix4<T> temp ( EM4CONST_NOTHING ); temp[0] = M[0]*scalar; temp[1] = M[1]*scalar; temp[2] = M[2]*scalar; temp[3] = M[3]*scalar; temp[4] = M[4]*scalar; temp[5] = M[5]*scalar; temp[6] = M[6]*scalar; temp[7] = M[7]*scalar; temp[8] = M[8]*scalar; temp[9] = M[9]*scalar; temp[10] = M[10]*scalar; temp[11] = M[11]*scalar; temp[12] = M[12]*scalar; temp[13] = M[13]*scalar; temp[14] = M[14]*scalar; temp[15] = M[15]*scalar; return temp; } //! Multiply by scalar. template <class T> inline CMatrix4<T>& CMatrix4<T>::operator*=(const T& scalar) { M[0]*=scalar; M[1]*=scalar; M[2]*=scalar; M[3]*=scalar; M[4]*=scalar; M[5]*=scalar; M[6]*=scalar; M[7]*=scalar; M[8]*=scalar; M[9]*=scalar; M[10]*=scalar; M[11]*=scalar; M[12]*=scalar; M[13]*=scalar; M[14]*=scalar; M[15]*=scalar; return *this; } //! Multiply by another matrix. template <class T> inline CMatrix4<T>& CMatrix4<T>::operator*=(const CMatrix4<T>& other) { // do checks on your own in order to avoid copy creation if ( !other.isIdentity() ) { if ( this->isIdentity() ) { return (*this = other); } else { CMatrix4<T> temp ( *this ); return setbyproduct_nocheck( temp, other ); } } return *this; } //! multiply by another matrix // set this matrix to the product of two other matrices // goal is to reduce stack use and copy template <class T> inline CMatrix4<T>& CMatrix4<T>::setbyproduct_nocheck(const CMatrix4<T>& other_a,const CMatrix4<T>& other_b ) { const T *m1 = other_a.M; const T *m2 = other_b.M; M[0] = m1[0]*m2[0] + m1[4]*m2[1] + m1[8]*m2[2] + m1[12]*m2[3]; M[1] = m1[1]*m2[0] + m1[5]*m2[1] + m1[9]*m2[2] + m1[13]*m2[3]; M[2] = m1[2]*m2[0] + m1[6]*m2[1] + m1[10]*m2[2] + m1[14]*m2[3]; M[3] = m1[3]*m2[0] + m1[7]*m2[1] + m1[11]*m2[2] + m1[15]*m2[3]; M[4] = m1[0]*m2[4] + m1[4]*m2[5] + m1[8]*m2[6] + m1[12]*m2[7]; M[5] = m1[1]*m2[4] + m1[5]*m2[5] + m1[9]*m2[6] + m1[13]*m2[7]; M[6] = m1[2]*m2[4] + m1[6]*m2[5] + m1[10]*m2[6] + m1[14]*m2[7]; M[7] = m1[3]*m2[4] + m1[7]*m2[5] + m1[11]*m2[6] + m1[15]*m2[7]; M[8] = m1[0]*m2[8] + m1[4]*m2[9] + m1[8]*m2[10] + m1[12]*m2[11]; M[9] = m1[1]*m2[8] + m1[5]*m2[9] + m1[9]*m2[10] + m1[13]*m2[11]; M[10] = m1[2]*m2[8] + m1[6]*m2[9] + m1[10]*m2[10] + m1[14]*m2[11]; M[11] = m1[3]*m2[8] + m1[7]*m2[9] + m1[11]*m2[10] + m1[15]*m2[11]; M[12] = m1[0]*m2[12] + m1[4]*m2[13] + m1[8]*m2[14] + m1[12]*m2[15]; M[13] = m1[1]*m2[12] + m1[5]*m2[13] + m1[9]*m2[14] + m1[13]*m2[15]; M[14] = m1[2]*m2[12] + m1[6]*m2[13] + m1[10]*m2[14] + m1[14]*m2[15]; M[15] = m1[3]*m2[12] + m1[7]*m2[13] + m1[11]*m2[14] + m1[15]*m2[15]; definitelyIdentityMatrix=false; return *this; } //! multiply by another matrix // set this matrix to the product of two other matrices // goal is to reduce stack use and copy template <class T> inline CMatrix4<T>& CMatrix4<T>::setbyproduct(const CMatrix4<T>& other_a, const CMatrix4<T>& other_b ) { if ( other_a.isIdentity () ) return (*this = other_b); else if ( other_b.isIdentity () ) return (*this = other_a); else return setbyproduct_nocheck(other_a,other_b); } //! multiply by another matrix template <class T> inline CMatrix4<T> CMatrix4<T>::operator*(const CMatrix4<T>& m2) const { // Testing purpose.. if ( this->isIdentity() ) return m2; if ( m2.isIdentity() ) return *this; CMatrix4<T> m3 ( EM4CONST_NOTHING ); const T *m1 = M; m3[0] = m1[0]*m2[0] + m1[4]*m2[1] + m1[8]*m2[2] + m1[12]*m2[3]; m3[1] = m1[1]*m2[0] + m1[5]*m2[1] + m1[9]*m2[2] + m1[13]*m2[3]; m3[2] = m1[2]*m2[0] + m1[6]*m2[1] + m1[10]*m2[2] + m1[14]*m2[3]; m3[3] = m1[3]*m2[0] + m1[7]*m2[1] + m1[11]*m2[2] + m1[15]*m2[3]; m3[4] = m1[0]*m2[4] + m1[4]*m2[5] + m1[8]*m2[6] + m1[12]*m2[7]; m3[5] = m1[1]*m2[4] + m1[5]*m2[5] + m1[9]*m2[6] + m1[13]*m2[7]; m3[6] = m1[2]*m2[4] + m1[6]*m2[5] + m1[10]*m2[6] + m1[14]*m2[7]; m3[7] = m1[3]*m2[4] + m1[7]*m2[5] + m1[11]*m2[6] + m1[15]*m2[7]; m3[8] = m1[0]*m2[8] + m1[4]*m2[9] + m1[8]*m2[10] + m1[12]*m2[11]; m3[9] = m1[1]*m2[8] + m1[5]*m2[9] + m1[9]*m2[10] + m1[13]*m2[11]; m3[10] = m1[2]*m2[8] + m1[6]*m2[9] + m1[10]*m2[10] + m1[14]*m2[11]; m3[11] = m1[3]*m2[8] + m1[7]*m2[9] + m1[11]*m2[10] + m1[15]*m2[11]; m3[12] = m1[0]*m2[12] + m1[4]*m2[13] + m1[8]*m2[14] + m1[12]*m2[15]; m3[13] = m1[1]*m2[12] + m1[5]*m2[13] + m1[9]*m2[14] + m1[13]*m2[15]; m3[14] = m1[2]*m2[12] + m1[6]*m2[13] + m1[10]*m2[14] + m1[14]*m2[15]; m3[15] = m1[3]*m2[12] + m1[7]*m2[13] + m1[11]*m2[14] + m1[15]*m2[15]; return m3; } template <class T> inline vector3d<T> CMatrix4<T>::getTranslation() const { return vector3d<T>(M[12], M[13], M[14]); } template <class T> inline CMatrix4<T>& CMatrix4<T>::setTranslation( const vector3d<T>& translation ) { M[12] = translation.X; M[13] = translation.Y; M[14] = translation.Z; definitelyIdentityMatrix=false; return *this; } template <class T> inline CMatrix4<T>& CMatrix4<T>::setInverseTranslation( const vector3d<T>& translation ) { M[12] = -translation.X; M[13] = -translation.Y; M[14] = -translation.Z; definitelyIdentityMatrix=false; return *this; } template <class T> inline CMatrix4<T>& CMatrix4<T>::setScale( const vector3d<T>& scale ) { M[0] = scale.X; M[5] = scale.Y; M[10] = scale.Z; definitelyIdentityMatrix=false; return *this; } template <class T> inline vector3d<T> CMatrix4<T>::getScale() const { return vector3d<T>(M[0],M[5],M[10]); } template <class T> inline CMatrix4<T>& CMatrix4<T>::setRotationDegrees( const vector3d<T>& rotation ) { return setRotationRadians( rotation * core::DEGTORAD ); } template <class T> inline CMatrix4<T>& CMatrix4<T>::setInverseRotationDegrees( const vector3d<T>& rotation ) { return setInverseRotationRadians( rotation * core::DEGTORAD ); } template <class T> inline CMatrix4<T>& CMatrix4<T>::setRotationRadians( const vector3d<T>& rotation ) { const f64 cr = cos( rotation.X ); const f64 sr = sin( rotation.X ); const f64 cp = cos( rotation.Y ); const f64 sp = sin( rotation.Y ); const f64 cy = cos( rotation.Z ); const f64 sy = sin( rotation.Z ); M[0] = (T)( cp*cy ); M[1] = (T)( cp*sy ); M[2] = (T)( -sp ); const f64 srsp = sr*sp; const f64 crsp = cr*sp; M[4] = (T)( srsp*cy-cr*sy ); M[5] = (T)( srsp*sy+cr*cy ); M[6] = (T)( sr*cp ); M[8] = (T)( crsp*cy+sr*sy ); M[9] = (T)( crsp*sy-sr*cy ); M[10] = (T)( cr*cp ); definitelyIdentityMatrix=false; return *this; } //! Returns the rotation, as set by setRotation(). This code was sent //! in by Chev. template <class T> inline core::vector3d<T> CMatrix4<T>::getRotationDegrees() const { const CMatrix4<T> &mat = *this; f64 Y = -asin(mat(0,2)); const f64 C = cos(Y); Y *= RADTODEG64; f64 rotx, roty, X, Z; if (fabs(C)>ROUNDING_ERROR_64) { const T invC = (T)(1.0/C); rotx = mat(2,2) * invC; roty = mat(1,2) * invC; X = atan2( roty, rotx ) * RADTODEG64; rotx = mat(0,0) * invC; roty = mat(0,1) * invC; Z = atan2( roty, rotx ) * RADTODEG64; } else { X = 0.0; rotx = mat(1,1); roty = -mat(1,0); Z = atan2( roty, rotx ) * RADTODEG64; } // fix values that get below zero // before it would set (!) values to 360 // that where above 360: if (X < 0.0) X += 360.0; if (Y < 0.0) Y += 360.0; if (Z < 0.0) Z += 360.0; return vector3d<T>((T)X,(T)Y,(T)Z); } template <class T> inline CMatrix4<T>& CMatrix4<T>::setInverseRotationRadians( const vector3d<T>& rotation ) { f64 cr = cos( rotation.X ); f64 sr = sin( rotation.X ); f64 cp = cos( rotation.Y ); f64 sp = sin( rotation.Y ); f64 cy = cos( rotation.Z ); f64 sy = sin( rotation.Z ); M[0] = (T)( cp*cy ); M[4] = (T)( cp*sy ); M[8] = (T)( -sp ); f64 srsp = sr*sp; f64 crsp = cr*sp; M[1] = (T)( srsp*cy-cr*sy ); M[5] = (T)( srsp*sy+cr*cy ); M[9] = (T)( sr*cp ); M[2] = (T)( crsp*cy+sr*sy ); M[6] = (T)( crsp*sy-sr*cy ); M[10] = (T)( cr*cp ); definitelyIdentityMatrix=false; return *this; } /*! */ template <class T> inline CMatrix4<T>& CMatrix4<T>::makeIdentity() { memset(M, 0, 16*sizeof(T)); M[0] = M[5] = M[10] = M[15] = (T)1; definitelyIdentityMatrix=true; return *this; } /* check identity with epsilon solve floating range problems.. */ template <class T> inline bool CMatrix4<T>::isIdentity() const { if (definitelyIdentityMatrix) return true; if (!equals( M[ 0], (T)1 ) || !equals( M[ 5], (T)1 ) || !equals( M[10], (T)1 ) || !equals( M[15], (T)1 )) return false; for (s32 i=0; i<4; ++i) for (s32 j=0; j<4; ++j) if ((j != i) && (!iszero((*this)(i,j)))) return false; definitelyIdentityMatrix=true; return true; } /* doesn't solve floating range problems.. but takes care on +/- 0 on translation because we are changing it.. reducing floating point branches but it needs the floats in memory.. */ template <class T> inline bool CMatrix4<T>::isIdentity_integer_base() const { if (definitelyIdentityMatrix) return true; if(IR(M[0])!=F32_VALUE_1) return false; if(IR(M[1])!=0) return false; if(IR(M[2])!=0) return false; if(IR(M[3])!=0) return false; if(IR(M[4])!=0) return false; if(IR(M[5])!=F32_VALUE_1) return false; if(IR(M[6])!=0) return false; if(IR(M[7])!=0) return false; if(IR(M[8])!=0) return false; if(IR(M[9])!=0) return false; if(IR(M[10])!=F32_VALUE_1) return false; if(IR(M[11])!=0) return false; if(IR(M[12])!=0) return false; if(IR(M[13])!=0) return false; if(IR(M[13])!=0) return false; if(IR(M[15])!=F32_VALUE_1) return false; definitelyIdentityMatrix=true; return true; } template <class T> inline void CMatrix4<T>::rotateVect( vector3df& vect ) const { vector3df tmp = vect; vect.X = tmp.X*M[0] + tmp.Y*M[4] + tmp.Z*M[8]; vect.Y = tmp.X*M[1] + tmp.Y*M[5] + tmp.Z*M[9]; vect.Z = tmp.X*M[2] + tmp.Y*M[6] + tmp.Z*M[10]; } //! An alternate transform vector method, writing into a second vector template <class T> inline void CMatrix4<T>::rotateVect(core::vector3df& out, const core::vector3df& in) const { out.X = in.X*M[0] + in.Y*M[4] + in.Z*M[8]; out.Y = in.X*M[1] + in.Y*M[5] + in.Z*M[9]; out.Z = in.X*M[2] + in.Y*M[6] + in.Z*M[10]; } //! An alternate transform vector method, writing into an array of 3 floats template <class T> inline void CMatrix4<T>::rotateVect(T *out, const core::vector3df& in) const { out[0] = in.X*M[0] + in.Y*M[4] + in.Z*M[8]; out[1] = in.X*M[1] + in.Y*M[5] + in.Z*M[9]; out[2] = in.X*M[2] + in.Y*M[6] + in.Z*M[10]; } template <class T> inline void CMatrix4<T>::inverseRotateVect( vector3df& vect ) const { vector3df tmp = vect; vect.X = tmp.X*M[0] + tmp.Y*M[1] + tmp.Z*M[2]; vect.Y = tmp.X*M[4] + tmp.Y*M[5] + tmp.Z*M[6]; vect.Z = tmp.X*M[8] + tmp.Y*M[9] + tmp.Z*M[10]; } template <class T> inline void CMatrix4<T>::transformVect( vector3df& vect) const { f32 vector[3]; vector[0] = vect.X*M[0] + vect.Y*M[4] + vect.Z*M[8] + M[12]; vector[1] = vect.X*M[1] + vect.Y*M[5] + vect.Z*M[9] + M[13]; vector[2] = vect.X*M[2] + vect.Y*M[6] + vect.Z*M[10] + M[14]; vect.X = vector[0]; vect.Y = vector[1]; vect.Z = vector[2]; } template <class T> inline void CMatrix4<T>::transformVect( vector3df& out, const vector3df& in) const { out.X = in.X*M[0] + in.Y*M[4] + in.Z*M[8] + M[12]; out.Y = in.X*M[1] + in.Y*M[5] + in.Z*M[9] + M[13]; out.Z = in.X*M[2] + in.Y*M[6] + in.Z*M[10] + M[14]; } template <class T> inline void CMatrix4<T>::transformVect(T *out, const core::vector3df &in) const { out[0] = in.X*M[0] + in.Y*M[4] + in.Z*M[8] + M[12]; out[1] = in.X*M[1] + in.Y*M[5] + in.Z*M[9] + M[13]; out[2] = in.X*M[2] + in.Y*M[6] + in.Z*M[10] + M[14]; out[3] = in.X*M[3] + in.Y*M[7] + in.Z*M[11] + M[15]; } //! Transforms a plane by this matrix template <class T> inline void CMatrix4<T>::transformPlane( core::plane3d<f32> &plane) const { vector3df member; transformVect(member, plane.getMemberPoint()); vector3df origin(0,0,0); transformVect(plane.Normal); transformVect(origin); plane.Normal -= origin; plane.D = - member.dotProduct(plane.Normal); } //! Transforms a plane by this matrix template <class T> inline void CMatrix4<T>::transformPlane_new( core::plane3d<f32> &plane) const { // rotate normal -> rotateVect ( plane.n ); vector3df n; n.X = plane.Normal.X*M[0] + plane.Normal.Y*M[4] + plane.Normal.Z*M[8]; n.Y = plane.Normal.X*M[1] + plane.Normal.Y*M[5] + plane.Normal.Z*M[9]; n.Z = plane.Normal.X*M[2] + plane.Normal.Y*M[6] + plane.Normal.Z*M[10]; // compute new d. -> getTranslation(). dotproduct ( plane.n ) plane.D -= M[12] * n.X + M[13] * n.Y + M[14] * n.Z; plane.Normal.X = n.X; plane.Normal.Y = n.Y; plane.Normal.Z = n.Z; } //! Transforms a plane by this matrix template <class T> inline void CMatrix4<T>::transformPlane( const core::plane3d<f32> &in, core::plane3d<f32> &out) const { out = in; transformPlane( out ); } //! Transforms a axis aligned bounding box template <class T> inline void CMatrix4<T>::transformBox(core::aabbox3d<f32>& box) const { if (isIdentity() ) return; transformVect(box.MinEdge); transformVect(box.MaxEdge); box.repair(); } //! Transforms a axis aligned bounding box more accurately than transformBox() template <class T> inline void CMatrix4<T>::transformBoxEx(core::aabbox3d<f32>& box) const { f32 Amin[3]; f32 Amax[3]; f32 Bmin[3]; f32 Bmax[3]; Amin[0] = box.MinEdge.X; Amin[1] = box.MinEdge.Y; Amin[2] = box.MinEdge.Z; Amax[0] = box.MaxEdge.X; Amax[1] = box.MaxEdge.Y; Amax[2] = box.MaxEdge.Z; Bmin[0] = Bmax[0] = M[12]; Bmin[1] = Bmax[1] = M[13]; Bmin[2] = Bmax[2] = M[14]; u32 i, j; const CMatrix4<T> &m = *this; for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { f32 a = m(j,i) * Amin[j]; f32 b = m(j,i) * Amax[j]; if (a < b) { Bmin[i] += a; Bmax[i] += b; } else { Bmin[i] += b; Bmax[i] += a; } } } box.MinEdge.X = Bmin[0]; box.MinEdge.Y = Bmin[1]; box.MinEdge.Z = Bmin[2]; box.MaxEdge.X = Bmax[0]; box.MaxEdge.Y = Bmax[1]; box.MaxEdge.Z = Bmax[2]; } //! Multiplies this matrix by a 1x4 matrix template <class T> inline void CMatrix4<T>::multiplyWith1x4Matrix(T* matrix) const { /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ T mat[4]; mat[0] = matrix[0]; mat[1] = matrix[1]; mat[2] = matrix[2]; mat[3] = matrix[3]; matrix[0] = M[0]*mat[0] + M[4]*mat[1] + M[8]*mat[2] + M[12]*mat[3]; matrix[1] = M[1]*mat[0] + M[5]*mat[1] + M[9]*mat[2] + M[13]*mat[3]; matrix[2] = M[2]*mat[0] + M[6]*mat[1] + M[10]*mat[2] + M[14]*mat[3]; matrix[3] = M[3]*mat[0] + M[7]*mat[1] + M[11]*mat[2] + M[15]*mat[3]; } template <class T> inline void CMatrix4<T>::inverseTranslateVect( vector3df& vect ) const { vect.X = vect.X-M[12]; vect.Y = vect.Y-M[13]; vect.Z = vect.Z-M[14]; } template <class T> inline void CMatrix4<T>::translateVect( vector3df& vect ) const { vect.X = vect.X+M[12]; vect.Y = vect.Y+M[13]; vect.Z = vect.Z+M[14]; } template <class T> inline bool CMatrix4<T>::getInverse(CMatrix4<T>& out) const { /// Calculates the inverse of this Matrix /// The inverse is calculated using Cramers rule. /// If no inverse exists then 'false' is returned. if ( this->isIdentity() ) { out=*this; return true; } const CMatrix4<T> &m = *this; f32 d = (m(0, 0) * m(1, 1) - m(0, 1) * m(1, 0)) * (m(2, 2) * m(3, 3) - m(2, 3) * m(3, 2)) - (m(0, 0) * m(1, 2) - m(0, 2) * m(1, 0)) * (m(2, 1) * m(3, 3) - m(2, 3) * m(3, 1)) + (m(0, 0) * m(1, 3) - m(0, 3) * m(1, 0)) * (m(2, 1) * m(3, 2) - m(2, 2) * m(3, 1)) + (m(0, 1) * m(1, 2) - m(0, 2) * m(1, 1)) * (m(2, 0) * m(3, 3) - m(2, 3) * m(3, 0)) - (m(0, 1) * m(1, 3) - m(0, 3) * m(1, 1)) * (m(2, 0) * m(3, 2) - m(2, 2) * m(3, 0)) + (m(0, 2) * m(1, 3) - m(0, 3) * m(1, 2)) * (m(2, 0) * m(3, 1) - m(2, 1) * m(3, 0)); if( core::iszero ( d ) ) return false; d = core::reciprocal ( d ); out(0, 0) = d * (m(1, 1) * (m(2, 2) * m(3, 3) - m(2, 3) * m(3, 2)) + m(1, 2) * (m(2, 3) * m(3, 1) - m(2, 1) * m(3, 3)) + m(1, 3) * (m(2, 1) * m(3, 2) - m(2, 2) * m(3, 1))); out(0, 1) = d * (m(2, 1) * (m(0, 2) * m(3, 3) - m(0, 3) * m(3, 2)) + m(2, 2) * (m(0, 3) * m(3, 1) - m(0, 1) * m(3, 3)) + m(2, 3) * (m(0, 1) * m(3, 2) - m(0, 2) * m(3, 1))); out(0, 2) = d * (m(3, 1) * (m(0, 2) * m(1, 3) - m(0, 3) * m(1, 2)) + m(3, 2) * (m(0, 3) * m(1, 1) - m(0, 1) * m(1, 3)) + m(3, 3) * (m(0, 1) * m(1, 2) - m(0, 2) * m(1, 1))); out(0, 3) = d * (m(0, 1) * (m(1, 3) * m(2, 2) - m(1, 2) * m(2, 3)) + m(0, 2) * (m(1, 1) * m(2, 3) - m(1, 3) * m(2, 1)) + m(0, 3) * (m(1, 2) * m(2, 1) - m(1, 1) * m(2, 2))); out(1, 0) = d * (m(1, 2) * (m(2, 0) * m(3, 3) - m(2, 3) * m(3, 0)) + m(1, 3) * (m(2, 2) * m(3, 0) - m(2, 0) * m(3, 2)) + m(1, 0) * (m(2, 3) * m(3, 2) - m(2, 2) * m(3, 3))); out(1, 1) = d * (m(2, 2) * (m(0, 0) * m(3, 3) - m(0, 3) * m(3, 0)) + m(2, 3) * (m(0, 2) * m(3, 0) - m(0, 0) * m(3, 2)) + m(2, 0) * (m(0, 3) * m(3, 2) - m(0, 2) * m(3, 3))); out(1, 2) = d * (m(3, 2) * (m(0, 0) * m(1, 3) - m(0, 3) * m(1, 0)) + m(3, 3) * (m(0, 2) * m(1, 0) - m(0, 0) * m(1, 2)) + m(3, 0) * (m(0, 3) * m(1, 2) - m(0, 2) * m(1, 3))); out(1, 3) = d * (m(0, 2) * (m(1, 3) * m(2, 0) - m(1, 0) * m(2, 3)) + m(0, 3) * (m(1, 0) * m(2, 2) - m(1, 2) * m(2, 0)) + m(0, 0) * (m(1, 2) * m(2, 3) - m(1, 3) * m(2, 2))); out(2, 0) = d * (m(1, 3) * (m(2, 0) * m(3, 1) - m(2, 1) * m(3, 0)) + m(1, 0) * (m(2, 1) * m(3, 3) - m(2, 3) * m(3, 1)) + m(1, 1) * (m(2, 3) * m(3, 0) - m(2, 0) * m(3, 3))); out(2, 1) = d * (m(2, 3) * (m(0, 0) * m(3, 1) - m(0, 1) * m(3, 0)) + m(2, 0) * (m(0, 1) * m(3, 3) - m(0, 3) * m(3, 1)) + m(2, 1) * (m(0, 3) * m(3, 0) - m(0, 0) * m(3, 3))); out(2, 2) = d * (m(3, 3) * (m(0, 0) * m(1, 1) - m(0, 1) * m(1, 0)) + m(3, 0) * (m(0, 1) * m(1, 3) - m(0, 3) * m(1, 1)) + m(3, 1) * (m(0, 3) * m(1, 0) - m(0, 0) * m(1, 3))); out(2, 3) = d * (m(0, 3) * (m(1, 1) * m(2, 0) - m(1, 0) * m(2, 1)) + m(0, 0) * (m(1, 3) * m(2, 1) - m(1, 1) * m(2, 3)) + m(0, 1) * (m(1, 0) * m(2, 3) - m(1, 3) * m(2, 0))); out(3, 0) = d * (m(1, 0) * (m(2, 2) * m(3, 1) - m(2, 1) * m(3, 2)) + m(1, 1) * (m(2, 0) * m(3, 2) - m(2, 2) * m(3, 0)) + m(1, 2) * (m(2, 1) * m(3, 0) - m(2, 0) * m(3, 1))); out(3, 1) = d * (m(2, 0) * (m(0, 2) * m(3, 1) - m(0, 1) * m(3, 2)) + m(2, 1) * (m(0, 0) * m(3, 2) - m(0, 2) * m(3, 0)) + m(2, 2) * (m(0, 1) * m(3, 0) - m(0, 0) * m(3, 1))); out(3, 2) = d * (m(3, 0) * (m(0, 2) * m(1, 1) - m(0, 1) * m(1, 2)) + m(3, 1) * (m(0, 0) * m(1, 2) - m(0, 2) * m(1, 0)) + m(3, 2) * (m(0, 1) * m(1, 0) - m(0, 0) * m(1, 1))); out(3, 3) = d * (m(0, 0) * (m(1, 1) * m(2, 2) - m(1, 2) * m(2, 1)) + m(0, 1) * (m(1, 2) * m(2, 0) - m(1, 0) * m(2, 2)) + m(0, 2) * (m(1, 0) * m(2, 1) - m(1, 1) * m(2, 0))); out.definitelyIdentityMatrix = definitelyIdentityMatrix; return true; } //! Inverts a primitive matrix which only contains a translation and a rotation //! \param out: where result matrix is written to. template <class T> inline bool CMatrix4<T>::getInversePrimitive ( CMatrix4<T>& out ) const { out.M[0 ] = M[0]; out.M[1 ] = M[4]; out.M[2 ] = M[8]; out.M[3 ] = 0; out.M[4 ] = M[1]; out.M[5 ] = M[5]; out.M[6 ] = M[9]; out.M[7 ] = 0; out.M[8 ] = M[2]; out.M[9 ] = M[6]; out.M[10] = M[10]; out.M[11] = 0; out.M[12] = (T)-(M[12]*M[0] + M[13]*M[1] + M[14]*M[2]); out.M[13] = (T)-(M[12]*M[4] + M[13]*M[5] + M[14]*M[6]); out.M[14] = (T)-(M[12]*M[8] + M[13]*M[9] + M[14]*M[10]); out.M[15] = 1; out.definitelyIdentityMatrix = definitelyIdentityMatrix; return true; } /*! */ template <class T> inline bool CMatrix4<T>::makeInverse() { if (definitelyIdentityMatrix) return true; CMatrix4<T> temp ( EM4CONST_NOTHING ); if (getInverse(temp)) { *this = temp; return true; } return false; } template <class T> inline CMatrix4<T>& CMatrix4<T>::operator=(const CMatrix4<T> &other) { if (this==&other) return *this; memcpy(M, other.M, 16*sizeof(T)); definitelyIdentityMatrix=other.definitelyIdentityMatrix; return *this; } template <class T> inline CMatrix4<T>& CMatrix4<T>::operator=(const T& scalar) { for (s32 i = 0; i < 16; ++i) M[i]=scalar; definitelyIdentityMatrix=false; return *this; } template <class T> inline bool CMatrix4<T>::operator==(const CMatrix4<T> &other) const { if (definitelyIdentityMatrix && other.definitelyIdentityMatrix) return true; for (s32 i = 0; i < 16; ++i) if (M[i] != other.M[i]) return false; return true; } template <class T> inline bool CMatrix4<T>::operator!=(const CMatrix4<T> &other) const { return !(*this == other); } // Builds a right-handed perspective projection matrix based on a field of view template <class T> inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveFovRH( f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar) { const f64 h = 1.0/tan(fieldOfViewRadians/2.0); const T w = h / aspectRatio; M[0] = w; M[1] = 0; M[2] = 0; M[3] = 0; M[4] = 0; M[5] = (T)h; M[6] = 0; M[7] = 0; M[8] = 0; M[9] = 0; M[10] = (T)(zFar/(zNear-zFar)); // DirectX version // M[10] = (T)(zFar+zNear/(zNear-zFar)); // OpenGL version M[11] = -1; M[12] = 0; M[13] = 0; M[14] = (T)(zNear*zFar/(zNear-zFar)); // DirectX version // M[14] = (T)(2.0f*zNear*zFar/(zNear-zFar)); // OpenGL version M[15] = 0; definitelyIdentityMatrix=false; return *this; } // Builds a left-handed perspective projection matrix based on a field of view template <class T> inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveFovLH( f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar) { const f64 h = 1.0/tan(fieldOfViewRadians/2.0); const T w = (T)(h / aspectRatio); M[0] = w; M[1] = 0; M[2] = 0; M[3] = 0; M[4] = 0; M[5] = (T)h; M[6] = 0; M[7] = 0; M[8] = 0; M[9] = 0; M[10] = (T)(zFar/(zFar-zNear)); M[11] = 1; M[12] = 0; M[13] = 0; M[14] = (T)(-zNear*zFar/(zFar-zNear)); M[15] = 0; definitelyIdentityMatrix=false; return *this; } // Builds a left-handed orthogonal projection matrix. template <class T> inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixOrthoLH( f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) { M[0] = (T)(2/widthOfViewVolume); M[1] = 0; M[2] = 0; M[3] = 0; M[4] = 0; M[5] = (T)(2/heightOfViewVolume); M[6] = 0; M[7] = 0; M[8] = 0; M[9] = 0; M[10] = (T)(1/(zFar-zNear)); M[11] = 0; M[12] = 0; M[13] = 0; M[14] = (T)(zNear/(zNear-zFar)); M[15] = 1; definitelyIdentityMatrix=false; return *this; } // Builds a right-handed orthogonal projection matrix. template <class T> inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixOrthoRH( f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) { M[0] = (T)(2/widthOfViewVolume); M[1] = 0; M[2] = 0; M[3] = 0; M[4] = 0; M[5] = (T)(2/heightOfViewVolume); M[6] = 0; M[7] = 0; M[8] = 0; M[9] = 0; M[10] = (T)(1/(zNear-zFar)); M[11] = 0; M[12] = 0; M[13] = 0; M[14] = (T)(zNear/(zNear-zFar)); M[15] = -1; definitelyIdentityMatrix=false; return *this; } // Builds a right-handed perspective projection matrix. template <class T> inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveRH( f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) { M[0] = (T)(2*zNear/widthOfViewVolume); M[1] = 0; M[2] = 0; M[3] = 0; M[4] = 0; M[5] = (T)(2*zNear/heightOfViewVolume); M[6] = 0; M[7] = 0; M[8] = 0; M[9] = 0; M[10] = (T)(zFar/(zNear-zFar)); M[11] = -1; M[12] = 0; M[13] = 0; M[14] = (T)(zNear*zFar/(zNear-zFar)); M[15] = 0; definitelyIdentityMatrix=false; return *this; } // Builds a left-handed perspective projection matrix. template <class T> inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixPerspectiveLH( f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar) { M[0] = (T)(2*zNear/widthOfViewVolume); M[1] = 0; M[2] = 0; M[3] = 0; M[4] = 0; M[5] = (T)(2*zNear/heightOfViewVolume); M[6] = 0; M[7] = 0; M[8] = 0; M[9] = 0; M[10] = (T)(zFar/(zFar-zNear)); M[11] = 1; M[12] = 0; M[13] = 0; M[14] = (T)(zNear*zFar/(zNear-zFar)); M[15] = 0; definitelyIdentityMatrix=false; return *this; } // Builds a matrix that flattens geometry into a plane. template <class T> inline CMatrix4<T>& CMatrix4<T>::buildShadowMatrix(const core::vector3df& light, core::plane3df plane, f32 point) { plane.Normal.normalize(); const f32 d = plane.Normal.dotProduct(light); M[ 0] = (T)(-plane.Normal.X * light.X + d); M[ 1] = (T)(-plane.Normal.X * light.Y); M[ 2] = (T)(-plane.Normal.X * light.Z); M[ 3] = (T)(-plane.Normal.X * point); M[ 4] = (T)(-plane.Normal.Y * light.X); M[ 5] = (T)(-plane.Normal.Y * light.Y + d); M[ 6] = (T)(-plane.Normal.Y * light.Z); M[ 7] = (T)(-plane.Normal.Y * point); M[ 8] = (T)(-plane.Normal.Z * light.X); M[ 9] = (T)(-plane.Normal.Z * light.Y); M[10] = (T)(-plane.Normal.Z * light.Z + d); M[11] = (T)(-plane.Normal.Z * point); M[12] = (T)(-plane.D * light.X); M[13] = (T)(-plane.D * light.Y); M[14] = (T)(-plane.D * light.Z); M[15] = (T)(-plane.D * point + d); definitelyIdentityMatrix=false; return *this; } // Builds a left-handed look-at matrix. template <class T> inline CMatrix4<T>& CMatrix4<T>::buildCameraLookAtMatrixLH( const vector3df& position, const vector3df& target, const vector3df& upVector) { vector3df zaxis = target - position; zaxis.normalize(); vector3df xaxis = upVector.crossProduct(zaxis); xaxis.normalize(); vector3df yaxis = zaxis.crossProduct(xaxis); M[0] = (T)xaxis.X; M[1] = (T)yaxis.X; M[2] = (T)zaxis.X; M[3] = 0; M[4] = (T)xaxis.Y; M[5] = (T)yaxis.Y; M[6] = (T)zaxis.Y; M[7] = 0; M[8] = (T)xaxis.Z; M[9] = (T)yaxis.Z; M[10] = (T)zaxis.Z; M[11] = 0; M[12] = (T)-xaxis.dotProduct(position); M[13] = (T)-yaxis.dotProduct(position); M[14] = (T)-zaxis.dotProduct(position); M[15] = 1; definitelyIdentityMatrix=false; return *this; } // Builds a right-handed look-at matrix. template <class T> inline CMatrix4<T>& CMatrix4<T>::buildCameraLookAtMatrixRH( const vector3df& position, const vector3df& target, const vector3df& upVector) { vector3df zaxis = position - target; zaxis.normalize(); vector3df xaxis = upVector.crossProduct(zaxis); xaxis.normalize(); vector3df yaxis = zaxis.crossProduct(xaxis); M[0] = (T)xaxis.X; M[1] = (T)yaxis.X; M[2] = (T)zaxis.X; M[3] = 0; M[4] = (T)xaxis.Y; M[5] = (T)yaxis.Y; M[6] = (T)zaxis.Y; M[7] = 0; M[8] = (T)xaxis.Z; M[9] = (T)yaxis.Z; M[10] = (T)zaxis.Z; M[11] = 0; M[12] = (T)-xaxis.dotProduct(position); M[13] = (T)-yaxis.dotProduct(position); M[14] = (T)-zaxis.dotProduct(position); M[15] = 1; definitelyIdentityMatrix=false; return *this; } // creates a new matrix as interpolated matrix from this and the passed one. template <class T> inline CMatrix4<T> CMatrix4<T>::interpolate(const core::CMatrix4<T>& b, f32 time) const { CMatrix4<T> mat ( EM4CONST_NOTHING ); for (u32 i=0; i < 16; i += 4) { mat.M[i+0] = (T)(M[i+0] + ( b.M[i+0] - M[i+0] ) * time); mat.M[i+1] = (T)(M[i+1] + ( b.M[i+1] - M[i+1] ) * time); mat.M[i+2] = (T)(M[i+2] + ( b.M[i+2] - M[i+2] ) * time); mat.M[i+3] = (T)(M[i+3] + ( b.M[i+3] - M[i+3] ) * time); } return mat; } // returns transposed matrix template <class T> inline CMatrix4<T> CMatrix4<T>::getTransposed() const { CMatrix4<T> t ( EM4CONST_NOTHING ); getTransposed ( t ); return t; } // returns transposed matrix template <class T> inline void CMatrix4<T>::getTransposed( CMatrix4<T>& o ) const { o[ 0] = M[ 0]; o[ 1] = M[ 4]; o[ 2] = M[ 8]; o[ 3] = M[12]; o[ 4] = M[ 1]; o[ 5] = M[ 5]; o[ 6] = M[ 9]; o[ 7] = M[13]; o[ 8] = M[ 2]; o[ 9] = M[ 6]; o[10] = M[10]; o[11] = M[14]; o[12] = M[ 3]; o[13] = M[ 7]; o[14] = M[11]; o[15] = M[15]; o.definitelyIdentityMatrix=definitelyIdentityMatrix; } // used to scale <-1,-1><1,1> to viewport template <class T> inline CMatrix4<T>& CMatrix4<T>::buildNDCToDCMatrix( const core::rect<s32>& viewport, f32 zScale) { const f32 scaleX = (viewport.getWidth() - 0.75f ) / 2.0f; const f32 scaleY = -(viewport.getHeight() - 0.75f ) / 2.0f; const f32 dx = -0.5f + ( (viewport.UpperLeftCorner.X + viewport.LowerRightCorner.X ) / 2.0f ); const f32 dy = -0.5f + ( (viewport.UpperLeftCorner.Y + viewport.LowerRightCorner.Y ) / 2.0f ); makeIdentity(); M[12] = (T)dx; M[13] = (T)dy; return setScale(core::vector3d<T>((T)scaleX, (T)scaleY, (T)zScale)); } /*! Generate texture coordinates as linear functions so that: u = Ux*x + Uy*y + Uz*z + Uw v = Vx*x + Vy*y + Vz*z + Vw The matrix M for this case is: Ux Vx 0 0 Uy Vy 0 0 Uz Vz 0 0 Uw Vw 0 0 */ template <class T> inline CMatrix4<T>& CMatrix4<T>::buildTextureTransform( f32 rotateRad, const core::vector2df &rotatecenter, const core::vector2df &translate, const core::vector2df &scale) { const f32 c = cosf(rotateRad); const f32 s = sinf(rotateRad); M[0] = (T)(c * scale.X); M[1] = (T)(s * scale.Y); M[2] = 0; M[3] = 0; M[4] = (T)(-s * scale.X); M[5] = (T)(c * scale.Y); M[6] = 0; M[7] = 0; M[8] = (T)(c * scale.X * rotatecenter.X + -s * rotatecenter.Y + translate.X); M[9] = (T)(s * scale.Y * rotatecenter.X + c * rotatecenter.Y + translate.Y); M[10] = 1; M[11] = 0; M[12] = 0; M[13] = 0; M[14] = 0; M[15] = 1; definitelyIdentityMatrix=false; return *this; } // rotate about z axis, center ( 0.5, 0.5 ) template <class T> inline CMatrix4<T>& CMatrix4<T>::setTextureRotationCenter( f32 rotateRad ) { const f32 c = cosf(rotateRad); const f32 s = sinf(rotateRad); M[0] = (T)c; M[1] = (T)s; M[4] = (T)-s; M[5] = (T)c; M[8] = (T)(0.5f * ( s - c) + 0.5f); M[9] = (T)(-0.5f * ( s + c) + 0.5f); definitelyIdentityMatrix = definitelyIdentityMatrix && (rotateRad==0.0f); return *this; } template <class T> inline CMatrix4<T>& CMatrix4<T>::setTextureTranslate ( f32 x, f32 y ) { M[8] = (T)x; M[9] = (T)y; definitelyIdentityMatrix = definitelyIdentityMatrix && (x==0.0f) && (y==0.0f); return *this; } template <class T> inline CMatrix4<T>& CMatrix4<T>::setTextureTranslateTransposed ( f32 x, f32 y ) { M[2] = (T)x; M[6] = (T)y; definitelyIdentityMatrix = definitelyIdentityMatrix && (x==0.0f) && (y==0.0f) ; return *this; } template <class T> inline CMatrix4<T>& CMatrix4<T>::setTextureScale ( f32 sx, f32 sy ) { M[0] = (T)sx; M[5] = (T)sy; definitelyIdentityMatrix = definitelyIdentityMatrix && (sx==1.0f) && (sy==1.0f); return *this; } template <class T> inline CMatrix4<T>& CMatrix4<T>::setTextureScaleCenter( f32 sx, f32 sy ) { M[0] = (T)sx; M[5] = (T)sy; M[8] = (T)(0.5f - 0.5f * sx); M[9] = (T)(0.5f - 0.5f * sy); definitelyIdentityMatrix = definitelyIdentityMatrix && (sx==1.0f) && (sy==1.0f); return *this; } // sets all matrix data members at once template <class T> inline CMatrix4<T>& CMatrix4<T>::setM(const T* data) { memcpy(M,data, 16*sizeof(T)); definitelyIdentityMatrix = false; return *this; } // sets if the matrix is definitely identity matrix template <class T> inline void CMatrix4<T>::setDefinitelyIdentityMatrix( bool isDefinitelyIdentityMatrix) { definitelyIdentityMatrix = isDefinitelyIdentityMatrix; } // gets if the matrix is definitely identity matrix template <class T> inline bool CMatrix4<T>::getDefinitelyIdentityMatrix() const { return definitelyIdentityMatrix; } // Multiply by scalar. template <class T> inline CMatrix4<T> operator*(const T scalar, const CMatrix4<T>& mat) { return mat*scalar; } //! Typedef for f32 matrix typedef CMatrix4<f32> matrix4; //! global const identity matrix const matrix4 IdentityMatrix(matrix4::EM4CONST_IDENTITY); } // end namespace core } // end namespace irr #endif
[ [ [ 1, 1750 ] ] ]
c54dc651fdbef549a8edaa283f2d04b555ccd92c
3e1e78cd64328f947fdd721213f75b47a810d68c
/windows/src/CrashHandler.cpp
d18fa73658e052b7e76d3d3d6c6883a71256d996
[]
no_license
phuonglelephuong/dynamicipupdate
daeb10b891a06da80d345ced677cd96bdaa62d8f
58eb721427f132900d81ee95acf3cb09ea133f59
refs/heads/master
2021-01-15T20:53:17.046848
2011-12-06T18:41:32
2011-12-06T18:45:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,748
cpp
#include "stdafx.h" #include <dbghelp.h> #include "CrashHandler.h" #include "MiscUtil.h" #include "StrUtil.h" typedef BOOL WINAPI MiniDumpWriteProc( HANDLE hProcess, DWORD ProcessId, HANDLE hFile, LONG DumpType, PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, void * UserStreamParam, void * CallbackParam ); typedef struct { DWORD threadId; EXCEPTION_POINTERS * exceptionInfo; } DumpThreadInfo; static TCHAR g_crashDumpPath[MAX_PATH]; static TCHAR g_exePath[MAX_PATH]; static MiniDumpWriteProc *g_minidDumpWriteProc = NULL; static bool InitDbgHelpDll() { #ifdef DEBUG static bool wasHere = false; assert(!wasHere); wasHere = true; #endif HMODULE hdll = LoadLibraryA("DBGHELP.DLL"); if (NULL == hdll) return false; g_minidDumpWriteProc = (MiniDumpWriteProc*)GetProcAddress(hdll, "MiniDumpWriteDump"); return (g_minidDumpWriteProc != NULL); } static void GenPaths(const TCHAR *crashDumpDir, const TCHAR *crashDumpBasename) { _tcscpy_s(g_crashDumpPath, dimof(g_crashDumpPath), crashDumpDir); if (LastTChar(g_crashDumpPath) != PATH_SEP_CHAR) _tcscat_s(g_crashDumpPath, dimof(g_crashDumpPath), PATH_SEP_STR); _tcscat_s(g_crashDumpPath, dimof(g_crashDumpPath), crashDumpBasename); _tcscat_s(g_crashDumpPath, dimof(g_crashDumpPath), _T(".dmp")); GetModuleFileName(NULL, g_exePath, dimof(g_exePath)); } static BOOL CALLBACK OpenDnsMiniDumpCallback(void* /*param*/, MINIDUMP_CALLBACK_INPUT* input, MINIDUMP_CALLBACK_OUTPUT* output) { if (!input || !output) return FALSE; ULONG ct = input->CallbackType; if (ModuleCallback == ct) { if (!(output->ModuleWriteFlags & ModuleReferencedByMemory)) output->ModuleWriteFlags &= ~ModuleWriteModule; return TRUE; } else if ( (IncludeModuleCallback == ct) || (IncludeThreadCallback == ct) || (ThreadCallback == ct) || (ThreadExCallback == ct)) { return TRUE; } return FALSE; } unsigned WINAPI CrushDumpThread(void* data) { HANDLE dumpFile = INVALID_HANDLE_VALUE; DumpThreadInfo *dti = (DumpThreadInfo*)data; if (!dti) return 0; dumpFile = CreateFile(g_crashDumpPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH, NULL); if (INVALID_HANDLE_VALUE == dumpFile) return 0; MINIDUMP_CALLBACK_INFORMATION mci; mci.CallbackRoutine = (MINIDUMP_CALLBACK_ROUTINE)OpenDnsMiniDumpCallback; MINIDUMP_EXCEPTION_INFORMATION excInfo; excInfo.ThreadId = dti->threadId; excInfo.ExceptionPointers = dti->exceptionInfo; excInfo.ClientPointers = FALSE; MINIDUMP_TYPE type = (MINIDUMP_TYPE)(MiniDumpNormal | MiniDumpWithIndirectlyReferencedMemory | MiniDumpScanMemory); //type |= MiniDumpWithDataSegs|MiniDumpWithHandleData|MiniDumpWithPrivateReadWriteMemory; BOOL ok = g_minidDumpWriteProc(GetCurrentProcess(), GetCurrentProcessId(), dumpFile, type, &excInfo, NULL, &mci); ///BOOL ok = minidDumpWriteProc(GetCurrentProcess(), GetCurrentProcessId(), dumpFile, type, &excInfo, NULL, NULL); UNUSED_VAR(ok); if (dumpFile != INVALID_HANDLE_VALUE) CloseHandle(dumpFile); ExecWithParams(g_exePath, CMD_ARG_SEND_CRASHDUMP, true /* hidden */); return 0; } static LONG WINAPI OpenDnsCrashHandler(EXCEPTION_POINTERS *exceptionInfo) { static bool wasHere = false; if (wasHere) return EXCEPTION_CONTINUE_SEARCH; if (exceptionInfo && (EXCEPTION_BREAKPOINT == exceptionInfo->ExceptionRecord->ExceptionCode)) return EXCEPTION_CONTINUE_SEARCH; wasHere = true; // we either forgot to call InitDbgHelpDll() or it failed to obtain address of // MiniDumpWriteDump(), so nothing we can do if (NULL == g_minidDumpWriteProc) return EXCEPTION_CONTINUE_SEARCH; // per msdn (which is backed by my experience), MiniDumpWriteDump() doesn't // write callstack for the calling thread correctly. We use msdn-recommended // work-around of spinning a thread to do the writing DumpThreadInfo dti; dti.exceptionInfo = exceptionInfo; dti.threadId = ::GetCurrentThreadId(); unsigned tid; HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, CrushDumpThread, &dti, 0, &tid) ; if ((HANDLE)-1 != hThread ) { WaitForSingleObject(hThread, INFINITE); CloseHandle(hThread); } return EXCEPTION_CONTINUE_SEARCH; } void InstallCrashHandler(const TCHAR *crashDumpDir, const TCHAR *crashDumpBaseName) { // do as much work as possible here (as opposed to in crash handler) // the downside is that startup time might suffer due to loading of dbghelp.dll bool ok = InitDbgHelpDll(); if (!ok) return; GenPaths(crashDumpDir, crashDumpBaseName); SetUnhandledExceptionFilter(OpenDnsCrashHandler); }
[ [ [ 1, 150 ] ] ]
de930f40a158391b3520e0b6d6d2693ed14bcb8b
41371839eaa16ada179d580f7b2c1878600b718e
/UVa/Volume C/10010.cpp
87b7a4898f8a2bbf4ad011c05cc98d983d35f18e
[]
no_license
marinvhs/SMAS
5481aecaaea859d123077417c9ee9f90e36cc721
2241dc612a653a885cf9c1565d3ca2010a6201b0
refs/heads/master
2021-01-22T16:31:03.431389
2009-10-01T02:33:01
2009-10-01T02:33:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,672
cpp
///////////////////////////////// // 10010 - Where's Waldorf? ///////////////////////////////// #include<cstdio> #include<cstring> char board[52][52],i,j,m,n,word[250],words; int len, found, cases; void recsearch(int xo,int yo, int px, int py, int ax,int ay, int k){ if(k == len) { printf("%d %d\n",xo,yo,word); found = true; return; } if(board[xo+ax][yo+ay] != word[k]) return; recsearch(xo,yo,px,py,ax+px,ay+py,k+1); } void search(void){ char x,y; for(x = 1; x <= m; x++) for(y = 1; y <= n; y++) if(board[x][y] == word[0]){ recsearch(x,y,0,1,0,1,1); // right if(!found) recsearch(x,y,1,0,1,0,1); // down if(!found) recsearch(x,y,0,-1,0,-1,1);// left if(!found) recsearch(x,y,-1,0,-1,0,1);// up if(!found) recsearch(x,y,1,1,1,1,1); // right down if(!found) recsearch(x,y,-1,1,-1,1,1); // right up if(!found) recsearch(x,y,1,-1,1,-1,1); // left down if(!found) recsearch(x,y,-1,-1,-1,-1,1); // left up if(found) return; } } int main(void){ scanf("%d\n",&cases); while(cases--){ scanf("%d %d\n",&m,&n); for(i = 0; i < m+2; i++) board[i][0] = '-'; for(j = 0; j < n+2; j++) board[0][j] = board[m+1][j] = '-'; for(i = 1; i <= m; i++) gets(board[i]+1); for(i = 0; i < m+2; i++) board[i][n+1] = '-'; for(i = 1; i <= m; i++) for(j = 1; j <= n; j++) if(board[i][j] > 64 && board[i][j] < 91) board[i][j] +=32; scanf("%d\n",&words); while(words--){ gets(word); found = false; len = strlen(word); for(j = 0; word[j] != '\0'; j++) if(word[j] > 64 && word[j] < 91) word[j] +=32; search(); } if(cases) putchar('\n'); } return 0; }
[ [ [ 1, 55 ] ] ]
6fea51fe61a8df7d1de954a8bfa30d7fb56b7e2f
478570cde911b8e8e39046de62d3b5966b850384
/apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.2/bctestmisc32/src/bctestlistdatacase.cpp
13f1e5cc66183ff57adfda374e25b42f6b1b5e3a
[]
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
10,120
cpp
/* * Copyright (c) 2006 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: test case * */ #include <w32std.h> #include <coecntrl.h> #include <aknlists.h> #include <barsread.h> #include <eikclbd.h> #include <bctestmisc32.rsg> #include "bctestlistdatacase.h" #include "bctestmisc32container.h" #include "bctestmisc32.hrh" #include "bctestmisc32appui.h" _LIT( KFormatListBoxCreate, "Create CAknDoubleStyle2ListBox ok" ); _LIT( KColumnListBoxCreate, "Create CAknDoubleStyle2ListBox ok" ); _LIT( KFormateDataTest1, "CFormattedCellListBoxData long text clipped"); _LIT( KFormateDataTest2, "CFormattedCellListBoxData short text not clipped"); _LIT( KColumnDataTest1, "CColumnListBoxData long text clipped"); _LIT( KColumnDataTest2, "CColumnListBoxData shot text not clipped"); // ======== MEMBER FUNCTIONS ======== // --------------------------------------------------------------------------- // Symbian 2nd static Constructor // --------------------------------------------------------------------------- // CBCTestListDataCase* CBCTestListDataCase::NewL( CBCTestmisc32Container* aContainer ) { CBCTestListDataCase* self = new( ELeave ) CBCTestListDataCase( aContainer ); CleanupStack::PushL( self ); self->ConstructL(); CleanupStack::Pop( self ); return self; } // --------------------------------------------------------------------------- // C++ default constructor // --------------------------------------------------------------------------- // CBCTestListDataCase::CBCTestListDataCase( CBCTestmisc32Container* aContainer ) : iContainer( aContainer ) { } // --------------------------------------------------------------------------- // Destructor // --------------------------------------------------------------------------- // CBCTestListDataCase::~CBCTestListDataCase() { } // --------------------------------------------------------------------------- // Symbian 2nd Constructor // --------------------------------------------------------------------------- // void CBCTestListDataCase::ConstructL() { BuildScriptL(); iEikEnv = CEikonEnv::Static(); } // --------------------------------------------------------------------------- // CBCTestListDataCase::BuildScriptL // --------------------------------------------------------------------------- // void CBCTestListDataCase::BuildScriptL() { // Add script as your need. for ( TInt i=0; i <= EBCTestCmdOutline5 - EBCTestCmdOutline2; i++ ) { AddTestL( LeftCBA, REP( Down, 1 ), KeyOK, TEND ); AddTestL( REP( Down, i ), KeyOK, TEND ); } } // --------------------------------------------------------------------------- // CBCTestListDataCase::RunL // --------------------------------------------------------------------------- // void CBCTestListDataCase::RunL( TInt aCmd ) { if ( aCmd < EBCTestCmdOutline2 || aCmd > EBCTestCmdOutline5 ) { return; } // Call release before prepare to let container has time to draw the // control created in PrepareCaseL. ReleaseCaseL(); PrepareCaseL( aCmd ); switch ( aCmd ) { case EBCTestCmdOutline2: TestFmtLongTextWasClippedL(); break; case EBCTestCmdOutline3: TestFmtShortTextWasClippedL(); break; case EBCTestCmdOutline4: TestColLongTextWasClippedL(); break; case EBCTestCmdOutline5: TestColShortTextWasClippedL(); break; default: break; } } // -------------------------------------------------------------------------- // CBCTestListDataCase::SetListBoxFromResourceL // Sets listbox from resource using ConstructFromResourceL() of // CEikColumnListBox class. // -------------------------------------------------------------------------- // void CBCTestListDataCase::SetListBoxFromResourceL( CEikColumnListBox* aListBox, const TInt aResourceId ) { if ( aListBox && aResourceId ) { aListBox->SetContainerWindowL( *iContainer ); TResourceReader reader; iEikEnv->CreateResourceReaderLC( reader, aResourceId ); aListBox->ConstructFromResourceL( reader ); CleanupStack::PopAndDestroy(); // resource stuffs. } } // -------------------------------------------------------------------------- // CBCTestListDataCase::SetListBoxFromResourceL // Sets listbox from resource using ConstructFromResourceL() of // CEikFormattedCellListBox class. // -------------------------------------------------------------------------- // void CBCTestListDataCase::SetListBoxFromResourceL( CEikFormattedCellListBox* aListBox, const TInt aResourceId ) { if ( aListBox && aResourceId ) { aListBox->SetContainerWindowL( *iContainer ); TResourceReader reader; iEikEnv->CreateResourceReaderLC( reader, aResourceId ); aListBox->ConstructFromResourceL( reader ); CleanupStack::PopAndDestroy(); // resource stuffs. } } // --------------------------------------------------------------------------- // CBCTestListDataCase::PrepareCaseL // --------------------------------------------------------------------------- // void CBCTestListDataCase::PrepareCaseL( TInt aCmd ) { switch ( aCmd ) { case EBCTestCmdOutline1: // Here is a simple demo. You should create your control // instead of this. iControl = new( ELeave ) CCoeControl(); iControl->SetContainerWindowL( *iContainer ); iControl->MakeVisible( ETrue ); // Pass the owner of iControl to iContainer. iContainer->SetControl( iControl ); break; case EBCTestCmdOutline2: iFormattedListBox = new( ELeave ) CAknDoubleStyleListBox(); AssertNotNullL( iFormattedListBox, KFormatListBoxCreate ); SetListBoxFromResourceL( iFormattedListBox, R_BCTESTMISC32_SINGLE_LONGITEM ); iContainer->SetControl( iFormattedListBox ); break; case EBCTestCmdOutline3: iFormattedListBox = new( ELeave ) CAknDoubleStyleListBox(); AssertNotNullL( iFormattedListBox, KFormatListBoxCreate ); SetListBoxFromResourceL( iFormattedListBox, R_BCTESTMISC32_SINGLE_SHORTITEM ); iContainer->SetControl( iFormattedListBox ); break; case EBCTestCmdOutline4: iColumnListBox = new( ELeave ) CAknSingleStyleListBox(); AssertNotNullL( iColumnListBox, KColumnListBoxCreate ); SetListBoxFromResourceL( iColumnListBox, R_BCTESTMISC32_SINGLE_LONGITEM ); iContainer->SetControl( iColumnListBox ); break; case EBCTestCmdOutline5: iColumnListBox = new( ELeave ) CAknSingleStyleListBox(); AssertNotNullL( iColumnListBox, KColumnListBoxCreate ); SetListBoxFromResourceL( iColumnListBox, R_BCTESTMISC32_SINGLE_SHORTITEM ); iContainer->SetControl( iColumnListBox ); break; default: break; } } // --------------------------------------------------------------------------- // CBCTestListDataCase::ReleaseCaseL // --------------------------------------------------------------------------- // void CBCTestListDataCase::ReleaseCaseL() { // let container delete the component control. iContainer->ResetControl(); iFormattedListBox = NULL; iColumnListBox = NULL; } // --------------------------------------------------------------------------- // CBCTestListDataCase::TestFmtLongTextWasClippedL // --------------------------------------------------------------------------- // void CBCTestListDataCase::TestFmtLongTextWasClippedL() { CFormattedCellListBoxData* data = iFormattedListBox->ItemDrawer()->FormattedCellData(); data->CurrentItemTextWasClipped(); AssertTrueL( ETrue, KFormateDataTest1 ); } // --------------------------------------------------------------------------- // CBCTestListDataCase::TestFmtShortTextWasClippedL // --------------------------------------------------------------------------- // void CBCTestListDataCase::TestFmtShortTextWasClippedL() { CFormattedCellListBoxData* data = iFormattedListBox->ItemDrawer()->FormattedCellData(); AssertTrueL( (data->CurrentItemTextWasClipped() == 0), KFormateDataTest2 ); } // --------------------------------------------------------------------------- // CBCTestListDataCase::TestColLongTextWasClippedL // --------------------------------------------------------------------------- // void CBCTestListDataCase::TestColLongTextWasClippedL() { CColumnListBoxData* data = iColumnListBox->ItemDrawer()->ColumnData(); data->CurrentItemTextWasClipped(); AssertTrueL( ETrue, KColumnDataTest1 ); } // --------------------------------------------------------------------------- // CBCTestListDataCase::TestColShortTextWasClippedL // --------------------------------------------------------------------------- // void CBCTestListDataCase::TestColShortTextWasClippedL() { CColumnListBoxData* data = iColumnListBox->ItemDrawer()->ColumnData(); AssertTrueL( (data->CurrentItemTextWasClipped() == 0), KColumnDataTest2 ); }
[ "none@none" ]
[ [ [ 1, 281 ] ] ]
877713303e3dd166d7e22720286229194d6a552a
bfa5154af92c808bd268fc95fe1db53ed5315466
/Implementation/test.cpp
bae74d2a714a26fa6353ce4c1ca7a1f36336a49e
[]
no_license
joshgartner/csce315-502-database
427fe7b5453f8bc02d3e02afa9d3eb149c9243cb
7d3a46766634014f0bb5b57b29e94a0e39d6971e
refs/heads/master
2021-01-19T14:10:52.097372
2010-02-22T04:56:04
2010-02-22T04:56:04
32,806,557
0
0
null
null
null
null
UTF-8
C++
false
false
2,654
cpp
#include <iostream> #include <string> #include <vector> #include "relation.hpp" #include "database.hpp" #include "parser.hpp" using namespace std; // Make some test strings: string create1 = "CREATE TABLE table1 (name VARCHAR(20), age VARCHAR(20), letter VARCHAR(20)) PRIMARY KEY (letter);"; string create2 = "CREATE TABLE table2 (age VARCHAR(20), name VARCHAR(20), color VARCHAR(20)) PRIMARY KEY (color);"; string insert1 = "INSERT INTO table1 VALUES FROM (\"Joe\", 12, \"A\");"; string insert2 = "INSERT INTO table1 VALUES FROM (\"Sally\", 4, \"B\");"; string insert3 = "INSERT INTO table1 VALUES FROM (\"Sally\", 13, \"C\");"; string insert4 = "INSERT INTO table1 VALUES FROM (\"Bob\", 4, \"D\");"; string insert5 = "INSERT INTO table1 VALUES FROM (\"Bill\", 44, \"E\");"; string insert6 = "INSERT INTO table1 VALUES FROM (\"Rob\", 21, \"F\");"; string insert7 = "INSERT INTO table2 VALUES FROM (13, \"Sally\", \"Red\");"; string insert8 = "INSERT INTO table2 VALUES FROM (44, \"Man\", \"Purple\");"; string insert9 = "INSERT INTO table2 VALUES FROM (12, \"Joe\", \"Blue\");"; string insert10 = "INSERT INTO table2 VALUES FROM (7, \"Bob\", \"Fushia\");"; string insert11 = "INSERT INTO table2 VALUES FROM (12, \"Joe\", \"Green\");"; string join1 = "table3 <- table1 JOIN table2;"; string complex = "test <- select (name == \"Sally\" && age < 20) (table1 JOIN table2);"; int main(){ Database dbms; vector<string> test_str; // TEST: Create Test String vector: test_str.push_back(create1); test_str.push_back(create2); test_str.push_back(insert1); test_str.push_back(insert2); test_str.push_back(insert3); test_str.push_back(insert4); test_str.push_back(insert5); test_str.push_back(insert6); test_str.push_back(insert7); test_str.push_back(insert8); test_str.push_back(insert9); test_str.push_back(insert10); test_str.push_back(insert11); test_str.push_back(join1); test_str.push_back(complex); cout << "\n-- Database Test Suite\n"; cout << "Enter database command or: \n"; cout << " <t> to run string tests\n"; cout << " <q> to quit\n"; cout << "> "; string table1 = "table1"; string table2 = "table2"; dbms.load(table1); dbms.load(table2); string str; while(getline(cin, str)){ if(str.empty() || str[0] == 'q' || str[0] == 'Q') break; try{ if(str[0] == 't'){ for(int i = 0; i < (int) test_str.size(); i++){ cout << "\n\nTesting: " << test_str[i] << "\n"; dbms.execute(test_str[i]); } } }catch(exception& e){ cout << e.what(); } cout << "\n> "; } return 0; }
[ "darren.j.white@b1f88d2a-1737-11df-85d1-b5325210c051" ]
[ [ [ 1, 82 ] ] ]
209c2c018b113e4a7b02fb38df164893763e6fb5
0c5fd443401312fafae18ea6a9d17bac9ee61474
/code/engine/Base/Pause.h
f721dca75e6ed7a0a6746e1c9f18cf7ea3b40e76
[]
no_license
nurF/Brute-Force-Game-Engine
fcfebc997d6ab487508a5706b849e9d7bc66792d
b930472429ec6d6f691230e36076cd2c868d853d
refs/heads/master
2021-01-18T09:29:44.038036
2011-12-02T17:31:59
2011-12-02T17:31:59
2,877,061
1
0
null
null
null
null
UTF-8
C++
false
false
1,381
h
/* ___ _________ ____ __ / _ )/ __/ ___/____/ __/___ ___ _/_/___ ___ / _ / _// (_ //___/ _/ / _ | _ `/ // _ | -_) /____/_/ \___/ /___//_//_|_, /_//_//_|__/ /___/ This file is part of the Brute-Force Game Engine, BFG-Engine For the latest info, see http://www.brute-force-games.com Copyright (c) 2011 Brute-Force Games GbR The BFG-Engine is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. The BFG-Engine 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 the BFG-Engine. If not, see <http://www.gnu.org/licenses/>. */ #ifndef BFG_BASE_PAUSE_H_ #define BFG_BASE_PAUSE_H_ #include <iostream> namespace BFG { namespace Base { void pause() { #ifdef WIN32 system("PAUSE"); #else std::cout << "Press 'Enter' to resume."; std::cin.get(); #endif } } // namespace Base } // namespace BFG #endif
[ [ [ 1, 48 ] ] ]
f65ac613bbfacfbc71e5ec47cd105b65f15820e7
9c62af23e0a1faea5aaa8dd328ba1d82688823a5
/rl/branches/persistence2/engine/ai/include/SteeringVehicle.h
fe95282ca92c82f401ffb0b99b63cc4972b72bec
[ "ClArtistic", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
jacmoe/dsa-hl-svn
55b05b6f28b0b8b216eac7b0f9eedf650d116f85
97798e1f54df9d5785fb206c7165cd011c611560
refs/heads/master
2021-04-22T12:07:43.389214
2009-11-27T22:01:03
2009-11-27T22:01:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,298
h
/* This source file is part of Rastullahs Lockenpracht. * Copyright(C) 2003-2008 Team Pantheon. http://www.team-pantheon.de * * This program is free software; you can redistribute it and/or modify * it under the terms of the Clarified Artistic License. * * 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 * Clarified Artistic License for more details. * * You should have received a copy of the Clarified Artistic License * along with this program; if not you can get it here * http://www.jpaulmorrison.com/fbp/artistic2.htm. */ #ifndef __RlAI_SteeringVehicle_H__ #define __RlAI_SteeringVehicle_H__ #include "AiPrerequisites.h" #include "AgentManager.h" #include "DebugVisualisable.h" #include "LineSetPrimitive.h" #include <OpenSteer/SteerLibrary.h> #include "SimpleVehicle.h" #include "MessagePump.h" namespace rl { /** * SimpleVehicle_1 adds concrete LocalSpace methods to AbstractVehicle. * OpenSteer::LocalSpaceMixin contains functionality to convert from one * coordinate system to an other. */ typedef OpenSteer::LocalSpaceMixin<SimpleVehicle> SimpleVehicle_1; /** * SimpleVehicle_2 adds concrete steering methods to SimpleVehicle_1. * OpenSteer::SteerLibraryMixin adds the "steering library" * functionality to a given base class. SteerLibraryMixin assumes its base * class supports the AbstractVehicle interface. * The "steering library" itself presents methods to calculate movements * according to behaviours. */ typedef OpenSteer::SteerLibraryMixin<SimpleVehicle_1> SimpleVehicle_2; class Actor; class Agent; class CreatureController; /** * Realises steering for NPCs * Provides different steering behaviours through methods that calculate * steering forces */ class _RlAiExport SteeringVehicle : public SimpleVehicle_2, public DebugVisualisable { public: /** Constructor. * @param parent Agent owning this vehicle */ SteeringVehicle(Creature* creature); /** explicit virtual destructor. */ virtual ~SteeringVehicle(void); /** * Add a force to the current force of the vehicle * @param force value as force vector */ void addForce(const Ogre::Vector3& force); /** * Random walking behaviour * The steering value is purely tangential(has no Forward component) * and uses the x-axis only at the moment(2D wandering) * @param elapsedTime The time step value allows wander rate to be consistent when frame times vary * @return a steering force for wandering behavior. */ Ogre::Vector3 calcWander(const float elapsedTime); /** * Causes the vehicle to turn toward a target and move to it. * If this behavior is used alone and unconditionally, * it will cause the vehicle to pass through the target * then turn around for another pass. * @param target target position to seek for * @return a steering force to seek the given target location. */ Ogre::Vector3 calcSeek(const Ogre::Vector3& target); /** * Causes the vehicle to turn away from a target and move away from it. * @param target target position to flee for * @return a steering force to flee from the given target location. */ Ogre::Vector3 calcFlee(const Ogre::Vector3& target); /** * Causes the vehicle to turn to a target and move to it. * @param agent to persue * @return a steering force for persuing the given agent */ Ogre::Vector3 calcPursuit(Agent* agent); /** * Causes the vehicle to turn away from obstacles in space. * The vehicle will consider all close-by obstacles automatically * @param minTimeToCollision distance to the obstacle in time at the vehicle's current velocity * @return a steering force to avoid obstacles. */ Ogre::Vector3 calcAvoidObstacles(const float minTimeToCollision); /** * Causes the vehicle to turn away from neighbor vehicles. * The vehicle will consider all close-by nieghbours automatically * @param minTimeToCollision distance to the neighbour in time at the vehicle's current velocity * @return a steering force to avoid neighbours. */ Ogre::Vector3 calcAvoidNeighbors(const float minTimeToCollision); /** * @returns a steering force to maintain a given target speed. */ Ogre::Vector3 calcSteerTargetSpeed(const float targetSpeed); /** tests if the specified Agent is within the threshold. * @param agent Agent to test against * @param threshold specifies maximum distance */ bool isAhead(Agent* agent, const float threshold); /** tests if the specified position is within the threshold. * @param agent Agent to test against * @param threshold specifies maximum distance */ bool isAhead(const Vector3& position, const float threshold); /** tests if collision will happen within specified timeframe * @param minTimeToCollision minimum time to next collision */ bool needAvoidance(const float minTimeToCollision); /* TODO: calcFollowPath calcStayOnPath calcAvoidObstacles(Obstacle&) Vector3 calcEvasion(AbstractVehicle&); Vector3 calcPursuit(AbstractVehicle&); Vector3 calcSeperation(AVGroup&); Vector3 calcAlignment(AVGroup&); Vector3 calcCohesion(AVGroup&); */ /** calculates euklidian distance between two vectors * @param vec1 first vector * @param vec2 second vector */ float calcDistance(const Ogre::Vector3& vec1, const Ogre::Vector3& vec2); /** returns the position of ? */ //Ogre::Vector3 getPosition(); // inherited from AbstractVehicle /** * update the steering of the vehicle */ virtual void update(const float currentTime, const float elapsedTime); /** * predict position of this vehicle at some time in the future *(assumes velocity remains constant) */ //Ogre::Vector3 predictFuturePosition(const float predictionTime) const; void resetLocalSpace(); /** get mass * @returns mass of physical object */ //float getMass() const; /** does not set mass but is necessary for AbstractVehicle. * throws an exception on invocation. * @param m mass */ //float setMass(float m); /** retrieve velocity of vehicle * @returns velocity of the vehicle */ //Ogre::Vector3 getVelocity() const {return mCurrentVelocity;} /** retrieves speed of vehicle. * may be faster than taking mag of velocity */ //float getSpeed() const; /** sets speed of vehicle. * may be faster than taking mag of velocity * @param s new speed to set * @returns float new speed set. */ //float setSpeed(float s); /** radius for size of bounding sphere. * used for obstacle avoidance, etc. * TODO: this should be handled by size of NewtonBody * @returns float the radius */ //float getRadius() const; /** sets radius for size of bounding sphere. * used for obstacle avoidance, etc. * TODO: this should be handled by size of NewtonBody * @returns float the radius */ //float setRadius(float m); /** height for size of bounding sphere. * used for obstacle avoidance, etc. * TODO: this should be handled by height of NewtonBody * @returns float the height */ //float getHeight() const; /** height for size of bounding sphere. * used for obstacle avoidance, etc. * TODO: this should be handled by height of NewtonBody * @returns float the height */ //float setHeight(float h); /** retrieves maximum force. * @returns float containing maximum force. */ //float getMaxForce() const; /** sets maximum force. * TODO: should not be set here, throw excpetion or so * @returns float containing maximum force set. */ //float setMaxForce(float mf); /** retrieves maximum speed. * @returns float containing maximum speed */ //float getMaxSpeed() const; /** retrieves maximum speed. * TODO: should not be set here, throw excpetion or so * @returns float containing maximum speed */ //float setMaxSpeed(float ms); /** * adjust the steering force passed to applySteeringForce. * allows a specific vehicle class to redefine this adjustment. * default is to disallow backward-facing steering at low speed. */ virtual Ogre::Vector3 adjustRawSteeringForce(const Ogre::Vector3& force); /** retrieve the controlled Actor * @returns Actor that is controlled by the SteeringVehicle */ const Actor* getActor() const; // derived from debugvisualisable virtual DebugVisualisableFlag getFlag() const; virtual void updatePrimitive(); protected: /** initializes */ void initialize(); /** retrieves the neighbours of this SteeringVehicle */ OpenSteer::AVGroup getNeighbors(const float maxRadius) const; /** retrieves the obstacles */ const OpenSteer::ObstacleGroup& getObstacles() const; /** the maximum steering force this vehicle can apply. * steering force is clipped to this magnitude. */ float _maxForce; /** the maximum speed this vehicle is allowed to move. * velocity is clipped to this magnitude. */ float _maxSpeed; //! speed of the vehicle Ogre::Real mSpeed; //! current force Ogre::Vector3 mCurrentForce; //! current velocity Ogre::Vector3 mCurrentVelocity; //! direction vector Ogre::Vector3 mForwardVector; //! the yaw angle in radians //Ogre::Radian mYaw; CeGuiString mCreatureId; bool refetchCreature(); CreatureController* mController; // derived from debugvisualisable virtual void doCreatePrimitive(); Ogre::Vector3 mDebugSteer; Ogre::Vector3 mDebugWander; Ogre::Vector3 mDebugAvoidObstacles; private: MessagePump::ScopedConnection mMessageType_GameObjectsLoaded_Handler; }; } #endif
[ "timm@4c79e8ff-cfd4-0310-af45-a38c79f83013" ]
[ [ [ 1, 317 ] ] ]
413e45b673fd79f6e664900b1c2a0d7a348cb8ae
bf0684ce69d618b1bbad5e2b4d8c8d4c79c1048b
/boot/log/include/LogCategory.h
2cc304460dffb66e82ae75ae6de81f1317f2e283
[ "BSD-3-Clause" ]
permissive
cider-load-test/devon
485829d3ad8c980eeeb352a594571e4ff69711aa
5b11265e5eae3db7bfaeb49543a2a6293bd15557
refs/heads/master
2021-12-02T07:24:11.497854
2010-08-07T09:16:40
2010-08-07T09:16:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,021
h
#ifndef DEVON_LOGCATEGORY_H #define DEVON_LOGCATEGORY_H namespace Devon { // ************************************************************************************************ class LogCategory { public: LogCategory(const std::string& name, bool disabled=false) : mName(name), mDisabled(disabled) { } const std::string& GetName() const { return mName; } bool GetDisabled() const { return mDisabled; } void SetDisabled(bool disabled) { mDisabled = disabled; } protected: std::string mName; bool mDisabled; }; // ************************************************************************************************ extern LogCategory LogCategoryDefault; extern LogCategory LogCategoryAssertion; extern LogCategory LogCategoryException; extern LogCategory LogCategoryLifetime; // ************************************************************************************************ } // namespace Devon #endif // DEVON_LOGCATEGORY_H
[ [ [ 1, 38 ] ] ]
7656b674b49562dd78095a760084f9e144c7d94c
150926210848ebc2773f4683180b2e53e67232f1
/UFOHunt/ImageConverter/Stdafx.cpp
728bd3387e2e65a300f806fc4587da3ac123872f
[]
no_license
wkx11/kuradevsandbox
429dccabf6b07847ed33ea07bb77a93d7c8004f0
21f09987fd7e22ba6bf2c4929ca4cbf872827b36
refs/heads/master
2021-01-02T09:33:52.967804
2010-12-12T04:06:19
2010-12-12T04:06:19
37,631,953
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
269
cpp
// stdafx.cpp : 標準インクルード ImageConverter.pch のみを // 含むソース ファイルは、プリコンパイル済みヘッダーになります。 // stdafx.obj にはプリコンパイル済み型情報が含まれます。 #include "stdafx.h"
[ "sasraing@cdde4f24-bdbc-632a-de5c-276029d4cb88" ]
[ [ [ 1, 5 ] ] ]
383526cd97bc4855b205694b74af85f5e48d3b23
60b362ba672a29bedf3d44abf11138dd71742c5d
/ex1-ilia/ex1/testPaint.cpp
8fd5f32e5b8bc69f216cd7333e48a2924ba94c13
[]
no_license
AndreyShamis/oop1
9e04882ab6969cc542e99422b84114157d4b20f3
861da0e7a70eba21e4b7ee39e355c21a864ce8b1
refs/heads/master
2016-09-06T14:15:47.867525
2011-03-16T22:20:04
2011-03-16T22:20:04
32,789,848
0
0
null
null
null
null
UTF-8
C++
false
false
2,718
cpp
//includes #include <iostream> #include <time.h> #include <windows.h> #include "macros.h" #include "Line.h" //#include "Plus.h" #include "Vertex.h" //#include "Stairs.h" //#include "Square.h" //Name spaces using namespace std; //Constants const bool LINE = true; const bool STAIRS = false; const bool PLUS = false; const bool SQUARE = false; //Global variables declaration bool paintBoard[MAX_X+1][MAX_Y+1]; //Methods declaration void clearBoard(); void printBoard(); void sleep(unsigned int mseconds); void gotoTop(); int main(){ clearBoard(); if(LINE){ cout << "Please enter x and y coordinates for one end of the line separated by spaces:" << endl; float x0,y0,x1,y1; cin >> x0 >> y0; cout << "Please enter x and y coordinates for the second end of the line:" << endl; cin >> x1 >> y1; Line inputLine = Line(x0,y0,x1,y1); clearBoard(); inputLine.draw(paintBoard); printBoard(); } /* if (SQUARE){ Vertex tl,shift; tl._x = 10.0; tl._y = 10.0; shift._x = 2.0; shift._y = 2.0; for (int i=0; i< 5; i++) { clearBoard(); mySquare.draw(paintBoard); printBoard(); mySquare.move(shift); gotoTop(); sleep(1000); } } if (PLUS){ Vertex t2; t2._x = 15.0; t2._y = 15.0; Plus myPlus = Plus(t2,5); for (int i=0; i< 5; i++) { clearBoard(); myPlus.draw(paintBoard); printBoard(); myPlus.grow(1); gotoTop(); sleep(1000); } } if (STAIRS){ Vertex t2; t2._x = 20.0; t2._y = 20.0; Stairs myStairs = Stairs(t2,3,3,2); for (int i=0; i< 12; i++) { clearBoard(); myStairs.draw(paintBoard); printBoard(); myStairs.rotate(90); gotoTop(); sleep(1000); } */ //} int xx; cin >> xx; return 0; } /* * Clears the board. */ void clearBoard(){ for(int i=0;i<=MAX_X;i++){ for(int j=0;j<=MAX_Y;j++){ paintBoard[i][j]= false; } } } /* * Prints the board to the standart output. */ void printBoard(){ for(int j=0;j<=MAX_Y;j++){ for(int i=0;i<=MAX_X;i++){ if(paintBoard[i][j]) cout << '*'; else{ //Draw the axes (i==0) ? cout << '|' : ((j==0) ? cout << '-' : cout << '#'); } } cout << endl; } } /* * Delay method, Used for the animation */ void sleep(unsigned int mseconds) { clock_t goal = mseconds + clock(); while (goal > clock()); } /* * Places the cursor in the top left corner of the console screen */ void gotoTop() { HANDLE screen_buffer_handle = GetStdHandle(STD_OUTPUT_HANDLE); COORD coord; coord.X = 0; coord.Y = 0; SetConsoleCursorPosition(screen_buffer_handle, coord); }
[ "[email protected]@915c7e4a-0830-d67a-7742-9bd6d4e428b7" ]
[ [ [ 1, 160 ] ] ]
d0afe0ab491bfc41501aaa7d4240293ede46dfd2
41d17c35d528a3b1296837776e8e084e5f61c001
/ghostmod/ghost/ghost.cpp
8be5644f62e01cd764d8b3c0366553071b5acd4f
[]
no_license
yjfyy/nwpubn
bb92eafb069744818add441a1936e05bd7d9ebbc
ec934eaf3746145f09aeafdfb8dd5f4412c5f162
refs/heads/master
2016-09-13T00:44:26.417809
2011-06-02T17:13:27
2011-06-02T17:13:27
57,039,206
0
0
null
null
null
null
UTF-8
C++
false
false
61,844
cpp
/* Copyright [2008] [Trevor Hogan] 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. CODE PORTED FROM THE ORIGINAL GHOST PROJECT: http://ghost.pwner.org/ */ #include "ghost.h" #include "util.h" #include "crc32.h" #include "sha1.h" #include "csvparser.h" #include "config.h" #include "language.h" #include "socket.h" #include "ghostdb.h" #include "ghostdbsqlite.h" #include "ghostdbmysql.h" #include "bnet.h" #include "map.h" #include "packed.h" #include "savegame.h" #include "gameplayer.h" #include "gameprotocol.h" #include "gpsprotocol.h" #include "game_base.h" #include "game.h" #include "game_admin.h" #include "userinterface.h" #include <signal.h> #include <stdlib.h> #ifdef WIN32 #include <ws2tcpip.h> // for WSAIoctl #endif #define __STORMLIB_SELF__ #include <stormlib/StormLib.h> /* #include "ghost.h" #include "util.h" #include "crc32.h" #include "sha1.h" #include "csvparser.h" #include "config.h" #include "language.h" #include "socket.h" #include "commandpacket.h" #include "ghostdb.h" #include "ghostdbsqlite.h" #include "ghostdbmysql.h" #include "bncsutilinterface.h" #include "warden.h" #include "bnlsprotocol.h" #include "bnlsclient.h" #include "bnetprotocol.h" #include "bnet.h" #include "map.h" #include "packed.h" #include "savegame.h" #include "replay.h" #include "gameslot.h" #include "gameplayer.h" #include "gameprotocol.h" #include "gpsprotocol.h" #include "game_base.h" #include "game.h" #include "game_admin.h" #include "stats.h" #include "statsdota.h" #include "sqlite3.h" */ #ifdef WIN32 #include <windows.h> #include <winsock.h> #endif #include <time.h> #ifndef WIN32 #include <sys/time.h> #endif #ifdef __APPLE__ #include <mach/mach_time.h> #endif string gCFGFile; string gLogFile; uint32_t gLogMethod; ofstream *gLog = NULL; CGHost *gGHost = NULL; CCurses *gCurses = NULL; uint32_t GetTime( ) { return GetTicks( ) / 1000; } uint32_t GetTicks( ) { #ifdef WIN32 // don't use GetTickCount anymore because it's not accurate enough (~16ms resolution) // don't use QueryPerformanceCounter anymore because it isn't guaranteed to be strictly increasing on some systems and thus requires "smoothing" code // use timeGetTime instead, which typically has a high resolution (5ms or more) but we request a lower resolution on startup return timeGetTime( ); #elif __APPLE__ uint64_t current = mach_absolute_time( ); static mach_timebase_info_data_t info = { 0, 0 }; // get timebase info if( info.denom == 0 ) mach_timebase_info( &info ); uint64_t elapsednano = current * ( info.numer / info.denom ); // convert ns to ms return elapsednano / 1e6; #else uint32_t ticks; struct timespec t; clock_gettime( CLOCK_MONOTONIC, &t ); ticks = t.tv_sec * 1000; ticks += t.tv_nsec / 1000000; return ticks; #endif } void SignalCatcher2( int s ) { CONSOLE_Print( "[!!!] caught signal " + UTIL_ToString( s ) + ", exiting NOW" ); if( gGHost ) { if( gGHost->m_Exiting ) exit( 1 ); else gGHost->m_Exiting = true; } else exit( 1 ); } void SignalCatcher( int s ) { // signal( SIGABRT, SignalCatcher2 ); signal( SIGINT, SignalCatcher2 ); CONSOLE_Print( "[!!!] caught signal " + UTIL_ToString( s ) + ", exiting nicely" ); if( gGHost ) gGHost->m_ExitingNice = true; else exit( 1 ); } void CONSOLE_Print( string message ) { CONSOLE_Print( message, 0, true ); } void CONSOLE_Print( string message, bool toMainBuffer ) { CONSOLE_Print( message, 0, toMainBuffer ); } void CONSOLE_Print( string message, uint32_t realmId, bool toMainBuffer ) { if ( gCurses ) gCurses->Print( message, realmId, toMainBuffer ); else cout << message << endl; // logging if( !gLogFile.empty( ) ) { if( gLogMethod == 1 ) { ofstream Log; Log.open( gLogFile.c_str( ), ios :: app ); if( !Log.fail( ) ) { time_t Now = time( NULL ); string Time = asctime( localtime( &Now ) ); // erase the newline Time.erase( Time.size( ) - 1 ); Log << "[" << Time << "] " << message << endl; Log.close( ); } } else if( gLogMethod == 2 ) { if( gLog && !gLog->fail( ) ) { time_t Now = time( NULL ); string Time = asctime( localtime( &Now ) ); // erase the newline Time.erase( Time.size( ) - 1 ); *gLog << "[" << Time << "] " << message << endl; gLog->flush( ); } } } } void DEBUG_Print( string message ) { cout << message << endl; } void DEBUG_Print( BYTEARRAY b ) { cout << "{ "; for( unsigned int i = 0; i < b.size( ); i++ ) cout << hex << (int)b[i] << " "; cout << "}" << endl; } void CONSOLE_ChangeChannel( string channel, uint32_t realmId ) { if ( gCurses ) gCurses->ChangeChannel( channel, realmId ); } void CONSOLE_AddChannelUser( string name, uint32_t realmId, int flag ) { if ( gCurses ) gCurses->AddChannelUser( name, realmId, flag ); } void CONSOLE_UpdateChannelUser( string name, uint32_t realmId, int flag ) { if ( gCurses ) gCurses->UpdateChannelUser( name, realmId, flag ); } void CONSOLE_RemoveChannelUser( string name, uint32_t realmId ) { if ( gCurses ) gCurses->RemoveChannelUser( name, realmId ); } void CONSOLE_RemoveChannelUsers( uint32_t realmId ) { if ( gCurses ) gCurses->RemoveChannelUsers( realmId ); } // // main // int main( int argc, char **argv ) { gCFGFile = "ghost.cfg"; if( argc > 1 && argv[1] ) gCFGFile = argv[1]; // read config file CConfig CFG; CFG.Read( "default.cfg" ); CFG.Read( gCFGFile ); gLogFile = CFG.GetString( "bot_log", string( ) ); gLogMethod = CFG.GetInt( "bot_logmethod", 1 ); if ( CFG.GetInt( "curses_enabled", 1 ) == 1 ) gCurses = new CCurses( CFG.GetInt( "term_width", 0 ), CFG.GetInt( "term_height", 0 ), !!CFG.GetInt( "curses_splitview", 0 ), CFG.GetInt( "curses_listtype", 0 ) ); UTIL_Construct_UTF8_Latin1_Map( ); if( !gLogFile.empty( ) ) { if( gLogMethod == 1 ) { // log method 1: open, append, and close the log for every message // this works well on Linux but poorly on Windows, particularly as the log file grows in size // the log file can be edited/moved/deleted while GHost++ is running } else if( gLogMethod == 2 ) { // log method 2: open the log on startup, flush the log for every message, close the log on shutdown // the log file CANNOT be edited/moved/deleted while GHost++ is running gLog = new ofstream( ); gLog->open( gLogFile.c_str( ), ios :: app ); } } CONSOLE_Print( "[GHOST] starting up" ); if( !gLogFile.empty( ) ) { if( gLogMethod == 1 ) CONSOLE_Print( "[GHOST] using log method 1, logging is enabled and [" + gLogFile + "] will not be locked" ); else if( gLogMethod == 2 ) { if( gLog->fail( ) ) CONSOLE_Print( "[GHOST] using log method 2 but unable to open [" + gLogFile + "] for appending, logging is disabled" ); else CONSOLE_Print( "[GHOST] using log method 2, logging is enabled and [" + gLogFile + "] is now locked" ); } } else CONSOLE_Print( "[GHOST] no log file specified, logging is disabled" ); // catch SIGABRT and SIGINT // signal( SIGABRT, SignalCatcher ); signal( SIGINT, SignalCatcher ); #ifndef WIN32 // disable SIGPIPE since some systems like OS X don't define MSG_NOSIGNAL signal( SIGPIPE, SIG_IGN ); #endif #ifdef WIN32 // initialize timer resolution // attempt to set the resolution as low as possible from 1ms to 5ms unsigned int TimerResolution = 0; for( unsigned int i = 1; i <= 5; i++ ) { if( timeBeginPeriod( i ) == TIMERR_NOERROR ) { TimerResolution = i; break; } else if( i < 5 ) CONSOLE_Print( "[GHOST] error setting Windows timer resolution to " + UTIL_ToString( i ) + " milliseconds, trying a higher resolution" ); else { CONSOLE_Print( "[GHOST] error setting Windows timer resolution" ); return 1; } } CONSOLE_Print( "[GHOST] using Windows timer with resolution " + UTIL_ToString( TimerResolution ) + " milliseconds" ); #elif __APPLE__ // not sure how to get the resolution #else // print the timer resolution struct timespec Resolution; if( clock_getres( CLOCK_MONOTONIC, &Resolution ) == -1 ) CONSOLE_Print( "[GHOST] error getting monotonic timer resolution" ); else CONSOLE_Print( "[GHOST] using monotonic timer with resolution " + UTIL_ToString( (double)( Resolution.tv_nsec / 1000 ), 2 ) + " microseconds" ); #endif #ifdef WIN32 // initialize winsock CONSOLE_Print( "[GHOST] starting winsock" ); WSADATA wsadata; if( WSAStartup( MAKEWORD( 2, 2 ), &wsadata ) != 0 ) { CONSOLE_Print( "[GHOST] error starting winsock" ); return 1; } // increase process priority CONSOLE_Print( "[GHOST] setting process priority to \"above normal\"" ); SetPriorityClass( GetCurrentProcess( ), ABOVE_NORMAL_PRIORITY_CLASS ); #endif // initialize ghost gGHost = new CGHost( &CFG ); if ( gCurses ) gCurses->SetGHost( gGHost ); while( 1 ) { // block for 50ms on all sockets - if you intend to perform any timed actions more frequently you should change this // that said it's likely we'll loop more often than this due to there being data waiting on one of the sockets but there aren't any guarantees if( gGHost->Update( 50000 ) || ( gCurses && gCurses->Update( ) ) ) break; } // shutdown ghost CONSOLE_Print( "[GHOST] shutting down" ); delete gGHost; gGHost = NULL; #ifdef WIN32 // shutdown winsock CONSOLE_Print( "[GHOST] shutting down winsock" ); WSACleanup( ); // shutdown timer timeEndPeriod( TimerResolution ); #endif if( gLog ) { if( !gLog->fail( ) ) gLog->close( ); delete gLog; } // shutdown curses if ( gCurses ) { CONSOLE_Print( "[GHOST] shutting down curses" ); delete gCurses; gCurses = NULL; } return 0; } // // CGHost // CGHost :: CGHost( CConfig *CFG ) { m_UDPSocket = new CUDPSocket( ); m_UDPSocket->SetBroadcastTarget( CFG->GetString( "udp_broadcasttarget", string( ) ) ); m_UDPSocket->SetDontRoute( CFG->GetInt( "udp_dontroute", 0 ) == 0 ? false : true ); m_ReconnectSocket = NULL; m_GPSProtocol = new CGPSProtocol( ); m_CRC = new CCRC32( ); m_CRC->Initialize( ); m_SHA = new CSHA1( ); m_CurrentGame = NULL; string DBType = CFG->GetString( "db_type", "sqlite3" ); CONSOLE_Print( "[GHOST] opening primary database" ); if( DBType == "mysql" ) { #ifdef GHOST_MYSQL m_DB = new CGHostDBMySQL( CFG ); #else CONSOLE_Print( "[GHOST] warning - this binary was not compiled with MySQL database support, using SQLite database instead" ); m_DB = new CGHostDBSQLite( CFG ); #endif } else m_DB = new CGHostDBSQLite( CFG ); CONSOLE_Print( "[GHOST] opening secondary (local) database" ); m_DBLocal = new CGHostDBSQLite( CFG ); // get a list of local IP addresses // this list is used elsewhere to determine if a player connecting to the bot is local or not CONSOLE_Print( "[GHOST] attempting to find local IP addresses" ); #ifdef WIN32 // use a more reliable Windows specific method since the portable method doesn't always work properly on Windows // code stolen from: http://tangentsoft.net/wskfaq/examples/getifaces.html SOCKET sd = WSASocket( AF_INET, SOCK_DGRAM, 0, 0, 0, 0 ); if( sd == SOCKET_ERROR ) CONSOLE_Print( "[GHOST] error finding local IP addresses - failed to create socket (error code " + UTIL_ToString( WSAGetLastError( ) ) + ")" ); else { INTERFACE_INFO InterfaceList[20]; unsigned long nBytesReturned; if( WSAIoctl( sd, SIO_GET_INTERFACE_LIST, 0, 0, &InterfaceList, sizeof(InterfaceList), &nBytesReturned, 0, 0 ) == SOCKET_ERROR ) CONSOLE_Print( "[GHOST] error finding local IP addresses - WSAIoctl failed (error code " + UTIL_ToString( WSAGetLastError( ) ) + ")" ); else { int nNumInterfaces = nBytesReturned / sizeof(INTERFACE_INFO); for( int i = 0; i < nNumInterfaces; i++ ) { sockaddr_in *pAddress; pAddress = (sockaddr_in *)&(InterfaceList[i].iiAddress); CONSOLE_Print( "[GHOST] local IP address #" + UTIL_ToString( i + 1 ) + " is [" + string( inet_ntoa( pAddress->sin_addr ) ) + "]" ); m_LocalAddresses.push_back( UTIL_CreateByteArray( (uint32_t)pAddress->sin_addr.s_addr, false ) ); } } closesocket( sd ); } #else // use a portable method char HostName[255]; if( gethostname( HostName, 255 ) == SOCKET_ERROR ) CONSOLE_Print( "[GHOST] error finding local IP addresses - failed to get local hostname" ); else { CONSOLE_Print( "[GHOST] local hostname is [" + string( HostName ) + "]" ); struct hostent *HostEnt = gethostbyname( HostName ); if( !HostEnt ) CONSOLE_Print( "[GHOST] error finding local IP addresses - gethostbyname failed" ); else { for( int i = 0; HostEnt->h_addr_list[i] != NULL; i++ ) { struct in_addr Address; memcpy( &Address, HostEnt->h_addr_list[i], sizeof(struct in_addr) ); CONSOLE_Print( "[GHOST] local IP address #" + UTIL_ToString( i + 1 ) + " is [" + string( inet_ntoa( Address ) ) + "]" ); m_LocalAddresses.push_back( UTIL_CreateByteArray( (uint32_t)Address.s_addr, false ) ); } } } #endif m_Language = NULL; m_Exiting = false; m_ExitingNice = false; m_Enabled = true; m_Version = "17.1"; m_HostCounter = 1; m_AutoHostMaximumGames = CFG->GetInt( "autohost_maxgames", 0 ); m_AutoHostAutoStartPlayers = CFG->GetInt( "autohost_startplayers", 0 ); m_AutoHostGameName = CFG->GetString( "autohost_gamename", string( ) ); m_AutoHostOwner = CFG->GetString( "autohost_owner", string( ) ); m_LastAutoHostTime = GetTime( ); m_AutoHostMatchMaking = false; m_AutoHostMinimumScore = 0.0; m_AutoHostMaximumScore = 0.0; m_AllGamesFinished = false; m_AllGamesFinishedTime = 0; m_TFT = CFG->GetInt( "bot_tft", 1 ) == 0 ? false : true; if( m_TFT ) CONSOLE_Print( "[GHOST] acting as Warcraft III: The Frozen Throne" ); else CONSOLE_Print( "[GHOST] acting as Warcraft III: Reign of Chaos" ); m_HostPort = CFG->GetInt( "bot_hostport", 6112 ); m_Reconnect = CFG->GetInt( "bot_reconnect", 1 ) == 0 ? false : true; m_ReconnectPort = CFG->GetInt( "bot_reconnectport", 6114 ); m_DefaultMap = CFG->GetString( "bot_defaultmap", "map" ); m_AdminGameCreate = CFG->GetInt( "admingame_create", 0 ) == 0 ? false : true; m_AdminGamePort = CFG->GetInt( "admingame_port", 6113 ); m_AdminGamePassword = CFG->GetString( "admingame_password", string( ) ); m_AdminGameMap = CFG->GetString( "admingame_map", string( ) ); m_LANWar3Version = CFG->GetInt( "lan_war3version", 24 ); m_ReplayWar3Version = CFG->GetInt( "replay_war3version", 24 ); m_ReplayBuildNumber = CFG->GetInt( "replay_buildnumber", 6059 ); SetConfigs( CFG ); // load the battle.net connections // we're just loading the config data and creating the CBNET classes here, the connections are established later (in the Update function) for( uint32_t i = 1; i < 10; i++ ) { string Prefix; if( i == 1 ) Prefix = "bnet_"; else Prefix = "bnet" + UTIL_ToString( i ) + "_"; string Server = CFG->GetString( Prefix + "server", string( ) ); string ServerAlias = CFG->GetString( Prefix + "serveralias", string( ) ); string CDKeyROC = CFG->GetString( Prefix + "cdkeyroc", string( ) ); string CDKeyTFT = CFG->GetString( Prefix + "cdkeytft", string( ) ); string CountryAbbrev = CFG->GetString( Prefix + "countryabbrev", "USA" ); string Country = CFG->GetString( Prefix + "country", "United States" ); string Locale = CFG->GetString( Prefix + "locale", "system" ); uint32_t LocaleID; if( Locale == "system" ) { #ifdef WIN32 LocaleID = GetUserDefaultLangID( ); #else LocaleID = 1033; #endif } else LocaleID = UTIL_ToUInt32( Locale ); string UserName = CFG->GetString( Prefix + "username", string( ) ); string UserPassword = CFG->GetString( Prefix + "password", string( ) ); string FirstChannel = CFG->GetString( Prefix + "firstchannel", "The Void" ); string RootAdmin = CFG->GetString( Prefix + "rootadmin", string( ) ); string BNETCommandTrigger = CFG->GetString( Prefix + "commandtrigger", "!" ); if( BNETCommandTrigger.empty( ) ) BNETCommandTrigger = "!"; bool HoldFriends = CFG->GetInt( Prefix + "holdfriends", 1 ) == 0 ? false : true; bool HoldClan = CFG->GetInt( Prefix + "holdclan", 1 ) == 0 ? false : true; bool PublicCommands = CFG->GetInt( Prefix + "publiccommands", 1 ) == 0 ? false : true; string BNLSServer = CFG->GetString( Prefix + "bnlsserver", string( ) ); int BNLSPort = CFG->GetInt( Prefix + "bnlsport", 9367 ); int BNLSWardenCookie = CFG->GetInt( Prefix + "bnlswardencookie", 0 ); unsigned char War3Version = CFG->GetInt( Prefix + "custom_war3version", 24 ); BYTEARRAY EXEVersion = UTIL_ExtractNumbers( CFG->GetString( Prefix + "custom_exeversion", string( ) ), 4 ); BYTEARRAY EXEVersionHash = UTIL_ExtractNumbers( CFG->GetString( Prefix + "custom_exeversionhash", string( ) ), 4 ); string PasswordHashType = CFG->GetString( Prefix + "custom_passwordhashtype", string( ) ); string PVPGNRealmName = CFG->GetString( Prefix + "custom_pvpgnrealmname", "PvPGN Realm" ); uint32_t MaxMessageLength = CFG->GetInt( Prefix + "custom_maxmessagelength", 200 ); if( Server.empty( ) ) break; if( CDKeyROC.empty( ) ) { CONSOLE_Print( "[GHOST] missing " + Prefix + "cdkeyroc, skipping this battle.net connection" ); continue; } if( m_TFT && CDKeyTFT.empty( ) ) { CONSOLE_Print( "[GHOST] missing " + Prefix + "cdkeytft, skipping this battle.net connection" ); continue; } if( UserName.empty( ) ) { CONSOLE_Print( "[GHOST] missing " + Prefix + "username, skipping this battle.net connection" ); continue; } if( UserPassword.empty( ) ) { CONSOLE_Print( "[GHOST] missing " + Prefix + "password, skipping this battle.net connection" ); continue; } CONSOLE_Print( "[GHOST] found battle.net connection #" + UTIL_ToString( i ) + " for server [" + Server + "]" ); if( Locale == "system" ) { #ifdef WIN32 CONSOLE_Print( "[GHOST] using system locale of " + UTIL_ToString( LocaleID ) ); #else CONSOLE_Print( "[GHOST] unable to get system locale, using default locale of 1033" ); #endif } m_BNETs.push_back( new CBNET( this, Server, ServerAlias, BNLSServer, (uint16_t)BNLSPort, (uint32_t)BNLSWardenCookie, CDKeyROC, CDKeyTFT, CountryAbbrev, Country, LocaleID, UserName, UserPassword, FirstChannel, RootAdmin, m_LANRootAdmin, BNETCommandTrigger[0], HoldFriends, HoldClan, PublicCommands, War3Version, EXEVersion, EXEVersionHash, PasswordHashType, PVPGNRealmName, MaxMessageLength, i ) ); } if( m_BNETs.empty( ) ) CONSOLE_Print( "[GHOST] warning - no battle.net connections found in config file" ); // extract common.j and blizzard.j from War3Patch.mpq if we can // these two files are necessary for calculating "map_crc" when loading maps so we make sure to do it before loading the default map // see CMap :: Load for more information ExtractScripts( ); // load the default maps (note: make sure to run ExtractScripts first) if( m_DefaultMap.size( ) < 4 || m_DefaultMap.substr( m_DefaultMap.size( ) - 4 ) != ".cfg" ) { m_DefaultMap += ".cfg"; CONSOLE_Print( "[GHOST] adding \".cfg\" to default map -> new default is [" + m_DefaultMap + "]" ); } CConfig MapCFG; MapCFG.Read( m_MapCFGPath + m_DefaultMap ); m_Map = new CMap( this, &MapCFG, m_MapCFGPath + m_DefaultMap ); if( !m_AdminGameMap.empty( ) ) { if( m_AdminGameMap.size( ) < 4 || m_AdminGameMap.substr( m_AdminGameMap.size( ) - 4 ) != ".cfg" ) { m_AdminGameMap += ".cfg"; CONSOLE_Print( "[GHOST] adding \".cfg\" to default admin game map -> new default is [" + m_AdminGameMap + "]" ); } CONSOLE_Print( "[GHOST] trying to load default admin game map" ); CConfig AdminMapCFG; AdminMapCFG.Read( m_MapCFGPath + m_AdminGameMap ); m_AdminMap = new CMap( this, &AdminMapCFG, m_MapCFGPath + m_AdminGameMap ); if( !m_AdminMap->GetValid( ) ) { CONSOLE_Print( "[GHOST] default admin game map isn't valid, using hardcoded admin game map instead" ); delete m_AdminMap; m_AdminMap = new CMap( this ); } } else { CONSOLE_Print( "[GHOST] using hardcoded admin game map" ); m_AdminMap = new CMap( this ); } m_AutoHostMap = new CMap( *m_Map ); m_SaveGame = new CSaveGame( ); // load the iptocountry data LoadIPToCountryData( ); // create the admin game if( m_AdminGameCreate ) { CONSOLE_Print( "[GHOST] creating admin game" ); m_AdminGame = new CAdminGame( this, m_AdminMap, NULL, m_AdminGamePort, 0, "GHost++ Admin Game", m_AdminGamePassword ); if( m_AdminGamePort == m_HostPort ) CONSOLE_Print( "[GHOST] warning - admingame_port and bot_hostport are set to the same value, you won't be able to host any games" ); } else m_AdminGame = NULL; if( m_BNETs.empty( ) && !m_AdminGame ) CONSOLE_Print( "[GHOST] warning - no battle.net connections found and no admin game created" ); #ifdef GHOST_MYSQL CONSOLE_Print( "[GHOST] GHost++ Version " + m_Version + " (with MySQL support)" ); #else CONSOLE_Print( "[GHOST] GHost++ Version " + m_Version + " (without MySQL support)" ); #endif } CGHost :: ~CGHost( ) { delete m_UDPSocket; delete m_ReconnectSocket; for( vector<CTCPSocket *> :: iterator i = m_ReconnectSockets.begin( ); i != m_ReconnectSockets.end( ); i++ ) delete *i; delete m_GPSProtocol; delete m_CRC; delete m_SHA; for( vector<CBNET *> :: iterator i = m_BNETs.begin( ); i != m_BNETs.end( ); i++ ) delete *i; delete m_CurrentGame; delete m_AdminGame; for( vector<CBaseGame *> :: iterator i = m_Games.begin( ); i != m_Games.end( ); i++ ) delete *i; delete m_DB; delete m_DBLocal; // warning: we don't delete any entries of m_Callables here because we can't be guaranteed that the associated threads have terminated // this is fine if the program is currently exiting because the OS will clean up after us // but if you try to recreate the CGHost object within a single session you will probably leak resources! if( !m_Callables.empty( ) ) CONSOLE_Print( "[GHOST] warning - " + UTIL_ToString( m_Callables.size( ) ) + " orphaned callables were leaked (this is not an error)" ); delete m_Language; delete m_Map; delete m_AdminMap; delete m_AutoHostMap; delete m_SaveGame; } bool CGHost :: Update( long usecBlock ) { // todotodo: do we really want to shutdown if there's a database error? is there any way to recover from this? if( m_DB->HasError( ) ) { CONSOLE_Print( "[GHOST] database error - " + m_DB->GetError( ) ); return true; } if( m_DBLocal->HasError( ) ) { CONSOLE_Print( "[GHOST] local database error - " + m_DBLocal->GetError( ) ); return true; } // try to exit nicely if requested to do so if( m_ExitingNice ) { if( !m_BNETs.empty( ) ) { CONSOLE_Print( "[GHOST] deleting all battle.net connections in preparation for exiting nicely" ); for( vector<CBNET *> :: iterator i = m_BNETs.begin( ); i != m_BNETs.end( ); i++ ) delete *i; m_BNETs.clear( ); } if( m_CurrentGame ) { CONSOLE_Print( "[GHOST] deleting current game in preparation for exiting nicely" ); delete m_CurrentGame; m_CurrentGame = NULL; } if( m_AdminGame ) { CONSOLE_Print( "[GHOST] deleting admin game in preparation for exiting nicely" ); delete m_AdminGame; m_AdminGame = NULL; } if( m_Games.empty( ) ) { if( !m_AllGamesFinished ) { CONSOLE_Print( "[GHOST] all games finished, waiting 60 seconds for threads to finish" ); CONSOLE_Print( "[GHOST] there are " + UTIL_ToString( m_Callables.size( ) ) + " threads in progress" ); m_AllGamesFinished = true; m_AllGamesFinishedTime = GetTime( ); } else { if( m_Callables.empty( ) ) { CONSOLE_Print( "[GHOST] all threads finished, exiting nicely" ); m_Exiting = true; } else if( GetTime( ) - m_AllGamesFinishedTime >= 60 ) { CONSOLE_Print( "[GHOST] waited 60 seconds for threads to finish, exiting anyway" ); CONSOLE_Print( "[GHOST] there are " + UTIL_ToString( m_Callables.size( ) ) + " threads still in progress which will be terminated" ); m_Exiting = true; } } } } // update callables for( vector<CBaseCallable *> :: iterator i = m_Callables.begin( ); i != m_Callables.end( ); ) { if( (*i)->GetReady( ) ) { m_DB->RecoverCallable( *i ); delete *i; i = m_Callables.erase( i ); } else i++; } // create the GProxy++ reconnect listener if( m_Reconnect ) { if( !m_ReconnectSocket ) { m_ReconnectSocket = new CTCPServer( ); if( m_ReconnectSocket->Listen( m_BindAddress, m_ReconnectPort ) ) CONSOLE_Print( "[GHOST] listening for GProxy++ reconnects on port " + UTIL_ToString( m_ReconnectPort ) ); else { CONSOLE_Print( "[GHOST] error listening for GProxy++ reconnects on port " + UTIL_ToString( m_ReconnectPort ) ); delete m_ReconnectSocket; m_ReconnectSocket = NULL; m_Reconnect = false; } } else if( m_ReconnectSocket->HasError( ) ) { CONSOLE_Print( "[GHOST] GProxy++ reconnect listener error (" + m_ReconnectSocket->GetErrorString( ) + ")" ); delete m_ReconnectSocket; m_ReconnectSocket = NULL; m_Reconnect = false; } } unsigned int NumFDs = 0; // take every socket we own and throw it in one giant select statement so we can block on all sockets int nfds = 0; fd_set fd; fd_set send_fd; FD_ZERO( &fd ); FD_ZERO( &send_fd ); // 1. all battle.net sockets for( vector<CBNET *> :: iterator i = m_BNETs.begin( ); i != m_BNETs.end( ); i++ ) NumFDs += (*i)->SetFD( &fd, &send_fd, &nfds ); // 2. the current game's server and player sockets if( m_CurrentGame ) NumFDs += m_CurrentGame->SetFD( &fd, &send_fd, &nfds ); // 3. the admin game's server and player sockets if( m_AdminGame ) NumFDs += m_AdminGame->SetFD( &fd, &send_fd, &nfds ); // 4. all running games' player sockets for( vector<CBaseGame *> :: iterator i = m_Games.begin( ); i != m_Games.end( ); i++ ) NumFDs += (*i)->SetFD( &fd, &send_fd, &nfds ); // 5. the GProxy++ reconnect socket(s) if( m_Reconnect && m_ReconnectSocket ) { m_ReconnectSocket->SetFD( &fd, &send_fd, &nfds ); NumFDs++; } for( vector<CTCPSocket *> :: iterator i = m_ReconnectSockets.begin( ); i != m_ReconnectSockets.end( ); i++ ) { (*i)->SetFD( &fd, &send_fd, &nfds ); NumFDs++; } // before we call select we need to determine how long to block for // previously we just blocked for a maximum of the passed usecBlock microseconds // however, in an effort to make game updates happen closer to the desired latency setting we now use a dynamic block interval // note: we still use the passed usecBlock as a hard maximum for( vector<CBaseGame *> :: iterator i = m_Games.begin( ); i != m_Games.end( ); i++ ) { if( (*i)->GetNextTimedActionTicks( ) * 1000 < usecBlock ) usecBlock = (*i)->GetNextTimedActionTicks( ) * 1000; } // always block for at least 1ms just in case something goes wrong // this prevents the bot from sucking up all the available CPU if a game keeps asking for immediate updates // it's a bit ridiculous to include this check since, in theory, the bot is programmed well enough to never make this mistake // however, considering who programmed it, it's worthwhile to do it anyway if( usecBlock < 1000 ) usecBlock = 1000; struct timeval tv; tv.tv_sec = 0; tv.tv_usec = usecBlock; struct timeval send_tv; send_tv.tv_sec = 0; send_tv.tv_usec = 0; #ifdef WIN32 select( 1, &fd, NULL, NULL, &tv ); select( 1, NULL, &send_fd, NULL, &send_tv ); #else select( nfds + 1, &fd, NULL, NULL, &tv ); select( nfds + 1, NULL, &send_fd, NULL, &send_tv ); #endif if( NumFDs == 0 ) { // we don't have any sockets (i.e. we aren't connected to battle.net maybe due to a lost connection and there aren't any games running) // select will return immediately and we'll chew up the CPU if we let it loop so just sleep for 50ms to kill some time MILLISLEEP( 50 ); } bool AdminExit = false; bool BNETExit = false; // update current game if( m_CurrentGame ) { if( m_CurrentGame->Update( &fd, &send_fd ) ) { CONSOLE_Print( "[GHOST] deleting current game [" + m_CurrentGame->GetGameName( ) + "]" ); delete m_CurrentGame; m_CurrentGame = NULL; for( vector<CBNET *> :: iterator i = m_BNETs.begin( ); i != m_BNETs.end( ); i++ ) { (*i)->QueueGameUncreate( ); (*i)->QueueEnterChat( ); } } else if( m_CurrentGame ) m_CurrentGame->UpdatePost( &send_fd ); } // update admin game if( m_AdminGame ) { if( m_AdminGame->Update( &fd, &send_fd ) ) { CONSOLE_Print( "[GHOST] deleting admin game" ); delete m_AdminGame; m_AdminGame = NULL; AdminExit = true; } else if( m_AdminGame ) m_AdminGame->UpdatePost( &send_fd ); } // update running games for( vector<CBaseGame *> :: iterator i = m_Games.begin( ); i != m_Games.end( ); ) { if( (*i)->Update( &fd, &send_fd ) ) { CONSOLE_Print( "[GHOST] deleting game [" + (*i)->GetGameName( ) + "]" ); EventGameDeleted( *i ); delete *i; i = m_Games.erase( i ); } else { (*i)->UpdatePost( &send_fd ); i++; } } // update battle.net connections for( vector<CBNET *> :: iterator i = m_BNETs.begin( ); i != m_BNETs.end( ); i++ ) { if( (*i)->Update( &fd, &send_fd ) ) BNETExit = true; } // update GProxy++ reliable reconnect sockets if( m_Reconnect && m_ReconnectSocket ) { CTCPSocket *NewSocket = m_ReconnectSocket->Accept( &fd ); if( NewSocket ) m_ReconnectSockets.push_back( NewSocket ); } for( vector<CTCPSocket *> :: iterator i = m_ReconnectSockets.begin( ); i != m_ReconnectSockets.end( ); ) { if( (*i)->HasError( ) || !(*i)->GetConnected( ) || GetTime( ) - (*i)->GetLastRecv( ) >= 10 ) { delete *i; i = m_ReconnectSockets.erase( i ); continue; } (*i)->DoRecv( &fd ); string *RecvBuffer = (*i)->GetBytes( ); BYTEARRAY Bytes = UTIL_CreateByteArray( (unsigned char *)RecvBuffer->c_str( ), RecvBuffer->size( ) ); // a packet is at least 4 bytes if( Bytes.size( ) >= 4 ) { if( Bytes[0] == GPS_HEADER_CONSTANT ) { // bytes 2 and 3 contain the length of the packet uint16_t Length = UTIL_ByteArrayToUInt16( Bytes, false, 2 ); if( Length >= 4 ) { if( Bytes.size( ) >= Length ) { if( Bytes[1] == CGPSProtocol :: GPS_RECONNECT && Length == 13 ) { unsigned char PID = Bytes[4]; uint32_t ReconnectKey = UTIL_ByteArrayToUInt32( Bytes, false, 5 ); uint32_t LastPacket = UTIL_ByteArrayToUInt32( Bytes, false, 9 ); // look for a matching player in a running game CGamePlayer *Match = NULL; for( vector<CBaseGame *> :: iterator j = m_Games.begin( ); j != m_Games.end( ); j++ ) { if( (*j)->GetGameLoaded( ) ) { CGamePlayer *Player = (*j)->GetPlayerFromPID( PID ); if( Player && Player->GetGProxy( ) && Player->GetGProxyReconnectKey( ) == ReconnectKey ) { Match = Player; break; } } } if( Match ) { // reconnect successful! *RecvBuffer = RecvBuffer->substr( Length ); Match->EventGProxyReconnect( *i, LastPacket ); i = m_ReconnectSockets.erase( i ); continue; } else { (*i)->PutBytes( m_GPSProtocol->SEND_GPSS_REJECT( REJECTGPS_NOTFOUND ) ); (*i)->DoSend( &send_fd ); delete *i; i = m_ReconnectSockets.erase( i ); continue; } } else { (*i)->PutBytes( m_GPSProtocol->SEND_GPSS_REJECT( REJECTGPS_INVALID ) ); (*i)->DoSend( &send_fd ); delete *i; i = m_ReconnectSockets.erase( i ); continue; } } } else { (*i)->PutBytes( m_GPSProtocol->SEND_GPSS_REJECT( REJECTGPS_INVALID ) ); (*i)->DoSend( &send_fd ); delete *i; i = m_ReconnectSockets.erase( i ); continue; } } else { (*i)->PutBytes( m_GPSProtocol->SEND_GPSS_REJECT( REJECTGPS_INVALID ) ); (*i)->DoSend( &send_fd ); delete *i; i = m_ReconnectSockets.erase( i ); continue; } } (*i)->DoSend( &send_fd ); i++; } // autohost if( !m_AutoHostGameName.empty( ) && m_AutoHostMaximumGames != 0 && m_AutoHostAutoStartPlayers != 0 && GetTime( ) - m_LastAutoHostTime >= 30 ) { // copy all the checks from CGHost :: CreateGame here because we don't want to spam the chat when there's an error // instead we fail silently and try again soon if( !m_ExitingNice && m_Enabled && !m_CurrentGame && m_Games.size( ) < m_MaxGames && m_Games.size( ) < m_AutoHostMaximumGames ) { if( m_AutoHostMap->GetValid( ) ) { // @disturbed_oc // try to find gamename with random mode, or fallback on autohost_gamename //CONSOLE_Print( "[GHOST] Trying to determine gamename..." ); string GameName = m_AutoHostMap->GetMapGameNameWithRandomMode(); if (GameName.empty()) GameName = m_AutoHostGameName; GameName = GameName + " #" + UTIL_ToString( m_HostCounter ); // @end /* removed when implemented HCL command rotation code string GameName = m_AutoHostGameName + " #" + UTIL_ToString( m_HostCounter ); */ if( GameName.size( ) <= 31 ) { CreateGame( m_AutoHostMap, GAME_PUBLIC, false, GameName, m_AutoHostOwner, m_AutoHostOwner, m_AutoHostServer, false ); if( m_CurrentGame ) { m_CurrentGame->SetAutoStartPlayers( m_AutoHostAutoStartPlayers ); if( m_AutoHostMatchMaking ) { if( !m_Map->GetMapMatchMakingCategory( ).empty( ) ) { if( !( m_Map->GetMapOptions( ) & MAPOPT_FIXEDPLAYERSETTINGS ) ) CONSOLE_Print( "[GHOST] autohostmm - map_matchmakingcategory [" + m_Map->GetMapMatchMakingCategory( ) + "] found but matchmaking can only be used with fixed player settings, matchmaking disabled" ); else { CONSOLE_Print( "[GHOST] autohostmm - map_matchmakingcategory [" + m_Map->GetMapMatchMakingCategory( ) + "] found, matchmaking enabled" ); m_CurrentGame->SetMatchMaking( true ); m_CurrentGame->SetMinimumScore( m_AutoHostMinimumScore ); m_CurrentGame->SetMaximumScore( m_AutoHostMaximumScore ); } } else CONSOLE_Print( "[GHOST] autohostmm - map_matchmakingcategory not found, matchmaking disabled" ); } } } else { CONSOLE_Print( "[GHOST] stopped auto hosting, next game name [" + GameName + "] is too long (the maximum is 31 characters)" ); m_AutoHostGameName.clear( ); m_AutoHostOwner.clear( ); m_AutoHostServer.clear( ); m_AutoHostMaximumGames = 0; m_AutoHostAutoStartPlayers = 0; m_AutoHostMatchMaking = false; m_AutoHostMinimumScore = 0.0; m_AutoHostMaximumScore = 0.0; } } else { CONSOLE_Print( "[GHOST] stopped auto hosting, map config file [" + m_AutoHostMap->GetCFGFile( ) + "] is invalid" ); m_AutoHostGameName.clear( ); m_AutoHostOwner.clear( ); m_AutoHostServer.clear( ); m_AutoHostMaximumGames = 0; m_AutoHostAutoStartPlayers = 0; m_AutoHostMatchMaking = false; m_AutoHostMinimumScore = 0.0; m_AutoHostMaximumScore = 0.0; } } m_LastAutoHostTime = GetTime( ); } return m_Exiting || AdminExit || BNETExit; } void CGHost :: EventBNETConnecting( CBNET *bnet ) { if( m_AdminGame ) m_AdminGame->SendAllChat( m_Language->ConnectingToBNET( bnet->GetServer( ) ) ); if( m_CurrentGame ) m_CurrentGame->SendAllChat( m_Language->ConnectingToBNET( bnet->GetServer( ) ) ); } void CGHost :: EventBNETConnected( CBNET *bnet ) { if( m_AdminGame ) m_AdminGame->SendAllChat( m_Language->ConnectedToBNET( bnet->GetServer( ) ) ); if( m_CurrentGame ) m_CurrentGame->SendAllChat( m_Language->ConnectedToBNET( bnet->GetServer( ) ) ); } void CGHost :: EventBNETDisconnected( CBNET *bnet ) { if( m_AdminGame ) m_AdminGame->SendAllChat( m_Language->DisconnectedFromBNET( bnet->GetServer( ) ) ); if( m_CurrentGame ) m_CurrentGame->SendAllChat( m_Language->DisconnectedFromBNET( bnet->GetServer( ) ) ); } void CGHost :: EventBNETLoggedIn( CBNET *bnet ) { if( m_AdminGame ) m_AdminGame->SendAllChat( m_Language->LoggedInToBNET( bnet->GetServer( ) ) ); if( m_CurrentGame ) m_CurrentGame->SendAllChat( m_Language->LoggedInToBNET( bnet->GetServer( ) ) ); } void CGHost :: EventBNETGameRefreshed( CBNET *bnet ) { if( m_AdminGame ) m_AdminGame->SendAllChat( m_Language->BNETGameHostingSucceeded( bnet->GetServer( ) ) ); if( m_CurrentGame ) m_CurrentGame->EventGameRefreshed( bnet->GetServer( ) ); } void CGHost :: EventBNETGameRefreshFailed( CBNET *bnet ) { if( m_CurrentGame ) { for( vector<CBNET *> :: iterator i = m_BNETs.begin( ); i != m_BNETs.end( ); i++ ) { (*i)->QueueChatCommand( m_Language->UnableToCreateGameTryAnotherName( bnet->GetServer( ), m_CurrentGame->GetGameName( ) ) ); if( (*i)->GetServer( ) == m_CurrentGame->GetCreatorServer( ) ) (*i)->QueueChatCommand( m_Language->UnableToCreateGameTryAnotherName( bnet->GetServer( ), m_CurrentGame->GetGameName( ) ), m_CurrentGame->GetCreatorName( ), true, false ); } if( m_AdminGame ) m_AdminGame->SendAllChat( m_Language->BNETGameHostingFailed( bnet->GetServer( ), m_CurrentGame->GetGameName( ) ) ); m_CurrentGame->SendAllChat( m_Language->UnableToCreateGameTryAnotherName( bnet->GetServer( ), m_CurrentGame->GetGameName( ) ) ); // we take the easy route and simply close the lobby if a refresh fails // it's possible at least one refresh succeeded and therefore the game is still joinable on at least one battle.net (plus on the local network) but we don't keep track of that // we only close the game if it has no players since we support game rehosting (via !priv and !pub in the lobby) if( m_CurrentGame->GetNumHumanPlayers( ) == 0 ) m_CurrentGame->SetExiting( true ); m_CurrentGame->SetRefreshError( true ); } } void CGHost :: EventBNETConnectTimedOut( CBNET *bnet ) { if( m_AdminGame ) m_AdminGame->SendAllChat( m_Language->ConnectingToBNETTimedOut( bnet->GetServer( ) ) ); if( m_CurrentGame ) m_CurrentGame->SendAllChat( m_Language->ConnectingToBNETTimedOut( bnet->GetServer( ) ) ); } void CGHost :: EventBNETWhisper( CBNET *bnet, string user, string message ) { if( m_AdminGame ) { m_AdminGame->SendAdminChat( "[WHISPER: " + bnet->GetServerAlias( ) + "] [" + user + "] " + message ); if( m_CurrentGame ) m_CurrentGame->SendLocalAdminChat( "[WHISPER: " + bnet->GetServerAlias( ) + "] [" + user + "] " + message ); for( vector<CBaseGame *> :: iterator i = m_Games.begin( ); i != m_Games.end( ); i++ ) (*i)->SendLocalAdminChat( "[WHISPER: " + bnet->GetServerAlias( ) + "] [" + user + "] " + message ); } } void CGHost :: EventBNETChat( CBNET *bnet, string user, string message ) { if( m_AdminGame ) { m_AdminGame->SendAdminChat( "[LOCAL: " + bnet->GetServerAlias( ) + "] [" + user + "] " + message ); if( m_CurrentGame ) m_CurrentGame->SendLocalAdminChat( "[LOCAL: " + bnet->GetServerAlias( ) + "] [" + user + "] " + message ); for( vector<CBaseGame *> :: iterator i = m_Games.begin( ); i != m_Games.end( ); i++ ) (*i)->SendLocalAdminChat( "[LOCAL: " + bnet->GetServerAlias( ) + "] [" + user + "] " + message ); } } void CGHost :: EventBNETBROADCAST( CBNET *bnet, string user, string message ) { if( m_AdminGame ) { m_AdminGame->SendAdminChat( "[BROADCAST: " + bnet->GetServerAlias( ) + "] " + message ); if( m_CurrentGame ) m_CurrentGame->SendLocalAdminChat( "[BROADCAST: " + bnet->GetServerAlias( ) + "] " + message ); for( vector<CBaseGame *> :: iterator i = m_Games.begin( ); i != m_Games.end( ); i++ ) (*i)->SendLocalAdminChat( "[BROADCAST: " + bnet->GetServerAlias( ) + "] " + message ); } } void CGHost :: EventBNETCHANNEL( CBNET *bnet, string user, string message ) { if( m_AdminGame ) { m_AdminGame->SendAdminChat( "[BNET: " + bnet->GetServerAlias( ) + "] joined channel [" + message + "]" ); if( m_CurrentGame ) m_CurrentGame->SendLocalAdminChat( "[BNET: " + bnet->GetServerAlias( ) + "] joined channel [" + message + "]" ); for( vector<CBaseGame *> :: iterator i = m_Games.begin( ); i != m_Games.end( ); i++ ) (*i)->SendLocalAdminChat( "[BNET: " + bnet->GetServerAlias( ) + "] joined channel [" + message + "]" ); } } void CGHost :: EventBNETWHISPERSENT( CBNET *bnet, string user, string message ) { if( m_AdminGame ) { m_AdminGame->SendAdminChat( "[WHISPERED: " + bnet->GetServerAlias( ) + "] [" + user + "] " + message ); if( m_CurrentGame ) m_CurrentGame->SendLocalAdminChat( "[WHISPERED: " + bnet->GetServerAlias( ) + "] [" + user + "] " + message ); for( vector<CBaseGame *> :: iterator i = m_Games.begin( ); i != m_Games.end( ); i++ ) (*i)->SendLocalAdminChat( "[WHISPERED: " + bnet->GetServerAlias( ) + "] [" + user + "] " + message ); } } void CGHost :: EventBNETCHANNELFULL( CBNET *bnet, string user, string message ) { if( m_AdminGame ) { m_AdminGame->SendAdminChat( "[BNET: " + bnet->GetServerAlias( ) + "] channel is full" ); if( m_CurrentGame ) m_CurrentGame->SendLocalAdminChat( "[BNET: " + bnet->GetServerAlias( ) + "] channel is full" ); for( vector<CBaseGame *> :: iterator i = m_Games.begin( ); i != m_Games.end( ); i++ ) (*i)->SendLocalAdminChat( "[BNET: " + bnet->GetServerAlias( ) + "] channel is full" ); } } void CGHost :: EventBNETCHANNELDOESNOTEXIST( CBNET *bnet, string user, string message ) { if( m_AdminGame ) { m_AdminGame->SendAdminChat( "[BNET: " + bnet->GetServerAlias( ) + "] channel does not exist" ); if( m_CurrentGame ) m_CurrentGame->SendLocalAdminChat( "[BNET: " + bnet->GetServerAlias( ) + "] channel does not exist" ); for( vector<CBaseGame *> :: iterator i = m_Games.begin( ); i != m_Games.end( ); i++ ) (*i)->SendLocalAdminChat( "[BNET: " + bnet->GetServerAlias( ) + "] channel does not exist" ); } } void CGHost :: EventBNETCHANNELRESTRICTED( CBNET *bnet, string user, string message ) { if( m_AdminGame ) { m_AdminGame->SendAdminChat( "[BNET: " + bnet->GetServerAlias( ) + "] channel restricted" ); if( m_CurrentGame ) m_CurrentGame->SendLocalAdminChat( "[BNET: " + bnet->GetServerAlias( ) + "] channel restricted" ); for( vector<CBaseGame *> :: iterator i = m_Games.begin( ); i != m_Games.end( ); i++ ) (*i)->SendLocalAdminChat( "[BNET: " + bnet->GetServerAlias( ) + "] channel restricted" ); } } void CGHost :: EventBNETError( CBNET *bnet, string user, string message ) { if( m_AdminGame ) { m_AdminGame->SendAdminChat( "[ERROR: " + bnet->GetServerAlias( ) + "] " + message ); if( m_CurrentGame ) m_CurrentGame->SendLocalAdminChat( "[ERROR: " + bnet->GetServerAlias( ) + "] " + message ); for( vector<CBaseGame *> :: iterator i = m_Games.begin( ); i != m_Games.end( ); i++ ) (*i)->SendLocalAdminChat( "[ERROR: " + bnet->GetServerAlias( ) + "] " + message ); } } void CGHost :: EventBNETEmote( CBNET *bnet, string user, string message ) { if( m_AdminGame ) { m_AdminGame->SendAdminChat( "[E: " + bnet->GetServerAlias( ) + "] [" + user + "] " + message ); if( m_CurrentGame ) m_CurrentGame->SendLocalAdminChat( "[E: " + bnet->GetServerAlias( ) + "] [" + user + "] " + message ); for( vector<CBaseGame *> :: iterator i = m_Games.begin( ); i != m_Games.end( ); i++ ) (*i)->SendLocalAdminChat( "[E: " + bnet->GetServerAlias( ) + "] [" + user + "] " + message ); } } void CGHost :: EventGameDeleted( CBaseGame *game ) { for( vector<CBNET *> :: iterator i = m_BNETs.begin( ); i != m_BNETs.end( ); i++ ) { (*i)->QueueChatCommand( m_Language->GameIsOver( game->GetDescription( ) ) ); if( (*i)->GetServer( ) == game->GetCreatorServer( ) ) (*i)->QueueChatCommand( m_Language->GameIsOver( game->GetDescription( ) ), game->GetCreatorName( ), true, false); } } void CGHost :: EventBNETInfo( CBNET *bnet, string user, string message ) { if( m_AdminGame ) { m_AdminGame->SendAdminChat( "[INFO: " + bnet->GetServerAlias( ) + "] " + message ); if( m_CurrentGame ) m_CurrentGame->SendLocalAdminChat( "[INFO: " + bnet->GetServerAlias( ) + "] " + message ); for( vector<CBaseGame *> :: iterator i = m_Games.begin( ); i != m_Games.end( ); i++ ) (*i)->SendLocalAdminChat( "[INFO: " + bnet->GetServerAlias( ) + "] " + message ); } } void CGHost :: ReloadConfigs( ) { CConfig CFG; CFG.Read( "default.cfg" ); CFG.Read( gCFGFile ); SetConfigs( &CFG ); } void CGHost :: SetConfigs( CConfig *CFG ) { // this doesn't set EVERY config value since that would potentially require reconfiguring the battle.net connections // it just set the easily reloadable values m_LanguageFile = CFG->GetString( "bot_language", "language.cfg" ); delete m_Language; m_Language = new CLanguage( m_LanguageFile ); m_Warcraft3Path = UTIL_AddPathSeperator( CFG->GetString( "bot_war3path", "C:\\Program Files\\Warcraft III\\" ) ); m_BindAddress = CFG->GetString( "bot_bindaddress", string( ) ); m_ReconnectWaitTime = CFG->GetInt( "bot_reconnectwaittime", 3 ); m_MaxGames = CFG->GetInt( "bot_maxgames", 5 ); string BotCommandTrigger = CFG->GetString( "bot_commandtrigger", "!" ); if( BotCommandTrigger.empty( ) ) BotCommandTrigger = "!"; m_CommandTrigger = BotCommandTrigger[0]; m_MapCFGPath = UTIL_AddPathSeperator( CFG->GetString( "bot_mapcfgpath", string( ) ) ); m_SaveGamePath = UTIL_AddPathSeperator( CFG->GetString( "bot_savegamepath", string( ) ) ); m_MapPath = UTIL_AddPathSeperator( CFG->GetString( "bot_mappath", string( ) ) ); m_SaveReplays = CFG->GetInt( "bot_savereplays", 0 ) == 0 ? false : true; m_ReplayPath = UTIL_AddPathSeperator( CFG->GetString( "bot_replaypath", string( ) ) ); m_VirtualHostName = CFG->GetString( "bot_virtualhostname", "|cFF4080C0GHost" ); m_HideIPAddresses = CFG->GetInt( "bot_hideipaddresses", 0 ) == 0 ? false : true; m_CheckMultipleIPUsage = CFG->GetInt( "bot_checkmultipleipusage", 1 ) == 0 ? false : true; if( m_VirtualHostName.size( ) > 15 ) { m_VirtualHostName = "|cFF4080C0GHost"; CONSOLE_Print( "[GHOST] warning - bot_virtualhostname is longer than 15 characters, using default virtual host name" ); } m_SpoofChecks = CFG->GetInt( "bot_spoofchecks", 2 ); m_RequireSpoofChecks = CFG->GetInt( "bot_requirespoofchecks", 0 ) == 0 ? false : true; m_ReserveAdmins = CFG->GetInt( "bot_reserveadmins", 1 ) == 0 ? false : true; m_RefreshMessages = CFG->GetInt( "bot_refreshmessages", 0 ) == 0 ? false : true; m_AutoLock = CFG->GetInt( "bot_autolock", 0 ) == 0 ? false : true; m_AutoSave = CFG->GetInt( "bot_autosave", 0 ) == 0 ? false : true; m_AllowDownloads = CFG->GetInt( "bot_allowdownloads", 0 ); m_PingDuringDownloads = CFG->GetInt( "bot_pingduringdownloads", 0 ) == 0 ? false : true; m_MaxDownloaders = CFG->GetInt( "bot_maxdownloaders", 3 ); m_MaxDownloadSpeed = CFG->GetInt( "bot_maxdownloadspeed", 100 ); m_LCPings = CFG->GetInt( "bot_lcpings", 1 ) == 0 ? false : true; m_AutoKickPing = CFG->GetInt( "bot_autokickping", 400 ); m_BanMethod = CFG->GetInt( "bot_banmethod", 1 ); m_IPBlackListFile = CFG->GetString( "bot_ipblacklistfile", "ipblacklist.txt" ); m_LobbyTimeLimit = CFG->GetInt( "bot_lobbytimelimit", 10 ); m_Latency = CFG->GetInt( "bot_latency", 100 ); m_SyncLimit = CFG->GetInt( "bot_synclimit", 50 ); m_VoteKickAllowed = CFG->GetInt( "bot_votekickallowed", 1 ) == 0 ? false : true; m_VoteKickPercentage = CFG->GetInt( "bot_votekickpercentage", 100 ); if( m_VoteKickPercentage > 100 ) { m_VoteKickPercentage = 100; CONSOLE_Print( "[GHOST] warning - bot_votekickpercentage is greater than 100, using 100 instead" ); } m_MOTDFile = CFG->GetString( "bot_motdfile", "motd.txt" ); m_GameLoadedFile = CFG->GetString( "bot_gameloadedfile", "gameloaded.txt" ); m_GameOverFile = CFG->GetString( "bot_gameoverfile", "gameover.txt" ); m_LocalAdminMessages = CFG->GetInt( "bot_localadminmessages", 1 ) == 0 ? false : true; m_TCPNoDelay = CFG->GetInt( "tcp_nodelay", 0 ) == 0 ? false : true; m_MatchMakingMethod = CFG->GetInt( "bot_matchmakingmethod", 1 ); //GHost Custom Reloadable CFG Values m_ApprovedCountries = CFG->GetString( "bot_approvedcountries", string( )); m_LANAdmins = CFG->GetInt( "lan_admins", 0 ); m_UseNormalCountDown = CFG->GetInt( "bot_usenormalcountdown",0) == 0 ? false : true; m_GetLANRootAdmins = CFG->GetInt( "lan_getrootadmins", 1) == 0 ? false : true; m_LANRootAdmin = CFG->GetString( "lan_rootadmins", string( ) ); m_ResetDownloads = CFG->GetInt( "bot_resetdownloads", 0) == 0 ? false : true; m_AllowDownloads2 = m_AllowDownloads; m_HideCommands = CFG->GetInt( "bot_hideadmincommands", 0) == 0 ? false : true; m_WhisperResponses = CFG->GetInt( "bot_whisperresponses", 0) == 0 ? false : true; m_ForceLoadInGame = CFG->GetInt( "bot_forceloadingame", 0 ) == 0 ? false : true; m_HCLCommandFromGameName = CFG->GetInt( "bot_hclfromgamename", 0 ) == 0 ? false : true; } void CGHost :: ExtractScripts( ) { string PatchMPQFileName = m_Warcraft3Path + "War3Patch.mpq"; HANDLE PatchMPQ; if( SFileOpenArchive( PatchMPQFileName.c_str( ), 0, MPQ_OPEN_FORCE_MPQ_V1, &PatchMPQ ) ) { CONSOLE_Print( "[GHOST] loading MPQ file [" + PatchMPQFileName + "]" ); HANDLE SubFile; // common.j if( SFileOpenFileEx( PatchMPQ, "Scripts\\common.j", 0, &SubFile ) ) { uint32_t FileLength = SFileGetFileSize( SubFile, NULL ); if( FileLength > 0 && FileLength != 0xFFFFFFFF ) { char *SubFileData = new char[FileLength]; DWORD BytesRead = 0; if( SFileReadFile( SubFile, SubFileData, FileLength, &BytesRead ) ) { CONSOLE_Print( "[GHOST] extracting Scripts\\common.j from MPQ file to [" + m_MapCFGPath + "common.j]" ); UTIL_FileWrite( m_MapCFGPath + "common.j", (unsigned char *)SubFileData, BytesRead ); } else CONSOLE_Print( "[GHOST] warning - unable to extract Scripts\\common.j from MPQ file" ); delete [] SubFileData; } SFileCloseFile( SubFile ); } else CONSOLE_Print( "[GHOST] couldn't find Scripts\\common.j in MPQ file" ); // blizzard.j if( SFileOpenFileEx( PatchMPQ, "Scripts\\blizzard.j", 0, &SubFile ) ) { uint32_t FileLength = SFileGetFileSize( SubFile, NULL ); if( FileLength > 0 && FileLength != 0xFFFFFFFF ) { char *SubFileData = new char[FileLength]; DWORD BytesRead = 0; if( SFileReadFile( SubFile, SubFileData, FileLength, &BytesRead ) ) { CONSOLE_Print( "[GHOST] extracting Scripts\\blizzard.j from MPQ file to [" + m_MapCFGPath + "blizzard.j]" ); UTIL_FileWrite( m_MapCFGPath + "blizzard.j", (unsigned char *)SubFileData, BytesRead ); } else CONSOLE_Print( "[GHOST] warning - unable to extract Scripts\\blizzard.j from MPQ file" ); delete [] SubFileData; } SFileCloseFile( SubFile ); } else CONSOLE_Print( "[GHOST] couldn't find Scripts\\blizzard.j in MPQ file" ); SFileCloseArchive( PatchMPQ ); } else CONSOLE_Print( "[GHOST] warning - unable to load MPQ file [" + PatchMPQFileName + "] - error code " + UTIL_ToString( GetLastError( ) ) ); } void CGHost :: LoadIPToCountryData( ) { ifstream in; in.open( "ip-to-country.csv" ); if( in.fail( ) ) CONSOLE_Print( "[GHOST] warning - unable to read file [ip-to-country.csv], iptocountry data not loaded" ); else { CONSOLE_Print( "[GHOST] started loading [ip-to-country.csv]" ); // the begin and commit statements are optimizations // we're about to insert ~4 MB of data into the database so if we allow the database to treat each insert as a transaction it will take a LONG time // todotodo: handle begin/commit failures a bit more gracefully if( !m_DBLocal->Begin( ) ) CONSOLE_Print( "[GHOST] warning - failed to begin local database transaction, iptocountry data not loaded" ); else { unsigned char Percent = 0; string Line; string IP1; string IP2; string Country; CSVParser parser; // get length of file for the progress meter in.seekg( 0, ios :: end ); uint32_t FileLength = in.tellg( ); in.seekg( 0, ios :: beg ); while( !in.eof( ) ) { getline( in, Line ); if( Line.empty( ) ) continue; parser << Line; parser >> IP1; parser >> IP2; parser >> Country; m_DBLocal->FromAdd( UTIL_ToUInt32( IP1 ), UTIL_ToUInt32( IP2 ), Country ); // it's probably going to take awhile to load the iptocountry data (~10 seconds on my 3.2 GHz P4 when using SQLite3) // so let's print a progress meter just to keep the user from getting worried unsigned char NewPercent = (unsigned char)( (float)in.tellg( ) / FileLength * 100 ); if( NewPercent != Percent && NewPercent % 10 == 0 ) { Percent = NewPercent; CONSOLE_Print( "[GHOST] iptocountry data: " + UTIL_ToString( Percent ) + "% loaded" ); } } if( !m_DBLocal->Commit( ) ) CONSOLE_Print( "[GHOST] warning - failed to commit local database transaction, iptocountry data not loaded" ); else CONSOLE_Print( "[GHOST] finished loading [ip-to-country.csv]" ); } in.close( ); } } void CGHost :: CreateGame( CMap *map, unsigned char gameState, bool saveGame, string gameName, string ownerName, string creatorName, string creatorServer, bool whisper ) { if( !m_Enabled ) { for( vector<CBNET *> :: iterator i = m_BNETs.begin( ); i != m_BNETs.end( ); i++ ) { if( (*i)->GetServer( ) == creatorServer ) (*i)->QueueChatCommand( m_Language->UnableToCreateGameDisabled( gameName ), creatorName, whisper, false ); } if( m_AdminGame ) m_AdminGame->SendAllChat( m_Language->UnableToCreateGameDisabled( gameName ) ); return; } if( gameName.size( ) > 31 ) { for( vector<CBNET *> :: iterator i = m_BNETs.begin( ); i != m_BNETs.end( ); i++ ) { if( (*i)->GetServer( ) == creatorServer ) (*i)->QueueChatCommand( m_Language->UnableToCreateGameNameTooLong( gameName ), creatorName, whisper, false ); } if( m_AdminGame ) m_AdminGame->SendAllChat( m_Language->UnableToCreateGameNameTooLong( gameName ) ); return; } if( !map->GetValid( ) ) { for( vector<CBNET *> :: iterator i = m_BNETs.begin( ); i != m_BNETs.end( ); i++ ) { if( (*i)->GetServer( ) == creatorServer ) (*i)->QueueChatCommand( m_Language->UnableToCreateGameInvalidMap( gameName ), creatorName, whisper, false ); } if( m_AdminGame ) m_AdminGame->SendAllChat( m_Language->UnableToCreateGameInvalidMap( gameName ) ); return; } if( saveGame ) { if( !m_SaveGame->GetValid( ) ) { for( vector<CBNET *> :: iterator i = m_BNETs.begin( ); i != m_BNETs.end( ); i++ ) { if( (*i)->GetServer( ) == creatorServer ) (*i)->QueueChatCommand( m_Language->UnableToCreateGameInvalidSaveGame( gameName ), creatorName, whisper, false ); } if( m_AdminGame ) m_AdminGame->SendAllChat( m_Language->UnableToCreateGameInvalidSaveGame( gameName ) ); return; } string MapPath1 = m_SaveGame->GetMapPath( ); string MapPath2 = map->GetMapPath( ); transform( MapPath1.begin( ), MapPath1.end( ), MapPath1.begin( ), (int(*)(int))tolower ); transform( MapPath2.begin( ), MapPath2.end( ), MapPath2.begin( ), (int(*)(int))tolower ); if( MapPath1 != MapPath2 ) { CONSOLE_Print( "[GHOST] path mismatch, saved game path is [" + MapPath1 + "] but map path is [" + MapPath2 + "]" ); for( vector<CBNET *> :: iterator i = m_BNETs.begin( ); i != m_BNETs.end( ); i++ ) { if( (*i)->GetServer( ) == creatorServer ) (*i)->QueueChatCommand( m_Language->UnableToCreateGameSaveGameMapMismatch( gameName ), creatorName, whisper, false ); } if( m_AdminGame ) m_AdminGame->SendAllChat( m_Language->UnableToCreateGameSaveGameMapMismatch( gameName ) ); return; } if( m_EnforcePlayers.empty( ) ) { for( vector<CBNET *> :: iterator i = m_BNETs.begin( ); i != m_BNETs.end( ); i++ ) { if( (*i)->GetServer( ) == creatorServer ) (*i)->QueueChatCommand( m_Language->UnableToCreateGameMustEnforceFirst( gameName ), creatorName, whisper, false ); } if( m_AdminGame ) m_AdminGame->SendAllChat( m_Language->UnableToCreateGameMustEnforceFirst( gameName ) ); return; } } if( m_CurrentGame ) { for( vector<CBNET *> :: iterator i = m_BNETs.begin( ); i != m_BNETs.end( ); i++ ) { if( (*i)->GetServer( ) == creatorServer ) (*i)->QueueChatCommand( m_Language->UnableToCreateGameAnotherGameInLobby( gameName, m_CurrentGame->GetDescription( ) ), creatorName, whisper, false ); } if( m_AdminGame ) m_AdminGame->SendAllChat( m_Language->UnableToCreateGameAnotherGameInLobby( gameName, m_CurrentGame->GetDescription( ) ) ); return; } if( m_Games.size( ) >= m_MaxGames ) { for( vector<CBNET *> :: iterator i = m_BNETs.begin( ); i != m_BNETs.end( ); i++ ) { if( (*i)->GetServer( ) == creatorServer ) (*i)->QueueChatCommand( m_Language->UnableToCreateGameMaxGamesReached( gameName, UTIL_ToString( m_MaxGames ) ), creatorName, whisper, false ); } if( m_AdminGame ) m_AdminGame->SendAllChat( m_Language->UnableToCreateGameMaxGamesReached( gameName, UTIL_ToString( m_MaxGames ) ) ); return; } CONSOLE_Print( "[GHOST] creating game [" + gameName + "]" ); if( saveGame ) m_CurrentGame = new CGame( this, map, m_SaveGame, m_HostPort, gameState, gameName, ownerName, creatorName, creatorServer ); else m_CurrentGame = new CGame( this, map, NULL, m_HostPort, gameState, gameName, ownerName, creatorName, creatorServer ); // todotodo: check if listening failed and report the error to the user if( m_SaveGame ) { m_CurrentGame->SetEnforcePlayers( m_EnforcePlayers ); m_EnforcePlayers.clear( ); } // auto set HCL if map_defaulthcl is not empty m_CurrentGame->AutoSetHCL(); for( vector<CBNET *> :: iterator i = m_BNETs.begin( ); i != m_BNETs.end( ); i++ ) { if( whisper && (*i)->GetServer( ) == creatorServer ) { // note that we send this whisper only on the creator server if( gameState == GAME_PRIVATE ) (*i)->QueueChatCommand( m_Language->CreatingPrivateGame( gameName, ownerName ), creatorName, whisper, false ); else if( gameState == GAME_PUBLIC ) (*i)->QueueChatCommand( m_Language->CreatingPublicGame( gameName, ownerName ), creatorName, whisper, false ); } else { // note that we send this chat message on all other bnet servers if( gameState == GAME_PRIVATE ) (*i)->QueueChatCommand( m_Language->CreatingPrivateGame( gameName, ownerName ) ); else if( gameState == GAME_PUBLIC ) (*i)->QueueChatCommand( m_Language->CreatingPublicGame( gameName, ownerName ) ); } if( saveGame ) (*i)->QueueGameCreate( gameState, gameName, string( ), map, m_SaveGame, m_CurrentGame->GetHostCounter( ) ); else (*i)->QueueGameCreate( gameState, gameName, string( ), map, NULL, m_CurrentGame->GetHostCounter( ) ); } if( m_AdminGame ) { if( gameState == GAME_PRIVATE ) m_AdminGame->SendAllChat( m_Language->CreatingPrivateGame( gameName, ownerName ) ); else if( gameState == GAME_PUBLIC ) m_AdminGame->SendAllChat( m_Language->CreatingPublicGame( gameName, ownerName ) ); } // if we're creating a private game we don't need to send any game refresh messages so we can rejoin the chat immediately // unfortunately this doesn't work on PVPGN servers because they consider an enterchat message to be a gameuncreate message when in a game // so don't rejoin the chat if we're using PVPGN if( gameState == GAME_PRIVATE ) { for( vector<CBNET *> :: iterator i = m_BNETs.begin( ); i != m_BNETs.end( ); i++ ) { if( (*i)->GetPasswordHashType( ) != "pvpgn" ) (*i)->QueueEnterChat( ); } } // hold friends and/or clan members for( vector<CBNET *> :: iterator i = m_BNETs.begin( ); i != m_BNETs.end( ); i++ ) { if( (*i)->GetHoldFriends( ) ) (*i)->HoldFriends( m_CurrentGame ); if( (*i)->GetHoldClan( ) ) (*i)->HoldClan( m_CurrentGame ); } }
[ [ [ 1, 1927 ] ] ]
05d559aae63767aa2d9930013bd151c4aa7f3873
1271dc8f6e3006f5c3a77ea2804bad2c0ef13301
/src/main.cpp
43f18668ef5fc6044aeb02540677baf48abe00f7
[]
no_license
cybertk/opencv-line-detector
298a94ebc217b2d0527c75fb42fa468c74f9e021
9878c64498efb9af5b6aad45e9c3d890d9dfafac
refs/heads/master
2016-09-16T05:57:14.590466
2011-12-03T17:50:44
2011-12-03T17:50:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,202
cpp
/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information ([email protected]) ** ** This file is part of the examples 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$ ** ****************************************************************************/ #include <QApplication> #include "screenshot.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); Screenshot screenshot; screenshot.show(); //QM return app.exec(); }
[ [ [ 1, 53 ] ] ]
0feab14f257430c8bbcc85c0c9fc5a047872e0a0
1775576281b8c24b5ce36b8685bc2c6919b35770
/tags/release_1.01/trunk/tex_browser.cpp
d02bfb25ad1cfd96d3bdaf5b37069dbedd4ea171
[]
no_license
BackupTheBerlios/gtkslade-svn
933a1268545eaa62087f387c057548e03497b412
03890e3ba1735efbcccaf7ea7609d393670699c1
refs/heads/master
2016-09-06T18:35:25.336234
2006-01-01T11:05:50
2006-01-01T11:05:50
40,615,146
0
0
null
null
null
null
UTF-8
C++
false
false
11,083
cpp
#include "main.h" #include "textures.h" #include "tex_box.h" #include "map.h" #include "draw.h" #include <gdk/gdkkeysyms.h> bool browse_sprites = false; string selected_tex = ""; string tex_search = ""; int rows = 0; vector<string> tex_names; vector<string> browsesprites; GtkWidget *browse_vscroll; GtkWidget *browser_dialog; CVAR(Int, browser_columns, 6, CVAR_SAVE) extern GtkWidget *editor_window; extern vector<Texture*> textures; extern vector<Texture*> flats; extern vector<Texture*> sprites; extern GdkGLConfig *glconfig; extern GdkGLContext *glcontext; extern rgba_t col_selbox; extern rgba_t col_selbox_line; extern bool mix_tex; void scroll_to_selected_texture(GtkWidget* w) { int width = (w->allocation.width / browser_columns); int top = gtk_range_get_value(GTK_RANGE(browse_vscroll)); int bottom = top + w->allocation.height; int a = 0; for (int y = 0; y < rows; y++) { for (int x = 0; x < browser_columns; x++) { if (browse_sprites) { if (browsesprites[a] == selected_tex) { if (y * width < top) gtk_range_set_value(GTK_RANGE(browse_vscroll), y * width); if ((y+1) * width > bottom) gtk_range_set_value(GTK_RANGE(browse_vscroll), ((y+1) * width) - w->allocation.height); return; } } else { if (tex_names[a] == selected_tex) { if (y * width < top) gtk_range_set_value(GTK_RANGE(browse_vscroll), y * width); if ((y+1) * width > bottom) gtk_range_set_value(GTK_RANGE(browse_vscroll), ((y+1) * width) - w->allocation.height); return; } } a++; if (a >= tex_names.size()) return; } } } gboolean browser_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) { GdkGLContext *context = gtk_widget_get_gl_context(widget); GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(widget); if (!gdk_gl_drawable_gl_begin(gldrawable, context)) return false; glViewport(0, 0, widget->allocation.width, widget->allocation.height); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_CULL_FACE); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0f, widget->allocation.width, widget->allocation.height, 0.0f, -1.0f, 1.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gdk_gl_drawable_gl_end(gldrawable); rows = (tex_names.size() / browser_columns) + 1; int width = widget->allocation.width / browser_columns; int rows_page = widget->allocation.height / width; gtk_range_set_range(GTK_RANGE(browse_vscroll), 0.0, (rows * width) - widget->allocation.height); scroll_to_selected_texture(widget); return true; } gboolean browser_expose_event(GtkWidget *w, GdkEventExpose *event, gpointer data) { int width = w->allocation.width / browser_columns; rows = (tex_names.size() / browser_columns) + 1; int top = gtk_range_get_value(GTK_RANGE(browse_vscroll)); // Set sizes for row and page steps (for the scrollbar) int rows_page = w->allocation.height / width; gtk_range_set_increments(GTK_RANGE(browse_vscroll), width, rows_page * width); GdkGLContext *context = gtk_widget_get_gl_context(w); GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(w); if (!gdk_gl_drawable_gl_begin(gldrawable, context)) return false; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); int sel_index = -1; int a = 0; for (int row = 0; row < rows; row++) { for (int col = 0; col < browser_columns; col++) { if (a >= tex_names.size()) continue; rect_t rect(col * width, (row * width) - top, width, width, 0); glLineWidth(2.0f); if (selected_tex == tex_names[a]) { draw_rect(rect, rgba_t(0, 180, 255, 150, 0), true); draw_rect(rect, rgba_t(100, 220, 255, 255, 0), false); sel_index = a; } glLineWidth(1.0f); rect.resize(-8, -8); if (((row + 1) * width) > top && (row * width) < (top + w->allocation.height)) { if (!browse_sprites) { if (tex_names[a] != "-") draw_texture_scale(rect, tex_names[a], 0); draw_text(rect.x1() + (width/2) - 8, rect.y2() - 4, rgba_t(255, 255, 255, 255, 0), 1, tex_names[a].c_str()); } else draw_texture_scale(rect, browsesprites[a], 3); } a++; } } if (browse_sprites && sel_index != -1) draw_text(0, 0, rgba_t(255, 255, 255, 255, 0), 0, tex_names[sel_index].c_str()); if (gdk_gl_drawable_is_double_buffered(gldrawable)) gdk_gl_drawable_swap_buffers(gldrawable); else glFlush(); gdk_gl_drawable_gl_end(gldrawable); return false; } gboolean browse_vscroll_change(GtkRange *range, GtkScrollType scroll, gdouble value, gpointer data) { GtkWidget *draw_area = (GtkWidget*)data; gdk_window_invalidate_rect(draw_area->window, &draw_area->allocation, false); return false; } gboolean browser_scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer user_data) { int width = (widget->allocation.width / browser_columns) / 2; int top = gtk_range_get_value(GTK_RANGE(browse_vscroll)); if (event->direction == GDK_SCROLL_UP) gtk_range_set_value(GTK_RANGE(browse_vscroll), top - width); else if (event->direction = GDK_SCROLL_DOWN) gtk_range_set_value(GTK_RANGE(browse_vscroll), top + width); gdk_window_invalidate_rect(widget->window, &widget->allocation, false); return false; } static gboolean browser_click_event(GtkWidget *widget, GdkEventButton *event) { int width = widget->allocation.width / browser_columns; if (event->button == 1) { if (event->type == GDK_2BUTTON_PRESS) gtk_dialog_response(GTK_DIALOG(browser_dialog), GTK_RESPONSE_ACCEPT); else { int row = (gtk_range_get_value(GTK_RANGE(browse_vscroll)) + event->y) / width; int col = event->x / width; int index = (row * browser_columns) + col; if (index < tex_names.size()) selected_tex = tex_names[index]; gdk_window_invalidate_rect(widget->window, &widget->allocation, false); } } return false; } gboolean browser_key_event(GtkWidget *widget, GdkEventKey *event) { char key = gdk_keyval_name(event->keyval)[0]; int index = 0; for (int a = 0; a < tex_names.size(); a++) { if (tex_names[a] == selected_tex) index = a; } if (event->keyval == GDK_Return) gtk_dialog_response(GTK_DIALOG(browser_dialog), GTK_RESPONSE_ACCEPT); if (event->keyval == GDK_Up && index - browser_columns >= 0) index -= browser_columns; if (event->keyval == GDK_Left && index > 0) index--; if (event->keyval == GDK_Right && index < tex_names.size() - 1) index++; if (event->keyval == GDK_Down && index < tex_names.size() - browser_columns) index += browser_columns; selected_tex = tex_names[index]; scroll_to_selected_texture(widget); gdk_window_invalidate_rect(widget->window, &widget->allocation, false); return true; } void browser_search_entry_changed(GtkWidget *w, gpointer data) { string search = g_strup((gchar*)gtk_entry_get_text(GTK_ENTRY(w))); for (int a = 0; a < tex_names.size(); a++) { if (tex_names[a].size() < search.size()) continue; bool match = true; for (int c = 0; c < search.size(); c++) { if (tex_names[a][c] != search[c]) match = false; } if (match) { selected_tex = tex_names[a]; scroll_to_selected_texture(GTK_WIDGET(data)); gdk_window_invalidate_rect(GTK_WIDGET(data)->window, &GTK_WIDGET(data)->allocation, false); return; } } } GtkWidget* setup_texture_browser() { GtkWidget *hbox = gtk_hbox_new(false, 0); GtkWidget *draw_area = gtk_drawing_area_new(); GTK_WIDGET_SET_FLAGS(draw_area, GTK_CAN_FOCUS); gtk_widget_set_gl_capability(draw_area, glconfig, glcontext, TRUE, GDK_GL_RGBA_TYPE); gtk_widget_set_events(draw_area, GDK_EXPOSURE_MASK|GDK_LEAVE_NOTIFY_MASK|GDK_BUTTON_PRESS_MASK); g_signal_connect(G_OBJECT(draw_area), "expose-event", G_CALLBACK(browser_expose_event), NULL); g_signal_connect(G_OBJECT(draw_area), "configure-event", G_CALLBACK(browser_configure_event), NULL); g_signal_connect(G_OBJECT(draw_area), "button_press_event", G_CALLBACK(browser_click_event), NULL); g_signal_connect(G_OBJECT(draw_area), "scroll-event", G_CALLBACK(browser_scroll_event), NULL); g_signal_connect(G_OBJECT(draw_area), "key_press_event", G_CALLBACK(browser_key_event), NULL); gtk_box_pack_start(GTK_BOX(hbox), draw_area, true, true, 0); browse_vscroll = gtk_vscrollbar_new(NULL); gtk_range_set_range(GTK_RANGE(browse_vscroll), 0.0, 1.0); g_signal_connect(G_OBJECT(browse_vscroll), "change-value", G_CALLBACK(browse_vscroll_change), draw_area); gtk_box_pack_start(GTK_BOX(hbox), browse_vscroll, false, false, 0); GtkWidget *vbox = gtk_vbox_new(false, 0); gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); gtk_box_pack_start(GTK_BOX(hbox), vbox, false, false, 0); // 'search' entry GtkWidget *entry = gtk_entry_new(); gtk_widget_set_size_request(entry, 64, -1); g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(browser_search_entry_changed), draw_area); gtk_box_pack_start(GTK_BOX(vbox), gtk_label_new("Search:"), false, false, 0); gtk_box_pack_start(GTK_BOX(vbox), entry, false, false, 0); gtk_widget_grab_focus(draw_area); return hbox; } string open_texture_browser(bool tex, bool flat, bool sprite, string init_tex, bool fullscreen) { tex_names.clear(); browsesprites.clear(); selected_tex = init_tex; browse_sprites = sprite; if (!sprite) { tex_names.push_back("-"); if (tex || mix_tex) { for (int a = 0; a < textures.size(); a++) tex_names.push_back(textures[a]->name); } if (flat || mix_tex) { for (int a = 0; a < flats.size(); a++) tex_names.push_back(flats[a]->name); } // Sort alphabetically for now sort(tex_names.begin(), tex_names.end()); } else { get_ttype_names(&tex_names); for (int a = 0; a < tex_names.size(); a++) browsesprites.push_back(get_thing_type_from_name(tex_names[a])->spritename); } browser_dialog = gtk_dialog_new_with_buttons("Textures", GTK_WINDOW(editor_window), GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(browser_dialog)->vbox), setup_texture_browser()); gtk_window_set_position(GTK_WINDOW(browser_dialog), GTK_WIN_POS_CENTER_ON_PARENT); gtk_window_set_default_size(GTK_WINDOW(browser_dialog), 640, 480); gtk_widget_show_all(browser_dialog); if (fullscreen) gtk_window_fullscreen(GTK_WINDOW(browser_dialog)); string ret = init_tex; int response = gtk_dialog_run(GTK_DIALOG(browser_dialog)); if (response == GTK_RESPONSE_ACCEPT) ret = selected_tex; gtk_widget_destroy(browser_dialog); gtk_window_present(GTK_WINDOW(editor_window)); return ret; }
[ "veilofsorrow@0f6d0948-3201-0410-bbe6-95a89488c5be" ]
[ [ [ 1, 385 ] ] ]
afe8afb6dcb4f88da154e179a6a4eb0695745dcf
c86338cfb9a65230aa7773639eb8f0a3ce9d34fd
/CameraModel.h
96a6f481e7c8e5ba72fd250732c410e88b19c7d1
[]
no_license
jonike/mnrt
2319fb48d544d58984d40d63dc0b349ffcbfd1dd
99b41c3deb75aad52afd0c315635f1ca9b9923ec
refs/heads/master
2021-08-24T05:52:41.056070
2010-12-03T18:31:24
2010-12-03T18:31:24
113,554,148
0
0
null
null
null
null
UTF-8
C++
false
false
12,911
h
//////////////////////////////////////////////////////////////////////////////////////////////////// // MNRT License //////////////////////////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2010 Mathias Neumann, www.maneumann.com. // 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 Mathias Neumann, nor the names of 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. //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// /// \file MNRT\CameraModel.h /// /// \brief Declares the CameraModel class. /// \ingroup core //////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef __MN_CAMERAMODEL_H__ #define __MN_CAMERAMODEL_H__ #pragma once #include "Geometry/MNGeometry.h" //////////////////////////////////////////////////////////////////////////////////////////////////// /// \class CameraModel /// /// \brief A simple camera model for MNRT. /// /// Basically, a LookAt()-approach is taken. That is, the user specifies the camera's /// orientation using eye and look-at points and up direction. Additionally, the field of /// view angle and the near and far clipping distances can be set. The class supports two /// rotation methods and WASD keyboard movement. To pass camera information to kernels, /// MNTransform objects can be generated. They can be passed to kernels in form of 4x4 /// matrices. /// /// \author Mathias Neumann /// \date 31.01.2010 //////////////////////////////////////////////////////////////////////////////////////////////////// class CameraModel { public: //////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn CameraModel(void) /// /// \brief Default constructor. /// /// Calls /// /// \code LookAt(MNPoint3(0.f, 0.f, -10.f), MNPoint3(0.f, 0.f, 0.f), MNVector3(0.f, 1.f, 0.f)); \endcode /// /// and sets FOV to 75 degree and clip distances to \c 0.3f and ::MN_INFINITY. /// /// \author Mathias Neumann /// \date 31.01.2010 //////////////////////////////////////////////////////////////////////////////////////////////////// CameraModel(void); ~CameraModel(void); private: /// Eye position (world space). MNPoint3 m_ptEye; /// Look at position (world space). MNPoint3 m_ptLookAt; /// Up direction (normalized). MNVector3 m_vecUp; /// \brief Initial up direction (normalized). /// /// Set when calling LookAt(). This direction can be used to fix the left /// and right rotation around this initial up direction. It confirms to the /// default behaviour of the camera in games. MNVector3 m_vecInitialUp; /// \brief View direction (normalized). /// /// Derived from eye and look-at position. MNVector3 m_vecViewDir; /// \brief Screen dimension in pixels (screen space). /// /// Used for raster to camera space transformation. uint m_screenW, m_screenH; /// \brief "Normalized" screen extent. /// /// Stores extent of screen in normalized coordinates, scaled by aspect ratio. /// See \ref lit_pharr "[Pharr and Humphreys 2004]" for details. float m_ScreenExtent[4]; /// FOV angle (radians). float m_fFOV; /// Near clip distance (hither). float m_fClipHither; /// Far clip distance (yon). float m_fClipYon; /// If set, the initial up direction is used for left and right rotation. bool m_bUseInitialUp; public: //////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn void LookAt(MNPoint3 ptEye, MNPoint3 ptLookAt, MNVector3 vecUp) /// /// \brief Sets the camera's position and orientation. /// /// \author Mathias Neumann /// \date 31.01.2010 /// /// \param ptEye Eye position in world space. /// \param ptLookAt Look-at position in world space. /// \param vecUp The up direction. Can be unnormalized, but may not be zero. //////////////////////////////////////////////////////////////////////////////////////////////////// void LookAt(MNPoint3 ptEye, MNPoint3 ptLookAt, MNVector3 vecUp); /// Returns the current eye position in world space. MNPoint3 GetEye() const { return m_ptEye; } /// Returns the current look-at position in world space. MNPoint3 GetLookAt() const { return m_ptLookAt; } /// Returns the current up direction (normalized). MNVector3 GetUp() const { return m_vecUp; } /// Returns the current viewing direction (normalized). MNVector3 GetViewDirection() const { return m_vecViewDir; } //////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn MNTransform GetCamera2World() const /// /// \brief Computes and returns the camera space to world space transformation. /// /// Camera space is the space with the camera's eye at the origin, the z axis as the /// viewing direction and the y axis as up direction. /// /// \author Mathias Neumann /// \date March 2010 /// \see MNTransform::LookAt(), MNTransform::Inverse() /// /// \return The transformation. //////////////////////////////////////////////////////////////////////////////////////////////////// MNTransform GetCamera2World() const; //////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn MNTransform GetRaster2Camera() const /// /// \brief Computes and returns the raster space to camera space transformation. /// /// Raster space is a two-dimensional space where x and y coordinates range from 0 to /// the corresponding image resolution (screen dimension). /// /// \author Mathias Neumann /// \date March 2010 /// /// \return The transformation. //////////////////////////////////////////////////////////////////////////////////////////////////// MNTransform GetRaster2Camera() const; //////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn void SetScreenDimension(uint screenW, uint screenH) /// /// \brief Sets the screen's dimension or resolution. /// /// \author Mathias Neumann /// \date March 2010 /// /// \param screenW Screen width in pixels. /// \param screenH Screen height in pixels. //////////////////////////////////////////////////////////////////////////////////////////////////// void SetScreenDimension(uint screenW, uint screenH); /// Returns the screen's width in pixels. uint GetScreenWidth() const { return m_screenW; } /// Returns the screen's height in pixels. uint GetScreenHeight() const { return m_screenH; } //////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn void SetFOV(float fov_rad) /// /// \brief Sets the field of view (FOV) angle. /// /// \author Mathias Neumann /// \date March 2010 /// /// \param fov_rad FOV angle in radians. Has to be positive and smaller than ::MN_PI. //////////////////////////////////////////////////////////////////////////////////////////////////// void SetFOV(float fov_rad); /// Returns the current field of view (FOV) angle. float GetFOV() const { return m_fFOV; } //////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn void SetClipDistances(float clipHither, float clipYon) /// /// \brief Sets clipping plane distances. /// /// The clipping planes define the z-axis range of space that will be visible in the /// generated image. All scene contents within this camera space range will be projected /// onto the image plane at z = \a clipHither. /// /// \author Mathias Neumann /// \date 31.01.2010 /// /// \param clipHither Distance to near clipping plane. /// \param clipYon Distance to far clipping plane. //////////////////////////////////////////////////////////////////////////////////////////////////// void SetClipDistances(float clipHither, float clipYon); /// Returns near (hither) clipping plane distance on camera space z-axis. float GetClipHither() const { return m_fClipHither; } /// Returns far (yon) clipping plane distance on camera space z-axis. float GetClipYon() const { return m_fClipYon; } /// Sets whether to use the initial up direction for left/right rotation within RotateAroundFixedEye(). void SetUseInitialUp(bool bSet) { m_bUseInitialUp = bSet; } /// Gets whether the initial up direction is used for left/right rotation within RotateAroundFixedEye(). bool GetUseInitialUp() const { return m_bUseInitialUp; } //////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn void RotateAroundAt(float angleLR_rad, float angleUD_rad) /// /// \brief Performs an orbital rotation around the look-at position. The look-at position is fixed. /// /// \author Mathias Neumann /// \date Februrary 2010 /// /// \param angleLR_rad The left/right rotation angle in radians. /// \param angleUD_rad The up/down rotation angle in radians. //////////////////////////////////////////////////////////////////////////////////////////////////// void RotateAroundAt(float angleLR_rad, float angleUD_rad); //////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn void RotateAroundFixedEye(float angleLR_rad, float angleUD_rad) /// /// \brief Rotates the camera with fixed exe position. /// /// This corresponds to the rotation used in computer games, especially when /// rotation is performed around initial up direction (see SetUseInitialUp()). /// /// \author Mathias Neumann /// \date Februrary 2010 /// /// \param angleLR_rad The left/right rotation angle in radians. /// \param angleUD_rad The up/down rotation angle in radians. //////////////////////////////////////////////////////////////////////////////////////////////////// void RotateAroundFixedEye(float angleLR_rad, float angleUD_rad); //////////////////////////////////////////////////////////////////////////////////////////////////// /// \fn bool ProcessKey(int key_ASCII, float fTransFactor = 0.01f) /// /// \brief Processes keyboard input for WASD camera movement. /// /// Very simple camera movement (i.e. eye and look-at position translation) using the /// following keys: /// /// \li \c w: Move camera forward along viewing direction. /// \li \c a: Move camera to the left (strafing). /// \li \c s: Move camera backward along viewing direction. /// \li \c d: Move camera to the right (strafing). /// /// All other keyboard inputs are ignored. /// /// \author Mathias Neumann /// \date Februrary 2010 /// /// \param key_ASCII The ASCII key code to process. /// \param fTransFactor The translation factor. Simple way to adjust camera translation speed. /// /// \return \c true if the key was used to change the camera's parameters, else \c false. //////////////////////////////////////////////////////////////////////////////////////////////////// bool ProcessKey(int key_ASCII, float fTransFactor = 0.01f); private: void TransformView(const MNTransform& trans); MNTransform Perspective(float fov, float n, float f) const; }; #endif //__MN_CAMERAMODEL_H__
[ [ [ 1, 290 ] ] ]
7bf6bb725113e2137e06db096078306529f4a657
3977ae61b891f7e8ae7d75b8e22bcb63dedc3c1c
/Base/Gui/Source/MenuFormInterface/MasterFormMenuController.cpp
8cab47ba88edc0ab16fabcfc7b5128581c6971e0
[]
no_license
jayrulez/ourprs
9734915b69207e7c3382412ca8647b051a787bb1
9d10f7a6edb06483015ed11dcfc9785f63b7204b
refs/heads/master
2020-05-17T11:40:55.001049
2010-03-25T05:20:04
2010-03-25T05:20:04
40,554,502
0
0
null
null
null
null
UTF-8
C++
false
false
32,357
cpp
#include "MasterFormMenuController.h" #include "../Form/Field.h" #include "../Menu/MenuController.h" #include "../Form/FormController.h" #include "../Menu/Menus/MenuSet.h" #include "../Form/FormController.h" #include "../Form/FormSet/FormSet.h" #include "../Menu/Menus/Extended/ExtendedMenuController.h" #include "../Services/Services.h" MasterFormMenuController::MasterFormMenuController() { FormSize=0; } MasterFormMenuController::~MasterFormMenuController() { } MenuController MasterFormMenuController::GetMenuController() { return MenuControllerObj; } Field* MasterFormMenuController::GetAllFieldData() { return FieldObj; } void MasterFormMenuController::SetAllFieldData(Field *NewField) { FormControllerObj.UpdateAllFieldInfo(NewField); } int MasterFormMenuController::GetFormSize() { return FormSize; } void MasterFormMenuController::ClearAllFieldData() { FormControllerObj.ClearAllFieldData(); } void MasterFormMenuController::SetYRelativeSystemFrame(int y) { this->YRelativeSystemFrame=y; } /* * Main Menu */ int MasterFormMenuController::MainMenu() { int MenuCall; bool Flag; if(MenuControllerObj.SetMenu(MenuSetObj.MainMenu(),MenuSetObj.GetMenuSize(MenuSetObj.MainMenu()), MenuSetObj.GetMenuCode(MenuSetObj.MainMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(ExtendedMenuControllerObj.ExtendedMenuCalls(MenuCall,MenuControllerObj.GetMenuCode())) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); Flag=true; } }while(Flag); }while(MenuCall==0); } return MenuCall; } /* * Department Menu */ int MasterFormMenuController::DepartmentMenu() { bool Flag; int MenuCall; if(MenuControllerObj.SetMenu(MenuSetObj.DepartmentMenu(),MenuSetObj.GetMenuSize(MenuSetObj.DepartmentMenu()), MenuSetObj.GetMenuCode(MenuSetObj.DepartmentMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(ExtendedMenuControllerObj.ExtendedMenuCalls(MenuCall,MenuControllerObj.GetMenuCode())) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); Flag=true; } }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::AddDepartmentMenu() { bool Flag; int MenuCall; if(FormControllerObj.SetForm(FormSetObj.AddDepartmentForm(),FormSetObj.GetFormSize(FormSetObj.AddDepartmentForm()), FormSetObj.GetFormCode(FormSetObj.AddDepartmentForm()))&& MenuControllerObj.SetMenu(MenuSetObj.AddDepartmentFormMenu(),MenuSetObj.GetMenuSize(MenuSetObj.AddDepartmentFormMenu()), MenuSetObj.GetMenuCode(MenuSetObj.AddDepartmentFormMenu()))) { FormControllerObj.ShowForm(); MenuControllerObj.ShowMenu(); MenuSetObj.ShowMenuTitle(ON); MenuSetObj.AddDepartmentFormMenuExtension(ON); do { FormControllerObj.BrowseForm(); do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(MenuCall==DEPARTMENT_ADD_SAVE_CODE&&FormControllerObj.GetFormCompletionState()==_FAIL) { Flag=true; } if(MenuCall==DEPARTMENT_CODE||MenuCall==MAIN_CODE) { this->ClearAllFieldData(); } if(MenuCall==DEPARTMENT_ADD_RESET_CODE) { this->ClearAllFieldData(); ServicesObj.BasicRunLevel(); FormControllerObj.ShowForm(); MenuControllerObj.ShowMenu(); MenuSetObj.ShowMenuTitle(ON); MenuSetObj.AddDepartmentFormMenuExtension(ON); Flag=true; } }while(Flag); }while(MenuCall==0); } this->FieldObj=FormControllerObj.GetAllFieldInfo(); this->FormSize=FormControllerObj.GetFormSize(); return MenuCall; } int MasterFormMenuController::UpdateSearchDepartmentMenu() { bool Flag; int MenuCall; if(FormControllerObj.SetForm(FormSetObj.SearchDepartmentForm(),FormSetObj.GetFormSize(FormSetObj.SearchDepartmentForm()), FormSetObj.GetFormCode(FormSetObj.SearchDepartmentForm()))&& MenuControllerObj.SetMenu(MenuSetObj.UpdateSearchDepartmentFormMenu(),MenuSetObj.GetMenuSize(MenuSetObj.UpdateSearchDepartmentFormMenu()), MenuSetObj.GetMenuCode(MenuSetObj.UpdateSearchDepartmentFormMenu()))) { FormControllerObj.ShowForm(); MenuControllerObj.ShowMenu(); MenuSetObj.ShowMenuTitle(ON); MenuSetObj.SearchDepartmentFormMenuExtension(ON); do { FormControllerObj.BrowseForm(); do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(MenuCall==DEPARTMENT_CODE||MenuCall==MAIN_CODE) { this->ClearAllFieldData(); } }while(Flag); }while(MenuCall==0); } this->FieldObj=FormControllerObj.GetAllFieldInfo(); this->FormSize=FormControllerObj.GetFormSize(); return MenuCall; } int MasterFormMenuController::UpdateDepartmentMenu() { bool Flag; int MenuCall; if(FormControllerObj.SetForm(FormSetObj.UpdateDepartmentForm(),FormSetObj.GetFormSize(FormSetObj.UpdateDepartmentForm()), FormSetObj.GetFormCode(FormSetObj.UpdateDepartmentForm()))&& MenuControllerObj.SetMenu(MenuSetObj.UpdateDepartmentFormMenu(),MenuSetObj.GetMenuSize(MenuSetObj.UpdateDepartmentFormMenu()), MenuSetObj.GetMenuCode(MenuSetObj.UpdateDepartmentFormMenu()))) { /* Field *ptr=FormControllerObj.GetAllFieldInfo(); cout<<"["<<(ptr+2)->GetFieldData()<<"]"; system("pause"); */ FormControllerObj.ShowForm(); MenuControllerObj.ShowMenu(); MenuSetObj.ShowMenuTitle(ON); MenuSetObj.UpdateDepartmentFormMenuExtension(ON); do { FormControllerObj.BrowseForm(); do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(MenuCall==DEPARTMENT_UPDATE_SAVE_CODE&&FormControllerObj.GetFormCompletionState()==_FAIL) { Flag=true; } if(MenuCall==MAIN_CODE) { FormSetObj.FlushFieldData(FormSetObj.SearchDepartmentForm()); } }while(Flag); }while(MenuCall==0); } this->FieldObj=FormControllerObj.GetAllFieldInfo(); this->FormSize=FormControllerObj.GetFormSize(); return MenuCall; } int MasterFormMenuController::ViewSearchDepartmentMenu() { bool Flag; int MenuCall; if(FormControllerObj.SetForm(FormSetObj.SearchDepartmentForm(),FormSetObj.GetFormSize(FormSetObj.SearchDepartmentForm()), FormSetObj.GetFormCode(FormSetObj.SearchDepartmentForm()))&& MenuControllerObj.SetMenu(MenuSetObj.ViewSearchDepartmentFormMenu(),MenuSetObj.GetMenuSize(MenuSetObj.ViewSearchDepartmentFormMenu()), MenuSetObj.GetMenuCode(MenuSetObj.ViewSearchDepartmentFormMenu()))) { FormControllerObj.ShowForm(); MenuControllerObj.ShowMenu(); MenuSetObj.ShowMenuTitle(ON); MenuSetObj.SearchDepartmentFormMenuExtension(ON); do { FormControllerObj.BrowseForm(); do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(MenuCall==MAIN_CODE || MenuCall==DEPARTMENT_CODE) { FormSetObj.FlushFieldData(FormSetObj.SearchDepartmentForm()); } }while(Flag); }while(MenuCall==0); } this->FieldObj=FormControllerObj.GetAllFieldInfo(); this->FormSize=FormControllerObj.GetFormSize(); return MenuCall; } int MasterFormMenuController::DepartmentAfterViewMenu() { int MenuCall; bool Flag; if(MenuControllerObj.SetMenu(MenuSetObj.DepartmentAfterViewMenu(),MenuSetObj.GetMenuSize(MenuSetObj.DepartmentAfterViewMenu()), MenuSetObj.GetMenuCode(MenuSetObj.DepartmentAfterViewMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); }while(Flag); }while(MenuCall==0); } FormSetObj.FlushFieldData(FormSetObj.SearchDepartmentForm()); return MenuCall; } int MasterFormMenuController::ViewAllDepartmentMenu() { int MenuCall; bool Flag; MenuSetObj.SetYRelativeSystemFrame(YRelativeSystemFrame); if(MenuControllerObj.SetMenu(MenuSetObj.ViewAllDepartmentMenu(),MenuSetObj.GetMenuSize(MenuSetObj.ViewAllDepartmentMenu()), MenuSetObj.GetMenuCode(MenuSetObj.ViewAllDepartmentMenu()))) MenuControllerObj.ShowMenu(); MenuSetObj.ViewAllDepartmentMenuExtension(ON); MenuSetObj.ShowMenuTitle(ON); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); }while(Flag); }while(MenuCall==0); return MenuCall; } int MasterFormMenuController::AddDepartmentAfterSaveMenu() { int MenuCall; bool Flag; if(MenuControllerObj.SetMenu(MenuSetObj.AddDepartmentAfterSaveMenu(),MenuSetObj.GetMenuSize(MenuSetObj.AddDepartmentAfterSaveMenu()), MenuSetObj.GetMenuCode(MenuSetObj.AddDepartmentAfterSaveMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(MenuCall==MAIN_CODE || MenuCall==DEPARTMENT_CODE || MenuCall==DEPARTMENT_ADD_CODE) { FormSetObj.FlushFieldData(FormSetObj.AddDepartmentForm()); } }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::AddDepartmentFailSaveMenu() { int MenuCall; bool Flag; if(MenuControllerObj.SetMenu(MenuSetObj.AddDepartmentFailSaveMenu(),MenuSetObj.GetMenuSize(MenuSetObj.AddDepartmentFailSaveMenu()), MenuSetObj.GetMenuCode(MenuSetObj.AddDepartmentFailSaveMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(MenuCall==MAIN_CODE || MenuCall==DEPARTMENT_CODE) { FormSetObj.FlushFieldData(FormSetObj.AddDepartmentForm()); } }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::UpdateDepartmentAfterSaveMenu() { int MenuCall; bool Flag; if(MenuControllerObj.SetMenu(MenuSetObj.UpdateDepartmentAfterSaveMenu(),MenuSetObj.GetMenuSize(MenuSetObj.UpdateDepartmentAfterSaveMenu()), MenuSetObj.GetMenuCode(MenuSetObj.UpdateDepartmentAfterSaveMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::UpdateDepartmentFailSaveMenu() { int MenuCall; bool Flag; if(MenuControllerObj.SetMenu(MenuSetObj.UpdateDepartmentFailSaveMenu(),MenuSetObj.GetMenuSize(MenuSetObj.UpdateDepartmentFailSaveMenu()), MenuSetObj.GetMenuCode(MenuSetObj.UpdateDepartmentFailSaveMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(MenuCall==DEPARTMENT_CODE || MenuCall==MAIN_CODE) { FormSetObj.FlushFieldData(FormSetObj.SearchDepartmentForm()); } }while(Flag); }while(MenuCall==0); } return MenuCall; } /* *Employee Menu */ int MasterFormMenuController::EmployeeMenu() { bool Flag; int MenuCall; if(MenuControllerObj.SetMenu(MenuSetObj.EmployeeMenu(),MenuSetObj.GetMenuSize(MenuSetObj.EmployeeMenu()), MenuSetObj.GetMenuCode(MenuSetObj.EmployeeMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(ExtendedMenuControllerObj.ExtendedMenuCalls(MenuCall,MenuControllerObj.GetMenuCode())) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); Flag=true; } }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::AddEmployeeMenu() { bool Flag; int MenuCall; if(FormControllerObj.SetForm(FormSetObj.AddEmployeeForm(),FormSetObj.GetFormSize(FormSetObj.AddEmployeeForm()), FormSetObj.GetFormCode(FormSetObj.AddEmployeeForm()))&& MenuControllerObj.SetMenu(MenuSetObj.AddEmployeeFormMenu(),MenuSetObj.GetMenuSize(MenuSetObj.AddEmployeeFormMenu()), MenuSetObj.GetMenuCode(MenuSetObj.AddEmployeeFormMenu()))) { FormControllerObj.ShowForm(); MenuControllerObj.ShowMenu(); MenuSetObj.ShowMenuTitle(ON); MenuSetObj.AddEmployeeFormMenuExtension(ON); do { FormControllerObj.BrowseForm(); do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(MenuCall==EMPLOYEE_ADD_SAVE_CODE&&FormControllerObj.GetFormCompletionState()==_FAIL) { Flag=true; } if(MenuCall==EMPLOYEE_ADD_RESET_CODE) { this->ClearAllFieldData(); ServicesObj.BasicRunLevel(); FormControllerObj.ShowForm(); MenuControllerObj.ShowMenu(); MenuSetObj.ShowMenuTitle(ON); MenuSetObj.AddEmployeeFormMenuExtension(ON); Flag=true; } }while(Flag); }while(MenuCall==0); } if(MenuCall==EMPLOYEE_CODE || MenuCall==MAIN_CODE) { FormSetObj.FlushFieldData(FormSetObj.AddEmployeeForm()); } this->FieldObj=FormControllerObj.GetAllFieldInfo(); this->FormSize=FormControllerObj.GetFormSize(); return MenuCall; } int MasterFormMenuController::AddEmployeeAfterSaveMenu() { int MenuCall; bool Flag; if(MenuControllerObj.SetMenu(MenuSetObj.AddEmployeeAfterSaveMenu(),MenuSetObj.GetMenuSize(MenuSetObj.AddEmployeeAfterSaveMenu()), MenuSetObj.GetMenuCode(MenuSetObj.AddEmployeeAfterSaveMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(MenuCall==MAIN_CODE || MenuCall==EMPLOYEE_CODE || MenuCall==EMPLOYEE_ADD_CODE) { FormSetObj.FlushFieldData(FormSetObj.AddEmployeeForm()); } }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::AddEmployeeFailSaveMenu() { int MenuCall; bool Flag; if(MenuControllerObj.SetMenu(MenuSetObj.AddEmployeeFailSaveMenu(),MenuSetObj.GetMenuSize(MenuSetObj.AddEmployeeFailSaveMenu()), MenuSetObj.GetMenuCode(MenuSetObj.AddEmployeeFailSaveMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(MenuCall==MAIN_CODE || MenuCall==EMPLOYEE_CODE) { FormSetObj.FlushFieldData(FormSetObj.AddEmployeeForm()); } }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::SearchEmployeeMenu() { bool Flag; int MenuCall; if(FormControllerObj.SetForm(FormSetObj.SearchEmployeeForm(),FormSetObj.GetFormSize(FormSetObj.SearchEmployeeForm()), FormSetObj.GetFormCode(FormSetObj.SearchEmployeeForm()))&& MenuControllerObj.SetMenu(MenuSetObj.SearchEmployeeFormMenu(),MenuSetObj.GetMenuSize(MenuSetObj.SearchEmployeeFormMenu()), MenuSetObj.GetMenuCode(MenuSetObj.SearchEmployeeFormMenu()))) { FormControllerObj.ShowForm(); MenuControllerObj.ShowMenu(); MenuSetObj.ShowMenuTitle(ON); MenuSetObj.SearchEmployeeFormMenuExtension(ON); do { FormControllerObj.BrowseForm(); do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(MenuCall==MAIN_CODE || MenuCall==EMPLOYEE_CODE) { this->ClearAllFieldData(); } }while(Flag); }while(MenuCall==0); } this->FieldObj=FormControllerObj.GetAllFieldInfo(); this->FormSize=FormControllerObj.GetFormSize(); return MenuCall; } int MasterFormMenuController::UpdateEmployeeMenu() { bool Flag; int MenuCall; if(FormControllerObj.SetForm(FormSetObj.UpdateEmployeeForm(),FormSetObj.GetFormSize(FormSetObj.UpdateEmployeeForm()), FormSetObj.GetFormCode(FormSetObj.UpdateEmployeeForm()))&& MenuControllerObj.SetMenu(MenuSetObj.UpdateEmployeeFormMenu(),MenuSetObj.GetMenuSize(MenuSetObj.UpdateEmployeeFormMenu()), MenuSetObj.GetMenuCode(MenuSetObj.UpdateEmployeeFormMenu()))) { FormControllerObj.ShowForm(); MenuControllerObj.ShowMenu(); MenuSetObj.ShowMenuTitle(ON); MenuSetObj.UpdateDepartmentFormMenuExtension(ON); do { FormControllerObj.BrowseForm(); do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(MenuCall==EMPLOYEE_UPDATE_SAVE_CODE&&FormControllerObj.GetFormCompletionState()==_FAIL) { Flag=true; } }while(Flag); }while(MenuCall==0); } this->FieldObj=FormControllerObj.GetAllFieldInfo(); this->FormSize=FormControllerObj.GetFormSize(); return MenuCall; } int MasterFormMenuController::UpdateEmployeeAfterSaveMenu() { int MenuCall; bool Flag; if(MenuControllerObj.SetMenu(MenuSetObj.UpdateEmployeeAfterSaveMenu(),MenuSetObj.GetMenuSize(MenuSetObj.UpdateEmployeeAfterSaveMenu()), MenuSetObj.GetMenuCode(MenuSetObj.UpdateEmployeeAfterSaveMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::UpdateEmployeeFailSaveMenu() { int MenuCall; bool Flag; if(MenuControllerObj.SetMenu(MenuSetObj.UpdateEmployeeFailSaveMenu(),MenuSetObj.GetMenuSize(MenuSetObj.UpdateEmployeeFailSaveMenu()), MenuSetObj.GetMenuCode(MenuSetObj.UpdateEmployeeFailSaveMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(MenuCall==EMPLOYEE_CODE || MenuCall==MAIN_CODE) { FormSetObj.FlushFieldData(FormSetObj.SearchEmployeeForm()); } }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::EmployeeAfterViewMenu() { int MenuCall; bool Flag; if(MenuControllerObj.SetMenu(MenuSetObj.EmployeeAfterViewMenu(),MenuSetObj.GetMenuSize(MenuSetObj.EmployeeAfterViewMenu()), MenuSetObj.GetMenuCode(MenuSetObj.EmployeeAfterViewMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(MenuCall==MAIN_CODE || MenuCall==EMPLOYEE_VIEW_CODE ||MenuCall==EMPLOYEE_CODE) { FormSetObj.FlushFieldData(FormSetObj.SearchEmployeeForm()); } }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::ViewSortedEmployeeMenu() { bool Flag; int MenuCall; if(MenuControllerObj.SetMenu(MenuSetObj.ViewSortedEmployeeMenu(),MenuSetObj.GetMenuSize(MenuSetObj.ViewSortedEmployeeMenu()), MenuSetObj.GetMenuCode(MenuSetObj.ViewSortedEmployeeMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuSetObj.ViewSortedEmployeeMenuExtension(ON); MenuControllerObj.ShowMenu(); do { do { Flag=false; MenuCall = MenuControllerObj.BrowseMenu(); }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::EmployeeAfterViewSortedMenu() { int MenuCall; bool Flag; MenuSetObj.SetYRelativeSystemFrame(YRelativeSystemFrame); if(MenuControllerObj.SetMenu(MenuSetObj.EmployeeAfterViewSortedMenu(),MenuSetObj.GetMenuSize(MenuSetObj.EmployeeAfterViewSortedMenu()), MenuSetObj.GetMenuCode(MenuSetObj.EmployeeAfterViewSortedMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); MenuSetObj.EmployeeAfterViewSortedMenuExtension(ON); do { do { Flag=false; MenuCall = MenuControllerObj.BrowseMenu(); }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::EmployeeDeleteConfirmMenu() { bool Flag; int MenuCall; if(MenuControllerObj.SetMenu(MenuSetObj.DeleteConfirmEmployeeMenu(),MenuSetObj.GetMenuSize(MenuSetObj.DeleteConfirmEmployeeMenu()), MenuSetObj.GetMenuCode(MenuSetObj.DeleteConfirmEmployeeMenu()))) { MenuControllerObj.ShowMenu(); MenuSetObj.ShowMenuTitle(ON); MenuSetObj.DeleteConfirmEmployeeMenuExtension(ON); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(MenuCall==MAIN_CODE || MenuCall==EMPLOYEE_CODE) { FormSetObj.FlushFieldData(FormSetObj.SearchEmployeeForm()); } }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::EmployeeAfterDeleteMenu() { bool Flag; int MenuCall; if(MenuControllerObj.SetMenu(MenuSetObj.EmployeeAfterDeleteMenu(),MenuSetObj.GetMenuSize(MenuSetObj.EmployeeAfterDeleteMenu()), MenuSetObj.GetMenuCode(MenuSetObj.EmployeeAfterDeleteMenu()))) { MenuControllerObj.ShowMenu(); MenuSetObj.ShowMenuTitle(ON); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(MenuCall==MAIN_CODE || MenuCall==EMPLOYEE_DELETE_CODE ||MenuCall==EMPLOYEE_CODE) { FormSetObj.FlushFieldData(FormSetObj.SearchEmployeeForm()); } }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::EmployeeFailDeleteMenu() { bool Flag; int MenuCall; if(MenuControllerObj.SetMenu(MenuSetObj.EmployeeFailDeleteMenu(),MenuSetObj.GetMenuSize(MenuSetObj.EmployeeFailDeleteMenu()), MenuSetObj.GetMenuCode(MenuSetObj.EmployeeFailDeleteMenu()))) { MenuControllerObj.ShowMenu(); MenuSetObj.ShowMenuTitle(ON); MenuSetObj.ViewEmployeeMenuExtension(ON); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(MenuCall==MAIN_CODE || MenuCall==EMPLOYEE_CODE) { FormSetObj.FlushFieldData(FormSetObj.SearchEmployeeForm()); } }while(Flag); }while(MenuCall==0); } return MenuCall; } /* * Payroll Menu */ int MasterFormMenuController::PayrollMenu() { bool Flag; int MenuCall; if(MenuControllerObj.SetMenu(MenuSetObj.PayrollMenu(),MenuSetObj.GetMenuSize(MenuSetObj.PayrollMenu()), MenuSetObj.GetMenuCode(MenuSetObj.PayrollMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(ExtendedMenuControllerObj.ExtendedMenuCalls(MenuCall,MenuControllerObj.GetMenuCode())) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); Flag=true; } }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::PayrollAfterProcessMenu() { bool Flag; int MenuCall; if(MenuControllerObj.SetMenu(MenuSetObj.PayrollAfterGenerateMenu(),MenuSetObj.GetMenuSize(MenuSetObj.PayrollAfterGenerateMenu()), MenuSetObj.GetMenuCode(MenuSetObj.PayrollAfterGenerateMenu()))) { MenuControllerObj.ShowMenu(); MenuSetObj.ShowMenuTitle(ON); do { do { Flag=false; MenuCall = MenuControllerObj.BrowseMenu(); }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::PayrollFailProcessMenu() { bool Flag; int MenuCall; if(MenuControllerObj.SetMenu(MenuSetObj.PayrollFailGenerateMenu(),MenuSetObj.GetMenuSize(MenuSetObj.PayrollFailGenerateMenu()), MenuSetObj.GetMenuCode(MenuSetObj.PayrollFailGenerateMenu()))) {MenuSetObj.SetYRelativeSystemFrame(YRelativeSystemFrame); MenuControllerObj.ShowMenu(); MenuSetObj.ShowMenuTitle(ON); do { do { Flag=false; MenuCall = MenuControllerObj.BrowseMenu(); }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::ViewPayrollMenu() { bool Flag; int MenuCall; if(MenuControllerObj.SetMenu(MenuSetObj.ViewPayrollMenu(),MenuSetObj.GetMenuSize(MenuSetObj.ViewPayrollMenu()), MenuSetObj.GetMenuCode(MenuSetObj.ViewPayrollMenu()))) { MenuControllerObj.ShowMenu(); MenuSetObj.ShowMenuTitle(ON); do { do { Flag=false; MenuCall= MenuControllerObj.BrowseMenu(); if(MenuCall==MAIN_CODE || MenuCall==PAYROLL_CODE || MenuCall==PAYROLL_VIEW_CODE) { FormSetObj.FlushFieldData(FormSetObj.SearchPayrollForm()); } }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::SearchPayrollMenu() { bool Flag; int MenuCall; if(FormControllerObj.SetForm(FormSetObj.SearchPayrollForm(),FormSetObj.GetFormSize(FormSetObj.SearchPayrollForm()), FormSetObj.GetFormCode(FormSetObj.SearchPayrollForm()))&& MenuControllerObj.SetMenu(MenuSetObj.SearchPayrollFormMenu(),MenuSetObj.GetMenuSize(MenuSetObj.SearchPayrollFormMenu()), MenuSetObj.GetMenuCode(MenuSetObj.SearchPayrollFormMenu()))) { FormControllerObj.ShowForm(); MenuControllerObj.ShowMenu(); MenuSetObj.ShowMenuTitle(ON); MenuSetObj.SearchPayrollFormMenuExtension(ON); do { FormControllerObj.BrowseForm(); do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); if(MenuCall==MAIN_CODE || MenuCall==PAYROLL_CODE) { FormSetObj.FlushFieldData(FormSetObj.SearchPayrollForm()); } }while(Flag); }while(MenuCall==0); } this->FieldObj=FormControllerObj.GetAllFieldInfo(); this->FormSize=FormControllerObj.GetFormSize(); return MenuCall; } int MasterFormMenuController::ViewSortedPayrollMenu() { bool Flag; int MenuCall; if(MenuControllerObj.SetMenu(MenuSetObj.ViewSortedPayrollMenu(),MenuSetObj.GetMenuSize(MenuSetObj.ViewSortedPayrollMenu()), MenuSetObj.GetMenuCode(MenuSetObj.ViewSortedPayrollMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuSetObj.ViewSortedPayrollMenuExtension(ON); MenuControllerObj.ShowMenu(); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::PayrollAfterViewSortedMenu() { bool Flag; int MenuCall; MenuSetObj.SetYRelativeSystemFrame(YRelativeSystemFrame); if(MenuControllerObj.SetMenu(MenuSetObj.PayrollAfterViewSortedMenu(),MenuSetObj.GetMenuSize(MenuSetObj.PayrollAfterViewSortedMenu()), MenuSetObj.GetMenuCode(MenuSetObj.PayrollAfterViewSortedMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuControllerObj.ShowMenu(); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); }while(Flag); }while(MenuCall==0); } return MenuCall; } int MasterFormMenuController::PayrollFailViewSortedMenu() { bool Flag; int MenuCall; if(MenuControllerObj.SetMenu(MenuSetObj.PayrollFailViewSortedMenu(),MenuSetObj.GetMenuSize(MenuSetObj.PayrollFailViewSortedMenu()), MenuSetObj.GetMenuCode(MenuSetObj.PayrollFailViewSortedMenu()))) { MenuSetObj.ShowMenuTitle(ON); MenuSetObj.ViewSortedPayrollMenuExtension(ON); MenuControllerObj.ShowMenu(); do { do { Flag=false; MenuCall=MenuControllerObj.BrowseMenu(); }while(Flag); }while(MenuCall==0); } return MenuCall; } /* * Exit Menu */ int MasterFormMenuController::ExitMenu() { int MenuCall = EXIT_CODE; return MenuCall; }
[ "portmore.representa@c48e7a12-1f02-11df-8982-67e453f37615", "[email protected]" ]
[ [ [ 1, 290 ], [ 306, 309 ], [ 315, 944 ], [ 946, 947 ] ], [ [ 291, 305 ], [ 310, 314 ], [ 945, 945 ] ] ]
a9b995d01a92d117df273f1ab3f0c6cb3ddcfb44
21dd1ece27a68047f93bac2bdf9e6603827b1990
/CppUTest/tests/SetPluginTest.cpp
2e893b735f0626a0c8c6d058b5639337458acbd1
[]
no_license
LupusDei/8LU-DSP
c626ce817b6b178c226c437537426f25597958a5
65860326bb89a36ff71871b046642b7dd45d5607
refs/heads/master
2021-01-17T21:51:19.971505
2010-09-24T15:08:01
2010-09-24T15:08:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,526
cpp
#include "CppUTest/TestHarness.h" #include "CppUTest/TestRegistry.h" #include "CppUTest/TestOutput.h" #include "CppUTest/TestPlugin.h" void orig_func1 () {}; void stub_func1 () {}; void orig_func2 () {}; void stub_func2 () {}; void (*fp1)(); void (*fp2)(); TEST_GROUP(SetPointerPluginTest) { SetPointerPlugin* plugin; TestRegistry* myRegistry; StringBufferTestOutput* output; TestResult* result; void setup() { myRegistry = new TestRegistry(); plugin = new SetPointerPlugin("TestSetPlugin"); myRegistry->setCurrentRegistry(myRegistry); myRegistry->installPlugin(plugin); output = new StringBufferTestOutput(); result = new TestResult(*output); } void teardown() { myRegistry->setCurrentRegistry(0); delete myRegistry; delete plugin; delete output; delete result; } }; class FunctionPointerUtest : public Utest { public: void setup() { UT_PTR_SET(fp1, stub_func1); UT_PTR_SET(fp2, stub_func2); UT_PTR_SET(fp2, stub_func2); } void testBody() { CHECK(fp1 == stub_func1); CHECK(fp2 == stub_func2); } }; TEST(SetPointerPluginTest, installTwoFunctionPointer) { FunctionPointerUtest *tst = new FunctionPointerUtest();; fp1 = orig_func1; fp2 = orig_func2; myRegistry->addTest(tst); myRegistry->runAllTests(*result); CHECK(fp1 == orig_func1); CHECK(fp2 == orig_func2); LONGS_EQUAL(0, result->getFailureCount()); delete tst; } class MaxFunctionPointerUtest : public Utest { public: int numOfFpSets; MaxFunctionPointerUtest (int num) : numOfFpSets(num) {}; void setup() { for (int i = 0; i < numOfFpSets; ++i) UT_PTR_SET(fp1, stub_func1); } }; IGNORE_TEST(SetPointerPluginTest, installTooMuchFunctionPointer) { MaxFunctionPointerUtest *tst = new MaxFunctionPointerUtest(SetPointerPlugin::MAX_SET + 1); myRegistry->addTest(tst); myRegistry->runAllTests(*result); LONGS_EQUAL(1, result->getFailureCount()); delete tst; } double orig_double = 3.0; double* orig_double_ptr = &orig_double; double stub_double = 4.0; class SetDoublePointerUtest : public Utest { public: void setup() { UT_PTR_SET(orig_double_ptr, &stub_double); } void testBody() { CHECK(orig_double_ptr == &stub_double); } }; TEST(SetPointerPluginTest, doublePointer) { SetDoublePointerUtest *doubletst = new SetDoublePointerUtest(); myRegistry->addTest(doubletst); CHECK(orig_double_ptr == &orig_double); delete doubletst; }
[ [ [ 1, 119 ] ] ]
64ca415bf92710400fa53097f1f71a2a3c539e85
f2b4a9d938244916aa4377d4d15e0e2a6f65a345
/Game/Dlg_WitchHut.h
0455d9f2b37b260b7c29799be053c179e8393a48
[ "Apache-2.0" ]
permissive
notpushkin/palm-heroes
d4523798c813b6d1f872be2c88282161cb9bee0b
9313ea9a2948526eaed7a4d0c8ed2292a90a4966
refs/heads/master
2021-05-31T19:10:39.270939
2010-07-25T12:25:00
2010-07-25T12:25:00
62,046,865
2
1
null
null
null
null
UTF-8
C++
false
false
1,272
h
/* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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 _HMM_GAME_WITCH_HUT_DIALOG_H_ #define _HMM_GAME_WITCH_HUT_DIALOG_H_ class iWitchHutDlg : public iBaseGameDlg { public: iWitchHutDlg(iViewMgr* pViewMgr, SECONDARY_SKILLS skill, PLAYER_ID pid); void OnCreateDlg(); protected: void DoCompose(const iRect& clRect); iSize ClientSize() const; private: void iCMDH_ControlCommand(iView* pView, CTRL_CMD_ID cmd, sint32 param); protected: SECONDARY_SKILLS m_skill; }; #endif //_HMM_GAME_WITCH_HUT_DIALOG_H_
[ "palmheroesteam@2c21ad19-eed7-4c86-9350-8a7669309276" ]
[ [ [ 1, 42 ] ] ]
26e736ded2e6b92b352581c24329e9fd13bb5ff4
bd89d3607e32d7ebb8898f5e2d3445d524010850
/connectivitylayer/isce/isirouter_dll/inc/misiif.h
6502342692eced4ab8372d1a80a78427e211d5af
[]
no_license
wannaphong/symbian-incubation-projects.fcl-modemadaptation
9b9c61ba714ca8a786db01afda8f5a066420c0db
0e6894da14b3b096cffe0182cedecc9b6dac7b8d
refs/heads/master
2021-05-30T05:09:10.980036
2010-10-19T10:16:20
2010-10-19T10:16:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,271
h
/* * Copyright (c) 2009 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: * */ #ifndef __ISIIF_H__ #define __ISIIF_H__ // Forward declarations #ifdef __KERNEL_MODE__ class TDfc; #endif /** * Class MISIIf defines an abstract interface for ISA entities. * Interface is used to transceive ISI messages between ISA entities. */ class MISIIf { public: #ifdef __KERNEL_MODE__ /** * Returns a free block for sending ISI messages. Blocks descriptor length is set * to zero, but maximum length can be more than size given as parameter. * Interface shall be created before with MISIIf::NewISIIf or Kern::Fault raised. * Fault is raised if no free blocks left. * Responsibility to deallocate the block is transferred to caller. * Execution: Synchronous * Re-entrant: No * Blocking: Yes * Panic mode: Kern::Fault * SMP safe: Yes * @param aSize, minimum size of the buffer in bytes. * @return TDes8&, reference to allocated block. * @pre Called always in kernel thread context. * @pre No fastmutex held. * @pre Called with interrupts enabled and kernel unlocked. * @post Calling thread not blocked. */ virtual TDes8& AllocateMsgBlock( const TUint16 aSize ) = 0; /** * Deallocates the ISI message block retrieved with MISIIf::Receive. * After deallocation set pointer to NULL. Interface shall be created * before with MISIIf::NewISIIf or Kern::Fault raised. ISI message shall * be received before with MISIIf::Receive. * Execution: Synchronous * Re-entrant: No * Blocking: Yes * Panic mode: Kern::Fault * SMP safe: Yes * @param aMsgBlock, reference to block to deallocate. * @pre Called always in kernel thread context. * @pre No fastmutex held. * @pre Called with interrupts enabled and kernel unlocked. * @post Calling thread not blocked. */ virtual void DeallocateMsgBlock( TDes8& aMsgBlock ) = 0; #endif /** * Creates a new ISI interface. * Interface must be released with MISIIf::Release. * If no memory available panics. When same UID already used Kern::Fault raised. * Execution: Synchronous * Re-entrant: Yes * Blocking: No * Panic mode: Kernel: Kern::Fault, User: User::Panic * SMP safe: Yes * @param aUID, clients unique UID identifier. TODO: Symbian UID * @param aObjId, reference to write clients object id. * @return pointer to new interface. * @pre Called always in thread context (Kernel: in kernel thread context). * @pre No fastmutex held. (Kernel only) * @post Calling thread not blocked. */ IMPORT_C static MISIIf* NewISIIf( const TInt32 aUID, TUint8& aObjId ); /** * Receive an ISI message from other ISA entity. Interface shall be created * before with MISIIf::NewISIIf or panic raised. Receive shall always be * pending after interface is created. * Execution: Asynchronous * Re-entrant: No * Blocking: Yes * Panic mode: Kernel: Kern::Fault, User: User::Panic * SMP safe: Yes * @param aRxStatus, updated when receive either succesful or failed. KErrNone, receive succesful. KErrCancel, outstanding request is cancelled. KErrOverflow, not enough memory to store the message. * @param aRxMsg, reference to store received message (Kernel only pointer reference). * @param aNeededBufLen, if receive buffer too short correct lenght is written to this (User only). * @param aRxCompletedDfc, DFC executed when receive is completed (Kernel only). * @pre Called always in thread context (Kernel: in kernel thread context). * @pre No fastmutex held (Kernel only). * @post Calling thread not blocked. */ virtual void Receive( TRequestStatus& aRxStatus, #ifndef __KERNEL_MODE__ TDes8& aRxMsg, TUint16& aNeededBufLen #else TDes8*& aRxMsg, const TDfc& aRxCompletedDfc #endif ) = 0; /** * Cancels the pending receive request with KErrCancel. * If the request is not pending anymore does nothing. * Automatically called in MISIIf::Release. Interface shall be created * before with MISIIf::NewISIIf or panic raised. * Execution: Synchronous * Re-entrant: No * Blocking: Yes * Panic mode: Kernel: Kern::Fault, User: User::Panic * SMP safe: Yes * @pre Called always in kernel thread context. * @pre No fastmutex held (Kernel only). * @pre Called with interrupts enabled and kernel unlocked (Kernel only). * @post Calling thread not blocked. */ virtual void ReceiveCancel() = 0; /** * Deletes the concret object of the interface and releases reserved resources. * Cancels pending receive request. Caller is responsible to set the interface pointer to NULL. * In case of User::Panic called automatically. * Execution: Synchronous * Re-entrant: No * Blocking: Yes * Panic mode: Kernel: Kern::Fault, User: User::Panic * SMP safe: Yes * @pre Called always in kernel thread context. * @pre No fastmutex held (Kernel only). * @pre Called with interrupts enabled and kernel unlocked (Kernel only). * @post Calling thread not blocked. */ virtual void Release() = 0; /** * Send ISI message to other ISA entity. Interface shall be created before * with MISIIf::NewISIIf or panic raised. * Execution: Synchronous * Re-entrant: No * Blocking: Yes * Panic mode: Kernel: Kern::Fault, User: User::Panic * SMP safe: Yes * @param aTxMsg, ISI message to be send. * @return success code of the operation. KErrNone, send succesful. KErrOverflow, too long message tried to send. * @pre Called always in thread context (Kernel: in kernel thread context). * @pre No fastmutex held (Kernel only). * @post Calling thread not blocked. */ virtual TInt Send( const TDesC8& aTxMsg ) = 0; }; #endif // _ISIIF_H_ // End of File
[ "dalarub@localhost", "mikaruus@localhost" ]
[ [ [ 1, 86 ], [ 88, 185 ] ], [ [ 87, 87 ] ] ]
83aa14810ade0e9455ddedbc71c2a7048a01ceda
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/nGENE Proj/PhysXMapping.h
e4d807ac04e435119f8b87f8be34942a7a603e5c
[]
no_license
svn2github/ngene
b2cddacf7ec035aa681d5b8989feab3383dac012
61850134a354816161859fe86c2907c8e73dc113
refs/heads/master
2023-09-03T12:34:18.944872
2011-07-27T19:26:04
2011-07-27T19:26:04
78,163,390
2
0
null
null
null
null
UTF-8
C++
false
false
2,182
h
/* --------------------------------------------------------------------------- This source file is part of nGENE Tech. Copyright (c) 2006- Wojciech Toman This program is free software. File: PhysXMapping.h Version: 0.05 --------------------------------------------------------------------------- */ #pragma once #ifndef __INC_PHYSXMAPPING_H_ #define __INC_PHYSXMAPPING_H_ #include "Prerequisities.h" #include "PrerequisitiesPhysX.h" #include "Quaternion.h" namespace nGENE { /** Provides conversions between nGENE Tech and Ageia PhysX types. @remarks These conversions are necessary as nGENE uses its own conventions which are not entirely compatible with those of PhysX. */ class PhysXMapping { public: /// Converts PhysX NxVec3 into nGENE's Vector3. static Vector3 nxVec3ToVector3(const NxVec3& _vec); /// Converts PhysX NxExtendedVec3 into nGENE's Vector3. static Vector3 nxVec3ToVector3(const NxExtendedVec3& _vec); /// Converts nGENE Vector3 to NxVec3 of PhysX. static NxVec3 vector3ToNxVec3(const Vector3& _vec); /// Converts nGENE Vector3 to NxExtendedVec3 of PhysX. static NxExtendedVec3 vector3ToNxExtendedVec3(const Vector3& _vec); /// Converts nGENE Matrix3x3 to NxMat33 of PhysX. static NxMat33 matrix3x3ToNxMat33(const Matrix3x3& _mat); /// Converts nGENE Matrix4x4 to NxMat34 of PhysX. static NxMat34 matrix4x4ToNxMat34(const Matrix4x4& _mat); /// Converts PhysX NxQuat into nGENE's Quaternion. static Quaternion nxQuatToQuaternion(const NxQuat& _quat); /// Converts nGENE Quaternion to NxQuat of PhysX. static NxQuat quaternionToNxQuat(const Quaternion& _quat); /// Converts between FORCE_FIELD_INTERACTION and NxForceField enums. static NxForceFieldType ffiToNxForceFieldType(const FORCE_FIELD_INTERACTION& _interaction); /// Converts between FORCE_FIELD_COORDINATES and NxForceFieldCoordinates. static NxForceFieldCoordinates ffcToNxForceFieldCoordinates(const FORCE_FIELD_COORDINATES& _coordinates); /// Converts between FORCE_FIELD_VOLUME_SCALING and uint. static uint ffvsToNxForceFieldFlags(uint _scaling); }; } #endif
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 66 ] ] ]
2af5af6c7e2f438ec699a4ef6f497d5422414d03
854ee643a4e4d0b7a202fce237ee76b6930315ec
/arcemu_svn/src/sun/src/InstanceScripts/GenericAI.cpp
9d28cad7cb3ea9bc67519a874c2b176f22220cf0
[]
no_license
miklasiak/projekt
df37fa82cf2d4a91c2073f41609bec8b2f23cf66
064402da950555bf88609e98b7256d4dc0af248a
refs/heads/master
2021-01-01T19:29:49.778109
2008-11-10T17:14:14
2008-11-10T17:14:14
34,016,391
2
0
null
null
null
null
UTF-8
C++
false
false
453,691
cpp
/* * Moon++ Scripts for Ascent MMORPG Server * Copyright (C) 2005-2007 Ascent Team <http://www.ascentemu.com/> * Copyright (C) 2007-2008 Moon++ Team <http://www.moonplusplus.info/> * * 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 * 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/>. */ #include "StdAfx.h" #include "Setup.h" /************************************************************************/ /* Generic AI Script */ /************************************************************************/ // Family based AI's class SpiderFamily : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(SpiderFamily); SP_AI_Spell spells[10]; bool m_spellcheck[10]; SpiderFamily(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 10; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(17253); spells[0].reqlvl = 1; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(17255); spells[1].reqlvl = 8; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(17256); spells[2].reqlvl = 16; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(17257); spells[3].reqlvl = 24; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(17258); spells[4].reqlvl = 32; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(17259); spells[5].reqlvl = 40; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(17260); spells[6].reqlvl = 48; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(17261); spells[7].reqlvl = 56; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(27050); spells[8].reqlvl = 64; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(15471); spells[9].reqlvl = 1; spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; #define Frost_Nova 10230 #define Shadow_Shock 16583 #define Consuming_Shadows 24614 class VoidwalkerFamily : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(VoidwalkerFamily); SP_AI_Spell spells[3]; bool m_spellcheck[3]; VoidwalkerFamily(Creature* pCreature) : CreatureAIScript(pCreature) { // -- Number of spells to add -- nrspells = 3; // --- Initialization --- for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } // ---------------------- spells[0].info = dbcSpell.LookupEntry(Frost_Nova); spells[0].reqlvl = 25; spells[0].targettype = TARGET_VARIOUS; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; // 1sec m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(Shadow_Shock); spells[1].reqlvl = 20; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; // 1sec m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(Consuming_Shadows); spells[2].reqlvl = 20; spells[2].targettype = TARGET_SELF; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; // 1sec m_spellcheck[2] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; // do another set of spells on transform if((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class BirdFamily : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(BirdFamily); SP_AI_Spell spells[28]; bool m_spellcheck[28]; BirdFamily(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 28; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(17253); spells[0].reqlvl = 1; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(17255); spells[1].reqlvl = 8; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(17256); spells[2].reqlvl = 16; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(17257); spells[3].reqlvl = 24; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(17258); spells[4].reqlvl = 32; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(17259); spells[5].reqlvl = 40; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(17260); spells[6].reqlvl = 48; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(17261); spells[7].reqlvl = 56; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(27050); spells[8].reqlvl = 64; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(27050); spells[9].reqlvl = 64; spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].perctrigger = 0; spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(16827); spells[10].reqlvl = 1; spells[10].targettype = TARGET_ATTACKING; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(16828); spells[11].reqlvl = 8; spells[11].targettype = TARGET_ATTACKING; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(16829); spells[12].reqlvl = 16; spells[12].targettype = TARGET_ATTACKING; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; spells[13].info = dbcSpell.LookupEntry(16830); spells[13].reqlvl = 24; spells[13].targettype = TARGET_ATTACKING; spells[13].instant = false; spells[13].perctrigger = (float)RandomFloat(5.0f); spells[13].attackstoptimer = 1000; m_spellcheck[13] = true; spells[14].info = dbcSpell.LookupEntry(16831); spells[14].reqlvl = 32; spells[14].targettype = TARGET_ATTACKING; spells[14].instant = false; spells[14].perctrigger = (float)RandomFloat(5.0f); spells[14].attackstoptimer = 1000; m_spellcheck[14] = true; spells[15].info = dbcSpell.LookupEntry(16832); spells[15].reqlvl = 40; spells[15].targettype = TARGET_ATTACKING; spells[15].instant = false; spells[15].perctrigger = (float)RandomFloat(5.0f); spells[15].attackstoptimer = 1000; m_spellcheck[15] = true; spells[16].info = dbcSpell.LookupEntry(3010); spells[16].reqlvl = 48; spells[16].targettype = TARGET_ATTACKING; spells[16].instant = false; spells[16].perctrigger = (float)RandomFloat(5.0f); spells[16].attackstoptimer = 1000; m_spellcheck[16] = true; spells[17].info = dbcSpell.LookupEntry(3009); spells[17].reqlvl = 56; spells[17].targettype = TARGET_ATTACKING; spells[17].instant = false; spells[17].perctrigger = (float)RandomFloat(5.0f); spells[17].attackstoptimer = 1000; m_spellcheck[17] = true; spells[18].info = dbcSpell.LookupEntry(27049); spells[18].reqlvl = 64; spells[18].targettype = TARGET_ATTACKING; spells[18].instant = false; spells[18].perctrigger = (float)RandomFloat(5.0f); spells[18].attackstoptimer = 1000; m_spellcheck[18] = true; spells[19].info = dbcSpell.LookupEntry(23145); spells[19].reqlvl = 30; spells[19].targettype = TARGET_SELF; spells[19].instant = false; spells[19].perctrigger = (float)RandomFloat(5.0f); spells[19].attackstoptimer = 1000; m_spellcheck[19] = true; spells[20].info = dbcSpell.LookupEntry(23147); spells[20].reqlvl = 40; spells[20].targettype = TARGET_SELF; spells[20].instant = false; spells[20].perctrigger = (float)RandomFloat(5.0f); spells[20].attackstoptimer = 1000; m_spellcheck[20] = true; spells[21].info = dbcSpell.LookupEntry(23148); spells[21].reqlvl = 50; spells[21].targettype = TARGET_SELF; spells[21].instant = false; spells[21].perctrigger = (float)RandomFloat(5.0f); spells[21].attackstoptimer = 1000; m_spellcheck[21] = true; spells[22].info = dbcSpell.LookupEntry(24423); spells[22].reqlvl = 8; spells[22].targettype = TARGET_ATTACKING; spells[22].instant = false; spells[22].perctrigger = (float)RandomFloat(5.0f); spells[22].attackstoptimer = 1000; m_spellcheck[22] = true; spells[23].info = dbcSpell.LookupEntry(24577); spells[23].reqlvl = 24; spells[23].targettype = TARGET_ATTACKING; spells[23].instant = false; spells[23].perctrigger = (float)RandomFloat(5.0f); spells[23].attackstoptimer = 1000; m_spellcheck[23] = true; spells[24].info = dbcSpell.LookupEntry(24578); spells[24].reqlvl = 48; spells[24].targettype = TARGET_ATTACKING; spells[24].instant = false; spells[24].perctrigger = (float)RandomFloat(5.0f); spells[24].attackstoptimer = 1000; m_spellcheck[24] = true; spells[25].info = dbcSpell.LookupEntry(24579); spells[25].reqlvl = 55; spells[25].targettype = TARGET_ATTACKING; spells[25].instant = false; spells[25].perctrigger = (float)RandomFloat(5.0f); spells[25].attackstoptimer = 1000; m_spellcheck[25] = true; spells[26].info = dbcSpell.LookupEntry(24579); spells[26].reqlvl = 64; spells[26].targettype = TARGET_ATTACKING; spells[26].instant = false; spells[26].perctrigger = (float)RandomFloat(5.0f); spells[26].attackstoptimer = 1000; m_spellcheck[26] = true; spells[27].info = dbcSpell.LookupEntry(23147); spells[27].reqlvl = 1; spells[27].targettype = TARGET_ATTACKING; spells[27].instant = false; spells[27].perctrigger = (float)RandomFloat(5.0f); spells[27].attackstoptimer = 1000; m_spellcheck[27] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class ScorpionFamily : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(ScorpionFamily); SP_AI_Spell spells[10]; bool m_spellcheck[10]; ScorpionFamily(Creature* pCreature) : CreatureAIScript(pCreature) { // -- Number of spells to add -- nrspells = 10; // --- Initialization --- for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } // ---------------------- spells[0].info = dbcSpell.LookupEntry(27049); spells[0].reqlvl = 64; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(16827); spells[1].reqlvl = 1; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(16828); spells[2].reqlvl = 8; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(16829); spells[3].reqlvl = 16; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(16830); spells[4].reqlvl = 24; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(16831); spells[5].reqlvl = 32; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(16832); spells[6].reqlvl = 40; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(3010); spells[7].reqlvl = 48; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(3009); spells[8].reqlvl = 56; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(3609); spells[9].reqlvl = 1; spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; // do another set of spells on transform if((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; /* #define Rabies 3150 // If u have that buff and u kill wolf ur instanly dead */ class WolfFamily : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(WolfFamily); SP_AI_Spell spells[16]; bool m_spellcheck[16]; WolfFamily(Creature* pCreature) : CreatureAIScript(pCreature) { // -- Number of spells to add -- nrspells = 16; // --- Initialization --- for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } // ---------------------- spells[0].info = dbcSpell.LookupEntry(17253); spells[0].reqlvl = 1; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(17255); spells[1].reqlvl = 8; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(17256); spells[2].reqlvl = 16; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(17257); spells[3].reqlvl = 24; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(17258); spells[4].reqlvl = 32; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(17259); spells[5].reqlvl = 40; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(17260); spells[6].reqlvl = 48; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(17261); spells[7].reqlvl = 56; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(27050); spells[8].reqlvl = 64; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(23099); spells[9].reqlvl = 30; spells[9].targettype = TARGET_SELF; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(23109); spells[10].reqlvl = 40; spells[10].targettype = TARGET_SELF; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(23110); spells[11].reqlvl = 50; spells[11].targettype = TARGET_SELF; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(24604); spells[12].reqlvl = 10; spells[12].targettype = TARGET_SELF; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; spells[13].info = dbcSpell.LookupEntry(24605); spells[13].reqlvl = 24; spells[13].targettype = TARGET_SELF; spells[13].instant = false; spells[13].perctrigger = (float)RandomFloat(5.0f); spells[13].attackstoptimer = 1000; m_spellcheck[13] = true; spells[14].info = dbcSpell.LookupEntry(24603); spells[14].reqlvl = 40; spells[14].targettype = TARGET_SELF; spells[14].instant = false; spells[14].perctrigger = (float)RandomFloat(5.0f); spells[14].attackstoptimer = 1000; m_spellcheck[14] = true; spells[15].info = dbcSpell.LookupEntry(24597); spells[15].reqlvl = 56; spells[15].targettype = TARGET_SELF; spells[15].instant = false; spells[15].perctrigger = (float)RandomFloat(5.0f); spells[15].attackstoptimer = 1000; m_spellcheck[15] = true; /* spells[2].info = dbcSpell.LookupEntry(Rabies); spells[2].reqlvl = 0; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; // 1sec m_spellcheck[2] = true; */ } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; // do another set of spells on transform if((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class GorillaFamily : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(GorillaFamily); SP_AI_Spell spells[13]; bool m_spellcheck[13]; GorillaFamily(Creature* pCreature) : CreatureAIScript(pCreature) { // -- Number of spells to add -- nrspells = 13; // --- Initialization --- for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } // ---------------------- spells[0].info = dbcSpell.LookupEntry(17253); spells[0].reqlvl = 1; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(17255); spells[1].reqlvl = 8; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(17256); spells[2].reqlvl = 16; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(17257); spells[3].reqlvl = 24; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(17258); spells[4].reqlvl = 32; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(17259); spells[5].reqlvl = 40; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(17260); spells[6].reqlvl = 48; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(17261); spells[7].reqlvl = 56; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(27050); spells[8].reqlvl = 64; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(26090); spells[9].reqlvl = 30; spells[9].targettype = TARGET_DESTINATION; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(26187); spells[10].reqlvl = 30; spells[10].targettype = TARGET_DESTINATION; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(26188); spells[11].reqlvl = 30; spells[11].targettype = TARGET_DESTINATION; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(27063); spells[12].reqlvl = 30; spells[12].targettype = TARGET_DESTINATION; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; // do another set of spells on transform if((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // Only if type!=8 class CrabFamily : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(CrabFamily); SP_AI_Spell spells[9]; bool m_spellcheck[9]; CrabFamily(Creature* pCreature) : CreatureAIScript(pCreature) { // -- Number of spells to add -- nrspells = 9; // --- Initialization --- for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } // ---------------------- spells[0].info = dbcSpell.LookupEntry(27049); spells[0].reqlvl = 64; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(16827); spells[1].reqlvl = 1; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(16828); spells[2].reqlvl = 8; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(16829); spells[3].reqlvl = 16; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(16830); spells[4].reqlvl = 24; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(16831); spells[5].reqlvl = 32; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(16832); spells[6].reqlvl = 40; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(3010); spells[7].reqlvl = 48; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(3009); spells[8].reqlvl = 56; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; // do another set of spells on transform if((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class BearFamily : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(BearFamily); SP_AI_Spell spells[18]; bool m_spellcheck[18]; BearFamily(Creature* pCreature) : CreatureAIScript(pCreature) { // -- Number of spells to add -- nrspells = 18; // --- Initialization --- for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } // ---------------------- spells[0].info = dbcSpell.LookupEntry(27049); spells[0].reqlvl = 64; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(16827); spells[1].reqlvl = 1; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(16828); spells[2].reqlvl = 8; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(16829); spells[3].reqlvl = 16; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(16830); spells[4].reqlvl = 24; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(16831); spells[5].reqlvl = 32; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(16832); spells[6].reqlvl = 40; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(3010); spells[7].reqlvl = 48; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(3009); spells[8].reqlvl = 56; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(17253); spells[9].reqlvl = 1; spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(17255); spells[10].reqlvl = 8; spells[10].targettype = TARGET_ATTACKING; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(17256); spells[11].reqlvl = 16; spells[11].targettype = TARGET_ATTACKING; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(17257); spells[12].reqlvl = 24; spells[12].targettype = TARGET_ATTACKING; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; spells[13].info = dbcSpell.LookupEntry(17258); spells[13].reqlvl = 32; spells[13].targettype = TARGET_ATTACKING; spells[13].instant = false; spells[13].perctrigger = (float)RandomFloat(5.0f); spells[13].attackstoptimer = 1000; m_spellcheck[13] = true; spells[14].info = dbcSpell.LookupEntry(17259); spells[14].reqlvl = 40; spells[14].targettype = TARGET_ATTACKING; spells[14].instant = false; spells[14].perctrigger = (float)RandomFloat(5.0f); spells[14].attackstoptimer = 1000; m_spellcheck[14] = true; spells[15].info = dbcSpell.LookupEntry(17260); spells[15].reqlvl = 48; spells[15].targettype = TARGET_ATTACKING; spells[15].instant = false; spells[15].perctrigger = (float)RandomFloat(5.0f); spells[15].attackstoptimer = 1000; m_spellcheck[15] = true; spells[16].info = dbcSpell.LookupEntry(17261); spells[16].reqlvl = 56; spells[16].targettype = TARGET_ATTACKING; spells[16].instant = false; spells[16].perctrigger = (float)RandomFloat(5.0f); spells[16].attackstoptimer = 1000; m_spellcheck[16] = true; spells[17].info = dbcSpell.LookupEntry(27050); spells[17].reqlvl = 64; spells[17].targettype = TARGET_ATTACKING; spells[17].instant = false; spells[17].perctrigger = (float)RandomFloat(5.0f); spells[17].attackstoptimer = 1000; m_spellcheck[17] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; // do another set of spells on transform if((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class BoarFamily : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(BoarFamily); SP_AI_Spell spells[27]; bool m_spellcheck[27]; BoarFamily(Creature* pCreature) : CreatureAIScript(pCreature) { // -- Number of spells to add -- nrspells = 27; // --- Initialization --- for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } // ---------------------- spells[0].info = dbcSpell.LookupEntry(17253); spells[0].reqlvl = 1; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(17255); spells[1].reqlvl = 8; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(17256); spells[2].reqlvl = 16; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(17257); spells[3].reqlvl = 24; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(17258); spells[4].reqlvl = 32; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(17259); spells[5].reqlvl = 40; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(17260); spells[6].reqlvl = 48; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(17261); spells[7].reqlvl = 56; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(27050); spells[8].reqlvl = 64; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(23099); spells[9].reqlvl = 30; spells[9].targettype = TARGET_SELF; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(23109); spells[10].reqlvl = 40; spells[10].targettype = TARGET_SELF; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(23110); spells[11].reqlvl = 50; spells[11].targettype = TARGET_SELF; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(7371); spells[12].reqlvl = 1; spells[12].targettype = TARGET_ATTACKING; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; spells[13].info = dbcSpell.LookupEntry(26177); spells[13].reqlvl = 12; spells[13].targettype = TARGET_ATTACKING; spells[13].instant = false; spells[13].perctrigger = (float)RandomFloat(5.0f); spells[13].attackstoptimer = 1000; m_spellcheck[13] = true; spells[14].info = dbcSpell.LookupEntry(26178); spells[14].reqlvl = 24; spells[14].targettype = TARGET_ATTACKING; spells[14].instant = false; spells[14].perctrigger = (float)RandomFloat(5.0f); spells[14].attackstoptimer = 1000; m_spellcheck[14] = true; spells[15].info = dbcSpell.LookupEntry(26179); spells[15].reqlvl = 36; spells[15].targettype = TARGET_ATTACKING; spells[15].instant = false; spells[15].perctrigger = (float)RandomFloat(5.0f); spells[15].attackstoptimer = 1000; m_spellcheck[15] = true; spells[16].info = dbcSpell.LookupEntry(26201); spells[16].reqlvl = 48; spells[16].targettype = TARGET_ATTACKING; spells[16].instant = false; spells[16].perctrigger = (float)RandomFloat(5.0f); spells[16].attackstoptimer = 1000; m_spellcheck[16] = true; spells[17].info = dbcSpell.LookupEntry(27685); spells[17].reqlvl = 60; spells[17].targettype = TARGET_ATTACKING; spells[17].instant = false; spells[17].perctrigger = (float)RandomFloat(5.0f); spells[17].attackstoptimer = 1000; m_spellcheck[17] = true; spells[18].info = dbcSpell.LookupEntry(35290); spells[18].reqlvl = 1; spells[18].targettype = TARGET_ATTACKING; spells[18].instant = false; spells[18].perctrigger = (float)RandomFloat(5.0f); spells[18].attackstoptimer = 1000; m_spellcheck[18] = true; spells[19].info = dbcSpell.LookupEntry(35291); spells[19].reqlvl = 8; spells[19].targettype = TARGET_ATTACKING; spells[19].instant = false; spells[19].perctrigger = (float)RandomFloat(5.0f); spells[19].attackstoptimer = 1000; m_spellcheck[19] = true; spells[20].info = dbcSpell.LookupEntry(35292); spells[20].reqlvl = 16; spells[20].targettype = TARGET_ATTACKING; spells[20].instant = false; spells[20].perctrigger = (float)RandomFloat(5.0f); spells[20].attackstoptimer = 1000; m_spellcheck[20] = true; spells[21].info = dbcSpell.LookupEntry(35293); spells[21].reqlvl = 24; spells[21].targettype = TARGET_ATTACKING; spells[21].instant = false; spells[21].perctrigger = (float)RandomFloat(5.0f); spells[21].attackstoptimer = 1000; m_spellcheck[21] = true; spells[22].info = dbcSpell.LookupEntry(35294); spells[22].reqlvl = 32; spells[22].targettype = TARGET_ATTACKING; spells[22].instant = false; spells[22].perctrigger = (float)RandomFloat(5.0f); spells[22].attackstoptimer = 1000; m_spellcheck[22] = true; spells[23].info = dbcSpell.LookupEntry(35295); spells[23].reqlvl = 40; spells[23].targettype = TARGET_ATTACKING; spells[23].instant = false; spells[23].perctrigger = (float)RandomFloat(5.0f); spells[23].attackstoptimer = 1000; m_spellcheck[23] = true; spells[24].info = dbcSpell.LookupEntry(35296); spells[24].reqlvl = 48; spells[24].targettype = TARGET_ATTACKING; spells[24].instant = false; spells[24].perctrigger = (float)RandomFloat(5.0f); spells[24].attackstoptimer = 1000; m_spellcheck[24] = true; spells[25].info = dbcSpell.LookupEntry(35297); spells[25].reqlvl = 56; spells[25].targettype = TARGET_ATTACKING; spells[25].instant = false; spells[25].perctrigger = (float)RandomFloat(5.0f); spells[25].attackstoptimer = 1000; m_spellcheck[25] = true; spells[26].info = dbcSpell.LookupEntry(35298); spells[26].reqlvl = 63; spells[26].targettype = TARGET_ATTACKING; spells[26].instant = false; spells[26].perctrigger = (float)RandomFloat(5.0f); spells[26].attackstoptimer = 1000; m_spellcheck[26] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; // do another set of spells on transform if((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // End of family based ai's // Type based AI's class DragonType : public CreatureAIScript // 8873 9573 16390 16396 20712 (self) { public: ADD_CREATURE_FACTORY_FUNCTION(DragonType); SP_AI_Spell spells[5]; bool m_spellcheck[5]; DragonType(Creature* pCreature) : CreatureAIScript(pCreature) { // -- Number of spells to add -- nrspells = 5; // --- Initialization --- for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } // ---------------------- spells[0].info = dbcSpell.LookupEntry(8873); spells[0].reqlvl = 1; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; // 1sec m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(9573); spells[1].reqlvl = 10; spells[1].targettype = TARGET_SELF; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; // 1sec m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(16390); spells[1].reqlvl = 20; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; // 1sec m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(16396); spells[3].reqlvl = 20; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; // 1sec m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(20712); spells[4].reqlvl = 60; spells[4].targettype = TARGET_SELF; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; // 1sec m_spellcheck[4] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; // do another set of spells on transform if((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class MechanicalType : public CreatureAIScript // 9483 91 12021 11837 8277 403 474 (Self) { public: ADD_CREATURE_FACTORY_FUNCTION(MechanicalType); SP_AI_Spell spells[7]; bool m_spellcheck[7]; MechanicalType(Creature* pCreature) : CreatureAIScript(pCreature) { // -- Number of spells to add -- nrspells = 7; // --- Initialization --- for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } // ---------------------- spells[0].info = dbcSpell.LookupEntry(9483); spells[0].reqlvl = 20; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; // 1sec m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(91); spells[1].reqlvl = 5; spells[1].targettype = TARGET_SELF; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; // 1sec m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(12021); spells[2].reqlvl = 1; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; // 1sec m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(11837); spells[3].reqlvl = 1; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; // 1sec m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(8277); spells[4].reqlvl = 5; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; // 1sec m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(403); spells[5].reqlvl = 1; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; // 1sec m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(474); spells[6].reqlvl = 8; spells[6].targettype = TARGET_SELF; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; // 1sec m_spellcheck[6] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class UnknownType /* Type=10 */ : public CreatureAIScript // 9515 (<-self) 11975 <-self) 12001 12038 (<-self) 17009 { public: ADD_CREATURE_FACTORY_FUNCTION(UnknownType); SP_AI_Spell spells[5]; bool m_spellcheck[5]; UnknownType(Creature* pCreature) : CreatureAIScript(pCreature) { // -- Number of spells to add -- nrspells = 5; // --- Initialization --- for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } // ---------------------- spells[0].info = dbcSpell.LookupEntry(9515); spells[0].reqlvl = 30; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(2.0f); spells[0].attackstoptimer = 1000; // 1sec m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(11975); spells[1].reqlvl = 20; spells[1].targettype = TARGET_SELF; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; // 1sec m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(12001); spells[2].reqlvl = 17; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; // 1sec m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(12038); // this shity spell doesnt exist?:PPP spells[3].reqlvl = 0; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; // 1sec m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(17009); //VOODOOOOOO :) spells[4].reqlvl = 0; // Feel the 1337 power spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; // 1sec m_spellcheck[4] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; /* Humanoids AI */ class HumanoidHunter : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(HumanoidHunter); SP_AI_Spell spells[44]; bool m_spellcheck[44]; HumanoidHunter(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 44; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(1978); spells[0].reqlvl = 4; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(13549); spells[1].reqlvl = 10; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(13550); spells[2].reqlvl = 18; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(3551); spells[3].reqlvl = 20; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(13552); spells[4].reqlvl = 34; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(13553); spells[5].reqlvl = 42; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(13555); spells[6].reqlvl = 58; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(3044); spells[7].reqlvl = 6; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(14281); spells[8].reqlvl = 12; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(14282); spells[9].reqlvl = 20; spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(14283); spells[10].reqlvl = 28; spells[10].targettype = TARGET_ATTACKING; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(14284); spells[11].reqlvl = 36; spells[11].targettype = TARGET_ATTACKING; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(13554); spells[12].reqlvl = 50; spells[12].targettype = TARGET_ATTACKING; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; spells[13].info = dbcSpell.LookupEntry(14287); spells[13].reqlvl = 60; spells[13].targettype = TARGET_ATTACKING; spells[13].instant = false; spells[13].perctrigger = (float)RandomFloat(5.0f); spells[13].attackstoptimer = 1000; m_spellcheck[13] = true; spells[14].info = dbcSpell.LookupEntry(20736); spells[14].reqlvl = 12; spells[14].targettype = TARGET_ATTACKING; spells[14].instant = false; spells[14].perctrigger = (float)RandomFloat(5.0f); spells[14].attackstoptimer = 1000; m_spellcheck[14] = true; spells[15].info = dbcSpell.LookupEntry(14274); spells[15].reqlvl = 20; spells[15].targettype = TARGET_ATTACKING; spells[15].instant = false; spells[15].perctrigger = (float)RandomFloat(5.0f); spells[15].attackstoptimer = 1000; m_spellcheck[15] = true; spells[16].info = dbcSpell.LookupEntry(15629); spells[16].reqlvl = 30; spells[16].targettype = TARGET_ATTACKING; spells[16].instant = false; spells[16].perctrigger = (float)RandomFloat(5.0f); spells[16].attackstoptimer = 1000; m_spellcheck[16] = true; spells[17].info = dbcSpell.LookupEntry(15630); spells[17].reqlvl = 40; spells[17].targettype = TARGET_ATTACKING; spells[17].instant = false; spells[17].perctrigger = (float)RandomFloat(5.0f); spells[17].attackstoptimer = 1000; m_spellcheck[17] = true; spells[18].info = dbcSpell.LookupEntry(14285); spells[18].reqlvl = 44; spells[18].targettype = TARGET_ATTACKING; spells[18].instant = false; spells[18].perctrigger = (float)RandomFloat(5.0f); spells[18].attackstoptimer = 1000; m_spellcheck[18] = true; spells[19].info = dbcSpell.LookupEntry(15632); spells[19].reqlvl = 60; spells[19].targettype = TARGET_ATTACKING; spells[19].instant = false; spells[19].perctrigger = (float)RandomFloat(5.0f); spells[19].attackstoptimer = 1000; m_spellcheck[19] = true; spells[20].info = dbcSpell.LookupEntry(5116); spells[20].reqlvl = 8; spells[20].targettype = TARGET_ATTACKING; spells[20].instant = false; spells[20].perctrigger = (float)RandomFloat(5.0f); spells[20].attackstoptimer = 1000; m_spellcheck[20] = true; spells[21].info = dbcSpell.LookupEntry(14286); spells[21].reqlvl = 52; spells[21].targettype = TARGET_ATTACKING; spells[21].instant = false; spells[21].perctrigger = (float)RandomFloat(5.0f); spells[21].attackstoptimer = 1000; m_spellcheck[21] = true; spells[22].info = dbcSpell.LookupEntry(19434); spells[22].reqlvl = 20; spells[22].targettype = TARGET_ATTACKING; spells[22].instant = false; spells[22].perctrigger = (float)RandomFloat(5.0f); spells[22].attackstoptimer = 1000; m_spellcheck[22] = true; spells[23].info = dbcSpell.LookupEntry(20900); spells[23].reqlvl = 28; spells[23].targettype = TARGET_ATTACKING; spells[23].instant = false; spells[23].perctrigger = (float)RandomFloat(5.0f); spells[23].attackstoptimer = 1000; m_spellcheck[23] = true; spells[24].info = dbcSpell.LookupEntry(20901); spells[24].reqlvl = 36; spells[24].targettype = TARGET_ATTACKING; spells[24].instant = false; spells[24].perctrigger = (float)RandomFloat(5.0f); spells[24].attackstoptimer = 1000; m_spellcheck[24] = true; spells[25].info = dbcSpell.LookupEntry(15631); spells[25].reqlvl = 50; spells[25].targettype = TARGET_ATTACKING; spells[25].instant = false; spells[25].perctrigger = (float)RandomFloat(5.0f); spells[25].attackstoptimer = 1000; m_spellcheck[25] = true; spells[26].info = dbcSpell.LookupEntry(20903); spells[26].reqlvl = 52; spells[26].targettype = TARGET_ATTACKING; spells[26].instant = false; spells[26].perctrigger = (float)RandomFloat(5.0f); spells[26].attackstoptimer = 1000; m_spellcheck[26] = true; spells[27].info = dbcSpell.LookupEntry(2643); spells[27].reqlvl = 18; spells[27].targettype = TARGET_ATTACKING; spells[27].instant = false; spells[27].perctrigger = (float)RandomFloat(5.0f); spells[27].attackstoptimer = 1000; m_spellcheck[27] = true; spells[28].info = dbcSpell.LookupEntry(14288); spells[28].reqlvl = 30; spells[28].targettype = TARGET_ATTACKING; spells[28].instant = false; spells[28].perctrigger = (float)RandomFloat(5.0f); spells[28].attackstoptimer = 1000; m_spellcheck[28] = true; spells[29].info = dbcSpell.LookupEntry(5116); spells[29].reqlvl = 8; spells[29].targettype = TARGET_ATTACKING; spells[29].instant = false; spells[29].perctrigger = (float)RandomFloat(5.0f); spells[29].attackstoptimer = 1000; m_spellcheck[29] = true; spells[30].info = dbcSpell.LookupEntry(20904); spells[30].reqlvl = 60; spells[30].targettype = TARGET_ATTACKING; spells[30].instant = false; spells[30].perctrigger = (float)RandomFloat(5.0f); spells[30].attackstoptimer = 1000; m_spellcheck[30] = true; spells[31].info = dbcSpell.LookupEntry(3043); spells[31].reqlvl = 22; spells[31].targettype = TARGET_ATTACKING; spells[31].instant = false; spells[31].perctrigger = (float)RandomFloat(5.0f); spells[31].attackstoptimer = 1000; m_spellcheck[31] = true; spells[32].info = dbcSpell.LookupEntry(14275); spells[32].reqlvl = 32; spells[32].targettype = TARGET_ATTACKING; spells[32].instant = false; spells[32].perctrigger = (float)RandomFloat(5.0f); spells[32].attackstoptimer = 1000; m_spellcheck[32] = true; spells[33].info = dbcSpell.LookupEntry(20902); spells[33].reqlvl = 44; spells[33].targettype = TARGET_ATTACKING; spells[33].instant = false; spells[33].perctrigger = (float)RandomFloat(5.0f); spells[33].attackstoptimer = 1000; m_spellcheck[33] = true; spells[34].info = dbcSpell.LookupEntry(14290); spells[34].reqlvl = 54; spells[34].targettype = TARGET_ATTACKING; spells[34].instant = false; spells[34].perctrigger = (float)RandomFloat(5.0f); spells[34].attackstoptimer = 1000; m_spellcheck[34] = true; spells[35].info = dbcSpell.LookupEntry(3034); spells[35].reqlvl = 36; spells[35].targettype = TARGET_ATTACKING; spells[35].instant = false; spells[35].perctrigger = (float)RandomFloat(5.0f); spells[35].attackstoptimer = 1000; m_spellcheck[35] = true; spells[36].info = dbcSpell.LookupEntry(14289); spells[36].reqlvl = 42; spells[36].targettype = TARGET_ATTACKING; spells[36].instant = false; spells[36].perctrigger = (float)RandomFloat(5.0f); spells[36].attackstoptimer = 1000; m_spellcheck[36] = true; spells[37].info = dbcSpell.LookupEntry(14277); spells[37].reqlvl = 52; spells[37].targettype = TARGET_ATTACKING; spells[37].instant = false; spells[37].perctrigger = (float)RandomFloat(5.0f); spells[37].attackstoptimer = 1000; m_spellcheck[37] = true; spells[38].info = dbcSpell.LookupEntry(1510); spells[38].reqlvl = 40; spells[38].targettype = TARGET_ATTACKING; spells[38].instant = false; spells[38].perctrigger = (float)RandomFloat(5.0f); spells[38].attackstoptimer = 1000; m_spellcheck[38] = true; spells[39].info = dbcSpell.LookupEntry(14276); spells[39].reqlvl = 42; spells[39].targettype = TARGET_ATTACKING; spells[39].instant = false; spells[39].perctrigger = (float)RandomFloat(5.0f); spells[39].attackstoptimer = 1000; m_spellcheck[39] = true; spells[40].info = dbcSpell.LookupEntry(14280); spells[40].reqlvl = 56; spells[40].targettype = TARGET_ATTACKING; spells[40].instant = false; spells[40].perctrigger = (float)RandomFloat(5.0f); spells[40].attackstoptimer = 1000; m_spellcheck[40] = true; spells[41].info = dbcSpell.LookupEntry(14279); spells[41].reqlvl = 46; spells[41].targettype = TARGET_ATTACKING; spells[41].instant = false; spells[41].perctrigger = (float)RandomFloat(5.0f); spells[41].attackstoptimer = 1000; m_spellcheck[41] = true; spells[42].info = dbcSpell.LookupEntry(14295); spells[42].reqlvl = 58; spells[42].targettype = TARGET_ATTACKING; spells[42].instant = false; spells[42].perctrigger = (float)RandomFloat(5.0f); spells[42].attackstoptimer = 1000; m_spellcheck[42] = true; spells[43].info = dbcSpell.LookupEntry(14294); spells[43].reqlvl = 50; spells[43].targettype = TARGET_ATTACKING; spells[43].instant = false; spells[43].perctrigger = (float)RandomFloat(5.0f); spells[43].attackstoptimer = 1000; m_spellcheck[43] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if ((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class HumanoidShadowHunter : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(HumanoidShadowHunter); SP_AI_Spell spells[28]; bool m_spellcheck[28]; HumanoidShadowHunter(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 28; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(589); spells[0].reqlvl = 4; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(594); spells[1].reqlvl = 10; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(970); spells[2].reqlvl = 18; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(992); spells[3].reqlvl = 26; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(2767); spells[4].reqlvl = 34; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(10892); spells[5].reqlvl = 42; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(10893); spells[6].reqlvl = 50; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(695); spells[7].reqlvl = 6; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(705); spells[8].reqlvl = 12; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(1106); spells[9].reqlvl = 28; spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(7641); spells[10].reqlvl = 36; spells[10].targettype = TARGET_ATTACKING; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(11659); spells[11].reqlvl = 44; spells[11].targettype = TARGET_ATTACKING; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(11660); spells[12].reqlvl = 52; spells[12].targettype = TARGET_ATTACKING; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; spells[13].info = dbcSpell.LookupEntry(11661); spells[13].reqlvl = 60; spells[13].targettype = TARGET_ATTACKING; spells[13].instant = false; spells[13].perctrigger = (float)RandomFloat(5.0f); spells[13].attackstoptimer = 1000; m_spellcheck[13] = true; spells[14].info = dbcSpell.LookupEntry(1978); spells[14].reqlvl = 4; spells[14].targettype = TARGET_ATTACKING; spells[14].instant = false; spells[14].perctrigger = (float)RandomFloat(5.0f); spells[14].attackstoptimer = 1000; m_spellcheck[14] = true; spells[15].info = dbcSpell.LookupEntry(13549); spells[15].reqlvl = 10; spells[15].targettype = TARGET_ATTACKING; spells[15].instant = false; spells[15].perctrigger = (float)RandomFloat(5.0f); spells[15].attackstoptimer = 1000; m_spellcheck[15] = true; spells[16].info = dbcSpell.LookupEntry(13550); spells[16].reqlvl = 18; spells[16].targettype = TARGET_ATTACKING; spells[16].instant = false; spells[16].perctrigger = (float)RandomFloat(5.0f); spells[16].attackstoptimer = 1000; m_spellcheck[16] = true; spells[17].info = dbcSpell.LookupEntry(3551); spells[17].reqlvl = 20; spells[17].targettype = TARGET_ATTACKING; spells[17].instant = false; spells[17].perctrigger = (float)RandomFloat(5.0f); spells[17].attackstoptimer = 1000; m_spellcheck[17] = true; spells[18].info = dbcSpell.LookupEntry(13552); spells[18].reqlvl = 34; spells[18].targettype = TARGET_ATTACKING; spells[18].instant = false; spells[18].perctrigger = (float)RandomFloat(5.0f); spells[18].attackstoptimer = 1000; m_spellcheck[18] = true; spells[19].info = dbcSpell.LookupEntry(13554); spells[19].reqlvl = 50; spells[19].targettype = TARGET_ATTACKING; spells[19].instant = false; spells[19].perctrigger = (float)RandomFloat(5.0f); spells[19].attackstoptimer = 1000; m_spellcheck[19] = true; spells[20].info = dbcSpell.LookupEntry(13555); spells[20].reqlvl = 58; spells[20].targettype = TARGET_ATTACKING; spells[20].instant = false; spells[20].perctrigger = (float)RandomFloat(5.0f); spells[20].attackstoptimer = 1000; m_spellcheck[20] = true; spells[21].info = dbcSpell.LookupEntry(3043); spells[21].reqlvl = 22; spells[21].targettype = TARGET_ATTACKING; spells[21].instant = false; spells[21].perctrigger = (float)RandomFloat(5.0f); spells[21].attackstoptimer = 1000; m_spellcheck[21] = true; spells[22].info = dbcSpell.LookupEntry(14275); spells[22].reqlvl = 32; spells[22].targettype = TARGET_ATTACKING; spells[22].instant = false; spells[22].perctrigger = (float)RandomFloat(5.0f); spells[22].attackstoptimer = 1000; m_spellcheck[22] = true; spells[23].info = dbcSpell.LookupEntry(14276); spells[23].reqlvl = 42; spells[23].targettype = TARGET_ATTACKING; spells[23].instant = false; spells[23].perctrigger = (float)RandomFloat(5.0f); spells[23].attackstoptimer = 1000; m_spellcheck[23] = true; spells[24].info = dbcSpell.LookupEntry(14277); spells[24].reqlvl = 52; spells[24].targettype = TARGET_ATTACKING; spells[24].instant = false; spells[24].perctrigger = (float)RandomFloat(5.0f); spells[24].attackstoptimer = 1000; m_spellcheck[24] = true; spells[25].info = dbcSpell.LookupEntry(3034); spells[25].reqlvl = 36; spells[25].targettype = TARGET_ATTACKING; spells[25].instant = false; spells[25].perctrigger = (float)RandomFloat(5.0f); spells[25].attackstoptimer = 1000; m_spellcheck[25] = true; spells[26].info = dbcSpell.LookupEntry(14279); spells[26].reqlvl = 46; spells[26].targettype = TARGET_ATTACKING; spells[26].instant = false; spells[26].perctrigger = (float)RandomFloat(5.0f); spells[26].attackstoptimer = 1000; m_spellcheck[26] = true; spells[27].info = dbcSpell.LookupEntry(14280); spells[27].reqlvl = 56; spells[27].targettype = TARGET_ATTACKING; spells[27].instant = false; spells[27].perctrigger = (float)RandomFloat(5.0f); spells[27].attackstoptimer = 1000; m_spellcheck[27] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if ((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class HumanoidMage : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(HumanoidMage); SP_AI_Spell spells[57]; bool m_spellcheck[57]; HumanoidMage(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 57; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(133); spells[0].reqlvl = 1; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(143); spells[1].reqlvl = 6; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(3140); spells[2].reqlvl = 18; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(8401); spells[3].reqlvl = 30; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(10148); spells[4].reqlvl = 42; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(10149); spells[5].reqlvl = 48; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(10151); spells[6].reqlvl = 60; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(116); spells[7].reqlvl = 4; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(145); spells[8].reqlvl = 12; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(8400); spells[9].reqlvl = 24; spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(7322); spells[10].reqlvl = 20; spells[10].targettype = TARGET_ATTACKING; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(8407); spells[11].reqlvl = 32; spells[11].targettype = TARGET_ATTACKING; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(10179); spells[12].reqlvl = 44; spells[12].targettype = TARGET_ATTACKING; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; spells[13].info = dbcSpell.LookupEntry(10181); spells[13].reqlvl = 56; spells[13].targettype = TARGET_ATTACKING; spells[13].instant = false; spells[13].perctrigger = (float)RandomFloat(5.0f); spells[13].attackstoptimer = 1000; m_spellcheck[13] = true; spells[14].info = dbcSpell.LookupEntry(2136); spells[14].reqlvl = 6; spells[14].targettype = TARGET_ATTACKING; spells[14].instant = false; spells[14].perctrigger = (float)RandomFloat(5.0f); spells[14].attackstoptimer = 1000; m_spellcheck[14] = true; spells[15].info = dbcSpell.LookupEntry(2137); spells[15].reqlvl = 14; spells[15].targettype = TARGET_ATTACKING; spells[15].instant = false; spells[15].perctrigger = (float)RandomFloat(5.0f); spells[15].attackstoptimer = 1000; m_spellcheck[15] = true; spells[16].info = dbcSpell.LookupEntry(8406); spells[16].reqlvl = 26; spells[16].targettype = TARGET_ATTACKING; spells[16].instant = false; spells[16].perctrigger = (float)RandomFloat(5.0f); spells[16].attackstoptimer = 1000; m_spellcheck[16] = true; spells[17].info = dbcSpell.LookupEntry(8408); spells[17].reqlvl = 38; spells[17].targettype = TARGET_ATTACKING; spells[17].instant = false; spells[17].perctrigger = (float)RandomFloat(5.0f); spells[17].attackstoptimer = 1000; m_spellcheck[17] = true; spells[18].info = dbcSpell.LookupEntry(10180); spells[18].reqlvl = 50; spells[18].targettype = TARGET_ATTACKING; spells[18].instant = false; spells[18].perctrigger = (float)RandomFloat(5.0f); spells[18].attackstoptimer = 1000; m_spellcheck[18] = true; spells[19].info = dbcSpell.LookupEntry(10199); spells[19].reqlvl = 54; spells[19].targettype = TARGET_ATTACKING; spells[19].instant = false; spells[19].perctrigger = (float)RandomFloat(5.0f); spells[19].attackstoptimer = 1000; m_spellcheck[19] = true; spells[20].info = dbcSpell.LookupEntry(205); spells[20].reqlvl = 8; spells[20].targettype = TARGET_ATTACKING; spells[20].instant = false; spells[20].perctrigger = (float)RandomFloat(5.0f); spells[20].attackstoptimer = 1000; m_spellcheck[20] = true; spells[21].info = dbcSpell.LookupEntry(837); spells[21].reqlvl = 14; spells[21].targettype = TARGET_ATTACKING; spells[21].instant = false; spells[21].perctrigger = (float)RandomFloat(5.0f); spells[21].attackstoptimer = 1000; m_spellcheck[21] = true; spells[22].info = dbcSpell.LookupEntry(2138); spells[22].reqlvl = 22; spells[22].targettype = TARGET_ATTACKING; spells[22].instant = false; spells[22].perctrigger = (float)RandomFloat(5.0f); spells[22].attackstoptimer = 1000; m_spellcheck[22] = true; spells[23].info = dbcSpell.LookupEntry(8413); spells[23].reqlvl = 38; spells[23].targettype = TARGET_ATTACKING; spells[23].instant = false; spells[23].perctrigger = (float)RandomFloat(5.0f); spells[23].attackstoptimer = 1000; m_spellcheck[23] = true; spells[24].info = dbcSpell.LookupEntry(10197); spells[24].reqlvl = 46; spells[24].targettype = TARGET_ATTACKING; spells[24].instant = false; spells[24].perctrigger = (float)RandomFloat(5.0f); spells[24].attackstoptimer = 1000; m_spellcheck[24] = true; spells[25].info = dbcSpell.LookupEntry(10230); spells[25].reqlvl = 54; spells[25].targettype = TARGET_ATTACKING; spells[25].instant = false; spells[25].perctrigger = (float)RandomFloat(5.0f); spells[25].attackstoptimer = 1000; m_spellcheck[25] = true; spells[26].info = dbcSpell.LookupEntry(122); spells[26].reqlvl = 10; spells[26].targettype = TARGET_ATTACKING; spells[26].instant = false; spells[26].perctrigger = (float)RandomFloat(5.0f); spells[26].attackstoptimer = 1000; m_spellcheck[26] = true; spells[27].info = dbcSpell.LookupEntry(8412); spells[27].reqlvl = 30; spells[27].targettype = TARGET_ATTACKING; spells[27].instant = false; spells[27].perctrigger = (float)RandomFloat(5.0f); spells[27].attackstoptimer = 1000; m_spellcheck[27] = true; spells[28].info = dbcSpell.LookupEntry(6131); spells[28].reqlvl = 40; spells[28].targettype = TARGET_ATTACKING; spells[28].instant = false; spells[28].perctrigger = (float)RandomFloat(5.0f); spells[28].attackstoptimer = 1000; m_spellcheck[28] = true; spells[29].info = dbcSpell.LookupEntry(10161); spells[29].reqlvl = 58; spells[29].targettype = TARGET_ATTACKING; spells[29].instant = false; spells[29].perctrigger = (float)RandomFloat(5.0f); spells[29].attackstoptimer = 1000; m_spellcheck[29] = true; spells[30].info = dbcSpell.LookupEntry(10); spells[30].reqlvl = 20; spells[30].targettype = TARGET_ATTACKING; spells[30].instant = false; spells[30].perctrigger = (float)RandomFloat(5.0f); spells[30].attackstoptimer = 1000; m_spellcheck[30] = true; spells[31].info = dbcSpell.LookupEntry(120); spells[31].reqlvl = 26; spells[31].targettype = TARGET_ATTACKING; spells[31].instant = false; spells[31].perctrigger = (float)RandomFloat(5.0f); spells[31].attackstoptimer = 1000; m_spellcheck[31] = true; spells[32].info = dbcSpell.LookupEntry(865); spells[32].reqlvl = 26; spells[32].targettype = TARGET_ATTACKING; spells[32].instant = false; spells[32].perctrigger = (float)RandomFloat(5.0f); spells[32].attackstoptimer = 1000; m_spellcheck[32] = true; spells[33].info = dbcSpell.LookupEntry(10159); spells[33].reqlvl = 42; spells[33].targettype = TARGET_ATTACKING; spells[33].instant = false; spells[33].perctrigger = (float)RandomFloat(5.0f); spells[33].attackstoptimer = 1000; m_spellcheck[33] = true; spells[34].info = dbcSpell.LookupEntry(10160); spells[34].reqlvl = 50; spells[34].targettype = TARGET_ATTACKING; spells[34].instant = false; spells[34].perctrigger = (float)RandomFloat(5.0f); spells[34].attackstoptimer = 1000; m_spellcheck[34] = true; spells[35].info = dbcSpell.LookupEntry(13020); spells[35].reqlvl = 52; spells[35].targettype = TARGET_ATTACKING; spells[35].instant = false; spells[35].perctrigger = (float)RandomFloat(5.0f); spells[35].attackstoptimer = 1000; m_spellcheck[35] = true; spells[36].info = dbcSpell.LookupEntry(8437); spells[36].reqlvl = 22; spells[36].targettype = TARGET_ATTACKING; spells[36].instant = false; spells[36].perctrigger = (float)RandomFloat(5.0f); spells[36].attackstoptimer = 1000; m_spellcheck[36] = true; spells[37].info = dbcSpell.LookupEntry(8427); spells[37].reqlvl = 36; spells[37].targettype = TARGET_ATTACKING; spells[37].instant = false; spells[37].perctrigger = (float)RandomFloat(5.0f); spells[37].attackstoptimer = 1000; m_spellcheck[37] = true; spells[38].info = dbcSpell.LookupEntry(10185); spells[38].reqlvl = 44; spells[38].targettype = TARGET_ATTACKING; spells[38].instant = false; spells[38].perctrigger = (float)RandomFloat(5.0f); spells[38].attackstoptimer = 1000; m_spellcheck[38] = true; spells[39].info = dbcSpell.LookupEntry(10186); spells[39].reqlvl = 52; spells[39].targettype = TARGET_ATTACKING; spells[39].instant = false; spells[39].perctrigger = (float)RandomFloat(5.0f); spells[39].attackstoptimer = 1000; m_spellcheck[39] = true; spells[40].info = dbcSpell.LookupEntry(10202); spells[40].reqlvl = 54; spells[40].targettype = TARGET_ATTACKING; spells[40].instant = false; spells[40].perctrigger = (float)RandomFloat(5.0f); spells[40].attackstoptimer = 1000; m_spellcheck[40] = true; spells[41].info = dbcSpell.LookupEntry(8438); spells[41].reqlvl = 30; spells[41].targettype = TARGET_ATTACKING; spells[41].instant = false; spells[41].perctrigger = (float)RandomFloat(5.0f); spells[41].attackstoptimer = 1000; m_spellcheck[41] = true; spells[42].info = dbcSpell.LookupEntry(8439); spells[42].reqlvl = 38; spells[42].targettype = TARGET_ATTACKING; spells[42].instant = false; spells[42].perctrigger = (float)RandomFloat(5.0f); spells[42].attackstoptimer = 1000; m_spellcheck[42] = true; spells[43].info = dbcSpell.LookupEntry(10201); spells[43].reqlvl = 46; spells[43].targettype = TARGET_ATTACKING; spells[43].instant = false; spells[43].perctrigger = (float)RandomFloat(5.0f); spells[43].attackstoptimer = 1000; m_spellcheck[43] = true; spells[44].info = dbcSpell.LookupEntry(168); spells[44].reqlvl = 1; spells[44].targettype = TARGET_SELF; spells[44].instant = false; spells[44].perctrigger = (float)RandomFloat(5.0f); spells[44].attackstoptimer = 1000; m_spellcheck[44] = true; spells[45].info = dbcSpell.LookupEntry(7300); spells[45].reqlvl = 10; spells[45].targettype = TARGET_SELF; spells[45].instant = false; spells[45].perctrigger = (float)RandomFloat(5.0f); spells[45].attackstoptimer = 1000; m_spellcheck[45] = true; spells[46].info = dbcSpell.LookupEntry(7301); spells[46].reqlvl = 20; spells[46].targettype = TARGET_SELF; spells[46].instant = false; spells[46].perctrigger = (float)RandomFloat(5.0f); spells[46].attackstoptimer = 1000; m_spellcheck[46] = true; spells[47].info = dbcSpell.LookupEntry(7302); spells[47].reqlvl = 30; spells[47].targettype = TARGET_SELF; spells[47].instant = false; spells[47].perctrigger = (float)RandomFloat(5.0f); spells[47].attackstoptimer = 1000; m_spellcheck[47] = true; spells[48].info = dbcSpell.LookupEntry(7320); spells[48].reqlvl = 40; spells[48].targettype = TARGET_SELF; spells[48].instant = false; spells[48].perctrigger = (float)RandomFloat(5.0f); spells[48].attackstoptimer = 1000; m_spellcheck[48] = true; spells[49].info = dbcSpell.LookupEntry(10219); spells[49].reqlvl = 50; spells[49].targettype = TARGET_SELF; spells[49].instant = false; spells[49].perctrigger = (float)RandomFloat(5.0f); spells[49].attackstoptimer = 1000; m_spellcheck[49] = true; spells[50].info = dbcSpell.LookupEntry(10220); spells[50].reqlvl = 60; spells[50].targettype = TARGET_SELF; spells[50].instant = false; spells[50].perctrigger = (float)RandomFloat(5.0f); spells[50].attackstoptimer = 1000; m_spellcheck[50] = true; spells[51].info = dbcSpell.LookupEntry(1463); spells[51].reqlvl = 20; spells[51].targettype = TARGET_SELF; spells[51].instant = false; spells[51].perctrigger = (float)RandomFloat(5.0f); spells[51].attackstoptimer = 1000; m_spellcheck[51] = true; spells[52].info = dbcSpell.LookupEntry(8494); spells[52].reqlvl = 28; spells[52].targettype = TARGET_SELF; spells[52].instant = false; spells[52].perctrigger = (float)RandomFloat(5.0f); spells[52].attackstoptimer = 1000; m_spellcheck[52] = true; spells[53].info = dbcSpell.LookupEntry(8495); spells[53].reqlvl = 36; spells[53].targettype = TARGET_SELF; spells[53].instant = false; spells[53].perctrigger = (float)RandomFloat(5.0f); spells[53].attackstoptimer = 1000; m_spellcheck[53] = true; spells[54].info = dbcSpell.LookupEntry(10191); spells[54].reqlvl = 44; spells[54].targettype = TARGET_SELF; spells[54].instant = false; spells[54].perctrigger = (float)RandomFloat(5.0f); spells[54].attackstoptimer = 1000; m_spellcheck[54] = true; spells[55].info = dbcSpell.LookupEntry(10192); spells[55].reqlvl = 52; spells[55].targettype = TARGET_SELF; spells[55].instant = false; spells[55].perctrigger = (float)RandomFloat(5.0f); spells[55].attackstoptimer = 1000; m_spellcheck[55] = true; spells[56].info = dbcSpell.LookupEntry(10193); spells[56].reqlvl = 60; spells[56].targettype = TARGET_SELF; spells[56].instant = false; spells[56].perctrigger = (float)RandomFloat(5.0f); spells[56].attackstoptimer = 1000; m_spellcheck[56] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if ((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class HumanoidWarlock : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(HumanoidWarlock); SP_AI_Spell spells[56]; bool m_spellcheck[56]; HumanoidWarlock(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 56; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(348); spells[0].reqlvl = 1; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(172); spells[1].reqlvl = 4; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(686); spells[2].reqlvl = 1; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(695); spells[3].reqlvl = 6; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(1454); spells[4].reqlvl = 6; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(980); spells[5].reqlvl = 8; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(5782); spells[6].reqlvl = 8; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = 0; //fear crash server spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(707); spells[7].reqlvl = 10; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(172); spells[8].reqlvl = 4; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(705); spells[9].reqlvl = 12; spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(6222); spells[10].reqlvl = 14; spells[10].targettype = TARGET_ATTACKING; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(704); spells[11].reqlvl = 14; spells[11].targettype = TARGET_ATTACKING; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(689); spells[12].reqlvl = 14; spells[12].targettype = TARGET_ATTACKING; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; spells[13].info = dbcSpell.LookupEntry(1455); spells[13].reqlvl = 16; spells[13].targettype = TARGET_ATTACKING; spells[13].instant = false; spells[13].perctrigger = (float)RandomFloat(5.0f); spells[13].attackstoptimer = 1000; m_spellcheck[13] = true; spells[14].info = dbcSpell.LookupEntry(1014); spells[14].reqlvl = 18; spells[14].targettype = TARGET_ATTACKING; spells[14].instant = false; spells[14].perctrigger = (float)RandomFloat(5.0f); spells[14].attackstoptimer = 1000; m_spellcheck[14] = true; spells[15].info = dbcSpell.LookupEntry(1094); spells[15].reqlvl = 20; spells[15].targettype = TARGET_ATTACKING; spells[15].instant = false; spells[15].perctrigger = (float)RandomFloat(5.0f); spells[15].attackstoptimer = 1000; m_spellcheck[15] = true; spells[16].info = dbcSpell.LookupEntry(1088); spells[16].reqlvl = 20; spells[16].targettype = TARGET_ATTACKING; spells[16].instant = false; spells[16].perctrigger = (float)RandomFloat(5.0f); spells[16].attackstoptimer = 1000; m_spellcheck[16] = true; spells[17].info = dbcSpell.LookupEntry(1106); spells[17].reqlvl = 28; spells[17].targettype = TARGET_ATTACKING; spells[17].instant = false; spells[17].perctrigger = (float)RandomFloat(5.0f); spells[17].attackstoptimer = 1000; m_spellcheck[17] = true; spells[18].info = dbcSpell.LookupEntry(699); spells[18].reqlvl = 22; spells[18].targettype = TARGET_ATTACKING; spells[18].instant = false; spells[18].perctrigger = (float)RandomFloat(5.0f); spells[18].attackstoptimer = 1000; m_spellcheck[18] = true; spells[19].info = dbcSpell.LookupEntry(6223); spells[19].reqlvl = 24; spells[19].targettype = TARGET_ATTACKING; spells[19].instant = false; spells[19].perctrigger = (float)RandomFloat(5.0f); spells[19].attackstoptimer = 1000; m_spellcheck[19] = true; spells[20].info = dbcSpell.LookupEntry(5138); spells[20].reqlvl = 24; spells[20].targettype = TARGET_ATTACKING; spells[20].instant = false; spells[20].perctrigger = (float)RandomFloat(5.0f); spells[20].attackstoptimer = 1000; m_spellcheck[20] = true; spells[21].info = dbcSpell.LookupEntry(1456); spells[21].reqlvl = 26; spells[21].targettype = TARGET_ATTACKING; spells[21].instant = false; spells[21].perctrigger = (float)RandomFloat(5.0f); spells[21].attackstoptimer = 1000; m_spellcheck[21] = true; spells[22].info = dbcSpell.LookupEntry(6217); spells[22].reqlvl = 28; spells[22].targettype = TARGET_ATTACKING; spells[22].instant = false; spells[22].perctrigger = (float)RandomFloat(5.0f); spells[22].attackstoptimer = 1000; m_spellcheck[22] = true; spells[23].info = dbcSpell.LookupEntry(7658); spells[23].reqlvl = 28; spells[23].targettype = TARGET_ATTACKING; spells[23].instant = false; spells[23].perctrigger = (float)RandomFloat(5.0f); spells[23].attackstoptimer = 1000; m_spellcheck[23] = true; spells[24].info = dbcSpell.LookupEntry(7641); spells[24].reqlvl = 36; spells[24].targettype = TARGET_ATTACKING; spells[24].instant = false; spells[24].perctrigger = (float)RandomFloat(5.0f); spells[24].attackstoptimer = 1000; m_spellcheck[24] = true; spells[25].info = dbcSpell.LookupEntry(18223); spells[25].reqlvl = 0; spells[25].targettype = TARGET_ATTACKING; spells[25].instant = false; spells[25].perctrigger = (float)RandomFloat(5.0f); spells[25].attackstoptimer = 1000; m_spellcheck[25] = true; spells[26].info = dbcSpell.LookupEntry(709); spells[26].reqlvl = 30; spells[26].targettype = TARGET_ATTACKING; spells[26].instant = false; spells[26].perctrigger = (float)RandomFloat(5.0f); spells[26].attackstoptimer = 1000; m_spellcheck[26] = true; spells[27].info = dbcSpell.LookupEntry(2941); spells[27].reqlvl = 30; spells[27].targettype = TARGET_ATTACKING; spells[27].instant = false; spells[27].perctrigger = (float)RandomFloat(5.0f); spells[27].attackstoptimer = 1000; m_spellcheck[27] = true; spells[28].info = dbcSpell.LookupEntry(6213); spells[28].reqlvl = 32; spells[28].targettype = TARGET_ATTACKING; spells[28].instant = false; spells[28].perctrigger = 0; //Fear crash server spells[28].attackstoptimer = 1000; m_spellcheck[28] = true; spells[29].info = dbcSpell.LookupEntry(7648); spells[29].reqlvl = 34; spells[29].targettype = TARGET_ATTACKING; spells[29].instant = false; spells[29].perctrigger = (float)RandomFloat(5.0f); spells[29].attackstoptimer = 1000; m_spellcheck[29] = true; spells[30].info = dbcSpell.LookupEntry(6226); spells[30].reqlvl = 34; spells[30].targettype = TARGET_ATTACKING; spells[30].instant = false; spells[30].perctrigger = (float)RandomFloat(5.0f); spells[30].attackstoptimer = 1000; m_spellcheck[30] = true; spells[31].info = dbcSpell.LookupEntry(11687); spells[31].reqlvl = 36; spells[31].targettype = TARGET_ATTACKING; spells[31].instant = false; spells[31].perctrigger = (float)RandomFloat(5.0f); spells[31].attackstoptimer = 1000; m_spellcheck[31] = true; spells[32].info = dbcSpell.LookupEntry(11711); spells[32].reqlvl = 38; spells[32].targettype = TARGET_ATTACKING; spells[32].instant = false; spells[32].perctrigger = (float)RandomFloat(5.0f); spells[32].attackstoptimer = 1000; m_spellcheck[32] = true; spells[33].info = dbcSpell.LookupEntry(11659); spells[33].reqlvl = 44; spells[33].targettype = TARGET_ATTACKING; spells[33].instant = false; spells[33].perctrigger = (float)RandomFloat(5.0f); spells[33].attackstoptimer = 1000; m_spellcheck[33] = true; spells[34].info = dbcSpell.LookupEntry(11665); spells[34].reqlvl = 40; spells[34].targettype = TARGET_ATTACKING; spells[34].instant = false; spells[34].perctrigger = (float)RandomFloat(5.0f); spells[34].attackstoptimer = 1000; m_spellcheck[34] = true; spells[35].info = dbcSpell.LookupEntry(7651); spells[35].reqlvl = 38; spells[35].targettype = TARGET_ATTACKING; spells[35].instant = false; spells[35].perctrigger = (float)RandomFloat(5.0f); spells[35].attackstoptimer = 1000; m_spellcheck[35] = true; spells[36].info = dbcSpell.LookupEntry(7659); spells[36].reqlvl = 42; spells[36].targettype = TARGET_ATTACKING; spells[36].instant = false; spells[36].perctrigger = (float)RandomFloat(5.0f); spells[36].attackstoptimer = 1000; m_spellcheck[36] = true; spells[37].info = dbcSpell.LookupEntry(6789); spells[37].reqlvl = 42; spells[37].targettype = TARGET_ATTACKING; spells[37].instant = false; spells[37].perctrigger = (float)RandomFloat(5.0f); spells[37].attackstoptimer = 1000; m_spellcheck[37] = true; spells[38].info = dbcSpell.LookupEntry(11671); spells[38].reqlvl = 44; spells[38].targettype = TARGET_ATTACKING; spells[38].instant = false; spells[38].perctrigger = (float)RandomFloat(5.0f); spells[38].attackstoptimer = 1000; m_spellcheck[38] = true; spells[39].info = dbcSpell.LookupEntry(17862); spells[39].reqlvl = 44; spells[39].targettype = TARGET_ATTACKING; spells[39].instant = false; spells[39].perctrigger = (float)RandomFloat(5.0f); spells[39].attackstoptimer = 1000; m_spellcheck[39] = true; spells[40].info = dbcSpell.LookupEntry(11699); spells[40].reqlvl = 46; spells[40].targettype = TARGET_ATTACKING; spells[40].instant = false; spells[40].perctrigger = (float)RandomFloat(5.0f); spells[40].attackstoptimer = 1000; m_spellcheck[40] = true; spells[41].info = dbcSpell.LookupEntry(11688); spells[41].reqlvl = 46; spells[41].targettype = TARGET_ATTACKING; spells[41].instant = false; spells[41].perctrigger = (float)RandomFloat(5.0f); spells[41].attackstoptimer = 1000; m_spellcheck[41] = true; spells[42].info = dbcSpell.LookupEntry(11712); spells[42].reqlvl = 48; spells[42].targettype = TARGET_ATTACKING; spells[42].instant = false; spells[42].perctrigger = (float)RandomFloat(5.0f); spells[42].attackstoptimer = 1000; m_spellcheck[42] = true; spells[43].info = dbcSpell.LookupEntry(11660); spells[43].reqlvl = 52; spells[43].targettype = TARGET_ATTACKING; spells[43].instant = false; spells[43].perctrigger = (float)RandomFloat(5.0f); spells[43].attackstoptimer = 1000; m_spellcheck[43] = true; spells[44].info = dbcSpell.LookupEntry(11661); spells[44].reqlvl = 60; spells[44].targettype = TARGET_ATTACKING; spells[44].instant = false; spells[44].perctrigger = (float)RandomFloat(5.0f); spells[44].attackstoptimer = 1000; m_spellcheck[44] = true; spells[45].info = dbcSpell.LookupEntry(11661); spells[45].reqlvl = 60; spells[45].targettype = TARGET_ATTACKING; spells[45].instant = false; spells[45].perctrigger = (float)RandomFloat(5.0f); spells[45].attackstoptimer = 1000; m_spellcheck[45] = true; spells[46].info = dbcSpell.LookupEntry(17926); spells[46].reqlvl = 58; spells[46].targettype = TARGET_ATTACKING; spells[46].instant = false; spells[46].perctrigger = (float)RandomFloat(5.0f); spells[46].attackstoptimer = 1000; m_spellcheck[46] = true; spells[47].info = dbcSpell.LookupEntry(11713); spells[47].reqlvl = 58; spells[47].targettype = TARGET_ATTACKING; spells[47].instant = false; spells[47].perctrigger = (float)RandomFloat(5.0f); spells[47].attackstoptimer = 1000; m_spellcheck[47] = true; spells[48].info = dbcSpell.LookupEntry(6215); spells[48].reqlvl = 56; spells[48].targettype = TARGET_ATTACKING; spells[48].instant = false; spells[48].perctrigger = 0; //fear crash server spells[48].attackstoptimer = 1000; m_spellcheck[48] = true; spells[49].info = dbcSpell.LookupEntry(11689); spells[49].reqlvl = 56; spells[49].targettype = TARGET_ATTACKING; spells[49].instant = false; spells[49].perctrigger = (float)RandomFloat(5.0f); spells[49].attackstoptimer = 1000; m_spellcheck[49] = true; spells[50].info = dbcSpell.LookupEntry(11717); spells[50].reqlvl = 56; spells[50].targettype = TARGET_ATTACKING; spells[50].instant = false; spells[50].perctrigger = (float)RandomFloat(5.0f); spells[50].attackstoptimer = 1000; m_spellcheck[50] = true; spells[51].info = dbcSpell.LookupEntry(11704); spells[51].reqlvl = 54; spells[51].targettype = TARGET_ATTACKING; spells[51].instant = false; spells[51].perctrigger = (float)RandomFloat(5.0f); spells[51].attackstoptimer = 1000; m_spellcheck[51] = true; spells[52].info = dbcSpell.LookupEntry(11700); spells[52].reqlvl = 54; spells[52].targettype = TARGET_ATTACKING; spells[52].instant = false; spells[52].perctrigger = (float)RandomFloat(5.0f); spells[52].attackstoptimer = 1000; m_spellcheck[52] = true; spells[53].info = dbcSpell.LookupEntry(11672); spells[53].reqlvl = 54; spells[53].targettype = TARGET_ATTACKING; spells[53].instant = false; spells[53].perctrigger = (float)RandomFloat(5.0f); spells[53].attackstoptimer = 1000; m_spellcheck[53] = true; spells[54].info = dbcSpell.LookupEntry(17925); spells[54].reqlvl = 50; spells[54].targettype = TARGET_ATTACKING; spells[54].instant = false; spells[54].perctrigger = (float)RandomFloat(5.0f); spells[54].attackstoptimer = 1000; m_spellcheck[54] = true; spells[55].info = dbcSpell.LookupEntry(11667); spells[55].reqlvl = 50; spells[55].targettype = TARGET_ATTACKING; spells[55].instant = false; spells[55].perctrigger = (float)RandomFloat(5.0f); spells[55].attackstoptimer = 1000; m_spellcheck[55] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if ((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class HumanoidPriest : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(HumanoidPriest); SP_AI_Spell spells[49]; bool m_spellcheck[49]; HumanoidPriest(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 49; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(589); spells[0].reqlvl = 4; spells[0].hpreqtocast = 85; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(585); spells[1].reqlvl = 1; spells[1].hpreqtocast = 85; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(594); spells[2].reqlvl = 10; spells[2].hpreqtocast = 85; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(591); spells[3].reqlvl = 6; spells[3].hpreqtocast = 85; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(8092); spells[4].reqlvl = 10; spells[4].hpreqtocast = 85; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(970); spells[5].reqlvl = 18; spells[5].hpreqtocast = 85; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(598); spells[6].reqlvl = 14; spells[6].hpreqtocast = 85; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(8102); spells[7].reqlvl = 16; spells[7].hpreqtocast = 85; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(8122); spells[8].reqlvl = 14; spells[8].hpreqtocast = 85; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(992); spells[9].reqlvl = 26; spells[9].hpreqtocast = 85; spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(984); spells[10].reqlvl = 22; spells[10].hpreqtocast = 85; spells[10].targettype = TARGET_ATTACKING; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(8103); spells[11].reqlvl = 22; spells[11].hpreqtocast = 85; spells[11].targettype = TARGET_ATTACKING; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(8104); spells[12].reqlvl = 28; spells[12].hpreqtocast = 85; spells[12].targettype = TARGET_ATTACKING; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; spells[13].info = dbcSpell.LookupEntry(8122); spells[13].reqlvl = 14; spells[13].hpreqtocast = 85; spells[13].targettype = TARGET_ATTACKING; spells[13].instant = false; spells[13].perctrigger = (float)RandomFloat(5.0f); spells[13].attackstoptimer = 1000; m_spellcheck[13] = true; spells[14].info = dbcSpell.LookupEntry(2767); spells[14].reqlvl = 34; spells[14].hpreqtocast = 85; spells[14].targettype = TARGET_ATTACKING; spells[14].instant = false; spells[14].perctrigger = (float)RandomFloat(5.0f); spells[14].attackstoptimer = 1000; m_spellcheck[14] = true; spells[15].info = dbcSpell.LookupEntry(1004); spells[15].reqlvl = 30; spells[15].hpreqtocast = 85; spells[15].targettype = TARGET_ATTACKING; spells[15].instant = false; spells[15].perctrigger = (float)RandomFloat(5.0f); spells[15].attackstoptimer = 1000; m_spellcheck[15] = true; spells[16].info = dbcSpell.LookupEntry(8105); spells[16].reqlvl = 34; spells[16].hpreqtocast = 85; spells[16].targettype = TARGET_ATTACKING; spells[16].instant = false; spells[16].perctrigger = (float)RandomFloat(5.0f); spells[16].attackstoptimer = 1000; m_spellcheck[16] = true; spells[17].info = dbcSpell.LookupEntry(8122); spells[17].reqlvl = 14; spells[17].hpreqtocast = 85; spells[17].targettype = TARGET_ATTACKING; spells[17].instant = false; spells[17].perctrigger = (float)RandomFloat(5.0f); spells[17].attackstoptimer = 1000; m_spellcheck[17] = true; spells[18].info = dbcSpell.LookupEntry(10892); spells[18].reqlvl = 42; spells[18].hpreqtocast = 85; spells[18].targettype = TARGET_ATTACKING; spells[18].instant = false; spells[18].perctrigger = (float)RandomFloat(5.0f); spells[18].attackstoptimer = 1000; m_spellcheck[18] = true; spells[19].info = dbcSpell.LookupEntry(6060); spells[19].reqlvl = 38; spells[19].hpreqtocast = 85; spells[19].targettype = TARGET_ATTACKING; spells[19].instant = false; spells[19].perctrigger = (float)RandomFloat(5.0f); spells[19].attackstoptimer = 1000; m_spellcheck[19] = true; spells[20].info = dbcSpell.LookupEntry(10933); spells[20].reqlvl = 46; spells[20].hpreqtocast = 85; spells[20].targettype = TARGET_ATTACKING; spells[20].instant = false; spells[20].perctrigger = (float)RandomFloat(5.0f); spells[20].attackstoptimer = 1000; m_spellcheck[20] = true; spells[21].info = dbcSpell.LookupEntry(8106); spells[21].reqlvl = 40; spells[21].hpreqtocast = 85; spells[21].targettype = TARGET_ATTACKING; spells[21].instant = false; spells[21].perctrigger = (float)RandomFloat(5.0f); spells[21].attackstoptimer = 1000; m_spellcheck[21] = true; spells[22].info = dbcSpell.LookupEntry(10945); spells[22].reqlvl = 46; spells[22].hpreqtocast = 85; spells[22].targettype = TARGET_ATTACKING; spells[22].instant = false; spells[22].perctrigger = (float)RandomFloat(5.0f); spells[22].attackstoptimer = 1000; m_spellcheck[22] = true; spells[23].info = dbcSpell.LookupEntry(8122); spells[23].reqlvl = 14; spells[23].hpreqtocast = 85; spells[23].targettype = TARGET_ATTACKING; spells[23].instant = false; spells[23].perctrigger = (float)RandomFloat(5.0f); spells[23].attackstoptimer = 1000; m_spellcheck[23] = true; spells[24].info = dbcSpell.LookupEntry(10893); spells[24].reqlvl = 50; spells[24].hpreqtocast = 85; spells[24].targettype = TARGET_ATTACKING; spells[24].instant = false; spells[24].perctrigger = (float)RandomFloat(5.0f); spells[24].attackstoptimer = 1000; m_spellcheck[24] = true; spells[25].info = dbcSpell.LookupEntry(10894); spells[25].reqlvl = 58; spells[25].hpreqtocast = 85; spells[25].targettype = TARGET_ATTACKING; spells[25].instant = false; spells[25].perctrigger = (float)RandomFloat(5.0f); spells[25].attackstoptimer = 1000; m_spellcheck[25] = true; spells[26].info = dbcSpell.LookupEntry(10934); spells[26].reqlvl = 54; spells[26].hpreqtocast = 85; spells[26].targettype = TARGET_ATTACKING; spells[26].instant = false; spells[26].perctrigger = (float)RandomFloat(5.0f); spells[26].attackstoptimer = 1000; m_spellcheck[26] = true; spells[27].info = dbcSpell.LookupEntry(10946); spells[27].reqlvl = 52; spells[27].hpreqtocast = 85; spells[27].targettype = TARGET_ATTACKING; spells[27].instant = false; spells[27].perctrigger = (float)RandomFloat(5.0f); spells[27].attackstoptimer = 1000; m_spellcheck[27] = true; spells[28].info = dbcSpell.LookupEntry(10947); spells[28].reqlvl = 58; spells[28].hpreqtocast = 85; spells[28].targettype = TARGET_ATTACKING; spells[28].instant = false; spells[28].perctrigger = (float)RandomFloat(5.0f); spells[28].attackstoptimer = 1000; m_spellcheck[28] = true; spells[29].info = dbcSpell.LookupEntry(17); spells[29].reqlvl = 6; spells[29].hpreqtocast = 85; spells[29].targettype = TARGET_SELF; spells[29].instant = false; spells[29].perctrigger = (float)RandomFloat(5.0f); spells[29].attackstoptimer = 1000; m_spellcheck[29] = true; spells[30].info = dbcSpell.LookupEntry(592); spells[30].reqlvl = 12; spells[30].hpreqtocast = 85; spells[30].targettype = TARGET_SELF; spells[30].instant = false; spells[30].perctrigger = (float)RandomFloat(5.0f); spells[30].attackstoptimer = 1000; m_spellcheck[30] = true; spells[31].info = dbcSpell.LookupEntry(600); spells[31].reqlvl = 18; spells[31].hpreqtocast = 85; spells[31].targettype = TARGET_SELF; spells[31].instant = false; spells[31].perctrigger = (float)RandomFloat(5.0f); spells[31].attackstoptimer = 1000; m_spellcheck[31] = true; spells[32].info = dbcSpell.LookupEntry(3747); spells[32].reqlvl = 24; spells[32].hpreqtocast = 85; spells[32].targettype = TARGET_SELF; spells[32].instant = false; spells[32].perctrigger = (float)RandomFloat(5.0f); spells[32].attackstoptimer = 1000; m_spellcheck[32] = true; spells[33].info = dbcSpell.LookupEntry(6066); spells[33].reqlvl = 36; spells[33].hpreqtocast = 85; spells[33].targettype = TARGET_SELF; spells[33].instant = false; spells[33].perctrigger = (float)RandomFloat(5.0f); spells[33].attackstoptimer = 1000; m_spellcheck[33] = true; spells[34].info = dbcSpell.LookupEntry(10899); spells[34].reqlvl = 48; spells[34].hpreqtocast = 85; spells[34].targettype = TARGET_SELF; spells[34].instant = false; spells[34].perctrigger = (float)RandomFloat(5.0f); spells[34].attackstoptimer = 1000; m_spellcheck[34] = true; spells[35].info = dbcSpell.LookupEntry(10900); spells[35].reqlvl = 54; spells[35].hpreqtocast = 85; spells[35].targettype = TARGET_SELF; spells[35].instant = false; spells[35].perctrigger = (float)RandomFloat(5.0f); spells[35].attackstoptimer = 1000; m_spellcheck[35] = true; spells[36].info = dbcSpell.LookupEntry(2052); spells[36].reqlvl = 4; spells[36].hpreqtocast = 50; spells[36].targettype = TARGET_SELF; spells[36].instant = false; spells[36].perctrigger = (float)RandomFloat(5.0f); spells[36].attackstoptimer = 1000; m_spellcheck[36] = true; spells[37].info = dbcSpell.LookupEntry(2053); spells[37].reqlvl = 10; spells[37].hpreqtocast = 50; spells[37].targettype = TARGET_SELF; spells[37].instant = false; spells[37].perctrigger = (float)RandomFloat(5.0f); spells[37].attackstoptimer = 1000; m_spellcheck[37] = true; spells[38].info = dbcSpell.LookupEntry(9472); spells[38].reqlvl = 26; spells[38].hpreqtocast = 50; spells[38].targettype = TARGET_SELF; spells[38].instant = false; spells[38].perctrigger = (float)RandomFloat(5.0f); spells[38].attackstoptimer = 1000; m_spellcheck[38] = true; spells[39].info = dbcSpell.LookupEntry(9474); spells[39].reqlvl = 38; spells[39].hpreqtocast = 50; spells[39].targettype = TARGET_SELF; spells[39].instant = false; spells[39].perctrigger = (float)RandomFloat(5.0f); spells[39].attackstoptimer = 1000; m_spellcheck[39] = true; spells[40].info = dbcSpell.LookupEntry(10915); spells[40].reqlvl = 44; spells[40].hpreqtocast = 50; spells[40].targettype = TARGET_SELF; spells[40].instant = false; spells[40].perctrigger = (float)RandomFloat(5.0f); spells[40].attackstoptimer = 1000; m_spellcheck[40] = true; spells[41].info = dbcSpell.LookupEntry(10916); spells[41].reqlvl = 50; spells[41].hpreqtocast = 50; spells[41].targettype = TARGET_SELF; spells[41].instant = false; spells[41].perctrigger = (float)RandomFloat(5.0f); spells[41].attackstoptimer = 1000; m_spellcheck[41] = true; spells[42].info = dbcSpell.LookupEntry(10917); spells[42].reqlvl = 56; spells[42].hpreqtocast = 50; spells[42].targettype = TARGET_SELF; spells[42].instant = false; spells[42].perctrigger = (float)RandomFloat(5.0f); spells[42].attackstoptimer = 1000; m_spellcheck[42] = true; spells[43].info = dbcSpell.LookupEntry(139); spells[43].reqlvl = 8; spells[43].hpreqtocast = 50; spells[43].targettype = TARGET_SELF; spells[43].instant = false; spells[43].perctrigger = (float)RandomFloat(5.0f); spells[43].attackstoptimer = 1000; m_spellcheck[43] = true; spells[44].info = dbcSpell.LookupEntry(6074); spells[44].reqlvl = 14; spells[44].hpreqtocast = 50; spells[44].targettype = TARGET_SELF; spells[44].instant = false; spells[44].perctrigger = (float)RandomFloat(5.0f); spells[44].attackstoptimer = 1000; m_spellcheck[44] = true; spells[45].info = dbcSpell.LookupEntry(6075); spells[45].reqlvl = 20; spells[45].hpreqtocast = 50; spells[45].targettype = TARGET_SELF; spells[45].instant = false; spells[45].perctrigger = (float)RandomFloat(5.0f); spells[45].attackstoptimer = 1000; m_spellcheck[45] = true; spells[46].info = dbcSpell.LookupEntry(6078); spells[46].reqlvl = 38; spells[46].hpreqtocast = 50; spells[46].targettype = TARGET_SELF; spells[46].instant = false; spells[46].perctrigger = (float)RandomFloat(5.0f); spells[46].attackstoptimer = 1000; m_spellcheck[46] = true; spells[47].info = dbcSpell.LookupEntry(10927); spells[47].reqlvl = 44; spells[47].hpreqtocast = 50; spells[47].targettype = TARGET_SELF; spells[47].instant = false; spells[47].perctrigger = (float)RandomFloat(5.0f); spells[47].attackstoptimer = 1000; m_spellcheck[47] = true; spells[48].info = dbcSpell.LookupEntry(10929); spells[48].reqlvl = 56; spells[48].hpreqtocast = 50; spells[48].targettype = TARGET_SELF; spells[48].instant = false; spells[48].perctrigger = (float)RandomFloat(5.0f); spells[48].attackstoptimer = 1000; m_spellcheck[48] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if (_unit->GetHealthPct()<=spells[i].hpreqtocast) { if ((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class HumanoidWitchDoctor : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(HumanoidWitchDoctor); SP_AI_Spell spells[30]; bool m_spellcheck[30]; HumanoidWitchDoctor(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 0; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(589); spells[0].reqlvl = 4; spells[0].hpreqtocast = 85; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(24053); spells[1].reqlvl = 30; spells[1].hpreqtocast = 85; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(8042); spells[2].reqlvl = 4; spells[2].hpreqtocast = 85; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(594); spells[3].reqlvl = 10; spells[3].hpreqtocast = 85; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(8092); spells[4].reqlvl = 10; spells[4].hpreqtocast = 85; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(24053); spells[5].reqlvl = 30; spells[5].hpreqtocast = 85; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(8044); spells[6].reqlvl = 8; spells[6].hpreqtocast = 85; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(8277); spells[7].reqlvl = 4; spells[7].hpreqtocast = 85; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(970); spells[8].reqlvl = 18; spells[8].hpreqtocast = 85; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(8102); spells[9].reqlvl = 16; spells[9].hpreqtocast = 85; spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(8045); spells[10].reqlvl = 14; spells[10].hpreqtocast = 85; spells[10].targettype = TARGET_ATTACKING; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(992); spells[11].reqlvl = 26; spells[11].hpreqtocast = 85; spells[11].targettype = TARGET_ATTACKING; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(8104); spells[12].reqlvl = 28; spells[12].hpreqtocast = 85; spells[12].targettype = TARGET_ATTACKING; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; spells[13].info = dbcSpell.LookupEntry(8046); spells[13].reqlvl = 24; spells[13].hpreqtocast = 85; spells[13].targettype = TARGET_ATTACKING; spells[13].instant = false; spells[13].perctrigger = (float)RandomFloat(5.0f); spells[13].attackstoptimer = 1000; m_spellcheck[13] = true; spells[14].info = dbcSpell.LookupEntry(2767); spells[14].reqlvl = 34; spells[14].hpreqtocast = 85; spells[14].targettype = TARGET_ATTACKING; spells[14].instant = false; spells[14].perctrigger = (float)RandomFloat(5.0f); spells[14].attackstoptimer = 1000; m_spellcheck[14] = true; spells[15].info = dbcSpell.LookupEntry(8105); spells[15].reqlvl = 34; spells[15].hpreqtocast = 85; spells[15].targettype = TARGET_ATTACKING; spells[15].instant = false; spells[15].perctrigger = (float)RandomFloat(5.0f); spells[15].attackstoptimer = 1000; m_spellcheck[15] = true; spells[16].info = dbcSpell.LookupEntry(10412); spells[16].reqlvl = 36; spells[16].hpreqtocast = 85; spells[16].targettype = TARGET_ATTACKING; spells[16].instant = false; spells[16].perctrigger = (float)RandomFloat(5.0f); spells[16].attackstoptimer = 1000; m_spellcheck[16] = true; spells[17].info = dbcSpell.LookupEntry(10892); spells[17].reqlvl = 42; spells[17].hpreqtocast = 85; spells[17].targettype = TARGET_ATTACKING; spells[17].instant = false; spells[17].perctrigger = (float)RandomFloat(5.0f); spells[17].attackstoptimer = 1000; m_spellcheck[17] = true; spells[18].info = dbcSpell.LookupEntry(10945); spells[18].reqlvl = 46; spells[18].hpreqtocast = 85; spells[18].targettype = TARGET_ATTACKING; spells[18].instant = false; spells[18].perctrigger = (float)RandomFloat(5.0f); spells[18].attackstoptimer = 1000; m_spellcheck[18] = true; spells[19].info = dbcSpell.LookupEntry(10413); spells[19].reqlvl = 48; spells[19].hpreqtocast = 85; spells[19].targettype = TARGET_ATTACKING; spells[19].instant = false; spells[19].perctrigger = (float)RandomFloat(5.0f); spells[19].attackstoptimer = 1000; m_spellcheck[19] = true; spells[20].info = dbcSpell.LookupEntry(10894); spells[20].reqlvl = 58; spells[20].hpreqtocast = 85; spells[20].targettype = TARGET_ATTACKING; spells[20].instant = false; spells[20].perctrigger = (float)RandomFloat(5.0f); spells[20].attackstoptimer = 1000; m_spellcheck[20] = true; spells[21].info = dbcSpell.LookupEntry(10947); spells[21].reqlvl = 58; spells[21].hpreqtocast = 85; spells[21].targettype = TARGET_ATTACKING; spells[21].instant = false; spells[21].perctrigger = (float)RandomFloat(5.0f); spells[21].attackstoptimer = 1000; m_spellcheck[21] = true; spells[22].info = dbcSpell.LookupEntry(10414); spells[22].reqlvl = 60; spells[22].hpreqtocast = 85; spells[22].targettype = TARGET_ATTACKING; spells[22].instant = false; spells[22].perctrigger = (float)RandomFloat(5.0f); spells[22].attackstoptimer = 1000; m_spellcheck[22] = true; spells[23].info = dbcSpell.LookupEntry(331); spells[23].reqlvl = 1; spells[23].hpreqtocast = 50; spells[23].targettype = TARGET_SELF; spells[23].instant = false; spells[23].perctrigger = (float)RandomFloat(5.0f); spells[23].attackstoptimer = 1000; m_spellcheck[23] = true; spells[24].info = dbcSpell.LookupEntry(332); spells[24].reqlvl = 6; spells[24].hpreqtocast = 50; spells[24].targettype = TARGET_SELF; spells[24].instant = false; spells[24].perctrigger = (float)RandomFloat(5.0f); spells[24].attackstoptimer = 1000; m_spellcheck[24] = true; spells[25].info = dbcSpell.LookupEntry(8004); spells[25].reqlvl = 20; spells[25].hpreqtocast = 50; spells[25].targettype = TARGET_SELF; spells[25].instant = false; spells[25].perctrigger = (float)RandomFloat(5.0f); spells[25].attackstoptimer = 1000; m_spellcheck[25] = true; spells[26].info = dbcSpell.LookupEntry(8008); spells[26].reqlvl = 28; spells[26].hpreqtocast = 50; spells[26].targettype = TARGET_SELF; spells[26].instant = false; spells[26].perctrigger = (float)RandomFloat(5.0f); spells[26].attackstoptimer = 1000; m_spellcheck[26] = true; spells[27].info = dbcSpell.LookupEntry(8010); spells[27].reqlvl = 36; spells[27].hpreqtocast = 50; spells[27].targettype = TARGET_SELF; spells[27].instant = false; spells[27].perctrigger = (float)RandomFloat(5.0f); spells[27].attackstoptimer = 1000; m_spellcheck[27] = true; spells[28].info = dbcSpell.LookupEntry(10466); spells[28].reqlvl = 44; spells[28].hpreqtocast = 50; spells[28].targettype = TARGET_SELF; spells[28].instant = false; spells[28].perctrigger = (float)RandomFloat(5.0f); spells[28].attackstoptimer = 1000; m_spellcheck[28] = true; spells[29].info = dbcSpell.LookupEntry(10468); spells[29].reqlvl = 60; spells[29].hpreqtocast = 50; spells[29].targettype = TARGET_SELF; spells[29].instant = false; spells[29].perctrigger = (float)RandomFloat(5.0f); spells[29].attackstoptimer = 1000; m_spellcheck[29] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if (spells[i].hpreqtocast<=_unit->GetHealthPct()) { if ((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class HumanoidShadowPriest : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(HumanoidShadowPriest); SP_AI_Spell spells[27]; bool m_spellcheck[27]; HumanoidShadowPriest(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 27; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(589); spells[0].reqlvl = 4; spells[0].hpreqtocast = 85; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(15407); spells[1].reqlvl = 20; spells[1].hpreqtocast = 85; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(594); spells[2].reqlvl = 10; spells[2].hpreqtocast = 85; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(8092); spells[3].reqlvl = 10; spells[3].hpreqtocast = 85; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(17311); spells[4].reqlvl = 28; spells[4].hpreqtocast = 85; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(970); spells[5].reqlvl = 18; spells[5].hpreqtocast = 85; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(8102); spells[6].reqlvl = 16; spells[6].hpreqtocast = 85; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(8122); spells[7].reqlvl = 14; spells[7].hpreqtocast = 85; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(15487); spells[8].reqlvl = 0; spells[8].hpreqtocast = 85; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(17312); spells[9].reqlvl = 36; spells[9].hpreqtocast = 85; spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(992); spells[10].reqlvl = 26; spells[10].hpreqtocast = 85; spells[10].targettype = TARGET_ATTACKING; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(984); spells[11].reqlvl = 22; spells[11].hpreqtocast = 85; spells[11].targettype = TARGET_ATTACKING; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(8103); spells[12].reqlvl = 22; spells[12].hpreqtocast = 85; spells[12].targettype = TARGET_ATTACKING; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; spells[13].info = dbcSpell.LookupEntry(8104); spells[13].reqlvl = 28; spells[13].hpreqtocast = 85; spells[13].targettype = TARGET_ATTACKING; spells[13].instant = false; spells[13].perctrigger = (float)RandomFloat(5.0f); spells[13].attackstoptimer = 1000; m_spellcheck[13] = true; spells[14].info = dbcSpell.LookupEntry(8122); spells[14].reqlvl = 14; spells[14].hpreqtocast = 85; spells[14].targettype = TARGET_ATTACKING; spells[14].instant = false; spells[14].perctrigger = (float)RandomFloat(5.0f); spells[14].attackstoptimer = 1000; m_spellcheck[14] = true; spells[15].info = dbcSpell.LookupEntry(17313); spells[15].reqlvl = 44; spells[15].hpreqtocast = 85; spells[15].targettype = TARGET_ATTACKING; spells[15].instant = false; spells[15].perctrigger = (float)RandomFloat(5.0f); spells[15].attackstoptimer = 1000; m_spellcheck[15] = true; spells[16].info = dbcSpell.LookupEntry(2767); spells[16].reqlvl = 34; spells[16].hpreqtocast = 85; spells[16].targettype = TARGET_ATTACKING; spells[16].instant = false; spells[16].perctrigger = (float)RandomFloat(5.0f); spells[16].attackstoptimer = 1000; m_spellcheck[16] = true; spells[17].info = dbcSpell.LookupEntry(8105); spells[17].reqlvl = 34; spells[17].hpreqtocast = 85; spells[17].targettype = TARGET_ATTACKING; spells[17].instant = false; spells[17].perctrigger = (float)RandomFloat(5.0f); spells[17].attackstoptimer = 1000; m_spellcheck[17] = true; spells[18].info = dbcSpell.LookupEntry(17314); spells[18].reqlvl = 52; spells[18].hpreqtocast = 85; spells[18].targettype = TARGET_ATTACKING; spells[18].instant = false; spells[18].perctrigger = (float)RandomFloat(5.0f); spells[18].attackstoptimer = 1000; m_spellcheck[18] = true; spells[19].info = dbcSpell.LookupEntry(10892); spells[19].reqlvl = 42; spells[19].hpreqtocast = 85; spells[19].targettype = TARGET_ATTACKING; spells[19].instant = false; spells[19].perctrigger = (float)RandomFloat(5.0f); spells[19].attackstoptimer = 1000; m_spellcheck[19] = true; spells[20].info = dbcSpell.LookupEntry(8106); spells[20].reqlvl = 40; spells[20].hpreqtocast = 85; spells[20].targettype = TARGET_ATTACKING; spells[20].instant = false; spells[20].perctrigger = (float)RandomFloat(5.0f); spells[20].attackstoptimer = 1000; m_spellcheck[20] = true; spells[21].info = dbcSpell.LookupEntry(10945); spells[21].reqlvl = 46; spells[21].hpreqtocast = 85; spells[21].targettype = TARGET_ATTACKING; spells[21].instant = false; spells[21].perctrigger = (float)RandomFloat(5.0f); spells[21].attackstoptimer = 1000; m_spellcheck[21] = true; spells[22].info = dbcSpell.LookupEntry(18807); spells[22].reqlvl = 60; spells[22].hpreqtocast = 85; spells[22].targettype = TARGET_ATTACKING; spells[22].instant = false; spells[22].perctrigger = (float)RandomFloat(5.0f); spells[22].attackstoptimer = 1000; m_spellcheck[22] = true; spells[23].info = dbcSpell.LookupEntry(10893); spells[23].reqlvl = 50; spells[23].hpreqtocast = 85; spells[23].targettype = TARGET_ATTACKING; spells[23].instant = false; spells[23].perctrigger = (float)RandomFloat(5.0f); spells[23].attackstoptimer = 1000; m_spellcheck[23] = true; spells[24].info = dbcSpell.LookupEntry(10894); spells[24].reqlvl = 58; spells[24].hpreqtocast = 85; spells[24].targettype = TARGET_ATTACKING; spells[24].instant = false; spells[24].perctrigger = (float)RandomFloat(5.0f); spells[24].attackstoptimer = 1000; m_spellcheck[24] = true; spells[25].info = dbcSpell.LookupEntry(10946); spells[25].reqlvl = 52; spells[25].hpreqtocast = 85; spells[25].targettype = TARGET_ATTACKING; spells[25].instant = false; spells[25].perctrigger = (float)RandomFloat(5.0f); spells[25].attackstoptimer = 1000; m_spellcheck[25] = true; spells[26].info = dbcSpell.LookupEntry(10947); spells[26].reqlvl = 58; spells[26].hpreqtocast = 85; spells[26].targettype = TARGET_ATTACKING; spells[26].instant = false; spells[26].perctrigger = (float)RandomFloat(5.0f); spells[26].attackstoptimer = 1000; m_spellcheck[26] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if (spells[i].hpreqtocast<=_unit->GetHealthPct()) { if ((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class HumanoidHolyPriest : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(HumanoidHolyPriest); SP_AI_Spell spells[37]; bool m_spellcheck[37]; HumanoidHolyPriest(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 37; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(585); spells[0].reqlvl = 1; spells[0].hpreqtocast = 85; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(591); spells[1].reqlvl = 6; spells[1].hpreqtocast = 85; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(598); spells[2].reqlvl = 14; spells[2].hpreqtocast = 85; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(15237); spells[3].reqlvl = 20; spells[3].hpreqtocast = 85; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(15262); spells[4].reqlvl = 24; spells[4].hpreqtocast = 85; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(984); spells[5].reqlvl = 22; spells[5].hpreqtocast = 85; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(15430); spells[6].reqlvl = 28; spells[6].hpreqtocast = 85; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(15264); spells[7].reqlvl = 36; spells[7].hpreqtocast = 85; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(1004); spells[8].reqlvl = 30; spells[8].hpreqtocast = 85; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(15431); spells[9].reqlvl = 36; spells[9].hpreqtocast = 85; spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(15266); spells[10].reqlvl = 48; spells[10].hpreqtocast = 85; spells[10].targettype = TARGET_ATTACKING; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(10933); spells[11].reqlvl = 46; spells[11].hpreqtocast = 85; spells[11].targettype = TARGET_ATTACKING; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(15431); spells[12].reqlvl = 36; spells[12].hpreqtocast = 85; spells[12].targettype = TARGET_ATTACKING; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; spells[13].info = dbcSpell.LookupEntry(15267); spells[13].reqlvl = 54; spells[13].hpreqtocast = 85; spells[13].targettype = TARGET_ATTACKING; spells[13].instant = false; spells[13].perctrigger = (float)RandomFloat(5.0f); spells[13].attackstoptimer = 1000; m_spellcheck[13] = true; spells[14].info = dbcSpell.LookupEntry(10934); spells[14].reqlvl = 54; spells[14].hpreqtocast = 85; spells[14].targettype = TARGET_ATTACKING; spells[14].instant = false; spells[14].perctrigger = (float)RandomFloat(5.0f); spells[14].attackstoptimer = 1000; m_spellcheck[14] = true; spells[15].info = dbcSpell.LookupEntry(15431); spells[15].reqlvl = 36; spells[15].hpreqtocast = 85; spells[15].targettype = TARGET_ATTACKING; spells[15].instant = false; spells[15].perctrigger = (float)RandomFloat(5.0f); spells[15].attackstoptimer = 1000; m_spellcheck[15] = true; spells[16].info = dbcSpell.LookupEntry(15261); spells[16].reqlvl = 60; spells[16].hpreqtocast = 85; spells[16].targettype = TARGET_ATTACKING; spells[16].instant = false; spells[16].perctrigger = (float)RandomFloat(5.0f); spells[16].attackstoptimer = 1000; m_spellcheck[16] = true; spells[17].info = dbcSpell.LookupEntry(17); spells[17].reqlvl = 6; spells[17].hpreqtocast = 85; spells[17].targettype = TARGET_SELF; spells[17].instant = false; spells[17].perctrigger = (float)RandomFloat(5.0f); spells[17].attackstoptimer = 1000; m_spellcheck[17] = true; spells[18].info = dbcSpell.LookupEntry(592); spells[18].reqlvl = 12; spells[18].hpreqtocast = 85; spells[18].targettype = TARGET_SELF; spells[18].instant = false; spells[18].perctrigger = (float)RandomFloat(5.0f); spells[18].attackstoptimer = 1000; m_spellcheck[18] = true; spells[19].info = dbcSpell.LookupEntry(600); spells[19].reqlvl = 18; spells[19].hpreqtocast = 85; spells[19].targettype = TARGET_SELF; spells[19].instant = false; spells[19].perctrigger = (float)RandomFloat(5.0f); spells[19].attackstoptimer = 1000; m_spellcheck[19] = true; spells[20].info = dbcSpell.LookupEntry(3747); spells[20].reqlvl = 24; spells[20].hpreqtocast = 85; spells[20].targettype = TARGET_SELF; spells[20].instant = false; spells[20].perctrigger = (float)RandomFloat(5.0f); spells[20].attackstoptimer = 1000; m_spellcheck[20] = true; spells[21].info = dbcSpell.LookupEntry(6066); spells[21].reqlvl = 36; spells[21].hpreqtocast = 85; spells[21].targettype = TARGET_SELF; spells[21].instant = false; spells[21].perctrigger = (float)RandomFloat(5.0f); spells[21].attackstoptimer = 1000; m_spellcheck[21] = true; spells[22].info = dbcSpell.LookupEntry(10899); spells[22].reqlvl = 48; spells[22].hpreqtocast = 85; spells[22].targettype = TARGET_SELF; spells[22].instant = false; spells[22].perctrigger = (float)RandomFloat(5.0f); spells[22].attackstoptimer = 1000; m_spellcheck[22] = true; spells[23].info = dbcSpell.LookupEntry(10900); spells[23].reqlvl = 54; spells[23].hpreqtocast = 85; spells[23].targettype = TARGET_SELF; spells[23].instant = false; spells[23].perctrigger = (float)RandomFloat(5.0f); spells[23].attackstoptimer = 1000; m_spellcheck[23] = true; spells[24].info = dbcSpell.LookupEntry(2052); spells[24].reqlvl = 4; spells[24].hpreqtocast = 50; spells[24].targettype = TARGET_SELF; spells[24].instant = false; spells[24].perctrigger = (float)RandomFloat(5.0f); spells[24].attackstoptimer = 1000; m_spellcheck[24] = true; spells[25].info = dbcSpell.LookupEntry(2053); spells[25].reqlvl = 10; spells[25].hpreqtocast = 50; spells[25].targettype = TARGET_SELF; spells[25].instant = false; spells[25].perctrigger = (float)RandomFloat(5.0f); spells[25].attackstoptimer = 1000; m_spellcheck[25] = true; spells[26].info = dbcSpell.LookupEntry(9472); spells[26].reqlvl = 26; spells[26].hpreqtocast = 50; spells[26].targettype = TARGET_SELF; spells[26].instant = false; spells[26].perctrigger = (float)RandomFloat(5.0f); spells[26].attackstoptimer = 1000; m_spellcheck[26] = true; spells[27].info = dbcSpell.LookupEntry(9474); spells[27].reqlvl = 38; spells[27].hpreqtocast = 50; spells[27].targettype = TARGET_SELF; spells[27].instant = false; spells[27].perctrigger = (float)RandomFloat(5.0f); spells[27].attackstoptimer = 1000; m_spellcheck[27] = true; spells[28].info = dbcSpell.LookupEntry(10915); spells[28].reqlvl = 44; spells[28].hpreqtocast = 50; spells[28].targettype = TARGET_SELF; spells[28].instant = false; spells[28].perctrigger = (float)RandomFloat(5.0f); spells[28].attackstoptimer = 1000; m_spellcheck[28] = true; spells[29].info = dbcSpell.LookupEntry(10916); spells[29].reqlvl = 50; spells[29].hpreqtocast = 50; spells[29].targettype = TARGET_SELF; spells[29].instant = false; spells[29].perctrigger = (float)RandomFloat(5.0f); spells[29].attackstoptimer = 1000; m_spellcheck[29] = true; spells[30].info = dbcSpell.LookupEntry(10917); spells[30].reqlvl = 56; spells[30].hpreqtocast = 50; spells[30].targettype = TARGET_SELF; spells[30].instant = false; spells[30].perctrigger = (float)RandomFloat(5.0f); spells[30].attackstoptimer = 1000; m_spellcheck[30] = true; spells[31].info = dbcSpell.LookupEntry(139); spells[31].reqlvl = 8; spells[31].hpreqtocast = 50; spells[31].targettype = TARGET_SELF; spells[31].instant = false; spells[31].perctrigger = (float)RandomFloat(5.0f); spells[31].attackstoptimer = 1000; m_spellcheck[31] = true; spells[32].info = dbcSpell.LookupEntry(6074); spells[32].reqlvl = 14; spells[32].hpreqtocast = 50; spells[32].targettype = TARGET_SELF; spells[32].instant = false; spells[32].perctrigger = (float)RandomFloat(5.0f); spells[32].attackstoptimer = 1000; m_spellcheck[32] = true; spells[33].info = dbcSpell.LookupEntry(6075); spells[33].reqlvl = 20; spells[33].hpreqtocast = 50; spells[33].targettype = TARGET_SELF; spells[33].instant = false; spells[33].perctrigger = (float)RandomFloat(5.0f); spells[33].attackstoptimer = 1000; m_spellcheck[33] = true; spells[34].info = dbcSpell.LookupEntry(6078); spells[34].reqlvl = 38; spells[34].hpreqtocast = 50; spells[34].targettype = TARGET_SELF; spells[34].instant = false; spells[34].perctrigger = (float)RandomFloat(5.0f); spells[34].attackstoptimer = 1000; m_spellcheck[34] = true; spells[35].info = dbcSpell.LookupEntry(10927); spells[35].reqlvl = 44; spells[35].hpreqtocast = 50; spells[35].targettype = TARGET_SELF; spells[35].instant = false; spells[35].perctrigger = (float)RandomFloat(5.0f); spells[35].attackstoptimer = 1000; m_spellcheck[35] = true; spells[36].info = dbcSpell.LookupEntry(10929); spells[36].reqlvl = 56; spells[36].hpreqtocast = 50; spells[36].targettype = TARGET_SELF; spells[36].instant = false; spells[36].perctrigger = (float)RandomFloat(5.0f); spells[36].attackstoptimer = 1000; m_spellcheck[36] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if (spells[i].hpreqtocast<=_unit->GetHealthPct()) { if ((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class HumanoidDruid : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(HumanoidDruid); SP_AI_Spell spells[68]; bool m_spellcheck[68]; HumanoidDruid(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 68; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(5176); spells[0].reqlvl = 1; spells[0].hpreqtocast = 85; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(8921); spells[1].reqlvl = 4; spells[1].hpreqtocast = 85; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(5177); spells[2].reqlvl = 6; spells[2].hpreqtocast = 85; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(8924); spells[3].reqlvl = 10; spells[3].hpreqtocast = 85; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(5178); spells[4].reqlvl = 14; spells[4].hpreqtocast = 85; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(8925); spells[5].reqlvl = 16; spells[5].hpreqtocast = 85; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(770); spells[6].reqlvl = 18; spells[6].hpreqtocast = 85; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(5570); spells[7].reqlvl = 20; spells[7].hpreqtocast = 85; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(2912); spells[8].reqlvl = 20; spells[8].hpreqtocast = 85; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(5179); spells[9].reqlvl = 22; spells[9].hpreqtocast = 85; spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(8926); spells[10].reqlvl = 22; spells[10].hpreqtocast = 85; spells[10].targettype = TARGET_ATTACKING; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(778); spells[11].reqlvl = 30; spells[11].hpreqtocast = 85; spells[11].targettype = TARGET_ATTACKING; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(24974); spells[12].reqlvl = 30; spells[12].hpreqtocast = 85; spells[12].targettype = TARGET_ATTACKING; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; spells[13].info = dbcSpell.LookupEntry(8949); spells[13].reqlvl = 26; spells[13].hpreqtocast = 85; spells[13].targettype = TARGET_ATTACKING; spells[13].instant = false; spells[13].perctrigger = (float)RandomFloat(5.0f); spells[13].attackstoptimer = 1000; m_spellcheck[13] = true; spells[14].info = dbcSpell.LookupEntry(5180); spells[14].reqlvl = 30; spells[14].hpreqtocast = 85; spells[14].targettype = TARGET_ATTACKING; spells[14].instant = false; spells[14].perctrigger = (float)RandomFloat(5.0f); spells[14].attackstoptimer = 1000; m_spellcheck[14] = true; spells[15].info = dbcSpell.LookupEntry(8927); spells[15].reqlvl = 28; spells[15].hpreqtocast = 85; spells[15].targettype = TARGET_ATTACKING; spells[15].instant = false; spells[15].perctrigger = (float)RandomFloat(5.0f); spells[15].attackstoptimer = 1000; m_spellcheck[15] = true; spells[16].info = dbcSpell.LookupEntry(9749); spells[16].reqlvl = 42; spells[16].hpreqtocast = 85; spells[16].targettype = TARGET_ATTACKING; spells[16].instant = false; spells[16].perctrigger = (float)RandomFloat(5.0f); spells[16].attackstoptimer = 1000; m_spellcheck[16] = true; spells[17].info = dbcSpell.LookupEntry(24975); spells[17].reqlvl = 40; spells[17].hpreqtocast = 85; spells[17].targettype = TARGET_ATTACKING; spells[17].instant = false; spells[17].perctrigger = (float)RandomFloat(5.0f); spells[17].attackstoptimer = 1000; m_spellcheck[17] = true; spells[18].info = dbcSpell.LookupEntry(8950); spells[18].reqlvl = 34; spells[18].hpreqtocast = 85; spells[18].targettype = TARGET_ATTACKING; spells[18].instant = false; spells[18].perctrigger = (float)RandomFloat(5.0f); spells[18].attackstoptimer = 1000; m_spellcheck[18] = true; spells[19].info = dbcSpell.LookupEntry(16914); spells[19].reqlvl = 40; spells[19].hpreqtocast = 85; spells[19].targettype = TARGET_ATTACKING; spells[19].instant = false; spells[19].perctrigger = (float)RandomFloat(5.0f); spells[19].attackstoptimer = 1000; m_spellcheck[19] = true; spells[20].info = dbcSpell.LookupEntry(6780); spells[20].reqlvl = 38; spells[20].hpreqtocast = 85; spells[20].targettype = TARGET_ATTACKING; spells[20].instant = false; spells[20].perctrigger = (float)RandomFloat(5.0f); spells[20].attackstoptimer = 1000; m_spellcheck[20] = true; spells[21].info = dbcSpell.LookupEntry(8905); spells[21].reqlvl = 46; spells[21].hpreqtocast = 85; spells[21].targettype = TARGET_ATTACKING; spells[21].instant = false; spells[21].perctrigger = (float)RandomFloat(5.0f); spells[21].attackstoptimer = 1000; m_spellcheck[21] = true; spells[22].info = dbcSpell.LookupEntry(8928); spells[22].reqlvl = 34; spells[22].hpreqtocast = 85; spells[22].targettype = TARGET_ATTACKING; spells[22].instant = false; spells[22].perctrigger = (float)RandomFloat(5.0f); spells[22].attackstoptimer = 1000; m_spellcheck[22] = true; spells[23].info = dbcSpell.LookupEntry(8929); spells[23].reqlvl = 40; spells[23].hpreqtocast = 85; spells[23].targettype = TARGET_ATTACKING; spells[23].instant = false; spells[23].perctrigger = (float)RandomFloat(5.0f); spells[23].attackstoptimer = 1000; m_spellcheck[23] = true; spells[24].info = dbcSpell.LookupEntry(9907); spells[24].reqlvl = 54; spells[24].hpreqtocast = 85; spells[24].targettype = TARGET_ATTACKING; spells[24].instant = false; spells[24].perctrigger = (float)RandomFloat(5.0f); spells[24].attackstoptimer = 1000; m_spellcheck[24] = true; spells[25].info = dbcSpell.LookupEntry(24976); spells[25].reqlvl = 50; spells[25].hpreqtocast = 85; spells[25].targettype = TARGET_ATTACKING; spells[25].instant = false; spells[25].perctrigger = (float)RandomFloat(5.0f); spells[25].attackstoptimer = 1000; m_spellcheck[25] = true; spells[26].info = dbcSpell.LookupEntry(8951); spells[26].reqlvl = 42; spells[26].hpreqtocast = 85; spells[26].targettype = TARGET_ATTACKING; spells[26].instant = false; spells[26].perctrigger = (float)RandomFloat(5.0f); spells[26].attackstoptimer = 1000; m_spellcheck[26] = true; spells[27].info = dbcSpell.LookupEntry(17401); spells[27].reqlvl = 50; spells[27].hpreqtocast = 85; spells[27].targettype = TARGET_ATTACKING; spells[27].instant = false; spells[27].perctrigger = (float)RandomFloat(5.0f); spells[27].attackstoptimer = 1000; m_spellcheck[27] = true; spells[28].info = dbcSpell.LookupEntry(9912); spells[28].reqlvl = 54; spells[28].hpreqtocast = 85; spells[28].targettype = TARGET_ATTACKING; spells[28].instant = false; spells[28].perctrigger = (float)RandomFloat(5.0f); spells[28].attackstoptimer = 1000; m_spellcheck[28] = true; spells[29].info = dbcSpell.LookupEntry(9833); spells[29].reqlvl = 46; spells[29].hpreqtocast = 85; spells[29].targettype = TARGET_ATTACKING; spells[29].instant = false; spells[29].perctrigger = (float)RandomFloat(5.0f); spells[29].attackstoptimer = 1000; m_spellcheck[29] = true; spells[30].info = dbcSpell.LookupEntry(9834); spells[30].reqlvl = 52; spells[30].hpreqtocast = 85; spells[30].targettype = TARGET_ATTACKING; spells[30].instant = false; spells[30].perctrigger = (float)RandomFloat(5.0f); spells[30].attackstoptimer = 1000; m_spellcheck[30] = true; spells[31].info = dbcSpell.LookupEntry(9907); spells[31].reqlvl = 54; spells[31].hpreqtocast = 85; spells[31].targettype = TARGET_ATTACKING; spells[31].instant = false; spells[31].perctrigger = (float)RandomFloat(5.0f); spells[31].attackstoptimer = 1000; m_spellcheck[31] = true; spells[32].info = dbcSpell.LookupEntry(24977); spells[32].reqlvl = 60; spells[32].hpreqtocast = 85; spells[32].targettype = TARGET_ATTACKING; spells[32].instant = false; spells[32].perctrigger = (float)RandomFloat(5.0f); spells[32].attackstoptimer = 1000; m_spellcheck[32] = true; spells[33].info = dbcSpell.LookupEntry(9875); spells[33].reqlvl = 50; spells[33].hpreqtocast = 85; spells[33].targettype = TARGET_ATTACKING; spells[33].instant = false; spells[33].perctrigger = (float)RandomFloat(5.0f); spells[33].attackstoptimer = 1000; m_spellcheck[33] = true; spells[34].info = dbcSpell.LookupEntry(9876); spells[34].reqlvl = 58; spells[34].hpreqtocast = 85; spells[34].targettype = TARGET_ATTACKING; spells[34].instant = false; spells[34].perctrigger = (float)RandomFloat(5.0f); spells[34].attackstoptimer = 1000; m_spellcheck[34] = true; spells[35].info = dbcSpell.LookupEntry(17402); spells[35].reqlvl = 60; spells[35].hpreqtocast = 85; spells[35].targettype = TARGET_ATTACKING; spells[35].instant = false; spells[35].perctrigger = (float)RandomFloat(5.0f); spells[35].attackstoptimer = 1000; m_spellcheck[35] = true; spells[36].info = dbcSpell.LookupEntry(467); spells[36].reqlvl = 6; spells[36].hpreqtocast = 85; spells[36].targettype = TARGET_SELF; spells[36].instant = false; spells[36].perctrigger = (float)RandomFloat(5.0f); spells[36].attackstoptimer = 1000; m_spellcheck[36] = true; spells[37].info = dbcSpell.LookupEntry(782); spells[37].reqlvl = 14; spells[37].hpreqtocast = 85; spells[37].targettype = TARGET_SELF; spells[37].instant = false; spells[37].perctrigger = (float)RandomFloat(5.0f); spells[37].attackstoptimer = 1000; m_spellcheck[37] = true; spells[38].info = dbcSpell.LookupEntry(1075); spells[38].reqlvl = 24; spells[38].hpreqtocast = 85; spells[38].targettype = TARGET_SELF; spells[38].instant = false; spells[38].perctrigger = (float)RandomFloat(5.0f); spells[38].attackstoptimer = 1000; m_spellcheck[38] = true; spells[39].info = dbcSpell.LookupEntry(8914); spells[39].reqlvl = 34; spells[39].hpreqtocast = 85; spells[39].targettype = TARGET_SELF; spells[39].instant = false; spells[39].perctrigger = (float)RandomFloat(5.0f); spells[39].attackstoptimer = 1000; m_spellcheck[39] = true; spells[40].info = dbcSpell.LookupEntry(9756); spells[40].reqlvl = 44; spells[40].hpreqtocast = 85; spells[40].targettype = TARGET_SELF; spells[40].instant = false; spells[40].perctrigger = (float)RandomFloat(5.0f); spells[40].attackstoptimer = 1000; m_spellcheck[40] = true; spells[41].info = dbcSpell.LookupEntry(9910); spells[41].reqlvl = 54; spells[41].hpreqtocast = 85; spells[41].targettype = TARGET_SELF; spells[41].instant = false; spells[41].perctrigger = (float)RandomFloat(5.0f); spells[41].attackstoptimer = 1000; m_spellcheck[41] = true; spells[42].info = dbcSpell.LookupEntry(16689); spells[42].reqlvl = 10; spells[42].hpreqtocast = 50; spells[42].targettype = TARGET_SELF; spells[42].instant = false; spells[42].perctrigger = (float)RandomFloat(5.0f); spells[42].attackstoptimer = 1000; m_spellcheck[42] = true; spells[43].info = dbcSpell.LookupEntry(16810); spells[43].reqlvl = 18; spells[43].hpreqtocast = 50; spells[43].targettype = TARGET_SELF; spells[43].instant = false; spells[43].perctrigger = (float)RandomFloat(5.0f); spells[43].attackstoptimer = 1000; m_spellcheck[43] = true; spells[44].info = dbcSpell.LookupEntry(16811); spells[44].reqlvl = 28; spells[44].hpreqtocast = 50; spells[44].targettype = TARGET_SELF; spells[44].instant = false; spells[44].perctrigger = (float)RandomFloat(5.0f); spells[44].attackstoptimer = 1000; m_spellcheck[44] = true; spells[45].info = dbcSpell.LookupEntry(16812); spells[45].reqlvl = 38; spells[45].hpreqtocast = 50; spells[45].targettype = TARGET_SELF; spells[45].instant = false; spells[45].perctrigger = (float)RandomFloat(5.0f); spells[45].attackstoptimer = 1000; m_spellcheck[45] = true; spells[46].info = dbcSpell.LookupEntry(16813); spells[46].reqlvl = 48; spells[46].hpreqtocast = 50; spells[46].targettype = TARGET_SELF; spells[46].instant = false; spells[46].perctrigger = (float)RandomFloat(5.0f); spells[46].attackstoptimer = 1000; m_spellcheck[46] = true; spells[47].info = dbcSpell.LookupEntry(17329); spells[47].reqlvl = 58; spells[47].hpreqtocast = 50; spells[47].targettype = TARGET_SELF; spells[47].instant = false; spells[47].perctrigger = (float)RandomFloat(5.0f); spells[47].attackstoptimer = 1000; m_spellcheck[47] = true; spells[48].info = dbcSpell.LookupEntry(774); spells[48].reqlvl = 4; spells[48].hpreqtocast = 50; spells[48].targettype = TARGET_SELF; spells[48].instant = false; spells[48].perctrigger = (float)RandomFloat(5.0f); spells[48].attackstoptimer = 1000; m_spellcheck[48] = true; spells[49].info = dbcSpell.LookupEntry(1058); spells[49].reqlvl = 10; spells[49].hpreqtocast = 50; spells[49].targettype = TARGET_SELF; spells[49].instant = false; spells[49].perctrigger = (float)RandomFloat(5.0f); spells[49].attackstoptimer = 1000; m_spellcheck[49] = true; spells[50].info = dbcSpell.LookupEntry(1430); spells[50].reqlvl = 16; spells[50].hpreqtocast = 50; spells[50].targettype = TARGET_SELF; spells[50].instant = false; spells[50].perctrigger = (float)RandomFloat(5.0f); spells[50].attackstoptimer = 1000; m_spellcheck[50] = true; spells[51].info = dbcSpell.LookupEntry(2090); spells[51].reqlvl = 22; spells[51].hpreqtocast = 50; spells[51].targettype = TARGET_SELF; spells[51].instant = false; spells[51].perctrigger = (float)RandomFloat(5.0f); spells[51].attackstoptimer = 1000; m_spellcheck[51] = true; spells[52].info = dbcSpell.LookupEntry(2091); spells[52].reqlvl = 28; spells[52].hpreqtocast = 50; spells[52].targettype = TARGET_SELF; spells[52].instant = false; spells[52].perctrigger = (float)RandomFloat(5.0f); spells[52].attackstoptimer = 1000; m_spellcheck[52] = true; spells[53].info = dbcSpell.LookupEntry(3627); spells[53].reqlvl = 34; spells[53].hpreqtocast = 50; spells[53].targettype = TARGET_SELF; spells[53].instant = false; spells[53].perctrigger = (float)RandomFloat(5.0f); spells[53].attackstoptimer = 1000; m_spellcheck[53] = true; spells[54].info = dbcSpell.LookupEntry(8910); spells[54].reqlvl = 40; spells[54].hpreqtocast = 50; spells[54].targettype = TARGET_SELF; spells[54].instant = false; spells[54].perctrigger = (float)RandomFloat(5.0f); spells[54].attackstoptimer = 1000; m_spellcheck[54] = true; spells[55].info = dbcSpell.LookupEntry(5185); spells[55].reqlvl = 1; spells[55].hpreqtocast = 50; spells[55].targettype = TARGET_SELF; spells[55].instant = false; spells[55].perctrigger = (float)RandomFloat(5.0f); spells[55].attackstoptimer = 1000; m_spellcheck[55] = true; spells[56].info = dbcSpell.LookupEntry(5186); spells[56].reqlvl = 8; spells[56].hpreqtocast = 50; spells[56].targettype = TARGET_SELF; spells[56].instant = false; spells[56].perctrigger = (float)RandomFloat(5.0f); spells[56].attackstoptimer = 1000; m_spellcheck[56] = true; spells[57].info = dbcSpell.LookupEntry(5187); spells[57].reqlvl = 14; spells[57].hpreqtocast = 50; spells[57].targettype = TARGET_SELF; spells[57].instant = false; spells[57].perctrigger = (float)RandomFloat(5.0f); spells[57].attackstoptimer = 1000; m_spellcheck[57] = true; spells[58].info = dbcSpell.LookupEntry(5188); spells[58].reqlvl = 20; spells[58].hpreqtocast = 50; spells[58].targettype = TARGET_SELF; spells[58].instant = false; spells[58].perctrigger = (float)RandomFloat(5.0f); spells[58].attackstoptimer = 1000; m_spellcheck[58] = true; spells[59].info = dbcSpell.LookupEntry(5189); spells[59].reqlvl = 26; spells[59].hpreqtocast = 50; spells[59].targettype = TARGET_SELF; spells[59].instant = false; spells[59].perctrigger = (float)RandomFloat(5.0f); spells[59].attackstoptimer = 1000; m_spellcheck[59] = true; spells[60].info = dbcSpell.LookupEntry(6778); spells[60].reqlvl = 32; spells[60].hpreqtocast = 50; spells[60].targettype = TARGET_SELF; spells[60].instant = false; spells[60].perctrigger = (float)RandomFloat(5.0f); spells[60].attackstoptimer = 1000; m_spellcheck[60] = true; spells[61].info = dbcSpell.LookupEntry(8903); spells[61].reqlvl = 38; spells[61].hpreqtocast = 50; spells[61].targettype = TARGET_SELF; spells[61].instant = false; spells[61].perctrigger = (float)RandomFloat(5.0f); spells[61].attackstoptimer = 1000; m_spellcheck[61] = true; spells[62].info = dbcSpell.LookupEntry(339); spells[62].reqlvl = 8; spells[62].hpreqtocast = 20; spells[62].targettype = TARGET_ATTACKING; spells[62].instant = false; spells[62].perctrigger = (float)RandomFloat(5.0f); spells[62].attackstoptimer = 1000; m_spellcheck[62] = true; spells[63].info = dbcSpell.LookupEntry(1062); spells[63].reqlvl = 18; spells[63].hpreqtocast = 20; spells[63].targettype = TARGET_ATTACKING; spells[63].instant = false; spells[63].perctrigger = (float)RandomFloat(5.0f); spells[63].attackstoptimer = 1000; m_spellcheck[63] = true; spells[64].info = dbcSpell.LookupEntry(5195); spells[64].reqlvl = 28; spells[64].hpreqtocast = 20; spells[64].targettype = TARGET_ATTACKING; spells[64].instant = false; spells[64].perctrigger = (float)RandomFloat(5.0f); spells[64].attackstoptimer = 1000; m_spellcheck[64] = true; spells[65].info = dbcSpell.LookupEntry(5196); spells[65].reqlvl = 38; spells[65].hpreqtocast = 20; spells[65].targettype = TARGET_ATTACKING; spells[65].instant = false; spells[65].perctrigger = (float)RandomFloat(5.0f); spells[65].attackstoptimer = 1000; m_spellcheck[65] = true; spells[66].info = dbcSpell.LookupEntry(9852); spells[66].reqlvl = 48; spells[66].hpreqtocast = 20; spells[66].targettype = TARGET_ATTACKING; spells[66].instant = false; spells[66].perctrigger = (float)RandomFloat(5.0f); spells[66].attackstoptimer = 1000; m_spellcheck[66] = true; spells[67].info = dbcSpell.LookupEntry(9853); spells[67].reqlvl = 58; spells[67].hpreqtocast = 20; spells[67].targettype = TARGET_ATTACKING; spells[67].instant = false; spells[67].perctrigger = (float)RandomFloat(5.0f); spells[67].attackstoptimer = 1000; m_spellcheck[67] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if (spells[i].hpreqtocast<=_unit->GetHealthPct()) { if ((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class HumanoidRogue : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(HumanoidRogue); SP_AI_Spell spells[21]; bool m_spellcheck[21]; HumanoidRogue(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 21; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(13518); spells[0].reqlvl = 10; spells[0].hpreqtocast = 85; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(15614); spells[1].reqlvl = 20; spells[1].hpreqtocast = 85; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(16400); spells[2].reqlvl = 10; spells[2].hpreqtocast = 85; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(15614); spells[3].reqlvl = 20; spells[3].hpreqtocast = 85; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(12540); spells[4].reqlvl = 18; spells[4].hpreqtocast = 85; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(15614); spells[5].reqlvl = 20; spells[5].hpreqtocast = 85; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(14873); spells[6].reqlvl = 20; spells[6].hpreqtocast = 85; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(7159); spells[7].reqlvl = 4; spells[7].hpreqtocast = 85; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(8313); spells[8].reqlvl = 25; spells[8].hpreqtocast = 85; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(6409); spells[9].reqlvl = 20; spells[9].hpreqtocast = 85; spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(12540); spells[10].reqlvl = 18; spells[10].hpreqtocast = 85; spells[10].targettype = TARGET_ATTACKING; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(15614); spells[11].reqlvl = 20; spells[11].hpreqtocast = 85; spells[11].targettype = TARGET_ATTACKING; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(15581); spells[12].reqlvl = 20; spells[12].hpreqtocast = 85; spells[12].targettype = TARGET_ATTACKING; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; spells[13].info = dbcSpell.LookupEntry(15657); spells[13].reqlvl = 4; spells[13].hpreqtocast = 85; spells[13].targettype = TARGET_ATTACKING; spells[13].instant = false; spells[13].perctrigger = (float)RandomFloat(5.0f); spells[13].attackstoptimer = 1000; m_spellcheck[13] = true; spells[14].info = dbcSpell.LookupEntry(13298); spells[14].reqlvl = 20; spells[14].hpreqtocast = 85; spells[14].targettype = TARGET_ATTACKING; spells[14].instant = false; spells[14].perctrigger = (float)RandomFloat(5.0f); spells[14].attackstoptimer = 1000; m_spellcheck[14] = true; spells[15].info = dbcSpell.LookupEntry(15667); spells[15].reqlvl = 20; spells[15].hpreqtocast = 85; spells[15].targettype = TARGET_ATTACKING; spells[15].instant = false; spells[15].perctrigger = (float)RandomFloat(5.0f); spells[15].attackstoptimer = 1000; m_spellcheck[15] = true; spells[16].info = dbcSpell.LookupEntry(15582); spells[16].reqlvl = 4; spells[16].hpreqtocast = 85; spells[16].targettype = TARGET_ATTACKING; spells[16].instant = false; spells[16].perctrigger = (float)RandomFloat(5.0f); spells[16].attackstoptimer = 1000; m_spellcheck[16] = true; spells[17].info = dbcSpell.LookupEntry(16401); spells[17].reqlvl = 35; spells[17].hpreqtocast = 85; spells[17].targettype = TARGET_ATTACKING; spells[17].instant = false; spells[17].perctrigger = (float)RandomFloat(5.0f); spells[17].attackstoptimer = 1000; m_spellcheck[17] = true; spells[18].info = dbcSpell.LookupEntry(19472); spells[18].reqlvl = 20; spells[18].hpreqtocast = 85; spells[18].targettype = TARGET_ATTACKING; spells[18].instant = false; spells[18].perctrigger = (float)RandomFloat(5.0f); spells[18].attackstoptimer = 1000; m_spellcheck[18] = true; spells[19].info = dbcSpell.LookupEntry(22416); spells[19].reqlvl = 4; spells[19].hpreqtocast = 85; spells[19].targettype = TARGET_ATTACKING; spells[19].instant = false; spells[19].perctrigger = (float)RandomFloat(5.0f); spells[19].attackstoptimer = 1000; m_spellcheck[19] = true; spells[20].info = dbcSpell.LookupEntry(13298); spells[20].reqlvl = 20; spells[20].hpreqtocast = 85; spells[20].targettype = TARGET_ATTACKING; spells[20].instant = false; spells[20].perctrigger = (float)RandomFloat(5.0f); spells[20].attackstoptimer = 1000; m_spellcheck[20] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if (spells[i].hpreqtocast<=_unit->GetHealthPct()) { if ((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class HumanoidWarrior : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(HumanoidWarrior); SP_AI_Spell spells[20]; bool m_spellcheck[20]; HumanoidWarrior(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells =20; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(11998); spells[0].reqlvl = 20; spells[0].hpreqtocast = 85; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(18078); spells[1].reqlvl = 30; spells[1].hpreqtocast = 85; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(13446); spells[2].reqlvl = 1; spells[2].hpreqtocast = 85; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(8242); spells[3].reqlvl = 10; spells[3].hpreqtocast = 85; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(11977); spells[4].reqlvl = 20; spells[4].hpreqtocast = 85; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(13446); spells[5].reqlvl = 1; spells[5].hpreqtocast = 85; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(15655); spells[6].reqlvl = 10; spells[6].hpreqtocast = 85; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(12170); spells[7].reqlvl = 20; spells[7].hpreqtocast = 85; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(13443); spells[8].reqlvl = 20; spells[8].hpreqtocast = 85; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(14516); spells[9].reqlvl = 1; spells[9].hpreqtocast = 85; spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(11972); spells[10].reqlvl = 20; spells[10].hpreqtocast = 85; spells[10].targettype = TARGET_ATTACKING; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(19130); spells[11].reqlvl = 20; spells[11].hpreqtocast = 85; spells[11].targettype = TARGET_ATTACKING; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(13738); spells[12].reqlvl = 20; spells[12].hpreqtocast = 85; spells[12].targettype = TARGET_ATTACKING; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; spells[13].info = dbcSpell.LookupEntry(15623); spells[13].reqlvl = 10; spells[13].hpreqtocast = 85; spells[13].targettype = TARGET_ATTACKING; spells[13].instant = false; spells[13].perctrigger = (float)RandomFloat(5.0f); spells[13].attackstoptimer = 1000; m_spellcheck[13] = true; spells[14].info = dbcSpell.LookupEntry(14087); spells[14].reqlvl = 35; spells[14].hpreqtocast = 85; spells[14].targettype = TARGET_ATTACKING; spells[14].instant = false; spells[14].perctrigger = (float)RandomFloat(5.0f); spells[14].attackstoptimer = 1000; m_spellcheck[14] = true; spells[15].info = dbcSpell.LookupEntry(15613); spells[15].reqlvl = 10; spells[15].hpreqtocast = 85; spells[15].targettype = TARGET_ATTACKING; spells[15].instant = false; spells[15].perctrigger = (float)RandomFloat(5.0f); spells[15].attackstoptimer = 1000; m_spellcheck[15] = true; spells[16].info = dbcSpell.LookupEntry(16406); spells[16].reqlvl = 45; spells[16].hpreqtocast = 85; spells[16].targettype = TARGET_ATTACKING; spells[16].instant = false; spells[16].perctrigger = (float)RandomFloat(5.0f); spells[16].attackstoptimer = 1000; m_spellcheck[16] = true; spells[17].info = dbcSpell.LookupEntry(15584); spells[17].reqlvl = 10; spells[17].hpreqtocast = 85; spells[17].targettype = TARGET_ATTACKING; spells[17].instant = false; spells[17].perctrigger = (float)RandomFloat(5.0f); spells[17].attackstoptimer = 1000; m_spellcheck[17] = true; spells[18].info = dbcSpell.LookupEntry(13737); spells[18].reqlvl = 0; spells[18].hpreqtocast = 85; spells[18].targettype = TARGET_ATTACKING; spells[18].instant = false; spells[18].perctrigger = (float)RandomFloat(5.0f); spells[18].attackstoptimer = 1000; m_spellcheck[18] = true; spells[19].info = dbcSpell.LookupEntry(17504); spells[19].reqlvl = 60; spells[19].hpreqtocast = 85; spells[19].targettype = TARGET_ATTACKING; spells[19].instant = false; spells[19].perctrigger = (float)RandomFloat(5.0f); spells[19].attackstoptimer = 1000; m_spellcheck[19] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if (spells[i].hpreqtocast<=_unit->GetHealthPct()) { if ((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class HumanoidFuryWarrior : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(HumanoidFuryWarrior); SP_AI_Spell spells[18]; bool m_spellcheck[18]; HumanoidFuryWarrior(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 18; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(11998); spells[0].reqlvl = 20; spells[0].hpreqtocast = 85; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(18078); spells[1].reqlvl = 30; spells[1].hpreqtocast = 85; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(13446); spells[2].reqlvl = 1; spells[2].hpreqtocast = 85; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(11977); spells[3].reqlvl = 20; spells[3].hpreqtocast = 85; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(13446); spells[4].reqlvl = 1; spells[4].hpreqtocast = 85; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(23600); spells[5].reqlvl = 0; spells[5].hpreqtocast = 85; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(13443); spells[6].reqlvl = 20; spells[6].hpreqtocast = 85; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(14516); spells[7].reqlvl = 1; spells[7].hpreqtocast = 85; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(5532); spells[8].reqlvl = 10; spells[8].hpreqtocast = 85; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(23600); spells[9].reqlvl = 0; spells[9].hpreqtocast = 85; spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(13738); spells[10].reqlvl = 20; spells[10].hpreqtocast = 85; spells[10].targettype = TARGET_ATTACKING; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(15580); spells[11].reqlvl = 1; spells[11].hpreqtocast = 85; spells[11].targettype = TARGET_ATTACKING; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(15623); spells[12].reqlvl = 10; spells[12].hpreqtocast = 85; spells[12].targettype = TARGET_ATTACKING; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; spells[13].info = dbcSpell.LookupEntry(14087); spells[13].reqlvl = 35; spells[13].hpreqtocast = 85; spells[13].targettype = TARGET_ATTACKING; spells[13].instant = false; spells[13].perctrigger = (float)RandomFloat(5.0f); spells[13].attackstoptimer = 1000; m_spellcheck[13] = true; spells[14].info = dbcSpell.LookupEntry(15613); spells[14].reqlvl = 10; spells[14].hpreqtocast = 85; spells[14].targettype = TARGET_ATTACKING; spells[14].instant = false; spells[14].perctrigger = (float)RandomFloat(5.0f); spells[14].attackstoptimer = 1000; m_spellcheck[14] = true; spells[15].info = dbcSpell.LookupEntry(16406); spells[15].reqlvl = 45; spells[15].hpreqtocast = 85; spells[15].targettype = TARGET_ATTACKING; spells[15].instant = false; spells[15].perctrigger = (float)RandomFloat(5.0f); spells[15].attackstoptimer = 1000; m_spellcheck[15] = true; spells[16].info = dbcSpell.LookupEntry(15584); spells[16].reqlvl = 10; spells[16].hpreqtocast = 85; spells[16].targettype = TARGET_ATTACKING; spells[16].instant = false; spells[16].perctrigger = (float)RandomFloat(5.0f); spells[16].attackstoptimer = 1000; m_spellcheck[16] = true; spells[17].info = dbcSpell.LookupEntry(17504); spells[17].reqlvl = 60; spells[17].hpreqtocast = 85; spells[17].targettype = TARGET_ATTACKING; spells[17].instant = false; spells[17].perctrigger = (float)RandomFloat(5.0f); spells[17].attackstoptimer = 1000; m_spellcheck[17] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if (spells[i].hpreqtocast<=_unit->GetHealthPct()) { if ((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class HumanoidUnarmed : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(HumanoidUnarmed); SP_AI_Spell spells[13]; bool m_spellcheck[13]; HumanoidUnarmed(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 13; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(19639); spells[0].reqlvl = 20; spells[0].hpreqtocast = 85; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(11978); spells[1].reqlvl = 20; spells[1].hpreqtocast = 85; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(19639); spells[2].reqlvl = 20; spells[2].hpreqtocast = 85; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(15610); spells[3].reqlvl = 20; spells[3].hpreqtocast = 85; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(12555); spells[4].reqlvl = 20; spells[4].hpreqtocast = 85; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(10966); spells[5].reqlvl = 40; spells[5].hpreqtocast = 85; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(15614); spells[6].reqlvl = 20; spells[6].hpreqtocast = 85; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(12555); spells[7].reqlvl = 20; spells[7].hpreqtocast = 85; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(10966); spells[8].reqlvl = 40; spells[8].hpreqtocast = 85; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(15614); spells[9].reqlvl = 20; spells[9].hpreqtocast = 85; spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(15615); spells[10].reqlvl = 20; spells[10].hpreqtocast = 85; spells[10].targettype = TARGET_ATTACKING; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(8716); spells[11].reqlvl = 0; spells[11].hpreqtocast = 85; spells[11].targettype = TARGET_ATTACKING; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(15618); spells[12].reqlvl = 1; spells[12].hpreqtocast = 85; spells[12].targettype = TARGET_ATTACKING; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if (spells[i].hpreqtocast<=_unit->GetHealthPct()) { if ((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; class HumanoidShaman : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(HumanoidShaman); SP_AI_Spell spells[43]; bool m_spellcheck[43]; HumanoidShaman(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 43; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(403); spells[0].reqlvl = 1; spells[0].hpreqtocast = 85; spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].perctrigger = (float)RandomFloat(5.0f); spells[0].attackstoptimer = 1000; m_spellcheck[0] = true; spells[1].info = dbcSpell.LookupEntry(8042); spells[1].reqlvl = 4; spells[1].hpreqtocast = 85; spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].perctrigger = (float)RandomFloat(5.0f); spells[1].attackstoptimer = 1000; m_spellcheck[1] = true; spells[2].info = dbcSpell.LookupEntry(529); spells[2].reqlvl = 8; spells[2].hpreqtocast = 85; spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].perctrigger = (float)RandomFloat(5.0f); spells[2].attackstoptimer = 1000; m_spellcheck[2] = true; spells[3].info = dbcSpell.LookupEntry(8044); spells[3].reqlvl = 8; spells[3].hpreqtocast = 85; spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].perctrigger = (float)RandomFloat(5.0f); spells[3].attackstoptimer = 1000; m_spellcheck[3] = true; spells[4].info = dbcSpell.LookupEntry(8050); spells[4].reqlvl = 10; spells[4].hpreqtocast = 85; spells[4].targettype = TARGET_ATTACKING; spells[4].instant = false; spells[4].perctrigger = (float)RandomFloat(5.0f); spells[4].attackstoptimer = 1000; m_spellcheck[4] = true; spells[5].info = dbcSpell.LookupEntry(548); spells[5].reqlvl = 14; spells[5].hpreqtocast = 85; spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].perctrigger = (float)RandomFloat(5.0f); spells[5].attackstoptimer = 1000; m_spellcheck[5] = true; spells[6].info = dbcSpell.LookupEntry(8045); spells[6].reqlvl = 14; spells[6].hpreqtocast = 85; spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].perctrigger = (float)RandomFloat(5.0f); spells[6].attackstoptimer = 1000; m_spellcheck[6] = true; spells[7].info = dbcSpell.LookupEntry(8052); spells[7].reqlvl = 18; spells[7].hpreqtocast = 85; spells[7].targettype = TARGET_ATTACKING; spells[7].instant = false; spells[7].perctrigger = (float)RandomFloat(5.0f); spells[7].attackstoptimer = 1000; m_spellcheck[7] = true; spells[8].info = dbcSpell.LookupEntry(915); spells[8].reqlvl = 20; spells[8].hpreqtocast = 85; spells[8].targettype = TARGET_ATTACKING; spells[8].instant = false; spells[8].perctrigger = (float)RandomFloat(5.0f); spells[8].attackstoptimer = 1000; m_spellcheck[8] = true; spells[9].info = dbcSpell.LookupEntry(943); spells[9].reqlvl = 26; spells[9].hpreqtocast = 85; spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].perctrigger = (float)RandomFloat(5.0f); spells[9].attackstoptimer = 1000; m_spellcheck[9] = true; spells[10].info = dbcSpell.LookupEntry(8046); spells[10].reqlvl = 24; spells[10].hpreqtocast = 85; spells[10].targettype = TARGET_ATTACKING; spells[10].instant = false; spells[10].perctrigger = (float)RandomFloat(5.0f); spells[10].attackstoptimer = 1000; m_spellcheck[10] = true; spells[11].info = dbcSpell.LookupEntry(8053); spells[11].reqlvl = 28; spells[11].hpreqtocast = 85; spells[11].targettype = TARGET_ATTACKING; spells[11].instant = false; spells[11].perctrigger = (float)RandomFloat(5.0f); spells[11].attackstoptimer = 1000; m_spellcheck[11] = true; spells[12].info = dbcSpell.LookupEntry(8056); spells[12].reqlvl = 20; spells[12].hpreqtocast = 85; spells[12].targettype = TARGET_ATTACKING; spells[12].instant = false; spells[12].perctrigger = (float)RandomFloat(5.0f); spells[12].attackstoptimer = 1000; m_spellcheck[12] = true; spells[13].info = dbcSpell.LookupEntry(6041); spells[13].reqlvl = 32; spells[13].hpreqtocast = 85; spells[13].targettype = TARGET_ATTACKING; spells[13].instant = false; spells[13].perctrigger = (float)RandomFloat(5.0f); spells[13].attackstoptimer = 1000; m_spellcheck[13] = true; spells[14].info = dbcSpell.LookupEntry(10391); spells[14].reqlvl = 38; spells[14].hpreqtocast = 85; spells[14].targettype = TARGET_ATTACKING; spells[14].instant = false; spells[14].perctrigger = (float)RandomFloat(5.0f); spells[14].attackstoptimer = 1000; m_spellcheck[14] = true; spells[15].info = dbcSpell.LookupEntry(421); spells[15].reqlvl = 32; spells[15].hpreqtocast = 85; spells[15].targettype = TARGET_ATTACKING; spells[15].instant = false; spells[15].perctrigger = (float)RandomFloat(5.0f); spells[15].attackstoptimer = 1000; m_spellcheck[15] = true; spells[16].info = dbcSpell.LookupEntry(10412); spells[16].reqlvl = 36; spells[16].hpreqtocast = 85; spells[16].targettype = TARGET_ATTACKING; spells[16].instant = false; spells[16].perctrigger = (float)RandomFloat(5.0f); spells[16].attackstoptimer = 1000; m_spellcheck[16] = true; spells[17].info = dbcSpell.LookupEntry(8056); spells[17].reqlvl = 20; spells[17].hpreqtocast = 85; spells[17].targettype = TARGET_ATTACKING; spells[17].instant = false; spells[17].perctrigger = (float)RandomFloat(5.0f); spells[17].attackstoptimer = 1000; m_spellcheck[17] = true; spells[18].info = dbcSpell.LookupEntry(10413); spells[18].reqlvl = 48; spells[18].hpreqtocast = 85; spells[18].targettype = TARGET_ATTACKING; spells[18].instant = false; spells[18].perctrigger = (float)RandomFloat(5.0f); spells[18].attackstoptimer = 1000; m_spellcheck[18] = true; spells[19].info = dbcSpell.LookupEntry(930); spells[19].reqlvl = 40; spells[19].hpreqtocast = 85; spells[19].targettype = TARGET_ATTACKING; spells[19].instant = false; spells[19].perctrigger = (float)RandomFloat(5.0f); spells[19].attackstoptimer = 1000; m_spellcheck[19] = true; spells[20].info = dbcSpell.LookupEntry(2860); spells[20].reqlvl = 48; spells[20].hpreqtocast = 85; spells[20].targettype = TARGET_ATTACKING; spells[20].instant = false; spells[20].perctrigger = (float)RandomFloat(5.0f); spells[20].attackstoptimer = 1000; m_spellcheck[20] = true; spells[21].info = dbcSpell.LookupEntry(10447); spells[21].reqlvl = 40; spells[21].hpreqtocast = 85; spells[21].targettype = TARGET_ATTACKING; spells[21].instant = false; spells[21].perctrigger = (float)RandomFloat(5.0f); spells[21].attackstoptimer = 1000; m_spellcheck[21] = true; spells[22].info = dbcSpell.LookupEntry(10392); spells[22].reqlvl = 44; spells[22].hpreqtocast = 85; spells[22].targettype = TARGET_ATTACKING; spells[22].instant = false; spells[22].perctrigger = (float)RandomFloat(5.0f); spells[22].attackstoptimer = 1000; m_spellcheck[22] = true; spells[23].info = dbcSpell.LookupEntry(10472); spells[23].reqlvl = 46; spells[23].hpreqtocast = 85; spells[23].targettype = TARGET_ATTACKING; spells[23].instant = false; spells[23].perctrigger = (float)RandomFloat(5.0f); spells[23].attackstoptimer = 1000; m_spellcheck[23] = true; spells[24].info = dbcSpell.LookupEntry(10414); spells[24].reqlvl = 60; spells[24].hpreqtocast = 85; spells[24].targettype = TARGET_ATTACKING; spells[24].instant = false; spells[24].perctrigger = (float)RandomFloat(5.0f); spells[24].attackstoptimer = 1000; m_spellcheck[24] = true; spells[25].info = dbcSpell.LookupEntry(10473); spells[25].reqlvl = 58; spells[25].hpreqtocast = 85; spells[25].targettype = TARGET_ATTACKING; spells[25].instant = false; spells[25].perctrigger = (float)RandomFloat(5.0f); spells[25].attackstoptimer = 1000; m_spellcheck[25] = true; spells[26].info = dbcSpell.LookupEntry(15207); spells[26].reqlvl = 50; spells[26].hpreqtocast = 85; spells[26].targettype = TARGET_ATTACKING; spells[26].instant = false; spells[26].perctrigger = (float)RandomFloat(5.0f); spells[26].attackstoptimer = 1000; m_spellcheck[26] = true; spells[27].info = dbcSpell.LookupEntry(10448); spells[27].reqlvl = 52; spells[27].hpreqtocast = 85; spells[27].targettype = TARGET_ATTACKING; spells[27].instant = false; spells[27].perctrigger = (float)RandomFloat(5.0f); spells[27].attackstoptimer = 1000; m_spellcheck[27] = true; spells[28].info = dbcSpell.LookupEntry(10605); spells[28].reqlvl = 56; spells[28].hpreqtocast = 85; spells[28].targettype = TARGET_ATTACKING; spells[28].instant = false; spells[28].perctrigger = (float)RandomFloat(5.0f); spells[28].attackstoptimer = 1000; m_spellcheck[28] = true; spells[29].info = dbcSpell.LookupEntry(15208); spells[29].reqlvl = 56; spells[29].hpreqtocast = 85; spells[29].targettype = TARGET_ATTACKING; spells[29].instant = false; spells[29].perctrigger = (float)RandomFloat(5.0f); spells[29].attackstoptimer = 1000; m_spellcheck[29] = true; spells[30].info = dbcSpell.LookupEntry(324); spells[30].reqlvl = 8; spells[30].hpreqtocast = 85; spells[30].targettype = TARGET_SELF; spells[30].instant = false; spells[30].perctrigger = (float)RandomFloat(5.0f); spells[30].attackstoptimer = 1000; m_spellcheck[30] = true; spells[31].info = dbcSpell.LookupEntry(325); spells[31].reqlvl = 16; spells[31].hpreqtocast = 85; spells[31].targettype = TARGET_SELF; spells[31].instant = false; spells[31].perctrigger = (float)RandomFloat(5.0f); spells[31].attackstoptimer = 1000; m_spellcheck[31] = true; spells[32].info = dbcSpell.LookupEntry(905); spells[32].reqlvl = 24; spells[32].hpreqtocast = 85; spells[32].targettype = TARGET_SELF; spells[32].instant = false; spells[32].perctrigger = (float)RandomFloat(5.0f); spells[32].attackstoptimer = 1000; m_spellcheck[32] = true; spells[33].info = dbcSpell.LookupEntry(8134); spells[33].reqlvl = 40; spells[33].hpreqtocast = 85; spells[33].targettype = TARGET_SELF; spells[33].instant = false; spells[33].perctrigger = (float)RandomFloat(5.0f); spells[33].attackstoptimer = 1000; m_spellcheck[33] = true; spells[34].info = dbcSpell.LookupEntry(10431); spells[34].reqlvl = 48; spells[34].hpreqtocast = 85; spells[34].targettype = TARGET_SELF; spells[34].instant = false; spells[34].perctrigger = (float)RandomFloat(5.0f); spells[34].attackstoptimer = 1000; m_spellcheck[34] = true; spells[35].info = dbcSpell.LookupEntry(10432); spells[35].reqlvl = 56; spells[35].hpreqtocast = 85; spells[35].targettype = TARGET_SELF; spells[35].instant = false; spells[35].perctrigger = (float)RandomFloat(5.0f); spells[35].attackstoptimer = 1000; m_spellcheck[35] = true; spells[36].info = dbcSpell.LookupEntry(331); spells[36].reqlvl = 1; spells[36].hpreqtocast = 50; spells[36].targettype = TARGET_SELF; spells[36].instant = false; spells[36].perctrigger = (float)RandomFloat(5.0f); spells[36].attackstoptimer = 1000; m_spellcheck[36] = true; spells[37].info = dbcSpell.LookupEntry(332); spells[37].reqlvl = 6; spells[37].hpreqtocast = 50; spells[37].targettype = TARGET_SELF; spells[37].instant = false; spells[37].perctrigger = (float)RandomFloat(5.0f); spells[37].attackstoptimer = 1000; m_spellcheck[37] = true; spells[38].info = dbcSpell.LookupEntry(8004); spells[38].reqlvl = 20; spells[38].hpreqtocast = 50; spells[38].targettype = TARGET_SELF; spells[38].instant = false; spells[38].perctrigger = (float)RandomFloat(5.0f); spells[38].attackstoptimer = 1000; m_spellcheck[38] = true; spells[39].info = dbcSpell.LookupEntry(8008); spells[39].reqlvl = 28; spells[39].hpreqtocast = 50; spells[39].targettype = TARGET_SELF; spells[39].instant = false; spells[39].perctrigger = (float)RandomFloat(5.0f); spells[39].attackstoptimer = 1000; m_spellcheck[39] = true; spells[40].info = dbcSpell.LookupEntry(8010); spells[40].reqlvl = 36; spells[40].hpreqtocast = 50; spells[40].targettype = TARGET_SELF; spells[40].instant = false; spells[40].perctrigger = (float)RandomFloat(5.0f); spells[40].attackstoptimer = 1000; m_spellcheck[40] = true; spells[41].info = dbcSpell.LookupEntry(10466); spells[41].reqlvl = 44; spells[41].hpreqtocast = 50; spells[41].targettype = TARGET_SELF; spells[41].instant = false; spells[41].perctrigger = (float)RandomFloat(5.0f); spells[41].attackstoptimer = 1000; m_spellcheck[41] = true; spells[42].info = dbcSpell.LookupEntry(10468); spells[42].reqlvl = 60; spells[42].hpreqtocast = 50; spells[42].targettype = TARGET_SELF; spells[42].instant = false; spells[42].perctrigger = (float)RandomFloat(5.0f); spells[42].attackstoptimer = 1000; m_spellcheck[42] = true; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if (spells[i].hpreqtocast<=_unit->GetHealthPct()) { if ((spells[i].reqlvl<=_unit->GetUInt32Value(UNIT_FIELD_LEVEL)) && (spells[i].reqlvl+10>=_unit->GetUInt32Value(UNIT_FIELD_LEVEL))) { if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } } } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; void SetupGenericAI(ScriptMgr * mgr) { // Family based AI's /* mgr->register_creature_script(16350, &SpiderFamily::Create); mgr->register_creature_script(18466, &SpiderFamily::Create); mgr->register_creature_script(11370, &SpiderFamily::Create); mgr->register_creature_script(15041, &SpiderFamily::Create); mgr->register_creature_script(4005, &SpiderFamily::Create); mgr->register_creature_script(16351, &SpiderFamily::Create); mgr->register_creature_script(16352, &SpiderFamily::Create); mgr->register_creature_script(7319, &SpiderFamily::Create); mgr->register_creature_script(2563, &SpiderFamily::Create); mgr->register_creature_script(14880, &SpiderFamily::Create); mgr->register_creature_script(20714, &SpiderFamily::Create); mgr->register_creature_script(20027, &SpiderFamily::Create); mgr->register_creature_script(3821, &SpiderFamily::Create); mgr->register_creature_script(8762, &SpiderFamily::Create); mgr->register_creature_script(2565, &SpiderFamily::Create); mgr->register_creature_script(505, &SpiderFamily::Create); mgr->register_creature_script(1688, &SpiderFamily::Create); mgr->register_creature_script(4376, &SpiderFamily::Create); mgr->register_creature_script(4377, &SpiderFamily::Create); mgr->register_creature_script(4379, &SpiderFamily::Create); mgr->register_creature_script(4380, &SpiderFamily::Create); mgr->register_creature_script(1504, &SpiderFamily::Create); mgr->register_creature_script(1195, &SpiderFamily::Create); mgr->register_creature_script(471, &SpiderFamily::Create); mgr->register_creature_script(616, &SpiderFamily::Create); mgr->register_creature_script(769, &SpiderFamily::Create); mgr->register_creature_script(1112, &SpiderFamily::Create); mgr->register_creature_script(1780, &SpiderFamily::Create); mgr->register_creature_script(1781, &SpiderFamily::Create); mgr->register_creature_script(1823, &SpiderFamily::Create); mgr->register_creature_script(1825, &SpiderFamily::Create); mgr->register_creature_script(1986, &SpiderFamily::Create); mgr->register_creature_script(1994, &SpiderFamily::Create); mgr->register_creature_script(2686, &SpiderFamily::Create); mgr->register_creature_script(5856, &SpiderFamily::Create); mgr->register_creature_script(1505, &SpiderFamily::Create); mgr->register_creature_script(14532, &SpiderFamily::Create); mgr->register_creature_script(18983, &SpiderFamily::Create); mgr->register_creature_script(4415, &SpiderFamily::Create); mgr->register_creature_script(5446, &SpiderFamily::Create); mgr->register_creature_script(4007, &SpiderFamily::Create); mgr->register_creature_script(8277, &SpiderFamily::Create); mgr->register_creature_script(8933, &SpiderFamily::Create); mgr->register_creature_script(10359, &SpiderFamily::Create); mgr->register_creature_script(10375, &SpiderFamily::Create); mgr->register_creature_script(12433, &SpiderFamily::Create); mgr->register_creature_script(14266, &SpiderFamily::Create); mgr->register_creature_script(14472, &SpiderFamily::Create); mgr->register_creature_script(1185, &SpiderFamily::Create); mgr->register_creature_script(539, &SpiderFamily::Create); mgr->register_creature_script(442, &SpiderFamily::Create); mgr->register_creature_script(18467, &SpiderFamily::Create); mgr->register_creature_script(16171, &SpiderFamily::Create); mgr->register_creature_script(16170, &SpiderFamily::Create); mgr->register_creature_script(4411, &SpiderFamily::Create); mgr->register_creature_script(4412, &SpiderFamily::Create); mgr->register_creature_script(22044, &SpiderFamily::Create); mgr->register_creature_script(2350, &SpiderFamily::Create); mgr->register_creature_script(2349, &SpiderFamily::Create); mgr->register_creature_script(3820, &SpiderFamily::Create); mgr->register_creature_script(17522, &SpiderFamily::Create); mgr->register_creature_script(17523, &SpiderFamily::Create); mgr->register_creature_script(18647, &SpiderFamily::Create); mgr->register_creature_script(4414, &SpiderFamily::Create); mgr->register_creature_script(1821, &SpiderFamily::Create); mgr->register_creature_script(1824, &SpiderFamily::Create); mgr->register_creature_script(4413, &SpiderFamily::Create); mgr->register_creature_script(22132, &SpiderFamily::Create); mgr->register_creature_script(2000, &SpiderFamily::Create); mgr->register_creature_script(20998, &SpiderFamily::Create); mgr->register_creature_script(3819, &SpiderFamily::Create); mgr->register_creature_script(1822, &SpiderFamily::Create); mgr->register_creature_script(5857, &SpiderFamily::Create); mgr->register_creature_script(1999, &SpiderFamily::Create); mgr->register_creature_script(1998, &SpiderFamily::Create); mgr->register_creature_script(930, &SpiderFamily::Create); mgr->register_creature_script(11738, &SpiderFamily::Create); mgr->register_creature_script(11739, &SpiderFamily::Create); mgr->register_creature_script(858, &SpiderFamily::Create); mgr->register_creature_script(17683, &SpiderFamily::Create); mgr->register_creature_script(14279, &SpiderFamily::Create); mgr->register_creature_script(2348, &SpiderFamily::Create); mgr->register_creature_script(574, &SpiderFamily::Create); mgr->register_creature_script(4006, &SpiderFamily::Create); mgr->register_creature_script(4263, &SpiderFamily::Create); mgr->register_creature_script(11921, &SpiderFamily::Create); mgr->register_creature_script(4264, &SpiderFamily::Create); mgr->register_creature_script(30, &SpiderFamily::Create); mgr->register_creature_script(1555, &SpiderFamily::Create); mgr->register_creature_script(4378, &SpiderFamily::Create); mgr->register_creature_script(43, &SpiderFamily::Create); mgr->register_creature_script(1111, &SpiderFamily::Create); mgr->register_creature_script(1184, &SpiderFamily::Create); mgr->register_creature_script(5858, &SpiderFamily::Create); mgr->register_creature_script(217, &SpiderFamily::Create); mgr->register_creature_script(949, &SpiderFamily::Create); mgr->register_creature_script(569, &SpiderFamily::Create); mgr->register_creature_script(2001, &SpiderFamily::Create); mgr->register_creature_script(4040, &SpiderFamily::Create); mgr->register_creature_script(17112, &SpiderFamily::Create); mgr->register_creature_script(16179, &SpiderFamily::Create); mgr->register_creature_script(4692, &BirdFamily::Create); mgr->register_creature_script(16973, &BirdFamily::Create); mgr->register_creature_script(18470, &BirdFamily::Create); mgr->register_creature_script(199, &BirdFamily::Create); mgr->register_creature_script(5982, &BirdFamily::Create); mgr->register_creature_script(2580, &BirdFamily::Create); mgr->register_creature_script(2579, &BirdFamily::Create); mgr->register_creature_script(462, &BirdFamily::Create); mgr->register_creature_script(4695, &BirdFamily::Create); mgr->register_creature_script(2578, &BirdFamily::Create); mgr->register_creature_script(428, &BirdFamily::Create); mgr->register_creature_script(2801, &BirdFamily::Create); mgr->register_creature_script(2870, &BirdFamily::Create); mgr->register_creature_script(2880, &BirdFamily::Create); mgr->register_creature_script(5430, &BirdFamily::Create); mgr->register_creature_script(154, &BirdFamily::Create); mgr->register_creature_script(6013, &BirdFamily::Create); mgr->register_creature_script(8207, &BirdFamily::Create); mgr->register_creature_script(2931, &BirdFamily::Create); mgr->register_creature_script(14268, &BirdFamily::Create); mgr->register_creature_script(4154, &BirdFamily::Create); mgr->register_creature_script(1809, &BirdFamily::Create); mgr->register_creature_script(21515, &BirdFamily::Create); mgr->register_creature_script(2971, &BirdFamily::Create); mgr->register_creature_script(16972, &BirdFamily::Create); mgr->register_creature_script(2830, &BirdFamily::Create); mgr->register_creature_script(2831, &BirdFamily::Create); mgr->register_creature_script(21042, &BirdFamily::Create); mgr->register_creature_script(2970, &BirdFamily::Create); mgr->register_creature_script(2969, &BirdFamily::Create); mgr->register_creature_script(4693, &BirdFamily::Create); mgr->register_creature_script(4694, &BirdFamily::Create); mgr->register_creature_script(4158, &BirdFamily::Create); mgr->register_creature_script(1109, &BirdFamily::Create); mgr->register_creature_script(5428, &BirdFamily::Create); mgr->register_creature_script(5429, &BirdFamily::Create); mgr->register_creature_script(2829, &BirdFamily::Create); mgr->register_creature_script(8299, &BirdFamily::Create); mgr->register_creature_script(1194, &BirdFamily::Create); mgr->register_creature_script(1722, &BirdFamily::Create); mgr->register_creature_script(1723, &BirdFamily::Create); mgr->register_creature_script(1724, &BirdFamily::Create); mgr->register_creature_script(8001, &BirdFamily::Create); mgr->register_creature_script(8996, &VoidwalkerFamily::Create); mgr->register_creature_script(14389, &VoidwalkerFamily::Create); mgr->register_creature_script(1860, &VoidwalkerFamily::Create); mgr->register_creature_script(8656, &VoidwalkerFamily::Create); mgr->register_creature_script(9695, &ScorpionFamily::Create); mgr->register_creature_script(22257, &ScorpionFamily::Create); mgr->register_creature_script(7078, &ScorpionFamily::Create); mgr->register_creature_script(9691, &ScorpionFamily::Create); mgr->register_creature_script(3126, &ScorpionFamily::Create); mgr->register_creature_script(7022, &ScorpionFamily::Create); mgr->register_creature_script(5422, &ScorpionFamily::Create); mgr->register_creature_script(5937, &ScorpionFamily::Create); mgr->register_creature_script(7803, &ScorpionFamily::Create); mgr->register_creature_script(8301, &ScorpionFamily::Create); mgr->register_creature_script(8926, &ScorpionFamily::Create); mgr->register_creature_script(7405, &ScorpionFamily::Create); mgr->register_creature_script(5988, &ScorpionFamily::Create); mgr->register_creature_script(3127, &ScorpionFamily::Create); mgr->register_creature_script(5423, &ScorpionFamily::Create); mgr->register_creature_script(21864, &ScorpionFamily::Create); mgr->register_creature_script(4140, &ScorpionFamily::Create); mgr->register_creature_script(4139, &ScorpionFamily::Create); mgr->register_creature_script(4697, &ScorpionFamily::Create); mgr->register_creature_script(14476, &ScorpionFamily::Create); mgr->register_creature_script(3250, &ScorpionFamily::Create); mgr->register_creature_script(3252, &ScorpionFamily::Create); mgr->register_creature_script(22100, &ScorpionFamily::Create); mgr->register_creature_script(4696, &ScorpionFamily::Create); mgr->register_creature_script(4699, &ScorpionFamily::Create); mgr->register_creature_script(3226, &ScorpionFamily::Create); mgr->register_creature_script(5823, &ScorpionFamily::Create); mgr->register_creature_script(11735, &ScorpionFamily::Create); mgr->register_creature_script(11736, &ScorpionFamily::Create); mgr->register_creature_script(11737, &ScorpionFamily::Create); mgr->register_creature_script(3125, &ScorpionFamily::Create); mgr->register_creature_script(3124, &ScorpionFamily::Create); mgr->register_creature_script(3281, &ScorpionFamily::Create); mgr->register_creature_script(5424, &ScorpionFamily::Create); mgr->register_creature_script(9698, &ScorpionFamily::Create); mgr->register_creature_script(2959, &WolfFamily::Create); mgr->register_creature_script(20748, &WolfFamily::Create); mgr->register_creature_script(2730, &WolfFamily::Create); mgr->register_creature_script(17669, &WolfFamily::Create); mgr->register_creature_script(2925, &WolfFamily::Create); mgr->register_creature_script(2680, &WolfFamily::Create); mgr->register_creature_script(521, &WolfFamily::Create); mgr->register_creature_script(1131, &WolfFamily::Create); mgr->register_creature_script(17280, &WolfFamily::Create); mgr->register_creature_script(2727, &WolfFamily::Create); mgr->register_creature_script(10981, &WolfFamily::Create); mgr->register_creature_script(10221, &WolfFamily::Create); mgr->register_creature_script(923, &WolfFamily::Create); mgr->register_creature_script(9416, &WolfFamily::Create); mgr->register_creature_script(2924, &WolfFamily::Create); mgr->register_creature_script(704, &WolfFamily::Create); mgr->register_creature_script(5286, &WolfFamily::Create); mgr->register_creature_script(19616, &WolfFamily::Create); mgr->register_creature_script(2958, &WolfFamily::Create); mgr->register_creature_script(1508, &WolfFamily::Create); mgr->register_creature_script(2681, &WolfFamily::Create); mgr->register_creature_script(1133, &WolfFamily::Create); mgr->register_creature_script(21952, &WolfFamily::Create); mgr->register_creature_script(1509, &WolfFamily::Create); mgr->register_creature_script(2926, &WolfFamily::Create); mgr->register_creature_script(10644, &WolfFamily::Create); mgr->register_creature_script(5433, &WolfFamily::Create); mgr->register_creature_script(5437, &WolfFamily::Create); mgr->register_creature_script(5438, &WolfFamily::Create); mgr->register_creature_script(5444, &WolfFamily::Create); mgr->register_creature_script(5449, &WolfFamily::Create); mgr->register_creature_script(834, &WolfFamily::Create); mgr->register_creature_script(3825, &WolfFamily::Create); mgr->register_creature_script(11871, &WolfFamily::Create); mgr->register_creature_script(628, &WolfFamily::Create); mgr->register_creature_script(17548, &WolfFamily::Create); mgr->register_creature_script(20058, &WolfFamily::Create); mgr->register_creature_script(11614, &WolfFamily::Create); mgr->register_creature_script(12345, &WolfFamily::Create); mgr->register_creature_script(12348, &WolfFamily::Create); mgr->register_creature_script(12356, &WolfFamily::Create); mgr->register_creature_script(12357, &WolfFamily::Create); mgr->register_creature_script(5356, &WolfFamily::Create); mgr->register_creature_script(3824, &WolfFamily::Create); mgr->register_creature_script(20330, &WolfFamily::Create); mgr->register_creature_script(9696, &WolfFamily::Create); mgr->register_creature_script(2960, &WolfFamily::Create); mgr->register_creature_script(3823, &WolfFamily::Create); mgr->register_creature_script(1132, &WolfFamily::Create); mgr->register_creature_script(18476, &WolfFamily::Create); mgr->register_creature_script(9694, &WolfFamily::Create); mgr->register_creature_script(5288, &WolfFamily::Create); mgr->register_creature_script(9697, &WolfFamily::Create); mgr->register_creature_script(8959, &WolfFamily::Create); mgr->register_creature_script(11024, &WolfFamily::Create); mgr->register_creature_script(2728, &WolfFamily::Create); mgr->register_creature_script(18670, &WolfFamily::Create); mgr->register_creature_script(1765, &WolfFamily::Create); mgr->register_creature_script(1766, &WolfFamily::Create); mgr->register_creature_script(21340, &WolfFamily::Create); mgr->register_creature_script(18477, &WolfFamily::Create); mgr->register_creature_script(8960, &WolfFamily::Create); mgr->register_creature_script(18033, &WolfFamily::Create); mgr->register_creature_script(8961, &WolfFamily::Create); mgr->register_creature_script(21956, &WolfFamily::Create); mgr->register_creature_script(1817, &WolfFamily::Create); mgr->register_creature_script(2729, &WolfFamily::Create); mgr->register_creature_script(1258, &WolfFamily::Create); mgr->register_creature_script(3862, &WolfFamily::Create); mgr->register_creature_script(118, &WolfFamily::Create); mgr->register_creature_script(5287, &WolfFamily::Create); mgr->register_creature_script(3939, &WolfFamily::Create); mgr->register_creature_script(833, &WolfFamily::Create); mgr->register_creature_script(12431, &WolfFamily::Create); mgr->register_creature_script(19423, &WolfFamily::Create); mgr->register_creature_script(19640, &WolfFamily::Create); mgr->register_creature_script(19458, &WolfFamily::Create); mgr->register_creature_script(19459, &WolfFamily::Create); mgr->register_creature_script(1923, &WolfFamily::Create); mgr->register_creature_script(3861, &WolfFamily::Create); mgr->register_creature_script(5058, &WolfFamily::Create); mgr->register_creature_script(2753, &WolfFamily::Create); mgr->register_creature_script(2275, &WolfFamily::Create); mgr->register_creature_script(565, &WolfFamily::Create); mgr->register_creature_script(525, &WolfFamily::Create); mgr->register_creature_script(299, &WolfFamily::Create); mgr->register_creature_script(213, &WolfFamily::Create); mgr->register_creature_script(1138, &WolfFamily::Create); mgr->register_creature_script(14282, &WolfFamily::Create); mgr->register_creature_script(69, &WolfFamily::Create); mgr->register_creature_script(8211, &WolfFamily::Create); mgr->register_creature_script(14339, &WolfFamily::Create); mgr->register_creature_script(4950, &WolfFamily::Create); mgr->register_creature_script(2923, &WolfFamily::Create); mgr->register_creature_script(9690, &WolfFamily::Create); mgr->register_creature_script(7055, &WolfFamily::Create); mgr->register_creature_script(1922, &WolfFamily::Create); mgr->register_creature_script(10077, &WolfFamily::Create); mgr->register_creature_script(705, &WolfFamily::Create); mgr->register_creature_script(1108, &GorillaFamily::Create); mgr->register_creature_script(6516, &GorillaFamily::Create); mgr->register_creature_script(1511, &GorillaFamily::Create); mgr->register_creature_script(1516, &GorillaFamily::Create); mgr->register_creature_script(6513, &GorillaFamily::Create); mgr->register_creature_script(6514, &GorillaFamily::Create); mgr->register_creature_script(12364, &GorillaFamily::Create); mgr->register_creature_script(12368, &GorillaFamily::Create); mgr->register_creature_script(14491, &GorillaFamily::Create); mgr->register_creature_script(5262, &GorillaFamily::Create); mgr->register_creature_script(2521, &GorillaFamily::Create); mgr->register_creature_script(1114, &GorillaFamily::Create); mgr->register_creature_script(5260, &GorillaFamily::Create); mgr->register_creature_script(1557, &GorillaFamily::Create); mgr->register_creature_script(6585, &GorillaFamily::Create); mgr->register_creature_script(9622, &GorillaFamily::Create); mgr->register_creature_script(1558, &GorillaFamily::Create); mgr->register_creature_script(3228, &CrabFamily::Create); mgr->register_creature_script(830, &CrabFamily::Create); mgr->register_creature_script(3107, &CrabFamily::Create); mgr->register_creature_script(922, &CrabFamily::Create); mgr->register_creature_script(1088, &CrabFamily::Create); mgr->register_creature_script(3812, &CrabFamily::Create); mgr->register_creature_script(1216, &CrabFamily::Create); mgr->register_creature_script(3814, &CrabFamily::Create); mgr->register_creature_script(3108, &CrabFamily::Create); mgr->register_creature_script(17216, &CrabFamily::Create); mgr->register_creature_script(2544, &CrabFamily::Create); mgr->register_creature_script(17217, &CrabFamily::Create); mgr->register_creature_script(2234, &CrabFamily::Create); mgr->register_creature_script(2231, &CrabFamily::Create); mgr->register_creature_script(3106, &CrabFamily::Create); mgr->register_creature_script(2236, &CrabFamily::Create); mgr->register_creature_script(4821, &CrabFamily::Create); mgr->register_creature_script(4822, &CrabFamily::Create); mgr->register_creature_script(4823, &CrabFamily::Create); mgr->register_creature_script(3503, &CrabFamily::Create); mgr->register_creature_script(2233, &CrabFamily::Create); mgr->register_creature_script(2235, &CrabFamily::Create); mgr->register_creature_script(2232, &CrabFamily::Create); mgr->register_creature_script(12347, &CrabFamily::Create); mgr->register_creature_script(18241, &CrabFamily::Create); mgr->register_creature_script(6250, &CrabFamily::Create); mgr->register_creature_script(831, &CrabFamily::Create); mgr->register_creature_script(5272, &BearFamily::Create); mgr->register_creature_script(1186, &BearFamily::Create); mgr->register_creature_script(14344, &BearFamily::Create); mgr->register_creature_script(1129, &BearFamily::Create); mgr->register_creature_script(3811, &BearFamily::Create); mgr->register_creature_script(2351, &BearFamily::Create); mgr->register_creature_script(3810, &BearFamily::Create); mgr->register_creature_script(12037, &BearFamily::Create); mgr->register_creature_script(5352, &BearFamily::Create); mgr->register_creature_script(7443, &BearFamily::Create); mgr->register_creature_script(1196, &BearFamily::Create); mgr->register_creature_script(2163, &BearFamily::Create); mgr->register_creature_script(1188, &BearFamily::Create); mgr->register_creature_script(5274, &BearFamily::Create); mgr->register_creature_script(14280, &BearFamily::Create); mgr->register_creature_script(8956, &BearFamily::Create); mgr->register_creature_script(8958, &BearFamily::Create); mgr->register_creature_script(1797, &BearFamily::Create); mgr->register_creature_script(1778, &BearFamily::Create); mgr->register_creature_script(7444, &BearFamily::Create); mgr->register_creature_script(17348, &BearFamily::Create); mgr->register_creature_script(17661, &BearFamily::Create); mgr->register_creature_script(8957, &BearFamily::Create); mgr->register_creature_script(1816, &BearFamily::Create); mgr->register_creature_script(2165, &BearFamily::Create); mgr->register_creature_script(10806, &BearFamily::Create); mgr->register_creature_script(2354, &BearFamily::Create); mgr->register_creature_script(2356, &BearFamily::Create); mgr->register_creature_script(22136, &BearFamily::Create); mgr->register_creature_script(3809, &BearFamily::Create); mgr->register_creature_script(1815, &BearFamily::Create); mgr->register_creature_script(1961, &BearFamily::Create); mgr->register_creature_script(5268, &BearFamily::Create); mgr->register_creature_script(7446, &BearFamily::Create); mgr->register_creature_script(7445, &BearFamily::Create); mgr->register_creature_script(6789, &BearFamily::Create); mgr->register_creature_script(12432, &BearFamily::Create); mgr->register_creature_script(822, &BearFamily::Create); mgr->register_creature_script(1130, &BearFamily::Create); mgr->register_creature_script(1128, &BearFamily::Create); mgr->register_creature_script(1225, &BearFamily::Create); mgr->register_creature_script(17345, &BearFamily::Create); mgr->register_creature_script(17347, &BearFamily::Create); mgr->register_creature_script(6788, &BearFamily::Create); mgr->register_creature_script(1189, &BearFamily::Create); mgr->register_creature_script(4514, &BoarFamily::Create); mgr->register_creature_script(454, &BoarFamily::Create); mgr->register_creature_script(5992, &BoarFamily::Create); mgr->register_creature_script(3100, &BoarFamily::Create); mgr->register_creature_script(1689, &BoarFamily::Create); mgr->register_creature_script(390, &BoarFamily::Create); mgr->register_creature_script(1190, &BoarFamily::Create); mgr->register_creature_script(1984, &BoarFamily::Create); mgr->register_creature_script(3225, &BoarFamily::Create); mgr->register_creature_script(547, &BoarFamily::Create); mgr->register_creature_script(157, &BoarFamily::Create); mgr->register_creature_script(1192, &BoarFamily::Create); mgr->register_creature_script(708, &BoarFamily::Create); mgr->register_creature_script(1127, &BoarFamily::Create); mgr->register_creature_script(1126, &BoarFamily::Create); mgr->register_creature_script(4535, &BoarFamily::Create); mgr->register_creature_script(16117, &BoarFamily::Create); mgr->register_creature_script(4511, &BoarFamily::Create); mgr->register_creature_script(4512, &BoarFamily::Create); mgr->register_creature_script(3099, &BoarFamily::Create); mgr->register_creature_script(524, &BoarFamily::Create); mgr->register_creature_script(3098, &BoarFamily::Create); mgr->register_creature_script(1191, &BoarFamily::Create); mgr->register_creature_script(345, &BoarFamily::Create); mgr->register_creature_script(113, &BoarFamily::Create); mgr->register_creature_script(2966, &BoarFamily::Create); mgr->register_creature_script(2954, &BoarFamily::Create); mgr->register_creature_script(119, &BoarFamily::Create); mgr->register_creature_script(1125, &BoarFamily::Create); mgr->register_creature_script(330, &BoarFamily::Create); mgr->register_creature_script(1985, &BoarFamily::Create); mgr->register_creature_script(8303, &BoarFamily::Create); //End of family based AI's //Type based AI's mgr->register_creature_script(20142, &DragonType::Create); mgr->register_creature_script(15192, &DragonType::Create); mgr->register_creature_script(19951, &DragonType::Create); mgr->register_creature_script(17918, &DragonType::Create); mgr->register_creature_script(18994, &DragonType::Create); mgr->register_creature_script(21104, &DragonType::Create); mgr->register_creature_script(17880, &DragonType::Create); mgr->register_creature_script(7048, &DragonType::Create); mgr->register_creature_script(12478, &DragonType::Create); mgr->register_creature_script(12479, &DragonType::Create); mgr->register_creature_script(12477, &DragonType::Create); mgr->register_creature_script(14890, &DragonType::Create); mgr->register_creature_script(5718, &DragonType::Create); mgr->register_creature_script(12496, &DragonType::Create); mgr->register_creature_script(15302, &DragonType::Create); mgr->register_creature_script(12468, &DragonType::Create); mgr->register_creature_script(12435, &DragonType::Create); mgr->register_creature_script(12465, &DragonType::Create); mgr->register_creature_script(12463, &DragonType::Create); mgr->register_creature_script(14024, &DragonType::Create); mgr->register_creature_script(14025, &DragonType::Create); mgr->register_creature_script(14023, &DragonType::Create); mgr->register_creature_script(14022, &DragonType::Create); mgr->register_creature_script(12017, &DragonType::Create); mgr->register_creature_script(12464, &DragonType::Create); mgr->register_creature_script(12467, &DragonType::Create); mgr->register_creature_script(13020, &DragonType::Create); mgr->register_creature_script(12422, &DragonType::Create); mgr->register_creature_script(21148, &DragonType::Create); mgr->register_creature_script(17879, &DragonType::Create); mgr->register_creature_script(14398, &DragonType::Create); mgr->register_creature_script(1042, &DragonType::Create); mgr->register_creature_script(9461, &DragonType::Create); mgr->register_creature_script(21138, &DragonType::Create); mgr->register_creature_script(10184, &DragonType::Create); mgr->register_creature_script(12129, &DragonType::Create); mgr->register_creature_script(11262, &DragonType::Create); mgr->register_creature_script(18418, &DragonType::Create); mgr->register_creature_script(745, &DragonType::Create); mgr->register_creature_script(743, &DragonType::Create); mgr->register_creature_script(742, &DragonType::Create); mgr->register_creature_script(744, &DragonType::Create); mgr->register_creature_script(12457, &DragonType::Create); mgr->register_creature_script(14601, &DragonType::Create); mgr->register_creature_script(11981, &DragonType::Create); mgr->register_creature_script(13976, &DragonType::Create); mgr->register_creature_script(10372, &DragonType::Create); mgr->register_creature_script(10366, &DragonType::Create); mgr->register_creature_script(20201, &DragonType::Create); mgr->register_creature_script(19933, &DragonType::Create); mgr->register_creature_script(6109, &DragonType::Create); mgr->register_creature_script(15481, &DragonType::Create); mgr->register_creature_script(6129, &DragonType::Create); mgr->register_creature_script(6130, &DragonType::Create); mgr->register_creature_script(193, &DragonType::Create); mgr->register_creature_script(6131, &DragonType::Create); mgr->register_creature_script(22332, &DragonType::Create); mgr->register_creature_script(17307, &DragonType::Create); mgr->register_creature_script(17536, &DragonType::Create); mgr->register_creature_script(5314, &DragonType::Create); mgr->register_creature_script(21818, &DragonType::Create); mgr->register_creature_script(17892, &DragonType::Create); mgr->register_creature_script(21140, &DragonType::Create); mgr->register_creature_script(21137, &DragonType::Create); mgr->register_creature_script(21136, &DragonType::Create); mgr->register_creature_script(14889, &DragonType::Create); mgr->register_creature_script(18692, &DragonType::Create); mgr->register_creature_script(10162, &DragonType::Create); mgr->register_creature_script(10371, &DragonType::Create); mgr->register_creature_script(10363, &DragonType::Create); mgr->register_creature_script(10814, &DragonType::Create); mgr->register_creature_script(9096, &DragonType::Create); mgr->register_creature_script(10083, &DragonType::Create); mgr->register_creature_script(21004, &DragonType::Create); mgr->register_creature_script(2447, &DragonType::Create); mgr->register_creature_script(10161, &DragonType::Create); mgr->register_creature_script(10442, &DragonType::Create); mgr->register_creature_script(10447, &DragonType::Create); mgr->register_creature_script(10740, &DragonType::Create); mgr->register_creature_script(10664, &DragonType::Create); mgr->register_creature_script(10929, &DragonType::Create); mgr->register_creature_script(746, &DragonType::Create); mgr->register_creature_script(1044, &DragonType::Create); mgr->register_creature_script(1045, &DragonType::Create); mgr->register_creature_script(1046, &DragonType::Create); mgr->register_creature_script(1047, &DragonType::Create); mgr->register_creature_script(1048, &DragonType::Create); mgr->register_creature_script(1049, &DragonType::Create); mgr->register_creature_script(1050, &DragonType::Create); mgr->register_creature_script(1063, &DragonType::Create); mgr->register_creature_script(1069, &DragonType::Create); mgr->register_creature_script(22112, &DragonType::Create); mgr->register_creature_script(10339, &DragonType::Create); mgr->register_creature_script(2725, &DragonType::Create); mgr->register_creature_script(2726, &DragonType::Create); mgr->register_creature_script(2757, &DragonType::Create); mgr->register_creature_script(2759, &DragonType::Create); mgr->register_creature_script(17839, &DragonType::Create); mgr->register_creature_script(12476, &DragonType::Create); mgr->register_creature_script(12474, &DragonType::Create); mgr->register_creature_script(4066, &DragonType::Create); mgr->register_creature_script(19959, &DragonType::Create); mgr->register_creature_script(19932, &DragonType::Create); mgr->register_creature_script(21811, &DragonType::Create); mgr->register_creature_script(12475, &DragonType::Create); mgr->register_creature_script(7047, &DragonType::Create); mgr->register_creature_script(7041, &DragonType::Create); mgr->register_creature_script(5277, &DragonType::Create); mgr->register_creature_script(5280, &DragonType::Create); mgr->register_creature_script(5283, &DragonType::Create); mgr->register_creature_script(5312, &DragonType::Create); mgr->register_creature_script(10538, &DragonType::Create); mgr->register_creature_script(10340, &DragonType::Create); mgr->register_creature_script(5709, &DragonType::Create); mgr->register_creature_script(5719, &DragonType::Create); mgr->register_creature_script(5720, &DragonType::Create); mgr->register_creature_script(5721, &DragonType::Create); mgr->register_creature_script(5722, &DragonType::Create); mgr->register_creature_script(5912, &DragonType::Create); mgr->register_creature_script(14888, &DragonType::Create); mgr->register_creature_script(10678, &DragonType::Create); mgr->register_creature_script(8319, &DragonType::Create); mgr->register_creature_script(8480, &DragonType::Create); mgr->register_creature_script(8497, &DragonType::Create); mgr->register_creature_script(17881, &DragonType::Create); mgr->register_creature_script(335, &DragonType::Create); mgr->register_creature_script(8776, &DragonType::Create); mgr->register_creature_script(8976, &DragonType::Create); mgr->register_creature_script(10196, &DragonType::Create); mgr->register_creature_script(10202, &DragonType::Create); mgr->register_creature_script(10258, &DragonType::Create); mgr->register_creature_script(10264, &DragonType::Create); mgr->register_creature_script(10296, &DragonType::Create); mgr->register_creature_script(10663, &DragonType::Create); mgr->register_creature_script(10683, &DragonType::Create); mgr->register_creature_script(12498, &DragonType::Create); mgr->register_creature_script(11583, &DragonType::Create); mgr->register_creature_script(17835, &DragonType::Create); mgr->register_creature_script(12497, &DragonType::Create); mgr->register_creature_script(12739, &DragonType::Create); mgr->register_creature_script(12756, &DragonType::Create); mgr->register_creature_script(12899, &DragonType::Create); mgr->register_creature_script(12900, &DragonType::Create); mgr->register_creature_script(14272, &DragonType::Create); mgr->register_creature_script(14445, &DragonType::Create); mgr->register_creature_script(9568, &DragonType::Create); mgr->register_creature_script(12460, &DragonType::Create); mgr->register_creature_script(14887, &DragonType::Create); mgr->register_creature_script(8198, &DragonType::Create); mgr->register_creature_script(14020, &DragonType::Create); mgr->register_creature_script(11983, &DragonType::Create); mgr->register_creature_script(441, &DragonType::Create); mgr->register_creature_script(8479, &DragonType::Create); mgr->register_creature_script(19438, &DragonType::Create); mgr->register_creature_script(4323, &DragonType::Create); mgr->register_creature_script(4328, &DragonType::Create); mgr->register_creature_script(4324, &DragonType::Create); mgr->register_creature_script(4329, &DragonType::Create); mgr->register_creature_script(4331, &DragonType::Create); mgr->register_creature_script(4339, &DragonType::Create); mgr->register_creature_script(4334, &DragonType::Create); mgr->register_creature_script(10321, &DragonType::Create); mgr->register_creature_script(15378, &DragonType::Create); mgr->register_creature_script(15379, &DragonType::Create); mgr->register_creature_script(15380, &DragonType::Create); mgr->register_creature_script(5276, &DragonType::Create); mgr->register_creature_script(5319, &DragonType::Create); mgr->register_creature_script(5317, &DragonType::Create); mgr->register_creature_script(5320, &DragonType::Create); mgr->register_creature_script(8197, &DragonType::Create); mgr->register_creature_script(3815, &DragonType::Create); mgr->register_creature_script(19918, &DragonType::Create); mgr->register_creature_script(20130, &DragonType::Create); mgr->register_creature_script(19935, &DragonType::Create); mgr->register_creature_script(19936, &DragonType::Create); mgr->register_creature_script(19950, &DragonType::Create); mgr->register_creature_script(19934, &DragonType::Create); mgr->register_creature_script(21648, &DragonType::Create); mgr->register_creature_script(21657, &DragonType::Create); mgr->register_creature_script(18995, &DragonType::Create); mgr->register_creature_script(21497, &DragonType::Create); mgr->register_creature_script(21387, &DragonType::Create); mgr->register_creature_script(21492, &DragonType::Create); mgr->register_creature_script(21389, &DragonType::Create); mgr->register_creature_script(22108, &DragonType::Create); mgr->register_creature_script(22130, &DragonType::Create); mgr->register_creature_script(21722, &DragonType::Create); mgr->register_creature_script(20129, &DragonType::Create); mgr->register_creature_script(18725, &DragonType::Create); mgr->register_creature_script(18723, &DragonType::Create); mgr->register_creature_script(21032, &DragonType::Create); mgr->register_creature_script(20911, &DragonType::Create); mgr->register_creature_script(21139, &DragonType::Create); mgr->register_creature_script(21823, &DragonType::Create); mgr->register_creature_script(22106, &DragonType::Create); mgr->register_creature_script(18171, &DragonType::Create); mgr->register_creature_script(18172, &DragonType::Create); mgr->register_creature_script(18170, &DragonType::Create); mgr->register_creature_script(18096, &DragonType::Create); mgr->register_creature_script(20910, &DragonType::Create); mgr->register_creature_script(17652, &DragonType::Create); mgr->register_creature_script(5278, &DragonType::Create); mgr->register_creature_script(8662, &DragonType::Create); mgr->register_creature_script(21820, &DragonType::Create); mgr->register_creature_script(21817, &DragonType::Create); mgr->register_creature_script(20021, &DragonType::Create); mgr->register_creature_script(18877, &DragonType::Create); mgr->register_creature_script(20332, &DragonType::Create); mgr->register_creature_script(20903, &DragonType::Create); mgr->register_creature_script(21721, &DragonType::Create); mgr->register_creature_script(22072, &DragonType::Create); mgr->register_creature_script(7997, &DragonType::Create); mgr->register_creature_script(15185, &DragonType::Create); mgr->register_creature_script(21821, &DragonType::Create); mgr->register_creature_script(740, &DragonType::Create); mgr->register_creature_script(741, &DragonType::Create); mgr->register_creature_script(10667, &DragonType::Create); mgr->register_creature_script(4016, &DragonType::Create); mgr->register_creature_script(4017, &DragonType::Create); mgr->register_creature_script(8196, &DragonType::Create); mgr->register_creature_script(20713, &DragonType::Create); mgr->register_creature_script(1749, &DragonType::Create); mgr->register_creature_script(8506, &DragonType::Create); mgr->register_creature_script(7846, &DragonType::Create); mgr->register_creature_script(10659, &DragonType::Create); mgr->register_creature_script(7437, &DragonType::Create); mgr->register_creature_script(10660, &DragonType::Create); mgr->register_creature_script(7436, &DragonType::Create); mgr->register_creature_script(7435, &DragonType::Create); mgr->register_creature_script(10661, &DragonType::Create); mgr->register_creature_script(10662, &DragonType::Create); mgr->register_creature_script(7043, &DragonType::Create); mgr->register_creature_script(7049, &DragonType::Create); mgr->register_creature_script(14388, &DragonType::Create); mgr->register_creature_script(8964, &DragonType::Create); mgr->register_creature_script(7042, &DragonType::Create); mgr->register_creature_script(7046, &DragonType::Create); mgr->register_creature_script(7045, &DragonType::Create); mgr->register_creature_script(7040, &DragonType::Create); mgr->register_creature_script(7044, &DragonType::Create); mgr->register_creature_script(9459, &DragonType::Create); mgr->register_creature_script(1043, &DragonType::Create); mgr->register_creature_script(15381, &DragonType::Create); mgr->register_creature_script(22360, &DragonType::Create); mgr->register_creature_script(22496, &DragonType::Create); mgr->register_creature_script(15491, &DragonType::Create); mgr->register_creature_script(18544, &DragonType::Create); mgr->register_creature_script(21510, &DragonType::Create); mgr->register_creature_script(22000, &DragonType::Create); mgr->register_creature_script(21698, &DragonType::Create); mgr->register_creature_script(21697, &DragonType::Create); mgr->register_creature_script(15628, &DragonType::Create); mgr->register_creature_script(16597, &DragonType::Create); mgr->register_creature_script(18543, &DragonType::Create); mgr->register_creature_script(19582, &MechanicalType::Create); mgr->register_creature_script(19588, &MechanicalType::Create); mgr->register_creature_script(21233, &MechanicalType::Create); mgr->register_creature_script(9656, &MechanicalType::Create); mgr->register_creature_script(5202, &MechanicalType::Create); mgr->register_creature_script(6233, &MechanicalType::Create); mgr->register_creature_script(2673, &MechanicalType::Create); mgr->register_creature_script(9657, &MechanicalType::Create); mgr->register_creature_script(18733, &MechanicalType::Create); mgr->register_creature_script(17059, &MechanicalType::Create); mgr->register_creature_script(17578, &MechanicalType::Create); mgr->register_creature_script(20869, &MechanicalType::Create); mgr->register_creature_script(17178, &MechanicalType::Create); mgr->register_creature_script(20243, &MechanicalType::Create); mgr->register_creature_script(16111, &MechanicalType::Create); mgr->register_creature_script(3538, &MechanicalType::Create); mgr->register_creature_script(4872, &MechanicalType::Create); mgr->register_creature_script(7023, &MechanicalType::Create); mgr->register_creature_script(5674, &MechanicalType::Create); mgr->register_creature_script(19139, &MechanicalType::Create); mgr->register_creature_script(22196, &MechanicalType::Create); mgr->register_creature_script(22293, &MechanicalType::Create); mgr->register_creature_script(19589, &MechanicalType::Create); mgr->register_creature_script(20392, &MechanicalType::Create); mgr->register_creature_script(19692, &MechanicalType::Create); mgr->register_creature_script(7527, &MechanicalType::Create); mgr->register_creature_script(13416, &MechanicalType::Create); mgr->register_creature_script(8035, &MechanicalType::Create); mgr->register_creature_script(573, &MechanicalType::Create); mgr->register_creature_script(6225, &MechanicalType::Create); mgr->register_creature_script(6235, &MechanicalType::Create); mgr->register_creature_script(21976, &MechanicalType::Create); mgr->register_creature_script(12473, &MechanicalType::Create); mgr->register_creature_script(2678, &MechanicalType::Create); mgr->register_creature_script(19210, &MechanicalType::Create); mgr->register_creature_script(7915, &MechanicalType::Create); mgr->register_creature_script(6227, &MechanicalType::Create); mgr->register_creature_script(6229, &MechanicalType::Create); mgr->register_creature_script(6230, &MechanicalType::Create); mgr->register_creature_script(6232, &MechanicalType::Create); mgr->register_creature_script(5723, &MechanicalType::Create); mgr->register_creature_script(6234, &MechanicalType::Create); mgr->register_creature_script(6231, &MechanicalType::Create); mgr->register_creature_script(6386, &MechanicalType::Create); mgr->register_creature_script(7784, &MechanicalType::Create); mgr->register_creature_script(7806, &MechanicalType::Create); mgr->register_creature_script(2667, &MechanicalType::Create); mgr->register_creature_script(7209, &MechanicalType::Create); mgr->register_creature_script(9623, &MechanicalType::Create); mgr->register_creature_script(17543, &MechanicalType::Create); mgr->register_creature_script(7849, &MechanicalType::Create); mgr->register_creature_script(7800, &MechanicalType::Create); mgr->register_creature_script(17547, &MechanicalType::Create); mgr->register_creature_script(7897, &MechanicalType::Create); mgr->register_creature_script(11875, &MechanicalType::Create); mgr->register_creature_script(12364, &MechanicalType::Create); mgr->register_creature_script(12368, &MechanicalType::Create); mgr->register_creature_script(12385, &MechanicalType::Create); mgr->register_creature_script(12426, &MechanicalType::Create); mgr->register_creature_script(13378, &MechanicalType::Create); mgr->register_creature_script(14224, &MechanicalType::Create); mgr->register_creature_script(15328, &MechanicalType::Create); mgr->register_creature_script(15368, &MechanicalType::Create); mgr->register_creature_script(22122, &MechanicalType::Create); mgr->register_creature_script(17796, &MechanicalType::Create); mgr->register_creature_script(17954, &MechanicalType::Create); mgr->register_creature_script(4945, &MechanicalType::Create); mgr->register_creature_script(4251, &MechanicalType::Create); mgr->register_creature_script(16504, &MechanicalType::Create); mgr->register_creature_script(4252, &MechanicalType::Create); mgr->register_creature_script(21761, &MechanicalType::Create); mgr->register_creature_script(6226, &MechanicalType::Create); mgr->register_creature_script(8447, &MechanicalType::Create); mgr->register_creature_script(16121, &MechanicalType::Create); mgr->register_creature_script(14337, &MechanicalType::Create); mgr->register_creature_script(15691, &MechanicalType::Create); mgr->register_creature_script(16485, &MechanicalType::Create); mgr->register_creature_script(8836, &MechanicalType::Create); mgr->register_creature_script(8615, &MechanicalType::Create); mgr->register_creature_script(7807, &MechanicalType::Create); mgr->register_creature_script(15079, &MechanicalType::Create); mgr->register_creature_script(18405, &MechanicalType::Create); mgr->register_creature_script(16211, &MechanicalType::Create); mgr->register_creature_script(22461, &MechanicalType::Create); mgr->register_creature_script(19849, &MechanicalType::Create); mgr->register_creature_script(4946, &MechanicalType::Create); mgr->register_creature_script(21949, &MechanicalType::Create); mgr->register_creature_script(19851, &MechanicalType::Create); mgr->register_creature_script(21404, &MechanicalType::Create); mgr->register_creature_script(17711, &MechanicalType::Create); mgr->register_creature_script(20076, &MechanicalType::Create); mgr->register_creature_script(11684, &MechanicalType::Create); mgr->register_creature_script(2674, &MechanicalType::Create); mgr->register_creature_script(22443, &MechanicalType::Create); mgr->register_creature_script(22451, &MechanicalType::Create); mgr->register_creature_script(22295, &MechanicalType::Create); mgr->register_creature_script(22389, &MechanicalType::Create); mgr->register_creature_script(20420, &MechanicalType::Create); mgr->register_creature_script(7166, &MechanicalType::Create); mgr->register_creature_script(5652, &MechanicalType::Create); mgr->register_creature_script(4260, &MechanicalType::Create); mgr->register_creature_script(21426, &MechanicalType::Create); mgr->register_creature_script(22067, &MechanicalType::Create); mgr->register_creature_script(22064, &MechanicalType::Create); mgr->register_creature_script(22315, &MechanicalType::Create); mgr->register_creature_script(19166, &MechanicalType::Create); mgr->register_creature_script(19735, &MechanicalType::Create); mgr->register_creature_script(19219, &MechanicalType::Create); mgr->register_creature_script(20478, &MechanicalType::Create); mgr->register_creature_script(19399, &MechanicalType::Create); mgr->register_creature_script(19400, &MechanicalType::Create); mgr->register_creature_script(17060, &MechanicalType::Create); mgr->register_creature_script(2676, &MechanicalType::Create); mgr->register_creature_script(4074, &MechanicalType::Create); mgr->register_creature_script(4073, &MechanicalType::Create); mgr->register_creature_script(480, &MechanicalType::Create); mgr->register_creature_script(36, &MechanicalType::Create); mgr->register_creature_script(114, &MechanicalType::Create); mgr->register_creature_script(8856, &MechanicalType::Create); mgr->register_creature_script(12363, &MechanicalType::Create); mgr->register_creature_script(12367, &MechanicalType::Create); mgr->register_creature_script(12365, &MechanicalType::Create); mgr->register_creature_script(14553, &MechanicalType::Create); mgr->register_creature_script(14552, &MechanicalType::Create); mgr->register_creature_script(12366, &MechanicalType::Create); mgr->register_creature_script(14551, &MechanicalType::Create); mgr->register_creature_script(19405, &MechanicalType::Create); mgr->register_creature_script(21690, &MechanicalType::Create); mgr->register_creature_script(6669, &MechanicalType::Create); mgr->register_creature_script(22085, &MechanicalType::Create); mgr->register_creature_script(11199, &MechanicalType::Create); mgr->register_creature_script(2922, &MechanicalType::Create); mgr->register_creature_script(4952, &MechanicalType::Create); mgr->register_creature_script(115, &MechanicalType::Create); mgr->register_creature_script(642, &MechanicalType::Create); mgr->register_creature_script(2520, &MechanicalType::Create); mgr->register_creature_script(25, &MechanicalType::Create); mgr->register_creature_script(15104, &MechanicalType::Create); mgr->register_creature_script(15319, &MechanicalType::Create); mgr->register_creature_script(15323, &MechanicalType::Create); mgr->register_creature_script(15333, &MechanicalType::Create); mgr->register_creature_script(15336, &MechanicalType::Create); mgr->register_creature_script(15340, &MechanicalType::Create); mgr->register_creature_script(15370, &MechanicalType::Create); mgr->register_creature_script(15428, &MechanicalType::Create); mgr->register_creature_script(15505, &MechanicalType::Create); mgr->register_creature_script(15963, &MechanicalType::Create); mgr->register_creature_script(15964, &MechanicalType::Create); mgr->register_creature_script(17299, &MechanicalType::Create); mgr->register_creature_script(20041, &MechanicalType::Create); mgr->register_creature_script(20040, &MechanicalType::Create); mgr->register_creature_script(19516, &MechanicalType::Create); mgr->register_creature_script(17706, &MechanicalType::Create); mgr->register_creature_script(15935, &MechanicalType::Create); mgr->register_creature_script(19552, &MechanicalType::Create); mgr->register_creature_script(20779, &UnknownType::Create); mgr->register_creature_script(15883, &UnknownType::Create); mgr->register_creature_script(15882, &UnknownType::Create); mgr->register_creature_script(16364, &UnknownType::Create); mgr->register_creature_script(19475, &UnknownType::Create); mgr->register_creature_script(6509, &UnknownType::Create); mgr->register_creature_script(20208, &UnknownType::Create); mgr->register_creature_script(11729, &UnknownType::Create); mgr->register_creature_script(11726, &UnknownType::Create); mgr->register_creature_script(11728, &UnknownType::Create); mgr->register_creature_script(11725, &UnknownType::Create); mgr->register_creature_script(6556, &UnknownType::Create); mgr->register_creature_script(17408, &UnknownType::Create); mgr->register_creature_script(22422, &UnknownType::Create); mgr->register_creature_script(20736, &UnknownType::Create); mgr->register_creature_script(22068, &UnknownType::Create); mgr->register_creature_script(22065, &UnknownType::Create); mgr->register_creature_script(22069, &UnknownType::Create); mgr->register_creature_script(2992, &UnknownType::Create); mgr->register_creature_script(21899, &UnknownType::Create); mgr->register_creature_script(21039, &UnknownType::Create); mgr->register_creature_script(20767, &UnknownType::Create); mgr->register_creature_script(15324, &UnknownType::Create); mgr->register_creature_script(15047, &UnknownType::Create); mgr->register_creature_script(4130, &UnknownType::Create); mgr->register_creature_script(15343, &UnknownType::Create); mgr->register_creature_script(18133, &UnknownType::Create); mgr->register_creature_script(15608, &UnknownType::Create); mgr->register_creature_script(21862, &UnknownType::Create); mgr->register_creature_script(10415, &UnknownType::Create); mgr->register_creature_script(18781, &UnknownType::Create); mgr->register_creature_script(19680, &UnknownType::Create); mgr->register_creature_script(20808, &UnknownType::Create); mgr->register_creature_script(19165, &UnknownType::Create); mgr->register_creature_script(19688, &UnknownType::Create); mgr->register_creature_script(18481, &UnknownType::Create); mgr->register_creature_script(18593, &UnknownType::Create); mgr->register_creature_script(18228, &UnknownType::Create); mgr->register_creature_script(18842, &UnknownType::Create); mgr->register_creature_script(12276, &UnknownType::Create); mgr->register_creature_script(15288, &UnknownType::Create); mgr->register_creature_script(15290, &UnknownType::Create); mgr->register_creature_script(15286, &UnknownType::Create); mgr->register_creature_script(6219, &UnknownType::Create); mgr->register_creature_script(16047, &UnknownType::Create); mgr->register_creature_script(20796, &UnknownType::Create); mgr->register_creature_script(19869, &UnknownType::Create); mgr->register_creature_script(21101, &UnknownType::Create); mgr->register_creature_script(21346, &UnknownType::Create); mgr->register_creature_script(20865, &UnknownType::Create); mgr->register_creature_script(20864, &UnknownType::Create); mgr->register_creature_script(20780, &UnknownType::Create); mgr->register_creature_script(14453, &UnknownType::Create); mgr->register_creature_script(19686, &UnknownType::Create); mgr->register_creature_script(14449, &UnknownType::Create); mgr->register_creature_script(14459, &UnknownType::Create); mgr->register_creature_script(6554, &UnknownType::Create); mgr->register_creature_script(10925, &UnknownType::Create); mgr->register_creature_script(16899, &UnknownType::Create); mgr->register_creature_script(20023, &UnknownType::Create); mgr->register_creature_script(20024, &UnknownType::Create); mgr->register_creature_script(20003, &UnknownType::Create); mgr->register_creature_script(2656, &UnknownType::Create); mgr->register_creature_script(1032, &UnknownType::Create); mgr->register_creature_script(16897, &UnknownType::Create); mgr->register_creature_script(18504, &UnknownType::Create); mgr->register_creature_script(18560, &UnknownType::Create); mgr->register_creature_script(15894, &UnknownType::Create); mgr->register_creature_script(15893, &UnknownType::Create); mgr->register_creature_script(6348, &UnknownType::Create); mgr->register_creature_script(6140, &UnknownType::Create); mgr->register_creature_script(20809, &UnknownType::Create); mgr->register_creature_script(19301, &UnknownType::Create); mgr->register_creature_script(19302, &UnknownType::Create); mgr->register_creature_script(19303, &UnknownType::Create); mgr->register_creature_script(19304, &UnknownType::Create); mgr->register_creature_script(19913, &UnknownType::Create); mgr->register_creature_script(17687, &UnknownType::Create); mgr->register_creature_script(19032, &UnknownType::Create); mgr->register_creature_script(17795, &UnknownType::Create); mgr->register_creature_script(17794, &UnknownType::Create); mgr->register_creature_script(19029, &UnknownType::Create); mgr->register_creature_script(19028, &UnknownType::Create); mgr->register_creature_script(17356, &UnknownType::Create); mgr->register_creature_script(17357, &UnknownType::Create); mgr->register_creature_script(17552, &UnknownType::Create); mgr->register_creature_script(18370, &UnknownType::Create); mgr->register_creature_script(17471, &UnknownType::Create); mgr->register_creature_script(18782, &UnknownType::Create); mgr->register_creature_script(21395, &UnknownType::Create); mgr->register_creature_script(16968, &UnknownType::Create); mgr->register_creature_script(11101, &UnknownType::Create); mgr->register_creature_script(19646, &UnknownType::Create); mgr->register_creature_script(14848, &UnknownType::Create); mgr->register_creature_script(18818, &UnknownType::Create); mgr->register_creature_script(19466, &UnknownType::Create); mgr->register_creature_script(15091, &UnknownType::Create); mgr->register_creature_script(18381, &UnknownType::Create); mgr->register_creature_script(14466, &UnknownType::Create); mgr->register_creature_script(2462, &UnknownType::Create); mgr->register_creature_script(16046, &UnknownType::Create); mgr->register_creature_script(14646, &UnknownType::Create); mgr->register_creature_script(19193, &UnknownType::Create); mgr->register_creature_script(7863, &UnknownType::Create); mgr->register_creature_script(18563, &UnknownType::Create); mgr->register_creature_script(19437, &UnknownType::Create); mgr->register_creature_script(19421, &UnknownType::Create); mgr->register_creature_script(18967, &UnknownType::Create); mgr->register_creature_script(20617, &UnknownType::Create); mgr->register_creature_script(18240, &UnknownType::Create); mgr->register_creature_script(8766, &UnknownType::Create); mgr->register_creature_script(15064, &UnknownType::Create); mgr->register_creature_script(17984, &UnknownType::Create); mgr->register_creature_script(22336, &UnknownType::Create); mgr->register_creature_script(18913, &UnknownType::Create); mgr->register_creature_script(19272, &UnknownType::Create); mgr->register_creature_script(19216, &UnknownType::Create); mgr->register_creature_script(19179, &UnknownType::Create); mgr->register_creature_script(12219, &UnknownType::Create); mgr->register_creature_script(12220, &UnknownType::Create); mgr->register_creature_script(12222, &UnknownType::Create); mgr->register_creature_script(12258, &UnknownType::Create); mgr->register_creature_script(12221, &UnknownType::Create); mgr->register_creature_script(3560, &UnknownType::Create); mgr->register_creature_script(7483, &UnknownType::Create); mgr->register_creature_script(19845, &UnknownType::Create); mgr->register_creature_script(19651, &UnknownType::Create); mgr->register_creature_script(22063, &UnknownType::Create); mgr->register_creature_script(21974, &UnknownType::Create); mgr->register_creature_script(20162, &UnknownType::Create); mgr->register_creature_script(21872, &UnknownType::Create); mgr->register_creature_script(22395, &UnknownType::Create); mgr->register_creature_script(22417, &UnknownType::Create); mgr->register_creature_script(22437, &UnknownType::Create); mgr->register_creature_script(21944, &UnknownType::Create); mgr->register_creature_script(18589, &UnknownType::Create); mgr->register_creature_script(16243, &UnknownType::Create); mgr->register_creature_script(18600, &UnknownType::Create); mgr->register_creature_script(21186, &UnknownType::Create); mgr->register_creature_script(21903, &UnknownType::Create); mgr->register_creature_script(21957, &UnknownType::Create); mgr->register_creature_script(21997, &UnknownType::Create); mgr->register_creature_script(1030, &UnknownType::Create); mgr->register_creature_script(19067, &UnknownType::Create); mgr->register_creature_script(19212, &UnknownType::Create); mgr->register_creature_script(18532, &UnknownType::Create); mgr->register_creature_script(16079, &UnknownType::Create); mgr->register_creature_script(22358, &UnknownType::Create); mgr->register_creature_script(21814, &UnknownType::Create); mgr->register_creature_script(22090, &UnknownType::Create); mgr->register_creature_script(19660, &UnknownType::Create); mgr->register_creature_script(18904, &UnknownType::Create); mgr->register_creature_script(18215, &UnknownType::Create); mgr->register_creature_script(18208, &UnknownType::Create); mgr->register_creature_script(18840, &UnknownType::Create); mgr->register_creature_script(20289, &UnknownType::Create); mgr->register_creature_script(16085, &UnknownType::Create); mgr->register_creature_script(18688, &UnknownType::Create); mgr->register_creature_script(19063, &UnknownType::Create); mgr->register_creature_script(18538, &UnknownType::Create); mgr->register_creature_script(19009, &UnknownType::Create); mgr->register_creature_script(21236, &UnknownType::Create); mgr->register_creature_script(16901, &UnknownType::Create); mgr->register_creature_script(16903, &UnknownType::Create); mgr->register_creature_script(14345, &UnknownType::Create); mgr->register_creature_script(21849, &UnknownType::Create); mgr->register_creature_script(19433, &UnknownType::Create); mgr->register_creature_script(19939, &UnknownType::Create); mgr->register_creature_script(19727, &UnknownType::Create); mgr->register_creature_script(19731, &UnknownType::Create); mgr->register_creature_script(21898, &UnknownType::Create); mgr->register_creature_script(5451, &UnknownType::Create); mgr->register_creature_script(15897, &UnknownType::Create); mgr->register_creature_script(18530, &UnknownType::Create); mgr->register_creature_script(8149, &UnknownType::Create); mgr->register_creature_script(7785, &UnknownType::Create); mgr->register_creature_script(7732, &UnknownType::Create); mgr->register_creature_script(19655, &UnknownType::Create); mgr->register_creature_script(15063, &UnknownType::Create); mgr->register_creature_script(21203, &UnknownType::Create); mgr->register_creature_script(4469, &UnknownType::Create); mgr->register_creature_script(22400, &UnknownType::Create); mgr->register_creature_script(21858, &UnknownType::Create); mgr->register_creature_script(22407, &UnknownType::Create); mgr->register_creature_script(19467, &UnknownType::Create); mgr->register_creature_script(21305, &UnknownType::Create); mgr->register_creature_script(13876, &UnknownType::Create); mgr->register_creature_script(17690, &UnknownType::Create); mgr->register_creature_script(15390, &UnknownType::Create); mgr->register_creature_script(21996, &UnknownType::Create); mgr->register_creature_script(21237, &UnknownType::Create); mgr->register_creature_script(18778, &UnknownType::Create); mgr->register_creature_script(19523, &UnknownType::Create); mgr->register_creature_script(19524, &UnknownType::Create); mgr->register_creature_script(15384, &UnknownType::Create); mgr->register_creature_script(20709, &UnknownType::Create); mgr->register_creature_script(17611, &UnknownType::Create); mgr->register_creature_script(15089, &UnknownType::Create); mgr->register_creature_script(15107, &UnknownType::Create); mgr->register_creature_script(15086, &UnknownType::Create); mgr->register_creature_script(15075, &UnknownType::Create); mgr->register_creature_script(15074, &UnknownType::Create); mgr->register_creature_script(15108, &UnknownType::Create); mgr->register_creature_script(15087, &UnknownType::Create); mgr->register_creature_script(15062, &UnknownType::Create); mgr->register_creature_script(15046, &UnknownType::Create); mgr->register_creature_script(22021, &UnknownType::Create); mgr->register_creature_script(18263, &UnknownType::Create); mgr->register_creature_script(19211, &UnknownType::Create); mgr->register_creature_script(18264, &UnknownType::Create); mgr->register_creature_script(19469, &UnknownType::Create); mgr->register_creature_script(19468, &UnknownType::Create); mgr->register_creature_script(19390, &UnknownType::Create); mgr->register_creature_script(1806, &UnknownType::Create); mgr->register_creature_script(1808, &UnknownType::Create); mgr->register_creature_script(6555, &UnknownType::Create); mgr->register_creature_script(21262, &UnknownType::Create); mgr->register_creature_script(21261, &UnknownType::Create); mgr->register_creature_script(21334, &UnknownType::Create); mgr->register_creature_script(21856, &UnknownType::Create); mgr->register_creature_script(21855, &UnknownType::Create); mgr->register_creature_script(4541, &UnknownType::Create); mgr->register_creature_script(19654, &UnknownType::Create); mgr->register_creature_script(8120, &UnknownType::Create); mgr->register_creature_script(14732, &UnknownType::Create); mgr->register_creature_script(20851, &UnknownType::Create); mgr->register_creature_script(21159, &UnknownType::Create); mgr->register_creature_script(18793, &UnknownType::Create); mgr->register_creature_script(3652, &UnknownType::Create); mgr->register_creature_script(18625, &UnknownType::Create); mgr->register_creature_script(18553, &UnknownType::Create); mgr->register_creature_script(18555, &UnknownType::Create); mgr->register_creature_script(17838, &UnknownType::Create); mgr->register_creature_script(14894, &UnknownType::Create); mgr->register_creature_script(17310, &UnknownType::Create); mgr->register_creature_script(4392, &UnknownType::Create); mgr->register_creature_script(4393, &UnknownType::Create); mgr->register_creature_script(19050, &UnknownType::Create); mgr->register_creature_script(19161, &UnknownType::Create); mgr->register_creature_script(19377, &UnknownType::Create); mgr->register_creature_script(15045, &UnknownType::Create); mgr->register_creature_script(21999, &UnknownType::Create); mgr->register_creature_script(4795, &UnknownType::Create); mgr->register_creature_script(17066, &UnknownType::Create); mgr->register_creature_script(15902, &UnknownType::Create); mgr->register_creature_script(5228, &UnknownType::Create); mgr->register_creature_script(5235, &UnknownType::Create); mgr->register_creature_script(16044, &UnknownType::Create); mgr->register_creature_script(5350, &UnknownType::Create); mgr->register_creature_script(5441, &UnknownType::Create); mgr->register_creature_script(5450, &UnknownType::Create); mgr->register_creature_script(5452, &UnknownType::Create); mgr->register_creature_script(5453, &UnknownType::Create); mgr->register_creature_script(5454, &UnknownType::Create); mgr->register_creature_script(21935, &UnknownType::Create); mgr->register_creature_script(15325, &UnknownType::Create); mgr->register_creature_script(22002, &UnknownType::Create); mgr->register_creature_script(12247, &UnknownType::Create); mgr->register_creature_script(12252, &UnknownType::Create); mgr->register_creature_script(16431, &UnknownType::Create); mgr->register_creature_script(6347, &UnknownType::Create); mgr->register_creature_script(6582, &UnknownType::Create); mgr->register_creature_script(21798, &UnknownType::Create); mgr->register_creature_script(21760, &UnknownType::Create); mgr->register_creature_script(7412, &UnknownType::Create); mgr->register_creature_script(7413, &UnknownType::Create); mgr->register_creature_script(7423, &UnknownType::Create); mgr->register_creature_script(7424, &UnknownType::Create); mgr->register_creature_script(16844, &UnknownType::Create); mgr->register_creature_script(16092, &UnknownType::Create); mgr->register_creature_script(7468, &UnknownType::Create); mgr->register_creature_script(18726, &UnknownType::Create); mgr->register_creature_script(7768, &UnknownType::Create); mgr->register_creature_script(7769, &UnknownType::Create); mgr->register_creature_script(16048, &UnknownType::Create); mgr->register_creature_script(8204, &UnknownType::Create); mgr->register_creature_script(8205, &UnknownType::Create); mgr->register_creature_script(8212, &UnknownType::Create); mgr->register_creature_script(8257, &UnknownType::Create); mgr->register_creature_script(8311, &UnknownType::Create); mgr->register_creature_script(21512, &UnknownType::Create); mgr->register_creature_script(8437, &UnknownType::Create); mgr->register_creature_script(8438, &UnknownType::Create); mgr->register_creature_script(8440, &UnknownType::Create); mgr->register_creature_script(8443, &UnknownType::Create); mgr->register_creature_script(8510, &UnknownType::Create); mgr->register_creature_script(19427, &UnknownType::Create); mgr->register_creature_script(21759, &UnknownType::Create); mgr->register_creature_script(9157, &UnknownType::Create); mgr->register_creature_script(9436, &UnknownType::Create); mgr->register_creature_script(9477, &UnknownType::Create); mgr->register_creature_script(9496, &UnknownType::Create); mgr->register_creature_script(9498, &UnknownType::Create); mgr->register_creature_script(6218, &UnknownType::Create); mgr->register_creature_script(16592, &UnknownType::Create); mgr->register_creature_script(9621, &UnknownType::Create); mgr->register_creature_script(9707, &UnknownType::Create); mgr->register_creature_script(10040, &UnknownType::Create); mgr->register_creature_script(10041, &UnknownType::Create); mgr->register_creature_script(10183, &UnknownType::Create); mgr->register_creature_script(10217, &UnknownType::Create); mgr->register_creature_script(10290, &UnknownType::Create); mgr->register_creature_script(20333, &UnknownType::Create); mgr->register_creature_script(20922, &UnknownType::Create); mgr->register_creature_script(12251, &UnknownType::Create); mgr->register_creature_script(10697, &UnknownType::Create); mgr->register_creature_script(21234, &UnknownType::Create); mgr->register_creature_script(8607, &UnknownType::Create); mgr->register_creature_script(11100, &UnknownType::Create); mgr->register_creature_script(11122, &UnknownType::Create); mgr->register_creature_script(11136, &UnknownType::Create); mgr->register_creature_script(17535, &UnknownType::Create); mgr->register_creature_script(15224, &UnknownType::Create); mgr->register_creature_script(11623, &UnknownType::Create); mgr->register_creature_script(18162, &UnknownType::Create); mgr->register_creature_script(12381, &UnknownType::Create); mgr->register_creature_script(12382, &UnknownType::Create); mgr->register_creature_script(12387, &UnknownType::Create); mgr->register_creature_script(19300, &UnknownType::Create); mgr->register_creature_script(13136, &UnknownType::Create); mgr->register_creature_script(13301, &UnknownType::Create); mgr->register_creature_script(13602, &UnknownType::Create); mgr->register_creature_script(13636, &UnknownType::Create); mgr->register_creature_script(13756, &UnknownType::Create); mgr->register_creature_script(13778, &UnknownType::Create); mgr->register_creature_script(13796, &UnknownType::Create); mgr->register_creature_script(13916, &UnknownType::Create); mgr->register_creature_script(13936, &UnknownType::Create); mgr->register_creature_script(14027, &UnknownType::Create); mgr->register_creature_script(14028, &UnknownType::Create); mgr->register_creature_script(8606, &UnknownType::Create); mgr->register_creature_script(14081, &UnknownType::Create); mgr->register_creature_script(18537, &UnknownType::Create); mgr->register_creature_script(14235, &UnknownType::Create); mgr->register_creature_script(16467, &UnknownType::Create); mgr->register_creature_script(16465, &UnknownType::Create); mgr->register_creature_script(14370, &UnknownType::Create); mgr->register_creature_script(14396, &UnknownType::Create); mgr->register_creature_script(22194, &UnknownType::Create); mgr->register_creature_script(14434, &UnknownType::Create); mgr->register_creature_script(14473, &UnknownType::Create); mgr->register_creature_script(14474, &UnknownType::Create); mgr->register_creature_script(14475, &UnknownType::Create); mgr->register_creature_script(14495, &UnknownType::Create); mgr->register_creature_script(14524, &UnknownType::Create); mgr->register_creature_script(14525, &UnknownType::Create); mgr->register_creature_script(14526, &UnknownType::Create); mgr->register_creature_script(14661, &UnknownType::Create); mgr->register_creature_script(14751, &UnknownType::Create); mgr->register_creature_script(14752, &UnknownType::Create); mgr->register_creature_script(14761, &UnknownType::Create); mgr->register_creature_script(15001, &UnknownType::Create); mgr->register_creature_script(15002, &UnknownType::Create); mgr->register_creature_script(15003, &UnknownType::Create); mgr->register_creature_script(15004, &UnknownType::Create); mgr->register_creature_script(15005, &UnknownType::Create); mgr->register_creature_script(15069, &UnknownType::Create); mgr->register_creature_script(15073, &UnknownType::Create); mgr->register_creature_script(15113, &UnknownType::Create); mgr->register_creature_script(15115, &UnknownType::Create); mgr->register_creature_script(15122, &UnknownType::Create); mgr->register_creature_script(15207, &UnknownType::Create); mgr->register_creature_script(15218, &UnknownType::Create); mgr->register_creature_script(15260, &UnknownType::Create); mgr->register_creature_script(15261, &UnknownType::Create); mgr->register_creature_script(15305, &UnknownType::Create); mgr->register_creature_script(15363, &UnknownType::Create); mgr->register_creature_script(15415, &UnknownType::Create); mgr->register_creature_script(15425, &UnknownType::Create); mgr->register_creature_script(19483, &UnknownType::Create); mgr->register_creature_script(19439, &UnknownType::Create); mgr->register_creature_script(19484, &UnknownType::Create); mgr->register_creature_script(20336, &UnknownType::Create); mgr->register_creature_script(15730, &UnknownType::Create); mgr->register_creature_script(15624, &UnknownType::Create); mgr->register_creature_script(15901, &UnknownType::Create); mgr->register_creature_script(20978, &UnknownType::Create); mgr->register_creature_script(18531, &UnknownType::Create); mgr->register_creature_script(22497, &UnknownType::Create); mgr->register_creature_script(21893, &UnknownType::Create); mgr->register_creature_script(18549, &UnknownType::Create); mgr->register_creature_script(19142, &UnknownType::Create); mgr->register_creature_script(15335, &UnknownType::Create); mgr->register_creature_script(18132, &UnknownType::Create); mgr->register_creature_script(22126, &UnknownType::Create); mgr->register_creature_script(22094, &UnknownType::Create); mgr->register_creature_script(22439, &UnknownType::Create); mgr->register_creature_script(22438, &UnknownType::Create); mgr->register_creature_script(22124, &UnknownType::Create); mgr->register_creature_script(18395, &UnknownType::Create); mgr->register_creature_script(18393, &UnknownType::Create); mgr->register_creature_script(18841, &UnknownType::Create); mgr->register_creature_script(15391, &UnknownType::Create); mgr->register_creature_script(17915, &UnknownType::Create); mgr->register_creature_script(22125, &UnknownType::Create); mgr->register_creature_script(22440, &UnknownType::Create); mgr->register_creature_script(15241, &UnknownType::Create); mgr->register_creature_script(18597, &UnknownType::Create); mgr->register_creature_script(18757, &UnknownType::Create); mgr->register_creature_script(19668, &UnknownType::Create); mgr->register_creature_script(17378, &UnknownType::Create); mgr->register_creature_script(20926, &UnknownType::Create); mgr->register_creature_script(14994, &UnknownType::Create); mgr->register_creature_script(15168, &UnknownType::Create); mgr->register_creature_script(15348, &UnknownType::Create); mgr->register_creature_script(19008, &UnknownType::Create); mgr->register_creature_script(20093, &UnknownType::Create); mgr->register_creature_script(3398, &UnknownType::Create); mgr->register_creature_script(20214, &UnknownType::Create); mgr->register_creature_script(21347, &UnknownType::Create); mgr->register_creature_script(21756, &UnknownType::Create); mgr->register_creature_script(14443, &UnknownType::Create); mgr->register_creature_script(15387, &UnknownType::Create); mgr->register_creature_script(2334, &UnknownType::Create); mgr->register_creature_script(17847, &UnknownType::Create); mgr->register_creature_script(17544, &UnknownType::Create); mgr->register_creature_script(15344, &UnknownType::Create); mgr->register_creature_script(7092, &UnknownType::Create); mgr->register_creature_script(18654, &UnknownType::Create); mgr->register_creature_script(15389, &UnknownType::Create); mgr->register_creature_script(19525, &UnknownType::Create); mgr->register_creature_script(15392, &UnknownType::Create); mgr->register_creature_script(15385, &UnknownType::Create); mgr->register_creature_script(10902, &UnknownType::Create); mgr->register_creature_script(15386, &UnknownType::Create); mgr->register_creature_script(21414, &UnknownType::Create); mgr->register_creature_script(15327, &UnknownType::Create); mgr->register_creature_script(22001, &UnknownType::Create); mgr->register_creature_script(21993, &UnknownType::Create); mgr->register_creature_script(2615, &UnknownType::Create); mgr->register_creature_script(18594, &UnknownType::Create); mgr->register_creature_script(18547, &UnknownType::Create); mgr->register_creature_script(18568, &UnknownType::Create); mgr->register_creature_script(22317, &UnknownType::Create); mgr->register_creature_script(21699, &UnknownType::Create); mgr->register_creature_script(17985, &UnknownType::Create); mgr->register_creature_script(19224, &UnknownType::Create); mgr->register_creature_script(17645, &UnknownType::Create); mgr->register_creature_script(16457, &UnknownType::Create); mgr->register_creature_script(17260, &UnknownType::Create); mgr->register_creature_script(21402, &UnknownType::Create); mgr->register_creature_script(19528, &UnknownType::Create); mgr->register_creature_script(21822, &UnknownType::Create); mgr->register_creature_script(19532, &UnknownType::Create); mgr->register_creature_script(15449, &UnknownType::Create); mgr->register_creature_script(20286, &UnknownType::Create); mgr->register_creature_script(20288, &UnknownType::Create); mgr->register_creature_script(21075, &UnknownType::Create); mgr->register_creature_script(19215, &UnknownType::Create); mgr->register_creature_script(19291, &UnknownType::Create); mgr->register_creature_script(19871, &UnknownType::Create); mgr->register_creature_script(18968, &UnknownType::Create); mgr->register_creature_script(19358, &UnknownType::Create); mgr->register_creature_script(19276, &UnknownType::Create); mgr->register_creature_script(19717, &UnknownType::Create); mgr->register_creature_script(19277, &UnknownType::Create); mgr->register_creature_script(6349, &UnknownType::Create); mgr->register_creature_script(4391, &UnknownType::Create); mgr->register_creature_script(10718, &UnknownType::Create); mgr->register_creature_script(15454, &UnknownType::Create); mgr->register_creature_script(15801, &UnknownType::Create); mgr->register_creature_script(15247, &UnknownType::Create); mgr->register_creature_script(15233, &UnknownType::Create); mgr->register_creature_script(15262, &UnknownType::Create); mgr->register_creature_script(15264, &UnknownType::Create); mgr->register_creature_script(15263, &UnknownType::Create); mgr->register_creature_script(15426, &UnknownType::Create); mgr->register_creature_script(15230, &UnknownType::Create); mgr->register_creature_script(15896, &UnknownType::Create); mgr->register_creature_script(15589, &UnknownType::Create); mgr->register_creature_script(15727, &UnknownType::Create); mgr->register_creature_script(15511, &UnknownType::Create); mgr->register_creature_script(15544, &UnknownType::Create); mgr->register_creature_script(15543, &UnknownType::Create); mgr->register_creature_script(15802, &UnknownType::Create); mgr->register_creature_script(15622, &UnknownType::Create); mgr->register_creature_script(15509, &UnknownType::Create); mgr->register_creature_script(15933, &UnknownType::Create); mgr->register_creature_script(15621, &UnknownType::Create); mgr->register_creature_script(15516, &UnknownType::Create); mgr->register_creature_script(15984, &UnknownType::Create); mgr->register_creature_script(15300, &UnknownType::Create); mgr->register_creature_script(15229, &UnknownType::Create); mgr->register_creature_script(15620, &UnknownType::Create); mgr->register_creature_script(18144, &UnknownType::Create); mgr->register_creature_script(7273, &UnknownType::Create); mgr->register_creature_script(5246, &UnknownType::Create); mgr->register_creature_script(5247, &UnknownType::Create); mgr->register_creature_script(5244, &UnknownType::Create); mgr->register_creature_script(5245, &UnknownType::Create); mgr->register_creature_script(2655, &UnknownType::Create); mgr->register_creature_script(15112, &UnknownType::Create); mgr->register_creature_script(14987, &UnknownType::Create); mgr->register_creature_script(15141, &UnknownType::Create); mgr->register_creature_script(15114, &UnknownType::Create); mgr->register_creature_script(15140, &UnknownType::Create); mgr->register_creature_script(16466, &UnknownType::Create); mgr->register_creature_script(15388, &UnknownType::Create); mgr->register_creature_script(15341, &UnknownType::Create); mgr->register_creature_script(16420, &UnknownType::Create); mgr->register_creature_script(16137, &UnknownType::Create); mgr->register_creature_script(16400, &UnknownType::Create); mgr->register_creature_script(16082, &UnknownType::Create); mgr->register_creature_script(16142, &UnknownType::Create); mgr->register_creature_script(16363, &UnknownType::Create); mgr->register_creature_script(16218, &UnknownType::Create); mgr->register_creature_script(16297, &UnknownType::Create); mgr->register_creature_script(17231, &UnknownType::Create); mgr->register_creature_script(16236, &UnknownType::Create); mgr->register_creature_script(17293, &UnknownType::Create); mgr->register_creature_script(16698, &UnknownType::Create); mgr->register_creature_script(16486, &UnknownType::Create); mgr->register_creature_script(15510, &UnknownType::Create); mgr->register_creature_script(15240, &UnknownType::Create); mgr->register_creature_script(15962, &UnknownType::Create); mgr->register_creature_script(15630, &UnknownType::Create); mgr->register_creature_script(15236, &UnknownType::Create); mgr->register_creature_script(15235, &UnknownType::Create); mgr->register_creature_script(15249, &UnknownType::Create); mgr->register_creature_script(15277, &UnknownType::Create); mgr->register_creature_script(15317, &UnknownType::Create); mgr->register_creature_script(15537, &UnknownType::Create); mgr->register_creature_script(15316, &UnknownType::Create); mgr->register_creature_script(15538, &UnknownType::Create); mgr->register_creature_script(15250, &UnknownType::Create); mgr->register_creature_script(15252, &UnknownType::Create); mgr->register_creature_script(15246, &UnknownType::Create); mgr->register_creature_script(15276, &UnknownType::Create); mgr->register_creature_script(15275, &UnknownType::Create); mgr->register_creature_script(15695, &UnknownType::Create); mgr->register_creature_script(15957, &UnknownType::Create); mgr->register_creature_script(15517, &UnknownType::Create); mgr->register_creature_script(15712, &UnknownType::Create); mgr->register_creature_script(15718, &UnknownType::Create); mgr->register_creature_script(16604, &UnknownType::Create); mgr->register_creature_script(14309, &UnknownType::Create); mgr->register_creature_script(14310, &UnknownType::Create); mgr->register_creature_script(16697, &UnknownType::Create); mgr->register_creature_script(15311, &UnknownType::Create); mgr->register_creature_script(15312, &UnknownType::Create); mgr->register_creature_script(14311, &UnknownType::Create); mgr->register_creature_script(15904, &UnknownType::Create); mgr->register_creature_script(15725, &UnknownType::Create); mgr->register_creature_script(15726, &UnknownType::Create); mgr->register_creature_script(15728, &UnknownType::Create); mgr->register_creature_script(15910, &UnknownType::Create); mgr->register_creature_script(15334, &UnknownType::Create); mgr->register_creature_script(15800, &UnknownType::Create); mgr->register_creature_script(16286, &UnknownType::Create); mgr->register_creature_script(17698, &UnknownType::Create); mgr->register_creature_script(16980, &UnknownType::Create); mgr->register_creature_script(16129, &UnknownType::Create); mgr->register_creature_script(16474, &UnknownType::Create); mgr->register_creature_script(17025, &UnknownType::Create); mgr->register_creature_script(12434, &UnknownType::Create); mgr->register_creature_script(14307, &UnknownType::Create); mgr->register_creature_script(14312, &UnknownType::Create); mgr->register_creature_script(17090, &UnknownType::Create); mgr->register_creature_script(18225, &UnknownType::Create); mgr->register_creature_script(18283, &UnknownType::Create); mgr->register_creature_script(18275, &UnknownType::Create); mgr->register_creature_script(15468, &UnknownType::Create); mgr->register_creature_script(17047, &UnknownType::Create); mgr->register_creature_script(22003, &UnknownType::Create); mgr->register_creature_script(12999, &UnknownType::Create); mgr->register_creature_script(16857, &UnknownType::Create); mgr->register_creature_script(15242, &UnknownType::Create); mgr->register_creature_script(18729, &UnknownType::Create); mgr->register_creature_script(19656, &UnknownType::Create); mgr->register_creature_script(21429, &UnknownType::Create); mgr->register_creature_script(4133, &UnknownType::Create); mgr->register_creature_script(4468, &UnknownType::Create); mgr->register_creature_script(6033, &UnknownType::Create); mgr->register_creature_script(21096, &UnknownType::Create); mgr->register_creature_script(21807, &UnknownType::Create); mgr->register_creature_script(11326, &UnknownType::Create); mgr->register_creature_script(21380, &UnknownType::Create); mgr->register_creature_script(21030, &UnknownType::Create); mgr->register_creature_script(22146, &UnknownType::Create); mgr->register_creature_script(21443, &UnknownType::Create); mgr->register_creature_script(19387, &UnknownType::Create); mgr->register_creature_script(19677, &UnknownType::Create); mgr->register_creature_script(19381, &UnknownType::Create); mgr->register_creature_script(19388, &UnknownType::Create); mgr->register_creature_script(12256, &UnknownType::Create); mgr->register_creature_script(17364, &UnknownType::Create); mgr->register_creature_script(16922, &UnknownType::Create); mgr->register_creature_script(20239, &UnknownType::Create); mgr->register_creature_script(17947, &UnknownType::Create); mgr->register_creature_script(17362, &UnknownType::Create); mgr->register_creature_script(17363, &UnknownType::Create); mgr->register_creature_script(17274, &UnknownType::Create); mgr->register_creature_script(17361, &UnknownType::Create); mgr->register_creature_script(18173, &UnknownType::Create); mgr->register_creature_script(17680, &UnknownType::Create); mgr->register_creature_script(17889, &UnknownType::Create); mgr->register_creature_script(17979, &UnknownType::Create); mgr->register_creature_script(17850, &UnknownType::Create); mgr->register_creature_script(17529, &UnknownType::Create); mgr->register_creature_script(18896, &UnknownType::Create); mgr->register_creature_script(21403, &UnknownType::Create); mgr->register_creature_script(21417, &UnknownType::Create); mgr->register_creature_script(21348, &UnknownType::Create); mgr->register_creature_script(21080, &UnknownType::Create); mgr->register_creature_script(20431, &UnknownType::Create); mgr->register_creature_script(21953, &UnknownType::Create); mgr->register_creature_script(19504, &UnknownType::Create); mgr->register_creature_script(22066, &UnknownType::Create); mgr->register_creature_script(21954, &UnknownType::Create); mgr->register_creature_script(22071, &UnknownType::Create); mgr->register_creature_script(19521, &UnknownType::Create); mgr->register_creature_script(22134, &UnknownType::Create); mgr->register_creature_script(22230, &UnknownType::Create); mgr->register_creature_script(21924, &UnknownType::Create); mgr->register_creature_script(21909, &UnknownType::Create); mgr->register_creature_script(17407, &UnknownType::Create); mgr->register_creature_script(22080, &UnknownType::Create); mgr->register_creature_script(22078, &UnknownType::Create); mgr->register_creature_script(21986, &UnknownType::Create); mgr->register_creature_script(19526, &UnknownType::Create); mgr->register_creature_script(22079, &UnknownType::Create); mgr->register_creature_script(22214, &UnknownType::Create); mgr->register_creature_script(22077, &UnknownType::Create); mgr->register_creature_script(19530, &UnknownType::Create); mgr->register_creature_script(22070, &UnknownType::Create); mgr->register_creature_script(19518, &UnknownType::Create); mgr->register_creature_script(22211, &UnknownType::Create); mgr->register_creature_script(21955, &UnknownType::Create); mgr->register_creature_script(19520, &UnknownType::Create); mgr->register_creature_script(19517, &UnknownType::Create); mgr->register_creature_script(21095, &UnknownType::Create); mgr->register_creature_script(21071, &UnknownType::Create); mgr->register_creature_script(21094, &UnknownType::Create); mgr->register_creature_script(21092, &UnknownType::Create); mgr->register_creature_script(21052, &UnknownType::Create); mgr->register_creature_script(21310, &UnknownType::Create); mgr->register_creature_script(16898, &UnknownType::Create); mgr->register_creature_script(21655, &UnknownType::Create); mgr->register_creature_script(19412, &UnknownType::Create); mgr->register_creature_script(21211, &UnknownType::Create); mgr->register_creature_script(21840, &UnknownType::Create); mgr->register_creature_script(14645, &UnknownType::Create); mgr->register_creature_script(21892, &UnknownType::Create); mgr->register_creature_script(22228, &UnknownType::Create); mgr->register_creature_script(18759, &UnknownType::Create); mgr->register_creature_script(22039, &UnknownType::Create); mgr->register_creature_script(18000, &UnknownType::Create); mgr->register_creature_script(20197, &UnknownType::Create); mgr->register_creature_script(17998, &UnknownType::Create); mgr->register_creature_script(10218, &UnknownType::Create); mgr->register_creature_script(17999, &UnknownType::Create); mgr->register_creature_script(3928, &UnknownType::Create); mgr->register_creature_script(22040, &UnknownType::Create); mgr->register_creature_script(22116, &UnknownType::Create); mgr->register_creature_script(22801, &UnknownType::Create); mgr->register_creature_script(21393, &UnknownType::Create); mgr->register_creature_script(21942, &UnknownType::Create); mgr->register_creature_script(21447, &UnknownType::Create); mgr->register_creature_script(21877, &UnknownType::Create); mgr->register_creature_script(21876, &UnknownType::Create); mgr->register_creature_script(18650, &UnknownType::Create); mgr->register_creature_script(7093, &UnknownType::Create); mgr->register_creature_script(18143, &UnknownType::Create); mgr->register_creature_script(17474, &UnknownType::Create); mgr->register_creature_script(17689, &UnknownType::Create); mgr->register_creature_script(19620, &UnknownType::Create); mgr->register_creature_script(19619, &UnknownType::Create); mgr->register_creature_script(19618, &UnknownType::Create); mgr->register_creature_script(20417, &UnknownType::Create); mgr->register_creature_script(21210, &UnknownType::Create); mgr->register_creature_script(18142, &UnknownType::Create); mgr->register_creature_script(20296, &UnknownType::Create); mgr->register_creature_script(18110, &UnknownType::Create); mgr->register_creature_script(19159, &UnknownType::Create); mgr->register_creature_script(21120, &UnknownType::Create); mgr->register_creature_script(21119, &UnknownType::Create); mgr->register_creature_script(20982, &UnknownType::Create); mgr->register_creature_script(21157, &UnknownType::Create); mgr->register_creature_script(20475, &UnknownType::Create); mgr->register_creature_script(20476, &UnknownType::Create); mgr->register_creature_script(20473, &UnknownType::Create); mgr->register_creature_script(22351, &UnknownType::Create); mgr->register_creature_script(22350, &UnknownType::Create); mgr->register_creature_script(22348, &UnknownType::Create); mgr->register_creature_script(20804, &UnknownType::Create); mgr->register_creature_script(20920, &UnknownType::Create); mgr->register_creature_script(20608, &UnknownType::Create); mgr->register_creature_script(20335, &UnknownType::Create); mgr->register_creature_script(20554, &UnknownType::Create); mgr->register_creature_script(20564, &UnknownType::Create); mgr->register_creature_script(20899, &UnknownType::Create); mgr->register_creature_script(19565, &UnknownType::Create); mgr->register_creature_script(22502, &UnknownType::Create); mgr->register_creature_script(21930, &UnknownType::Create); mgr->register_creature_script(22046, &UnknownType::Create); mgr->register_creature_script(22799, &UnknownType::Create); mgr->register_creature_script(22800, &UnknownType::Create); mgr->register_creature_script(21851, &UnknownType::Create); mgr->register_creature_script(22798, &UnknownType::Create); mgr->register_creature_script(22447, &UnknownType::Create); mgr->register_creature_script(22368, &UnknownType::Create); mgr->register_creature_script(22356, &UnknownType::Create); mgr->register_creature_script(22367, &UnknownType::Create); mgr->register_creature_script(4196, &UnknownType::Create); mgr->register_creature_script(20085, &UnknownType::Create); mgr->register_creature_script(20209, &UnknownType::Create); mgr->register_creature_script(20806, &UnknownType::Create); mgr->register_creature_script(15164, &UnknownType::Create); mgr->register_creature_script(20553, &UnknownType::Create); mgr->register_creature_script(21265, &UnknownType::Create); mgr->register_creature_script(20852, &UnknownType::Create); mgr->register_creature_script(22436, &UnknownType::Create); mgr->register_creature_script(22182, &UnknownType::Create); mgr->register_creature_script(22282, &UnknownType::Create); mgr->register_creature_script(22320, &UnknownType::Create); mgr->register_creature_script(21467, &UnknownType::Create); mgr->register_creature_script(20912, &UnknownType::Create); mgr->register_creature_script(21466, &UnknownType::Create); mgr->register_creature_script(21440, &UnknownType::Create); mgr->register_creature_script(21437, &UnknownType::Create); mgr->register_creature_script(21439, &UnknownType::Create); mgr->register_creature_script(21438, &UnknownType::Create); mgr->register_creature_script(21436, &UnknownType::Create); mgr->register_creature_script(20155, &UnknownType::Create); mgr->register_creature_script(7086, &UnknownType::Create); mgr->register_creature_script(17992, &UnknownType::Create); mgr->register_creature_script(17990, &UnknownType::Create); mgr->register_creature_script(19632, &UnknownType::Create); mgr->register_creature_script(17732, &UnknownType::Create); mgr->register_creature_script(18185, &UnknownType::Create); mgr->register_creature_script(20198, &UnknownType::Create); mgr->register_creature_script(20337, &UnknownType::Create); mgr->register_creature_script(22288, &UnknownType::Create); mgr->register_creature_script(20391, &UnknownType::Create); mgr->register_creature_script(20807, &UnknownType::Create); mgr->register_creature_script(18766, &UnknownType::Create); mgr->register_creature_script(15631, &UnknownType::Create); mgr->register_creature_script(21861, &UnknownType::Create); mgr->register_creature_script(21394, &UnknownType::Create); mgr->register_creature_script(21381, &UnknownType::Create); mgr->register_creature_script(21025, &UnknownType::Create); mgr->register_creature_script(21051, &UnknownType::Create); mgr->register_creature_script(21946, &UnknownType::Create); mgr->register_creature_script(18161, &UnknownType::Create); mgr->register_creature_script(20755, &UnknownType::Create); mgr->register_creature_script(20764, &UnknownType::Create); mgr->register_creature_script(20778, &UnknownType::Create); mgr->register_creature_script(20769, &UnknownType::Create); mgr->register_creature_script(19687, &UnknownType::Create); mgr->register_creature_script(20331, &UnknownType::Create); mgr->register_creature_script(21432, &UnknownType::Create); mgr->register_creature_script(18525, &UnknownType::Create); mgr->register_creature_script(19318, &UnknownType::Create); mgr->register_creature_script(19337, &UnknownType::Create); mgr->register_creature_script(19153, &UnknownType::Create); mgr->register_creature_script(19321, &UnknownType::Create); mgr->register_creature_script(19590, &UnknownType::Create); mgr->register_creature_script(22008, &UnknownType::Create); mgr->register_creature_script(20156, &UnknownType::Create); mgr->register_creature_script(21322, &UnknownType::Create); mgr->register_creature_script(20418, &UnknownType::Create); mgr->register_creature_script(19924, &UnknownType::Create); mgr->register_creature_script(19916, &UnknownType::Create); mgr->register_creature_script(19870, &UnknownType::Create); mgr->register_creature_script(19842, &UnknownType::Create); mgr->register_creature_script(21264, &UnknownType::Create); mgr->register_creature_script(20440, &UnknownType::Create); mgr->register_creature_script(19555, &UnknownType::Create); mgr->register_creature_script(20061, &UnknownType::Create); mgr->register_creature_script(19346, &UnknownType::Create); mgr->register_creature_script(22089, &UnknownType::Create); mgr->register_creature_script(18506, &UnknownType::Create); mgr->register_creature_script(18374, &UnknownType::Create); mgr->register_creature_script(11152, &UnknownType::Create); mgr->register_creature_script(10905, &UnknownType::Create); mgr->register_creature_script(10904, &UnknownType::Create); mgr->register_creature_script(10903, &UnknownType::Create); mgr->register_creature_script(20805, &UnknownType::Create); mgr->register_creature_script(21286, &UnknownType::Create); mgr->register_creature_script(20782, &UnknownType::Create); mgr->register_creature_script(20520, &UnknownType::Create); mgr->register_creature_script(20825, &UnknownType::Create); mgr->register_creature_script(19034, &UnknownType::Create); mgr->register_creature_script(18596, &UnknownType::Create); mgr->register_creature_script(19198, &UnknownType::Create); mgr->register_creature_script(18412, &UnknownType::Create); mgr->register_creature_script(16595, &UnknownType::Create); mgr->register_creature_script(22519, &UnknownType::Create); mgr->register_creature_script(22520, &UnknownType::Create); mgr->register_creature_script(17316, &UnknownType::Create); mgr->register_creature_script(17317, &UnknownType::Create); mgr->register_creature_script(17208, &UnknownType::Create); mgr->register_creature_script(17305, &UnknownType::Create); mgr->register_creature_script(22523, &UnknownType::Create); mgr->register_creature_script(16596, &UnknownType::Create); mgr->register_creature_script(22524, &UnknownType::Create); mgr->register_creature_script(21921, &UnknownType::Create); mgr->register_creature_script(17459, &UnknownType::Create); mgr->register_creature_script(17174, &UnknownType::Create); mgr->register_creature_script(17171, &UnknownType::Create); mgr->register_creature_script(17175, &UnknownType::Create); mgr->register_creature_script(17096, &UnknownType::Create); mgr->register_creature_script(19781, &UnknownType::Create); mgr->register_creature_script(19782, &UnknownType::Create); mgr->register_creature_script(17161, &UnknownType::Create); mgr->register_creature_script(19783, &UnknownType::Create); mgr->register_creature_script(17176, &UnknownType::Create); mgr->register_creature_script(17168, &UnknownType::Create); mgr->register_creature_script(17169, &UnknownType::Create); mgr->register_creature_script(17172, &UnknownType::Create); mgr->register_creature_script(17170, &UnknownType::Create); mgr->register_creature_script(17173, &UnknownType::Create); mgr->register_creature_script(17283, &UnknownType::Create); mgr->register_creature_script(22521, &UnknownType::Create); mgr->register_creature_script(17644, &UnknownType::Create); mgr->register_creature_script(17650, &UnknownType::Create); mgr->register_creature_script(17265, &UnknownType::Create); mgr->register_creature_script(17248, &UnknownType::Create); mgr->register_creature_script(17368, &UnknownType::Create); mgr->register_creature_script(17367, &UnknownType::Create); mgr->register_creature_script(17369, &UnknownType::Create); mgr->register_creature_script(21933, &UnknownType::Create); mgr->register_creature_script(22057, &UnknownType::Create); mgr->register_creature_script(12207, &UnknownType::Create); mgr->register_creature_script(8611, &UnknownType::Create); mgr->register_creature_script(20338, &UnknownType::Create); mgr->register_creature_script(20226, &UnknownType::Create); mgr->register_creature_script(15918, &UnknownType::Create); mgr->register_creature_script(15879, &UnknownType::Create); mgr->register_creature_script(15872, &UnknownType::Create); mgr->register_creature_script(14465, &UnknownType::Create); mgr->register_creature_script(22139, &UnknownType::Create); mgr->register_creature_script(22137, &UnknownType::Create); mgr->register_creature_script(21335, &UnknownType::Create); mgr->register_creature_script(20670, &UnknownType::Create); mgr->register_creature_script(20853, &UnknownType::Create); mgr->register_creature_script(20668, &UnknownType::Create); mgr->register_creature_script(20771, &UnknownType::Create); mgr->register_creature_script(20855, &UnknownType::Create); mgr->register_creature_script(20635, &UnknownType::Create); mgr->register_creature_script(20845, &UnknownType::Create); mgr->register_creature_script(20666, &UnknownType::Create); mgr->register_creature_script(20856, &UnknownType::Create); mgr->register_creature_script(21053, &UnknownType::Create); mgr->register_creature_script(20933, &UnknownType::Create); mgr->register_creature_script(20153, &UnknownType::Create); mgr->register_creature_script(20451, &UnknownType::Create); mgr->register_creature_script(19336, &UnknownType::Create); mgr->register_creature_script(20501, &UnknownType::Create); mgr->register_creature_script(20676, &UnknownType::Create); mgr->register_creature_script(20858, &UnknownType::Create); mgr->register_creature_script(20619, &UnknownType::Create); mgr->register_creature_script(20482, &UnknownType::Create); mgr->register_creature_script(20340, &UnknownType::Create); mgr->register_creature_script(21940, &UnknownType::Create); mgr->register_creature_script(21939, &UnknownType::Create); mgr->register_creature_script(21654, &UnknownType::Create); mgr->register_creature_script(21793, &UnknownType::Create); mgr->register_creature_script(21792, &UnknownType::Create); mgr->register_creature_script(21794, &UnknownType::Create); mgr->register_creature_script(21791, &UnknownType::Create); mgr->register_creature_script(20405, &UnknownType::Create); mgr->register_creature_script(22096, &UnknownType::Create); mgr->register_creature_script(22058, &UnknownType::Create); mgr->register_creature_script(22121, &UnknownType::Create); mgr->register_creature_script(21422, &UnknownType::Create); mgr->register_creature_script(21413, &UnknownType::Create); mgr->register_creature_script(21819, &UnknownType::Create); mgr->register_creature_script(11731, &UnknownType::Create); mgr->register_creature_script(11730, &UnknownType::Create); mgr->register_creature_script(11732, &UnknownType::Create); mgr->register_creature_script(11733, &UnknownType::Create); mgr->register_creature_script(11698, &UnknownType::Create); mgr->register_creature_script(17074, &UnknownType::Create); mgr->register_creature_script(11724, &UnknownType::Create); mgr->register_creature_script(11723, &UnknownType::Create); mgr->register_creature_script(11722, &UnknownType::Create); mgr->register_creature_script(11721, &UnknownType::Create); mgr->register_creature_script(18199, &UnknownType::Create); mgr->register_creature_script(11734, &UnknownType::Create); mgr->register_creature_script(19723, &UnknownType::Create); mgr->register_creature_script(19724, &UnknownType::Create); mgr->register_creature_script(19867, &UnknownType::Create); mgr->register_creature_script(19547, &UnknownType::Create); mgr->register_creature_script(19868, &UnknownType::Create); mgr->register_creature_script(19839, &UnknownType::Create); mgr->register_creature_script(19840, &UnknownType::Create); mgr->register_creature_script(21290, &UnknownType::Create); mgr->register_creature_script(19549, &UnknownType::Create); mgr->register_creature_script(19548, &UnknownType::Create); mgr->register_creature_script(19550, &UnknownType::Create); mgr->register_creature_script(19866, &UnknownType::Create); mgr->register_creature_script(19041, &UnknownType::Create); mgr->register_creature_script(19652, &UnknownType::Create); mgr->register_creature_script(19278, &UnknownType::Create); mgr->register_creature_script(19838, &UnknownType::Create); mgr->register_creature_script(19279, &UnknownType::Create); mgr->register_creature_script(19359, &UnknownType::Create); mgr->register_creature_script(19292, &UnknownType::Create); mgr->register_creature_script(21365, &UnknownType::Create); mgr->register_creature_script(18849, &UnknownType::Create); mgr->register_creature_script(18828, &UnknownType::Create); mgr->register_creature_script(21391, &UnknownType::Create); mgr->register_creature_script(22177, &UnknownType::Create); mgr->register_creature_script(21182, &UnknownType::Create); mgr->register_creature_script(20816, &UnknownType::Create); mgr->register_creature_script(19440, &UnknownType::Create); mgr->register_creature_script(20814, &UnknownType::Create); mgr->register_creature_script(22467, &UnknownType::Create); mgr->register_creature_script(19393, &UnknownType::Create); mgr->register_creature_script(22224, &UnknownType::Create); mgr->register_creature_script(19681, &UnknownType::Create); mgr->register_creature_script(19376, &UnknownType::Create); mgr->register_creature_script(20143, &UnknownType::Create); mgr->register_creature_script(22401, &UnknownType::Create); mgr->register_creature_script(21173, &UnknownType::Create); mgr->register_creature_script(22402, &UnknownType::Create); mgr->register_creature_script(18678, &UnknownType::Create); mgr->register_creature_script(20781, &UnknownType::Create); mgr->register_creature_script(22258, &UnknownType::Create); mgr->register_creature_script(22260, &UnknownType::Create); mgr->register_creature_script(22259, &UnknownType::Create); mgr->register_creature_script(22267, &UnknownType::Create); mgr->register_creature_script(22273, &UnknownType::Create); mgr->register_creature_script(20813, &UnknownType::Create); mgr->register_creature_script(20229, &UnknownType::Create); mgr->register_creature_script(20815, &UnknownType::Create); mgr->register_creature_script(15705, &UnknownType::Create); mgr->register_creature_script(22403, &UnknownType::Create); mgr->register_creature_script(22087, &UnknownType::Create); mgr->register_creature_script(22088, &UnknownType::Create); mgr->register_creature_script(22086, &UnknownType::Create); mgr->register_creature_script(14834, &UnknownType::Create); mgr->register_creature_script(14758, &UnknownType::Create); mgr->register_creature_script(14989, &UnknownType::Create); mgr->register_creature_script(16006, &UnknownType::Create); mgr->register_creature_script(17662, &UnknownType::Create); mgr->register_creature_script(18002, &UnknownType::Create); mgr->register_creature_script(3638, &UnknownType::Create); mgr->register_creature_script(3640, &UnknownType::Create); mgr->register_creature_script(5763, &UnknownType::Create); mgr->register_creature_script(5914, &UnknownType::Create); mgr->register_creature_script(3721, &UnknownType::Create); mgr->register_creature_script(4829, &UnknownType::Create); mgr->register_creature_script(5780, &UnknownType::Create); mgr->register_creature_script(3295, &UnknownType::Create); mgr->register_creature_script(17538, &UnknownType::Create); mgr->register_creature_script(18955, &UnknownType::Create); mgr->register_creature_script(18814, &UnknownType::Create); mgr->register_creature_script(17360, &UnknownType::Create); mgr->register_creature_script(17437, &UnknownType::Create); mgr->register_creature_script(17438, &UnknownType::Create); mgr->register_creature_script(5781, &UnknownType::Create); mgr->register_creature_script(3253, &UnknownType::Create); mgr->register_creature_script(3844, &UnknownType::Create); mgr->register_creature_script(4020, &UnknownType::Create); mgr->register_creature_script(4021, &UnknownType::Create); mgr->register_creature_script(4059, &UnknownType::Create); mgr->register_creature_script(12940, &UnknownType::Create); mgr->register_creature_script(3722, &UnknownType::Create); mgr->register_creature_script(4131, &UnknownType::Create); mgr->register_creature_script(4132, &UnknownType::Create); mgr->register_creature_script(20479, &UnknownType::Create); mgr->register_creature_script(22419, &UnknownType::Create); mgr->register_creature_script(21451, &UnknownType::Create); mgr->register_creature_script(21489, &UnknownType::Create); mgr->register_creature_script(21463, &UnknownType::Create); mgr->register_creature_script(18843, &UnknownType::Create); mgr->register_creature_script(22340, &UnknownType::Create); mgr->register_creature_script(22453, &UnknownType::Create); mgr->register_creature_script(21859, &UnknownType::Create); mgr->register_creature_script(21846, &UnknownType::Create); mgr->register_creature_script(22449, &UnknownType::Create); mgr->register_creature_script(22462, &UnknownType::Create); mgr->register_creature_script(22463, &UnknownType::Create); mgr->register_creature_script(22355, &UnknownType::Create); mgr->register_creature_script(22371, &UnknownType::Create); mgr->register_creature_script(22466, &UnknownType::Create); mgr->register_creature_script(22482, &UnknownType::Create); mgr->register_creature_script(21967, &UnknownType::Create); mgr->register_creature_script(21445, &UnknownType::Create); mgr->register_creature_script(21632, &UnknownType::Create); mgr->register_creature_script(21424, &UnknownType::Create); mgr->register_creature_script(22038, &UnknownType::Create); mgr->register_creature_script(18305, &UnknownType::Create); mgr->register_creature_script(18307, &UnknownType::Create); mgr->register_creature_script(18306, &UnknownType::Create); mgr->register_creature_script(18388, &UnknownType::Create); mgr->register_creature_script(18308, &UnknownType::Create); mgr->register_creature_script(19480, &UnknownType::Create); mgr->register_creature_script(18590, &UnknownType::Create); mgr->register_creature_script(18444, &UnknownType::Create); mgr->register_creature_script(18196, &UnknownType::Create); mgr->register_creature_script(18662, &UnknownType::Create); mgr->register_creature_script(17545, &UnknownType::Create); mgr->register_creature_script(18914, &UnknownType::Create); mgr->register_creature_script(18354, &UnknownType::Create); mgr->register_creature_script(21074, &UnknownType::Create); mgr->register_creature_script(20230, &UnknownType::Create); mgr->register_creature_script(17253, &UnknownType::Create); mgr->register_creature_script(14026, &UnknownType::Create); mgr->register_creature_script(14030, &UnknownType::Create); mgr->register_creature_script(14031, &UnknownType::Create); mgr->register_creature_script(14029, &UnknownType::Create); mgr->register_creature_script(4785, &UnknownType::Create); mgr->register_creature_script(15222, &UnknownType::Create); mgr->register_creature_script(15221, &UnknownType::Create); mgr->register_creature_script(22507, &UnknownType::Create); mgr->register_creature_script(22505, &UnknownType::Create); mgr->register_creature_script(22506, &UnknownType::Create); mgr->register_creature_script(22508, &UnknownType::Create); mgr->register_creature_script(14862, &UnknownType::Create); mgr->register_creature_script(11727, &UnknownType::Create); mgr->register_creature_script(8179, &UnknownType::Create); mgr->register_creature_script(8130, &UnknownType::Create); mgr->register_creature_script(8138, &UnknownType::Create); mgr->register_creature_script(8156, &UnknownType::Create); mgr->register_creature_script(6559, &UnknownType::Create); mgr->register_creature_script(6557, &UnknownType::Create); mgr->register_creature_script(6553, &UnknownType::Create); mgr->register_creature_script(6551, &UnknownType::Create); mgr->register_creature_script(6552, &UnknownType::Create); mgr->register_creature_script(5455, &UnknownType::Create); mgr->register_creature_script(5457, &UnknownType::Create); mgr->register_creature_script(5459, &UnknownType::Create); mgr->register_creature_script(5458, &UnknownType::Create); mgr->register_creature_script(5456, &UnknownType::Create); mgr->register_creature_script(5460, &UnknownType::Create); mgr->register_creature_script(4374, &UnknownType::Create); mgr->register_creature_script(14366, &UnknownType::Create); mgr->register_creature_script(14122, &UnknownType::Create); mgr->register_creature_script(17883, &UnknownType::Create); mgr->register_creature_script(19297, &UnknownType::Create); mgr->register_creature_script(17974, &UnknownType::Create); mgr->register_creature_script(17988, &UnknownType::Create); mgr->register_creature_script(1033, &UnknownType::Create); mgr->register_creature_script(1031, &UnknownType::Create); mgr->register_creature_script(17696, &UnknownType::Create); mgr->register_creature_script(12255, &UnknownType::Create); mgr->register_creature_script(12254, &UnknownType::Create); mgr->register_creature_script(12249, &UnknownType::Create); mgr->register_creature_script(12244, &UnknownType::Create); mgr->register_creature_script(12253, &UnknownType::Create); mgr->register_creature_script(19328, &UnknownType::Create); mgr->register_creature_script(19329, &UnknownType::Create); mgr->register_creature_script(17413, &UnknownType::Create); mgr->register_creature_script(20251, &UnknownType::Create); mgr->register_creature_script(19326, &UnknownType::Create); mgr->register_creature_script(21134, &UnknownType::Create); mgr->register_creature_script(3616, &UnknownType::Create); mgr->register_creature_script(19848, &UnknownType::Create); mgr->register_creature_script(14433, &UnknownType::Create); mgr->register_creature_script(14505, &UnknownType::Create); mgr->register_creature_script(14565, &UnknownType::Create); mgr->register_creature_script(358, &UnknownType::Create); mgr->register_creature_script(758, &UnknownType::Create); mgr->register_creature_script(8999, &UnknownType::Create); mgr->register_creature_script(11111, &UnknownType::Create); mgr->register_creature_script(18392, &UnknownType::Create); mgr->register_creature_script(14021, &UnknownType::Create); mgr->register_creature_script(14329, &UnknownType::Create); mgr->register_creature_script(14330, &UnknownType::Create); mgr->register_creature_script(14331, &UnknownType::Create); mgr->register_creature_script(14332, &UnknownType::Create); mgr->register_creature_script(14333, &UnknownType::Create); mgr->register_creature_script(14334, &UnknownType::Create); mgr->register_creature_script(14335, &UnknownType::Create); mgr->register_creature_script(14336, &UnknownType::Create); mgr->register_creature_script(14557, &UnknownType::Create); mgr->register_creature_script(14662, &UnknownType::Create); mgr->register_creature_script(14663, &UnknownType::Create); mgr->register_creature_script(14664, &UnknownType::Create); mgr->register_creature_script(14666, &UnknownType::Create); mgr->register_creature_script(14667, &UnknownType::Create); mgr->register_creature_script(14744, &UnknownType::Create); mgr->register_creature_script(14745, &UnknownType::Create); mgr->register_creature_script(15943, &UnknownType::Create); mgr->register_creature_script(16045, &UnknownType::Create); mgr->register_creature_script(16531, &UnknownType::Create); mgr->register_creature_script(19647, &UnknownType::Create); mgr->register_creature_script(21289, &UnknownType::Create); mgr->register_creature_script(21090, &UnknownType::Create); mgr->register_creature_script(20603, &UnknownType::Create); mgr->register_creature_script(20518, &UnknownType::Create); mgr->register_creature_script(17473, &UnknownType::Create); mgr->register_creature_script(17266, &UnknownType::Create); mgr->register_creature_script(17234, &UnknownType::Create); mgr->register_creature_script(20114, &UnknownType::Create); mgr->register_creature_script(20086, &UnknownType::Create); mgr->register_creature_script(19703, &UnknownType::Create); mgr->register_creature_script(18545, &UnknownType::Create); mgr->register_creature_script(18076, &UnknownType::Create); mgr->register_creature_script(18075, &UnknownType::Create); mgr->register_creature_script(17532, &UnknownType::Create); mgr->register_creature_script(17500, &UnknownType::Create); mgr->register_creature_script(17001, &UnknownType::Create); mgr->register_creature_script(16914, &UnknownType::Create); mgr->register_creature_script(22009, &UnknownType::Create); mgr->register_creature_script(22014, &UnknownType::Create); mgr->register_creature_script(15090, &UnknownType::Create); mgr->register_creature_script(22918, &UnknownType::Create); mgr->register_creature_script(22366, &UnknownType::Create); mgr->register_creature_script(22335, &UnknownType::Create); mgr->register_creature_script(22210, &UnknownType::Create); mgr->register_creature_script(22207, &UnknownType::Create); mgr->register_creature_script(22104, &UnknownType::Create); mgr->register_creature_script(21987, &UnknownType::Create); mgr->register_creature_script(21934, &UnknownType::Create); mgr->register_creature_script(17499, &UnknownType::Create); mgr->register_creature_script(21252, &UnknownType::Create); mgr->register_creature_script(18242, &UnknownType::Create); mgr->register_creature_script(19577, &UnknownType::Create); mgr->register_creature_script(19551, &UnknownType::Create); mgr->register_creature_script(18932, &UnknownType::Create); mgr->register_creature_script(18928, &UnknownType::Create); mgr->register_creature_script(18665, &UnknownType::Create); mgr->register_creature_script(17677, &UnknownType::Create); mgr->register_creature_script(17516, &UnknownType::Create); mgr->register_creature_script(17458, &UnknownType::Create); mgr->register_creature_script(17376, &UnknownType::Create); mgr->register_creature_script(17302, &UnknownType::Create); mgr->register_creature_script(17126, &UnknownType::Create); mgr->register_creature_script(17125, &UnknownType::Create); mgr->register_creature_script(17124, &UnknownType::Create); mgr->register_creature_script(16511, &UnknownType::Create); mgr->register_creature_script(16421, &UnknownType::Create); mgr->register_creature_script(16356, &UnknownType::Create); mgr->register_creature_script(16172, &UnknownType::Create); mgr->register_creature_script(16166, &UnknownType::Create); mgr->register_creature_script(16136, &UnknownType::Create); mgr->register_creature_script(16100, &UnknownType::Create); mgr->register_creature_script(15934, &UnknownType::Create); mgr->register_creature_script(15925, &UnknownType::Create); mgr->register_creature_script(15914, &UnknownType::Create); mgr->register_creature_script(15912, &UnknownType::Create); mgr->register_creature_script(15911, &UnknownType::Create); mgr->register_creature_script(15888, &UnknownType::Create); mgr->register_creature_script(15886, &UnknownType::Create); mgr->register_creature_script(15885, &UnknownType::Create); mgr->register_creature_script(15884, &UnknownType::Create); mgr->register_creature_script(15880, &UnknownType::Create); mgr->register_creature_script(15878, &UnknownType::Create); mgr->register_creature_script(15874, &UnknownType::Create); mgr->register_creature_script(15873, &UnknownType::Create); mgr->register_creature_script(15817, &UnknownType::Create); mgr->register_creature_script(15816, &UnknownType::Create); mgr->register_creature_script(15815, &UnknownType::Create); mgr->register_creature_script(15814, &UnknownType::Create); mgr->register_creature_script(15813, &UnknownType::Create); mgr->register_creature_script(15812, &UnknownType::Create); mgr->register_creature_script(15811, &UnknownType::Create); mgr->register_creature_script(15810, &UnknownType::Create); mgr->register_creature_script(15808, &UnknownType::Create); mgr->register_creature_script(15807, &UnknownType::Create); mgr->register_creature_script(15806, &UnknownType::Create); mgr->register_creature_script(15805, &UnknownType::Create); mgr->register_creature_script(15804, &UnknownType::Create); mgr->register_creature_script(15771, &UnknownType::Create); mgr->register_creature_script(15770, &UnknownType::Create); mgr->register_creature_script(15769, &UnknownType::Create); mgr->register_creature_script(15759, &UnknownType::Create); mgr->register_creature_script(15758, &UnknownType::Create); mgr->register_creature_script(15757, &UnknownType::Create); mgr->register_creature_script(15756, &UnknownType::Create); mgr->register_creature_script(15754, &UnknownType::Create); mgr->register_creature_script(15753, &UnknownType::Create); mgr->register_creature_script(15752, &UnknownType::Create); mgr->register_creature_script(15751, &UnknownType::Create); mgr->register_creature_script(15750, &UnknownType::Create); mgr->register_creature_script(15749, &UnknownType::Create); mgr->register_creature_script(15748, &UnknownType::Create); mgr->register_creature_script(15747, &UnknownType::Create); mgr->register_creature_script(15629, &UnknownType::Create); mgr->register_creature_script(15590, &UnknownType::Create); mgr->register_creature_script(15553, &UnknownType::Create); mgr->register_creature_script(15514, &UnknownType::Create); mgr->register_creature_script(15424, &UnknownType::Create); mgr->register_creature_script(15422, &UnknownType::Create); mgr->register_creature_script(15421, &UnknownType::Create); mgr->register_creature_script(15414, &UnknownType::Create); mgr->register_creature_script(13148, &UnknownType::Create); mgr->register_creature_script(23033, &UnknownType::Create); mgr->register_creature_script(18528, &UnknownType::Create); mgr->register_creature_script(22974, &UnknownType::Create); mgr->register_creature_script(22934, &UnknownType::Create); mgr->register_creature_script(22862, &UnknownType::Create); mgr->register_creature_script(22849, &UnknownType::Create); mgr->register_creature_script(22517, &UnknownType::Create); mgr->register_creature_script(22515, &UnknownType::Create); mgr->register_creature_script(23496, &UnknownType::Create); mgr->register_creature_script(23409, &UnknownType::Create); mgr->register_creature_script(23273, &UnknownType::Create); mgr->register_creature_script(23270, &UnknownType::Create); mgr->register_creature_script(23272, &UnknownType::Create); mgr->register_creature_script(23271, &UnknownType::Create); mgr->register_creature_script(18768, &UnknownType::Create); mgr->register_creature_script(18410, &UnknownType::Create); mgr->register_creature_script(22872, &UnknownType::Create); mgr->register_creature_script(38, &HumanoidUnarmed::Create); mgr->register_creature_script(68, &HumanoidWarrior::Create); mgr->register_creature_script(125, &HumanoidPriest::Create); mgr->register_creature_script(197, &HumanoidWarrior::Create); mgr->register_creature_script(203, &HumanoidMage::Create); mgr->register_creature_script(261, &HumanoidWarrior::Create); mgr->register_creature_script(263, &HumanoidFuryWarrior::Create); mgr->register_creature_script(331, &HumanoidMage::Create); mgr->register_creature_script(392, &HumanoidWarrior::Create); mgr->register_creature_script(426, &HumanoidUnarmed::Create); mgr->register_creature_script(429, &HumanoidWarlock::Create); mgr->register_creature_script(431, &HumanoidFuryWarrior::Create); mgr->register_creature_script(436, &HumanoidShadowPriest::Create); mgr->register_creature_script(450, &HumanoidMage::Create); mgr->register_creature_script(452, &HumanoidRogue::Create); mgr->register_creature_script(453, &HumanoidPriest::Create); mgr->register_creature_script(456, &HumanoidPriest::Create); mgr->register_creature_script(464, &HumanoidWarrior::Create); mgr->register_creature_script(476, &HumanoidShaman::Create); mgr->register_creature_script(481, &HumanoidRogue::Create); mgr->register_creature_script(503, &HumanoidFuryWarrior::Create); mgr->register_creature_script(515, &HumanoidFuryWarrior::Create); mgr->register_creature_script(583, &HumanoidRogue::Create); mgr->register_creature_script(588, &HumanoidWarrior::Create); mgr->register_creature_script(597, &HumanoidFuryWarrior::Create); mgr->register_creature_script(636, &HumanoidWarrior::Create); mgr->register_creature_script(660, &HumanoidWitchDoctor::Create); mgr->register_creature_script(669, &HumanoidHunter::Create); mgr->register_creature_script(670, &HumanoidWitchDoctor::Create); mgr->register_creature_script(671, &HumanoidHunter::Create); mgr->register_creature_script(672, &HumanoidWitchDoctor::Create); mgr->register_creature_script(678, &HumanoidUnarmed::Create); mgr->register_creature_script(679, &HumanoidShaman::Create); mgr->register_creature_script(680, &HumanoidFuryWarrior::Create); mgr->register_creature_script(697, &HumanoidShaman::Create); mgr->register_creature_script(709, &HumanoidFuryWarrior::Create); mgr->register_creature_script(710, &HumanoidMage::Create); mgr->register_creature_script(723, &HumanoidFuryWarrior::Create); mgr->register_creature_script(752, &HumanoidHolyPriest::Create); mgr->register_creature_script(759, &HumanoidHunter::Create); mgr->register_creature_script(761, &HumanoidPriest::Create); mgr->register_creature_script(780, &HumanoidPriest::Create); mgr->register_creature_script(781, &HumanoidHunter::Create); mgr->register_creature_script(782, &HumanoidWarrior::Create); mgr->register_creature_script(783, &HumanoidFuryWarrior::Create); mgr->register_creature_script(787, &HumanoidPriest::Create); mgr->register_creature_script(820, &HumanoidWarrior::Create); mgr->register_creature_script(821, &HumanoidWarrior::Create); mgr->register_creature_script(859, &HumanoidWarrior::Create); mgr->register_creature_script(871, &HumanoidWarrior::Create); mgr->register_creature_script(873, &HumanoidPriest::Create); mgr->register_creature_script(875, &HumanoidFuryWarrior::Create); mgr->register_creature_script(878, &HumanoidWarrior::Create); mgr->register_creature_script(879, &HumanoidHunter::Create); mgr->register_creature_script(903, &HumanoidWarrior::Create); mgr->register_creature_script(940, &HumanoidPriest::Create); mgr->register_creature_script(941, &HumanoidWitchDoctor::Create); mgr->register_creature_script(942, &HumanoidWitchDoctor::Create); mgr->register_creature_script(979, &HumanoidShadowHunter::Create); mgr->register_creature_script(1012, &HumanoidUnarmed::Create); mgr->register_creature_script(1050, &HumanoidWarrior::Create); mgr->register_creature_script(1060, &HumanoidPriest::Create); mgr->register_creature_script(1062, &HumanoidPriest::Create); mgr->register_creature_script(1065, &HumanoidShaman::Create); mgr->register_creature_script(1081, &HumanoidFuryWarrior::Create); mgr->register_creature_script(1092, &HumanoidWarrior::Create); mgr->register_creature_script(1124, &HumanoidShadowPriest::Create); mgr->register_creature_script(1142, &HumanoidUnarmed::Create); mgr->register_creature_script(1144, &HumanoidWitchDoctor::Create); mgr->register_creature_script(1165, &HumanoidShaman::Create); mgr->register_creature_script(1174, &HumanoidShaman::Create); mgr->register_creature_script(1181, &HumanoidShaman::Create); mgr->register_creature_script(1197, &HumanoidShaman::Create); mgr->register_creature_script(1399, &HumanoidShaman::Create); mgr->register_creature_script(1439, &HumanoidFuryWarrior::Create); mgr->register_creature_script(1449, &HumanoidWitchDoctor::Create); mgr->register_creature_script(1481, &HumanoidWarrior::Create); mgr->register_creature_script(1489, &HumanoidHunter::Create); mgr->register_creature_script(1490, &HumanoidWitchDoctor::Create); mgr->register_creature_script(1495, &HumanoidWarrior::Create); mgr->register_creature_script(1496, &HumanoidWarrior::Create); mgr->register_creature_script(1519, &HumanoidWarrior::Create); mgr->register_creature_script(1561, &HumanoidFuryWarrior::Create); mgr->register_creature_script(1562, &HumanoidMage::Create); mgr->register_creature_script(1564, &HumanoidWarlock::Create); mgr->register_creature_script(1569, &HumanoidShadowPriest::Create); mgr->register_creature_script(1652, &HumanoidWarrior::Create); mgr->register_creature_script(1658, &HumanoidWarrior::Create); mgr->register_creature_script(1662, &HumanoidWarrior::Create); mgr->register_creature_script(1718, &HumanoidFuryWarrior::Create); mgr->register_creature_script(1740, &HumanoidWarrior::Create); mgr->register_creature_script(1746, &HumanoidWarrior::Create); mgr->register_creature_script(1784, &HumanoidMage::Create); mgr->register_creature_script(1788, &HumanoidFuryWarrior::Create); mgr->register_creature_script(1826, &HumanoidMage::Create); mgr->register_creature_script(1831, &HumanoidHunter::Create); mgr->register_creature_script(1832, &HumanoidMage::Create); mgr->register_creature_script(1835, &HumanoidMage::Create); mgr->register_creature_script(1842, &HumanoidFuryWarrior::Create); mgr->register_creature_script(1848, &HumanoidFuryWarrior::Create); mgr->register_creature_script(1852, &HumanoidWarlock::Create); mgr->register_creature_script(1867, &HumanoidMage::Create); mgr->register_creature_script(1871, &HumanoidWarrior::Create); mgr->register_creature_script(1889, &HumanoidMage::Create); mgr->register_creature_script(1897, &HumanoidShadowPriest::Create); mgr->register_creature_script(1908, &HumanoidPriest::Create); mgr->register_creature_script(1909, &HumanoidRogue::Create); mgr->register_creature_script(1914, &HumanoidMage::Create); mgr->register_creature_script(1915, &HumanoidWarlock::Create); mgr->register_creature_script(1920, &HumanoidMage::Create); mgr->register_creature_script(1950, &HumanoidRogue::Create); mgr->register_creature_script(1973, &HumanoidWarrior::Create); mgr->register_creature_script(1978, &HumanoidRogue::Create); mgr->register_creature_script(1981, &HumanoidRogue::Create); mgr->register_creature_script(1997, &HumanoidHunter::Create); mgr->register_creature_script(2008, &HumanoidWarrior::Create); mgr->register_creature_script(2009, &HumanoidShaman::Create); mgr->register_creature_script(2014, &HumanoidShaman::Create); mgr->register_creature_script(2017, &HumanoidRogue::Create); mgr->register_creature_script(2058, &HumanoidRogue::Create); mgr->register_creature_script(2068, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2090, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2104, &HumanoidWarrior::Create); mgr->register_creature_script(2121, &HumanoidShadowPriest::Create); mgr->register_creature_script(2149, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2151, &HumanoidPriest::Create); mgr->register_creature_script(2152, &HumanoidRogue::Create); mgr->register_creature_script(2158, &HumanoidWarrior::Create); mgr->register_creature_script(2160, &HumanoidShaman::Create); mgr->register_creature_script(2169, &HumanoidShaman::Create); mgr->register_creature_script(2171, &HumanoidShaman::Create); mgr->register_creature_script(2183, &HumanoidWarrior::Create); mgr->register_creature_script(2201, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2208, &HumanoidHunter::Create); mgr->register_creature_script(2209, &HumanoidWarrior::Create); mgr->register_creature_script(2210, &HumanoidWarrior::Create); mgr->register_creature_script(2214, &HumanoidRogue::Create); mgr->register_creature_script(2240, &HumanoidRogue::Create); mgr->register_creature_script(2241, &HumanoidRogue::Create); mgr->register_creature_script(2244, &HumanoidShadowPriest::Create); mgr->register_creature_script(2246, &HumanoidRogue::Create); mgr->register_creature_script(2247, &HumanoidWarrior::Create); mgr->register_creature_script(2253, &HumanoidUnarmed::Create); mgr->register_creature_script(2255, &HumanoidMage::Create); mgr->register_creature_script(2260, &HumanoidRogue::Create); mgr->register_creature_script(2271, &HumanoidWarrior::Create); mgr->register_creature_script(2272, &HumanoidMage::Create); mgr->register_creature_script(2304, &HumanoidWarrior::Create); mgr->register_creature_script(2318, &HumanoidShadowPriest::Create); mgr->register_creature_script(2319, &HumanoidMage::Create); mgr->register_creature_script(2333, &HumanoidUnarmed::Create); mgr->register_creature_script(2346, &HumanoidPriest::Create); mgr->register_creature_script(2358, &HumanoidWarlock::Create); mgr->register_creature_script(2365, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2373, &HumanoidShaman::Create); mgr->register_creature_script(2376, &HumanoidPriest::Create); mgr->register_creature_script(2377, &HumanoidHunter::Create); mgr->register_creature_script(2410, &HumanoidMage::Create); mgr->register_creature_script(2418, &HumanoidWarrior::Create); mgr->register_creature_script(2419, &HumanoidWarrior::Create); mgr->register_creature_script(2423, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2434, &HumanoidRogue::Create); mgr->register_creature_script(2439, &HumanoidWarrior::Create); mgr->register_creature_script(2440, &HumanoidRogue::Create); mgr->register_creature_script(2465, &HumanoidPriest::Create); mgr->register_creature_script(2486, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2487, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2488, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2490, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2491, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2493, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2500, &HumanoidWarrior::Create); mgr->register_creature_script(2541, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2542, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2553, &HumanoidShadowPriest::Create); mgr->register_creature_script(2555, &HumanoidWitchDoctor::Create); mgr->register_creature_script(2556, &HumanoidHunter::Create); mgr->register_creature_script(2570, &HumanoidShaman::Create); mgr->register_creature_script(2577, &HumanoidShadowPriest::Create); mgr->register_creature_script(2583, &HumanoidHunter::Create); mgr->register_creature_script(2585, &HumanoidWarrior::Create); mgr->register_creature_script(2586, &HumanoidRogue::Create); mgr->register_creature_script(2587, &HumanoidRogue::Create); mgr->register_creature_script(2590, &HumanoidWarlock::Create); mgr->register_creature_script(2595, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2596, &HumanoidMage::Create); mgr->register_creature_script(2597, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2598, &HumanoidWarlock::Create); mgr->register_creature_script(2599, &HumanoidWarrior::Create); mgr->register_creature_script(2606, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2609, &HumanoidShaman::Create); mgr->register_creature_script(2610, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2640, &HumanoidWitchDoctor::Create); mgr->register_creature_script(2641, &HumanoidHunter::Create); mgr->register_creature_script(2642, &HumanoidShadowPriest::Create); mgr->register_creature_script(2643, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2645, &HumanoidShadowHunter::Create); mgr->register_creature_script(2646, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2647, &HumanoidWarlock::Create); mgr->register_creature_script(2648, &HumanoidWarrior::Create); mgr->register_creature_script(2649, &HumanoidRogue::Create); mgr->register_creature_script(2659, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2663, &HumanoidRogue::Create); mgr->register_creature_script(2686, &HumanoidWarrior::Create); mgr->register_creature_script(2692, &HumanoidWarrior::Create); mgr->register_creature_script(2700, &HumanoidWarrior::Create); mgr->register_creature_script(2715, &HumanoidUnarmed::Create); mgr->register_creature_script(2716, &HumanoidHunter::Create); mgr->register_creature_script(2717, &HumanoidUnarmed::Create); mgr->register_creature_script(2718, &HumanoidShaman::Create); mgr->register_creature_script(2719, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2720, &HumanoidMage::Create); mgr->register_creature_script(2726, &HumanoidWarrior::Create); mgr->register_creature_script(2740, &HumanoidWarlock::Create); mgr->register_creature_script(2743, &HumanoidWarrior::Create); mgr->register_creature_script(2752, &HumanoidUnarmed::Create); mgr->register_creature_script(2766, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2767, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2768, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2769, &HumanoidWarrior::Create); mgr->register_creature_script(2774, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2778, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2783, &HumanoidWarlock::Create); mgr->register_creature_script(2794, &HumanoidWarrior::Create); mgr->register_creature_script(2814, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2818, &HumanoidFuryWarrior::Create); mgr->register_creature_script(2852, &HumanoidDruid::Create); mgr->register_creature_script(2853, &HumanoidDruid::Create); mgr->register_creature_script(2892, &HumanoidPriest::Create); mgr->register_creature_script(2894, &HumanoidShaman::Create); mgr->register_creature_script(2906, &HumanoidWarrior::Create); mgr->register_creature_script(2907, &HumanoidPriest::Create); mgr->register_creature_script(2919, &HumanoidWarrior::Create); mgr->register_creature_script(2953, &HumanoidShaman::Create); mgr->register_creature_script(2982, &HumanoidPriest::Create); mgr->register_creature_script(2984, &HumanoidPriest::Create); mgr->register_creature_script(2986, &HumanoidRogue::Create); mgr->register_creature_script(2988, &HumanoidRogue::Create); mgr->register_creature_script(3089, &HumanoidFuryWarrior::Create); mgr->register_creature_script(3195, &HumanoidUnarmed::Create); mgr->register_creature_script(3198, &HumanoidWarlock::Create); mgr->register_creature_script(3199, &HumanoidWarlock::Create); mgr->register_creature_script(3258, &HumanoidHunter::Create); mgr->register_creature_script(3263, &HumanoidShaman::Create); mgr->register_creature_script(3265, &HumanoidHunter::Create); mgr->register_creature_script(3269, &HumanoidShaman::Create); mgr->register_creature_script(3270, &HumanoidPriest::Create); mgr->register_creature_script(3271, &HumanoidPriest::Create); mgr->register_creature_script(3279, &HumanoidRogue::Create); mgr->register_creature_script(3283, &HumanoidWarrior::Create); mgr->register_creature_script(3286, &HumanoidPriest::Create); mgr->register_creature_script(3339, &HumanoidWarrior::Create); mgr->register_creature_script(3380, &HumanoidWarlock::Create); mgr->register_creature_script(3387, &HumanoidPriest::Create); mgr->register_creature_script(3388, &HumanoidPriest::Create); mgr->register_creature_script(3393, &HumanoidWarrior::Create); mgr->register_creature_script(3411, &HumanoidFuryWarrior::Create); mgr->register_creature_script(3457, &HumanoidRogue::Create); mgr->register_creature_script(3458, &HumanoidPriest::Create); mgr->register_creature_script(3489, &HumanoidFuryWarrior::Create); mgr->register_creature_script(3659, &HumanoidWarrior::Create); mgr->register_creature_script(3705, &HumanoidFuryWarrior::Create); mgr->register_creature_script(3711, &HumanoidFuryWarrior::Create); mgr->register_creature_script(3725, &HumanoidWarlock::Create); mgr->register_creature_script(3727, &HumanoidWarrior::Create); mgr->register_creature_script(3728, &HumanoidWarlock::Create); mgr->register_creature_script(3739, &HumanoidWarrior::Create); mgr->register_creature_script(3742, &HumanoidPriest::Create); mgr->register_creature_script(3748, &HumanoidShaman::Create); mgr->register_creature_script(3750, &HumanoidShaman::Create); mgr->register_creature_script(3752, &HumanoidRogue::Create); mgr->register_creature_script(3754, &HumanoidRogue::Create); mgr->register_creature_script(3759, &HumanoidRogue::Create); mgr->register_creature_script(3763, &HumanoidRogue::Create); mgr->register_creature_script(3767, &HumanoidRogue::Create); mgr->register_creature_script(3770, &HumanoidRogue::Create); mgr->register_creature_script(3833, &HumanoidWarrior::Create); mgr->register_creature_script(3850, &HumanoidMage::Create); mgr->register_creature_script(3854, &HumanoidWarrior::Create); mgr->register_creature_script(3877, &HumanoidWarrior::Create); mgr->register_creature_script(3879, &HumanoidRogue::Create); mgr->register_creature_script(3881, &HumanoidFuryWarrior::Create); mgr->register_creature_script(3882, &HumanoidFuryWarrior::Create); mgr->register_creature_script(3922, &HumanoidShaman::Create); mgr->register_creature_script(3924, &HumanoidShaman::Create); mgr->register_creature_script(3932, &HumanoidWarrior::Create); mgr->register_creature_script(3933, &HumanoidFuryWarrior::Create); mgr->register_creature_script(3935, &HumanoidFuryWarrior::Create); mgr->register_creature_script(3944, &HumanoidPriest::Create); mgr->register_creature_script(3950, &HumanoidWarrior::Create); mgr->register_creature_script(3960, &HumanoidFuryWarrior::Create); mgr->register_creature_script(3965, &HumanoidRogue::Create); mgr->register_creature_script(3995, &HumanoidWitchDoctor::Create); mgr->register_creature_script(4003, &HumanoidShaman::Create); mgr->register_creature_script(4004, &HumanoidFuryWarrior::Create); mgr->register_creature_script(4023, &HumanoidRogue::Create); mgr->register_creature_script(4024, &HumanoidFuryWarrior::Create); mgr->register_creature_script(4025, &HumanoidRogue::Create); mgr->register_creature_script(4047, &HumanoidPriest::Create); mgr->register_creature_script(4052, &HumanoidDruid::Create); mgr->register_creature_script(4083, &HumanoidWitchDoctor::Create); mgr->register_creature_script(4094, &HumanoidWarrior::Create); mgr->register_creature_script(4095, &HumanoidUnarmed::Create); mgr->register_creature_script(4187, &HumanoidWarrior::Create); mgr->register_creature_script(4281, &HumanoidWarrior::Create); mgr->register_creature_script(4282, &HumanoidMage::Create); mgr->register_creature_script(4289, &HumanoidMage::Create); mgr->register_creature_script(4290, &HumanoidWarrior::Create); mgr->register_creature_script(4291, &HumanoidHolyPriest::Create); mgr->register_creature_script(4294, &HumanoidMage::Create); mgr->register_creature_script(4296, &HumanoidMage::Create); mgr->register_creature_script(4297, &HumanoidMage::Create); mgr->register_creature_script(4299, &HumanoidHolyPriest::Create); mgr->register_creature_script(4300, &HumanoidMage::Create); mgr->register_creature_script(4360, &HumanoidWarrior::Create); mgr->register_creature_script(4363, &HumanoidPriest::Create); mgr->register_creature_script(4364, &HumanoidWarrior::Create); mgr->register_creature_script(4366, &HumanoidWarrior::Create); mgr->register_creature_script(4368, &HumanoidFuryWarrior::Create); mgr->register_creature_script(4370, &HumanoidMage::Create); mgr->register_creature_script(4420, &HumanoidFuryWarrior::Create); mgr->register_creature_script(4427, &HumanoidWarrior::Create); mgr->register_creature_script(4435, &HumanoidWarrior::Create); mgr->register_creature_script(4436, &HumanoidWarrior::Create); mgr->register_creature_script(4440, &HumanoidShaman::Create); mgr->register_creature_script(4444, &HumanoidRogue::Create); mgr->register_creature_script(4458, &HumanoidHunter::Create); mgr->register_creature_script(4459, &HumanoidPriest::Create); mgr->register_creature_script(4460, &HumanoidFuryWarrior::Create); mgr->register_creature_script(4461, &HumanoidWarrior::Create); mgr->register_creature_script(4463, &HumanoidWarlock::Create); mgr->register_creature_script(4465, &HumanoidWarrior::Create); mgr->register_creature_script(4466, &HumanoidRogue::Create); mgr->register_creature_script(4467, &HumanoidWitchDoctor::Create); mgr->register_creature_script(4473, &HumanoidWarlock::Create); mgr->register_creature_script(4493, &HumanoidWarrior::Create); mgr->register_creature_script(4500, &HumanoidFuryWarrior::Create); mgr->register_creature_script(4517, &HumanoidPriest::Create); mgr->register_creature_script(4520, &HumanoidShaman::Create); mgr->register_creature_script(4528, &HumanoidUnarmed::Create); mgr->register_creature_script(4540, &HumanoidHolyPriest::Create); mgr->register_creature_script(4547, &HumanoidRogue::Create); mgr->register_creature_script(4633, &HumanoidWarrior::Create); mgr->register_creature_script(4634, &HumanoidUnarmed::Create); mgr->register_creature_script(4636, &HumanoidFuryWarrior::Create); mgr->register_creature_script(4638, &HumanoidWarrior::Create); mgr->register_creature_script(4645, &HumanoidUnarmed::Create); mgr->register_creature_script(4647, &HumanoidWarrior::Create); mgr->register_creature_script(4652, &HumanoidUnarmed::Create); mgr->register_creature_script(4654, &HumanoidWarrior::Create); mgr->register_creature_script(4656, &HumanoidUnarmed::Create); mgr->register_creature_script(4661, &HumanoidUnarmed::Create); mgr->register_creature_script(4665, &HumanoidWarlock::Create); mgr->register_creature_script(4667, &HumanoidWarlock::Create); mgr->register_creature_script(4668, &HumanoidWarlock::Create); mgr->register_creature_script(4680, &HumanoidWarrior::Create); mgr->register_creature_script(4705, &HumanoidWarlock::Create); mgr->register_creature_script(4712, &HumanoidMage::Create); mgr->register_creature_script(4713, &HumanoidWarrior::Create); mgr->register_creature_script(4714, &HumanoidFuryWarrior::Create); mgr->register_creature_script(4716, &HumanoidHunter::Create); mgr->register_creature_script(4718, &HumanoidPriest::Create); mgr->register_creature_script(4732, &HumanoidHunter::Create); mgr->register_creature_script(4784, &HumanoidWarrior::Create); mgr->register_creature_script(4787, &HumanoidWarrior::Create); mgr->register_creature_script(4798, &HumanoidRogue::Create); mgr->register_creature_script(4802, &HumanoidPriest::Create); mgr->register_creature_script(4813, &HumanoidWarlock::Create); mgr->register_creature_script(4845, &HumanoidUnarmed::Create); mgr->register_creature_script(4847, &HumanoidShadowHunter::Create); mgr->register_creature_script(4848, &HumanoidShadowPriest::Create); mgr->register_creature_script(4852, &HumanoidPriest::Create); mgr->register_creature_script(4853, &HumanoidShaman::Create); mgr->register_creature_script(4856, &HumanoidHunter::Create); mgr->register_creature_script(4875, &HumanoidFuryWarrior::Create); mgr->register_creature_script(4879, &HumanoidFuryWarrior::Create); mgr->register_creature_script(4921, &HumanoidWarrior::Create); mgr->register_creature_script(4944, &HumanoidWarrior::Create); mgr->register_creature_script(4951, &HumanoidWarrior::Create); mgr->register_creature_script(4954, &HumanoidFuryWarrior::Create); mgr->register_creature_script(4969, &HumanoidUnarmed::Create); mgr->register_creature_script(4996, &HumanoidWarrior::Create); mgr->register_creature_script(5085, &HumanoidWarrior::Create); mgr->register_creature_script(5086, &HumanoidWarrior::Create); mgr->register_creature_script(5095, &HumanoidWarrior::Create); mgr->register_creature_script(5096, &HumanoidWarrior::Create); mgr->register_creature_script(5232, &HumanoidUnarmed::Create); mgr->register_creature_script(5234, &HumanoidUnarmed::Create); mgr->register_creature_script(5236, &HumanoidShaman::Create); mgr->register_creature_script(5237, &HumanoidMage::Create); mgr->register_creature_script(5239, &HumanoidMage::Create); mgr->register_creature_script(5240, &HumanoidWarlock::Create); mgr->register_creature_script(5241, &HumanoidFuryWarrior::Create); mgr->register_creature_script(5253, &HumanoidUnarmed::Create); mgr->register_creature_script(5254, &HumanoidPriest::Create); mgr->register_creature_script(5256, &HumanoidWarrior::Create); mgr->register_creature_script(5328, &HumanoidPriest::Create); mgr->register_creature_script(5331, &HumanoidWarrior::Create); mgr->register_creature_script(5333, &HumanoidWarrior::Create); mgr->register_creature_script(5334, &HumanoidFuryWarrior::Create); mgr->register_creature_script(5336, &HumanoidMage::Create); mgr->register_creature_script(5346, &HumanoidRogue::Create); mgr->register_creature_script(5363, &HumanoidRogue::Create); mgr->register_creature_script(5364, &HumanoidFuryWarrior::Create); mgr->register_creature_script(5386, &HumanoidWarlock::Create); mgr->register_creature_script(5396, &HumanoidWarrior::Create); mgr->register_creature_script(5418, &HumanoidRogue::Create); mgr->register_creature_script(5470, &HumanoidUnarmed::Create); mgr->register_creature_script(5472, &HumanoidWarrior::Create); mgr->register_creature_script(5473, &HumanoidMage::Create); mgr->register_creature_script(5474, &HumanoidUnarmed::Create); mgr->register_creature_script(5475, &HumanoidWarlock::Create); mgr->register_creature_script(5616, &HumanoidRogue::Create); mgr->register_creature_script(5617, &HumanoidShadowPriest::Create); mgr->register_creature_script(5618, &HumanoidRogue::Create); mgr->register_creature_script(5623, &HumanoidRogue::Create); mgr->register_creature_script(5642, &HumanoidFuryWarrior::Create); mgr->register_creature_script(5648, &HumanoidShadowPriest::Create); mgr->register_creature_script(5649, &HumanoidFuryWarrior::Create); mgr->register_creature_script(5650, &HumanoidWitchDoctor::Create); mgr->register_creature_script(5694, &HumanoidMage::Create); mgr->register_creature_script(5760, &HumanoidFuryWarrior::Create); mgr->register_creature_script(5764, &HumanoidWarrior::Create); mgr->register_creature_script(5769, &HumanoidDruid::Create); mgr->register_creature_script(5787, &HumanoidWarrior::Create); mgr->register_creature_script(5824, &HumanoidWarrior::Create); mgr->register_creature_script(5851, &HumanoidWarrior::Create); mgr->register_creature_script(5860, &HumanoidShaman::Create); mgr->register_creature_script(5862, &HumanoidShaman::Create); mgr->register_creature_script(5863, &HumanoidShaman::Create); mgr->register_creature_script(5870, &HumanoidFuryWarrior::Create); mgr->register_creature_script(5888, &HumanoidPriest::Create); mgr->register_creature_script(5901, &HumanoidPriest::Create); mgr->register_creature_script(5975, &HumanoidMage::Create); mgr->register_creature_script(5976, &HumanoidUnarmed::Create); mgr->register_creature_script(5977, &HumanoidUnarmed::Create); mgr->register_creature_script(5978, &HumanoidWarlock::Create); mgr->register_creature_script(5994, &HumanoidPriest::Create); mgr->register_creature_script(6004, &HumanoidWarlock::Create); mgr->register_creature_script(6005, &HumanoidUnarmed::Create); mgr->register_creature_script(6006, &HumanoidWarlock::Create); mgr->register_creature_script(6007, &HumanoidWarrior::Create); mgr->register_creature_script(6008, &HumanoidWarlock::Create); mgr->register_creature_script(6009, &HumanoidWarlock::Create); mgr->register_creature_script(6035, &HumanoidRogue::Create); mgr->register_creature_script(6068, &HumanoidWarrior::Create); mgr->register_creature_script(6069, &HumanoidWarrior::Create); mgr->register_creature_script(6089, &HumanoidWarrior::Create); mgr->register_creature_script(6124, &HumanoidWarrior::Create); mgr->register_creature_script(6126, &HumanoidRogue::Create); mgr->register_creature_script(6129, &HumanoidMage::Create); mgr->register_creature_script(6131, &HumanoidMage::Create); mgr->register_creature_script(6134, &HumanoidFuryWarrior::Create); mgr->register_creature_script(6138, &HumanoidPriest::Create); mgr->register_creature_script(6180, &HumanoidFuryWarrior::Create); mgr->register_creature_script(6185, &HumanoidWarrior::Create); mgr->register_creature_script(6186, &HumanoidShaman::Create); mgr->register_creature_script(6188, &HumanoidShaman::Create); mgr->register_creature_script(6190, &HumanoidWarrior::Create); mgr->register_creature_script(6194, &HumanoidWarrior::Create); mgr->register_creature_script(6196, &HumanoidFuryWarrior::Create); mgr->register_creature_script(6201, &HumanoidRogue::Create); mgr->register_creature_script(6207, &HumanoidRogue::Create); mgr->register_creature_script(6244, &HumanoidPriest::Create); mgr->register_creature_script(6252, &HumanoidWarlock::Create); mgr->register_creature_script(6253, &HumanoidWarlock::Create); mgr->register_creature_script(6254, &HumanoidWarlock::Create); mgr->register_creature_script(6267, &HumanoidWarlock::Create); mgr->register_creature_script(6351, &HumanoidPriest::Create); mgr->register_creature_script(6371, &HumanoidWarrior::Create); mgr->register_creature_script(6389, &HumanoidWarrior::Create); mgr->register_creature_script(6519, &HumanoidFuryWarrior::Create); mgr->register_creature_script(6548, &HumanoidMage::Create); mgr->register_creature_script(6560, &HumanoidWarrior::Create); mgr->register_creature_script(6606, &HumanoidPriest::Create); mgr->register_creature_script(6668, &HumanoidFuryWarrior::Create); mgr->register_creature_script(6707, &HumanoidRogue::Create); mgr->register_creature_script(6766, &HumanoidRogue::Create); mgr->register_creature_script(6768, &HumanoidRogue::Create); mgr->register_creature_script(6771, &HumanoidRogue::Create); mgr->register_creature_script(7017, &HumanoidFuryWarrior::Create); mgr->register_creature_script(7026, &HumanoidMage::Create); mgr->register_creature_script(7028, &HumanoidWarlock::Create); mgr->register_creature_script(7034, &HumanoidMage::Create); mgr->register_creature_script(7035, &HumanoidUnarmed::Create); mgr->register_creature_script(7069, &HumanoidHolyPriest::Create); mgr->register_creature_script(7075, &HumanoidMage::Create); mgr->register_creature_script(7091, &HumanoidRogue::Create); mgr->register_creature_script(7106, &HumanoidRogue::Create); mgr->register_creature_script(7107, &HumanoidRogue::Create); mgr->register_creature_script(7108, &HumanoidRogue::Create); mgr->register_creature_script(7110, &HumanoidRogue::Create); mgr->register_creature_script(7112, &HumanoidWarlock::Create); mgr->register_creature_script(7114, &HumanoidWarrior::Create); mgr->register_creature_script(7115, &HumanoidWarlock::Create); mgr->register_creature_script(7118, &HumanoidWarlock::Create); mgr->register_creature_script(7120, &HumanoidWarlock::Create); mgr->register_creature_script(7135, &HumanoidWarrior::Create); mgr->register_creature_script(7153, &HumanoidWarrior::Create); mgr->register_creature_script(7157, &HumanoidWarrior::Create); mgr->register_creature_script(7158, &HumanoidShaman::Create); mgr->register_creature_script(7175, &HumanoidRogue::Create); mgr->register_creature_script(7246, &HumanoidShadowHunter::Create); mgr->register_creature_script(7247, &HumanoidWarlock::Create); mgr->register_creature_script(7313, &HumanoidPriest::Create); mgr->register_creature_script(7316, &HumanoidPriest::Create); mgr->register_creature_script(7320, &HumanoidUnarmed::Create); mgr->register_creature_script(7327, &HumanoidWarrior::Create); mgr->register_creature_script(7329, &HumanoidWarrior::Create); mgr->register_creature_script(7335, &HumanoidShaman::Create); mgr->register_creature_script(7337, &HumanoidShadowPriest::Create); mgr->register_creature_script(7340, &HumanoidShadowPriest::Create); mgr->register_creature_script(7342, &HumanoidWarlock::Create); mgr->register_creature_script(7344, &HumanoidWarrior::Create); mgr->register_creature_script(7345, &HumanoidWarrior::Create); mgr->register_creature_script(7369, &HumanoidUnarmed::Create); mgr->register_creature_script(7371, &HumanoidUnarmed::Create); mgr->register_creature_script(7372, &HumanoidWarlock::Create); mgr->register_creature_script(7379, &HumanoidMage::Create); mgr->register_creature_script(7404, &HumanoidWarrior::Create); mgr->register_creature_script(7437, &HumanoidMage::Create); mgr->register_creature_script(7439, &HumanoidShaman::Create); mgr->register_creature_script(7441, &HumanoidShaman::Create); mgr->register_creature_script(7457, &HumanoidRogue::Create); mgr->register_creature_script(7463, &HumanoidFuryWarrior::Create); mgr->register_creature_script(7725, &HumanoidFuryWarrior::Create); mgr->register_creature_script(7727, &HumanoidShaman::Create); mgr->register_creature_script(7779, &HumanoidPriest::Create); mgr->register_creature_script(7809, &HumanoidRogue::Create); mgr->register_creature_script(7855, &HumanoidRogue::Create); mgr->register_creature_script(7858, &HumanoidRogue::Create); mgr->register_creature_script(7873, &HumanoidWarrior::Create); mgr->register_creature_script(7899, &HumanoidRogue::Create); mgr->register_creature_script(7901, &HumanoidRogue::Create); mgr->register_creature_script(7995, &HumanoidPriest::Create); mgr->register_creature_script(8017, &HumanoidWarrior::Create); mgr->register_creature_script(8115, &HumanoidWitchDoctor::Create); mgr->register_creature_script(8125, &HumanoidFuryWarrior::Create); mgr->register_creature_script(8136, &HumanoidFuryWarrior::Create); mgr->register_creature_script(8216, &HumanoidFuryWarrior::Create); mgr->register_creature_script(8218, &HumanoidRogue::Create); mgr->register_creature_script(8282, &HumanoidFuryWarrior::Create); mgr->register_creature_script(8298, &HumanoidPriest::Create); mgr->register_creature_script(8309, &HumanoidRogue::Create); mgr->register_creature_script(8380, &HumanoidWarrior::Create); mgr->register_creature_script(8386, &HumanoidWarrior::Create); mgr->register_creature_script(8387, &HumanoidWarrior::Create); mgr->register_creature_script(8388, &HumanoidWarrior::Create); mgr->register_creature_script(8389, &HumanoidWarrior::Create); mgr->register_creature_script(8408, &HumanoidFuryWarrior::Create); mgr->register_creature_script(8441, &HumanoidWarrior::Create); mgr->register_creature_script(8524, &HumanoidMage::Create); mgr->register_creature_script(8527, &HumanoidWarrior::Create); mgr->register_creature_script(8546, &HumanoidWarlock::Create); mgr->register_creature_script(8547, &HumanoidWarlock::Create); mgr->register_creature_script(8550, &HumanoidWarlock::Create); mgr->register_creature_script(8551, &HumanoidWarlock::Create); mgr->register_creature_script(8553, &HumanoidShadowPriest::Create); mgr->register_creature_script(8558, &HumanoidFuryWarrior::Create); mgr->register_creature_script(8560, &HumanoidWarrior::Create); mgr->register_creature_script(8561, &HumanoidShadowHunter::Create); mgr->register_creature_script(8578, &HumanoidMage::Create); mgr->register_creature_script(8756, &HumanoidWarrior::Create); mgr->register_creature_script(8757, &HumanoidWarrior::Create); mgr->register_creature_script(8758, &HumanoidWarrior::Create); mgr->register_creature_script(8876, &HumanoidWarlock::Create); mgr->register_creature_script(8903, &HumanoidWarrior::Create); mgr->register_creature_script(8980, &HumanoidWarrior::Create); mgr->register_creature_script(9045, &HumanoidWarlock::Create); mgr->register_creature_script(9077, &HumanoidFuryWarrior::Create); mgr->register_creature_script(9078, &HumanoidWarlock::Create); mgr->register_creature_script(9095, &HumanoidWarrior::Create); mgr->register_creature_script(9196, &HumanoidFuryWarrior::Create); mgr->register_creature_script(9197, &HumanoidMage::Create); mgr->register_creature_script(9198, &HumanoidPriest::Create); mgr->register_creature_script(9199, &HumanoidWarrior::Create); mgr->register_creature_script(9201, &HumanoidMage::Create); mgr->register_creature_script(9216, &HumanoidFuryWarrior::Create); mgr->register_creature_script(9217, &HumanoidMage::Create); mgr->register_creature_script(9218, &HumanoidFuryWarrior::Create); mgr->register_creature_script(9219, &HumanoidFuryWarrior::Create); mgr->register_creature_script(9239, &HumanoidPriest::Create); mgr->register_creature_script(9240, &HumanoidShadowPriest::Create); mgr->register_creature_script(9241, &HumanoidHunter::Create); mgr->register_creature_script(9257, &HumanoidWarlock::Create); mgr->register_creature_script(9258, &HumanoidFuryWarrior::Create); mgr->register_creature_script(9261, &HumanoidWarlock::Create); mgr->register_creature_script(9262, &HumanoidWarlock::Create); mgr->register_creature_script(9263, &HumanoidWarlock::Create); mgr->register_creature_script(9265, &HumanoidShadowHunter::Create); mgr->register_creature_script(9266, &HumanoidWitchDoctor::Create); mgr->register_creature_script(9268, &HumanoidFuryWarrior::Create); mgr->register_creature_script(9269, &HumanoidPriest::Create); mgr->register_creature_script(9445, &HumanoidWarrior::Create); mgr->register_creature_script(9456, &HumanoidFuryWarrior::Create); mgr->register_creature_script(9464, &HumanoidFuryWarrior::Create); mgr->register_creature_script(9516, &HumanoidFuryWarrior::Create); mgr->register_creature_script(9517, &HumanoidFuryWarrior::Create); mgr->register_creature_script(9522, &HumanoidRogue::Create); mgr->register_creature_script(9523, &HumanoidPriest::Create); mgr->register_creature_script(9605, &HumanoidFuryWarrior::Create); mgr->register_creature_script(9692, &HumanoidFuryWarrior::Create); mgr->register_creature_script(9693, &HumanoidMage::Create); mgr->register_creature_script(9716, &HumanoidFuryWarrior::Create); mgr->register_creature_script(9717, &HumanoidWarlock::Create); mgr->register_creature_script(9817, &HumanoidWarlock::Create); mgr->register_creature_script(9818, &HumanoidWarlock::Create); mgr->register_creature_script(10040, &HumanoidWarrior::Create); mgr->register_creature_script(10076, &HumanoidPriest::Create); mgr->register_creature_script(10157, &HumanoidPriest::Create); mgr->register_creature_script(10307, &HumanoidWitchDoctor::Create); mgr->register_creature_script(10318, &HumanoidRogue::Create); mgr->register_creature_script(10319, &HumanoidWarrior::Create); mgr->register_creature_script(10371, &HumanoidWarrior::Create); mgr->register_creature_script(10390, &HumanoidWarrior::Create); mgr->register_creature_script(10391, &HumanoidFuryWarrior::Create); mgr->register_creature_script(10398, &HumanoidShadowPriest::Create); mgr->register_creature_script(10399, &HumanoidWarlock::Create); mgr->register_creature_script(10419, &HumanoidMage::Create); mgr->register_creature_script(10422, &HumanoidMage::Create); mgr->register_creature_script(10423, &HumanoidPriest::Create); mgr->register_creature_script(10425, &HumanoidMage::Create); mgr->register_creature_script(10469, &HumanoidWarlock::Create); mgr->register_creature_script(10471, &HumanoidWarlock::Create); mgr->register_creature_script(10472, &HumanoidWarlock::Create); mgr->register_creature_script(10477, &HumanoidShadowPriest::Create); mgr->register_creature_script(10486, &HumanoidWarrior::Create); mgr->register_creature_script(10489, &HumanoidWarrior::Create); mgr->register_creature_script(10601, &HumanoidWarrior::Create); mgr->register_creature_script(10602, &HumanoidMage::Create); mgr->register_creature_script(10608, &HumanoidPriest::Create); mgr->register_creature_script(10619, &HumanoidWarrior::Create); mgr->register_creature_script(10680, &HumanoidWarlock::Create); mgr->register_creature_script(10720, &HumanoidRogue::Create); mgr->register_creature_script(10721, &HumanoidWarrior::Create); mgr->register_creature_script(10758, &HumanoidRogue::Create); mgr->register_creature_script(10760, &HumanoidShaman::Create); mgr->register_creature_script(10762, &HumanoidUnarmed::Create); mgr->register_creature_script(10781, &HumanoidPriest::Create); mgr->register_creature_script(10824, &HumanoidFuryWarrior::Create); mgr->register_creature_script(10826, &HumanoidFuryWarrior::Create); mgr->register_creature_script(10878, &HumanoidRogue::Create); mgr->register_creature_script(10937, &HumanoidWarrior::Create); mgr->register_creature_script(10943, &HumanoidWarrior::Create); mgr->register_creature_script(10947, &HumanoidRogue::Create); mgr->register_creature_script(10984, &HumanoidFuryWarrior::Create); mgr->register_creature_script(11034, &HumanoidFuryWarrior::Create); mgr->register_creature_script(11043, &HumanoidHolyPriest::Create); mgr->register_creature_script(11053, &HumanoidPriest::Create); mgr->register_creature_script(11055, &HumanoidShadowPriest::Create); mgr->register_creature_script(11075, &HumanoidFuryWarrior::Create); mgr->register_creature_script(11076, &HumanoidFuryWarrior::Create); mgr->register_creature_script(11077, &HumanoidFuryWarrior::Create); mgr->register_creature_script(11078, &HumanoidFuryWarrior::Create); mgr->register_creature_script(11099, &HumanoidWarrior::Create); mgr->register_creature_script(11121, &HumanoidWarrior::Create); mgr->register_creature_script(11218, &HumanoidDruid::Create); mgr->register_creature_script(11279, &HumanoidWarrior::Create); mgr->register_creature_script(11288, &HumanoidRogue::Create); mgr->register_creature_script(11319, &HumanoidShaman::Create); mgr->register_creature_script(11322, &HumanoidWarlock::Create); mgr->register_creature_script(11323, &HumanoidWarrior::Create); mgr->register_creature_script(11324, &HumanoidWarlock::Create); mgr->register_creature_script(11338, &HumanoidShadowPriest::Create); mgr->register_creature_script(11339, &HumanoidShadowHunter::Create); mgr->register_creature_script(11340, &HumanoidPriest::Create); mgr->register_creature_script(11346, &HumanoidPriest::Create); mgr->register_creature_script(11351, &HumanoidHunter::Create); mgr->register_creature_script(11352, &HumanoidFuryWarrior::Create); mgr->register_creature_script(11353, &HumanoidFuryWarrior::Create); mgr->register_creature_script(11355, &HumanoidWarrior::Create); mgr->register_creature_script(11383, &HumanoidPriest::Create); mgr->register_creature_script(11440, &HumanoidWarrior::Create); mgr->register_creature_script(11441, &HumanoidUnarmed::Create); mgr->register_creature_script(11442, &HumanoidUnarmed::Create); mgr->register_creature_script(11444, &HumanoidMage::Create); mgr->register_creature_script(11445, &HumanoidWarrior::Create); mgr->register_creature_script(11448, &HumanoidWarlock::Create); mgr->register_creature_script(11452, &HumanoidRogue::Create); mgr->register_creature_script(11453, &HumanoidRogue::Create); mgr->register_creature_script(11454, &HumanoidRogue::Create); mgr->register_creature_script(11456, &HumanoidRogue::Create); mgr->register_creature_script(11466, &HumanoidWarlock::Create); mgr->register_creature_script(11470, &HumanoidMage::Create); mgr->register_creature_script(11518, &HumanoidWarlock::Create); mgr->register_creature_script(11552, &HumanoidPriest::Create); mgr->register_creature_script(11559, &HumanoidShadowPriest::Create); mgr->register_creature_script(11582, &HumanoidWarlock::Create); mgr->register_creature_script(11598, &HumanoidWarrior::Create); mgr->register_creature_script(11600, &HumanoidShaman::Create); mgr->register_creature_script(11604, &HumanoidShaman::Create); mgr->register_creature_script(11605, &HumanoidPriest::Create); mgr->register_creature_script(11662, &HumanoidPriest::Create); mgr->register_creature_script(11678, &HumanoidRogue::Create); mgr->register_creature_script(11679, &HumanoidWitchDoctor::Create); mgr->register_creature_script(11683, &HumanoidShaman::Create); mgr->register_creature_script(11685, &HumanoidPriest::Create); mgr->register_creature_script(11686, &HumanoidFuryWarrior::Create); mgr->register_creature_script(11723, &HumanoidRogue::Create); mgr->register_creature_script(11730, &HumanoidRogue::Create); mgr->register_creature_script(11734, &HumanoidFuryWarrior::Create); mgr->register_creature_script(11746, &HumanoidUnarmed::Create); mgr->register_creature_script(11777, &HumanoidUnarmed::Create); mgr->register_creature_script(11778, &HumanoidUnarmed::Create); mgr->register_creature_script(11791, &HumanoidRogue::Create); mgr->register_creature_script(11792, &HumanoidRogue::Create); mgr->register_creature_script(11831, &HumanoidWitchDoctor::Create); mgr->register_creature_script(11837, &HumanoidShaman::Create); mgr->register_creature_script(11838, &HumanoidPriest::Create); mgr->register_creature_script(11839, &HumanoidUnarmed::Create); mgr->register_creature_script(11880, &HumanoidWarrior::Create); mgr->register_creature_script(11898, &HumanoidFuryWarrior::Create); mgr->register_creature_script(11910, &HumanoidUnarmed::Create); mgr->register_creature_script(11912, &HumanoidUnarmed::Create); mgr->register_creature_script(11913, &HumanoidMage::Create); mgr->register_creature_script(11917, &HumanoidShaman::Create); mgr->register_creature_script(11937, &HumanoidWarrior::Create); mgr->register_creature_script(11944, &HumanoidPriest::Create); mgr->register_creature_script(11947, &HumanoidWarrior::Create); mgr->register_creature_script(11949, &HumanoidWarrior::Create); mgr->register_creature_script(12052, &HumanoidWarrior::Create); mgr->register_creature_script(12053, &HumanoidWarrior::Create); mgr->register_creature_script(12116, &HumanoidPriest::Create); mgr->register_creature_script(12126, &HumanoidFuryWarrior::Create); mgr->register_creature_script(12127, &HumanoidWarrior::Create); mgr->register_creature_script(12140, &HumanoidWarrior::Create); mgr->register_creature_script(12157, &HumanoidShadowHunter::Create); mgr->register_creature_script(12158, &HumanoidHunter::Create); mgr->register_creature_script(13284, &HumanoidShaman::Create); mgr->register_creature_script(13301, &HumanoidRogue::Create); mgr->register_creature_script(13324, &HumanoidWarrior::Create); mgr->register_creature_script(13328, &HumanoidWarrior::Create); mgr->register_creature_script(13330, &HumanoidWarrior::Create); mgr->register_creature_script(13332, &HumanoidWarrior::Create); mgr->register_creature_script(13333, &HumanoidWarrior::Create); mgr->register_creature_script(13337, &HumanoidWarrior::Create); mgr->register_creature_script(13419, &HumanoidFuryWarrior::Create); mgr->register_creature_script(13421, &HumanoidWarrior::Create); mgr->register_creature_script(13442, &HumanoidDruid::Create); mgr->register_creature_script(13443, &HumanoidDruid::Create); mgr->register_creature_script(13836, &HumanoidWarlock::Create); mgr->register_creature_script(13843, &HumanoidWarrior::Create); mgr->register_creature_script(13956, &HumanoidPriest::Create); mgr->register_creature_script(13957, &HumanoidWarrior::Create); mgr->register_creature_script(13958, &HumanoidPriest::Create); mgr->register_creature_script(14182, &HumanoidHunter::Create); mgr->register_creature_script(14185, &HumanoidHunter::Create); mgr->register_creature_script(14186, &HumanoidHunter::Create); mgr->register_creature_script(14187, &HumanoidHunter::Create); mgr->register_creature_script(14188, &HumanoidHunter::Create); mgr->register_creature_script(14236, &HumanoidFuryWarrior::Create); mgr->register_creature_script(14284, &HumanoidWarrior::Create); mgr->register_creature_script(14285, &HumanoidWarrior::Create); mgr->register_creature_script(14347, &HumanoidFuryWarrior::Create); mgr->register_creature_script(14369, &HumanoidWarrior::Create); mgr->register_creature_script(14372, &HumanoidRogue::Create); mgr->register_creature_script(14392, &HumanoidFuryWarrior::Create); mgr->register_creature_script(14393, &HumanoidPriest::Create); mgr->register_creature_script(14445, &HumanoidWarrior::Create); mgr->register_creature_script(14456, &HumanoidWarrior::Create); mgr->register_creature_script(14479, &HumanoidFuryWarrior::Create); mgr->register_creature_script(14483, &HumanoidWarrior::Create); mgr->register_creature_script(14530, &HumanoidFuryWarrior::Create); mgr->register_creature_script(14621, &HumanoidPriest::Create); mgr->register_creature_script(14625, &HumanoidPriest::Create); mgr->register_creature_script(14634, &HumanoidWarrior::Create); mgr->register_creature_script(14720, &HumanoidFuryWarrior::Create); mgr->register_creature_script(14739, &HumanoidPriest::Create); mgr->register_creature_script(14876, &HumanoidWitchDoctor::Create); mgr->register_creature_script(14911, &HumanoidWarrior::Create); mgr->register_creature_script(14912, &HumanoidWarrior::Create); mgr->register_creature_script(14962, &HumanoidFuryWarrior::Create); mgr->register_creature_script(15022, &HumanoidRogue::Create); mgr->register_creature_script(15182, &HumanoidWarrior::Create); mgr->register_creature_script(15184, &HumanoidWarrior::Create); mgr->register_creature_script(15195, &HumanoidWarrior::Create); mgr->register_creature_script(15202, &HumanoidWarlock::Create); mgr->register_creature_script(15213, &HumanoidFuryWarrior::Create); mgr->register_creature_script(15215, &HumanoidPriest::Create); mgr->register_creature_script(15440, &HumanoidWarrior::Create); mgr->register_creature_script(15528, &HumanoidPriest::Create); mgr->register_creature_script(15532, &HumanoidWarrior::Create); mgr->register_creature_script(15533, &HumanoidWarrior::Create); */ }
[ "[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef" ]
[ [ [ 1, 11311 ] ] ]