blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
5
146
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
7
license_type
stringclasses
2 values
repo_name
stringlengths
6
79
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
4 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.07k
426M
star_events_count
int64
0
27
fork_events_count
int64
0
12
gha_license_id
stringclasses
3 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
6 values
src_encoding
stringclasses
26 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
1 class
length_bytes
int64
20
6.28M
extension
stringclasses
20 values
content
stringlengths
20
6.28M
authors
sequencelengths
1
16
author_lines
sequencelengths
1
16
3370f6f0e3cfbd74944a2d768a73ae5e477281ba
d8f64a24453c6f077426ea58aaa7313aafafc75c
/RenderManager.cpp
2b84a2ad7a7031fa974d188a53e0226b01c781e5
[]
no_license
dotted/wfto
5b98591645f3ddd72cad33736da5def09484a339
6eebb66384e6eb519401bdd649ae986d94bcaf27
refs/heads/master
2021-01-20T06:25:20.468978
2010-11-04T21:01:51
2010-11-04T21:01:51
32,183,921
1
0
null
null
null
null
UTF-8
C++
false
false
16,689
cpp
#include "settings.h" #include "commons.h" #include "RenderManager.h" #include "Camera.h" #include "Conversions.h" #include "Frustum.h" #include "Logger.h" using namespace game_objects; using namespace game_objects::block_objects; using namespace game_utils; using namespace utils; using namespace cml; using namespace std; using namespace control; using namespace rendering; using namespace geometry; namespace game_utils { namespace managers { CRenderManager::CRenderManager(): CManager() { vbo = NULL; } CRenderManager::~CRenderManager() { } bool CRenderManager::init() { vbo = new CVBO(CVBO::BT_STREAM_DRAW,false); tmpVboVertexBuffer = new GLfloat[CV_MAX_VERTEX_BUFFER*3]; tmpVboNormalBuffer = new GLfloat[CV_MAX_VERTEX_BUFFER*3]; tmpVboTexCoordBuffer = new GLfloat[CV_MAX_TEX_COORD_BUFFER*2]; ZeroMemory(tmpVboVertexBuffer,sizeof(GLfloat)*CV_MAX_VERTEX_BUFFER*3); ZeroMemory(tmpVboNormalBuffer,sizeof(GLfloat)*CV_MAX_VERTEX_BUFFER*3); ZeroMemory(tmpVboTexCoordBuffer,sizeof(GLfloat)*CV_MAX_TEX_COORD_BUFFER*2); tmpVboVertexBufferSize = 0; tmpVboTexCoordBufferSize = 0; vbo->setVertexData(CV_MAX_VERTEX_BUFFER,3,sizeof(GLfloat),tmpVboVertexBuffer,CVBO::DT_FLOAT); vbo->setNormalData(CV_MAX_VERTEX_BUFFER,3,sizeof(GLfloat),tmpVboNormalBuffer,CVBO::DT_FLOAT); string textureQuality = CV_GAME_MANAGER->getSettingsManager()->getSetting_String(CV_SETTINGS_TEXTURE_QUALITY); GLint textureIndex = CV_GAME_MANAGER->getSettingsManager()->getSetting_Int(string(CV_SETTINGS_TEXTURE_ATLAS_INDEX)+"_"+textureQuality); CV_GAME_MANAGER->getResourceManager()->loadSelectedTexture(textureIndex); CV_GAME_MANAGER->getResourceManager()->loadSelectedTexture(textureIndex+CV_NORMAL_MAP_START_INDEX); textureAtlasColor = CV_TEXTURE_LIST->getTexture(textureIndex); textureAtlasNormal = CV_TEXTURE_LIST->getTexture(textureIndex+CV_NORMAL_MAP_START_INDEX); vbo->setTextureData(CVBO::TU_UNIT0,textureAtlasColor,CV_MAX_TEX_COORD_BUFFER,2,sizeof(GLfloat),tmpVboTexCoordBuffer,CVBO::DT_FLOAT); vbo->setTextureData(CVBO::TU_UNIT1,textureAtlasNormal,CV_MAX_TEX_COORD_BUFFER,2,sizeof(GLfloat),tmpVboTexCoordBuffer,CVBO::DT_FLOAT); vbo->setEnumMode(CVBO::EM_QUADS); CSettingsManager *sManager = CV_GAME_MANAGER->getSettingsManager(); cameraFPSExtent = sManager->getSetting_Float(CV_SETTINGS_CAMERA_FPS_EXTENT); // setup FOG - TODO read settings from file GLfloat fog_color[]={0.0f,0.0f,0.0f,1.0f}; glFogi(GL_FOG_MODE, GL_EXP); glFogfv(GL_FOG_COLOR, fog_color); glFogf(GL_FOG_DENSITY, 1.0f); glHint(GL_FOG_HINT, GL_DONT_CARE); glFogf(GL_FOG_START, 0.1f); glFogf(GL_FOG_END, 5.0f); return true; } bool CRenderManager::update() { glColor3f(1.0f,1.0f,1.0f); // get camera CCamera *camera = CV_GAME_MANAGER->getControlManager()->getCamera(); // transform view camera->transformView(); // Draw the map and items that fall into view frustum. // 1. extract approximate logical location of camera in the level map. vector2i center = CConversions::realToLogical(camera->getPosition()); GLint centerX = center[0]; GLint centerY = center[1]; bool isFPS = CV_GAME_MANAGER->getControlManager()->isFPS(); if (isFPS) { // fog only in FPS mode glEnable(GL_FOG); } /* In FPS mode we can't use height to determine visible offset. We have to use some extent read from config (CV_CAMERA_FPS_EXTENT). */ GLint diff = (GLint)(isFPS?cameraFPSExtent:camera->getPosition()[1]*10.0f); // 2. create a bounding square making its center logical position calculate above. GLint minX = (centerX-diff>=0?centerX-diff:0); GLint minY = (centerY-diff>=0?centerY-diff:0); GLint maxX = (centerX+diff<CV_LEVEL_MAP_SIZE?centerX+diff:CV_LEVEL_MAP_SIZE-1); GLint maxY = (centerY+diff<CV_LEVEL_MAP_SIZE?centerY+diff:CV_LEVEL_MAP_SIZE-1); // 3. go through all block that fall into this bounding square and check if they fall // int out view frustum. If not then just exclude them. CBlock *block; GLint blockVisible = 0, allVerticesCount = 0, creaturesVisible = 0, maxVertInput = 0, maxTexInput = 0; tmpVboVertexBufferSize = 0; tmpVboTexCoordBufferSize = 0; vector3f vertA, vertB, vertC; GLfloat **verts, *texCoords; CLevelManager *lManager = CV_GAME_MANAGER->getLevelManager(); CAnimatedTerrainManager *atManager = CV_GAME_MANAGER->getAnimatedTerrainManager(); CFrustum *frustum = CV_GAME_MANAGER->getControlManager()->getViewFrustum(); bool lavaWater = false; GLfloat delta = CV_GAME_MANAGER->getDeltaTime(); renderedBlocks.clear(); for (GLint y=minY; y<=maxY; y++) { for (GLint x=minX; x<=maxX; x++) { block = lManager->getBlock(x,y); if (block) { //block->getBoundingBox()->draw(); // just for testing if (frustum->containsBBOX(block->getBoundingBox())) { blockVisible++; block->updateTexture(delta); lavaWater = (block->isLava() || block->isWater()); if (lavaWater) { atManager->updateBlock(block); } renderedBlocks.push_back(block); // draw block objects if (block->getBlockObjects()->size()>0) { for (std::vector<CBlockObject*>::iterator rmIter = block->getBlockObjects()->begin(); rmIter != block->getBlockObjects()->end(); rmIter++) { CBlockObject *bObj = *rmIter; bObj->moveTo(); glRotatef(bObj->getRotateY(),0.0f,1.0f,0.0f); bObj->drawModel(delta); glRotatef(-bObj->getRotateY(),0.0f,1.0f,0.0f); bObj->moveBack(); } } bool isRoom = block->isRoom(); if (isRoom) { std::vector<GLuint> *dls = block->getDisplayLists(); if (dls->size()!=0) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,textureAtlasColor); glBegin(GL_QUADS); { for (std::vector<GLuint>::iterator dlIter = dls->begin(); dlIter != dls->end(); dlIter++) { glCallList(*dlIter); } } glEnd(); glDisable(GL_TEXTURE_2D); } } for (GLint f=CBlock::BFS_FRONT; f<=CBlock::BFS_CEILING; f++) { if ((!isFPS && f==CBlock::BFS_CEILING) || (isFPS && f==CBlock::BFS_TOP) || (isRoom && f!=CBlock::BFS_CEILING)) { continue; } if (block->isFaceVisible((CBlock::BLOCK_FACE_SELECTOR)f)) { verts = block->getVertices(); texCoords = block->getTextureCoordinates((CBlock::BLOCK_FACE_SELECTOR)f); if (lavaWater && f<=CBlock::BFS_RIGHT) { /* Lava and water have only lowers row of wall sections drawn. If they are drawn at all. */ maxVertInput = CV_FBLR_W_L_FACE_VERT_FLOATS; maxTexInput = CV_FBLR_W_L_FACE_TEX_FLOATS; } else { maxVertInput = f>=CBlock::BFS_TOP?CV_TBWLC_FACE_VERT_FLOATS:CV_FBLR_FACE_VERT_FLOATS; maxTexInput = f>=CBlock::BFS_TOP?CV_TBWLC_FACE_TEX_FLOATS:CV_FBLR_FACE_TEX_FLOATS; } if (tmpVboVertexBufferSize+maxVertInput>CV_MAX_VERTEX_BUFFER*3) { vbo->setElementsCount(CVBO::IDT_vertex,tmpVboVertexBufferSize/3); vbo->setElementsCount(CVBO::IDT_texture0,tmpVboTexCoordBufferSize/2); vbo->setElementsCount(CVBO::IDT_texture1,tmpVboTexCoordBufferSize/2); vbo->draw(); allVerticesCount+=tmpVboVertexBufferSize; tmpVboVertexBufferSize=0; tmpVboTexCoordBufferSize=0; } memcpy(tmpVboVertexBuffer+tmpVboVertexBufferSize, verts[f], sizeof(GLfloat)*maxVertInput); tmpVboVertexBufferSize+=maxVertInput; memcpy(tmpVboTexCoordBuffer+tmpVboTexCoordBufferSize, texCoords, sizeof(GLfloat)*maxTexInput); tmpVboTexCoordBufferSize+=maxTexInput; } } } } } } if (tmpVboVertexBufferSize>0) { vbo->setElementsCount(CVBO::IDT_vertex,tmpVboVertexBufferSize/3); vbo->setElementsCount(CVBO::IDT_texture0,tmpVboTexCoordBufferSize/2); vbo->setElementsCount(CVBO::IDT_texture1,tmpVboTexCoordBufferSize/2); vbo->draw(); allVerticesCount+=tmpVboVertexBufferSize; } // draw creatures CCreatureManager *cManager = CV_GAME_MANAGER->getCreatureManager(); GLint cCount = cManager->getCreatureVector()->size(); if (cCount>0) { CCreature *creature = NULL; for (std::vector<CCreature*>::iterator cIter = cManager->getCreatureVector()->begin(); cIter != cManager->getCreatureVector()->end(); cIter++) { creature = (*cIter); if (creature) { sBoundingBox *cBBOX = creature->getModel()->getBoundingBox(); cBBOX->translate(creature->getPosition()); if (frustum->containsBBOX(cBBOX)) { creature->draw(delta); creaturesVisible++; } cBBOX->translate(-creature->getPosition()); } } } // draw transparent block objects for (std::vector<CBlock*>::iterator vbIter = renderedBlocks.begin(); vbIter != renderedBlocks.end(); vbIter++) { block = *vbIter; if (block->getBlockObjects()->size()>0) { for (std::vector<CBlockObject*>::iterator rmIter = block->getBlockObjects()->begin(); rmIter != block->getBlockObjects()->end(); rmIter++) { CBlockObject *bObj = *rmIter; bObj->moveTo(); glRotatef(bObj->getRotateY(),0.0f,1.0f,0.0f); bObj->drawEffect(); glRotatef(-bObj->getRotateY(),0.0f,1.0f,0.0f); bObj->moveBack(); } } } glDisable(GL_FOG); if (!isFPS) { handlePickedObjects(); } handleMineMarker(); CV_GAME_MANAGER->getTextPrinter()->print((GLfloat)0,(GLfloat)(CV_SETTINGS_WINDOW_HEIGHT-15*3),"Visible blocks: %d",blockVisible); CV_GAME_MANAGER->getTextPrinter()->print((GLfloat)0,(GLfloat)(CV_SETTINGS_WINDOW_HEIGHT-15*2),"Visible creatures: %d",creaturesVisible); CV_GAME_MANAGER->getTextPrinter()->print((GLfloat)0,(GLfloat)(CV_SETTINGS_WINDOW_HEIGHT-15),"Triangles drawn: %d",(allVerticesCount/4)*2); // render the lights representations. usefull for debugging CV_GAME_MANAGER->getLightingManager()->drawLightSources(frustum); return true; } bool CRenderManager::shutdown() { delete [] tmpVboVertexBuffer; delete [] tmpVboNormalBuffer; delete [] tmpVboTexCoordBuffer; delete vbo; return true; } std::vector<CBlock*> *CRenderManager::getRenderedBlocks() { return &renderedBlocks; } GLvoid CRenderManager::handlePickedObjects() { // if we are ower the menu we do not have to proccess things under the cursor if (CV_GAME_MANAGER->getGUIManager()->getPlayGUI()->is_mouse_over_gui()) { return; } // if we are not selling or buying we don't have to process blocks (just objects TODO) ACTION_EVENT *ae = CV_GAME_MANAGER->getGUIManager()->getLastActionEvent(); // get the block we have our cursor on CBlock *pickedBlock = CV_GAME_MANAGER->getPickingManager()->getLastPickedBlock(); if (pickedBlock) { //go through all the blocks to determine which are highlighted for (GLint y=0; y<=CV_LEVEL_MAP_SIZE; y++) { for (GLint x=0; x<=CV_LEVEL_MAP_SIZE; x++) { pickedBlock = CV_GAME_MANAGER->getLevelManager()->getBlock(x,y); if(!pickedBlock) continue; //render only if block is highlighted //or if block has been selected for digging if(!pickedBlock->isHighlighted()) continue; GLint type = pickedBlock->getType(); /*if (!pickedBlock->isSellable()) { return; }*/ sBoundingBox *bbox = pickedBlock->getBoundingBox(); vector3f a(bbox->A); vector3f b(bbox->B); vector3f c(bbox->C); vector3f d(bbox->D); vector3f e(bbox->E); vector3f f(bbox->F); vector3f g(bbox->G); vector3f h(bbox->H); a[1]=b[1]=c[1]=d[1]=CV_BLOCK_HEIGHT+CV_BLOCK_HEIGHT/4.0f+CV_BLOCK_HEIGHT/32.0f; e[1]=f[1]=g[1]=h[1]=CV_BLOCK_HEIGHT/4.0f+CV_BLOCK_HEIGHT/32.0f; glLineWidth(4.0f); if (pickedBlock->isLow()) { if (!(ae->message_group==AEMG_BUILD_ROOMS || ae->message_group==AEMG_BUILD_DOORS || ae->message_group==AEMG_BUILD_TRAPS)) { return; } // draw the selection box if (pickedBlock->isSellable(CV_CURRENT_PLAYER_ID) && ae->message == AEM_SELL) { glColor3f(0.0f,1.0f,0.0f); } else if (pickedBlock->isBuildable(CV_CURRENT_PLAYER_ID) && ae->message != AEM_SELL) { glColor3f(0.0f,1.0f,0.0f); } else { glColor3f(1.0f,0.0f,0.0f); } glBegin(GL_LINES); { /*glVertex3fv(&a[0]); glVertex3fv(&b[0]); glVertex3fv(&b[0]); glVertex3fv(&c[0]); glVertex3fv(&c[0]); glVertex3fv(&d[0]); glVertex3fv(&d[0]); glVertex3fv(&a[0]);*/ glVertex3fv(&e[0]); glVertex3fv(&f[0]); glVertex3fv(&f[0]); glVertex3fv(&g[0]); glVertex3fv(&g[0]); glVertex3fv(&h[0]); glVertex3fv(&h[0]); glVertex3fv(&e[0]); /*glVertex3fv(&a[0]); glVertex3fv(&e[0]); glVertex3fv(&b[0]); glVertex3fv(&f[0]); glVertex3fv(&c[0]); glVertex3fv(&g[0]); glVertex3fv(&d[0]); glVertex3fv(&h[0]);*/ } glEnd(); } else { if (!(ae->message_group==AEMG_BUILD_ROOMS || ae->message_group==AEMG_BUILD_DOORS || ae->message_group==AEMG_BUILD_TRAPS)) glColor3f(type==CV_BLOCK_TYPE_ROCK_ID?1.0f:0.0f,type==CV_BLOCK_TYPE_ROCK_ID?0.0f:1.0f,0.0f); else glColor3f(1.0f,0.0f,0.0f); glBegin(GL_LINES); { glVertex3fv(&a[0]); glVertex3fv(&b[0]); glVertex3fv(&b[0]); glVertex3fv(&c[0]); glVertex3fv(&c[0]); glVertex3fv(&d[0]); glVertex3fv(&d[0]); glVertex3fv(&a[0]); glVertex3fv(&e[0]); glVertex3fv(&f[0]); glVertex3fv(&f[0]); glVertex3fv(&g[0]); glVertex3fv(&g[0]); glVertex3fv(&h[0]); glVertex3fv(&h[0]); glVertex3fv(&e[0]); glVertex3fv(&a[0]); glVertex3fv(&e[0]); glVertex3fv(&b[0]); glVertex3fv(&f[0]); glVertex3fv(&c[0]); glVertex3fv(&g[0]); glVertex3fv(&d[0]); glVertex3fv(&h[0]); } glEnd(); } glLineWidth(1.0f); } } } } GLvoid CRenderManager::handleMineMarker() { CBlock *pickedBlock; //go through all the blocks to determine which are marked for mining for (GLint y=0; y<=CV_LEVEL_MAP_SIZE; y++) { for (GLint x=0; x<=CV_LEVEL_MAP_SIZE; x++) { pickedBlock = CV_GAME_MANAGER->getLevelManager()->getBlock(x,y); if(!pickedBlock) continue; if (!pickedBlock->isMarked()) continue; // gold color glColor3f(1.0f,0.80f,0.0f); sBoundingBox *bbox = pickedBlock->getBoundingBox(); vector3f a(bbox->A); vector3f b(bbox->B); vector3f c(bbox->C); vector3f d(bbox->D); vector3f e(bbox->E); vector3f f(bbox->F); vector3f g(bbox->G); vector3f h(bbox->H); a[1]=b[1]=c[1]=d[1]=CV_BLOCK_HEIGHT+CV_BLOCK_HEIGHT/4.0f+CV_BLOCK_HEIGHT/32.0f; e[1]=f[1]=g[1]=h[1]=CV_BLOCK_HEIGHT/4.0f+CV_BLOCK_HEIGHT/32.0f; glLineWidth(4.0f); glBegin(GL_LINES); { glVertex3fv(&a[0]); glVertex3fv(&b[0]); glVertex3fv(&b[0]); glVertex3fv(&c[0]); glVertex3fv(&c[0]); glVertex3fv(&d[0]); glVertex3fv(&d[0]); glVertex3fv(&a[0]); glVertex3fv(&e[0]); glVertex3fv(&f[0]); glVertex3fv(&f[0]); glVertex3fv(&g[0]); glVertex3fv(&g[0]); glVertex3fv(&h[0]); glVertex3fv(&h[0]); glVertex3fv(&e[0]); glVertex3fv(&a[0]); glVertex3fv(&e[0]); glVertex3fv(&b[0]); glVertex3fv(&f[0]); glVertex3fv(&c[0]); glVertex3fv(&g[0]); glVertex3fv(&d[0]); glVertex3fv(&h[0]); } glEnd(); glLineWidth(1.0f); } } } }; };
[ [ [ 1, 54 ], [ 56, 318 ], [ 322, 356 ], [ 359, 362 ], [ 365, 365 ], [ 371, 371 ], [ 376, 376 ], [ 378, 378 ], [ 383, 383 ], [ 385, 385 ], [ 397, 397 ], [ 421, 421 ], [ 469, 472 ], [ 535, 536 ] ], [ [ 55, 55 ], [ 358, 358 ], [ 363, 364 ], [ 366, 370 ], [ 372, 372 ], [ 375, 375 ], [ 377, 377 ], [ 379, 382 ], [ 384, 384 ], [ 386, 393 ], [ 395, 396 ], [ 398, 420 ], [ 422, 446 ], [ 448, 468 ] ], [ [ 319, 321 ], [ 373, 374 ], [ 473, 534 ] ], [ [ 357, 357 ], [ 394, 394 ], [ 447, 447 ] ] ]
2643e29990769c0414bbd554062c8ecafb934575
74c8da5b29163992a08a376c7819785998afb588
/NetAnimal/Game/wheel/NetWheelController/include/NetHardwareCode.h
f2e01b07a620bbec8d66b78901755dbb4b525a85
[]
no_license
dbabox/aomi
dbfb46c1c9417a8078ec9a516cc9c90fe3773b78
4cffc8e59368e82aed997fe0f4dcbd7df626d1d0
refs/heads/master
2021-01-13T14:05:10.813348
2011-06-07T09:36:41
2011-06-07T09:36:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
369
h
#ifndef __Orz_NetHardwareCode_h__ #define __Orz_NetHardwareCode_h__ #include "WheelControllerConfig.h" #include "ThreadQueue.h" namespace Orz { namespace WheelEnum { enum HARDWARE { HW_BUTTON_UP = 0xa1, HW_BUTTON_DOWN = 0xa2 }; }; struct HardwareMsg { WheelEnum::HARDWARE msg; int id; int data; }; } #endif
[ [ [ 1, 31 ] ] ]
e47d38430eff2cb3aaa47619774b8adef2ba5213
7707c79fe6a5b216a62bb175133249663a0fa12b
/trunk/DlgAddMaskCutout.h
21006d06194f18637e37a8fa1bb786e22da75d58
[]
no_license
BackupTheBerlios/freepcb-svn
51be4b266e80f336045e2242b3388928c0b731f1
0ae28845832421c80bbdb10eae514a6e13d01034
refs/heads/master
2021-01-20T12:42:11.484059
2010-06-03T04:43:44
2010-06-03T04:43:44
40,441,767
0
0
null
null
null
null
UTF-8
C++
false
false
575
h
#pragma once #include "afxwin.h" // CDlgAddMaskCutout dialog class CDlgAddMaskCutout : public CDialog { DECLARE_DYNAMIC(CDlgAddMaskCutout) public: CDlgAddMaskCutout(CWnd* pParent = NULL); // standard constructor virtual ~CDlgAddMaskCutout(); // Dialog Data enum { IDD = IDD_ADD_MASK_CUTOUT }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support DECLARE_MESSAGE_MAP() public: CComboBox m_combo_layer; CButton m_radio_none; CButton m_radio_edge; CButton m_radio_full; int m_layer; int m_hatch; };
[ "allanwright@21cd2c34-3bff-0310-83e0-c30e317e0b48" ]
[ [ [ 1, 29 ] ] ]
4831f9f95be4512cfe4dc9913cbed864aab76f38
25233569ca21bf93b0d54ca99027938d65dc09d5
/Texture.h
1659722791befc2702dd3dae29bd80bc6addc1b4
[]
no_license
jugg/litestep-module-label
6ede7ff5c80c25e1dc611d02ba5dc13559914ddc
a75ef94a56d68c2a928bde5bab60318e609b9a10
refs/heads/master
2021-01-18T09:20:42.000147
2004-10-07T12:28:00
2004-10-07T12:28:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
306
h
#if !defined(__TEXTURE_H) #define __TEXTURE_H class Texture { public: virtual ~Texture() {} virtual void configure(const string &prefix, const string &subKey) = 0; virtual void apply(HDC hDC, int x, int y, int width, int height) = 0; virtual boolean isTransparent() const = 0; }; #endif
[ [ [ 1, 13 ] ] ]
64fefeb0e6c2210822ec4d1eeb4bd1e44c57de75
f8b364974573f652d7916c3a830e1d8773751277
/emulator/allegrex/instructions/VC2I.h
c3568ae2c6e40259af6dd9ce6bde35dc1aa9a4e6
[]
no_license
lemmore22/pspe4all
7a234aece25340c99f49eac280780e08e4f8ef49
77ad0acf0fcb7eda137fdfcb1e93a36428badfd0
refs/heads/master
2021-01-10T08:39:45.222505
2009-08-02T11:58:07
2009-08-02T11:58:07
55,047,469
0
0
null
null
null
null
UTF-8
C++
false
false
1,035
h
template< > struct AllegrexInstructionTemplate< 0xd0390000, 0xffff0000 > : AllegrexInstructionUnknown { static AllegrexInstructionTemplate &self() { static AllegrexInstructionTemplate insn; return insn; } static AllegrexInstruction *get_instance() { return &AllegrexInstructionTemplate::self(); } virtual AllegrexInstruction *instruction(u32 opcode) { return this; } virtual char const *opcode_name() { return "VC2I"; } virtual void interpret(Processor &processor, u32 opcode); virtual void disassemble(u32 address, u32 opcode, char *opcode_name, char *operands, char *comment); protected: AllegrexInstructionTemplate() {} }; typedef AllegrexInstructionTemplate< 0xd0390000, 0xffff0000 > AllegrexInstruction_VC2I; namespace Allegrex { extern AllegrexInstruction_VC2I &VC2I; } #ifdef IMPLEMENT_INSTRUCTION AllegrexInstruction_VC2I &Allegrex::VC2I = AllegrexInstruction_VC2I::self(); #endif
[ [ [ 1, 41 ] ] ]
efa8a1bcfc863c39fb57bce1b260d4ccbe6de08c
08b064b3fb246f720b8d9727d690ca8c3b96d100
/Nordwind/gui/CGuiImage.cpp
efca995c78a3445f7ef3de6aeb5b5b7d21bdb699
[]
no_license
michalxl/nordwind
e901d2d211b5db70e7b04700458cfbf8a4f68134
271bce7f872678a74c7020863bef9f7a7f4854af
refs/heads/master
2021-01-10T06:37:41.935726
2011-01-03T00:09:06
2011-01-03T00:09:06
43,566,147
0
0
null
null
null
null
UTF-8
C++
false
false
4,734
cpp
#include "CGuiImage.h" #include <Qt/QPainter.h> #include "../CClient.h" #include "../resource/CGumps.h" using namespace gui; void CGumpImage::buildConnections() { connect( this, SIGNAL(idChange()), this, SLOT(onIdChange()) ); connect( this, SIGNAL(hueChange()), this, SLOT(onHueChange()) ); connect( this, SIGNAL(gumpChange()), this, SLOT(onGumpChange()) ); connect( this, SIGNAL(resizeChange()), this, SLOT(onResizeChange()) ); connect( this, SIGNAL(partialHueChange()), this, SLOT(onPartialHueChange()) ); } CGumpImage::CGumpImage( QWidget* _parent, qint32 _x, qint32 _y, quint32 _id, quint32 _hue, bool _partialHue, const QString& _name, quint16 _width, quint16 _height, bool _resize, bool _tiled ) : QGLWidget( _parent, Client::instance().gui() ), m_gump(NULL), m_id(_id), m_hue(_hue), m_partialHue(_partialHue), m_resize(_resize), m_tiled(_tiled) { if(_name!="") setObjectName(_name); move( _x, _y ); quint16 width = (_width!=0xFFFF) ? _width : 50; quint16 height = (_height!=0xFFFF) ? _height : 50; m_gump = data::Gumps::instance().getGump( _id, _hue, _partialHue ); if(m_gump) { if(_resize) { width = m_gump->image().width(); height = m_gump->image().height(); } if(!m_tiled) setMask( m_gump->mask() ); } resize( width, height ); buildConnections(); } CGumpImage::~CGumpImage() { if(m_gump) m_gump->decRef(); } quint32 CGumpImage::id() const { return m_id; } void CGumpImage::setId(quint32 _id ) { if(m_id==_id) return; if(m_gump) m_gump->decRef(); m_gump = data::Gumps::instance().getGump( _id, m_hue, m_partialHue ); if(m_gump&&m_resize) { resize( m_gump->image().width(), m_gump->image().height() ); } m_id = _id; emit gumpChange(); emit idChange(); } quint32 CGumpImage::hue() const { return m_hue; } void CGumpImage::setHue(quint32 _hue) { if(m_hue==_hue) return; if(m_gump) m_gump->decRef(); m_gump = data::Gumps::instance().getGump( m_id, _hue, m_partialHue ); m_hue = _hue; emit gumpChange(); emit hueChange(); } bool CGumpImage::partialHue() const { return m_partialHue; } void CGumpImage::setPartialHue(bool _partialHue) { if(m_partialHue==_partialHue) return; if(m_gump) m_gump->decRef(); m_gump = data::Gumps::instance().getGump( m_id, m_hue, _partialHue ); m_partialHue = _partialHue; emit gumpChange(); emit partialHueChange(); } void CGumpImage::setType(quint32 _id, quint32 _hue, bool _partialHue, bool _resize ) { if(m_id==_id&&_hue==m_hue&&_partialHue==m_partialHue) return; if(m_gump) m_gump->decRef(); m_gump = data::Gumps::instance().getGump( _id, _hue, _partialHue ); if(m_gump&&_resize) { resize( m_gump->image().width(), m_gump->image().height() ); } emit gumpChange(); if(m_id!=_id) { m_id = _id; emit idChange(); } if(m_hue!=_hue) { m_hue = _hue; emit hueChange(); } if(m_partialHue!=_partialHue) { m_partialHue = _partialHue; emit partialHueChange(); } if(m_resize!=_resize) { m_resize=_resize; emit resizeChange(); } } bool CGumpImage::isResize() const { return m_resize; } void CGumpImage::setResize( bool _resize ) { if(m_resize==_resize) return; if(m_gump&&_resize) { resize( m_gump->image().width(), m_gump->image().height() ); } emit resizeChange(); } bool CGumpImage::isTiled() const { return m_tiled; } void CGumpImage::setTiled(bool _tile) { if(m_tiled==_tile) return; m_tiled = _tile; } void CGumpImage::onGumpChange() { if(m_gump&&!m_tiled) setMask(m_gump->mask()); update(); } void CGumpImage::onHueChange() { } void CGumpImage::onIdChange() { } void CGumpImage::onResizeChange() { } void CGumpImage::onPartialHueChange() { } void CGumpImage::paintEvent(QPaintEvent *_event) { Q_UNUSED(_event); QPainter painter(this); if(m_gump) { if(m_tiled) { //painter.drawImage( QRect(0,0, m_gump->image().width(), m_gump->image().height()), m_gump->image() ); //painter.drawImage( QRect(width()-m_gump->image().width(),height()-m_gump->image().height(), m_gump->image().width(), m_gump->image().height()), m_gump->image() ); painter.drawTiledPixmap( 0,0, width(), height(), QPixmap::fromImage( m_gump->image() ) ); } else { painter.drawImage( QRect(0,0, width(), height()), m_gump->image() ); } } else { painter.setPen( QPen(Qt::red, 1, Qt::SolidLine) ); QVector<QPoint> points(5); points << QPoint(0,0) << QPoint(width()-1,height()-1) << QPoint(width()-1, 0) << QPoint(0,0) << QPoint( 0, height()-1 ) << QPoint(width()-1,height()-1); painter.drawPolygon( points.data(), points.size() ); } painter.end(); }
[ "paulidstein@ae180d36-aaa7-11de-892d-7b2b76e7707e" ]
[ [ [ 1, 184 ] ] ]
8a713c77134c950422dda5bc2b34d127eda7b56b
dd5c8920aa0ea96607f2498701c81bb1af2b3c96
/stlplus/source/persistent.cpp
ac40fe40496f9ff9c6c9e718611befe6d1ce58bd
[]
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
18,970
cpp
/*------------------------------------------------------------------------------ Author: Andy Rushton Copyright: (c) Andy Rushton, 2004 License: BSD License, see ../docs/license.html ------------------------------------------------------------------------------*/ #include "os_fixes.hpp" #include "persistent.hpp" #include "textio.hpp" //////////////////////////////////////////////////////////////////////////////// // File format version // This relates to the layout of basic types - if I change the file layout of, say, int or vector, then this will change // Early versions of the persistence routines did not have this - they are no longer supported // - Change from version 1 to 2: changed the persistent representation of inf unsigned char PersistentVersion = 2; //////////////////////////////////////////////////////////////////////////////// // context classes //////////////////////////////////////////////////////////////////////////////// dump_context::dump_context(const otext& device, unsigned char version) throw(persistent_dump_failed) : m_max_key(0), m_version(version), m_little_endian(::little_endian()), m_device(device) { m_device.set_binary_mode(); put(version); // map a null pointer onto magic number zero m_pointers[0] = 0; if (m_version != 1 && m_version != 2) throw persistent_dump_failed(std::string("wrong version: ") + to_string(m_version)); } dump_context::~dump_context(void) { } void dump_context::put(unsigned char data) throw(persistent_dump_failed) { if (!m_device.put(data)) { if (m_device.error()) throw persistent_dump_failed(std::string("output device error: ") + m_device.error_string()); else throw persistent_dump_failed(std::string("output device error: unknown")); } } const otext& dump_context::device(void) const { return m_device; } unsigned char dump_context::version(void) const { return m_version; } bool dump_context::little_endian(void) const { return m_little_endian; } std::pair<bool,unsigned> dump_context::pointer_map(const void* const pointer) { dump_context::magic_map::iterator found = m_pointers.find(pointer); if (found == m_pointers.end()) { // add a new mapping unsigned magic = m_pointers.size(); m_pointers[pointer] = magic; return std::pair<bool,unsigned>(false,magic); } // return the old mapping return std::pair<bool,unsigned>(true,found->second); } unsigned short dump_context::register_type(const std::type_info& info, dump_context::dump_callback callback) { std::string key = info.name(); unsigned short data = ++m_max_key; m_callbacks[key] = std::make_pair(data,callback); return data; } bool dump_context::is_callback(const std::type_info& info) const { return m_callbacks.find(info.name()) != m_callbacks.end(); } dump_context::callback_data dump_context::lookup_type(const std::type_info& info) const throw(persistent_illegal_type) { std::string key = info.name(); callback_map::const_iterator found = m_callbacks.find(key); if (found == m_callbacks.end()) throw persistent_illegal_type(key); return found->second; } unsigned short dump_context::register_interface(const std::type_info& info) { std::string key = info.name(); unsigned short data = ++m_max_key; m_interfaces[key] = data; return data; } bool dump_context::is_interface(const std::type_info& info) const { return m_interfaces.find(info.name()) != m_interfaces.end(); } dump_context::interface_data dump_context::lookup_interface(const std::type_info& info) const throw(persistent_illegal_type) { std::string key = info.name(); interface_map::const_iterator found = m_interfaces.find(key); if (found == m_interfaces.end()) throw persistent_illegal_type(key); return found->second; } void dump_context::register_all(dump_context::installer installer) { if (installer) installer(*this); } //////////////////////////////////////////////////////////////////////////////// restore_context::restore_context(const itext& device) throw(persistent_restore_failed) : m_max_key(0), m_little_endian(::little_endian()), m_device(device) { m_device.set_binary_mode(); // map a null pointer onto magic number zero m_pointers[0] = 0; // get the dump version and see if we support it m_version = (unsigned char)get(); if (m_version != 1 && m_version != 2) throw persistent_restore_failed(std::string("wrong version: ") + to_string(m_version)); } restore_context::~restore_context(void) { } const itext& restore_context::device(void) const { return m_device; } unsigned char restore_context::version(void) const { return m_version; } bool restore_context::little_endian(void) const { return m_little_endian; } int restore_context::get(void) throw(persistent_restore_failed) { int result = m_device.get(); if (result < 0) { if (m_device.error()) throw persistent_restore_failed(std::string("input device error: ") + m_device.error_string()); throw persistent_restore_failed(std::string("premature end of file")); } return result; } std::pair<bool,void*> restore_context::pointer_map(unsigned magic) { restore_context::magic_map::iterator found = m_pointers.find(magic); if (found == m_pointers.end()) { // this magic number has never been seen before return std::pair<bool,void*>(false,0); } return std::pair<bool,void*>(true,found->second); } void restore_context::pointer_add(unsigned magic, void* new_pointer) { m_pointers[magic] = new_pointer; } unsigned short restore_context::register_type(restore_context::create_callback create, restore_context::restore_callback restore) { unsigned short key = ++m_max_key; m_callbacks[key] = std::make_pair(create,restore); return key; } bool restore_context::is_callback(unsigned short key) const { return m_callbacks.find(key) != m_callbacks.end(); } restore_context::callback_data restore_context::lookup_type(unsigned short key) const throw(persistent_illegal_type) { callback_map::const_iterator found = m_callbacks.find(key); if (found == m_callbacks.end()) throw persistent_illegal_type(key); return found->second; } unsigned short restore_context::register_interface(const persistent_ptr& sample) { unsigned short key = ++m_max_key; m_interfaces[key] = sample; return key; } bool restore_context::is_interface(unsigned short key) const { return m_interfaces.find(key) != m_interfaces.end(); } restore_context::interface_data restore_context::lookup_interface(unsigned short key) const throw(persistent_illegal_type) { interface_map::const_iterator found = m_interfaces.find(key); if (found == m_interfaces.end()) throw persistent_illegal_type(key); return found->second; } void restore_context::register_all(restore_context::installer installer) { if (installer) installer(*this); } //////////////////////////////////////////////////////////////////////////////// // Macro for mapping either endian data onto little-endian addressing to make // my life easier in writing this code! I think better in little-endian mode // so the macro does nothing in that mode but maps little-endian onto // big-endian addressing in big-endian mode #define INDEX(index) ((context.little_endian()) ? (index) : ((bytes) - (index) - 1)) //////////////////////////////////////////////////////////////////////////////// // Integer types // format: {size}{byte}*size // size can be zero! // // A major problem is that integer types may be different sizes on different // machines or even with different compilers on the same machine (though I // haven't come across that yet). Neither the C nor the C++ standards specify // the size of integer types. Dumping an int on one machine might dump 16 // bits. Restoring it on another machine might try to restore 32 bits. With // version 0 of these persistence routines, this was not dealt with and so the // restore function could fail. Version 1 handles different type sizes. It // does this by writing the size to the file as well as the data, so the // restore can therefore know how many bytes to restore independent of the // type size. // // In fact, the standard does not even specify the size of char (true! And // mind-numbingly stupid...). However, to be able to do anything at all, I've // had to assume that a char is 1 byte. static void dump_unsigned(dump_context& context, size_t bytes, unsigned char* data) throw(persistent_dump_failed) { // first skip zero bytes - this may reduce the data to zero bytes long size_t i = bytes; while(i >= 1 && data[INDEX(i-1)] == 0) i--; // put the remaining size context.put((unsigned char)i); // and put the bytes while(i--) context.put(data[INDEX(i)]); } static void dump_signed(dump_context& context, size_t bytes, unsigned char* data) throw(persistent_dump_failed) { // first skip all-zero or all-one bytes but only if doing so does not change the sign size_t i = bytes; if (data[INDEX(i-1)] < 128) { // positive number so discard leading zeros but only if the following byte is positive while(i >= 2 && data[INDEX(i-1)] == 0 && data[INDEX(i-2)] < 128) i--; } else { // negative number so discard leading ones but only if the following byte is negative while(i >= 2 && data[INDEX(i-1)] == 255 && data[INDEX(i-2)] >= 128) i--; } // put the remaining size context.put((unsigned char)i); // and put the bytes while(i--) context.put(data[INDEX(i)]); } static void restore_unsigned(restore_context& context, size_t bytes, unsigned char* data) throw(persistent_restore_failed) { // get the dumped size from the file size_t dumped_bytes = (size_t)context.get(); // zero fill any empty space size_t i = bytes; for (; i > dumped_bytes; i--) data[INDEX(i-1)] = 0; // restore the dumped bytes but discard any that don't fit // TODO - could detect overflow and throw an exception here while(i--) { int ch = context.get(); if (i < bytes) data[INDEX(i)] = (unsigned char)ch; else throw persistent_restore_failed(std::string("integer overflow: restoring byte ") + to_string(i) + " of " + to_string(bytes)); } } static void restore_signed(restore_context& context, size_t bytes, unsigned char* data) throw(persistent_restore_failed) { // get the dumped size from the file size_t dumped_bytes = (size_t)context.get(); // restore the dumped bytes but discard any that don't fit size_t i = dumped_bytes; while(i--) { int ch = context.get(); if (i < bytes) data[INDEX(i)] = (unsigned char)ch; else throw persistent_restore_failed(std::string("integer overflow: restoring byte ") + to_string(i) + " of " + to_string(bytes)); } // sign extend if the dumped integer was smaller if (dumped_bytes < bytes) { if (data[INDEX(dumped_bytes-1)] < 128) { // positive so zero fill for (i = dumped_bytes; i < bytes; i++) data[INDEX(i)] = 0; } else { // negative so one fill for (i = dumped_bytes; i < bytes; i++) data[INDEX(i)] = 0xff; } } } //////////////////////////////////////////////////////////////////////////////// // exported functions // bool is dumped and restored as an unsigned char void dump(dump_context& context, const bool& data) throw(persistent_dump_failed) { context.put((unsigned char)data); } void restore(restore_context& context, bool& data) throw(persistent_restore_failed) { data = context.get() != 0; } // char is dumped and restored as an unsigned char because the signedness of char is not defined and can vary void dump(dump_context& context, const char& data) throw(persistent_dump_failed) { context.put((unsigned char)data); } void restore(restore_context& context, char& data) throw(persistent_restore_failed) { data = (char)(unsigned char)context.get(); } void dump(dump_context& context, const signed char& data) throw(persistent_dump_failed) { context.put((unsigned char)data); } void restore(restore_context& context, signed char& data) throw(persistent_restore_failed) { data = (signed char)(unsigned char)context.get(); } void dump(dump_context& context, const unsigned char& data) throw(persistent_dump_failed) { context.put((unsigned char)data); } void restore(restore_context& context, unsigned char& data) throw(persistent_restore_failed) { data = (signed char)(unsigned char)context.get(); } void dump(dump_context& context, const short& data) throw(persistent_dump_failed) { dump_signed(context, sizeof(short), (unsigned char*)&data); } void restore(restore_context& context, short& data) throw(persistent_restore_failed) { restore_signed(context, sizeof(short),(unsigned char*)&data); } void dump(dump_context& context, const unsigned short& data) throw(persistent_dump_failed) { dump_unsigned(context, sizeof(unsigned short), (unsigned char*)&data); } void restore(restore_context& context, unsigned short& data) throw(persistent_restore_failed) { restore_unsigned(context, sizeof(unsigned short),(unsigned char*)&data); } void dump(dump_context& context, const int& data) throw(persistent_dump_failed) { dump_signed(context, sizeof(int), (unsigned char*)&data); } void restore(restore_context& context, int& data) throw(persistent_restore_failed) { restore_signed(context, sizeof(int),(unsigned char*)&data); } void dump(dump_context& context, const unsigned& data) throw(persistent_dump_failed) { dump_unsigned(context, sizeof(unsigned), (unsigned char*)&data); } void restore(restore_context& context, unsigned& data) throw(persistent_restore_failed) { restore_unsigned(context, sizeof(unsigned),(unsigned char*)&data); } void dump(dump_context& context, const long& data) throw(persistent_dump_failed) { dump_signed(context, sizeof(long), (unsigned char*)&data); } void restore(restore_context& context, long& data) throw(persistent_restore_failed) { restore_signed(context, sizeof(long),(unsigned char*)&data); } void dump(dump_context& context, const unsigned long& data) throw(persistent_dump_failed) { dump_unsigned(context, sizeof(unsigned long), (unsigned char*)&data); } void restore(restore_context& context, unsigned long& data) throw(persistent_restore_failed) { restore_unsigned(context, sizeof(unsigned long),(unsigned char*)&data); } ///////////////////////////////////////////////////////////////////// // floating point types // format: {size}{byte}*size // ordering is msB first // this uses a similar mechanism to integer dumps. However, it is not clear how // the big-endian and little-endian argument applies to multi-word data so // this may need reworking by splitting into words and then bytes. static void dump_float(dump_context& context, size_t bytes, unsigned char* data) throw(persistent_dump_failed) { size_t i = bytes; // put the size context.put((unsigned char)i); // and put the bytes while(i--) context.put(data[INDEX(i)]); } static void restore_float(restore_context& context, size_t bytes, unsigned char* data) throw(persistent_restore_failed) { // get the dumped size from the file size_t dumped_bytes = (size_t)context.get(); // get the bytes from the file size_t i = dumped_bytes; while(i--) { int ch = context.get(); if (i < bytes) data[INDEX(i)] = (unsigned char)ch; } // however, if the dumped size was different I don't know how to map the formats, so give an error if (dumped_bytes != bytes) throw persistent_restore_failed(std::string("size mismatch: dumped ") + to_string(dumped_bytes) + std::string(" bytes, restored ") + to_string(bytes) + std::string(" bytes")); } //////////////////////////////////////////////////////////////////////////////// // exported functions which simply call the low-levl byte-dump and byte-restore routines above void dump(dump_context& context, const float& data) throw(persistent_dump_failed) { dump_float(context, sizeof(float), (unsigned char*)&data); } void restore(restore_context& context, float& data) throw(persistent_restore_failed) { restore_float(context, sizeof(float), (unsigned char*)&data); } void dump(dump_context& context, const double& data) throw(persistent_dump_failed) { dump_float(context, sizeof(double), (unsigned char*)&data); } void restore(restore_context& context, double& data) throw(persistent_restore_failed) { restore_float(context, sizeof(double), (unsigned char*)&data); } //////////////////////////////////////////////////////////////////////////////// // Null-terminated char arrays // Format: address [ size data ] void dump(dump_context& context, char*& data) throw(persistent_dump_failed) { // register the address and get the magic key for it std::pair<bool,unsigned> mapping = context.pointer_map(data); dump(context,mapping.second); // if the address is null, then that is all that we need to do // however, if it is non-null and this is the first sight of the address, dump the contents if (data && !mapping.first) { unsigned size = strlen(data); dump(context,size); for (unsigned i = 0; i < size; i++) dump(context,data[i]); } } void restore(restore_context& context, char*& data) throw(persistent_restore_failed) { // destroy any previous contents if (data) { delete[] data; data = 0; } // get the magic key unsigned magic = 0; restore(context,magic); // now lookup the magic key to see if this pointer has already been restored // null pointers are always flagged as already restored std::pair<bool,void*> address = context.pointer_map(magic); if (!address.first) { // this pointer has never been seen before and is non-null // restore the string size_t size = 0; restore(context,size); data = new char[size+1]; for (size_t i = 0; i < size; i++) restore(context,data[i]); data[size] = '\0'; // add this pointer to the set of already seen objects context.pointer_add(magic,data); } } //////////////////////////////////////////////////////////////////////////////// void dump(dump_context& context, const std::string& data) throw(persistent_dump_failed) { dump_basic_string(context, data); } void restore(restore_context& context, std::string& data) throw(persistent_restore_failed) { restore_basic_string(context, data); } ////////////////////////////////////////////////////////////////////////////////
[ "schimmi@cb9ff89a-abed-0310-8fc6-a4cabe7d48c9" ]
[ [ [ 1, 575 ] ] ]
047cf039857bfb3afa7ed743a686b028f41b99f9
842997c28ef03f8deb3422d0bb123c707732a252
/src/moaicore/MOAILocationSensor.h
fa0760f62784cef4160394e2f2860e9f159f844d
[]
no_license
bjorn/moai-beta
e31f600a3456c20fba683b8e39b11804ac88d202
2f06a454d4d94939dc3937367208222735dd164f
refs/heads/master
2021-01-17T11:46:46.018377
2011-06-10T07:33:55
2011-06-10T07:33:55
1,837,561
2
1
null
null
null
null
UTF-8
C++
false
false
1,301
h
// Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved. // http://getmoai.com #ifndef MOAILOCATIONSENSOR_H #define MOAILOCATIONSENSOR_H #include <moaicore/MOAISensor.h> //================================================================// // MOAILocationSensor //================================================================// /** @name MOAILocationSensor @text Location services sensor. */ class MOAILocationSensor : public MOAISensor { private: double mLongitude; double mLatitude; double mAltitude; float mHAccuracy; float mVAccuracy; float mSpeed; USLuaRef mCallback; //----------------------------------------------------------------// static int _getLocation ( lua_State* L ); static int _setCallback ( lua_State* L ); public: DECL_LUA_FACTORY ( MOAILocationSensor ) //----------------------------------------------------------------// void HandleEvent ( USStream& eventStream ); MOAILocationSensor (); ~MOAILocationSensor (); void RegisterLuaClass ( USLuaState& state ); void RegisterLuaFuncs ( USLuaState& state ); static void WriteEvent ( USStream& eventStream, double longitude, double latitude, double altitude, float hAccuracy, float vAccuracy, float speed ); }; #endif
[ [ [ 1, 47 ] ] ]
6017c2168bfe2c377359d2f662d69500241b2cb7
444a151706abb7bbc8abeb1f2194a768ed03f171
/trunk/ENIGMAsystem/SHELL/Platforms/Cocoa/CocoaWindow.h
381ebc90ce70928b7284c16b2a561ea29ad15d3a
[]
no_license
amorri40/Enigma-Game-Maker
9d01f70ab8de42f7c80af9a0f8c7a66e412d19d6
c6b701201b6037f2eb57c6938c184a5d4ba917cf
refs/heads/master
2021-01-15T11:48:39.834788
2011-11-22T04:09:28
2011-11-22T04:09:28
1,855,342
1
1
null
null
null
null
UTF-8
C++
false
false
6,061
h
/********************************************************************************\ ** ** ** Copyright (C) 2010 Alasdair Morrison <[email protected]> ** ** ** ** This file is a part of the ENIGMA Development Environment. ** ** ** ** ** ** ENIGMA 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, version 3 of the license or any later version. ** ** ** ** This application and its source code is distributed AS-IS, 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 recieved a copy of the GNU General Public License along ** ** with this code. If not, see <http://www.gnu.org/licenses/> ** ** ** ** ENIGMA is an environment designed to create games and other programs with a ** ** high-level, fully compilable language. Developers of ENIGMA or anything ** ** associated with ENIGMA are in no way responsible for its users or ** ** applications created by its users, or damages caused by the environment ** ** or programs made in the environment. ** ** ** \********************************************************************************/ #include <string> #include "file_manip.h" using std::string; void gmw_init(); void Sleep(int ms); void window_set_position(int x,int y); ///////////// // VISIBLE // ///////////// int window_set_visible(int visible); int window_get_visible(); ///////////// // CAPTION // ///////////// void window_set_caption(std::string caption); char *window_get_caption(); /////////// // MOUSE // /////////// int display_mouse_get_x(); int display_mouse_get_y(); int window_mouse_get_x(); int window_mouse_get_y(); int window_mouse_set(double x,double y); int display_mouse_set(double x,double y); //////////// // WINDOW // //////////// //int getWindowDimension(int i); //Getters int window_get_x(); int window_get_y(); int window_get_width(); int window_get_height(); //Setters void window_set_size(unsigned int w,unsigned int h); int window_set_rectangle(double x,double y,double w,double h); //Center int window_center(); //////////////// // FULLSCREEN // //////////////// int window_set_fullscreen(const bool full); int window_get_fullscreen(); //////////// // CURSOR // //////////// #define cr_default 0 #define cr_none -1 #define cr_arrow -2 #define cr_cross -3 #define cr_beam -4 #define cr_size_nesw -6 #define cr_size_ns -7 #define cr_size_nwse -8 #define cr_size_we -9 #define cr_uparrow -10 #define cr_hourglass -11 #define cr_drag -12 #define cr_nodrop -13 #define cr_hsplit -14 #define cr_vsplit -15 #define cr_multidrag -16 #define cr_sqlwait -17 #define cr_no -18 #define cr_appstart -19 #define cr_help -20 #define cr_handpoint -21 #define cr_size_all -22 int window_set_cursor(double c); void window_set_showicons(bool show); void window_set_color(int color); int window_view_mouse_get_x(int wid); int window_view_mouse_get_y(int wid); void window_view_mouse_set(int wid, int x, int y); int window_views_mouse_get_x(); int window_views_mouse_get_y(); void window_views_mouse_set(int x, int y); int window_get_region_width(); int window_get_region_height(); /* display_get_width() // Returns the width of the display in pixels. display_get_height() // Returns the height of the display in pixels. display_set_size(w,h) Sets the width and height of the display in pixels. Returns whether this was successful. (Realize that only certain combinations are allowed.) display_get_colordepth() Returns the color depth in bits. display_get_frequency() Returns the refresh frequency of the display. display_set_colordepth(coldepth) Sets the color depth. In general only 16 and 32 are allowed values. Returns whether successful. display_set_frequency(frequency) Sets the refresh frequency for the display. Only few frequencies are allowed. Typically you could set this to 60 with a same room speed to get smooth 60 frames per second motion. Returns whether successful. display_set_all(w,h,frequency,coldepth) Sets all at once. Use -1 for values you do not want to change. Returns whether successful. display_test_all(w,h,frequency,coldepth) Tests whether the indicated settings are allowed. It does not change the settings. Use -1 for values you do not want to change. Returns whether the settings are allowed. display_reset() Resets the display settings to the ones when the program was started. window_default() window_get_cursor() window_set_color(color) window_get_color() window_set_region_scale(scale,adaptwindow) window_get_region_scale() window_set_showborder(show) window_get_showborder() window_set_showicons(show) window_get_showicons() window_set_stayontop(stay) window_get_stayontop() window_set_sizeable(sizeable) window_get_sizeable()*/ int show_message(string str); void io_handle(); void io_clear(); void keyboard_wait(); namespace enigma { extern char** parameters; //void writename(char* x); } #define enigmacatchmouse() //Linux should hopefully do that automatically. void game_end(); void action_end_game();
[ [ [ 1, 172 ] ] ]
18ea8aeb1c53c38b218e07ed3ab5473b490c4f6e
3bfc30f7a07ce0f6eabcd526e39ba1030d84c1f3
/BlobbyWarriors/Source/BlobbyWarriors/Logic/Controller/AbstractController.h
d6460fb6f8e32eaafdfc455983806e61ad00bfb2
[]
no_license
visusnet/Blobby-Warriors
b0b70a0b4769b60d96424b55ad7c47b256e60061
adec63056786e4e8dfcb1ed7f7fe8b09ce05399d
refs/heads/master
2021-01-19T14:09:32.522480
2011-11-29T21:53:25
2011-11-29T21:53:25
2,850,563
0
0
null
null
null
null
UTF-8
C++
false
false
248
h
#ifndef ABSTRACTCONTROLLER_H #define ABSTRACTCONTROLLER_H #include "IController.h" class AbstractController : public IController { public: void setBlobby(Blobby *blobby); virtual void step(); protected: Blobby *blobby; }; #endif
[ [ [ 1, 15 ] ] ]
9585fda730623e9beee6fb185bedcf5a1e98f478
295daf40cb62502dc197769c25a90aff6cf93b53
/strlib.cpp
95038b3a427279ecb420588b62ada2535d4ed7af
[]
no_license
BB4Win/stroke-bb
b97f37612fd8defda9559c72bb7acd21aeb1f752
6e78b0df081e4ea313d418b0221500ab1ea4e4bc
refs/heads/master
2016-09-07T18:43:03.176750
2007-08-07T00:47:20
2007-08-07T00:47:20
32,025,970
0
0
null
null
null
null
UTF-8
C++
false
false
14,779
cpp
/* * Copyright (C) 2001 Jeff Doozan */ #include "StrLib.h" HWND ghWndRestore = 0; char *posRestore = 0; char posCh; // the character that was nulled char *posNulled=0; // the position of the character nulled char *posHeadEscaped; // if the restored string was escaped void InitRestore(HWND hWnd, char *params) { if (posHeadEscaped) { EscapeBuf(posHeadEscaped, '"'); posHeadEscaped = NULL; } if (posNulled) { *posNulled = posCh; posNulled = NULL; } ghWndRestore = hWnd; posRestore = params; posNulled = NULL; posCh = NULL; posHeadEscaped = NULL; } void EndRestore() { if (posHeadEscaped) { EscapeBuf(posHeadEscaped, '"'); posHeadEscaped = NULL; } if (posNulled) { *posNulled = posCh; posNulled = NULL; } ghWndRestore = NULL; posRestore = NULL; posNulled = NULL; posCh = NULL; posHeadEscaped = NULL; } // the string returned is only valid until the next call // to a restore function char *RestoreItem(int id) { char *str = RestoreStr(); SetDlgItemText(ghWndRestore, id, str); return str; } // the string returned is only valid until the next call // to a restore function char *RestoreCheck(int id, char *value) { char *str = RestoreStr(); if (!lstrcmpi(str, value)) CheckDlgButton(ghWndRestore, id, BST_CHECKED); else CheckDlgButton(ghWndRestore, id, BST_UNCHECKED); return str; } char *RestoreRadio(s_radio *radio, int count) { char *str = RestoreStr(); int start = radio[0].id; int end = radio[count-1].id; while (count--) { if (!lstrcmpi(radio[count].val, str)) { CheckRadioButton(ghWndRestore, start, end, radio[count].id); return str; } } return str; } // the string returned is only valid until the next call // to a restore function char *RestoreCombo(int id) { char *str = RestoreStr(); int count = SendDlgItemMessage(ghWndRestore, id, CB_GETCOUNT, 0, 0); int sel = -1; int x = 0; while (x<count && sel==-1) { char *val = (char *) SendDlgItemMessage(ghWndRestore, id, CB_GETITEMDATA, x, 0); if (val && !lstrcmpi(val, str)) sel = x; x++; } // it wasn't found in the item data, check the strings if (sel == -1) { x = 0; char buf[1024]; while (x<count && sel==-1) { SendDlgItemMessage(ghWndRestore, id, CB_GETLBTEXT, x, (LPARAM) buf); if (buf[0] && !lstrcmpi(buf, str)) sel = x; x++; } } if (sel != -1) SendDlgItemMessage(ghWndRestore, id, CB_SETCURSEL, sel, 0); return str; } int RestoreInt() { if (posHeadEscaped) { EscapeBuf(posHeadEscaped, '"'); posHeadEscaped = NULL; } if (posNulled) { *posNulled = posCh; posNulled = NULL; } if (!posRestore) return 0; posRestore = SkipWhiteSpace(posRestore); BOOL bQuotes = FALSE; if (*posRestore == '\"') { bQuotes = TRUE; posRestore++; } int val = 0; while (*posRestore && *posRestore >= '0' && *posRestore <= '9') { val *= 10; val += *posRestore - '0'; posRestore++; } if (bQuotes && *posRestore) posRestore++; return val; } // the string returned is only valid until the next call // to a restore function char *RestoreStr() { if (posHeadEscaped) { EscapeBuf(posHeadEscaped, '"'); posHeadEscaped = NULL; } if (posNulled) { *posNulled = posCh; posNulled = NULL; } if (!posRestore) return NULL; posRestore = SkipWhiteSpace(posRestore); char *end = GetStringEnd(posRestore); if (*posRestore == '"') { // count the number of \'s preceeding the quote // if it's an odd number, then the final \ would // escape the ", meaning it's not the end quote int x=1; while ( *(end-1-x) == '\\') x++; x--; if (!(x & 1)) { // if it's even, the " is valid posRestore++; end--; } } posCh = *end; posNulled = end; *end = 0; // if there were characters that were unescaped, // we need to remember the beginning of the string, so // that we can restore the escaped data after we're done if (Unescape(posRestore)) posHeadEscaped = posRestore; else posHeadEscaped = NULL; char *ret = posRestore; posRestore = end+1; return ret; } HWND ghWndSave; char *posSave = 0; int posBytesLeft = 0; // space left in buffer void InitSave(HWND hWnd, char *params, int maxLength) { ghWndSave = hWnd; *params = 0; posSave = params; posBytesLeft = maxLength-1; // -1 for the null terminator } void EndSave() { ghWndSave = NULL; posSave = NULL; posBytesLeft = 0; } void SaveStr(char *param) { if ( (posBytesLeft <= 3) || !posSave) return; posBytesLeft -= 3; // subtract 3 for the 2 quotation marks and the space if (*posSave == 0) *posSave++ = ' '; int len = lstrlen(param); *posSave++ = '"'; len += Escape(posSave, param, '"'); posSave += len; *posSave++ = '"'; *posSave = 0; posBytesLeft -= len; } void SaveInt(long val) { if (!posBytesLeft || !posSave) return; posBytesLeft -= 3; // subtract 3 for the 2 quotation marks and the space if (*posSave == 0) *posSave++ = ' '; *posSave++ = '"'; mltoa(val, posSave); int len = lstrlen(posSave); posSave += len; *posSave++ = '"'; *posSave = 0; posBytesLeft -= len; } void SaveItem(int id) { if ( (posBytesLeft <= 3) || !posSave) return; posBytesLeft -= 3; // subtract 3 for the 2 quotation marks and the space if (*posSave == 0) *posSave++ = ' '; *posSave++ = '"'; int len = GetDlgItemText(ghWndSave, id, posSave, posBytesLeft); len += EscapeBuf(posSave, '"'); posSave += len; *posSave++ = '"'; *posSave = 0; posBytesLeft -= len; } void SaveCombo(int id) { if ( (posBytesLeft <= 3) || !posSave) return; posBytesLeft -= 3; // subtract 3 for the 2 quotation marks and the space if (*posSave == 0) *posSave++ = ' '; *posSave++ = '"'; int sel = SendDlgItemMessage(ghWndSave, id, CB_GETCURSEL, 0, 0); char *name = (char *) SendDlgItemMessage(ghWndSave, id, CB_GETITEMDATA, sel, 0); int len; if (name) { len = lstrlen(name); lstrcpy(posSave, name); } else len = SendDlgItemMessage(ghWndSave, id, CB_GETLBTEXT, sel, (LPARAM) posSave); len += EscapeBuf(posSave, '"'); posSave += len; *posSave++ = '"'; *posSave = 0; posBytesLeft -= len; } void SaveCheck(int id, char *val) { if (IsDlgButtonChecked(ghWndSave, id)) SaveStr(val); else SaveStr(""); } void SaveRadio(s_radio *radio, int count) { while (count--) { if (IsDlgButtonChecked(ghWndSave, radio[count].id)) { SaveStr(radio[count].val); return; } } SaveStr(""); } void AddCombo(HWND hWnd, int id, char *string, char *val) { int cur = SendDlgItemMessage(hWnd, id, CB_ADDSTRING, 0, (LPARAM) string); if (cur != CB_ERR) SendDlgItemMessage(hWnd, id, CB_SETITEMDATA, cur, (LPARAM) val); } // returns a pointer to the end of the current string // if the string passed to it begins with a quotation mark // it determines the end of the string as being the first // unescaped quotation mark, Otherwise, the end of the string // is the first whitespace char *GetStringEnd(char *buf) { if (!buf) return NULL; char *end = buf; if (*buf == '"') { // if it's a string in quotations end++; // skip past opening quotation mark while (*end) { if (*end == '"') { // count the number of \'s preceeding the quote // if it's an odd number, then the final \ would // escape the ", meaning it's not the end quote int x=1; while ( *(end-x) == '\\') x++; x--; if (!(x & 1)) // if it's even, the " is valid break; } end++; } if (*end) end++; } else // it's not in quotations while (*end && *end != ' ' && *end != '\t') end++; return end; } int GetDlgInt(HWND hWnd, int id) { char buf[11]; GetDlgItemText(hWnd, id, buf, 10); int val = 0; char *p = buf; while (*p && *p >= '0' && *p <= '9') { val *= 10; val += *p - '0'; p++; } return val; } char *SkipWhiteSpace(char *data) { if (data) while (*data && (*data == ' ' || *data == '\t')) // skip whitespace data++; return data; } void TrimWhiteSpace(char *data) { if (!data) return; char *p = data + lstrlen(data)-1; while (p >= data && (*p == ' ' || *p == '\t')) p--; *(p+1) = 0; } char *FindSeparator(char *string, char separator) { while (*string) { if (*string == separator && *(string-1) != '\\') return string; string++; } return NULL; } // return the number of characters removed from the string int Unescape(char *string) { char *in, *out; in = out = string; int count = 0; while (*in) { if (*in == '\\' && *(in+1)) { switch (*(in+1)) { case '\"': *out++ = '\"'; count++; break; case 't': *out++ = '\t'; count++; break; case 'n': *out++ = '\n'; *out++ = '\r'; break; default: *out++ = *(in+1); count++; break; } in+=2; } else *out++ = *in++; } *out = 0; return count; } int Escape(char *out, char *in, char escapeChar) { int escaped = 0; while (*in) { if (*in == escapeChar || *in == '\\') { if (out) { *out = '\\'; out++; } escaped ++; } if (out) { *out++ = *in; } in++; } if (out) *out = 0; return escaped; } // this function assumes that you've got room to expand the string passed to it int EscapeBuf(char *string, char escapeChar) { if (!string) return 0; int escaped = 0; while (*string) { if (*string == escapeChar || *string == '\\') { int len = lstrlen(string); char *ch = string + len; while (ch >= string) { *(ch+1) = *ch; ch--; } *string++ = '\\'; escaped++; } string++; } return escaped; } char *mstrchr(char *str, char chr) { while (*str) { if (*str==chr) return str; str++; } return NULL; } char *mstrrchr(char *str, char chr) { str = str+lstrlen(str); while (str>=str) { if (*str==chr) return str; str--; } return NULL; } char *mstrstr(char *string, char *match) { int slen = lstrlen(string); int mlen = lstrlen(match); char *end = string+slen-mlen; char temp; for (char *p=string,*pend=string+mlen;p<=end;p++,pend++) { temp = *pend; *pend = 0; if (!lstrcmp(p, match)) { *pend = temp; return p; } *pend = temp; } return NULL; } char *mstrstri(char *string, char *match) { int slen = lstrlen(string); int mlen = lstrlen(match); char *end = string+slen-mlen; char temp; for (char *p=string,*pend=string+mlen;p<=end;p++,pend++) { temp = *pend; *pend = 0; if (!lstrcmpi(p, match)) { *pend = temp; return p; } *pend = temp; } return NULL; } char *toknext; char *mstrtok (char *string, char *match) { if (string) toknext = string; char *tok = mstrstr(toknext, match); if (tok) { *tok = 0; char *ret = toknext; toknext = tok + lstrlen(match); return ret; } else return 0; } char *mstrdup (const char *string) { char *ret = new char[lstrlen(string) +1]; lstrcpy(ret, string); return ret; } // recursion...fun static char *s; void num_to_chr(unsigned long n) { unsigned long q = n / 10; if (q) num_to_chr(q); *s++ = (char) n % 10 + '0'; } void mltoa(long n, char *str) { s = str; if (n < 0) { n = -n; *s++ = '-'; } num_to_chr( (unsigned long) n); *s = 0; } long matol(char *str) { long val = 0; // hexidecimal if (str[1] == 'x') { str += 2; while (*str) { if (*str >= '0' && *str <= '9') { val <<= 4; // multiply by 16 val += *str-'0'; // add the integer value } else if (*str >= 'a' && *str <= 'f') { val <<= 4; // multiply by 16 val += *str-'a'+10; // add the integer value } else if (*str >= 'A' && *str <= 'F') { val <<= 4; val += *str-'A'+10; } else break; // not valid input, get outta here str++; } } // decimal else { while (*str >= '0' && *str <= '9') { val *= 10; val += *str-'0'; str++; } } return val; } void mmemcpy(void *dest, void const *src, int len) { if (len) { do { *(char *) dest = *(char *) src; dest = (char *) dest+1; src = (char *) src+1; } while (--len); } } int mmemcmp(void *dest, void const *src, int len) { while (len--) { if ( *(char *)src != *(char *)dest) return (* (char *) src) - (* (char *) dest); else { dest = (char *) dest+1; src = (char *) src+1; } } return 0; } // skip commented and blank lines char *SkipComments(char *data) { while (*data == '#' || *data == '\r') data = NextLine(data); return data; } char *NextLine(char *data) { while (*data && *data != '\r') data++; // find next eol return (*data) ? data+2 : NULL; // +2 to skip over \r\n }
[ [ [ 1, 703 ] ] ]
f767af166730aac96e73a04350b651476de4b28f
69aab86a56c78cdfb51ab19b8f6a71274fb69fba
/Code/inc/Engine/BasicMesh.h
1c0a5cbdae9677c24dde5b0527271a790ecc7dee
[ "BSD-3-Clause" ]
permissive
zc5872061/wonderland
89882b6062b4a2d467553fc9d6da790f4df59a18
b6e0153eaa65a53abdee2b97e1289a3252b966f1
refs/heads/master
2021-01-25T10:44:13.871783
2011-08-11T20:12:36
2011-08-11T20:12:36
38,088,714
0
0
null
null
null
null
UTF-8
C++
false
false
1,352
h
/* * BasicMesh.h * * Created on: 2011-02-13 * Author: Artur */ #ifndef BASICMESH_H_ #define BASICMESH_H_ #include "pi.h" #include "CollisionShapes.h" #include "Material.h" #include <string> #include <memory> class BasicMesh { public: friend class MeshManager; BasicMesh(); const GLfloat* getVertices() const { return m_vertices; } const GLshort* getIndices() const { return m_indices; } const GLfloat* getNormals() const { return m_normals; } const GLfloat* getUVs() const { return m_uvs; } int getIndicesCount() const { return m_indicesCount; } int getVerticesCount() const { return m_verticesCount; } const BaseCollisionShape* getCollisionShape() const { return m_collisionShape.get(); } CollisionShape getCollisionType() const { return m_collisionType; } void setCollisionType(CollisionShape type); const std::string& getName() const { return m_name; } void debugPrint() const; protected: GLfloat* m_vertices; GLshort* m_indices; GLfloat* m_normals; GLfloat* m_uvs; int m_indicesCount; int m_verticesCount; std::auto_ptr<BaseCollisionShape> m_collisionShape; CollisionShape m_collisionType; std::string m_name; private: BasicMesh(const BasicMesh&); BasicMesh& operator=(const BasicMesh&); ~BasicMesh(); }; #endif /* BASICMESH_H_ */
[ [ [ 1, 59 ] ] ]
1393b58b8d6bf31819a054d92060ba58e8bc5b42
6a98ab1a4800e6f169b75c17e01c2fa491989a79
/Weapons/LaserShot.h
20f7934971442e1663428b43d2d2533cfee5b915
[]
no_license
OpenEngineDK/branches-Prototype
966eccfb9ddb0e4a3a68f8fb6a1c1a0d0314dd5c
1364da5ca25a6eb00c829a63db8e083b2e03cc8b
refs/heads/master
2021-01-01T05:18:26.599471
2008-08-13T09:52:42
2008-08-13T09:52:42
58,077,163
0
1
null
null
null
null
UTF-8
C++
false
false
1,616
h
// Rigid body rendering. // ------------------------------------------------------------------- // Copyright (C) 2007 (See AUTHORS) // // This program is free software; It is covered by the GNU General // Public License version 2 or any later version. // See the GNU General Public License for more details (see LICENSE). //-------------------------------------------------------------------- #ifndef _LASER_SHOT_H_ #define _LASER_SHOT_H_ #include "IShot.h" #include <Renderers/IRenderNode.h> #include <Renderers/IRenderingView.h> #include <Scene/ISceneNode.h> #include <Meta/OpenGL.h> // forward declarations namespace OpenEngine { //namespace Geometry { class Box; } namespace Scene { class TransformationNode; } namespace Renderers { class IRenderNode; } } using namespace OpenEngine::Math; using namespace OpenEngine::Geometry; using namespace OpenEngine::Scene; using namespace OpenEngine::Renderers; using namespace std; namespace OpenEngine { namespace Prototype { namespace Weapons { class LaserShot : public IShot { private: double lifeTime; double decayTime; float shotSpeed; Vector<3,float> from; Vector<3,float> to; Vector<3,float> color; public: LaserShot(Vector<3,float> from, Vector<3,float> to); virtual ~LaserShot(); virtual void Process(const float timeSinceLast); void Apply(IRenderingView* view); void Destroy(); }; } } // NS Utils } // NS OpenEngine #endif // _DEFAULT_RIGID_BODY_RENDER_NODE_H_
[ [ [ 1, 59 ] ] ]
549af41db9a65d7fe1acf52e5054a2bf629b70d4
21da454a8f032d6ad63ca9460656c1e04440310e
/test/utest/StringTest.cpp
85fb41c510728e6ec167722582db6d8c20583906
[]
no_license
merezhang/wcpp
d9879ffb103513a6b58560102ec565b9dc5855dd
e22eb48ea2dd9eda5cd437960dd95074774b70b0
refs/heads/master
2021-01-10T06:29:42.908096
2009-08-31T09:20:31
2009-08-31T09:20:31
46,339,619
0
0
null
null
null
null
UTF-8
C++
false
false
3,030
cpp
#include "StringTest.h" #include <wcpp/lang/wscUUID.h> #include <wcpp/lang/wscSystem.h> #include <wcpp/lang/wscLong.h> #include <wcpp/lang/wscThrowable.h> StringTest::StringTest(void) { } StringTest::~StringTest(void) { } ws_result StringTest::doTest(void) { trace( "========================================\n" ); trace( "case:StringTest - begin\n" ); test_wsString(); test_wsLong_ToString(); test_wscUUID_ToString(); trace( "case:StringTest - end\n" ); trace( "========================================\n" ); return ws_result( WS_RLT_SUCCESS ); } void StringTest::test_wscUUID_ToString(void) { trace( " -------------------------------- \n" ); trace( "func:test_wscUUID_ToString - begin\n" ); { ws_ptr<wsiString> str1, str2; wscUUID::ToString( wsiObject::sIID.uuid, &str1 ); ws_uuid uuid; wscUUID::ParseUUID( str1, uuid ); wscUUID::ToString( uuid, &str2 ); trace( "wsiObject::sIID : " ); trace( "{3F45A92B-A7D5-4d93-946C-373E56A8C17B}" ); trace( "\n" ); trace( "wsiObject::sIID ToString : " ); trace( str1->GetBuffer() ); trace( "\n" ); trace( "wsiObject::sIID ParseUUID : " ); trace( str2->GetBuffer() ); trace( "\n" ); } ws_ptr<wsiString> str1,str2; wscUUID::ToString( wsiSystem::sIID.uuid, &str1 ); ws_uuid uuid; wscUUID::ParseUUID( str2, uuid ); wscUUID::ToString( uuid, &str2 ); trace( "wsiSystem::sIID : " ); trace( "{FAC4AD98-7554-4561-AF17-9A5ADB66AD30}" ); trace( "\n" ); trace( "wsiSystem::sIID ToString : " ); trace( str1->GetBuffer() ); trace( "\n" ); trace( "wsiSystem::sIID ParseUUID : " ); trace( str2->GetBuffer() ); trace( "\n" ); trace( "func:test_wscUUID_ToString - end\n" ); trace( " -------------------------------- \n" ); } void StringTest::test_wsLong_ToString(void) { trace( " -------------------------------- \n" ); trace( "func:test_wsLong_ToString - begin\n" ); const int len = 8; ws_long values[len] = { -1, 0, 1, 2147483647, -2147483647, 2147483647, // -2147483648, }; ws_ptr<wsiString> str; trace( "ws_long [wsString]\n" ); for (int i=0; i<len; i++) { wscLong::ToString( values[i], &str ); trace( values[i] ); trace( " [" ); trace( str->GetBuffer() ); trace( "]\n" ); } trace( "func:test_wsLong_ToString - end\n" ); trace( " -------------------------------- \n" ); } void StringTest::test_wsString(void) { trace( " -------------------------------- \n" ); trace( "func:test_wsString - begin\n" ); ws_str str1; ws_str str2( static_cast<wsiString*>(WS_NULL) ); ws_str str3( "" ); ws_str str4( "hello" ); str1 = str4; str2 = str4; str3 = str4; str4 = ""; str3 = str4; str4.SetString( 0, 0 ); str3 = "abcdefg hijk lmn opq rst uvw xyz"; str4 = "hp"; trace( "func:test_wsString - end\n" ); trace( " -------------------------------- \n" ); }
[ "xukun0217@98f29a9a-77f1-11de-91f8-ab615253d9e8" ]
[ [ [ 1, 132 ] ] ]
06d0cf32cc44ceaef1aee7231d700fa03263b9d0
5a48b6a95f18598181ef75dba2930a9d1720deae
/LuaEngine/Process/ProcessLua_Const.cpp
7fa731c182706c81a414b7040ce47d04f748391b
[]
no_license
CBE7F1F65/f980f016e8cbe587c9148f07b799438c
078950c80e3680880bc6b3751fcc345ebc8fe8e5
1aaed5baef10a5b9144f20603d672ea5ac76b3cc
refs/heads/master
2021-01-15T10:42:46.944415
2010-08-28T19:25:48
2010-08-28T19:25:48
32,192,651
0
0
null
null
null
null
UTF-8
C++
false
false
14,847
cpp
#include "../Header/Process.h" #include "../Header/LuaConstDefine.h" bool Process::_LuaRegistConst(LuaObject * obj) { // System obj->SetInteger("NULL", NULL); obj->SetString("LOG_STR_FILENAME", LOG_STR_FILENAME); // D3D obj->SetInteger("D3DTS_WORLD", D3DTS_WORLD); obj->SetInteger("D3DTS_VIEW", D3DTS_VIEW); obj->SetInteger("D3DTS_PROJECTION", D3DTS_PROJECTION); // DI obj->SetInteger("DIK_ESCAPE", DIK_ESCAPE); obj->SetInteger("DIK_1", DIK_1); obj->SetInteger("DIK_2", DIK_2); obj->SetInteger("DIK_3", DIK_3); obj->SetInteger("DIK_4", DIK_4); obj->SetInteger("DIK_5", DIK_5); obj->SetInteger("DIK_6", DIK_6); obj->SetInteger("DIK_7", DIK_7); obj->SetInteger("DIK_8", DIK_8); obj->SetInteger("DIK_9", DIK_9); obj->SetInteger("DIK_0", DIK_0); obj->SetInteger("DIK_MINUS", DIK_MINUS); obj->SetInteger("DIK_EQUALS", DIK_EQUALS); obj->SetInteger("DIK_BACK", DIK_BACK); obj->SetInteger("DIK_TAB", DIK_TAB); obj->SetInteger("DIK_Q", DIK_Q); obj->SetInteger("DIK_W", DIK_W); obj->SetInteger("DIK_E", DIK_E); obj->SetInteger("DIK_R", DIK_R); obj->SetInteger("DIK_T", DIK_T); obj->SetInteger("DIK_Y", DIK_Y); obj->SetInteger("DIK_U", DIK_U); obj->SetInteger("DIK_I", DIK_I); obj->SetInteger("DIK_O", DIK_O); obj->SetInteger("DIK_P", DIK_P); obj->SetInteger("DIK_LBRACKET", DIK_LBRACKET); obj->SetInteger("DIK_RBRACKET", DIK_RBRACKET); obj->SetInteger("DIK_RETURN", DIK_RETURN); obj->SetInteger("DIK_LCONTROL", DIK_LCONTROL); obj->SetInteger("DIK_A", DIK_A); obj->SetInteger("DIK_S", DIK_S); obj->SetInteger("DIK_D", DIK_D); obj->SetInteger("DIK_F", DIK_F); obj->SetInteger("DIK_G", DIK_G); obj->SetInteger("DIK_H", DIK_H); obj->SetInteger("DIK_J", DIK_J); obj->SetInteger("DIK_K", DIK_K); obj->SetInteger("DIK_L", DIK_L); obj->SetInteger("DIK_SEMICOLON", DIK_SEMICOLON); obj->SetInteger("DIK_APOSTROPHE", DIK_APOSTROPHE); obj->SetInteger("DIK_GRAVE", DIK_GRAVE); obj->SetInteger("DIK_LSHIFT", DIK_LSHIFT); obj->SetInteger("DIK_BACKSLASH", DIK_BACKSLASH); obj->SetInteger("DIK_Z", DIK_Z); obj->SetInteger("DIK_X", DIK_X); obj->SetInteger("DIK_C", DIK_C); obj->SetInteger("DIK_V", DIK_V); obj->SetInteger("DIK_B", DIK_B); obj->SetInteger("DIK_N", DIK_N); obj->SetInteger("DIK_M", DIK_M); obj->SetInteger("DIK_COMMA", DIK_COMMA); obj->SetInteger("DIK_PERIOD", DIK_PERIOD); obj->SetInteger("DIK_SLASH", DIK_SLASH); obj->SetInteger("DIK_RSHIFT", DIK_RSHIFT); obj->SetInteger("DIK_MULTIPLY", DIK_MULTIPLY); obj->SetInteger("DIK_LMENU", DIK_LMENU); obj->SetInteger("DIK_SPACE", DIK_SPACE); obj->SetInteger("DIK_CAPITAL", DIK_CAPITAL); obj->SetInteger("DIK_F1", DIK_F1); obj->SetInteger("DIK_F2", DIK_F2); obj->SetInteger("DIK_F3", DIK_F3); obj->SetInteger("DIK_F4", DIK_F4); obj->SetInteger("DIK_F5", DIK_F5); obj->SetInteger("DIK_F6", DIK_F6); obj->SetInteger("DIK_F7", DIK_F7); obj->SetInteger("DIK_F8", DIK_F8); obj->SetInteger("DIK_F9", DIK_F9); obj->SetInteger("DIK_F10", DIK_F10); obj->SetInteger("DIK_NUMLOCK", DIK_NUMLOCK); obj->SetInteger("DIK_SCROLL", DIK_SCROLL); obj->SetInteger("DIK_NUMPAD7", DIK_NUMPAD7); obj->SetInteger("DIK_NUMPAD8", DIK_NUMPAD8); obj->SetInteger("DIK_NUMPAD9", DIK_NUMPAD9); obj->SetInteger("DIK_SUBTRACT", DIK_SUBTRACT); obj->SetInteger("DIK_NUMPAD4", DIK_NUMPAD4); obj->SetInteger("DIK_NUMPAD5", DIK_NUMPAD5); obj->SetInteger("DIK_NUMPAD6", DIK_NUMPAD6); obj->SetInteger("DIK_ADD", DIK_ADD); obj->SetInteger("DIK_NUMPAD1", DIK_NUMPAD1); obj->SetInteger("DIK_NUMPAD2", DIK_NUMPAD2); obj->SetInteger("DIK_NUMPAD3", DIK_NUMPAD3); obj->SetInteger("DIK_NUMPAD0", DIK_NUMPAD0); obj->SetInteger("DIK_DECIMAL", DIK_DECIMAL); obj->SetInteger("DIK_OEM_102", DIK_OEM_102); obj->SetInteger("DIK_F11", DIK_F11); obj->SetInteger("DIK_F12", DIK_F12); obj->SetInteger("DIK_F13", DIK_F13); obj->SetInteger("DIK_F14", DIK_F14); obj->SetInteger("DIK_F15", DIK_F15); obj->SetInteger("DIK_KANA", DIK_KANA); obj->SetInteger("DIK_ABNT_C1", DIK_ABNT_C1); obj->SetInteger("DIK_CONVERT", DIK_CONVERT); obj->SetInteger("DIK_NOCONVERT", DIK_NOCONVERT); obj->SetInteger("DIK_YEN", DIK_YEN); obj->SetInteger("DIK_ABNT_C2", DIK_ABNT_C2); obj->SetInteger("DIK_NUMPADEQUALS", DIK_NUMPADEQUALS); obj->SetInteger("DIK_PREVTRACK", DIK_PREVTRACK); obj->SetInteger("DIK_AT", DIK_AT); obj->SetInteger("DIK_COLON", DIK_COLON); obj->SetInteger("DIK_UNDERLINE", DIK_UNDERLINE); obj->SetInteger("DIK_KANJI", DIK_KANJI); obj->SetInteger("DIK_STOP", DIK_STOP); obj->SetInteger("DIK_AX", DIK_AX); obj->SetInteger("DIK_UNLABELED", DIK_UNLABELED); obj->SetInteger("DIK_NEXTTRACK", DIK_NEXTTRACK); obj->SetInteger("DIK_NUMPADENTER", DIK_NUMPADENTER); obj->SetInteger("DIK_RCONTROL", DIK_RCONTROL); obj->SetInteger("DIK_MUTE", DIK_MUTE); obj->SetInteger("DIK_CALCULATOR", DIK_CALCULATOR); obj->SetInteger("DIK_PLAYPAUSE", DIK_PLAYPAUSE); obj->SetInteger("DIK_MEDIASTOP", DIK_MEDIASTOP); obj->SetInteger("DIK_VOLUMEDOWN", DIK_VOLUMEDOWN); obj->SetInteger("DIK_VOLUMEUP", DIK_VOLUMEUP); obj->SetInteger("DIK_WEBHOME", DIK_WEBHOME); obj->SetInteger("DIK_NUMPADCOMMA", DIK_NUMPADCOMMA); obj->SetInteger("DIK_DIVIDE", DIK_DIVIDE); obj->SetInteger("DIK_SYSRQ", DIK_SYSRQ); obj->SetInteger("DIK_RMENU", DIK_RMENU); obj->SetInteger("DIK_PAUSE", DIK_PAUSE); obj->SetInteger("DIK_HOME", DIK_HOME); obj->SetInteger("DIK_UP", DIK_UP); obj->SetInteger("DIK_PRIOR", DIK_PRIOR); obj->SetInteger("DIK_LEFT", DIK_LEFT); obj->SetInteger("DIK_RIGHT", DIK_RIGHT); obj->SetInteger("DIK_END", DIK_END); obj->SetInteger("DIK_DOWN", DIK_DOWN); obj->SetInteger("DIK_NEXT", DIK_NEXT); obj->SetInteger("DIK_INSERT", DIK_INSERT); obj->SetInteger("DIK_DELETE", DIK_DELETE); obj->SetInteger("DIK_LWIN", DIK_LWIN); obj->SetInteger("DIK_RWIN", DIK_RWIN); obj->SetInteger("DIK_APPS", DIK_APPS); obj->SetInteger("DIK_POWER", DIK_POWER); obj->SetInteger("DIK_SLEEP", DIK_SLEEP); obj->SetInteger("DIK_WAKE", DIK_WAKE); obj->SetInteger("DIK_WEBSEARCH", DIK_WEBSEARCH); obj->SetInteger("DIK_WEBFAVORITES", DIK_WEBFAVORITES); obj->SetInteger("DIK_WEBREFRESH", DIK_WEBREFRESH); obj->SetInteger("DIK_WEBSTOP", DIK_WEBSTOP); obj->SetInteger("DIK_WEBFORWARD", DIK_WEBFORWARD); obj->SetInteger("DIK_WEBBACK", DIK_WEBBACK); obj->SetInteger("DIK_MYCOMPUTER", DIK_MYCOMPUTER); obj->SetInteger("DIK_MAIL", DIK_MAIL); obj->SetInteger("DIK_MEDIASELECT", DIK_MEDIASELECT); return true; } bool Process::_LuaRegistHGEConst(LuaObject * obj) { // Math obj->SetNumber("M_PI", M_PI); obj->SetNumber("M_PI_2", M_PI_2); obj->SetNumber("M_PI_4", M_PI_4); obj->SetNumber("M_1_PI", M_1_PI); obj->SetNumber("M_2_PI", M_2_PI); obj->SetNumber("M_E", M_E); obj->SetNumber("M_LOG2E", M_LOG2E); obj->SetNumber("M_LOG10E", M_LOG10E); obj->SetNumber("M_LN2", M_LN2); obj->SetNumber("M_LN10", M_LN10); obj->SetNumber("M_PI", M_PI); obj->SetNumber("M_PI_2", M_PI_2); obj->SetNumber("M_PI_4", M_PI_4); obj->SetNumber("M_1_PI", M_1_PI); obj->SetNumber("M_2_PI", M_2_PI); obj->SetNumber("M_2_SQRTPI", M_2_SQRTPI); obj->SetNumber("M_SQRT2", M_SQRT2); obj->SetNumber("M_SQRT1_2", M_SQRT1_2); // Blend obj->SetInteger("BLEND_COLORADD", BLEND_COLORADD); obj->SetInteger("BLEND_COLORMUL", BLEND_COLORMUL); obj->SetInteger("BLEND_ALPHABLEND", BLEND_ALPHABLEND); obj->SetInteger("BLEND_ALPHAADD", BLEND_ALPHAADD); obj->SetInteger("BLEND_ZWRITE", BLEND_ZWRITE); obj->SetInteger("BLEND_NOZWRITE", BLEND_NOZWRITE); obj->SetInteger("BLEND_DEFAULT", BLEND_DEFAULT); obj->SetInteger("BLEND_DEFAULT_Z", BLEND_DEFAULT_Z); // hgeState obj->SetInteger("HGE_WINDOWED", HGE_WINDOWED); obj->SetInteger("HGE_ZBUFFER", HGE_ZBUFFER); obj->SetInteger("HGE_TEXTUREFILTER", HGE_TEXTUREFILTER); obj->SetInteger("HGE_USESOUND", HGE_USESOUND); obj->SetInteger("HGE_DONTSUSPEND", HGE_DONTSUSPEND); obj->SetInteger("HGE_HIDEMOUSE", HGE_HIDEMOUSE); obj->SetInteger("HGE_HWND", HGE_HWND); obj->SetInteger("HGE_HWNDPARENT", HGE_HWNDPARENT); obj->SetInteger("HGE_SCREENWIDTH", HGE_SCREENWIDTH); obj->SetInteger("HGE_SCREENHEIGHT", HGE_SCREENHEIGHT); obj->SetInteger("HGE_SCREENBPP", HGE_SCREENBPP); obj->SetInteger("HGE_SAMPLERATE", HGE_SAMPLERATE); obj->SetInteger("HGE_SAMPLEVOLUME", HGE_SAMPLEVOLUME); obj->SetInteger("HGE_FXVOLUME", HGE_FXVOLUME); obj->SetInteger("HGE_STREAMVOLUME", HGE_STREAMVOLUME); obj->SetInteger("HGE_FPS", HGE_FPS); obj->SetInteger("HGE_FRAMECOUNTER", HGE_FRAMECOUNTER); obj->SetInteger("HGE_FRAMESKIP", HGE_FRAMESKIP); obj->SetInteger("HGE_RENDERSKIP", HGE_RENDERSKIP); obj->SetInteger("HGE_ICON", HGE_ICON); obj->SetInteger("HGE_TITLE", HGE_TITLE); obj->SetInteger("HGE_INIFILE", HGE_INIFILE); obj->SetInteger("HGE_LOGFILE", HGE_LOGFILE); obj->SetInteger("HGE_BASSDLLFILE", HGE_BASSDLLFILE); // Input obj->SetInteger("INPUT_KEYDOWN", INPUT_KEYDOWN); obj->SetInteger("INPUT_KEYUP", INPUT_KEYUP); obj->SetInteger("INPUT_MBUTTONDOWN", INPUT_MBUTTONDOWN); obj->SetInteger("INPUT_MBUTTONUP", INPUT_MBUTTONUP); obj->SetInteger("INPUT_MOUSEMOVE", INPUT_MOUSEMOVE); obj->SetInteger("INPUT_MOUSEWHEEL", INPUT_MOUSEWHEEL); obj->SetInteger("HGEINP_SHIFT", HGEINP_SHIFT); obj->SetInteger("HGEINP_CTRL", HGEINP_CTRL); obj->SetInteger("HGEINP_ALT", HGEINP_ALT); obj->SetInteger("HGEINP_CAPSLOCK", HGEINP_CAPSLOCK); obj->SetInteger("HGEINP_SCROLLLOCK", HGEINP_SCROLLLOCK); obj->SetInteger("HGEINP_NUMLOCK", HGEINP_NUMLOCK); obj->SetInteger("HGEINP_REPEAT", HGEINP_REPEAT); obj->SetInteger("HGEK_LBUTTON", HGEK_LBUTTON); obj->SetInteger("HGEK_RBUTTON", HGEK_RBUTTON); obj->SetInteger("HGEK_MBUTTON", HGEK_MBUTTON); obj->SetInteger("HGEK_ESCAPE", HGEK_ESCAPE); obj->SetInteger("HGEK_BACKSPACE", HGEK_BACKSPACE); obj->SetInteger("HGEK_TAB", HGEK_TAB); obj->SetInteger("HGEK_ENTER", HGEK_ENTER); obj->SetInteger("HGEK_SPACE", HGEK_SPACE); obj->SetInteger("HGEK_SHIFT", HGEK_SHIFT); obj->SetInteger("HGEK_CTRL", HGEK_CTRL); obj->SetInteger("HGEK_ALT", HGEK_ALT); obj->SetInteger("HGEK_LWIN", HGEK_LWIN); obj->SetInteger("HGEK_RWIN", HGEK_RWIN); obj->SetInteger("HGEK_APPS", HGEK_APPS); obj->SetInteger("HGEK_PAUSE", HGEK_PAUSE); obj->SetInteger("HGEK_CAPSLOCK", HGEK_CAPSLOCK); obj->SetInteger("HGEK_NUMLOCK", HGEK_NUMLOCK); obj->SetInteger("HGEK_SCROLLLOCK", HGEK_SCROLLLOCK); obj->SetInteger("HGEK_PGUP", HGEK_PGUP); obj->SetInteger("HGEK_PGDN", HGEK_PGDN); obj->SetInteger("HGEK_HOME", HGEK_HOME); obj->SetInteger("HGEK_END", HGEK_END); obj->SetInteger("HGEK_INSERT", HGEK_INSERT); obj->SetInteger("HGEK_DELETE", HGEK_DELETE); obj->SetInteger("HGEK_LEFT", HGEK_LEFT); obj->SetInteger("HGEK_UP", HGEK_UP); obj->SetInteger("HGEK_RIGHT", HGEK_RIGHT); obj->SetInteger("HGEK_DOWN", HGEK_DOWN); obj->SetInteger("HGEK_0", HGEK_0); obj->SetInteger("HGEK_1", HGEK_1); obj->SetInteger("HGEK_2", HGEK_2); obj->SetInteger("HGEK_3", HGEK_3); obj->SetInteger("HGEK_4", HGEK_4); obj->SetInteger("HGEK_5", HGEK_5); obj->SetInteger("HGEK_6", HGEK_6); obj->SetInteger("HGEK_7", HGEK_7); obj->SetInteger("HGEK_8", HGEK_8); obj->SetInteger("HGEK_9", HGEK_9); obj->SetInteger("HGEK_A", HGEK_A); obj->SetInteger("HGEK_B", HGEK_B); obj->SetInteger("HGEK_C", HGEK_C); obj->SetInteger("HGEK_D", HGEK_D); obj->SetInteger("HGEK_E", HGEK_E); obj->SetInteger("HGEK_F", HGEK_F); obj->SetInteger("HGEK_G", HGEK_G); obj->SetInteger("HGEK_H", HGEK_H); obj->SetInteger("HGEK_I", HGEK_I); obj->SetInteger("HGEK_J", HGEK_J); obj->SetInteger("HGEK_K", HGEK_K); obj->SetInteger("HGEK_L", HGEK_L); obj->SetInteger("HGEK_M", HGEK_M); obj->SetInteger("HGEK_N", HGEK_N); obj->SetInteger("HGEK_O", HGEK_O); obj->SetInteger("HGEK_P", HGEK_P); obj->SetInteger("HGEK_Q", HGEK_Q); obj->SetInteger("HGEK_R", HGEK_R); obj->SetInteger("HGEK_S", HGEK_S); obj->SetInteger("HGEK_T", HGEK_T); obj->SetInteger("HGEK_U", HGEK_U); obj->SetInteger("HGEK_V", HGEK_V); obj->SetInteger("HGEK_W", HGEK_W); obj->SetInteger("HGEK_X", HGEK_X); obj->SetInteger("HGEK_Y", HGEK_Y); obj->SetInteger("HGEK_Z", HGEK_Z); obj->SetInteger("HGEK_GRAVE", HGEK_GRAVE); obj->SetInteger("HGEK_MINUS", HGEK_MINUS); obj->SetInteger("HGEK_EQUALS", HGEK_EQUALS); obj->SetInteger("HGEK_BACKSLASH", HGEK_BACKSLASH); obj->SetInteger("HGEK_LBRACKET", HGEK_LBRACKET); obj->SetInteger("HGEK_RBRACKET", HGEK_RBRACKET); obj->SetInteger("HGEK_SEMICOLON", HGEK_SEMICOLON); obj->SetInteger("HGEK_APOSTROPHE", HGEK_APOSTROPHE); obj->SetInteger("HGEK_COMMA", HGEK_COMMA); obj->SetInteger("HGEK_PERIOD", HGEK_PERIOD); obj->SetInteger("HGEK_SLASH", HGEK_SLASH); obj->SetInteger("HGEK_NUMPAD0", HGEK_NUMPAD0); obj->SetInteger("HGEK_NUMPAD1", HGEK_NUMPAD1); obj->SetInteger("HGEK_NUMPAD2", HGEK_NUMPAD2); obj->SetInteger("HGEK_NUMPAD3", HGEK_NUMPAD3); obj->SetInteger("HGEK_NUMPAD4", HGEK_NUMPAD4); obj->SetInteger("HGEK_NUMPAD5", HGEK_NUMPAD5); obj->SetInteger("HGEK_NUMPAD6", HGEK_NUMPAD6); obj->SetInteger("HGEK_NUMPAD7", HGEK_NUMPAD7); obj->SetInteger("HGEK_NUMPAD8", HGEK_NUMPAD8); obj->SetInteger("HGEK_NUMPAD9", HGEK_NUMPAD9); obj->SetInteger("HGEK_MULTIPLY", HGEK_MULTIPLY); obj->SetInteger("HGEK_DIVIDE", HGEK_DIVIDE); obj->SetInteger("HGEK_ADD", HGEK_ADD); obj->SetInteger("HGEK_SUBTRACT", HGEK_SUBTRACT); obj->SetInteger("HGEK_DECIMAL", HGEK_DECIMAL); obj->SetInteger("HGEK_F1", HGEK_F1); obj->SetInteger("HGEK_F2", HGEK_F2); obj->SetInteger("HGEK_F3", HGEK_F3); obj->SetInteger("HGEK_F4", HGEK_F4); obj->SetInteger("HGEK_F5", HGEK_F5); obj->SetInteger("HGEK_F6", HGEK_F6); obj->SetInteger("HGEK_F7", HGEK_F7); obj->SetInteger("HGEK_F8", HGEK_F8); obj->SetInteger("HGEK_F9", HGEK_F9); obj->SetInteger("HGEK_F10", HGEK_F10); obj->SetInteger("HGEK_F11", HGEK_F11); obj->SetInteger("HGEK_F12", HGEK_F12); // DI obj->SetInteger("DIKEY_PRESSED", DIKEY_PRESSED); obj->SetInteger("DIKEY_UP", DIKEY_UP); obj->SetInteger("DIKEY_DOWN", DIKEY_DOWN); obj->SetInteger("JOY_LEFT", JOY_LEFT); obj->SetInteger("JOY_RIGHT", JOY_RIGHT); obj->SetInteger("JOY_UP", JOY_UP); obj->SetInteger("JOY_DOWN", JOY_DOWN); return true; } bool Process::_LuaRegistHGEHelpConst(LuaObject * obj) { // hgeFont obj->SetInteger("HGETEXT_LEFT", HGETEXT_LEFT); obj->SetInteger("HGETEXT_RIGHT", HGETEXT_RIGHT); obj->SetInteger("HGETEXT_CENTER", HGETEXT_CENTER); obj->SetInteger("HGETEXT_HORZMASK", HGETEXT_HORZMASK); obj->SetInteger("HGETEXT_TOP", HGETEXT_TOP); obj->SetInteger("HGETEXT_BOTTOM", HGETEXT_BOTTOM); obj->SetInteger("HGETEXT_MIDDLE", HGETEXT_MIDDLE); obj->SetInteger("HGETEXT_VERTMASK", HGETEXT_VERTMASK); return true; }
[ "CBE7F1F65@120521f8-859b-11de-8382-973a19579e60" ]
[ [ [ 1, 390 ] ] ]
7dfc3145167ecfdeadb54aa63784479fad808693
5ac13fa1746046451f1989b5b8734f40d6445322
/minimangalore/Nebula2/code/contrib/nrubyserver/src/ruby/nrubyrun.cc
ac6268db5006208e762eca4832e1217480b1aa8e
[]
no_license
moltenguy1/minimangalore
9f2edf7901e7392490cc22486a7cf13c1790008d
4d849672a6f25d8e441245d374b6bde4b59cbd48
refs/heads/master
2020-04-23T08:57:16.492734
2009-08-01T09:13:33
2009-08-01T09:13:33
35,933,330
0
0
null
null
null
null
UTF-8
C++
false
false
7,316
cc
#define N_IMPLEMENTS nRubyServer //-------------------------------------------------------------------- // nrubyrun.cc -- Command evaluation and passing to ruby // // (C) 2003/4 Thomas Miskiewicz [email protected] //-------------------------------------------------------------------- #include <stdlib.h> #include <stdio.h> #include "ruby.h" #include "ruby/nrubyserver.h" #include "kernel/nfileserver2.h" #include "kernel/narg.h" extern "C" void free_d(VALUE); extern "C" VALUE cNRoot; //-------------------------------------------------------------------- /** Prompt Pass a prompt string to the interactive shell. Will be called each frame so I omitted any fancy stuff - 02-01-04 tom created */ //-------------------------------------------------------------------- nString nRubyServer::Prompt() { // no custom prompt as Prompt will be called every frame :-( nString prompt; prompt.Append("> "); return prompt; } //-------------------------------------------------------------------- /** Run Evaluate a ruby command string Result will be empty, as any errors get printed out by ruby itself for ease of use. - 02-01-04 Tom created - 11-02-04 Tom error printing for N2 */ //-------------------------------------------------------------------- bool nRubyServer::Run(const char *cmd_str, nString& result) { result.Clear(); int ret = 0; rb_p(rb_eval_string_protect((char *)cmd_str, &ret)); if (ret) { //same as rb_p but without rb_default_rs if (this->GetFailOnError()) { n_error(RSTRING(rb_obj_as_string(rb_inspect(ruby_errinfo)))->ptr); } else { n_printf(RSTRING(rb_obj_as_string(rb_inspect(ruby_errinfo)))->ptr); //n_printf(rb_default_rs); } return false; } return true; } #ifdef __cplusplus extern "C" { #endif //-------------------------------------------------------------------- /** NArg2RubyObj Converts a nebula argument into an ruby native object. TODO implement LIST Type for nebula 2 - 02-01-04 Tom created - 11-02-04 Tom N2 args */ //-------------------------------------------------------------------- VALUE NArg2RubyObj(nArg *a) { switch (a->GetType()) { case nArg::Void: return Qnil; case nArg::Int: return INT2NUM(a->GetI()); case nArg::Float: return rb_float_new(a->GetF()); case nArg::String: return rb_str_new2(a->GetS()); case nArg::Bool: return (a->GetB()==true?Qtrue:Qfalse); case nArg::Object: { nRoot* o = (nRoot *) a->GetO(); if(o) { VALUE tst = Data_Wrap_Struct(cNRoot, 0, free_d, (void *)o); return tst; } else { return Qnil; } } //case nArg::ARGTYPE_CODE: // return rb_str_new2(a->GetC()); case nArg::List: { nArg *args; int num_args = a->GetL(args); VALUE result = rb_ary_new2(num_args); for(int i = 0; i < num_args; i++) { rb_ary_push(result, NArg2RubyObj(&args[i])); } return result; } default: return Qundef; } return Qundef; } #ifdef __cplusplus } #endif //-------------------------------------------------------------------- /** RunCommand Execute a nebula command in ruby - 02-01-04 Tom created not tested to be done - 11-02-04 Tom error printing for N2 */ //-------------------------------------------------------------------- bool nRubyServer::RunCommand(nCmd *c) { //TODO nArg *arg; int num_args = c->GetNumInArgs(); c->Rewind(); VALUE rargs = Qfalse; // handle single return args (no need to create list) if (1 == num_args) { arg = c->In(); rargs = NArg2RubyObj(arg); } else { // rargs = rb_ary_new(); // more then one in arg, create an Array int i; for (i=0; i<num_args; i++) { arg = c->In(); rb_ary_push(rargs, NArg2RubyObj(arg)); //rargs[i] = NArg2RubyObj(arg); } } //rb_str_new2(c->In()->GetS()); rb_p(rb_funcall2(rb_mKernel,rb_intern(c->In()->GetS()), num_args, &rargs)); if (NIL_P(ruby_errinfo)) { //same as rb_p but without rb_default_rs if (this->GetFailOnError()) { n_error(RSTRING(rb_obj_as_string(rb_inspect(ruby_errinfo)))->ptr); } else { n_printf(RSTRING(rb_obj_as_string(rb_inspect(ruby_errinfo)))->ptr); //n_printf(rb_default_rs); } return false; } return true; } //-------------------------------------------------------------------- /** RunScript Load and evaluate a ruby script then switches over to interactive mode Result is left empty as errors get printed out by nebula itself for ease of use. - 18-12-03 Tom created - 11-02-04 Tom error printing for N2 */ //-------------------------------------------------------------------- bool nRubyServer::RunScript(const char *fname, nString& result) { char buf[N_MAXPATH]; result.Clear(); strcpy(buf,(kernelServer->GetFileServer()->ManglePath(fname).Get())); this->print_error = true; ruby_script(buf); //rb_load_file(buf); int ret =0; rb_load_protect(rb_str_new2(buf), 0, &ret); if (ret) { //rb_p(ruby_errinfo); //same as rb_p but without rb_default_rs if (this->GetFailOnError()) { n_error(RSTRING(rb_obj_as_string(rb_inspect(ruby_errinfo)))->ptr); } else { n_printf(RSTRING(rb_obj_as_string(rb_inspect(ruby_errinfo)))->ptr); //n_printf(rb_default_rs); } return false; } return true; } //-------------------------------------------------------------------- /** @brief Invoke a Ruby function. */ bool nRubyServer::RunFunction(const char *funcName, nString& result) { nString cmdStr = funcName; cmdStr.Append("()"); return this->Run(cmdStr.Get(), result); } //-------------------------------------------------------------------- /** Trigger Check for shutdown flag - 18-12-03 Tom created - 01-05-04 Tom cleaned up */ //-------------------------------------------------------------------- bool nRubyServer::Trigger(void) { if(!GetQuitRequested() && !finished) { return true; } else { return false; } } //-------------------------------------------------------------------- // EOF //--------------------------------------------------------------------
[ "BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c" ]
[ [ [ 1, 267 ] ] ]
d56bc22b2276f1f24816d046458e71ba0412639b
ad80c85f09a98b1bfc47191c0e99f3d4559b10d4
/code/inc/kernel/nfileloghandler.h
89ed8f84cddb6c899bc8c05f40d871385ccb3fdf
[]
no_license
DSPNerd/m-nebula
76a4578f5504f6902e054ddd365b42672024de6d
52a32902773c10cf1c6bc3dabefd2fd1587d83b3
refs/heads/master
2021-12-07T18:23:07.272880
2009-07-07T09:47:09
2009-07-07T09:47:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,287
h
#ifndef N_FILELOGHANDLER_H #define N_FILELOGHANDLER_H //------------------------------------------------------------------------------ /** A file based log handler class: - maintains a log file in the home: directory where ALL output is recorded (C) 2003 RadonLabs GmbH */ #ifndef N_LOGHANDLER_H #include "kernel/nloghandler.h" #endif #include "util/nstl.h" #undef N_DEFINES #define N_DEFINES nFileLogHandler #include "kernel/ndefdllclass.h" //------------------------------------------------------------------------------ class N_PUBLIC nFileLogHandler : public nLogHandler { public: /// constructor nFileLogHandler(const char* logName); /// destructor virtual ~nFileLogHandler(); /// print a message to the log dump virtual void Print(const char* msg, va_list argList); /// show an important message (may block the program until the user acks) virtual void Message(const char* msg, va_list argList); /// show an error message (may block the program until the user acks) virtual void Error(const char* msg, va_list argList); protected: stl_string logName; FILE* logFile; }; //------------------------------------------------------------------------------ #endif
[ "plushe@411252de-2431-11de-b186-ef1da62b6547" ]
[ [ [ 1, 44 ] ] ]
452d8dc9a44898ea3faae6b8a73b00d1642de0b1
299a1b0fca9e1de3858a5ebeaf63be6dc3a02b48
/tags/051101/trunk/dingus/dingus/dxutils/D3Dutil.cpp
8c1f5bc972b2bd1ac085ff8072b5c3baaacffec8
[]
no_license
BackupTheBerlios/dingus-svn
331d7546a6e7a5a3cb38ffb106e57b224efbf5df
1223efcf4c2079f58860d7fa685fa5ded8f24f32
refs/heads/master
2016-09-05T22:15:57.658243
2006-09-02T10:10:47
2006-09-02T10:10:47
40,673,143
0
0
null
null
null
null
UTF-8
C++
false
false
7,135
cpp
// -------------------------------------------------------------------------- // Dingus project - a collection of subsystems for game/graphics applications // -------------------------------------------------------------------------- #include "stdafx.h" #include "D3DUtil.h" #include "DXUtil.h" const TCHAR* dingus::convertD3DFormatToString( D3DFORMAT format ) { const TCHAR* pstr = NULL; switch( format ) { case D3DFMT_UNKNOWN: pstr = TEXT("Unknown"); break; case D3DFMT_R8G8B8: pstr = TEXT("24bit (rgb8)"); break; case D3DFMT_A8R8G8B8: pstr = TEXT("32bit (argb8)"); break; case D3DFMT_X8R8G8B8: pstr = TEXT("32bit (xrgb8)"); break; case D3DFMT_R5G6B5: pstr = TEXT("16bit (r5g6b5)"); break; case D3DFMT_X1R5G5B5: pstr = TEXT("16bit (x1rgb5)"); break; case D3DFMT_A1R5G5B5: pstr = TEXT("16bit (a1rgb5)"); break; case D3DFMT_A4R4G4B4: pstr = TEXT("16bit (argb4)"); break; case D3DFMT_R3G3B2: pstr = TEXT("8bit (r3g3b2)"); break; case D3DFMT_A8: pstr = TEXT("8bit (a8)"); break; case D3DFMT_A8R3G3B2: pstr = TEXT("16bit (a8r3g3b2)"); break; case D3DFMT_X4R4G4B4: pstr = TEXT("16bit (xrgb4)"); break; case D3DFMT_A2B10G10R10: pstr = TEXT("32bit (a2bgr10)"); break; case D3DFMT_A8B8G8R8: pstr = TEXT("32bit (abgr8)"); break; case D3DFMT_X8B8G8R8: pstr = TEXT("32bit (xbgr8)"); break; case D3DFMT_G16R16: pstr = TEXT("G16R16"); break; case D3DFMT_A2R10G10B10: pstr = TEXT("32bit (a2rgb10)"); break; case D3DFMT_A16B16G16R16: pstr = TEXT("A16B16G16R16"); break; case D3DFMT_A8P8: pstr = TEXT("A8P8"); break; case D3DFMT_P8: pstr = TEXT("P8"); break; case D3DFMT_L8: pstr = TEXT("L8"); break; case D3DFMT_A8L8: pstr = TEXT("A8L8"); break; case D3DFMT_A4L4: pstr = TEXT("A4L4"); break; case D3DFMT_V8U8: pstr = TEXT("V8U8"); break; case D3DFMT_L6V5U5: pstr = TEXT("L6V5U5"); break; case D3DFMT_X8L8V8U8: pstr = TEXT("X8L8V8U8"); break; case D3DFMT_Q8W8V8U8: pstr = TEXT("Q8W8V8U8"); break; case D3DFMT_V16U16: pstr = TEXT("V16U16"); break; case D3DFMT_A2W10V10U10: pstr = TEXT("A2W10V10U10"); break; case D3DFMT_UYVY: pstr = TEXT("UYVY"); break; case D3DFMT_YUY2: pstr = TEXT("YUY2"); break; case D3DFMT_DXT1: pstr = TEXT("DXT1"); break; case D3DFMT_DXT2: pstr = TEXT("DXT2"); break; case D3DFMT_DXT3: pstr = TEXT("DXT3"); break; case D3DFMT_DXT4: pstr = TEXT("DXT4"); break; case D3DFMT_DXT5: pstr = TEXT("DXT5"); break; case D3DFMT_D16_LOCKABLE: pstr = TEXT("D16_LOCKABLE"); break; case D3DFMT_D32: pstr = TEXT("32 z"); break; case D3DFMT_D15S1: pstr = TEXT("15 z 1 stencil"); break; case D3DFMT_D24S8: pstr = TEXT("24 z 8 stencil"); break; case D3DFMT_D24X8: pstr = TEXT("24 z"); break; case D3DFMT_D24X4S4: pstr = TEXT("24 z 4 stencil"); break; case D3DFMT_D16: pstr = TEXT("16 z"); break; case D3DFMT_L16: pstr = TEXT("L16"); break; case D3DFMT_VERTEXDATA: pstr = TEXT("VERTEXDATA"); break; case D3DFMT_INDEX16: pstr = TEXT("INDEX16"); break; case D3DFMT_INDEX32: pstr = TEXT("INDEX32"); break; case D3DFMT_Q16W16V16U16: pstr = TEXT("Q16W16V16U16"); break; case D3DFMT_MULTI2_ARGB8: pstr = TEXT("MULTI2_ARGB8"); break; case D3DFMT_R16F: pstr = TEXT("R16F"); break; case D3DFMT_G16R16F: pstr = TEXT("G16R16F"); break; case D3DFMT_A16B16G16R16F: pstr = TEXT("A16B16G16R16F"); break; case D3DFMT_R32F: pstr = TEXT("R32F"); break; case D3DFMT_G32R32F: pstr = TEXT("G32R32F"); break; case D3DFMT_A32B32G32R32F: pstr = TEXT("A32B32G32R32F"); break; case D3DFMT_CxV8U8: pstr = TEXT("CxV8U8"); break; default: pstr = TEXT("Unknown format"); break; } return pstr; } HRESULT dingus::setDeviceCursor( IDirect3DDevice9& device, HCURSOR hCursor ) { HRESULT hr = E_FAIL; ICONINFO iconinfo; bool bwCursor; IDirect3DSurface9* cursorSurface = NULL; HDC hdcColor = NULL; HDC hdcMask = NULL; HDC hdcScreen = NULL; BITMAP bm; DWORD dwWidth; DWORD dwHeightSrc; DWORD dwHeightDest; COLORREF crColor; COLORREF crMask; int x; int y; BITMAPINFO bmi; COLORREF* pcrArrayColor = NULL; COLORREF* pcrArrayMask = NULL; DWORD* pBitmap; HGDIOBJ hgdiobjOld; ZeroMemory( &iconinfo, sizeof(iconinfo) ); if( !GetIconInfo( hCursor, &iconinfo ) ) goto _end; if( 0 == GetObject((HGDIOBJ)iconinfo.hbmMask, sizeof(BITMAP), (LPVOID)&bm) ) goto _end; dwWidth = bm.bmWidth; dwHeightSrc = bm.bmHeight; if( iconinfo.hbmColor == NULL ) { bwCursor = TRUE; dwHeightDest = dwHeightSrc / 2; } else { bwCursor = FALSE; dwHeightDest = dwHeightSrc; } // Create a surface for the fullscreen cursor if( FAILED( hr = device.CreateOffscreenPlainSurface( dwWidth, dwHeightDest, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &cursorSurface, NULL ) ) ) { goto _end; } pcrArrayMask = new DWORD[dwWidth * dwHeightSrc]; ZeroMemory(&bmi, sizeof(bmi)); bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader); bmi.bmiHeader.biWidth = dwWidth; bmi.bmiHeader.biHeight = dwHeightSrc; bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount = 32; bmi.bmiHeader.biCompression = BI_RGB; hdcScreen = GetDC( NULL ); hdcMask = CreateCompatibleDC( hdcScreen ); if( hdcMask == NULL ) { hr = E_FAIL; goto _end; } hgdiobjOld = SelectObject(hdcMask, iconinfo.hbmMask); GetDIBits( hdcMask, iconinfo.hbmMask, 0, dwHeightSrc, pcrArrayMask, &bmi, DIB_RGB_COLORS ); SelectObject( hdcMask, hgdiobjOld ); if( !bwCursor ) { pcrArrayColor = new DWORD[dwWidth * dwHeightDest]; hdcColor = CreateCompatibleDC( hdcScreen ); if( hdcColor == NULL ) { hr = E_FAIL; goto _end; } SelectObject( hdcColor, iconinfo.hbmColor ); GetDIBits( hdcColor, iconinfo.hbmColor, 0, dwHeightDest, pcrArrayColor, &bmi, DIB_RGB_COLORS ); } // Transfer cursor image into the surface D3DLOCKED_RECT lr; cursorSurface->LockRect( &lr, NULL, 0 ); pBitmap = (DWORD*)lr.pBits; for( y = 0; y < dwHeightDest; y++ ) { for( x = 0; x < dwWidth; x++ ) { if( bwCursor ) { crColor = pcrArrayMask[dwWidth*(dwHeightDest-1-y) + x]; crMask = pcrArrayMask[dwWidth*(dwHeightSrc-1-y) + x]; } else { crColor = pcrArrayColor[dwWidth*(dwHeightDest-1-y) + x]; crMask = pcrArrayMask[dwWidth*(dwHeightDest-1-y) + x]; } if( crMask == 0 ) pBitmap[dwWidth*y + x] = 0xff000000 | crColor; else pBitmap[dwWidth*y + x] = 0x00000000; } } cursorSurface->UnlockRect(); // Set the device cursor if( FAILED( hr = device.SetCursorProperties( iconinfo.xHotspot, iconinfo.yHotspot, cursorSurface ) ) ) { goto _end; } hr = S_OK; _end: if( iconinfo.hbmMask != NULL ) DeleteObject( iconinfo.hbmMask ); if( iconinfo.hbmColor != NULL ) DeleteObject( iconinfo.hbmColor ); if( hdcScreen != NULL ) ReleaseDC( NULL, hdcScreen ); if( hdcColor != NULL ) DeleteDC( hdcColor ); if( hdcMask != NULL ) DeleteDC( hdcMask ); safeDeleteArray( pcrArrayColor ); safeDeleteArray( pcrArrayMask ); safeRelease( cursorSurface ); return hr; };
[ "nearaz@73827abb-88f4-0310-91e6-a2b8c1a3e93d" ]
[ [ [ 1, 196 ] ] ]
e40bf5272436f7d65537b0a03ba5aba80fda5469
b308f1edaab2be56eb66b7c03b0bf4673621b62f
/Code/CryEngine/CryCommon/IMusicSystem.h
289f25e27c6fdb0e67dcd0dfe5548d4caf93698e
[]
no_license
blockspacer/project-o
14e95aa2692930ee90d098980a7595759a8a1f74
403ec13c10757d7d948eafe9d0a95a7f59285e90
refs/heads/master
2021-05-31T16:46:36.814786
2011-09-16T14:34:07
2011-09-16T14:34:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
17,369
h
////////////////////////////////////////////////////////////////////// // // Crytek (C) 2001 // // CrySound Source Code // // File: ISound.h // Description: Music System Interface. // // History: // - August 25, 2005: seperate file created by Tomas Neuman // - August 28, 2001: Created by Marco Corbetta (as part of ISound) // ////////////////////////////////////////////////////////////////////// #include DEVIRTUALIZE_HEADER_FIX(IMusicSystem.h) #ifndef CRYSOUND_IMUSICSYSTEM_H #define CRYSOUND_IMUSICSYSTEM_H #include "StlUtils.h" #include "ISerialize.h" //#include "SerializeFwd.h" ////////////////////////////////////////////////////////////////////////// // String Iterator UNIQUE_IFACE struct IStringItVec { virtual ~IStringItVec(){} virtual bool IsEnd() = 0; virtual const char* Next() = 0; virtual void MoveFirst() = 0; virtual void AddRef() = 0; virtual void Release() = 0; }; ////////////////////////////////////////////////////////////////////////// // MusicSystem // Different layers #define MUSICLAYER_NONE 0x00000000 #define MUSICLAYER_MAIN 0x00000001 #define MUSICLAYER_RHYTHMIC 0x00000002 #define MUSICLAYER_INCIDENTAL 0x00000004 #define MUSICLAYER_STINGER 0x00000008 #define MUSICLAYER_START 0x00000010 #define MUSICLAYER_END 0x00000020 #define MUSICLAYER_MAIN_ANY 0x000000FF #define MUSICLAYER_PATTERN_BY_NAME 0x00000100 //#define MUSICLAYER_STINGER 0x00000200 // #define MUSICLAYER_ANY 0xFFFFFFFF // Type of blending enum EBlendingType { EBlend_None, EBlend_PlayOnFadePoint, EBlend_EndOnFadePoint, EBlend_FadeIn, EBlend_FadeInOnFadePoint, EBlend_FadeOut, EBlend_FadeOutOnFadePoint, EBlend_FadeOutOnMainEnd, EBlend_Any, EBlend_MAX, }; // Type of playing enum EPlayingType { EPlaying_Loop, EPlaying_Once, EPlaying_Trigger_Next, EPlaying_Stop, EPlaying_Any, EPlaying_MAX, }; // Type of ThemeFading enum EThemeFadeType { EThemeFade_StopAtOnce, EThemeFade_FadeOut, EThemeFade_PlayEnd, EThemeFade_PlayEndAtFadePoint, EThemeFade_KeepMood, EThemeFade_MAX, }; ////////////////////////////////////////////////////////////////////////// // Structures to pass as data-entry for music system ////////////////////////////////////////////////////////////////////////// struct SPatternDef; struct SMusicPatternSet; struct SMusicMood; struct SMusicTheme; struct IRenderer; // Helper integer-vector typedef std::vector<size_t> TIntVec; typedef TIntVec::iterator TIntVecIt; typedef std::vector<SPatternDef*> TPatternDefVec; typedef TPatternDefVec::iterator TPatternDefVecIt; typedef std::map<string,string,stl::less_stricmp<string> > TThemeBridgeMap; typedef TThemeBridgeMap::iterator TThemeBridgeMapIt; typedef std::map<string,SMusicMood*,stl::less_stricmp<string> > TMoodMap; typedef TMoodMap::iterator TMoodMapIt; typedef TMoodMap::const_iterator TMoodMapItConst; typedef std::vector<SMusicPatternSet*> TPatternSetVec; typedef TPatternSetVec::iterator TPatternSetVecIt; typedef std::map<string,SMusicTheme*,stl::less_stricmp<string> > TThemeMap; typedef TThemeMap::iterator TThemeMapIt; typedef TThemeMap::const_iterator TThemeMapItConst; // Pattern-definition struct SPatternDef { SPatternDef() : fLayeringVolume(1.0f), fProbabilityPoints(1.0f), nPreFadeIn(0) { } string sName; string sFilename; TIntVec vecFadePoints; float fLayeringVolume; float fProbabilityPoints; int nPreFadeIn; }; // PatternSet-Structure used by moods struct SMusicPatternSet { SMusicPatternSet() : fMinTimeout(0.0f), fMaxTimeout(0.0f), fRhythmicLayerProbabilityInPercent(0.0f), fIncidentalLayerProbabilityInPercent(0.0f), fTotalMainPatternProbability(0.0f), fTotalRhythmicPatternProbability(0.0f), fTotalIncidentalPatternProbability(0.0f), fTotalStingerPatternProbability(0.0f), nMaxSimultaneousRhythmicPatterns(1), nMaxSimultaneousIncidentalPatterns(1), bPlayRhythmicPatternSynced(false), bPlayIncidentalPatternSynced(false) { } //Pattern set float fMinTimeout; float fMaxTimeout; //Main float fTotalMainPatternProbability; // added probabilities of all containing patterns TPatternDefVec vecMainPatterns; //Rhythmic int nMaxSimultaneousRhythmicPatterns; float fRhythmicLayerProbabilityInPercent; float fTotalRhythmicPatternProbability; // added probabilities of all containing patterns bool bPlayRhythmicPatternSynced; TPatternDefVec vecRhythmicPatterns; //Incidental int nMaxSimultaneousIncidentalPatterns; float fIncidentalLayerProbabilityInPercent; float fTotalIncidentalPatternProbability; // added probabilities of all containing patterns bool bPlayIncidentalPatternSynced; TPatternDefVec vecIncidentalPatterns; //Start TPatternDefVec vecStartPatterns; //End TPatternDefVec vecEndPatterns; //Stinger TPatternDefVec vecStingerPatterns; float fTotalStingerPatternProbability; }; // Mood-Structure struct SMusicMood { SMusicMood() : nPriority(0), fFadeOutTime(0.0f), bPlaySingle(false), bPlayFromStart(false), bMainSpawned(false), bStopped(false), pCurrPatternSet(NULL), fCurrPatternSetTime(0.0f), fCurrPatternSetTimeout(0.0f), nPatternRandIndex(0), pSpawnedFromTheme(NULL) { } string sName; int nPriority; float fFadeOutTime; TPatternSetVec vecPatternSets; bool bPlaySingle; bool bPlayFromStart; bool bMainSpawned; bool bStopped; // internal SMusicPatternSet* pCurrPatternSet; float fCurrPatternSetTime; float fCurrPatternSetTimeout; int nPatternRandIndex; SMusicTheme* pSpawnedFromTheme; }; // Theme-Structure struct SMusicTheme { SMusicTheme() : fDefaultMoodTimeout(0.0f) { } string sName; TMoodMap mapMoods; TThemeBridgeMap mapBridges; // default mood string sDefaultMood; float fDefaultMoodTimeout; }; ////////////////////////////////////////////////////////////////////////// // Music interface structures. ////////////////////////////////////////////////////////////////////////// struct SMusicInfo { struct Pattern { Pattern() : sTheme(NULL), sMood(NULL), nPatternSetIndex(0), nPatternType(MUSICLAYER_NONE), sName(NULL), sFilename(NULL), pFadePoints(NULL), nFadePointsCount(0), nPreFadeIn(0), fLayeringVolume(0.0f), fProbabilityPoints(0.0f) { } const char* sTheme; const char* sMood; int nPatternSetIndex; // Index in mood pattern set. int nPatternType; // Type of pattern (Main/Rhythmic/Incidental) const char* sName; const char* sFilename; size_t* pFadePoints; int nFadePointsCount; int nPreFadeIn; float fLayeringVolume; float fProbabilityPoints; }; ////////////////////////////////////////////////////////////////////////// // PatternSet-Structure used by moods struct PatternSet { PatternSet() : fMinTimeout(0.0f), fMaxTimeout(0.0f), fTotalMainPatternProbability(0.0f), nMaxSimultaneousRhythmicPatterns(0), fRhythmicLayerProbabilityInPercent(0.0f), fTotalRhythmicPatternProbability(0.0f), bPlayRhythmicPatternSynced(false), nMaxSimultaneousIncidentalPatterns(0), fIncidentalLayerProbabilityInPercent(0.0f), fTotalIncidentalPatternProbability(0.0f), bPlayIncidentalPatternSynced(false), nMaxSimultaneousStartPatterns(0), fStartLayerProbability(0.0f), fTotalStartPatternProbability(0.0f), nMaxSimultaneousEndPatterns(0), fEndLayerProbability(0.0f), fTotalEndPatternProbability(0.0f), fTotalStingerPatternProbability(0.0f) { } float fMinTimeout; float fMaxTimeout; float fTotalMainPatternProbability; // added probabilities of all containing patterns int nMaxSimultaneousRhythmicPatterns; float fRhythmicLayerProbabilityInPercent; float fTotalRhythmicPatternProbability; // added probabilities of all containing patterns bool bPlayRhythmicPatternSynced; int nMaxSimultaneousIncidentalPatterns; float fIncidentalLayerProbabilityInPercent; float fTotalIncidentalPatternProbability; // added probabilities of all containing patterns bool bPlayIncidentalPatternSynced; int nMaxSimultaneousStartPatterns; float fStartLayerProbability; float fTotalStartPatternProbability; // added probabilities of all containing patterns int nMaxSimultaneousEndPatterns; float fEndLayerProbability; float fTotalEndPatternProbability; // added probabilities of all containing patterns float fTotalStingerPatternProbability; // added probabilities of all containing patterns }; ////////////////////////////////////////////////////////////////////////// struct Mood { Mood() : sTheme(NULL), sName(NULL), nPriority(0), fFadeOutTime(0.0f), bPlaySingle(false), pPatternSets(NULL), nPatternSetsCount(0) { } const char* sTheme; const char* sName; int nPriority; float fFadeOutTime; bool bPlaySingle; PatternSet* pPatternSets; int nPatternSetsCount; }; ////////////////////////////////////////////////////////////////////////// struct Theme { Theme() : sName(NULL), sDefaultMood(NULL), fDefaultMoodTimeout(0.0f), pBridges(NULL), nBridgeCount(0) { } const char* sName; const char* sDefaultMood; float fDefaultMoodTimeout; const char** pBridges; // Pairs of strings. int nBridgeCount; }; struct Data { Data() : pThemes(NULL), nThemes(0), pMoods(NULL), nMoods(0), pPatterns(NULL), nPatterns(0) { } Theme* pThemes; int nThemes; Mood* pMoods; int nMoods; Pattern* pPatterns; int nPatterns; }; }; ////////////////////////////////////////////////////////////////////////// #define DEFAULT_CROSSFADE_TIME 3.0f ////////////////////////////////////////////////////////////////////////// // Status struct ////////////////////////////////////////////////////////////////////////// struct SPlayingPatternsStatus { SPlayingPatternsStatus() : nInstances(0), nLayer(0), nLength(0), nSamplePos(0), nSamplesToNextFade(0), fVolume(0.0f), fPhase(0.0f), eBlendType(EBlend_None), ePlayingType(EPlaying_Any) { } string sPatternName; string sFileName; unsigned int nInstances; unsigned int nLayer; uint32 nLength; int nSamplePos; int nSamplesToNextFade; float fVolume; float fPhase; EBlendingType eBlendType; EPlayingType ePlayingType; }; typedef std::vector<SPlayingPatternsStatus> TPatternStatusVec; typedef TPatternStatusVec::iterator TPatternStatusVecIt; class CMusicPatternInstance; // Smart Pattern-Ptr typedef _smart_ptr<CMusicPatternInstance> TPatternInstancePtr; typedef std::vector<TPatternInstancePtr> TPatternInstancesVec; typedef TPatternInstancesVec::iterator TPatternInstancesVecIt; typedef TPatternInstancesVec::const_iterator TPatternInstancesVecItConst; struct SMusicSystemStatus { bool bPlaying; string sTheme; string sMood; TPatternStatusVec m_vecStatusPlayingPatterns; TPatternInstancesVec m_vecPatternInstances; }; ////////////////////////////////////////////////////////////////////////// // Main music-interface ////////////////////////////////////////////////////////////////////////// struct IMusicSystem { virtual ~IMusicSystem(){} virtual void Release() = 0; virtual void Update() = 0; virtual int GetBytesPerSample() = 0; virtual struct IMusicSystemSink* SetSink(struct IMusicSystemSink *pSink) = 0; virtual bool SetData( SMusicInfo::Data *pMusicData ) = 0; virtual void Unload() = 0; virtual void Pause(bool bPause) = 0; virtual bool IsPaused() const = 0; virtual void EnableEventProcessing(bool bEnable) = 0; // theme stuff virtual bool SetTheme(const char *pszTheme, bool bForceChange=true, bool bKeepMood=true, int nDelayInSec=-1) = 0; virtual bool EndTheme(EThemeFadeType ThemeFade=EThemeFade_FadeOut, int nForceEndLimitInSec=10, bool bEndEverything=true) = 0; virtual const char* GetTheme() const = 0; virtual IStringItVec* GetThemes() const = 0; virtual CTimeValue GetThemeTime() const = 0; // Mood stuff virtual bool SetMood(const char *pszMood, const bool bPlayFromStart=true, const bool bForceChance=false ) = 0; virtual bool SetDefaultMood(const char *pszMood) = 0; virtual const char* GetMood() const = 0; virtual IStringItVec* GetMoods(const char *pszTheme) const = 0; virtual bool AddMusicMoodEvent(const char *pszMood, float fTimeout) = 0; virtual CTimeValue GetMoodTime() const = 0; // general virtual SMusicSystemStatus* GetStatus() = 0; // retrieve status of music-system... dont keep returning pointer ! virtual void GetMemoryUsage(class ICrySizer* pSizer) const = 0; virtual void LogMsg( const int nVerbosity, const char *pszFormat, ... ) PRINTF_PARAMS(3, 4) = 0; virtual bool IsNullImplementation() const = 0; virtual bool IsPlaying() const = 0; virtual bool IsPatternFading() const = 0; ////////////////////////////////////////////////////////////////////////// //! Load music data from XML. //! @param bAddAdata if true data from XML will be added to currently loaded music data. virtual bool LoadFromXML( const char *sFilename, bool bAddData, bool bReplaceData) = 0; virtual bool LoadFromXMLNode( const XmlNodeRef root, bool bAddData, bool bReplaceData) = 0; ////////////////////////////////////////////////////////////////////////// // Editing support. ////////////////////////////////////////////////////////////////////////// virtual void UpdatePattern( SMusicInfo::Pattern *pPattern ) = 0; virtual void RenamePattern( const char *sOldName,const char *sNewName ) = 0; virtual void PlayPattern( const char *sPattern, bool bStopPrevious, bool bPlaySynched ) = 0; virtual void DeletePattern( const char *sPattern ) = 0; virtual void Silence() = 0; virtual void PlayStinger() = 0; // writes output to screen in debug virtual void DrawInformation(IRenderer* pRenderer, float xpos, float ypos) = 0; // for serialization virtual void Serialize(TSerialize ser) = 0; virtual bool SerializeInternal(bool bSave) = 0; //main update timing virtual float GetUpdateMilliseconds() = 0; }; ////////////////////////////////////////////////////////////////////////// // Sink to release data (if allocated in a different DLL) ////////////////////////////////////////////////////////////////////////// struct IMusicSystemSink { virtual ~IMusicSystemSink(){} virtual void ReleaseData(struct SMusicData *pData) = 0; }; #define UPDATE_MUSICLOGIC_IN_MS 200 enum EMusicLogicEvents { eMUSICLOGICEVENT_SET_MULTIPLIER = 0, eMUSICLOGICEVENT_SET_AI_MULTIPLIER, eMUSICLOGICEVENT_SET_AI, eMUSICLOGICEVENT_CHANGE_AI, eMUSICLOGICEVENT_SET_PLAYER, eMUSICLOGICEVENT_CHANGE_PLAYER, eMUSICLOGICEVENT_SET_GAME, eMUSICLOGICEVENT_CHANGE_GAME, eMUSICLOGICEVENT_SET_ALLOWCHANGE, eMUSICLOGICEVENT_CHANGE_ALLOWCHANGE, eMUSICLOGICEVENT_VEHICLE_ENTER, eMUSICLOGICEVENT_VEHICLE_LEAVE, eMUSICLOGICEVENT_WEAPON_MOUNT, eMUSICLOGICEVENT_WEAPON_UNMOUNT, eMUSICLOGICEVENT_SNIPERMODE_ENTER, eMUSICLOGICEVENT_SNIPERMODE_LEAVE, eMUSICLOGICEVENT_CLOAKMODE_ENTER, eMUSICLOGICEVENT_CLOAKMODE_LEAVE, eMUSICLOGICEVENT_ENEMY_SPOTTED, eMUSICLOGICEVENT_ENEMY_KILLED, eMUSICLOGICEVENT_ENEMY_HEADSHOT, eMUSICLOGICEVENT_ENEMY_OVERRUN, eMUSICLOGICEVENT_PLAYER_WOUNDED, eMUSICLOGICEVENT_PLAYER_KILLED, eMUSICLOGICEVENT_PLAYER_SPOTTED, eMUSICLOGICEVENT_PLAYER_TURRET_ATTACK, eMUSICLOGICEVENT_PLAYER_SWIM_ENTER, eMUSICLOGICEVENT_PLAYER_SWIM_LEAVE, eMUSICLOGICEVENT_EXPLOSION, eMUSICLOGICEVENT_FACTORY_CAPTURED, eMUSICLOGICEVENT_FACTORY_LOST, eMUSICLOGICEVENT_FACTORY_RECAPTURED, eMUSICLOGICEVENT_VEHICLE_CREATED, eMUSICLOGICEVENT_MAX }; #define MUSICLOGIC_FILENAME "Libs/MusicLogic/MusicLogic.xml" UNIQUE_IFACE struct IMusicLogic { virtual ~IMusicLogic(){} ////////////////////////////////////////////////////////////////////////// // Initialization ////////////////////////////////////////////////////////////////////////// virtual bool Init() = 0; virtual void Reset() = 0; virtual bool Start() = 0; virtual bool Stop() = 0; virtual void Update() = 0; // incoming events virtual void SetEvent(EMusicLogicEvents MusicEvent, const float fValue=0.0f) = 0; //IHitListener //virtual void OnHit(const HitInfo&); //virtual void OnExplosion(const ExplosionInfo&); //virtual void OnServerExplosion(const ExplosionInfo&); virtual void GetMemoryStatistics( ICrySizer * ) = 0; virtual void Serialize(TSerialize ser) = 0; // writes output to screen in debug virtual void DrawInformation(IRenderer* pRenderer, float xpos, float ypos, int nSoundInfo) = 0; }; #endif // CRYSOUND_IMUSICSYSTEM_H
[ [ [ 1, 601 ] ] ]
388b7cb08153a93f6822ec7d8d1e9378a11a7974
619941b532c6d2987c0f4e92b73549c6c945c7e5
/Source/Toxid/UI/StartDialog.h
9509944784c84d7e4d2019e8b604c7e5a879717c
[]
no_license
dzw/stellarengine
2b70ddefc2827be4f44ec6082201c955788a8a16
2a0a7db2e43c7c3519e79afa56db247f9708bc26
refs/heads/master
2016-09-01T21:12:36.888921
2008-12-12T12:40:37
2008-12-12T12:40:37
36,939,169
0
0
null
null
null
null
UTF-8
C++
false
false
2,134
h
//  // // ##### # # #### -= Nuclex Library =-  // //  # ## ## # # TitleScreen.h - Toxid title screen  // //  # ### # #  // //  # ### # # The title screen of the game  // //  # ## ## # #  // //  # # # #### R1 (C)2002-2004 Markus Ewald -> License.txt  // //  // #ifndef TOXID_UI_STARTDIALOG_H #define TOXID_UI_STARTDIALOG_H #include "Toxid/Toxid.h" #include "Nuclex/GUI/Window.h" #include "Nuclex/GUI/ButtonWidget.h" #include "Nuclex/GUI/SliderWidget.h" #include "Nuclex/GUI/TextWidget.h" #include "SigC++/SigC++.h" namespace Toxid { //  // //  Toxid::StartDialog  // //  // class StartDialog : public GUI::Window, public sigc::trackable { public: typedef SigC::Signal1<void, bool> CloseSignal; /// Constructor StartDialog(); /// Destructor virtual ~StartDialog(); // // StartDialog implementation // public: CloseSignal onClose; private: void onOk(); void onCancel(); shared_ptr<GUI::ButtonWidget> m_spOk; shared_ptr<GUI::ButtonWidget> m_spCancel; shared_ptr<GUI::TextWidget> m_spTitle; shared_ptr<GUI::SliderWidget> m_spSlider; std::vector<shared_ptr<GUI::ButtonWidget> > m_spPlanets; }; } // namespace Toxid #endif // TOXID_UI_STARTDIALOG_H
[ [ [ 1, 54 ] ] ]
e181520bb35918a2f9bd0b2ece129be82e90fcee
1c9f99b2b2e3835038aba7ec0abc3a228e24a558
/Projects/elastix/elastix_sources_v4/src/Components/Transforms/SplineKernelTransform/elxSplineKernelTransform.cxx
a7ca1a9211d9e1edaa707cd4c28141e5f81e9d42
[]
no_license
mijc/Diploma
95fa1b04801ba9afb6493b24b53383d0fbd00b33
bae131ed74f1b344b219c0ffe0fffcd90306aeb8
refs/heads/master
2021-01-18T13:57:42.223466
2011-02-15T14:19:49
2011-02-15T14:19:49
1,369,569
0
0
null
null
null
null
UTF-8
C++
false
false
662
cxx
/*====================================================================== This file is part of the elastix software. Copyright (c) University Medical Center Utrecht. All rights reserved. See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. ======================================================================*/ #include "elxSplineKernelTransform.h" elxInstallMacro( SplineKernelTransform );
[ [ [ 1, 18 ] ] ]
4f3fc5dfe6053f2eba30282208c1a5f566a27344
2b80036db6f86012afcc7bc55431355fc3234058
/src/contrib/mpg123decoder/MP3Decoder.cpp
fce682b278bb9fd1366e4d2d8df9ffa48e9086b6
[ "BSD-3-Clause" ]
permissive
leezhongshan/musikcube
d1e09cf263854bb16acbde707cb6c18b09a0189f
e7ca6a5515a5f5e8e499bbdd158e5cb406fda948
refs/heads/master
2021-01-15T11:45:29.512171
2011-02-25T14:09:21
2011-02-25T14:09:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,028
cpp
////////////////////////////////////////////////////////////////////////////// // Copyright � 2007, Daniel �nnerby // // 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 author nor the names of other contributors may // be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// #include "MP3Decoder.h" #define MP3_IN_BUFFSIZE 4096 #define MP3_OUT_BUFFSIZE 32768 MP3Decoder::MP3Decoder(void) :cachedLength(0) ,decoder(NULL) ,cachedRate(44100) ,cachedChannels(2) ,fileStream(NULL) ,lastMpg123Status(MPG123_NEED_MORE) { this->decoder = mpg123_new(NULL,NULL); this->sampleSize = this->cachedChannels*sizeof(float); } MP3Decoder::~MP3Decoder(void){ if(this->decoder){ mpg123_close(this->decoder); mpg123_delete(this->decoder); this->decoder = NULL; } } void MP3Decoder::Destroy(){ delete this; } double MP3Decoder::SetPosition(double second,double totalLength){ off_t seekToFileOffset(0); off_t seekToSampleOffset( (second*(double)this->cachedRate) ); off_t *indexOffset(NULL); off_t indexSet(0); size_t indexFill(0); int err=mpg123_index(this->decoder,&indexOffset,&indexSet,&indexFill); // Try to feed it some to be able to seek off_t seekedTo(0); int feedMore(20); while( (seekedTo=mpg123_feedseek(this->decoder,seekToSampleOffset,SEEK_SET,&seekToFileOffset))==MPG123_NEED_MORE && feedMore>0){ if(!this->Feed()){ feedMore=0; } feedMore--; } if(seekedTo>=0){ if(this->fileStream->SetPosition(seekToFileOffset)){ return second; } } return -1; } bool MP3Decoder::GetBuffer(IBuffer *buffer){ long nofSamplesMax = 1024*2; // Start by setting the buffer format buffer->SetChannels(this->cachedChannels); buffer->SetSampleRate(this->cachedRate); buffer->SetSamples(nofSamplesMax); unsigned char* currentBuffer = (unsigned char*)(buffer->BufferPointer()); bool done(false); size_t bytesWritten(0); do{ int rc = mpg123_read(this->decoder,currentBuffer,nofSamplesMax*this->sampleSize,&bytesWritten); switch(rc){ case MPG123_DONE: // Stream is finished done=true; break; case MPG123_NEED_MORE: if(!this->Feed()){ done=true; } break; case MPG123_ERR: return false; break; case MPG123_NEW_FORMAT: int encoding(0); int gfCode = mpg123_getformat(this->decoder,&this->cachedRate,&this->cachedChannels,&encoding); if( gfCode==MPG123_OK ){ this->sampleSize = this->cachedChannels*sizeof(float); // Format should not change mpg123_format_none(this->decoder); // Force the encoding to float32 int e=mpg123_format(this->decoder,this->cachedRate,this->cachedChannels,MPG123_ENC_FLOAT_32); buffer->SetChannels(this->cachedChannels); buffer->SetSampleRate(this->cachedRate); buffer->SetSamples(nofSamplesMax); } break; } }while(bytesWritten==0 && !done); buffer->SetSamples( bytesWritten/this->sampleSize ); return bytesWritten>0; } bool MP3Decoder::Feed(){ // Feed stuff to mpg123 if(this->fileStream){ unsigned char buffer[STREAM_FEED_SIZE]; musik::core::filestreams::PositionType bytesRead = this->fileStream->Read(&buffer,STREAM_FEED_SIZE); if(bytesRead){ if(mpg123_feed(this->decoder,buffer,bytesRead)==MPG123_OK){ return true; } } } return false; } bool MP3Decoder::Open(musik::core::filestreams::IFileStream *fileStream){ if(this->decoder && fileStream){ this->fileStream = fileStream; if(mpg123_open_feed(this->decoder)==MPG123_OK){ mpg123_param(this->decoder,MPG123_ADD_FLAGS,MPG123_FUZZY|MPG123_SEEKBUFFER,0); // Set filelength to decoder for better seeking mpg123_set_filesize(this->decoder,this->fileStream->Filesize()); return true; } } return false; }
[ "[email protected]@6a861d04-ae47-0410-a6da-2d49beace72e", "Urioxis@6a861d04-ae47-0410-a6da-2d49beace72e", "onnerby@6a861d04-ae47-0410-a6da-2d49beace72e" ]
[ [ [ 1, 1 ], [ 3, 5 ], [ 7, 11 ], [ 14, 15 ], [ 19, 19 ], [ 31, 33 ], [ 35, 43 ], [ 46, 125 ], [ 143, 185 ] ], [ [ 2, 2 ], [ 6, 6 ], [ 12, 13 ], [ 16, 18 ], [ 20, 30 ], [ 34, 34 ], [ 134, 134 ] ], [ [ 44, 45 ], [ 126, 133 ], [ 135, 142 ] ] ]
45a61c4457f4f6383de24768d1df4056897ff7b3
942b88e59417352fbbb1a37d266fdb3f0f839d27
/src/argss/font.hxx
5730a0435be5ec28993432684483f21a18da03f2
[ "BSD-2-Clause" ]
permissive
take-cheeze/ARGSS...
2c1595d924c24730cc714d017edb375cfdbae9ef
2f2830e8cc7e9c4a5f21f7649287cb6a4924573f
refs/heads/master
2016-09-05T15:27:26.319404
2010-12-13T09:07:24
2010-12-13T09:07:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,201
hxx
////////////////////////////////////////////////////////////////////////////////// /// ARGSS - Copyright (c) 2009 - 2010, Alejandro Marzini (vgvgf) /// 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 AUTHOR ''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 AUTHOR BE LIABLE FOR ANY /// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES /// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; /// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND /// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT /// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS /// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ////////////////////////////////////////////////////////////////////////////////// #ifndef _ARGSS_FONT_HXX_ #define _ARGSS_FONT_HXX_ //////////////////////////////////////////////////////////// /// Headers //////////////////////////////////////////////////////////// #include <argss/ruby.hxx> //////////////////////////////////////////////////////////// /// ARGSS Font namespace //////////////////////////////////////////////////////////// namespace ARGSS { namespace AFont { VALUE& getID(); void Init(); VALUE New(); VALUE rinitialize(int argc, VALUE *argv, VALUE self); VALUE rexistQ(VALUE self); VALUE rname(VALUE self); VALUE rnameE(VALUE self, VALUE name); VALUE rsize(VALUE self); VALUE rsizeE(VALUE self, VALUE size); VALUE rbold(VALUE self); VALUE rboldE(VALUE self, VALUE bold); VALUE ritalic(VALUE self); VALUE ritalicE(VALUE self, VALUE italic); VALUE rcolor(VALUE self); VALUE rcolorE(VALUE self, VALUE color); VALUE rshadow(VALUE self); VALUE rshadowE(VALUE self, VALUE shadow); VALUE rdefault_name(VALUE self); VALUE rdefault_nameE(VALUE self, VALUE default_name); VALUE rdefault_size(VALUE self); VALUE rdefault_sizeE(VALUE self, VALUE default_size); VALUE rdefault_bold(VALUE self); VALUE rdefault_boldE(VALUE self, VALUE default_bold); VALUE rdefault_italic(VALUE self); VALUE rdefault_italicE(VALUE self, VALUE default_italic); VALUE rdefault_color(VALUE self); VALUE rdefault_colorE(VALUE self, VALUE default_color); VALUE rdefault_shadow(VALUE self); VALUE rdefault_shadowE(VALUE self, VALUE default_shadow); } // namespace AFont } // namespace ARGSS #endif // _ARGSS_FONT_HXX_
[ "takeshi@takeshi-laptop.(none)", "[email protected]" ]
[ [ [ 1, 24 ], [ 27, 30 ], [ 32, 32 ], [ 73, 73 ] ], [ [ 25, 26 ], [ 31, 31 ], [ 33, 72 ], [ 74, 74 ] ] ]
73155d82499566ea4eac585e528daac92dc310a1
3d7fc34309dae695a17e693741a07cbf7ee26d6a
/aluminizerFPGA/shared/src/physics.h
83f58e5a0b3778e53f33619384a43f69d4ec8d8a
[ "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
2,606
h
#pragma once #define _USE_MATH_DEFINES #include <math.h> #include "Numerics.h" #include <string> using namespace std; namespace physics { extern const double hbar; extern const double m_e; extern const double gS; // a class to convert between SPDF lettering and integers class OrbitalL { public : OrbitalL(int iL) : L(std::min(iL, 6)) {} // OrbitalL(char cL) : L(string(spdf()).find(cL)) {} char spdf(int i) const { const char s[] = "SPDFGHI"; return s[std::min<int>(i,6)]; } operator int() const { return static_cast<int>(L); }; char symbol() const { return spdf(L); } protected: int L; }; /* a class to convert between strings and integers for polarization */ class polarization { public: polarization() : p(0) {} polarization(int i) : p(i) {} operator const int& () const { return p; } polarization& operator=(int i) { p = i; return *this; } // operator int () const { return p; } const static string SIGMA; const static string SIGMA_PLUS; const static string SIGMA_MINUS; const static string PI; private: int p; }; ostream& operator<<(ostream& o, const polarization& p); istream& operator>>(istream& i, polarization& p); typedef int sideband; /* a class to convert between strings and integers for sidebands */ /* class sideband { public: sideband(int sb) : sb(sb) {} // operator int& () { return sb; } operator int () const { return sb; } int integer() const { return sb; } // TODO private: int sb; }; */ //ostream& operator<<(ostream& o, const sideband& sb); //istream& operator>>(istream& i, sideband& sb); class line { public: line() : mFg(0), mFe(0), sb(0) {} line(const string& s) : mFg(extract_mFg(s)), mFe(extract_mFe(s)), sb(extract_sb(s)) {} line(double mFg, double mFe, int sb=0, double angle=M_PI) : mFg(mFg), mFe(mFe), sb(sb), angle(angle), Ex(0), Ey(0) {} line(double mFg, polarization p, int sb=0, double angle=M_PI) : mFg(mFg), mFe(mFg + p), sb(sb), angle(angle), Ex(0), Ey(0) {} virtual ~line() {} int delta_m() const { return static_cast<int>(mFe - mFg); } polarization Polarization() const { return static_cast<int>(mFe - mFg); } double extract_mFg(const string& s); double extract_mFe(const string& s); int extract_sb(const string& s); void InvertAngularMomentum() { mFg = -mFg; mFe = -mFe; } double mFg; double mFe; sideband sb; double f; double t; double angle; double Ex, Ey; }; }
[ "trosen@814e38a0-0077-4020-8740-4f49b76d3b44" ]
[ [ [ 1, 121 ] ] ]
ad8cc7a9bf227d69a1de580bbb94c9db37c774a1
f7d8a85f9d0c1956d64efbe96d056e338b0e0641
/Src/MainWindow.h
df3b162b2b94c36ee004fa91260ee91685d1e9f3
[]
no_license
thennequin/dlfm
6183dfeb485f860396573eda125fd61dcd497660
0b122e7042ec3b48660722e2b41ef0a0551a70a9
refs/heads/master
2020-04-11T03:53:12.856319
2008-07-06T10:17:29
2008-07-06T10:17:29
null
0
0
null
null
null
null
ISO-8859-1
C++
false
false
1,810
h
#include "wx/wx.h" #include "wx/listctrl.h" #include "wx/treectrl.h" #include "wx/splitter.h" #include "wx/toolbar.h" #include "wxVistagauge.h" #include "DLManager.h" #include "Parser.h" #include "LogWindow.h" #include "Config.h" #include "TaskBarIcon.h" #include "error.h" //#include "wx/aui/aui.h" #include "wx/wxFlatNotebook/wxFlatNotebook.h" #ifndef _MAINWINDOW_ #define _MAINWINDOW_ class MainWindow : public wxFrame { public: MainWindow(wxFrame *frame, Config *config/*, const wxString& title, int x, int y, int w, int h*/); ~MainWindow(); void AttachDLManager(DLManager *manager); void AttachTaskBarIcon(TaskBarIcon *icon); inline wxListCtrl *GetListCtrl() { return mList; } inline wxFlatNotebook *GetNotebook() { return book; } void AddDownload(wxString URL=""); void StartDownload(); void StopDownload(); void DeleteDownload(); void OnLeftClick(wxCommandEvent &event); void OnIdle(wxIdleEvent &event); void OnTimer(wxTimerEvent &event); void OnClose(wxCloseEvent &event); void OnIconize(wxIconizeEvent &event); void OnCopyData(wxEvent &event); // Pour récupérer le WM_COPYDATA WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); void ShowLog(bool show=true); wxFrame *GetLogWindow() { return LogWin; } enum { ID_ADD, ID_START, ID_STOP, ID_DELETE, ID_TIMER, ID_MAX }; private: DECLARE_EVENT_TABLE() TaskBarIcon *mTaskBarIcon; Config *mConfig; LogWindow *LogWin; wxPanel *mPanel; wxTreeCtrlBase *mGroup; wxPanel *mPanelList; wxListCtrl *mList; wxFlatNotebook *book; wxToolBar *mToolBar; wxSplitterWindow *mSplitter; DLManager *mDLManager; wxVistaGauge *mGauge; long time; wxTimer Timer; }; #endif
[ "CameleonTH@0c2b0ced-2a4c-0410-b056-e1a948518b24" ]
[ [ [ 1, 94 ] ] ]
4c8a716bfba9cc8e25b3041c6201fa18e90e6596
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/exporter/3dsplugin/src/n3dsmaterial/nabstractpropbuilder.cc
2bee889a35355417bed7fdde40b22ce9b3110114
[]
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
12,605
cc
#include "precompiled/pchn3dsmaxexport.h" #pragma warning( push, 3 ) #include "Max.h" #pragma warning( pop ) #include "n3dsmaterial/nabstractpropbuilder.h" #include "kernel/nkernelserver.h" #include "nscene/nscenenode.h" #include "nmaterial/nmaterialnode.h" nClass* nAbstractPropBuilder::nmaterialnode = 0; nClass* nAbstractPropBuilder::nsurfacenode = 0; nAbstractPropBuilder::nAbstractPropBuilder() : thisType(nAbstractPropBuilder::NONE), stringValid(false), matTypeIsValid(false) { n_assert(nKernelServer::ks); nmaterialnode = nKernelServer::ks->FindClass("nmaterialnode"); n_assert(nmaterialnode); nsurfacenode = nKernelServer::ks->FindClass("nsurfacenode"); n_assert(nsurfacenode); } int __cdecl nAbstractPropBuilder::TextureSorter(const varTexture* elm0, const varTexture* elm1) { return strcmp(elm0->varName.Get(), elm1->varName.Get() ); } int __cdecl nAbstractPropBuilder::AnimSorter( const nString* elm0, const nString* elm1) { n_assert(elm0); n_assert(elm1); return strcmp( elm0->Get(), elm1->Get() ); } int __cdecl nAbstractPropBuilder::FloatSorter(const varFloat* elm0, const varFloat* elm1) { return strcmp(elm0->varName.Get(), elm1->varName.Get() ); } int __cdecl nAbstractPropBuilder::IntSorter(const varInt* elm0, const varInt* elm1) { return strcmp(elm0->varName.Get(), elm1->varName.Get() ); } int __cdecl nAbstractPropBuilder::VectorSorter(const varVector* elm0, const varVector* elm1) { return strcmp(elm0->varName.Get(), elm1->varName.Get() ); } int __cdecl nAbstractPropBuilder::ShaderSorter(const varShader* elm0, const varShader* elm1) { return strcmp(elm0->varName.Get(), elm1->varName.Get() ); } void nAbstractPropBuilder::SetTexture ( const varTexture& var) { this->stringValid = false; varTexture var2(var); var2.texName.ToLower(); this->textures.Append ( var ); } const nAbstractPropBuilder::nSortedTextures& nAbstractPropBuilder::GetTextureArray() const { return this->textures; } nAbstractPropBuilder::nSortedTextures& nAbstractPropBuilder::GetTextureArray() { return this->textures; } void nAbstractPropBuilder::SetInt ( const varInt& var) { this->stringValid = false; this->integers.Append( var ); } void nAbstractPropBuilder::SetFloat ( const varFloat& var) { this->stringValid = false; this->floats.Append( var ); } void nAbstractPropBuilder::SetVector ( const varVector& var) { this->stringValid = false; this->vectors.Append( var ); } void nAbstractPropBuilder::SetAnim ( const nString& pathAnim) { this->stringValid = false; this->anims.Append(pathAnim); } void nAbstractPropBuilder::SetShader ( const varShader& var) { n_assert( this->thisType == NONE || this->thisType == NSURFACE); this->stringValid = false; this->thisType = NSURFACE; this->shaders.Append( var ); } void nAbstractPropBuilder::SetMaterial( const nMatTypePropBuilder& val) { n_assert( this->thisType == NONE || this->thisType == NMATERIAL ); this->stringValid = false; this->thisType = NMATERIAL; this->matType = val; this->matTypeIsValid = true; } //------------------------------------------------------------------------------ /** Set type Libaray. @parama val. The original material type for future conversion */ void nAbstractPropBuilder::SetMatType( const nMatTypePropBuilder& val) { n_assert( this->thisType == NONE || this->thisType == NMATERIAL || this->thisType == SHADERTYPELIBRARY ); this->stringValid = false; this->matType = val; this->matTypeIsValid = true; } //------------------------------------------------------------------------------ /** Set type Libaray. @param name The name's material in Library @parama val. The original material type for future conversion */ void nAbstractPropBuilder::SetMaterialTypeFromLibrary( const char* name , const nMatTypePropBuilder& val) { n_assert( this->thisType == NONE || this->thisType == SHADERTYPELIBRARY ); this->stringValid = false; this->thisType = SHADERTYPELIBRARY; this->matType = val; this->matTypeIsValid = true; this->materialTypeNameInLibrary = name; } //------------------------------------------------------------------------------ /** Set type Libaray. @param name The name's material in Library @parama val. The original material type for future conversion */ void nAbstractPropBuilder::SetMaterialTypeFromLibrary( const char* name) { n_assert( this->thisType == NONE || this->thisType == SHADERTYPELIBRARY ); this->stringValid = false; this->thisType = SHADERTYPELIBRARY; this->materialTypeNameInLibrary = name; } //------------------------------------------------------------------------------ /** */ const char* nAbstractPropBuilder::GetMaterialTypeName() const { return this->materialTypeNameInLibrary.Get(); } //------------------------------------------------------------------------------ /** */ bool nAbstractPropBuilder::IsInvalidShader() const { n_assert ( this->thisType == SHADERTYPELIBRARY ); return (this->materialTypeNameInLibrary.IsEmpty()) || (this->materialTypeNameInLibrary == "invalid" ); } //------------------------------------------------------------------------------ /** */ bool nAbstractPropBuilder::IsCustomShader() const { return (this->materialTypeNameInLibrary == "custom" ); } const char* nAbstractPropBuilder::GetUniqueString() { int idx; if (! this->stringValid ) { char buf[255]; stringKey=""; switch (thisType) { case NONE: stringKey+="NONE#"; break; case NMATERIAL: stringKey+="NMATERIAL#";//+material+"/"; if (this->matTypeIsValid) { stringKey += this->matType.GetUniqueString(); stringKey +="/"; } break; case NSURFACE: stringKey+="NSURFACE#"; for (idx = 0; idx < shaders.Size() ; idx ++) { varShader& shader = shaders[idx]; stringKey+= shader.varName + "." + shader.val+"/"; } break; case SHADERTYPELIBRARY: stringKey+="SHADERLIBRARY#"; stringKey+=this->materialTypeNameInLibrary; // If the material is custom get the matType properties if (this->matTypeIsValid && (this->IsInvalidShader() || this->IsCustomShader() ) ) { stringKey += this->matType.GetUniqueString(); stringKey +="/"; } } stringKey+="TEX#"; for (idx=0; idx < textures.Size() ; idx++) { varTexture& texture = textures[idx]; stringKey += texture.varName +"." + texture.texName + "/"; } stringKey+="INT#"; for ( idx=0; idx < integers.Size(); idx++) { varInt& integer = integers[idx]; sprintf(buf,".%i#", integer.val); stringKey += integer.varName + buf; } stringKey+="FLOAT#"; for (idx=0; idx < floats.Size(); idx ++) { varFloat& var = floats[idx]; sprintf(buf,".%f#", var.val ); stringKey += var.varName + buf; } stringKey+="VECTOR#"; for (idx = 0; idx< vectors.Size(); idx ++) { varVector& var = vectors[idx]; sprintf(buf,".%f_%f_%f_%f#", var.val.x, var.val.y, var.val.z, var.val.w); stringKey += var.varName + buf; } stringKey+="ANIMS$"; for (idx = 0 ; idx < anims.Size() ; idx ++) { stringKey += anims[idx] + "$"; } this->stringValid = true; } return this->stringKey.Get(); } void nAbstractPropBuilder::SetTo( nAbstractShaderNode* node) { n_assert(nKernelServer::ks); int idx; switch (thisType) { case NONE: break; case NMATERIAL: if ( node->IsA(nmaterialnode)) { //nMaterialNode* MaterialNode = (nMaterialNode*) node; //MaterialNode->SetMaterial( this->material.Get() ); } break; case NSURFACE: if ( node->IsA(nsurfacenode) ) { nSurfaceNode* SurfaceNode = (nSurfaceNode*) node; for (idx = 0; idx < shaders.Size() ; idx ++) { varShader& var = shaders[idx]; SurfaceNode->SetShader( nVariableServer::StringToFourCC(var.varName.Get()) , var.val.Get() ); } } break; case SHADERTYPELIBRARY: break; } for (idx = 0; idx < textures.Size() ; idx ++) { varTexture& var = textures[idx]; node->SetTexture( nShaderState::StringToParam( var.varName.Get()), var.texName.Get() ); } for (idx = 0; idx < floats.Size(); idx ++) { varFloat& var = floats[idx]; node->SetFloat( nShaderState::StringToParam( var.varName.Get()), var.val); } for (idx = 0; idx < integers.Size(); idx++) { varInt& var = integers[idx]; node->SetInt( nShaderState::StringToParam( var.varName.Get()) , var.val); } for (idx = 0; idx < vectors.Size(); idx++) { varVector& var = vectors[idx]; node->SetVector( nShaderState::StringToParam( var.varName.Get() ), var.val); } for (idx = 0 ; idx < anims.Size() ; idx ++) { node->AddAnimator( anims[idx].Get() ); } } void nAbstractPropBuilder::operator +=(const nAbstractPropBuilder& rhs) { switch (rhs.thisType) { case NONE: break; case NMATERIAL: if (this->thisType == NONE || this->thisType == NMATERIAL) { this->thisType = NMATERIAL; if (rhs.matTypeIsValid) { this->matTypeIsValid = true; this->matType += rhs.matType; } } break; case NSURFACE: if (this->thisType == NONE || this->thisType == NSURFACE) { this->thisType = NSURFACE; this->shaders += rhs.shaders; } break; case SHADERTYPELIBRARY: if (this->thisType == NONE || this->thisType == SHADERTYPELIBRARY) { this->thisType = SHADERTYPELIBRARY; this->matTypeIsValid = true; this->matType += rhs.matType; if ( this->thisType == NONE ) { this->materialTypeNameInLibrary = rhs.materialTypeNameInLibrary; } } } this->textures+= rhs.textures; this->integers+= rhs.integers; this->floats+= rhs.floats; this->vectors+= rhs.vectors; this->stringValid = false; } const char* nAbstractPropBuilder::GetNameClass() { switch (thisType ) { case nAbstractPropBuilder::NONE: return "nabstractshadernode"; break; case nAbstractPropBuilder::NMATERIAL : return "nmaterialnode"; break; case nAbstractPropBuilder::NSURFACE : return "nsurfacenode"; break; case nAbstractPropBuilder::SHADERTYPELIBRARY : return "nmaterialnode"; break; } return ""; } void nAbstractPropBuilder::Reduce() { //@ todo remove unnecesary variables, textures , etc.... by material properties }
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 460 ] ] ]
d7f767aa152c062f544cbe106c7bdb8b6f32c703
4dd44d686f1b96f8e6edae3769369a89013f6bc1
/ocass/liboca/ca_inject.cpp
748683b333d9af767ce12fdd03f70dfb5f4bc6d2
[]
no_license
bactq/ocass
e1975533a69adbd1b4d1f9fd1bd88647039fff82
116565ea7c554b11b0a696f185d3a6376e0161dc
refs/heads/master
2021-01-10T14:04:02.179429
2007-07-14T16:03:23
2007-07-14T16:03:23
45,017,357
0
0
null
null
null
null
UTF-8
C++
false
false
4,953
cpp
/* * OCASS - Microsoft Office Communicator Assistant * (http://code.google.com/p/ocass/) * * Copyright (C) 2007 Le Xiongjia * * 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, see <http://www.gnu.org/licenses/>. * * Le Xiongjia ([email protected] [email protected]) * */ #include "ca_inject.h" #include "ca_tlhlp.h" #include "dbghelp.h" static HMODULE ModuleFromAddress(PVOID pv) { MEMORY_BASIC_INFORMATION mbi; return ((VirtualQuery(pv, &mbi, sizeof(mbi)) != 0) ? (HMODULE) mbi.AllocationBase : NULL); } // The highest private memory address (used for Windows 98 only) PVOID sm_pvMaxAppAddr = NULL; const BYTE cPushOpCode = 0x68; // The PUSH opcode on x86 platforms void ReplaceIATEntryInOneMod(PCSTR pszCalleeModName, PROC pfnCurrent, PROC pfnNew, HMODULE hmodCaller) { // Get the address of the module's import section ULONG ulSize; PIMAGE_IMPORT_DESCRIPTOR pImportDesc = (PIMAGE_IMPORT_DESCRIPTOR) ImageDirectoryEntryToData(hmodCaller, TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &ulSize); if (pImportDesc == NULL) return; // This module has no import section // Find the import descriptor containing references to callee's functions for (; pImportDesc->Name; pImportDesc++) { PSTR pszModName = (PSTR) ((PBYTE) hmodCaller + pImportDesc->Name); if (lstrcmpiA(pszModName, pszCalleeModName) == 0) break; // Found } if (pImportDesc->Name == 0) return; // This module doesn't import any functions from this callee // Get caller's import address table (IAT) for the callee's functions PIMAGE_THUNK_DATA pThunk = (PIMAGE_THUNK_DATA) ((PBYTE) hmodCaller + pImportDesc->FirstThunk); // Replace current function address with new function address for (; pThunk->u1.Function; pThunk++) { // Get the address of the function address PROC* ppfn = (PROC*) &pThunk->u1.Function; // Is this the function we're looking for? BOOL fFound = (*ppfn == pfnCurrent); if (!fFound && (*ppfn > sm_pvMaxAppAddr)) { // If this is not the function and the address is in a shared DLL, // then maybe we're running under a debugger on Windows 98. In this // case, this address points to an instruction that may have the // correct address. PBYTE pbInFunc = (PBYTE) *ppfn; if (pbInFunc[0] == cPushOpCode) { // We see the PUSH instruction, the real function address follows ppfn = (PROC*) &pbInFunc[1]; // Is this the function we're looking for? fFound = (*ppfn == pfnCurrent); } } if (fFound) { // The addresses match, change the import section address WriteProcessMemory(GetCurrentProcess(), ppfn, &pfnNew, sizeof(pfnNew), NULL); return; // We did it, get out } } } CA_DECLARE(void) CA_ReplaceIATEntryInAllMods(PCSTR pszCalleeModName, PROC pfnCurrent, PROC pfnNew, BOOL fExcludeAPIHookMod) { HMODULE hmodThisMod = fExcludeAPIHookMod ? ModuleFromAddress(CA_ReplaceIATEntryInAllMods) : NULL; // Get the list of modules in this process CToolhelp th(TH32CS_SNAPMODULE, GetCurrentProcessId()); MODULEENTRY32 me = { sizeof(me) }; for (BOOL fOk = th.ModuleFirst(&me); fOk; fOk = th.ModuleNext(&me)) { // NOTE: We don't hook functions in our own module if (me.hModule != hmodThisMod) { // Hook this function in this module ReplaceIATEntryInOneMod(pszCalleeModName, pfnCurrent, pfnNew, me.hModule); } } } CA_DECLARE(CAErrno) CA_ReplaceAPI(const TCHAR *pszModName, const TCHAR *pszAPIName, PROC pNewFunc, PROC *pOldFunc) { CAErrno funcErr = CA_ERR_SUCCESS; HMODULE hMod = NULL; hMod = GetModuleHandle(pszModName); if (NULL == hMod) { funcErr = CA_ERR_FATAL; goto EXIT; } *pOldFunc = GetProcAddress(hMod, pszAPIName); if (NULL == *pOldFunc) { funcErr = CA_ERR_FATAL; goto EXIT; } CA_ReplaceIATEntryInAllMods(pszModName, *pOldFunc, pNewFunc, FALSE); EXIT: return funcErr; }
[ "lexiongjia@4b591cd5-a833-0410-8603-c1928dc92378" ]
[ [ [ 1, 150 ] ] ]
e3b64c168bb0d741b16d91003709635af6814d2e
1fab2f171271db026d5a12d9f9e08b5dc2021ce7
/pqueue/pqueue/HeapUtils.h
afa19a0be8f4bc6dba3dcbbc843768df1832cc29
[]
no_license
softwaredoug/CxxHeap
e35ee853120ee9313cac2da6fd1192fdb487501b
a7bce829d4a9311f190a50f980124d3fafe1314b
refs/heads/master
2021-01-22T13:51:39.362810
2011-02-21T02:14:30
2011-02-21T02:14:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,233
h
//******************************************************************** // FILE NAME: HeapUtils.h // // DESCRIPTION: Set of utility functions to be applied // on heaps //********************************************************************* #ifndef HEAP_UTILS_20100823_H #define HEAP_UTILS_20100823_H namespace pqueue { //************************************************************************ //! @details //! Empty one heap and place it's elements into the destination heap //! //! @param[in,out] src //! src heap that will be emptied //! @param[out] dest //! dest heap that will hold all of src's elems //! //! @return void //! //!************************************************************************ template <class T> void Reheapify(CHeap<T>&dest, CHeap<T>&src) { //! @remark //! get the size first, if we are stupidly reheapifying to //! ourselves and are doing while (src.GetSize() > 0) then //! we will go into an infinite loop because we constantly //! pop and reinsert into ourselves unsigned int currSize = src.GetSize(); while (currSize > 0) { dest.Insert( src.PeekTop() ); src.PopTop(); --currSize; } } } #endif
[ [ [ 1, 42 ] ] ]
d9d4aee53ebe71ba5e6b9d23fdbbe45a1b67436e
de0881d85df3a3a01924510134feba2fbff5b7c3
/apps/moreExamples/contourAnalysisExample/src/contourAnalysis.cpp
00dd94e5fb50e90b73433a3a5533557c95cc3d21
[]
no_license
peterkrenn/ofx-dev
6091def69a1148c05354e55636887d11e29d6073
e08e08a06be6ea080ecd252bc89c1662cf3e37f0
refs/heads/master
2021-01-21T00:32:49.065810
2009-06-26T19:13:29
2009-06-26T19:13:29
146,543
1
1
null
null
null
null
UTF-8
C++
false
false
4,610
cpp
#include "contourAnalysis.h" //----------------------------------------- float getOrientation( vector <ofPoint> & contour ) { CvMoments* myMoments = (CvMoments*)malloc( sizeof(CvMoments) ); // Allocate storage CvMemStorage* storage = cvCreateMemStorage(0); CvSeq* seq = cvCreateSeq( CV_SEQ_POLYGON, sizeof(CvContour),sizeof(CvPoint), storage ); for( unsigned int i = 0; i < contour.size(); i++) { CvPoint pt = cvPoint(contour[i].x,contour[i].y); cvSeqPush( seq, &pt ); } cvMoments( seq, myMoments ); double cm20 = cvGetCentralMoment(myMoments, 2, 0); double cm02 = cvGetCentralMoment(myMoments, 0, 2); double cm11 = cvGetCentralMoment(myMoments, 1, 1); if (cm11 == 0.0f) cm11 = 0.00001f; float d = (cm20 - cm02); float b = d/cm11; float quadratic = ((-1.0f*b) + sqrtf(b*b + 4.0f))/2.0f; float theta = atanf(quadratic); if (((d < 0) && (quadratic < 1.0f)) || ((d > 0) && (quadratic > 1.0f))) { theta += HALF_PI;} // Free the storage memory. // Warning: do this inside this function otherwise you get a strange memory leak if (storage != NULL) { cvReleaseMemStorage(&storage);} free( myMoments); return theta; } //----------------------------------------- int getIndexOfBlobIAmIn( vector<ofxCvBlob> & blobs, ofPoint pt ) { for( unsigned int i = 0; i < blobs.size(); i++) { if( isPointInsideMe( pt.x, pt.y, blobs[i].pts) ) return i; } return -1; } //----------------------------------------- bool isPointInsideMe(float x, float y, vector <ofPoint> & pts) { // code via Zach Lieberman via Randolph Franklin... int i, j, c = 0; int nPts = pts.size(); for (i = 0, j = nPts-1; i < nPts; j = i++) { if ((((pts[i].y <= y) && (y < pts[j].y)) || ((pts[j].y <= y) && (y < pts[i].y))) && (x < (pts[j].x - pts[i].x) * (y - pts[i].y) / (pts[j].y - pts[i].y) + pts[i].x)) c = !c; } return (bool) c; } //----------------------------------------- void fitEllipse( vector <ofPoint> & contour, CvBox2D32f & box ) { CvPoint2D32f* pointArray; // Alloc memory for contour point set. pointArray = (CvPoint2D32f*)malloc( contour.size()*sizeof(CvPoint2D32f) ); for( unsigned int i = 0; i < contour.size(); i++) { pointArray[i].x = contour[i].x; pointArray[i].y = contour[i].y; } // Fit ellipse cvFitEllipse(pointArray, contour.size(), &box); free(pointArray); } void drawBlob( float x, float y, ofxCvBlob & blob ) { // ---------------------------- draw the bounding rectangle glPushMatrix(); glTranslatef( x, y, 0.0 ); // ---------------------------- draw the blobs ofBeginShape(); for( int j=0; j<blob.nPts; j++ ) { ofVertex( blob.pts[j].x, blob.pts[j].y ); } ofEndShape(); glPopMatrix(); } void findLines(vector <ofPoint> & pts, vector<ofxPoint4f> & lines, float angleThreshold,float minLen, int res) { //float angleLast = 0.f; //float angle = 0.f; int startPt = pts.size()-1; int lastPt = pts.size()-1; lines.clear(); if( (int)pts.size() > res) { ofxVec2f lineAB, lineCB; for( int i = pts.size()-1; i >= 0; i-= res) { ofxVec2f ptA = ofxVec2f( pts[startPt].x, pts[startPt].y ) ; ofxVec2f ptB = ofxVec2f( pts[lastPt].x, pts[lastPt].y ) ; ofxVec2f ptC = ofxVec2f( pts[i].x, pts[i].y ) ; lineAB = ptB - ptA; lineCB = ptC - ptB; lineAB = lineAB.normalized(); lineCB = lineCB.normalized(); float dot = lineAB.x * lineCB.x + lineAB.y * lineCB.y; float cross = lineAB.x * lineCB.y - lineAB.y * lineCB.x; float theta = acos(dot); if (cross < 0) { theta = 0-theta; } if( theta > DEG_TO_RAD*angleThreshold ) { float len = (ptA - ptB).length(); if( len > minLen ) lines.push_back( ofxPoint4f( pts[startPt].x, pts[startPt].y, pts[lastPt].x, pts[lastPt].y ) ); startPt = lastPt; lastPt = i; }else { lastPt = i; } } lines.push_back( ofxPoint4f( pts[startPt].x, pts[startPt].y, pts[lastPt].x, pts[lastPt].y ) ); } }
[ [ [ 1, 175 ] ] ]
435d83d58e22def55788f393fa872e5de3301eef
ef23e388061a637f82b815d32f7af8cb60c5bb1f
/src/mame/includes/dec0.h
37826ba4a6cb0dbf4e6eba8dc855559eff507ae4
[]
no_license
marcellodash/psmame
76fd877a210d50d34f23e50d338e65a17deff066
09f52313bd3b06311b910ed67a0e7c70c2dd2535
refs/heads/master
2021-05-29T23:57:23.333706
2011-06-23T20:11:22
2011-06-23T20:11:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,871
h
class dec0_state : public driver_device { public: dec0_state(running_machine &machine, const driver_device_config_base &config) : driver_device(machine, config) { } UINT8 m_automat_adpcm_byte; int m_automat_msm5205_vclk_toggle; UINT16 *m_ram; UINT8 *m_robocop_shared_ram; int m_GAME; int m_i8751_return; int m_i8751_command; int m_slyspy_state; int m_share[0xff]; int m_hippodrm_msb; int m_hippodrm_lsb; UINT8 m_i8751_ports[4]; UINT16 *m_spriteram; UINT16 *m_buffered_spriteram; UINT16 m_pri; }; /*----------- defined in video/dec0.c -----------*/ /* Video emulation definitions */ VIDEO_START( dec0 ); VIDEO_START( dec0_nodma ); SCREEN_UPDATE( hbarrel ); SCREEN_UPDATE( baddudes ); SCREEN_UPDATE( birdtry ); SCREEN_UPDATE( robocop ); SCREEN_UPDATE( hippodrm ); SCREEN_UPDATE( slyspy ); SCREEN_UPDATE( midres ); WRITE16_HANDLER( dec0_priority_w ); WRITE16_HANDLER( dec0_update_sprites_w ); WRITE16_HANDLER( dec0_paletteram_rg_w ); WRITE16_HANDLER( dec0_paletteram_b_w ); READ8_HANDLER( dec0_pf3_data_8bit_r ); WRITE8_HANDLER( dec0_pf3_data_8bit_w ); WRITE8_HANDLER( dec0_pf3_control_8bit_w ); /*----------- defined in machine/dec0.c -----------*/ READ16_HANDLER( dec0_controls_r ); READ16_HANDLER( dec0_rotary_r ); READ16_HANDLER( midres_controls_r ); READ16_HANDLER( slyspy_controls_r ); DRIVER_INIT( slyspy ); DRIVER_INIT( hippodrm ); DRIVER_INIT( robocop ); DRIVER_INIT( baddudes ); DRIVER_INIT( hbarrel ); DRIVER_INIT( birdtry ); extern void dec0_i8751_write(running_machine &machine, int data); extern void dec0_i8751_reset(running_machine &machine); READ8_HANDLER( hippodrm_prot_r ); WRITE8_HANDLER( dec0_mcu_port_w ); READ8_HANDLER( dec0_mcu_port_r ); WRITE8_HANDLER( hippodrm_prot_w ); READ8_HANDLER( hippodrm_shared_r ); WRITE8_HANDLER( hippodrm_shared_w );
[ "Mike@localhost" ]
[ [ [ 1, 72 ] ] ]
9603f4abc44a01e5c14b9aa24062a0ad92cf83b9
82e8d2fca1858c076ea1593ed0364583356789dd
/atask/Attack.cpp
0a3a7bec59fbdb8934273bae6b9c4e96b823015c
[]
no_license
slogic/E323AI
1ddbf179d1edaf49c460a2726f21794ceb39f141
dfd540283198b12b3d70907e279df33843c1ac99
refs/heads/master
2021-01-18T12:20:39.082252
2011-01-09T18:37:11
2011-01-09T18:37:11
489,916
0
0
null
null
null
null
UTF-8
C++
false
false
3,353
cpp
#include "Attack.h" #include "../CGroup.h" #include "../CUnitTable.h" #include "../CDefenseMatrix.h" #include "../CPathfinder.h" AttackTask::AttackTask(AIClasses *_ai, int target, CGroup &group): ATask(_ai) { const UnitDef *eud = ai->cbc->GetUnitDef(target); this->t = TASK_ATTACK; this->target = target; this->pos = ai->cbc->GetUnitPos(target); if (eud) this->enemy = eud->humanName; targetAlt = -1; addGroup(group); } bool AttackTask::onValidate() { CGroup *group = firstGroup(); if (targetAlt >= 0) { if (ai->cbc->IsUnitCloaked(targetAlt) || !group->canAttack(targetAlt)) { group->stop(); } } const UnitDef *eud = ai->cbc->GetUnitDef(target); if (eud == NULL) return false; if (!isMoving) { if (ai->cbc->IsUnitCloaked(target)) return false; return true; } if (!group->canAttack(target)) return false; // don't chase scout groups too long if they are out of base... bool scoutGroup = (group->cats&SCOUTER).any(); if (!scoutGroup && lifeTime() > 20.0f) { const unitCategory ecats = UC(eud->id); if ((ecats&SCOUTER).any() && !ai->defensematrix->isPosInBounds(pos)) return false; } float targetDistance = pos.distance2D(group->pos()); if (targetDistance > 1000.0f) return true; // too far to panic if (ai->cbc->IsUnitCloaked(target)) return false; bool isBaseThreat = ai->defensematrix->isPosInBounds(pos); // if there is no threat to our base then prevent useless attack for groups // which are not too cheap if (!isBaseThreat && (group->costMetal / group->units.size()) >= 100.0f) { float threatRange; if (scoutGroup) threatRange = 300.0f; else threatRange = 0.0f; if (group->getThreat(pos, threatRange) > group->strength) return false; } return true; } void AttackTask::onUpdate() { CGroup *group = firstGroup(); if (group->isMicroing() && group->isIdle()) { targetAlt = -1; // for sure group->micro(false); } if (isMoving) { /* Keep tracking the target */ pos = ai->cbc->GetUnitPos(target); float3 gpos = group->pos(); float dist = gpos.distance2D(pos); float range = group->getRange(); /* See if we can attack our target already */ if (dist <= range) { bool canAttack = true; /* // for ground units prevent shooting across hill... if ((group->cats&AIR).none()) { // FIXME: improve dist = ai->pathfinder->getPathLength(*group, pos); canAttack = (dist <= range * 1.1f); } */ if (canAttack) { if ((group->cats&BUILDER).any()) group->reclaim(target); else group->attack(target); isMoving = false; ai->pathfinder->remove(*group); group->micro(true); } } } /* See if we can attack a target we found on our path */ if (!(group->isMicroing() || urgent())) { if ((group->cats&BUILDER).any()) resourceScan(); // builders should not be too aggressive else enemyScan(targetAlt); } } void AttackTask::toStream(std::ostream& out) const { out << "AttackTask(" << key << ") target(" << enemy << ") "; CGroup *group = firstGroup(); if (group) out << (*group); } void AttackTask::onEnemyDestroyed(int enemy, int attacker) { if (target == enemy) { LOG_II("AttackTask::onEnemyDestroyed") remove(); } }
[ [ [ 1, 138 ] ] ]
51f030359a8d30765035bd5d46f89019491a5aaf
e02fa80eef98834bf8a042a09d7cb7fe6bf768ba
/MyGUIEngine/src/MyGUI_Gui.cpp
f2900f0bab41f3a8cea807d4c41d2762d7a4f84a
[]
no_license
MyGUI/mygui-historical
fcd3edede9f6cb694c544b402149abb68c538673
4886073fd4813de80c22eded0b2033a5ba7f425f
refs/heads/master
2021-01-23T16:40:19.477150
2008-03-06T22:19:12
2008-03-06T22:19:12
22,805,225
2
0
null
null
null
null
WINDOWS-1251
C++
false
false
14,680
cpp
/*! @file @author Albert Semenov @date 11/2007 @module */ #include "MyGUI_Gui.h" #include "MyGUI_Widget.h" #include "MyGUI_InputManager.h" #include "MyGUI_SubWidgetManager.h" #include "MyGUI_ClipboardManager.h" #include "MyGUI_LayerManager.h" #include "MyGUI_LogManager.h" #include "MyGUI_SkinManager.h" #include "MyGUI_WidgetManager.h" #include "MyGUI_LayoutManager.h" #include "MyGUI_FontManager.h" #include "MyGUI_PointerManager.h" #include "MyGUI_PluginManager.h" #include "MyGUI_DynLibManager.h" #include "MyGUI_ControllerManager.h" namespace MyGUI { const std::string XML_TYPE("List"); INSTANCE_IMPLEMENT(Gui); void Gui::initialise(Ogre::RenderWindow* _window, const std::string& _core, const Ogre::String & _group) { // самый первый лог LogManager::registerSection(MYGUI_LOG_SECTION, MYGUI_LOG_FILENAME); MYGUI_ASSERT(false == mIsInitialise, INSTANCE_TYPE_NAME << " initialised twice"); MYGUI_LOG(Info, "* Initialise: " << INSTANCE_TYPE_NAME); MYGUI_LOG(Info, "* MyGUI version " << MYGUI_VERSION_MAJOR << "." << MYGUI_VERSION_MINOR << "." << MYGUI_VERSION_PATCH); // сохраняем окно и размеры mWindow = _window; Ogre::Viewport * port = mWindow->getViewport(0); mViewSize.set(port->getActualWidth(), port->getActualHeight()); MYGUI_LOG(Info, "Viewport : " << mViewSize.print()); registerLoadXmlDelegate(XML_TYPE) = newDelegate(this, &Gui::_load); // регистрируем фабрику текста и панели Ogre::OverlayManager &manager = Ogre::OverlayManager::getSingleton(); mFactoryTextSimpleOverlay = new TextSimpleOverlayElementFactory(); mFactoryTextEditOverlay = new TextEditOverlayElementFactory(); mFactorySharedPanelAlphaOverlay = new SharedPanelAlphaOverlayElementFactory(); manager.addOverlayElementFactory(mFactoryTextSimpleOverlay); manager.addOverlayElementFactory(mFactoryTextEditOverlay); manager.addOverlayElementFactory(mFactorySharedPanelAlphaOverlay); // создаем и инициализируем синглтоны mWidgetManager = new WidgetManager(); mInputManager = new InputManager(); mCroppedRectangleManager = new SubWidgetManager(); mClipboardManager = new ClipboardManager(); mLayerManager = new LayerManager(); mSkinManager = new SkinManager(); mLayoutManager = new LayoutManager(); mFontManager = new FontManager(); mPointerManager = new PointerManager(); mDynLibManager = new DynLibManager(); mPluginManager = new PluginManager(); mControllerManager = new ControllerManager(); mWidgetManager->initialise(); mInputManager->initialise(); mCroppedRectangleManager->initialise(); mClipboardManager->initialise(); mLayerManager->initialise(); mSkinManager->initialise(); mLayoutManager->initialise(); mFontManager->initialise(); mPointerManager->initialise(); mDynLibManager->initialise(); mPluginManager->initialise(); mControllerManager->initialise(); // подписываемся на изменение размеров окна и сразу оповещаем Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this); // загружаем дефолтные настройки load(_core, _group); // показываем курсор mPointerManager->show(); MYGUI_LOG(Info, INSTANCE_TYPE_NAME << " successfully initialized"); mIsInitialise = true; } void Gui::shutdown() { if (false == mIsInitialise) return; MYGUI_LOG(Info, "* Shutdown: " << INSTANCE_TYPE_NAME); // сразу отписываемся Ogre::WindowEventUtilities::removeWindowEventListener(mWindow, this); unregisterLoadXmlDelegate(XML_TYPE); mListFrameListener.clear(); mMapLoadXmlDelegate.clear(); _destroyAllChildWidget(); // деинициализируем и удаляем синглтоны mPluginManager->shutdown(); mDynLibManager->shutdown(); mWidgetManager->shutdown(); mPointerManager->shutdown(); mLayerManager->shutdown(); mFontManager->shutdown(); mLayoutManager->shutdown(); mInputManager->shutdown(); mSkinManager->shutdown(); mCroppedRectangleManager->shutdown(); mClipboardManager->shutdown(); mControllerManager->shutdown(); delete mPluginManager; delete mDynLibManager; delete mWidgetManager; delete mPointerManager; delete mLayerManager; delete mFontManager; delete mLayoutManager; delete mInputManager; delete mSkinManager; delete mCroppedRectangleManager; delete mClipboardManager; delete mControllerManager; delete mFactoryTextSimpleOverlay; delete mFactoryTextEditOverlay; delete mFactorySharedPanelAlphaOverlay; MYGUI_LOG(Info, INSTANCE_TYPE_NAME << " successfully shutdown"); // самый последний лог LogManager::shutdown(); mIsInitialise = false; } void Gui::addFrameListener(FrameListener * _listener) { if (null == _listener) return; removeFrameListener(_listener); mListFrameListener.push_back(_listener); } void Gui::removeFrameListener(FrameListener * _listener) { if (null == _listener) return; for (ListFrameListener::iterator iter=mListFrameListener.begin(); iter!=mListFrameListener.end(); ++iter) { if ((*iter) == _listener) { (*iter) = null; return; } } } void Gui::injectFrameEntered(Ogre::Real timeSinceLastFrame) { // сначала рассылаем ListFrameListener::iterator iter=mListFrameListener.begin(); while (iter != mListFrameListener.end()) { if (null == (*iter)) iter = mListFrameListener.erase(iter); else { (*iter)->_frameEntered(timeSinceLastFrame); ++iter; } }; } bool Gui::injectMouseMove( const OIS::MouseEvent & _arg) {return mInputManager->injectMouseMove(_arg);} bool Gui::injectMousePress( const OIS::MouseEvent & _arg , OIS::MouseButtonID _id ) {return mInputManager->injectMousePress(_arg, _id);} bool Gui::injectMouseRelease( const OIS::MouseEvent & _arg , OIS::MouseButtonID _id ) {return mInputManager->injectMouseRelease(_arg, _id);} bool Gui::injectKeyPress(const OIS::KeyEvent & _arg) {return mInputManager->injectKeyPress(_arg);} bool Gui::injectKeyRelease(const OIS::KeyEvent & _arg) {return mInputManager->injectKeyRelease(_arg);} WidgetPtr Gui::createWidgetT(const Ogre::String & _type, const Ogre::String & _skin, const IntCoord& _coord, Align _align, const Ogre::String & _layer, const Ogre::String & _name) { WidgetPtr widget = WidgetManager::getInstance().createWidget(_type, _skin, _coord, _align, null, _name); mWidgetChild.push_back(widget); // присоединяем виджет с уровню if (false == _layer.empty()) LayerManager::getInstance().attachItem(widget, _layer, true); return widget; } WidgetPtr Gui::findWidgetT(const std::string& _name) { return mWidgetManager->findWidgetT(_name); } void Gui::showPointer() {mPointerManager->show();} void Gui::hidePointer() {mPointerManager->hide();} bool Gui::isShowPointer() {return mPointerManager->isShow();} LoadXmlDelegate & Gui::registerLoadXmlDelegate(const Ogre::String & _key) { MapLoadXmlDelegate::iterator iter = mMapLoadXmlDelegate.find(_key); MYGUI_ASSERT(iter == mMapLoadXmlDelegate.end(), "name delegate is exist"); return (mMapLoadXmlDelegate[_key] = LoadXmlDelegate()); } void Gui::unregisterLoadXmlDelegate(const Ogre::String & _key) { MapLoadXmlDelegate::iterator iter = mMapLoadXmlDelegate.find(_key); if (iter != mMapLoadXmlDelegate.end()) mMapLoadXmlDelegate.erase(iter); } // удяляет только негодных батюшке государю void Gui::_destroyChildWidget(WidgetPtr _widget) { VectorWidgetPtr::iterator iter = std::find(mWidgetChild.begin(), mWidgetChild.end(), _widget); if(iter != mWidgetChild.end()) { delete *iter; // удаляем из списка *iter = mWidgetChild.back(); mWidgetChild.pop_back(); return; } MYGUI_EXCEPT("Widget not found"); } // удаляет всех детей void Gui::_destroyAllChildWidget() { while (false == mWidgetChild.empty()) { // отсылаем первый, так как он быстрее найдется в массиве // а удаление в векторе производится перестановкой, т.е. быстро WidgetPtr widget = mWidgetChild.front(); WidgetManager::getInstance().destroyWidget(widget); } } void Gui::destroyAllWidget() { mWidgetManager->destroyAllWidget(); } void Gui::destroyWidget(WidgetPtr _widget) { mWidgetManager->destroyWidget(_widget); } bool Gui::load(const std::string & _file, const std::string & _group) { return _loadImplement(_file, _group, false, "", INSTANCE_TYPE_NAME); } bool Gui::_loadImplement(const std::string & _file, const std::string & _group, bool _match, const std::string & _type, const std::string & _instance) { xml::xmlDocument doc; std::string file; if (_group.empty()) { file = _file; if (file.empty()) { MYGUI_LOG(Error, _instance << " : '" << _file << "' not found"); return false; } if (false == doc.open(file)) { MYGUI_LOG(Error, _instance << " : " << doc.getLastError()); return false; } } else { Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource (_file, _group); if (stream.isNull()) { MYGUI_LOG(Error, _instance << " : '" << _file << "' not found"); return false; } if (false == doc.open(stream)) { MYGUI_LOG(Error, _instance << " : " << doc.getLastError()); return false; } } xml::xmlNodePtr root = doc.getRoot(); if ( (null == root) || (root->getName() != "MyGUI") ) { MYGUI_LOG(Error, _instance << " : '" << _file << "', tag 'MyGUI' not found"); return false; } std::string type; if (root->findAttribute("type", type)) { MapLoadXmlDelegate::iterator iter = mMapLoadXmlDelegate.find(type); if (iter != mMapLoadXmlDelegate.end()) { if ((false == _match) || (type == _type)) (*iter).second(root, file); else { MYGUI_LOG(Error, _instance << " : '" << _file << "', type '" << _type << "' not found"); return false; } } else { MYGUI_LOG(Error, _instance << " : '" << _file << "', delegate for type '" << type << "'not found"); return false; } } // предпологаем что будут вложенные else if (false == _match) { xml::xmlNodeIterator node = root->getNodeIterator(); while (node.nextNode("MyGUI")) { if (node->findAttribute("type", type)) { MapLoadXmlDelegate::iterator iter = mMapLoadXmlDelegate.find(type); if (iter != mMapLoadXmlDelegate.end()) { (*iter).second(node.currentNode(), file); } else { MYGUI_LOG(Error, _instance << " : '" << _file << "', delegate for type '" << type << "'not found"); } } else { MYGUI_LOG(Error, _instance << " : '" << _file << "', tag 'type' not found"); } } } return true; } void Gui::_load(xml::xmlNodePtr _node, const std::string & _file) { // берем детей и крутимся, основной цикл xml::xmlNodeIterator node = _node->getNodeIterator(); while (node.nextNode(XML_TYPE)) { std::string source; if (false == node->findAttribute("file", source)) continue; std::string group = node->findAttribute("group"); MYGUI_LOG(Info, "Load ini file '" << source << "' from " << (group.empty() ? "current path" : "resource group : ") << group); _loadImplement(source, group, false, "", INSTANCE_TYPE_NAME); }; } VectorWidgetPtr Gui::loadLayout(const std::string & _file, const std::string & _group) { return mLayoutManager->load(_file, _group); } IntCoord Gui::convertRelativeToInt(const FloatCoord& _coord, WidgetPtr _parent) { const FloatSize& size = getViewSize(); if (null == _parent) { return IntCoord(_coord.left * size.width, _coord.top * size.height, _coord.width * size.width, _coord.height * size.height); } const IntCoord& coord = _parent->getClientRect(); return IntCoord(_coord.left * coord.width, _coord.top * coord.height, _coord.width * coord.width, _coord.height * coord.height); } FloatCoord Gui::convertIntToRelative(const IntCoord& _coord, WidgetPtr _parent) { const FloatSize& size = getViewSize(); if (null == _parent) { return FloatCoord(_coord.left / size.width, _coord.top / size.height, _coord.width / size.width, _coord.height / size.height); } const IntCoord& coord = _parent->getClientRect(); return FloatCoord(_coord.left / coord.width, _coord.top / coord.height, _coord.width / coord.width, _coord.height / coord.height); } // для оповещений об изменении окна рендера void Gui::windowResized(Ogre::RenderWindow* rw) { FloatSize oldViewSize = mViewSize; Ogre::Viewport * port = rw->getViewport(0); mViewSize.set(port->getActualWidth(), port->getActualHeight()); // выравниваем рутовые окна for (VectorWidgetPtr::iterator iter = mWidgetChild.begin(); iter!=mWidgetChild.end(); ++iter) { _alignWidget((*iter), oldViewSize, mViewSize); } } void Gui::_alignWidget(WidgetPtr _widget, const FloatSize& _old, const FloatSize& _new) { if (null == _widget) return; Align align = _widget->getAlign(); if (ALIGN_DEFAULT == align) return; IntCoord coord = _widget->getCoord(); // первоначальное выравнивание if (IS_ALIGN_RIGHT(align)) { if (IS_ALIGN_LEFT(align)) { // растягиваем coord.width += _new.width - _old.width; } else { // двигаем по правому краю coord.left += _new.width - _old.width; } } else if (false == IS_ALIGN_LEFT(align)) { // выравнивание по горизонтали без растяжения coord.left = (_new.width - coord.width) / 2; } if (IS_ALIGN_BOTTOM(align)) { if (IS_ALIGN_TOP(align)) { // растягиваем coord.height += _new.height - _old.height; } else { coord.top += _new.height - _old.height; } } else if (false == IS_ALIGN_TOP(align)) { // выравнивание по вертикали без растяжения coord.top = (_new.height - coord.height) / 2; } _widget->setPosition(coord); } } // namespace MyGUI
[ [ [ 1, 8 ], [ 14, 14 ], [ 24, 24 ], [ 27, 31 ], [ 33, 35 ], [ 37, 52 ], [ 54, 61 ], [ 63, 100 ], [ 105, 142 ], [ 144, 153 ], [ 177, 182 ], [ 184, 188 ], [ 192, 192 ], [ 195, 195 ], [ 197, 197 ], [ 201, 201 ], [ 204, 204 ], [ 208, 209 ], [ 214, 229 ], [ 238, 238 ], [ 240, 270 ], [ 283, 283 ], [ 295, 308 ], [ 310, 331 ], [ 333, 352 ], [ 378, 430 ] ], [ [ 9, 13 ], [ 15, 22 ], [ 36, 36 ], [ 156, 156 ], [ 158, 174 ], [ 176, 176 ], [ 183, 183 ], [ 189, 191 ], [ 193, 194 ], [ 196, 196 ], [ 198, 200 ], [ 202, 203 ], [ 205, 207 ], [ 210, 213 ], [ 230, 237 ], [ 239, 239 ], [ 271, 282 ], [ 284, 294 ], [ 309, 309 ], [ 332, 332 ], [ 353, 377 ] ], [ [ 23, 23 ], [ 25, 26 ], [ 32, 32 ], [ 53, 53 ], [ 62, 62 ], [ 101, 104 ], [ 143, 143 ], [ 154, 155 ], [ 157, 157 ], [ 175, 175 ] ] ]
aa681b390d7b81e73b179a4e08ccec8fe57b64ea
92bedc8155e2fb63f82603c5bf4ddec445d49468
/src/foundation/Archive.cpp
b802bd47d6fdea1ab930112ad11865237c1cc65b
[]
no_license
jemyzhang/pluto-hades
16372453f05510918b07720efa210c748b887316
78d9cf2ec7022ad35180e4fb685d780525ffc45d
refs/heads/master
2016-09-06T15:11:35.964172
2009-09-26T09:53:12
2009-09-26T09:53:12
32,126,635
0
0
null
null
null
null
UTF-8
C++
false
false
760
cpp
/******************************************************************************* ** ** NAME: Archive.cpp ** VER: 1.0 ** CREATE DATE: 2009/08/20 ** AUTHOR: Roger ** ** Copyright (C) 2009 - PlutoWare All Rights Reserved ** ** ** PURPOSE: Class Archive ** ** -------------------------------------------------------------- ** ** HISTORY: ** ** *******************************************************************************/ #include "stdafx.h" #include "Archive.h" namespace foundation { struct Archive::ArchiveImpl { QString file; }; Archive::Archive(void) : impl_(new ArchiveImpl) { } Archive::~Archive(void) { } void Archive::open(const QString& file) { Q_UNUSED(file); } }
[ "roger2yi@35b8d456-67b3-11de-a2f9-0f955267958a" ]
[ [ [ 1, 52 ] ] ]
dfa9635a621d68dde7bf0ca737888e2efae0add1
2b80036db6f86012afcc7bc55431355fc3234058
/src/server/MainWindowController.cpp
afc2429e30732c5dd1c720a8e1fa1889f05b88ee
[ "BSD-3-Clause" ]
permissive
leezhongshan/musikcube
d1e09cf263854bb16acbde707cb6c18b09a0189f
e7ca6a5515a5f5e8e499bbdd158e5cb406fda948
refs/heads/master
2021-01-15T11:45:29.512171
2011-02-25T14:09:21
2011-02-25T14:09:21
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
5,700
cpp
////////////////////////////////////////////////////////////////////////////// // // License Agreement: // // The following are Copyright © 2007, mC2 team // // 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 author nor the names of other contributors may // be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////// #include "pch.hpp" #include <server/MainWindowController.hpp> #include <server/resources/resource.h> #include <server/SyncpathController.hpp> #include <server/SyncpathView.hpp> #include <server/users/UsersController.hpp> #include <server/users/UsersView.hpp> #include <core/Preferences.h> #include <win32cpp/Types.hpp> // uichar, uistring #include <win32cpp/TopLevelWindow.hpp> #include <win32cpp/Application.hpp> #include <win32cpp/TabView.hpp> #include <win32cpp/RedrawLock.hpp> #include <win32cpp/LinearLayout.hpp> #include <win32cpp/Label.hpp> #include <win32cpp/Frame.hpp> #include <win32cpp/TrayIconManager.hpp> ////////////////////////////////////////////////////////////////////////////// using namespace musik::server; using namespace win32cpp; ////////////////////////////////////////////////////////////////////////////// /*ctor*/ MainWindowController::MainWindowController(TopLevelWindow& mainWindow,musik::core::ServerPtr server) :mainWindow(mainWindow) ,server(server) ,mainFrame(NULL) ,syncpathController(NULL) ,usersController(NULL) { this->mainWindow.Handle() ? this->OnMainWindowCreated(&this->mainWindow) : this->mainWindow.Created.connect(this, &MainWindowController::OnMainWindowCreated); } MainWindowController::~MainWindowController() { delete this->syncpathController; delete this->usersController; } void MainWindowController::OnMainWindowCreated(Window* window) { RedrawLock redrawLock(window); { // Set window size and position musik::core::Preferences windowPrefs("ServerSettingsWindow"); this->mainWindow.MoveTo(windowPrefs.GetInt("x",200), windowPrefs.GetInt("y",200)); this->mainWindow.Resize(windowPrefs.GetInt("width",500), windowPrefs.GetInt("height",400)); this->mainWindow.SetMinimumSize(Size(320, 240)); } FontRef boldFont(Font::Create()); boldFont->SetBold(true); // Create the layout this->mainFrame = new win32cpp::Frame(NULL,win32cpp::WindowPadding(4)); this->mainFrame->SetLayoutFlags(win32cpp::LayoutFillFill); // Second a TabView for the settings win32cpp::TabView *tabs = this->mainFrame->AddChild( new win32cpp::TabView() ); tabs->SetPadding(0); // Syncpath tab SyncpathView *synpathView = tabs->AddTab(uistring(_T("Sync paths")), new SyncpathView()); synpathView->SetLayoutFlags(win32cpp::LayoutFillFill); this->syncpathController = new SyncpathController(*synpathView,&this->server->indexer); // Users tab users::UsersView *usersView = tabs->AddTab(uistring(_T("Users")), new users::UsersView()); usersView->SetLayoutFlags(win32cpp::LayoutFillFill); this->usersController = new users::UsersController(*usersView,this->server.get()); // Settings tab Frame *settingsView = tabs->AddTab(uistring(_T("Settings")), new Frame()); settingsView->SetLayoutFlags(win32cpp::LayoutFillFill); this->mainWindow.AddChild(mainFrame); // Connect size and position signals this->mainWindow.Resized.connect(this, &MainWindowController::OnResize); this->mainWindow.Destroyed.connect(this, &MainWindowController::OnDestroyed); } void MainWindowController::OnResize(Window* window, Size size) { RedrawLock redrawLock(window); this->mainFrame->Resize(this->mainWindow.ClientSize()); } void MainWindowController::OnDestroyed(Window* window) { Point location( window->Location() ); Size size( window->WindowSize() ); musik::core::Preferences windowPrefs("ServerSettingsWindow"); windowPrefs.SetInt("x",location.x); windowPrefs.SetInt("y",location.y); windowPrefs.SetInt("width",size.width); windowPrefs.SetInt("height",size.height); }
[ "onnerby@6a861d04-ae47-0410-a6da-2d49beace72e", "[email protected]@6a861d04-ae47-0410-a6da-2d49beace72e", "[email protected]@6a861d04-ae47-0410-a6da-2d49beace72e" ]
[ [ [ 1, 55 ], [ 57, 100 ], [ 103, 105 ], [ 107, 109 ], [ 112, 115 ], [ 117, 120 ], [ 122, 148 ] ], [ [ 56, 56 ] ], [ [ 101, 102 ], [ 106, 106 ], [ 110, 111 ], [ 116, 116 ], [ 121, 121 ] ] ]
9505c38a5cdb1e4e725870431bdb5136e5de920b
847cccd728e768dc801d541a2d1169ef562311cd
/src/Editor/ValueEditors/Models/StringValueEditorModel.h
a03f22f2d64aa46486561998bb8a060f43deb22e
[]
no_license
aadarshasubedi/Ocerus
1bea105de9c78b741f3de445601f7dee07987b96
4920b99a89f52f991125c9ecfa7353925ea9603c
refs/heads/master
2021-01-17T17:50:00.472657
2011-03-25T13:26:12
2011-03-25T13:26:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,771
h
/// @file /// Value editor model wrapper that converts values of specified type to strings #ifndef _EDITOR_STRINGVALUEEDITORMODEL_H_ #define _EDITOR_STRINGVALUEEDITORMODEL_H_ #include "Base.h" #include "IValueEditorModel.h" #include "Utils/StringConverter.h" namespace Editor { /// The StringValueEditorModel class is a model for ValueEditors that allow to /// view/edit string values. template<class T> class StringValueEditorModel: public ITypedValueEditorModel<string> { public: /// Inner model this class extends. typedef ITypedValueEditorModel<T> WrappedModel; /// Constructs the model from a base model. StringValueEditorModel(WrappedModel* wrappedModel): mWrappedModel(wrappedModel) {} /// Default destructor. virtual ~StringValueEditorModel() { delete mWrappedModel; } /// Returns the name of the edited variable. virtual string GetName() const { return mWrappedModel->GetName(); } /// Returns the tool-tip for the edited variable. virtual string GetTooltip() const { return mWrappedModel->GetTooltip(); } /// Returns whether the variable is valid. virtual bool IsValid() const { return mWrappedModel->IsValid(); } /// Returns whether the variable is read only. virtual bool IsReadOnly() const { return mWrappedModel->IsReadOnly(); } /// Returns whether the variable is locked. virtual bool IsLocked() const { return mWrappedModel->IsLocked(); } /// Returns whether the variable is list element. virtual bool IsListElement() const { return mWrappedModel->IsListElement(); } /// Returns whether the variable is removable. virtual bool IsRemovable() const { return mWrappedModel->IsRemovable(); } /// Returns whether the variable is shareable. virtual bool IsShareable() const { return mWrappedModel->IsShareable(); } /// Returns whether the variable is shared. virtual bool IsShared() const { return mWrappedModel->IsShared(); } /// Removes the variable. virtual void Remove() { return mWrappedModel->Remove(); } /// Sets whether the variable is shared. This is used for prototype properties. virtual void SetShared(bool isShared) { return mWrappedModel->SetShared(isShared); } /// Returns the value of the variable. virtual string GetValue() const { return Utils::StringConverter::ToString(mWrappedModel->GetValue()); } /// Sets the value of the variable. virtual void SetValue(const string& newValue) { mWrappedModel->SetValue(Utils::StringConverter::FromString<T>(newValue)); } /// Inner model this class extends. WrappedModel* GetWrappedModel() const { return mWrappedModel; } private: WrappedModel* mWrappedModel; }; } #endif // _EDITOR_STRINGVALUEEDITORMODEL_H_
[ [ [ 1, 12 ], [ 15, 80 ] ], [ [ 13, 14 ] ], [ [ 81, 81 ] ] ]
0352a39a42e50a09136ea3202c85f0ce93999701
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/WORLDSERVER/GlobalTime.h
5abd4e016f5eff8e2bb1e9d269424f204091bff4
[]
no_license
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
563
h
#ifndef __GLOBALTIME_H__ #define __GLOBALTIME_H__ class CStopwatch { private: DWORD m_dwTime; LARGE_INTEGER m_liPerformanceCount; public: // Operations void Play( ) { m_dwTime = timeGetTime(); } void PlayEx( ) { QueryPerformanceCounter( &m_liPerformanceCount ); } DWORD Stop( ) { return( timeGetTime() - m_dwTime ); } float StopEx( ) { LARGE_INTEGER li; QueryPerformanceCounter( &li ); return ( (float)( li.QuadPart - m_liPerformanceCount.QuadPart ) ); } }; #endif // __GLOBALTIME_H__
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 37 ] ] ]
204b6dcebd9a6af4a45546f4eb11b9c8c4f6ee94
1e4daaa1f0846720f608094479aadb58759e1021
/p2p-simulation/atomic/gnutella/Gnutella.cpp
74a357fa0b4cd4e82645dc5113fd4d6f83bea270
[]
no_license
DDionne/SpiderWeb
d7d69091a08aaf6b2ae7f50ad7a8bd40406cc693
0d3e78a0a053e4c0e826cf9b9eae332930929fc0
refs/heads/master
2021-01-16T19:56:44.257854
2011-06-07T19:33:40
2011-06-07T19:33:40
1,860,449
0
0
null
null
null
null
UTF-8
C++
false
false
6,192
cpp
/******************************************************************* * * DESCRIPTION: Atomic Model : Gnutella Router * * AUTHOR: Alan * * * DATE: November 2010 * *******************************************************************/ /** include files **/ #include <math.h> // fabs( ... ) #include <stdlib.h> #include "randlib.h" // Random numbers library #include "Gnutella.h" // base header #include "message.h" // InternalMessage .... //#include "..\..\lib\graph-c++.h" // class graph //#include "NetGraph.h" // basic undirected graph with integers #include "mainsimu.h" // class MainSimulator #include "strutil.h" // str2float( ... ) /******************************************************************* * Function Name: Gnutella * Description: constructor ********************************************************************/ Gnutella::Gnutella( const string &name ) : Atomic( name ) , route_in( addInputPort( "route_in" ) ) , route_out( addOutputPort( "route_out" ) ) , in_n( addInputPort( "in_n" ) ) , out_n( addOutputPort( "out_n" ) ) { //initialising these values... not indispensable but always useful routing = false; hitting = false; nextOutputDB = 0.0f; nextOutputR= 0.0f; } /* //external function with simultaneous messages Model &Gnutella::externalFunction( const ExternalMessage &msg ){ }*/ /******************************************************************* * Function Name: externalFunction * Description: the router gets input from either the "outside" (a new messgae to route) or from the router (next step for routing) ********************************************************************/ Model &Gnutella::externalFunction( const ExternalMessage &msg ){ if(VERBOSE) cout<<"external message: "<<msg.value()<<endl; if ( this->state() == passive) { if (msg.port() == route_in) //new message to route { //expecting float values looking like 6,123 meaning route from peer 6 with msg id 123 (id<1000) //get the peerid, message id, generate new TTL, then put in "to output" variable // not a list ! [id, TTL, peer] int peerid = getPeerId(msg.value());// get originating peer (from value of external msg) if(VERBOSE)cout<<" peerid:"<<peerid<<endl; int id = getMessageId(msg.value()); // get message id if(VERBOSE)cout<<" message id:"<<id<<endl; //create "seen" list. The message ids are float values (that way we can generate them using a random function) // to create an empty list I use the default constructor, throught the shortcut of calling the [] operator. if (routingTable.find(id)==routingTable.end()) routingTable[id]; //creates empty set mapped to id else routingTable[id].clear();// clear the set (this case is for a msgId being reused) routingTable[id].insert(peerid); // the new peer has now been visited (because the first thing will be to send himself the message !) // we need to propagate this message to the DB and route it in the network (separate issues) hitting = true; routing = true; //set the output values // from right, digits 1-3 are id, digits 4-6 are peerid, digit 7 is TTL exampel value : 6005123 = TTL=6, peerid 5, id = 123 nextOutputDB = buildMessage(id, peerid); nextOutputR =buildMessage(id, peerid, STANDARDTTL); //standardTTL is a constant defined in the h, should be a model parameter //if(VERBOSE) cout<<"next output:"<<nextOutputR<<endl; } else if (msg.port() == in_n){ //expecting value = TTL * 100 + peerid + id, where id is the decimal part (<1) if(VERBOSE) cout<<"message from the network routing loop... "<<msg.value()<<"\n"; long inval = msg.value(); //extract our 3 values using static functions from complexmessages.h int OldTTL = getTTL(inval); if(VERBOSE)cout<<"old ttl:"<<OldTTL<<endl; int peerid = getPeerId(inval); if(VERBOSE)cout<<" peerid:"<<peerid<<endl; int id = getMessageId(inval); if(VERBOSE)cout<<" message id:"<<id<<endl; //check for already visited peer : search for "peerid" in set mapped to id in routing table set<long>::iterator finder = routingTable[id].find(peerid); if(finder==routingTable[id].end()){ //it's NOT in there //the unseen peer must get the message hitting = true; nextOutputDB = buildMessage(id, peerid); // we don't put in a TTL // the new peer has now been visited : we add him to the set of seen peers routingTable[id].insert(peerid); if(OldTTL>0){ // the unseen peer will also propagate the message because it still has some TTL routing=true; nextOutputR = buildMessage(id, peerid, OldTTL-1); //add the TTL for the routing msg } else { routing = false; } } else { hitting = false; routing = false; } } } //end if state is passive else{ cout<<"error: message received while in active state"<<endl; } // we have an instantaneous change back to the passive state (will output the next output values where relevant) holdIn( active, Time(0.00f)); return *this ; } /******************************************************************* * Function Name: internalFunction ********************************************************************/ Model &Gnutella::internalFunction( const InternalMessage & ){ //set these back routing = false; hitting = false; passivate(); // we just passivate immediately return *this; } /******************************************************************* * Function Name: outputFunction ********************************************************************/ Model &Gnutella::outputFunction( const InternalMessage &msg ) { if(VERBOSE) cout<<"output coming...\n"; if (routing) // if we have something to output { sendOutput( msg.time(), out_n, nextOutputR); //nextOutput contains the next value to output } if(hitting) { sendOutput( msg.time(), route_out, nextOutputDB); //nextOutput contains the next value to output } return *this; } Gnutella::~Gnutella() { //do nothing }
[ [ [ 1, 174 ] ] ]
58156bf1a4c29ba9b54e29f8e31f9d6f161d7679
27d5670a7739a866c3ad97a71c0fc9334f6875f2
/CPP/Targets/SupportWFLib/symbian/VectorMapConnection.h
31eefb4734ae1b47e5a785d3386783fc11b792b7
[ "BSD-3-Clause" ]
permissive
ravustaja/Wayfinder-S60-Navigator
ef506c418b8c2e6498ece6dcae67e583fb8a4a95
14d1b729b2cea52f726874687e78f17492949585
refs/heads/master
2021-01-16T20:53:37.630909
2010-06-28T09:51:10
2010-06-28T09:51:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,580
h
/* Copyright (c) 1999 - 2010, Vodafone Group Services Ltd 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 Vodafone Group Services Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef VECTOR_MAP_CONNECTION_H #define VECTOR_MAP_CONNECTION_H #include <e32base.h> #include "DBufConnection.h" //#include "GuiProt/GuiProtMess.h" namespace isab { class GuiProtMess; class DataGuiMess; } class CVectorMapConnection : public CBase, public DBufConnection{ public: ///Construction CVectorMapConnection(class MMessageSender* aSender); void SingleMapReply(const class isab::DataGuiMess& aReply); void MultiMapReply(const class isab::DataGuiMess& aReply); void MapErrorReply(uint16 aRequestId); public: /** Inherited from <code>DBufConnection</code>. */ //@{ /** * N.B! This function may Leave! * Requests one databuffer. The value returned here should * also be used when sending replies to the listeners via * the HttpClientConnectionListener interface. * Two requests must never return the same id and they should * be unique for both requestOne an requestMany, i.e. if * requestOne returns 1 then requestMany may not return that. * @param descr Buffer to request. * @return -1 if too many requests have been sent already. */ virtual int requestOne(const char* descr); /** * N.B! This function may Leave! * Requests many databuffers. (e.g. using post in http). * The value returned here should * also be used when sending replies to the listeners via the * HttpClientConnectionListener interface. * @param body Body of data as described in SharedDBufRequester * and ParserThread. (For multiple databufs). * @return -1 if too many requests have been sent already. */ virtual int requestMany(const uint8* buf, int nbrBytes); /** * Sets listener. */ virtual void setListener(class HttpClientConnectionListener* listener); //@} private: class MMessageSender* iSender; class HttpClientConnectionListener* iListener; }; #endif
[ [ [ 1, 82 ] ] ]
1d7fab81b9fe118ef8cf52b09f2c2aa5c6a81a68
fac8de123987842827a68da1b580f1361926ab67
/inc/physics/Physics/Collide/Shape/hkpShapeContainer.h
8b0737da138ba4b1ab049999e8ef8cff25867b24
[]
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
5,404
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 HK_COLLIDE_SHAPE_CONTAINER_H #define HK_COLLIDE_SHAPE_CONTAINER_H #include <Physics/Collide/Shape/hkpShape.h> /// Interface to shapes which have one or more children, accessible through a shapekey. /// See hkpShape::getCollection() class hkpShapeContainer { public: HK_DECLARE_REFLECTION(); /// Attributes of the buffer used in getChildShape. #if !defined(HK_PLATFORM_HAS_SPU) enum { HK_SHAPE_BUFFER_ALIGNMENT = 16, HK_SHAPE_BUFFER_SIZE = 512 }; #else enum { HK_SHAPE_BUFFER_ALIGNMENT = 16, HK_SHAPE_BUFFER_SIZE = 256 }; #endif /// A buffer type, allocated locally on the stack by calling functions, /// to be passed to getChildShape. typedef HK_ALIGN16( char ShapeBuffer[HK_SHAPE_BUFFER_SIZE] ); /// virtual ~hkpShapeContainer() { } #if !defined(HK_PLATFORM_SPU) /// The number of child shapes. The default implementation just iterates over all keys and is really slow virtual int getNumChildShapes() const; /// Get the first child shape key /// see getChildShape() for extra details virtual hkpShapeKey getFirstKey() const = 0; /// Get the next child shape key /// If the the "oldKey" parameter is the last key in the shape collection, this function /// returns HK_INVALID_SHAPE_KEY /// see getChildShape() for extra details virtual hkpShapeKey getNextKey( hkpShapeKey oldKey ) const = 0; /// Return the collision filter info for a given child shape virtual hkUint32 getCollisionFilterInfo( hkpShapeKey key ) const; /// Gets a child shape using a shape key. /// This function must return a child shape pointer. This is only called internally by /// the collision detection system after having called getFirstKey() or getNextKey(). /// If you have shape keys that are invalid, you must implement getNextKey() in such /// a way that it skips over these shapes. /// Important Note: It is assumed by the system that a shape key, if valid (i.e. returned by /// getNextkey()) will always remain valid.<br> /// Notes: /// - You can return a pointer to a shape /// - or you can construct a shape in place in the buffer and return a pointer to that buffer. /// e.g. hkpMeshShape uses this buffer for temporarily created triangles. /// hkpListShape does not use the buffer as it already has shape instances. /// Attention: When the buffer gets erased, no destructor will be called. /// - The buffer must be 16 byte aligned. virtual const hkpShape* getChildShape( hkpShapeKey key, ShapeBuffer& buffer ) const = 0; virtual hkBool32 isChildEnabled( hkpShapeKey key ) const { return true; } /// Return whether welding should be enabled for this shape container (default true) virtual bool isWeldingEnabled() const { return true; } #endif }; /// Utility class for a shape which has a single child. class hkpSingleShapeContainer : public hkpShapeContainer { public: HK_DECLARE_REFLECTION(); void* operator new(hk_size_t, void* p) { return p; } void operator delete(void* p) { } /// Create a single shape collection. hkpSingleShapeContainer( const hkpShape* s ) : m_childShape(s) { #if !defined(HK_PLATFORM_SPU) m_childShape->addReference(); #endif } #if !defined(HK_PLATFORM_SPU) hkpSingleShapeContainer(hkFinishLoadedObjectFlag) {} ~hkpSingleShapeContainer() { m_childShape->removeReference(); } // Implemented method of hkpShapeContainer virtual int getNumChildShapes() const { return 1; } // Implemented method of hkpShapeContainer virtual hkpShapeKey getFirstKey() const { return 0; } // Implemented method of hkpShapeContainer virtual hkpShapeKey getNextKey( hkpShapeKey oldKey ) const { return HK_INVALID_SHAPE_KEY; } // Implemented method of hkpShapeContainer virtual const hkpShape* getChildShape( hkpShapeKey key, ShapeBuffer& buffer ) const; #endif /// Get the child shape. inline const hkpShape* getChild() const { return m_childShape; } /// inline const hkpShape* operator->() const { return m_childShape; } protected: const hkpShape* m_childShape; }; #endif // HK_COLLIDE_SHAPE_CONTAINER_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, 143 ] ] ]
33bc460e357796f6ab46b26b7d043ec803d4c078
c1a2953285f2a6ac7d903059b7ea6480a7e2228e
/deitel/ch22/Fig22_30/Fig22_30.cpp
1999e88d025029acffbc2a628f206cace7c64ca2
[]
no_license
tecmilenio/computacion2
728ac47299c1a4066b6140cebc9668bf1121053a
a1387e0f7f11c767574fcba608d94e5d61b7f36c
refs/heads/master
2016-09-06T19:17:29.842053
2008-09-28T04:27:56
2008-09-28T04:27:56
50,540
4
3
null
null
null
null
UTF-8
C++
false
false
3,959
cpp
// Fig. 22.30: Fig22_30.cpp // Mathematical algorithms of the Standard Library. #include <iostream> using std::cout; using std::endl; #include <algorithm> // algorithm definitions #include <numeric> // accumulate is defined here #include <vector> #include <iterator> bool greater9( int ); // predicate function prototype void outputSquare( int ); // output square of a value int calculateCube( int ); // calculate cube of a value int main() { const int SIZE = 10; int a1[ SIZE ] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; std::vector< int > v( a1, a1 + SIZE ); // copy of a1 std::ostream_iterator< int > output( cout, " " ); cout << "Vector v before random_shuffle: "; std::copy( v.begin(), v.end(), output ); std::random_shuffle( v.begin(), v.end() ); // shuffle elements of v cout << "\nVector v after random_shuffle: "; std::copy( v.begin(), v.end(), output ); int a2[ SIZE ] = { 100, 2, 8, 1, 50, 3, 8, 8, 9, 10 }; std::vector< int > v2( a2, a2 + SIZE ); // copy of a2 cout << "\n\nVector v2 contains: "; std::copy( v2.begin(), v2.end(), output ); // count number of elements in v2 with value 8 int result = std::count( v2.begin(), v2.end(), 8 ); cout << "\nNumber of elements matching 8: " << result; // count number of elements in v2 that are greater than 9 result = std::count_if( v2.begin(), v2.end(), greater9 ); cout << "\nNumber of elements greater than 9: " << result; // locate minimum element in v2 cout << "\n\nMinimum element in Vector v2 is: " << *( std::min_element( v2.begin(), v2.end() ) ); // locate maximum element in v2 cout << "\nMaximum element in Vector v2 is: " << *( std::max_element( v2.begin(), v2.end() ) ); // calculate sum of elements in v cout << "\n\nThe total of the elements in Vector v is: " << std::accumulate( v.begin(), v.end(), 0 ); // output square of every element in v cout << "\n\nThe square of every integer in Vector v is:\n"; std::for_each( v.begin(), v.end(), outputSquare ); std::vector< int > cubes( SIZE ); // instantiate vector cubes // calculate cube of each element in v; place results in cubes std::transform( v.begin(), v.end(), cubes.begin(), calculateCube ); cout << "\n\nThe cube of every integer in Vector v is:\n"; std::copy( cubes.begin(), cubes.end(), output ); cout << endl; return 0; } // end main // determine whether argument is greater than 9 bool greater9( int value ) { return value > 9; } // end function greater9 // output square of argument void outputSquare( int value ) { cout << value * value << ' '; } // end function outputSquare // return cube of argument int calculateCube( int value ) { return value * value * value; } // end function calculateCube /************************************************************************** * (C) Copyright 1992-2008 by Deitel & Associates, Inc. and * * Pearson Education, Inc. All Rights Reserved. * * * * DISCLAIMER: The authors and publisher of this book have used their * * best efforts in preparing the book. These efforts include the * * development, research, and testing of the theories and programs * * to determine their effectiveness. The authors and publisher make * * no warranty of any kind, expressed or implied, with regard to these * * programs or to the documentation contained in these books. The authors * * and publisher shall not be liable in any event for incidental or * * consequential damages in connection with, or arising out of, the * * furnishing, performance, or use of these programs. * **************************************************************************/
[ [ [ 1, 100 ] ] ]
201b8d1cf366b614fdc201febfb514ca7fb7e079
0ce35229d1698224907e00f1fdfb34cfac5db1a2
/Voiture_Familiale.cpp
89cd1ffb1ee8bbe12310b166a833be4a58074b29
[]
no_license
manudss/efreiloca
f7b1089b6ba74ff26e6320044f66f9401ebca21b
54e8c4af1aace11f35846e63880a893e412b3309
refs/heads/master
2020-06-05T17:34:02.234617
2007-06-04T19:12:15
2007-06-04T19:12:15
32,325,713
0
0
null
null
null
null
UTF-8
C++
false
false
158
cpp
#include "StdAfx.h" #include "Voiture_Familiale.h" Voiture_Familiale::Voiture_Familiale(void) { } Voiture_Familiale::~Voiture_Familiale(void) { }
[ "pootoonet@65b228c9-682f-0410-abd1-c3b8cf015911" ]
[ [ [ 1, 10 ] ] ]
fab2fb5dc0ffb2e172dbe3991c65b51cdc132021
dbe773bf045c1bc90e6b19ca377d80552d9b08d9
/moses/src/WordLattice.h
346e1259d8845f2059fcbc96f5d4cfee07da4d7e
[]
no_license
kowey/moses
1b25133ae8cd97f4174d3a171e37f9a07e9aa38f
3bd207ba05c340c39c3ad36bea0c366526cc44e3
refs/heads/master
2021-03-12T21:46:45.589990
2008-11-24T13:54:50
2008-11-24T13:54:50
77,766
1
2
null
null
null
null
UTF-8
C++
false
false
1,008
h
#ifndef WORDLATTICE_H_ #define WORDLATTICE_H_ #include <vector> #include "ConfusionNet.h" namespace Moses { /** General word lattice */ class WordLattice: public ConfusionNet { private: std::vector<std::vector<size_t> > next_nodes; std::vector<std::vector<int> > distances; public: WordLattice(); size_t GetColumnIncrement(size_t ic, size_t j) const; void Print(std::ostream&) const; /** Get shortest path between two nodes */ virtual int ComputeDistortionDistance(const WordsRange& prev, const WordsRange& current) const; // is it possible to get from the edge of the previous word range to the current word range virtual bool CanIGetFromAToB(size_t start, size_t end) const; int Read(std::istream& in,const std::vector<FactorType>& factorOrder); /** Convert internal representation into an edge matrix * @note edges[1][2] means there is an edge from 1 to 2 */ void GetAsEdgeMatrix(std::vector<std::vector<bool> >& edges) const; }; } #endif
[ "hieuhoang1972@1f5c12ca-751b-0410-a591-d2e778427230" ]
[ [ [ 1, 36 ] ] ]
117f5188049db08f3086f84e37816295b5ac3fa0
5e6ff9e6e8427078135a7b4d3b194bcbf631e9cd
/EngineSource/dpslim/dpslim/Simulation/Source/Consumer.cpp
1bcd8b57529a971cc911cbd2c80ba58837486024
[]
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
12,477
cpp
// Consumer.cpp // // Copyright 2005 DecisionPower // // Consumer Agent Object // Created by Ken Karakotsios 10/26/98 #include "Consumer.h" #include "RepurchaseModel.h" #include "ProductTree.h" #include "DBModel.h" #include "Product.h" #include "Attributes.h" #include "ChoiceModel.h" // ------------------------------------------------------------------------------ // Everything should be allocated and reset in the newPopulation // by the time we get to here. // ------------------------------------------------------------------------------ void Consumer::CopyTo(Consumer* destGuy) { destGuy->iRepurchaseProb = iRepurchaseProb; destGuy->iProductLastBought = iProductLastBought; destGuy->iBoughtThisTick = iBoughtThisTick; destGuy->iRecommend = iRecommend; destGuy->iPreferredChannel = iPreferredChannel; destGuy->iPreferredProduct = iPreferredProduct; // consumers preferred brand destGuy->iShoppingChance = iShoppingChance; destGuy->iDaysSinceLastShopping = iDaysSinceLastShopping; destGuy->iInStoreSwitchFactor = iInStoreSwitchFactor; } // ------------------------------------------------------------------------------ // // ------------------------------------------------------------------------------ double Consumer::CountAllMessagesForThisProduct(Index pn) { return productPersuasion[pn]; } // ------------------------------------------------------------------------------ // // ------------------------------------------------------------------------------ int Consumer::HasNegMsgs(Index pn) { if(segment->iProdTree->IsLeaf(pn)) { return productPersuasion[pn] < 0.0; // OK } else { ProductTree::LeafNodeList leafs(pn); ProductTree::Iter iter; for(iter = leafs.begin(); iter != leafs.end(); ++iter) { pn = *iter; if(productPersuasion[pn] > 0.0) { return true; } } return false; } } // ------------------------------------------------------------------------------ // // ------------------------------------------------------------------------------ void Consumer::CountMyAvailableProdMsgs() { if (segment->iMessageSensitivity == 0) return; switch (choiceModel->iChoiceModel) { case kModel_EmergentLogit: case kModel_Bass: case kModel_CrossingTheChasm: case kModel_Emergent: case kModel_Linear: iTotalMessages = 0.0; return; break; case kModel_LinearSOV: break; case kModel_General: // OK { switch (choiceModel->iGCMf2_PersuasionValComp) { case kGCMf2_ShareOfVoice: break; case kGCMf2_Absolute: case kGCMf2_squareRoot: case kGCMf2_base10log: iTotalMessages = 0.0; return; break; } // end choiceModel->iGCMf2_PersuasionValComp switch break; } } // end choiceModel->iChoiceModel switch int i; double sum; for (i = 0; i < productPersuasion.size(); i++) { // It would seem that absolute number persuasion units makes no sense, // so we'll go with net persuasion in both numerator and denominator sum = productPersuasion[i]; // OK if (sum < 0.0) { sum = 0.0; } iTotalMessages += sum; } } // ------------------------------------------------------------------------------ // Return true if the consumer has ever tried this product // keeping this in a method so that I canchange it later. Curent implementation // is a test. It only allows 16 products, because storage is statically allocated. // // 4/2/01 am replacing use of iTriedProduct with iProdsEverBought. So, now I can // have more than 16 products. Also, 8 bits will be stored. For starters, we'll // continue to keep a count of uses in the first two bits. // ------------------------------------------------------------------------------ int Consumer::NumTimesTriedProduct(Index pn) { return productsBought[pn] & kProdTriesMask; } int Consumer::EverTriedProduct(Index pn, int doSibs) { int count; count = productsBought[pn] & kProdTriesMask; if (count > 0) return true; if(doSibs && (productsBought[pn] & kTriedSib)) { return true; } return false; } int Consumer::Aware(Index pn) { if(productAwareness[pn] == -1) { // not aware return false; } else if(productAwareness[pn] == segment->iNumDays) { // have just become aware - no time to lose awareness return true; } else { // maybe have lost awareness long span = segment->iNumDays - productAwareness[pn]; double aware_prob = 1.00000 - AwareProb(pn); long double prob = pow(aware_prob,span); if(WillDo0to1(prob)) { // since we did not lose awareness for this product // we have "checked" it for the siblings // otherwise the more siblings the more you lose ProductTree::List* sibs = ProductTree::theTree->Siblings(pn); if (segment->iShareAwarenessWithSibs && sibs) { for( ProductTree::Iter iter = sibs->begin(); iter != sibs->end(); ++iter) { int sibPn = *iter; if(productAwareness[sibPn] != -1) { productAwareness[sibPn] = segment->iNumDays; LosePersuasion(sibPn, span); } } } else { // just this one product productAwareness[pn] = segment->iNumDays; // lose perusasion regradless LosePersuasion(pn, span); } return true; } else { // turn off awareness of all siblings ProductTree::List* sibs = ProductTree::theTree->Siblings(pn); if (segment->iShareAwarenessWithSibs && sibs) { for( ProductTree::Iter iter = sibs->begin(); iter != sibs->end(); ++iter) { int sibPn = *iter; if(productAwareness[sibPn] != -1) { productAwareness[sibPn] = -1; for(da_iter iter = dynamic_attributes[sibPn].begin(); iter != dynamic_attributes[sibPn].end(); ++iter) { iter->second->Forget(); } segment->iProducts[sibPn]->iNumAwareSofar -= 1; if (segment->iProducts[sibPn]->iNumAwareSofar < 0) { segment->iProducts[sibPn]->iNumAwareSofar = 0; } // lose awareness - lose persuasion segment->iProducts[sibPn]->iTotalPersuasion -= productPersuasion[sibPn]; productPersuasion[sibPn] = 0.0; } } } else { productAwareness[pn] = -1; for(da_iter iter = dynamic_attributes[pn].begin(); iter != dynamic_attributes[pn].end(); ++iter) { iter->second->Forget(); } segment->iProducts[pn]->iNumAwareSofar -= 1; if (segment->iProducts[pn]->iNumAwareSofar < 0) { segment->iProducts[pn]->iNumAwareSofar = 0; } segment->iProducts[pn]->iTotalPersuasion -= productPersuasion[pn]; productPersuasion[pn] = 0.0; } return false; } } } void Consumer::LosePersuasion(Index pn, int span) { double persuasionVal = productPersuasion[pn]; if (persuasionVal != 0) { double locPersuasionDecayRate = PersuasionLoss(pn); double persuasionLoss = persuasionVal; persuasionVal *= pow(1.0 - locPersuasionDecayRate, span); if(persuasionVal*persuasionVal < 0.0001) { persuasionVal = 0; } persuasionLoss -= persuasionVal; segment->iProducts[pn]->iTotalPersuasion -= persuasionLoss; // KMK 8/22/05 productPersuasion[pn] = persuasionVal; } } //------------------------------------------------------------------------------- // //------------------------------------------------------------------------------- int Consumer::AlreadyHasCoupon(int CouponIndex) { if(coupons->find(CouponIndex) != coupons->end()) { return true; } return false; } double Consumer::DynamicScore(Pcn pcn, int post_use) { double utility = 0.0; map<int, DynamicAttribute*>::const_iterator iter; for(iter = dynamic_attributes[pcn.pn].begin(); iter != dynamic_attributes[pcn.pn].end(); ++iter) { if(iter->second->Aware()) { utility += segment->AttributeScore(iter->first, iter->second, post_use); } } return utility; } // ------------------------------------------------------------------------------ // Return true if the consumer has ever tried this product // keeping this in a method so that I can change it later. Curent implementation // is a test. It only allows 16 products, because storage is statically allocated. // // 4/2/01 am replacing use of iTriedProduct with iProdsEverBought. So, now I can // have more than 16 products. Also, 8 bits will be stored. For starters, we'll // continue to keep a count of uses in the first two bits. // ------------------------------------------------------------------------------ int Consumer::ConsumerTriedAndRejectedProduct(Index pn) { Index lpn; unsigned int rejected; if(segment->iProdTree->IsLeaf(pn)) { if(productsBought[pn] & kRejectedBit) { return true; } else { return false; } } else { ProductTree::LeafNodeList leafs(pn); ProductTree::Iter iter; for(iter = leafs.begin(); iter != leafs.end(); ++iter) { lpn = *iter; rejected = productsBought[lpn] & kRejectedBit; if(!rejected) { return false; } } return true; } } void Consumer::WriteToFile(ofstream & file) { for(int i = 0; i < this->productsBought.size(); i++) { file << this->productsBought[i] << " "; } //panel data for(int i = 0; i < this->productTries.size(); i++) { file << (int)this->productTries[i] << " "; } //product persuasion for(int i = 0; i < this->productPersuasion.size(); i++) { file << (double)this->productPersuasion[i] << " "; } //product awareness for(int i = 0; i < this->productAwareness.size(); i++) { file << (int)this->productAwareness[i] << " "; } //dynamic attributes for(int i = 0; i < this->dynamic_attributes.size(); i++) { for(da_iter iter = dynamic_attributes[i].begin(); iter != dynamic_attributes[i].end(); ++iter) { file << (int)segment->iProducts[i]->iProductID << " "; file << (int)iter->first << " "; file << (int)iter->second->Aware() << " "; file << (double)iter->second->PreUse() << " "; file << (double)iter->second->PostUse() << " "; } } file << (int)(-1) << " "; file << (double)this->iRepurchaseProb << " "; file << (unsigned int)this->iBoughtThisTick << " "; file << (unsigned int)this->iRecommend << " "; file << (unsigned int)this->iPreferredChannel << " "; file << (unsigned int)this->iProductLastBought << " "; file << endl; } void Consumer::ReadFromFile(ifstream & file) { for(int i = 0; i < this->productsBought.size(); i++) { file >> this->productsBought[i]; } for(int i = 0; i < this->productTries.size(); i++) { file >> this->productTries[i]; if(segment->iModelInfo->reset_panel_data_day >= 0) { this->productTries[i] = -1; } } //product persuasion for(int i = 0; i < this->productPersuasion.size(); i++) { file >> this->productPersuasion[i]; double persuasion = this->productPersuasion[i]; int numPersuasionUnitsToAdd = (int)persuasion; persuasion -= numPersuasionUnitsToAdd; if (persuasion > 0.0) { if (WillDo0to1(persuasion)) { numPersuasionUnitsToAdd += 1; } } else if (persuasion < 0.0) { if (WillDo0to1(0.0 - persuasion)) { numPersuasionUnitsToAdd -= 1; } } segment->iProducts[i]->iTotalPersuasion += numPersuasionUnitsToAdd; segment->iTotalMessages += abs(numPersuasionUnitsToAdd); } //product awareness for(int i = 0; i < this->productAwareness.size(); i++) { file >> this->productAwareness[i]; if(this->productAwareness[i] != -1) { // Moving POPULATION->iPopScaleFactor to segment writer //PRODUCT[i].iNumAwareSofar += POPULATION->iPopScaleFactor; segment->iProducts[i]->iNumAwareSofar += 1; } } int prod_id; int attr_id; int pn; int attr_awareness; double attr_pre_use; double attr_post_use; file >> prod_id; while(prod_id != -1) { file >> attr_id; file >> attr_awareness; file >> attr_pre_use; file >> attr_post_use; pn = segment->ProdIndex(prod_id); dynamic_attributes[pn][attr_id] = new DynamicAttribute(prod_id, attr_id, attr_post_use, attr_pre_use, attr_awareness); file >> prod_id; } file >> this->iRepurchaseProb; file >> this->iBoughtThisTick; file >> this->iRecommend; file >> this->iPreferredChannel; file >> this->iProductLastBought; }
[ "Isaac.Noble@fd82578e-0ebe-11df-96d9-85c6b80b8d9c" ]
[ [ [ 1, 480 ] ] ]
8b580e2a98e6c163843ec760251f075e78a7c0c4
e07af5d5401cec17dc0bbf6dea61f6c048f07787
/summaryview.hpp
a21af8ab197b86dafe53f8da446c3b5ffb61f513
[]
no_license
Mosesofmason/nineo
4189c378026f46441498a021d8571f75579ce55e
c7f774d83a7a1f59fde1ac089fde9aa0b0182d83
refs/heads/master
2016-08-04T16:33:00.101017
2009-12-26T15:25:54
2009-12-26T15:25:54
32,200,899
0
0
null
null
null
null
UTF-8
C++
false
false
2,974
hpp
#ifndef __NEXT_NINEO_SUMMARYVIEW_DEFINE__ #define __NEXT_NINEO_SUMMARYVIEW_DEFINE__ //////////////////////////////////////////////////////////////////////////////// ////////// Author: newblue <[email protected]> ////////// Copyright by newblue, 2008. //////////////////////////////////////////////////////////////////////////////// #include <wx/wx.h> #include "config.hpp" #include <wx/dynarray.h> #include <wx/sashwin.h> #include "vlist.hpp" #include "group.hpp" #include "articledb.hpp" class NiSummaryView : public wxVisualList { public: NiSummaryView ( wxWindow* parent, wxWindowID id ); ~NiSummaryView (); bool Load ( const NiGroup::SubGroup& group ); virtual void OnDrawLine ( wxDC& dc, const size_t& line, const size_t& col, const wxRect& rect ); private: NiDB::ArticleDB *m_db; DECLARE_EVENT_TABLE () }; const int DEFAULT_COL_WIDTH = 100; class NiTreeListHeader; class NiTreeList; class NiTreeListColumn : public wxObject { private: wxString m_label; int m_width, x, y, w, h; bool m_show; public: NiTreeListColumn ( const wxString& label, const int& width = DEFAULT_COL_WIDTH, const bool& show = true ); NiTreeListColumn ( const NiTreeListColumn& sc ); ~NiTreeListColumn (); void SetWidth ( const int& width ); void SetLabel ( const wxString& label ); wxString GetLabel (); int GetWidth (); bool IsShow (); void SetCoord ( const int& ox, const int& oy, const int& ow, const int& oh ); void GetCoord ( int& ox, int& oy, int& ow, int& oh ); }; class NiTreeListCtrl: public wxControl { public: NiTreeListCtrl () : m_header (NULL), m_list(NULL) {} NiTreeListCtrl ( wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = NStyle, const wxValidator &validator = wxDefaultValidator, const wxString& name = wxT("TreeList")) : m_header (NULL), m_list (NULL) { Create (parent, id, pos, size, style, validator, name); #if 0 const wxSize csize(480,380); SetVirtualSize(csize); SetMinSize ( csize ); SetSize (csize); SetClientSize (csize); #endif UI (); } virtual ~NiTreeListCtrl () { }; virtual void Refresh (bool erase, const wxRect* rect); protected: friend class NiTreeList; friend class NiTreeListHeader; NiTreeListHeader* m_header; NiTreeList* m_list; void DoUpdateUI (); private: void UI (); void OnSize (wxSizeEvent& event); DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(NiTreeListCtrl) }; #endif //
[ [ [ 1, 98 ] ] ]
8ae4e09691beed2bbf305f3b4f5fa5bf723ead11
57574cc7192ea8564bd630dbc2a1f1c4806e4e69
/Poker/Comun/UIException.cpp
b9eac38d223f37fc15d0964a082cb551c3d24826
[]
no_license
natlehmann/taller-2010-2c-poker
3c6821faacccd5afa526b36026b2b153a2e471f9
d07384873b3705d1cd37448a65b04b4105060f19
refs/heads/master
2016-09-05T23:43:54.272182
2010-11-17T11:48:00
2010-11-17T11:48:00
32,321,142
0
0
null
null
null
null
UTF-8
C++
false
false
322
cpp
#include "UIException.h" UIException::UIException(string mensaje) : PokerException(mensaje) { } UIException::UIException(string mensaje, string idError) : PokerException(mensaje, idError){ } UIException::UIException(Error& error) : PokerException(error) { } UIException::~UIException() throw() { }
[ "[email protected]@a9434d28-8610-e991-b0d0-89a272e3a296" ]
[ [ [ 1, 17 ] ] ]
a9d65cac373fe5d8832d3b4e56d917f02fd84720
10dae5a20816dba197ecf76d6200fd1a9763ef97
/src/tpatchfitness.cpp
8701bb877aeca6e64492046fd55a89991565fc1b
[]
no_license
peterdfields/quantiNEMO_Taylor2010
fd43aba9b1fcf504132494ff63d08a9b45b3f683
611b46bf89836c4327fe64abd7b4008815152c9f
refs/heads/master
2020-02-26T17:33:24.396350
2011-02-08T23:08:34
2011-02-08T23:08:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,944
cpp
/** @file tpatchfitness.cpp * * Copyright (C) 2008 Samuel Neuenschwander <[email protected]> * * quantiNEMO: * quantiNEMO is an individual-based, genetically explicit stochastic * simulation program. It was developed to investigate the effects of * selection, mutation, recombination, and drift on quantitative traits * with varying architectures in structured populations connected by * migration and located in a heterogeneous habitat. * * quantiNEMO is built on the evolutionary and population genetics * programming framework NEMO (Guillaume and Rougemont, 2006, Bioinformatics). * * * Licensing: * This file is part of quantiNEMO. * * quantiNEMO 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. * * quantiNEMO 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 quantiNEMO. If not, see <http://www.gnu.org/licenses/>. */ #include "tpatchfitness.h" //--------------------------------------------------------------------------- // constructor // ----------------------------------------------------------------------------- void TPatchFitness::init(int size){ if(size){ _nbInd = _capacity = size; _aInd = new Individual*[_nbInd]; _aFit = new double[_nbInd]; } else{ _nbInd = _capacity = 0; _aInd = NULL; _aFit = NULL; } _nbSubset = 0; _sort = 10; } // ----------------------------------------------------------------------------- // constructor // ----------------------------------------------------------------------------- void TPatchFitness::resize(const unsigned int& size){ if(size > _capacity){ if(_aInd) delete[] _aInd; if(_aFit) delete[] _aFit; _aInd = new Individual*[size]; _aFit = new double[size]; } _nbInd = size; } // ----------------------------------------------------------------------------- // constructor // ----------------------------------------------------------------------------- double TPatchFitness::getMeanFitness(){ if(!_nbInd)return 0; return getSumFitness()/_nbInd; } double TPatchFitness::getSumFitness(){ if(!_nbInd)return 0; switch(_sort){ // cumulative case -3: case -2: case -1: case 0 : return _aFit[_nbInd-1]; // reverse cumulative case 1 : case 2 : case 3 :{ double sum = 1.0/_aFit[0]; // first indvidual for(unsigned int i=1; i<_nbInd; ++i){ sum += 1.0/(_aFit[i]-_aFit[i-1]); } return sum; } // array is not cumulative case 10: return ARRAY::sum(_aFit, _nbInd); } fatal("TPatchFitness::getSumFitness not correctly implemented!\n"); return 1; } // ----------------------------------------------------------------------------- // _sort // ----------------------------------------------------------------------------- /** the function is called when the first time a individual is drawn (_sort == -1) * sort: 10: the fitnesses were never used before (don't make a cumulative array * -3: decremental sort (highest fitness first) subset random most fittest * -2: decremental sort (highest fitness first) subset fix most fittest * -1: decremental sort (highest fitness first) -> normal cumulative * 0: no sort -> normal cumulative * 1: incremental sort (lowest fitness first) -> reverse cumulative * 2: incremental sort (lowest fitness first) subset fix less fittest * 3: incremental sort (lowest fitness first) subset random less fittest * nbInd: 0: all individuals are used (default) * else : a subset has to be created */ void TPatchFitness::sort(int sort, unsigned int nbInd){ _sort = sort; // check the subset size if(sort==-3 || sort==-2){ // decrement sort subset assert(nbInd>0); // nbInd must be specified if(nbInd>=_nbInd)_sort = -1; // if the subset is bigger then the number of individuals no subset is needed } else if(sort==2 || sort==3){ // increment sort subset assert(nbInd>0); // nbInd must be specified if(nbInd>=_nbInd)_sort = 1; // if the subset is bigger then the number of individuals no subset is needed } switch(sort){ // decrement (most fittest): case -3: // random subset randomize_order_mostFit(_aFit, _aInd, _nbInd, nbInd); ARRAY::cumulative(_aFit, _nbInd); break; case -2: // fixed subset ARRAY::quicksortBoth(_aFit, _nbInd, _aInd, false); // fittest first ARRAY::cumulative(_aFit, _nbInd); break; case -1: // no subset ARRAY::cumulative(_aFit, _nbInd); break; // neutral (fitness not considered, for testing) case 0: randomize_order_noFit(_aFit, _aInd, _nbInd); // the order has to be randomized ARRAY::cumulative(_aFit, _nbInd); break; // increment (less fittest) case 1: // no subset ARRAY::reverse_cumulative(_aFit, _nbInd); break; case 2: // fixed subset ARRAY::quicksortBoth(_aFit, _nbInd, _aInd, true); // less fittest first ARRAY::reverse_cumulative(_aFit, _nbInd); break; case 3: // random subset randomize_order_lessFit(_aFit, _aInd, _nbInd, nbInd); ARRAY::reverse_cumulative(_aFit, _nbInd); break; } } // ---------------------------------------------------------------------------------------- // set_subset_random:: // ---------------------------------------------------------------------------------------- /** Randomize the order of the indivduals */ void TPatchFitness::randomize_order_noFit(double* aFit, Individual** aInd, unsigned int& size, unsigned int nbSubset){ // we start randomly drawing individuals for the first position // this fiest individual is then swapted with the drawn individual unsigned int pos; if(!size || size<nbSubset) nbSubset=size; for(unsigned int i=0; i<nbSubset; ++i){ pos = SimRunner::r.Uniform(size-i); // get the random individual form the curent position (included) to the last position if(pos != i){ // if it is not the same element swap them ARRAY::swap(aFit, pos, i+pos); // swap the fitness ARRAY::swap(aInd, pos, i+pos); // swap the individual } } } // ---------------------------------------------------------------------------------------- // set_subset_random:: // ---------------------------------------------------------------------------------------- /** Randomize the order of the indivduals */ void TPatchFitness::randomize_order_mostFit(double* aFit, Individual** aInd, unsigned int& size, unsigned int nbSubset){ // we start randomly drawing individuals for the first position // this first individual is then swapted with the drawn individual unsigned int pos; if(!size || size<nbSubset) _nbSubset = size; else _nbSubset = nbSubset; for(unsigned int i=0; i<nbSubset; ++i){ pos = SimRunner::r.AfterDistribution(aFit+i, size-i); // get the random individual form the current position (included) to the last position if(pos != i){ // if it is not the same element swap them ARRAY::swap(aFit, pos, i+pos); // swap the fitness ARRAY::swap(aInd, pos, i+pos); // swap the individual } } } // ---------------------------------------------------------------------------------------- // set_subset_random:: // ---------------------------------------------------------------------------------------- /** Randomize the order of the indivduals */ void TPatchFitness::randomize_order_lessFit(double* aFit, Individual** aInd, unsigned int& size, unsigned int nbSubset){ // we start randomly drawing individuals for the first position // this first individual is then swapted with the drawn individual unsigned int pos; if(!size || size<nbSubset) _nbSubset = size; else _nbSubset = nbSubset; for(unsigned int i=0; i<_nbSubset; ++i){ pos = SimRunner::r.AfterDistribution(aFit+i, size-i, -1); // get the random individual form the current position (included) to the last position if(pos != i){ // if it is not the same element swap them ARRAY::swap(aFit, pos, i+pos); // swap the fitness ARRAY::swap(aInd, pos, i+pos); // swap the individual } } } // ---------------------------------------------------------------------------------------- // remove:: // ---------------------------------------------------------------------------------------- /* remove the specified individual from the list and adjust the rest * this can only be done if a subset is not randomly drawn */ void TPatchFitness::remove(unsigned int i){ assert(i<_nbInd); assert((_sort>=-2 && _sort<=2) || _sort==10); // remove the individual if(_sort == 10){ // fitness array is not cumulative ++i; for(; i<_nbInd; ++i){ _aFit[i-1] = _aFit[i]; _aInd[i-1] = _aInd[i]; } } else { // fitness array is cumulative double diff = i ? _aFit[i]-_aFit[i-1] : _aFit[0]; // get the fitness of the individual ++i; for(; i<_nbInd; ++i){ _aFit[i-1] = _aFit[i]-diff; _aInd[i-1] = _aInd[i]; } } --_nbInd; // decrement the pop size by 1 }
[ [ [ 1, 260 ] ] ]
012cfa99e0ed10bd04461a308930cfa61e52aef9
6e4f9952ef7a3a47330a707aa993247afde65597
/PROJECTS_ROOT/SmartWires/HLayout/behaviors/behavior_grid.cpp
a1dabe91473f5c5eb8d704f679d4e0842fa617bf
[]
no_license
meiercn/wiredplane-wintools
b35422570e2c4b486c3aa6e73200ea7035e9b232
134db644e4271079d631776cffcedc51b5456442
refs/heads/master
2021-01-19T07:50:42.622687
2009-07-07T03:34:11
2009-07-07T03:34:11
34,017,037
2
1
null
null
null
null
UTF-8
C++
false
false
13,375
cpp
#include "stdafx.h" #include "behaviors/behavior_aux.h" namespace htmlayout { /** behavior:grid, browser of tabular data (records). * Supports multiple selection mode. Use "multiple" attribute. * * model is like this: * <table fixedrows=1 ... style="behavior:grid"> * <tr>... * <tr>... * </table> * * LOGICAL EVENTS: * TABLE_HEADER_CLICK, click on some cell in table header, target is the cell * TABLE_ROW_CLICK, click on data row in the table, target is the row * * See: html_samples/grid/scrollable-table.htm * Authors: Andrew Fedoniouk, initial implementation. * Andrey Kubyshev, multiselection mode. * **/ struct grid: public behavior { // ctor grid(const char* name = "grid", int additional_flags = 0): behavior(HANDLE_MOUSE | HANDLE_KEY | HANDLE_FOCUS | additional_flags, name) {} virtual void attached (HELEMENT he ) { #ifdef _DEBUG dom::element table = he; assert( aux::streq(table.get_element_type(), "table") ); // must be table. #endif } /** is it multiple selectable? **/ bool is_multiple (const dom::element& table) { return table.get_attribute ("multiple") != 0; } /** Click on column header (fixed row). Overrided in sortable-grid **/ virtual void on_column_click( dom::element& table, dom::element& header_cell ) { table.post_event( TABLE_HEADER_CLICK, header_cell.index(), header_cell); } /** returns current row (if any) **/ dom::element get_current_row( dom::element& table ) { for( int i = table.children_count() - 1; i >= 0 ; --i) { dom::element t = table.child((unsigned int)i); if( t.get_state(STATE_CURRENT)) return t; } return dom::element(); // empty } /** set current row **/ void set_current_row( dom::element& table, dom::element& row, UINT keyboardStates, bool dblClick = false ) { if(is_multiple(table)) { if (keyboardStates & SHIFT_KEY_PRESSED) { checkall(table, false); check_range(table,row.index(),TRUE); // from current to new } else { if (keyboardStates & CONTROL_KEY_PRESSED) set_checked_row (table,row, true); // toggle else checkall(table, false); set_anchor(table,row.index ()); } } // get previously selected row: dom::element prev = get_current_row( table ); if( prev.is_valid() ) { if( prev != row ) prev.set_state(0,STATE_CURRENT, false); // drop state flags } row.set_state(STATE_CURRENT); // set state flags row.scroll_to_view(); ::UpdateWindow(row.get_element_hwnd(false)); table.post_event( dblClick? TABLE_ROW_DBL_CLICK:TABLE_ROW_CLICK, row.index(), row); } dom::element target_row(const dom::element& table, const dom::element& target) { if( !target.is_valid() || target.parent() == table) return target; return target_row(table,target.parent()); } dom::element target_header(const dom::element& header_row, const dom::element& target) { if( !target.is_valid() || target.parent() == header_row) return target; return target_header(header_row,target.parent()); } int fixed_rows( const dom::element& table ) { return table.get_attribute_int("fixedrows",0); } void set_checked_row( dom::element& table, dom::element& row, bool toggle = false ) { if(toggle) { if( row.get_state( STATE_CHECKED) ) row.set_state( 0,STATE_CHECKED,false); else row.set_state( STATE_CHECKED,0,false); } else row.set_state( STATE_CHECKED,0,false); } int get_anchor (const dom::element& table) { dom::element row = table.find_first("tr:anchor"); if( row.is_valid() ) return (int)row.index(); return 0; } void set_anchor (dom::element& table,const int idx) { dom::element row = table.find_first("tr:anchor"); if( row.is_valid() ) row.set_state( 0,STATE_ANCHOR,false); row = table.child(idx); if( row.is_valid() ) row.set_state( STATE_ANCHOR | STATE_CHECKED,0,false); } void check_range (const dom::element& table, int idx, bool check) { if (!is_multiple(table)) return; int start_idx = get_anchor(table); int start = min(start_idx,idx ); int end = max(start_idx,idx ); int f_rows = fixed_rows(table); if(start < f_rows) start = f_rows; for( ;end >= start; --end ) { dom::element row = table.child(end); if(!aux::wcseq(row.get_style_attribute("display"),L"none" )) { if (check) row.set_state(STATE_CHECKED,0,false); else row.set_state(0,STATE_CHECKED,false); } } } virtual BOOL on_mouse(HELEMENT he, HELEMENT target, UINT event_type, POINT pt, UINT mouseButtons, UINT keyboardStates ) { if( event_type != MOUSE_DOWN && event_type != MOUSE_DCLICK ) return false; if(mouseButtons != MAIN_MOUSE_BUTTON) return false; // el must be table; dom::element table = he; dom::element row = target_row(table, dom::element(target)); if(row.is_valid()) // click on the row { if( (int)row.index() < (int)fixed_rows(table) ) { // click on the header cell dom::element header_cell = target_header(row,target); if( header_cell.is_valid() ) on_column_click(table, header_cell); return true; } set_current_row(table, row, keyboardStates, event_type == MOUSE_DCLICK); } return true; // as it is always ours then stop event bubbling } virtual BOOL on_key(HELEMENT he, HELEMENT target, UINT event_type, UINT code, UINT keyboardStates ) { if( event_type == KEY_DOWN ) { dom::element table = he; switch( code ) { case VK_DOWN: { dom::element c = get_current_row( table ); int idx = c.is_valid()? (c.index() + 1):fixed_rows(table); while( idx < (int)table.children_count() ) { dom::element row = table.child(idx); if( aux::wcseq(row.get_style_attribute("display"),L"none" )) { ++idx; continue; } set_current_row(table, row, keyboardStates); break; } } return TRUE; case VK_UP: { dom::element c = get_current_row( table ); int idx = c.is_valid()? (c.index() - 1):(table.children_count() - 1); while( idx >= fixed_rows(table) ) { dom::element row = table.child(idx); if( aux::wcseq(row.get_style_attribute("display"),L"none" )) { --idx; continue; } set_current_row(table, row, keyboardStates); break; } } return TRUE; case VK_PRIOR: { RECT trc = table.get_location(ROOT_RELATIVE | SCROLLABLE_AREA); int y = trc.top - (trc.bottom - trc.top); int first = fixed_rows(table); dom::element r; for( int i = table.children_count() - 1; i >= first; --i ) { dom::element nr = table.child(i); if( aux::wcseq(nr.get_style_attribute("display"),L"none" )) continue; dom::element pr = r; r = nr; if( r.get_location(ROOT_RELATIVE | BORDER_BOX).top < y ) { // row found if(pr.is_valid()) r = pr; // to last fully visible break; } } set_current_row(table, r, keyboardStates); } return TRUE; case VK_NEXT: { RECT trc = table.get_location(ROOT_RELATIVE | SCROLLABLE_AREA); int y = trc.bottom + (trc.bottom - trc.top); int last = table.children_count() - 1; dom::element r; for( int i = fixed_rows(table); i <= last; ++i ) { dom::element nr = table.child(i); if( aux::wcseq(nr.get_style_attribute("display"),L"none" )) continue; dom::element pr = r; r = nr; if( r.get_location(ROOT_RELATIVE | BORDER_BOX).bottom > y ) { // row found if(pr.is_valid()) r = pr; // to last fully visible break; } } set_current_row(table, r, keyboardStates); } return TRUE; case VK_HOME: { int idx = fixed_rows(table); while( (int)idx < (int)table.children_count() ) { dom::element row = table.child(idx); if( aux::wcseq(row.get_style_attribute("display"),L"none" )) { ++idx; continue; } set_current_row(table, row, keyboardStates); break; } } return TRUE; case VK_END: { int idx = table.children_count() - 1; while( idx >= fixed_rows(table) ) { dom::element row = table.child(idx); if( aux::wcseq(row.get_style_attribute("display"),L"none" )) { --idx; continue; } set_current_row(table, row, keyboardStates); break; } } return TRUE; case 'A': if( is_multiple(table) && (keyboardStates & CONTROL_KEY_PRESSED) != 0 ) { checkall(table, true); return TRUE; } return FALSE; } } return FALSE; } void checkall (dom::element& table, bool onOff ) { if( !is_multiple(table) ) return; struct unchecker_cb: dom::callback { bool on_element(HELEMENT he) { htmlayout::dom::element el = he; if( el.get_state(STATE_CHECKED)) el.set_state(0,STATE_CHECKED,false ); return false; /*continue enumeration*/ } }; struct checker_cb: dom::callback { bool on_element(HELEMENT he) { htmlayout::dom::element el = he; if( !el.get_state(STATE_CHECKED)) el.set_state(STATE_CHECKED,0,false ); return false; /*continue enumeration*/ } }; if(onOff) { checker_cb checker; table.find_all(&checker,"tr"); } else { unchecker_cb unchecker; table.find_all(&unchecker,"tr:checked"); } } }; struct sortable_grid: public grid { typedef grid super; // ctor sortable_grid(): super("sortable-grid") {} virtual void on_column_click( dom::element& table, dom::element& header_cell ) { super::on_column_click( table, header_cell ); dom::element current = table.find_first("th:checked"); if( current == header_cell ) return; // already here, nothing to do. if( current.is_valid() ) current.set_state(0, STATE_CHECKED); header_cell.set_state(STATE_CHECKED); dom::element ctr = get_current_row( table ); sort_rows( table, header_cell.index() ); if( ctr.is_valid() ) ctr.scroll_to_view(); } struct row_sorter: public dom::element::comparator { int column_no; row_sorter( int col_no ): column_no(col_no) {} virtual int compare(const htmlayout::dom::element& r1, const htmlayout::dom::element& r2) { if( !r1.is_valid() || !r2.is_valid() ) return 0; htmlayout::dom::element c1 = r1.child(column_no); htmlayout::dom::element c2 = r2.child(column_no); const wchar_t* t1 = c1.text(); const wchar_t* t2 = c2.text(); if( !t1 || !t2 ) return 0; return wcscmp(t1,t2); } }; void sort_rows( dom::element& table, int column_no ) { row_sorter rs( column_no ); int fr = fixed_rows( table ); table.sort(rs,fr); table.update(true); } }; // instantiating and attaching it to the global list grid grid_instance; sortable_grid sortable_grid_instance; }
[ "wplabs@3fb49600-69e0-11de-a8c1-9da277d31688" ]
[ [ [ 1, 431 ] ] ]
26205c441c0eaba4f3d1e5322b3e427ac01356ca
f992ff7d77a993c11768dd509c0307f782a13af0
/Projekt/src/map/Platform.cpp
175d7a5139a13e8b01901c5d58cda4dfa2a3f415
[]
no_license
mariojas/mariusz
6b0889f3ae623400274ab9448ee8f93556336618
965209b0ae0400991b9ceab4c5177b63116302ca
refs/heads/master
2021-01-23T03:13:01.384598
2010-05-03T10:27:47
2010-05-03T10:27:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
288
cpp
#include <allegro.h> #include "Platform.h" int Platform::getX() { return x; } int Platform::getY() { return y; } int Platform::getW() { return w; } int Platform::getH() { return h; } Platform::Platform(int _x, int _y, int _w, int _h) : x(_x), y(_y), w(_w), h(_h) {}
[ "ryba@ryb-520fb58ee61.(none)" ]
[ [ [ 1, 15 ] ] ]
32d2abd2001f53695be4d93a055ca5dcab69b9dd
3e69b159d352a57a48bc483cb8ca802b49679d65
/tags/release-2005-10-27/common/eda_doc.cpp
576b6cae2013d9841b5ce904837974facb0ae36e
[]
no_license
BackupTheBerlios/kicad-svn
4b79bc0af39d6e5cb0f07556eb781a83e8a464b9
4c97bbde4b1b12ec5616a57c17298c77a9790398
refs/heads/master
2021-01-01T19:38:40.000652
2006-06-19T20:01:24
2006-06-19T20:01:24
40,799,911
0
0
null
null
null
null
ISO-8859-1
C++
false
false
4,995
cpp
/***************/ /* eda_doc.cpp */ /***************/ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif // for all others, include the necessary headers (this file is usually all you // need because it includes almost all "standard" wxWindows headers #ifndef WX_PRECOMP #include <wx/wx.h> #endif #include <wx/mimetype.h> #include <wx/tokenzr.h> #include "wxstruct.h" #include "common.h" // Mime type extensions static wxMimeTypesManager * mimeDatabase; static const wxFileTypeInfo EDAfallbacks[] = { wxFileTypeInfo("text/pdf", "xpdf %s", "xpdf -p %s" "pdf document (from Kicad)", "pdf", "PDF", NULL), wxFileTypeInfo("text/html", "wxhtml %s", "wxhtml %s" "html document (from Kicad)", "htm", "html", NULL), wxFileTypeInfo("application/sch", "eeschema %s", "eeschema -p %s" "sch document (from Kicad)", "sch", "SCH", NULL), // must terminate the table with this! wxFileTypeInfo() }; /********************************************************************/ bool GetAssociatedDocument(wxFrame * frame, const wxString & LibPath, const wxString & DocName) /*********************************************************************/ /* appelle le viewer associé au fichier de doc du composant (mime type) LibPath est le prefixe du chemin des docs (/usr/local/kicad/library par exe.) DocName est le nom du fichier. Les wildcarts sont autorisees la recherche se fait sur LibPath/doc/DocName On peut spécifier plusieus noms séparés ar des ; dans DocName */ { wxString docpath, fullfilename; wxString Line; bool success = FALSE; /* Calcul du nom complet du fichier de documentation */ if ( wxIsAbsolutePath(DocName) ) fullfilename = DocName; else { docpath = LibPath + "doc/" ; fullfilename = docpath + DocName; } #ifdef __WINDOWS__ fullfilename.Replace("/", "\\"); #else fullfilename.Replace("\\", "/"); #endif if ( wxIsWild(fullfilename) ) { fullfilename = EDA_FileSelector(_("Doc Files"), /* Titre de la fenetre */ wxPathOnly(fullfilename), /* Chemin par defaut */ fullfilename, /* nom fichier par defaut */ "", /* extension par defaut */ "", /* Masque d'affichage */ frame, /* parent frame */ wxOPEN, /* wxSAVE, wxOPEN ..*/ TRUE, /* true = ne change pas le repertoire courant */ wxPoint(-1,-1) ); if ( fullfilename == "") return FALSE; } if ( ! wxFileExists(fullfilename) ) { Line = _("Doc File ") + fullfilename + _(" not found"); DisplayError(frame, Line); return FALSE; } wxFileType * filetype; wxFileName CurrentFileName(fullfilename); wxString ext, command, type; ext = CurrentFileName.GetExt(); filetype = wxTheMimeTypesManager->GetFileTypeFromExtension(ext); if ( ! filetype ) // 2ieme tentative { mimeDatabase = new wxMimeTypesManager; mimeDatabase->AddFallbacks(EDAfallbacks); filetype = mimeDatabase->GetFileTypeFromExtension(ext); delete mimeDatabase; mimeDatabase = NULL; } if ( filetype ) { wxFileType::MessageParameters params(fullfilename, type); success = filetype->GetOpenCommand( &command, params); delete filetype; if ( success ) wxExecute(command); } if ( ! success) { #ifdef __LINUX__ if ( ext == "pdf" ) { success = TRUE; command = ""; if ( wxFileExists("/usr/bin/xpdf") ) command = "xpdf " + fullfilename; else if ( wxFileExists("/usr/bin/konqueror") ) command = "konqueror " + fullfilename; if ( command == "" ) // not started { DisplayError(frame, _(" Cannot find the PDF viewer (xpdf or konqueror) in /usr/bin/") ); success = FALSE; } else wxExecute(command); } else #endif { Line.Printf( _("Unknown MIME type for Doc File [%s] (%s)"), fullfilename.GetData(), ext.GetData()); DisplayError(frame, Line); } } return success; } /******************************************************************/ int KeyWordOk(const wxString & KeyList, const wxString & Database ) /******************************************************************/ /* Recherche si dans le texte Database on retrouve tous les mots cles donnes dans KeyList ( KeyList = suite de mots cles separes par des espaces Retourne: 0 si aucun mot cle trouvé 1 si mot cle trouvé */ { wxString KeysCopy, DataList; if( KeyList.IsEmpty() ) return(0); KeysCopy = KeyList; KeysCopy.MakeUpper(); DataList = Database; DataList.MakeUpper(); wxStringTokenizer Token(KeysCopy, wxT(" \n\r")); while ( Token.HasMoreTokens() ) { wxString Key = Token.GetNextToken(); // Search Key in Datalist: wxStringTokenizer Data(DataList, wxT(" \n\r")); while ( Data.HasMoreTokens() ) { wxString word = Data.GetNextToken(); if ( word == Key ) return 1; // Key found ! } } // keyword not found return(0); }
[ "bokeoa@244deca0-f506-0410-ab94-f4f3571dea26" ]
[ [ [ 1, 189 ] ] ]
fd5ffc9f588dbabb733d88d4ed4a817888807b7b
cfcd2a448c91b249ea61d0d0d747129900e9e97f
/thirdparty/OpenCOLLADA/COLLADAFramework/include/COLLADAFWMatrix.h
4cfdcafc129acd70748345acb89f6680f24cee09
[]
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
UTF-8
C++
false
false
1,325
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_MATRIX_H__ #define __COLLADAFW_MATRIX_H__ #include "COLLADAFWPrerequisites.h" #include "COLLADAFWTransformation.h" #include "Math/COLLADABUMathMatrix4.h" namespace COLLADAFW { class Matrix : public Transformation { private: /** The matrix holding the transformation.*/ COLLADABU::Math::Matrix4 mMatrix; public: /** Constructor. Creates identity transformation.*/ Matrix(); virtual ~Matrix(); /** Constructor. Sets transformation to @a matrix.*/ Matrix(const COLLADABU::Math::Matrix4& matrix); /** Returns the matrix.*/ COLLADABU::Math::Matrix4& getMatrix() { return mMatrix; } /** Returns the matrix.*/ const COLLADABU::Math::Matrix4& getMatrix() const { return mMatrix; } /** Sets the transformation to @a matrix.*/ void setMatrix(const COLLADABU::Math::Matrix4& matrix) { mMatrix = matrix; } /** Clones the matrix.*/ Matrix* clone() const { return new Matrix(*this); } }; } // namespace COLLADAFW #endif // __COLLADAFW_MATRIX_H__
[ [ [ 1, 53 ] ] ]
71878608ad126cc6342ff1c0c9138f97f127100c
5e5e02f7663d86089d87d47aebf609ec6dbcf97c
/Tutorial.h
509d5982f83b09b2adce0b3a950d36397c918715
[]
no_license
mcejp/PacWorld
3483fce6512848dbc45dcea33a558b522faf24e2
b900387ac36d3f2f226c4534cd34ba90c7e7e9c3
refs/heads/master
2020-05-18T17:23:10.795308
2000-10-08T09:22:14
2019-05-02T09:22:14
184,553,619
2
0
null
null
null
null
ISO-8859-1
C++
false
false
1,325
h
#if !defined(AFX_TUTORIAL_H__0B1C6640_C227_11D3_A5E4_ACE3C4ADA636__INCLUDED_) #define AFX_TUTORIAL_H__0B1C6640_C227_11D3_A5E4_ACE3C4ADA636__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // Tutorial.h : Header-Datei // #include "BtnST.h" #include "ColorStaticST.h" ///////////////////////////////////////////////////////////////////////////// // Dialogfeld CTutorial class CTutorial : public CDialog { // Konstruktion public: CTutorial(CWnd* pParent = NULL); // Standardkonstruktor // Dialogfelddaten //{{AFX_DATA(CTutorial) enum { IDD = IDD_TUTORIAL }; CColorStaticST m_editStatic; CButtonST m_ok; CString m_edit; //}}AFX_DATA // Überschreibungen // Vom Klassen-Assistenten generierte virtuelle Funktionsüberschreibungen //{{AFX_VIRTUAL(CTutorial) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV-Unterstützung //}}AFX_VIRTUAL // Implementierung protected: // Generierte Nachrichtenzuordnungsfunktionen //{{AFX_MSG(CTutorial) virtual BOOL OnInitDialog(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ fügt unmittelbar vor der vorhergehenden Zeile zusätzliche Deklarationen ein. #endif // AFX_TUTORIAL_H__0B1C6640_C227_11D3_A5E4_ACE3C4ADA636__INCLUDED_
[ [ [ 1, 49 ] ] ]
9cd73a51093a6574f316d44469c84abb7242aae2
2b1d0ce1f134ccd6b2d46a5bda933c8edb822704
/installation/net_installer/win32/newprogress/main.cpp
157b14cad1b7b983783b9e6bbb079b71ad1b2f8a
[ "Apache-2.0" ]
permissive
pjunior/titanium
50e9a2163ef8b9115e718538b4f6a5551638cfe9
2d5846849fb33291afd73d79c117ea990b54db77
refs/heads/master
2020-12-25T16:02:23.138411
2009-04-02T01:18:45
2009-04-02T01:18:45
166,180
3
0
null
null
null
null
UTF-8
C++
false
false
8,926
cpp
/** * Appcelerator Titanium - licensed under the Apache Public License 2 * see LICENSE in the root folder for details on the license. * Copyright (c) 2009 Appcelerator, Inc. All Rights Reserved. */ #include <windows.h> #include <objbase.h> #include <Wininet.h> #include <vector> #include <iostream> #include <fstream> #include <io.h> #include <stdlib.h> #include <stdio.h> #include "Progress.h" #include "Resource.h" #define alert(msg) MessageBoxA(GetDesktopWindow(), msg, "Message", MB_OK); #define walert(msg) MessageBoxW(GetDesktopWindow(), msg, L"Message", MB_OK); #define DISTRIBUTION_UUID L"7F7FA377-E695-4280-9F1F-96126F3D2C2A" #define RUNTIME_UUID L"A2AC5CB5-8C52-456C-9525-601A5B0725DA" #define MODULE_UUID L"1ACE5D3A-2B52-43FB-A136-007BD166CFD0" std::wstring ParseQueryParam(std::wstring uri, std::wstring name) { std::wstring key = name; key+=L"="; size_t pos = uri.find(key); if (pos!=std::wstring::npos) { std::wstring p = uri.substr(pos + key.length()); pos = p.find(L"&"); if (pos!=std::wstring::npos) { p = p.substr(0,pos); } // decode WCHAR szOut[INTERNET_MAX_URL_LENGTH]; DWORD cchDecodedUrl = INTERNET_MAX_URL_LENGTH; CoInternetParseUrl(p.c_str(), PARSE_UNESCAPE, 0, szOut, INTERNET_MAX_URL_LENGTH, &cchDecodedUrl, 0); p.assign(szOut); return p; } return L""; } std::wstring ProgressString(DWORD size, DWORD total) { char str[1024]; #define KB 1024 #define MB KB * 1024 if (total < KB) { sprintf(str, "%0.2f of %0.2f bytes", size, total); } else if (size < MB) { double totalKB = total/1024.0; double sizeKB = size/1024.0; sprintf(str, "%0.2f of %0.2f KB", sizeKB, totalKB); } else { // hopefully we shouldn't ever need to count more than 1023 in a single file! double totalMB = total/1024.0/1024.0; double sizeMB = size/1024.0/1024.0; sprintf(str, "%0.2f of %0.2f MB", size, total); } wchar_t wstr[1024]; mbtowc(wstr, str, strlen(str)); return std::wstring(wstr); } bool DownloadURL(Progress *p, HINTERNET hINet, std::wstring url, std::wstring outFilename) { WCHAR szDecodedUrl[INTERNET_MAX_URL_LENGTH]; DWORD cchDecodedUrl = INTERNET_MAX_URL_LENGTH; WCHAR szDomainName[INTERNET_MAX_URL_LENGTH]; // parse the URL HRESULT hr = CoInternetParseUrl(url.c_str(), PARSE_DECODE, URL_ENCODING_NONE, szDecodedUrl, INTERNET_MAX_URL_LENGTH, &cchDecodedUrl, 0); if (hr != S_OK) { return false; } // figure out the domain/hostname hr = CoInternetParseUrl(szDecodedUrl, PARSE_DOMAIN, 0, szDomainName, INTERNET_MAX_URL_LENGTH, &cchDecodedUrl, 0); if (hr != S_OK) { return false; } // start the HTTP fetch HINTERNET hConnection = InternetConnectW( hINet, szDomainName, 80, L" ", L" ", INTERNET_SERVICE_HTTP, 0, 0 ); if ( !hConnection ) { return false; } std::wstring wurl(szDecodedUrl); std::wstring path = wurl.substr(wurl.find(szDomainName)+wcslen(szDomainName)); //std::wstring queryString = url.substr(url.rfind("?")+1); //astd::wstring object = path + "?" + queryString; HINTERNET hRequest = HttpOpenRequestW( hConnection, L"GET", path.c_str(), NULL, NULL, NULL, INTERNET_FLAG_RELOAD|INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_NO_COOKIES|INTERNET_FLAG_NO_UI|INTERNET_FLAG_IGNORE_CERT_CN_INVALID|INTERNET_FLAG_IGNORE_CERT_DATE_INVALID, 0 ); if ( !hRequest ) { InternetCloseHandle(hConnection); return false; } // now stream the resulting HTTP into a file std::ofstream ostr; ostr.open(outFilename.c_str(), std::ios_base::binary | std::ios_base::trunc); bool failed = false; CHAR buffer[2048]; DWORD dwRead; DWORD total = 0; wchar_t msg[255]; HttpSendRequest( hRequest, NULL, 0, NULL, 0); while( InternetReadFile( hRequest, buffer, 2047, &dwRead ) ) { if ( dwRead == 0) { break; } if (p->IsCancelled()) { failed = true; break; } buffer[dwRead] = '\0'; total+=dwRead; ostr.write(buffer, dwRead); wsprintfW(msg,L"Downloaded %d KB",total/1024); p->SetLineText(2,msg,true); } ostr.close(); InternetCloseHandle(hConnection); InternetCloseHandle(hRequest); return ! failed; } BOOL DirectoryExists(std::wstring dirName) { DWORD attribs = ::GetFileAttributesW(dirName.c_str()); if (attribs == INVALID_FILE_ATTRIBUTES) { return false; } return (attribs & FILE_ATTRIBUTE_DIRECTORY); } void CreateDirectoryTree(std::wstring dir) { if(! DirectoryExists(dir)) { // ensure parent dir exits int lastSlash = dir.find_last_of(L"\\"); if(lastSlash != std::wstring::npos) { std::wstring parent = dir.substr(0, lastSlash); CreateDirectoryTree(parent); } // by this point, all parent dirs are created CreateDirectoryW(dir.c_str(), NULL); } } bool UnzipFile(std::wstring unzipper, std::wstring zipFile, std::wstring destdir) { // ensure destdir exists CreateDirectoryTree(destdir); // now we're going to invoke back into the boot to unzip our file and install STARTUPINFOW si; PROCESS_INFORMATION pi; ZeroMemory( &si, sizeof(si) ); ZeroMemory( &pi, sizeof(pi) ); si.cb = sizeof(si); std::wstring cmdline = L"\""; cmdline+=unzipper; cmdline+=L"\" --tiunzip \""; cmdline+=zipFile; cmdline+=L"\" \""; cmdline+=destdir; cmdline+=L"\""; // in win32, we just invoke back the same process and let him unzip if (!CreateProcessW(NULL,(LPWSTR)cmdline.c_str(),NULL,NULL,FALSE,NULL,NULL,NULL,&si,&pi)) { return false; } // wait for the process to finish unzipping WaitForSingleObject(pi.hProcess,INFINITE); return true; } int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { //TODO: set the icon for this app and dialogs // HICON icon = LoadIcon(hInstance,MAKEINTRESOURCE(IDR_MAINFRAME)); // SendMessage(NULL, WM_SETICON, (WPARAM)true, (LPARAM)icon); // get the command line LPWSTR cmdline = GetCommandLineW(); int argcount = 0; LPWSTR *args = CommandLineToArgvW(cmdline,&argcount); // we must have at least the mandatory args + 1 URL if (argcount < 7) { MessageBoxW(GetDesktopWindow(),L"Invalid arguments passed to Installer",L"Application Error",MB_OK|MB_SYSTEMMODAL|MB_ICONEXCLAMATION); return 1; } std::wstring appname = args[1]; std::wstring title = args[2]; std::wstring message = args[3]; std::wstring appTitle = appname + L" Installer"; std::wstring tempdir = args[4]; std::wstring installdir = args[5]; std::wstring unzipper = args[6]; // verify the installation std::wstring tempTitle = appname + L" - " + title; if (IDOK != MessageBoxW(GetDesktopWindow(),message.c_str(),tempTitle.c_str(),MB_ICONINFORMATION|MB_OKCANCEL|MB_TOPMOST)) { MessageBoxW(GetDesktopWindow(),L"Installation Aborted. To install later, re-run the application again.", tempTitle.c_str(), MB_OK|MB_ICONWARNING|MB_TOPMOST); return 1; } int count = argcount - 7; int startAt = 7; CoInitialize(NULL); // create our progress indicator class Progress *p = new Progress; p->SetTitle(appTitle.c_str()); p->SetCancelMessage(L"Cancelling, one moment..."); wchar_t buf[255]; wsprintfW(buf,L"Preparing to download %d file%s", count, (count > 1 ? L"s" : L"")); p->SetLineText(1,std::wstring(buf),true); p->Show(); p->Update(0,count); // initialize interent DLL HINTERNET hINet = InternetOpenW(L"Mozilla/5.0 (compatible; Titanium_Downloader/0.1; Win32)", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 ); // for each URL, fetch the URL and then unzip it bool failed = false; DWORD x = 0; for (int c=startAt;c<argcount;c++) { p->Update(x++,count); std::wstring url = args[c]; std::wstring uuid = ParseQueryParam(url,L"uuid"); std::wstring name = ParseQueryParam(url,L"name"); std::wstring version = ParseQueryParam(url,L"version"); std::wstring filename = name; filename+=L"-"; filename+=version; filename+=L".zip"; // figure out the path and destination std::wstring path = tempdir + L"\\" + filename; std::wstring destdir; if (RUNTIME_UUID == uuid) { destdir = installdir + L"\\runtime\\win32\\" + version; } else if (MODULE_UUID == uuid) { destdir = installdir + L"\\modules\\win32\\" + name + L"\\" + version; } else { continue; } bool downloaded = DownloadURL(p, hINet, url, path); if(downloaded) { wchar_t msg[255]; wsprintfW(msg, L"Installing %s/%s ...",name.c_str(),version.c_str()); p->SetLineText(2,msg,true); UnzipFile(unzipper, path, destdir); } } // done with iNet - so close it InternetCloseHandle(hINet); if (p->IsCancelled()) { failed = true; } // cleanup delete p; CoUninitialize(); return (failed) ? 1 : 0; }
[ "[email protected]", "Marshall@.(none)", "[email protected]" ]
[ [ [ 1, 2 ], [ 4, 4 ], [ 6, 7 ], [ 9, 12 ], [ 16, 18 ], [ 21, 51 ], [ 81, 86 ], [ 90, 100 ], [ 102, 102 ], [ 104, 104 ], [ 106, 107 ], [ 116, 124 ], [ 126, 130 ], [ 133, 144 ], [ 146, 146 ], [ 149, 149 ], [ 151, 159 ], [ 161, 182 ], [ 184, 192 ], [ 194, 207 ], [ 209, 217 ], [ 219, 225 ], [ 227, 228 ], [ 231, 232 ], [ 234, 234 ], [ 236, 236 ], [ 238, 247 ], [ 249, 266 ], [ 269, 274 ], [ 276, 313 ], [ 316, 335 ] ], [ [ 3, 3 ], [ 5, 5 ], [ 8, 8 ], [ 88, 88 ], [ 103, 103 ], [ 125, 125 ], [ 131, 131 ], [ 150, 150 ], [ 193, 193 ], [ 208, 208 ], [ 218, 218 ], [ 226, 226 ], [ 229, 230 ], [ 237, 237 ], [ 248, 248 ], [ 267, 268 ], [ 275, 275 ], [ 314, 315 ] ], [ [ 13, 15 ], [ 19, 20 ], [ 52, 80 ], [ 87, 87 ], [ 89, 89 ], [ 101, 101 ], [ 105, 105 ], [ 108, 115 ], [ 132, 132 ], [ 145, 145 ], [ 147, 148 ], [ 160, 160 ], [ 183, 183 ], [ 233, 233 ], [ 235, 235 ] ] ]
0b5c3e8990a1d5fff1fc4c6d3ec0685c3e03d3c7
d159f5d7245ae5765d06f6f6213df63fb56df06a
/tests/acc.cpp
47812218e58f1fe226787140db39d756afae81c7
[]
no_license
baffles/sh05
41d46837acff9e4637672f17d179c15ffe8e39dc
6f065fda9a86fc6e1316a6df8107a26e2694faaa
refs/heads/master
2021-01-19T06:53:23.730789
2005-09-07T10:29:54
2005-09-07T10:29:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,029
cpp
#include <png.h> #include <allegro.h> #include <winalleg.h> #include <loadpng.h> #include <stdio.h> #include "curl.h" typedef struct avalist avalist; struct avalist { int id; BITMAP *bmp; avalist *next; }; avalist *avatars = NULL; /*CURL *curl_handle = NULL; FILE *temp = NULL;*/ Curl curl; BITMAP *get_avatar(int uid) { unsigned char found = 0; avalist *cur = avatars; while(cur != NULL) { if(cur->id == uid) { found = 1; break; } cur = cur->next; } if(!found) { char request[256], pngfname[128]; BITMAP *ret; avalist *newa; // http://www.bafsoft.net/acc_cache/user.php sprintf(request, "http://www.bafsoft.net/acc_cache/user.php?usr=%d&cmd=avapng", uid); sprintf(pngfname, "temp/%d.png", uid); printf("\nDownloading avatar for user #%d [%s]\n", uid, request); /*temp = fopen(pngfname, "wb"); curl_easy_setopt(curl_handle, CURLOPT_URL, request); curl_easy_perform(curl_handle); //curl_easy_cleanup(curl_handle); fclose(temp);*/ curl.download(request, pngfname); newa = (avalist *)malloc(sizeof(avalist)); newa->id = uid; newa->bmp = load_png(pngfname, NULL); newa->next = NULL; cur = avatars; if(cur) { while(cur->next != NULL) cur = cur->next; cur->next = newa; cur = cur->next; } else avatars = cur = newa; } return cur->bmp; } void clean_avatars() { avalist *cur = avatars; avalist *next = avatars; if(cur == NULL) return; while(1) { next = cur->next; destroy_bitmap(cur->bmp); free(cur); cur = next; if(cur == NULL) break; } } // from a.cc by spelly void textoutWordWrap_(BITMAP* dst, FONT* font, int x, int y, int w, int h, int col, char* text) { int height = text_height(font); char *start = NULL; char *end = NULL; static char delim[] = " "; char *token = NULL; int curX = x; int curY = y; int space = text_length(font, " "); int len = 0; int maxX = x + w; int maxY = y + h; int getToken = TRUE; char oneChar[] = "X"; start= text; end = strchr(start, '\n'); while (end != NULL) { *end='\0'; token = strtok(start, delim); while (token != NULL) { len = text_length(font , token); getToken = TRUE; if (curX + len > maxX) { if (len > w) { // the token does not fit into a single line getToken = FALSE; while (curX < maxX && *token) { // there's no char_out function, so we'll use a two char string *oneChar = *token; len = text_length(font, oneChar); if (curX + len < maxX) { token++; textout(dst, font, oneChar, curX, curY, col); } curX += len; } curY += height; curX = x; } else { curX = x; curY += height; textout(dst, font, token, curX, curY, col); curX += len + space; } } else { textout(dst, font, token, curX, curY, col); curX += len + space; } if (getToken) { token = strtok(NULL, delim); } } start = end+1; end = strchr(start, '\n'); curY += height; curX = x; } } void textoutWordWrap(BITMAP* dst, FONT* font, int x, int y, int w, int h, int col, char* txt) { static char text[512]; strcpy(text, txt); textoutWordWrap_(dst, font, x, y, w, h, col, text); } void textprintfWordWrap(BITMAP *bmp, FONT *f, int x, int y, int w, int h, int color, const char *format, ...) { static char buf[512]; va_list ap; va_start(ap, format); uvszprintf(buf, sizeof(buf), format, ap); va_end(ap); textoutWordWrap_(bmp, f, x, y, w, h, color, buf); } void do_wrapped_text(BITMAP *dest, FONT *font, int x, int y, int w, int rows, int txtcol, int bgcol, char *txt) { textoutWordWrap(dest, font, x, y, w, (rows - 1) * text_height(font), txtcol, txt); } int main(int argc, char **argv) { //CURL *curl_handle; FILE *rfptmp; BITMAP *buffer; char request[512], rfpname[256]; int len, num_posts, i; char *title, *xml; typedef struct _pl_ { int id; char *poster; int posterid; char *postdate; char *post; BITMAP *avatar; } postlist; postlist *posts; if(argc != 2) { printf("Usage: %s [a.cc username]\n", argv[0]); return -1; } sprintf(request, "http://www.bafsoft.net/acc_cache/user.php?usr=%s&cmd=rfp", argv[1]); sprintf(rfpname, "temp/%s.rfp", argv[1]); printf("%s\n", request); /*temp = fopen(rfpname, "wb"); curl_global_init(CURL_GLOBAL_ALL); curl_handle = curl_easy_init(); curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1); curl_easy_setopt(curl_handle, CURLOPT_HEADER, 0); curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, fwrite); curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)temp); curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0"); curl_easy_setopt(curl_handle, CURLOPT_URL, request); curl_easy_perform(curl_handle); //curl_easy_cleanup(curl_handle); fclose(temp);*/ curl.download(request, rfpname); /** printf("%d%s", strlen($rfp['title']), $rfp['title']); printf("%d%s", strlen($rfp['xml']), $rfp['xml']); printf("%d ", $rfp['pcount']); for($i = 0; $i < $rfp['pcount']; $i++) { printf("%d%s", strlen($rfp['posts'][$i]['poster']), $rfp['posts'][$i]['poster']); printf("%d ", $rfp['posts'][$i]['posterid']); printf("%d%s", strlen($rfp['posts'][$i]['postdate']), $rfp['posts'][$i]['postdate']); printf("%d %s ", strlen($rfp['posts'][$i]['post']), $rfp['posts'][$i]['post']); }**/ /// typedef struct { int id; char *poster, int posterid; char *postdate; char *post; } postlist; printf("Lets go to allegro...\n"); allegro_init(); install_keyboard(); set_color_depth(32); set_gfx_mode(GFX_AUTODETECT_WINDOWED, 1024, 768, 0, 0); buffer = create_bitmap(1024, 768); rfptmp = fopen(rfpname, "rb"); fscanf(rfptmp, "%d", &len); title = (char *)malloc(len + 1); fread(title, len, 1, rfptmp); title[len] = 0; fscanf(rfptmp, "%d", &len); xml = (char *)malloc(len + 1); fread(xml, len, 1, rfptmp); xml[len] = 0; fscanf(rfptmp, "%d ", &num_posts); posts = (postlist *)malloc(sizeof(postlist) * num_posts); for(i = 0; i < num_posts; ++i) { posts[i].id = i; fscanf(rfptmp, "%d", &len); posts[i].poster = (char *)malloc(len + 1); fread(posts[i].poster, len, 1, rfptmp); posts[i].poster[len] = 0; fscanf(rfptmp, "%d ", &posts[i].posterid); fscanf(rfptmp, "%d", &len); posts[i].postdate = (char *)malloc(len + 1); fread(posts[i].postdate, len, 1, rfptmp); posts[i].postdate[len] = 0; fscanf(rfptmp, "%d ", &len); posts[i].post = (char *)malloc(len + 1); fread(posts[i].post, len, 1, rfptmp); posts[i].post[len] = 0; printf("Avatar %d\n", i); posts[i].avatar = get_avatar(posts[i].posterid); //printf("DOWNLOADING AVATARS... (%d/%d) %d%% done\r", i + 1, num_posts, (int)(((float)(i + 1) / (float)num_posts) * 100)); clear_bitmap(buffer); textprintf_ex(buffer, font, 50, 50, makecol(255,255,255), -1, "Downloading Avatars...."); textprintf_ex(buffer, font, 70, 70, makecol(255,255,255), -1, "(%d/%d) %d%%", i + 1, num_posts, (int)(((float)(i + 1) / (float)num_posts) * 100)); /// 668 -> 868 rect(buffer, 412, 100, 612, 150, makecol(255,255,255)); rectfill(buffer, 413, 101, 412 + (2 * (int)(((float)(i + 1) / (float)num_posts) * 100)), 149, makecol(0,0,255)); blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); } //curl_easy_perform(curl_handle); //curl_easy_cleanup(curl_handle); clear_bitmap(screen); //set_gfx_mode(GFX_AUTODETECT, 1024, 768, 0, 0); //printf("Topic: %s XML URL: %s Number of Posts: %d\n", title, xml, num_posts); //for(i = 0; i < (num_posts < 9 ? num_posts : 9); ++i) for(i = 0; i < (num_posts < (SCREEN_W / 96) ? num_posts : (SCREEN_W / 96)); ++i) { //printf("Post %d Posted by: %s [%d] %s\n============================================================================\n%s\n============================================================================\n", i, posts[i].poster, posts[i].posterid, posts[i].postdate, posts[i].post); /// 96 height for each printf("\n%d", i); blit(posts[i].avatar, screen, 0, 0, 8, (i * 96) + 14, 80, 80); textprintf_ex(screen, font, 8, (i * 96) + 2, makecol(255,255,255), -1, "%s [%d]", posts[i].poster, posts[i].posterid); ///textprintf_ex(screen, font, 100, (i * 96) + 2 + text_height(font), makecol(255,255,255), -1, "%s", posts[i].post); do_wrapped_text(screen, font, 100, ((i * 96) + 2) + text_height(font), SCREEN_W - 102, (94 - text_height(font)) / text_height(font), makecol(255,255,255), -1, posts[i].post); } while(!keypressed()) ; for(i = 0; i < num_posts; ++i) { free(posts[i].poster); free(posts[i].postdate); free(posts[i].post); //destroy_bitmap(posts[i].avatar); } free(posts); clean_avatars(); return 0; } END_OF_MAIN()
[ [ [ 1, 314 ] ] ]
3b4f8e0be66e105b8da5faf4adffbac3b6172534
2a3952c00a7835e6cb61b9cb371ce4fb6e78dc83
/BasicOgreFramework/PhysxSDK/Graphics/include/Mesh.h
596ef9cea97e4024d3b53f97703d55351e9ce7a6
[]
no_license
mgq812/simengines-g2-code
5908d397ef2186e1988b1d14fa8b73f4674f96ea
699cb29145742c1768857945dc59ef283810d511
refs/heads/master
2016-09-01T22:57:54.845817
2010-01-11T19:26:51
2010-01-11T19:26:51
32,267,377
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
2,594
h
#ifndef _SG_MESH_H__ #define _SG_MESH_H__ /*----------------------------------------------------------------------------*\ | | Ageia PhysX Technology | | www.ageia.com | \*----------------------------------------------------------------------------*/ #include <string> #include <vector> #include <3DMath.h> struct GLMmodel; struct GLMgroup; namespace SceneGraph { class SubMesh { public: SubMesh() { vertexList = 0; indexList = 0; nVertices = 0; nTriangles = 0; displayList = 0; userData = 0; } ~SubMesh(); void changed(); void render(); void renderAsPoints(float size = 0); void DEBUGassertIntegrity(); float * vertexList; unsigned * indexList; unsigned nVertices; //a vertex is 3 + 3 + 2 dwords unsigned nTriangles; //a trig is 3 dwords std::string name; //name of submesh unsigned displayList; //the display list of the submesh, 0xffffffff if none. void * userData; }; /** A mesh is an ordered list of submeshes. Each submesh can have a different material assigned in the model class. */ class Mesh { public: typedef std::vector<SubMesh *> SubMeshList; SubMeshList subMeshList; //all the submeshes are owned. std::string name; Mesh(); ~Mesh(); void load(const char * MeshFName,bool TextureCoords = true,float Scale = 0.0f, bool forceNormals = true, unsigned forceTexCoordType = 0); virtual void render(int subMeshIndex = -1); //-1 means "ALL". virtual int findGroup(const char * name); //returns negative if not found. void getBoundingBox(Vec3 & dims); //returns box edge lengths, not radii. void changed(int submeshIndex = -1); //call to invalidate display lists. -1 for all of them. void collapseToSingleSubmesh(); //all but one of the submeshes get freed. That submesh gets all the geometry packed in. protected: Vec3 bbox; static void glmGroupToIndexedList(GLMmodel * m, GLMgroup * g, unsigned & nVertices, unsigned & nTriangles, float * & vertexList, unsigned * & indexList); /*-------------------------\ | converts a group to a simple | indexed triangle list with | 32 bit indices, and vertices | of: point, normal, u, v \-------------------------*/ }; }; #endif //__MESH_H__ //AGCOPYRIGHTBEGIN /////////////////////////////////////////////////////////////////////////// // Copyright © 2005 AGEIA Technologies. // All rights reserved. www.ageia.com /////////////////////////////////////////////////////////////////////////// //AGCOPYRIGHTEND
[ "erucarno@789472dc-e1c3-11de-81d3-db62269da9c1" ]
[ [ [ 1, 93 ] ] ]
d2843ba703c1f93b770a666c250801a22119a82b
c034a6ffa81773a279c4cd25bdbd3b23a999d4b7
/GMFGUI/GMFGUI/GMFComp/comGmidFunctions.cpp
22ac783c168e9ecc2a916c7e86c9c06b565b8fbc
[]
no_license
Shima33/gmftoolkit
08ee92bb5700af984286c71dd54dbfd1ffecd35a
0e602d27b9b8cce83942f9624cbb892b0fd44b6b
refs/heads/master
2021-01-10T15:45:10.838305
2010-06-20T19:09:19
2010-06-20T19:09:19
50,957,203
0
0
null
null
null
null
UTF-8
C++
false
false
13,447
cpp
#include "stdafx.h" #include "../mystdio.h" #include <stdlib.h> #include <string.h> #include <windows.h> #include "byteFunctions.h" #include "asciiFunctions.h" #include "objectFunctions.h" extern FILE* input; extern FILE* output; int readGMIDAttachmentPt() { printInt(21); printInt(2); printBytes("\xFF\xFF\xFF\xFF", 4); int beginningOffset = ftell(output); openBracket(); char* ptName = readString("*NODE_NAME"); printString(ptName); readTM(); fscanf(input, "USER DATA"); fgetc(input); int offset = ftell(input); int length = 0; while (fgetc(input) != '}') length++; fseek(input, offset, 0); char* ptUserData = (char*)malloc(sizeof(char)*(length+1)); fread(ptUserData, sizeof(char), length, input); ptUserData[length-2] = '\x00'; if (length != 0) printString(ptUserData); else printInt(0); closeBracket(); int endOffset = ftell(output); int size = endOffset - beginningOffset; fseek(output, beginningOffset - 4, 0); printInt(size); fseek(output, endOffset, 0); return 0; } int readHavokSimobject() { printInt(30); printInt(2); printBytes("\xFF\xFF\xFF\xFF", 4); int beginningOffset = ftell(output); openBracket(); char* soName = readString("*NODE_NAME"); if (strncmp("(null)", soName, 6)) printString(soName); else printInt(0); bracketize(); float soGravity[3]; fscanf(input, "*GRAVITY\t%f %f %f\n", &soGravity[0], &soGravity[1], &soGravity[2]); float soWorldScale = readFloat("*WORLDSCALE"); float soSimTolerance = readFloat("*SIMTOLERANCE"); int soResolver = readInt("*RESOLVER"); int soIncludeDrag = readInt("*INCLUDE_DRAG"); float soLinearDrag = readFloat("*LINEAR_DRAG"); float soAngularDrag = readFloat("*ANGULAR_DRAG"); int soDeactivator = readInt("*INCLUDE_DEACTIVATOR"); float soShortFreq = readFloat("*SHORTFREQ"); float soLongFreq = readFloat("*LONGFREQ"); int soUseFastSubspace = readInt("*USE_FAST_SUBSPACE"); float soUpdatesPerTimeStep = readFloat("*UPDATES_PER_TIMESTEP"); int soNumCollisionPairs = readInt("*NUM_COLLISION_PAIRS"); printFloat(soGravity[0]); printFloat(soGravity[1]); printFloat(soGravity[2]); printFloat(soWorldScale); printFloat(soSimTolerance); printBytes((char*)&soResolver, 1); printInt(soIncludeDrag); printFloat(soLinearDrag); printFloat(soAngularDrag); printBytes((char*)&soDeactivator, 1); printFloat(soShortFreq); printFloat(soLongFreq); printBytes((char*)&soUseFastSubspace, 1); printFloat(soUpdatesPerTimeStep); printInt(soNumCollisionPairs); closeBracket(); int endOffset = ftell(output); int size = endOffset - beginningOffset; fseek(output, beginningOffset - 4, 0); printInt(size - 4); fseek(output, endOffset, 0); return 0; } int readHavokRB() { printInt(32); printInt(4); printBytes("\xFF\xFF\xFF\xFF", 4); int beginningOffset = ftell(output); openBracket(); char* rbName = readString("*NODE_NAME"); printString(rbName); float rbMass = readFloat("*MASS"); printFloat(rbMass); float rbElasticity = readFloat("*ELASTICITY"); printFloat(rbElasticity); float rbFriction = readFloat("*FRICTION"); printFloat(rbFriction); float rbOptimization = readFloat("*OPTIMIZATION_LEVEL"); printFloat(rbOptimization); int rbUnyielding = readInt("*UNYIELDING"); printInt(rbUnyielding); int rbSimulationGeometry = readInt("*SIMULATION_GEOMETRY"); printInt(rbSimulationGeometry); char* rbGeometryProxyName = readString("*GEOMETRY_PROXY_NAME"); if(strncmp(rbGeometryProxyName, "(null)", 6)) printString(rbGeometryProxyName); else printInt(0); int rbUseDisplayProxy = readInt("*USE_DISPLAY_PROXY"); printBytes((char*)&rbUseDisplayProxy, 1); int rbDisableCollisions = readInt("*DISABLE_COLLISIONS"); printBytes((char*)&rbDisableCollisions, 1); int rbInactive = readInt("*INACTIVE"); printBytes((char*)&rbInactive, 1); char* rbDisplayProxyName = readString("*DISPLAY_PROXY_NAME"); if(strncmp(rbDisplayProxyName, "(null)", 6)) printString(rbDisplayProxyName); else printInt(0); readTM(); char* rbHavokGeoType = readString("*HAVOK_GEO_TYPE"); if (!strncmp(rbHavokGeoType, "Standard", 8)) printInt(0); else printInt(0); int rbNumberOfChildren = readInt("*NUMBER_OF_CHILDREN"); printInt(rbNumberOfChildren); closeBracket(); int endOffset = ftell(output); int size = endOffset - beginningOffset; fseek(output, beginningOffset - 4, 0); printInt(0); fseek(output, endOffset, 0); return 0; } int readHavokRBList() { printInt(33); printInt(2); printBytes("\xFF\xFF\xFF\xFF", 4); int beginningOffset = ftell(output); openBracket(); int rblCount = readInt("*COUNT"); printInt(rblCount); int i; for (i = 0; i < rblCount; i++) { readNothing("*GMID_HAVOK_RIGIDBODY"); readHavokRB(); } closeBracket(); int endOffset = ftell(output); int size = endOffset - beginningOffset; fseek(output, beginningOffset - 4, 0); printInt(0); //yes, this is weird, but otherwise RA2 crashes. fseek(output, endOffset, 0); return 0; } int readHavokDisabledPairs() { printInt(51); printInt(2); printBytes("\xFF\xFF\xFF\xFF", 4); int beginningOffset = ftell(output); openBracket(); int dpNumPairs = readInt("*COUNT"); printInt(dpNumPairs); int i; for (i = 0; i < dpNumPairs; i++) { bracketize(); //fscanf(input, "{ %s\t%s }"); int body1Length = 0; int body2Length = 0; fscanf(input, "{ %i", &body1Length); char* body1 = (char*)malloc(sizeof(char) * body1Length); fscanf(input, "%s\t%i", body1, &body2Length); char* body2 = (char*)malloc(sizeof(char) * body1Length); fscanf(input, "%s }\n", body2); printString(body1); printString(body2); } closeBracket(); int endOffset = ftell(output); int size = endOffset - beginningOffset; fseek(output, beginningOffset - 4, 0); printInt(0); // WUT fseek(output, endOffset, 0); return 0; } int readHavokRBCollection() { printInt(31); printInt(4); printBytes("\xFF\xFF\xFF\xFF", 4); int beginningOffset = ftell(output); openBracket(); char* rbcName = readString("*NODE_NAME"); int rbcNumDisabledPairs = readInt("*NUM_DISABLED_PAIRS"); int rbcSolverType = readInt("*SOLVER_TYPE"); int rbcRbCount = readInt("*COUNT"); printString(rbcName); printInt(rbcNumDisabledPairs); printInt(rbcSolverType); bracketize(); char* nextThing = (char*)malloc(sizeof(char)*128); while(1) { int offset = ftell(input); fscanf(input, "%s\n", nextThing); if (!strncmp(nextThing, "*GMID_HAVOK_RIGIDBODY_LIST", 26)) { /*fscanf(input, "\t%*i\n"); readNothing("*GMID_HAVOK_RIGIDBODY_LIST");*/ readHavokRBList(); } else if (!strncmp(nextThing, "*COUNT", 6)) { fscanf(input, "\t%*i\n"); readNothing("*GMID_HAVOK_RIGIDBODY_LIST"); readHavokRBList(); } else if (!strncmp(nextThing, "*GMID_HAVOK_DIS_COLLISION_PAIRS", 31)) { readHavokDisabledPairs(); } else if (!strncmp(nextThing, "}", 1)) { fseek(input, offset, 0); break; } else { error(nextThing); } } closeBracket(); int endOffset = ftell(output); int size = endOffset - beginningOffset; fseek(output, beginningOffset - 4, 0); printInt(size); fseek(output, endOffset, 0); return 0; } int readHavokHingeC() { printInt(47); printInt(2); printBytes("\xFF\xFF\xFF\xFF", 4); int beginningOffset = ftell(output); openBracket(); char* cName = readString("*NODE_NAME"); printString(cName); readTM(); char* cBody1 = readString("*BODY1"); char* cBody2 = readString("*BODY2"); float p[3]; bracketize(); fscanf(input, "*POINT %f\t%f\t%f\n", &p[0], &p[1], &p[2]); float s[3]; bracketize(); fscanf(input, "*SPIN_AXIS %f\t%f\t%f\n", &s[0], &s[1], &s[2]); int cLimited = readInt("*IS_LIMITED"); float cFriction = readFloat("*FRICTION"); float a[2]; bracketize(); fscanf(input, "*ANGLE_LIMITS %f\t%f\n", &a[0], &a[1]); printString(cBody1); printString(cBody2); printFloat(p[0]); printFloat(p[1]); printFloat(p[2]); printFloat(s[0]); printFloat(s[1]); printFloat(s[2]); printBytes((char*)&cLimited, 1); printFloat(cFriction); printFloat(a[0]); printFloat(a[1]); closeBracket(); int endOffset = ftell(output); int size = endOffset - beginningOffset; fseek(output, beginningOffset - 4, 0); printInt(0); fseek(output, endOffset, 0); return 0; } int readHavokPivotC() { MessageBox(NULL, L"Warning! The PIVOT constraint is deprecated. Please use the WHEEL constraint instead (see decompiled carsteering for details)!\nThe file will continue to compile.", L"Deprecation error", MB_ICONWARNING); printInt(46); printInt(2); printBytes("\xFF\xFF\xFF\xFF", 4); int beginningOffset = ftell(output); openBracket(); char* cName = readString("*NODE_NAME"); printString(cName); readTM(); char* cBody1 = readString("*BODY1"); char* cBody2 = readString("*BODY2"); float p[3]; bracketize(); fscanf(input, "*POINT %f\t%f\t%f\n", &p[0], &p[1], &p[2]); float s[3]; bracketize(); fscanf(input, "*SPIN_AXIS %f\t%f\t%f\n", &s[0], &s[1], &s[2]); float unkn[8]; bracketize(); fscanf(input, "*UNKNOWN %f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n", &unkn[0], &unkn[1], &unkn[2], &unkn[3], &unkn[4], &unkn[5], &unkn[6], &unkn[7]); printString(cBody1); printString(cBody2); printFloat(p[0]); printFloat(p[1]); printFloat(p[2]); printFloat(s[0]); printFloat(s[1]); printFloat(s[2]); int x; for (x = 0; x < 8; x++) printFloat(unkn[x]); closeBracket(); int endOffset = ftell(output); int size = endOffset - beginningOffset; fseek(output, beginningOffset - 4, 0); printInt(0); fseek(output, endOffset, 0); return 0; } int readHavokWheelC() { printInt(46); printInt(2); printBytes("\xFF\xFF\xFF\xFF", 4); int beginningOffset = ftell(output); openBracket(); char* cName = readString("*NODE_NAME"); printString(cName); readTM(); char* cBody1 = readString("*BODY1"); char* cBody2 = readString("*BODY2"); float p[3]; bracketize(); fscanf(input, "*POINT %f\t%f\t%f\n", &p[0], &p[1], &p[2]); float s[3]; bracketize(); fscanf(input, "*SPIN_AXIS %f\t%f\t%f\n", &s[0], &s[1], &s[2]); float suspAxis[3]; bracketize(); fscanf(input, "*SUSPENSION_AXIS %f\t%f\t%f\n", &suspAxis[0], &suspAxis[1], &suspAxis[2]); float suspLimits[2]; bracketize(); fscanf(input, "*SUSPENSION_LIMITS %f\t%f\n", &suspLimits[0], &suspLimits[1]); float suspFriction = readFloat("*SUSPENSION_FRICTION"); float angSpeed = readFloat("*ANGULAR_SPEED"); float gain = readFloat("*GAIN"); printString(cBody1); printString(cBody2); printFloat(p[0]); printFloat(p[1]); printFloat(p[2]); printFloat(s[0]); printFloat(s[1]); printFloat(s[2]); printFloat(suspAxis[0]); printFloat(suspAxis[1]); printFloat(suspAxis[2]); printFloat(suspLimits[0]); printFloat(suspLimits[1]); printFloat(suspFriction); printFloat(angSpeed); printFloat(gain); closeBracket(); int endOffset = ftell(output); int size = endOffset - beginningOffset; fseek(output, beginningOffset - 4, 0); printInt(0); fseek(output, endOffset, 0); return 0; } int readHavokCItem() { char* cType = (char*)malloc(sizeof(char)*128); bracketize(); fscanf(input, "%s\n", cType); if (!strncmp(cType, "*GMID_HAVOK_HINGE_CONSTRAINT", 28)) { readHavokHingeC(); } else if (!strncmp(cType, "*GMID_HAVOK_PIVOT_CONSTRAINT", 29)) { readHavokPivotC(); } else if (!strncmp(cType, "*GMID_HAVOK_WHEEL_CONSTRAINT", 29)) { readHavokWheelC(); } else { char* message = (char*)malloc(sizeof(char)*128); sprintf(message, "readHavokCItem(): Unknown Constraint type %s!", cType); error(message); } return 0; } int readHavokCList() { int cnlCountAgainOffset = ftell(output); printBytes("\xFF\xFF\xFF\xFF", 4); printInt(44); printInt(2); printBytes("\xFF\xFF\xFF\xFF", 4); int beginningOffset = ftell(output); openBracket(); int clCount = readInt("*COUNT"); printInt(clCount); int curOffset = ftell(output); fseek(output, cnlCountAgainOffset, 0); printInt(clCount); fseek(output, curOffset, 0); int i; for(i = 0; i < clCount; i++) readHavokCItem(); closeBracket(); int endOffset = ftell(output); int size = endOffset - beginningOffset; fseek(output, beginningOffset - 4, 0); printInt(0); fseek(output, endOffset, 0); return 0; } int readHavokCSolver() { printInt(42); printInt(3); printBytes("\xFF\xFF\xFF\xFF", 4); int beginningOffset = ftell(output); openBracket(); char* csName = readString("*NODE_NAME"); float csThreshold = readFloat("*THRESHOLD"); char* csRBCollectionName = readString("*RB_COLLECTION_NAME"); printString(csName); printFloat(csThreshold); printString(csRBCollectionName); int offset = ftell(input); char* next = (char*)malloc(sizeof(char)*128); fscanf(input, "%s", next); fseek(input, offset, 0); if (strncmp(next, "}", 1)) { readNothing("*GMID_HAVOK_CONSTRAINT_LIST"); readHavokCList(); } else printInt(0); closeBracket(); int endOffset = ftell(output); int size = endOffset - beginningOffset; fseek(output, beginningOffset - 4, 0); printInt(size); fseek(output, endOffset, 0); return 0; }
[ "Bazanski@1d10bff2-9961-11dd-bd51-a78b85c98fae" ]
[ [ [ 1, 564 ] ] ]
5592dc2f265213cf0fd64329441bf9f6e5c3a105
dc4b6ab7b120262779e29d8b2d96109517f35551
/Dialog/WtlHelperDlg.h
fcfc312a13cd55e514e2512d0726e0d0a2b1b126
[]
no_license
cnsuhao/wtlhelper9
92daef29b61f95f44a10e3277d8835c2dd620616
681df3a014fc71597e9380b0a60bd3cd23e22efe
refs/heads/master
2021-07-17T19:59:07.143192
2009-05-18T14:24:48
2009-05-18T14:24:48
108,361,858
0
1
null
null
null
null
UTF-8
C++
false
false
5,067
h
//////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2004 Sergey Solozhentsev // Author: Sergey Solozhentsev e-mail: [email protected] // Product: WTL Helper // File: WtlHelperDlg.h // Created: 12.01.2005 13:54 // // Using this software in commercial applications requires an author // permission. The permission will be granted to everyone excluding the cases // when someone simply tries to resell the code. // This file may be redistributed by any means PROVIDING it is not sold for // profit without the authors written consent, and providing that this notice // and the authors name is included. // This file is provided "as is" with no expressed or implied warranty. The // author accepts no liability if it causes any damage to you or your computer // whatsoever. // //////////////////////////////////////////////////////////////////////////////// // This file was generated by WTL Dialog wizard // WtlHelperDlg.h : Declaration of the CWtlHelperDlg #pragma once #pragma warning (disable: 4267) #include "../atlgdix.h" #include "../CustomTabCtrl.h" #include "../DotNetTabCtrl.h" #include <atlframe.h> #include "../TabbedFrame.h" #pragma warning (default: 4267) #include "VariablePage.h" #include "FunctionPage.h" struct WtlDlgWindowSettings : public CSettings<WtlDlgWindowSettings> { CRect m_WindowRect; int m_ActiveTab; BEGIN_SETTINGS_MAP() SETTINGS_VARIABLE_OPT(m_ActiveTab) SETTINGS_BINARY_OPT(&m_WindowRect, sizeof(CRect)) END_SETTINGS_MAP() WtlDlgWindowSettings() : m_ActiveTab(0), m_WindowRect(0, 0, 450, 300) { } }; // CWtlHelperDlg #define IDC_PAGESTAB 1023 class CWtlHelperDlg : public CDialogImpl<CWtlHelperDlg>, public CDialogResize<CWtlHelperDlg>, public CSettings<CWtlHelperDlg> { CToolBarCtrl m_ToolBar; CTabbedChildWindow< CDotNetTabCtrl<CTabViewTabItem> > m_tabbedChildWindow; CFunctionPage m_FunctionPage; CVariablePage m_VariablePage; WtlDlgWindowSettings m_DlgSettings; bool m_bSavePreviousPane; void SetCommonPointers(); void LoadSettings(); void SaveSettings(); public: CWtlHelperDlg(); ~CWtlHelperDlg(); enum { IDD = IDD_WTLHELPERDLG }; int* m_piCurrentClass; ClassVector* m_pClassVector; CSmartAtlArray<InsDelPoints>* m_pModifications; CResourceManager* m_pResManager; int m_iActivePage; HICON m_hIconSmall; BEGIN_MSG_MAP(CWtlHelperDlg) MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) MESSAGE_HANDLER(WM_SIZE, OnSize) MESSAGE_HANDLER(WM_DESTROY, OnDestroy) MESSAGE_HANDLER(WM_GETMINMAXINFO, OnGetMinMaxInfo) MESSAGE_HANDLER(WM_NCDESTROY, OnWmNcDestroy) COMMAND_HANDLER(IDOK, BN_CLICKED, OnClickedOK) COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnClickedCancel) COMMAND_HANDLER(IDC_BUTTON_APPLY, BN_CLICKED, OnApply) NOTIFY_CODE_HANDLER(CTCN_SELCHANGE, OnTabSelectChange) MESSAGE_HANDLER(WTLH_SETMODIFIED, OnSetModified) NOTIFY_CODE_HANDLER(TTN_GETDISPINFO, OnTtnGetDispInfo) if (uMsg == WM_COMMAND) { if (lParam == (LPARAM)m_ToolBar.m_hWnd) { ::SendMessage(m_tabbedChildWindow.GetActiveView(), uMsg, wParam, lParam); } } if (uMsg == WM_NOTIFY) { if (((LPNMHDR)lParam)->hwndFrom == m_ToolBar.m_hWnd) { ::SendMessage(m_tabbedChildWindow.GetActiveView(), uMsg, wParam, lParam); } } CHAIN_MSG_MAP(CDialogResize<CWtlHelperDlg>) END_MSG_MAP() BEGIN_DLGRESIZE_MAP(CWtlHelperDlg) DLGRESIZE_CONTROL(IDOK, DLSZ_MOVE_X | DLSZ_MOVE_Y) DLGRESIZE_CONTROL(IDCANCEL, DLSZ_MOVE_X | DLSZ_MOVE_Y) DLGRESIZE_CONTROL(IDC_BUTTON_APPLY, DLSZ_MOVE_X | DLSZ_MOVE_Y) DLGRESIZE_CONTROL(IDC_PAGESTAB, DLSZ_SIZE_X | DLSZ_SIZE_Y) END_DLGRESIZE_MAP() BEGIN_SETTINGS_MAP() SETTINGS_VARIABLE_OPT_RO(m_bSavePreviousPane) SETTINGS_CHILD_OPT_USE_PARENT(m_DlgSettings) END_SETTINGS_MAP() // Handler prototypes: // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnClickedOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnClickedCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnApply(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnTabSelectChange(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); LRESULT OnTtnGetDispInfo(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); LRESULT OnSetModified(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnWmNcDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); };
[ "free2000fly@eea8f18a-16fd-41b0-b60a-c1204a6b73d1" ]
[ [ [ 1, 146 ] ] ]
48fb8ae804e60b025fa6cb63cf1cf7e8235a97f1
85c91b680d74357b379204ecf7643ae1423f8d1e
/branches/pre_mico_2_3-12/examples/general/hello_world/HelloWorld_CalleeImpl/HelloWorld_CalleeImpl.h
3df833624f124a85067c204f4164cff7dc858bb9
[]
no_license
BackupTheBerlios/qedo-svn
6fdec4ca613d24b99a20b138fb1488f1ae9a80a2
3679ffe8ac7c781483b012dbef70176e28fea174
refs/heads/master
2020-11-26T09:42:37.603285
2010-07-02T10:00:26
2010-07-02T10:00:26
40,806,890
0
0
null
null
null
null
UTF-8
C++
false
false
5,062
h
// // generated by Qedo // #ifndef _HelloWorld_CalleeImpl_H_ #define _HelloWorld_CalleeImpl_H_ // BEGIN USER INSERT SECTION file_pre // END USER INSERT SECTION file_pre #include <CORBA.h> #include "HelloWorld_CalleeImpl_BUSINESS.h" #include "component_valuetypes.h" #include "RefCountBase.h" #include <string> // BEGIN USER INSERT SECTION file_post // END USER INSERT SECTION file_post namespace HelloWorld { // // executor // class CalleeSessionImpl : public virtual CORBA::LocalObject , public virtual ::HelloWorld::CCM_CalleeSessionImpl #ifndef MICO_ORB , public virtual Qedo::RefCountLocalObject #endif // BEGIN USER INSERT SECTION INHERITANCE_CalleeSessionImpl // END USER INSERT SECTION INHERITANCE_CalleeSessionImpl { private: ::HelloWorld::CCM_Callee_ContextImpl_var context_; public: CalleeSessionImpl(); virtual ~CalleeSessionImpl(); void set_context(::HelloWorld::CCM_Callee_ContextImpl_ptr context) throw (CORBA::SystemException, Components::CCMException); void configuration_complete() throw (CORBA::SystemException, Components::InvalidConfiguration); void remove() throw (CORBA::SystemException); // // IDL:HelloWorld/Hello/say:1.0 // virtual void say() throw(CORBA::SystemException); // BEGIN USER INSERT SECTION CalleeSessionImpl // END USER INSERT SECTION CalleeSessionImpl }; // // executor locator // class CalleeImpl : public virtual CORBA::LocalObject , public virtual Components::SessionExecutorLocator #ifndef MICO_ORB , public virtual Qedo::RefCountLocalObject #endif // BEGIN USER INSERT SECTION INHERITANCE_CalleeImpl // END USER INSERT SECTION INHERITANCE_CalleeImpl { private: ::HelloWorld::CCM_Callee_ContextImpl_var context_; CalleeSessionImpl* component_; public: CalleeImpl(); virtual ~CalleeImpl(); // // IDL:Components/ExecutorLocator/obtain_executor:1.0 // virtual CORBA::Object_ptr obtain_executor(const char* name) throw(CORBA::SystemException); // // IDL:Components/ExecutorLocator/release_executor:1.0 // virtual void release_executor(CORBA::Object_ptr exc) throw(CORBA::SystemException); // // IDL:Components/ExecutorLocator/configuration_complete:1.0 // virtual void configuration_complete() throw(CORBA::SystemException, ::Components::InvalidConfiguration); // // IDL:Components/SessionComponent/set_session_context:1.0 // virtual void set_session_context(Components::SessionContext_ptr ctx) throw(CORBA::SystemException, ::Components::CCMException); // // IDL:Components/SessionComponent/ccm_activate:1.0 // virtual void ccm_activate() throw(CORBA::SystemException, ::Components::CCMException); // // IDL:Components/SessionComponent/ccm_passivate:1.0 // virtual void ccm_passivate() throw(CORBA::SystemException, ::Components::CCMException); // // IDL:Components/SessionComponent/ccm_remove:1.0 // virtual void ccm_remove() throw(CORBA::SystemException, ::Components::CCMException); // BEGIN USER INSERT SECTION CalleeImpl // END USER INSERT SECTION CalleeImpl }; // // home executor // class CalleeHomeImpl : public virtual CORBA::LocalObject , public virtual ::HelloWorld::CCM_CalleeHome #ifndef MICO_ORB , public virtual Qedo::RefCountLocalObject #endif // BEGIN USER INSERT SECTION INHERITANCE_CalleeHomeImpl // END USER INSERT SECTION INHERITANCE_CalleeHomeImpl { private: Components::HomeContext_var context_; public: CalleeHomeImpl(); virtual ~CalleeHomeImpl(); // // IDL:Components/HomeExecutorBase/set_context:1.0 // virtual void set_context (Components::HomeContext_ptr ctx) throw (CORBA::SystemException, Components::CCMException); // // IDL:.../create:1.0 // virtual ::Components::EnterpriseComponent_ptr create() throw (CORBA::SystemException, Components::CreateFailure); // BEGIN USER INSERT SECTION CalleeHomeImpl // END USER INSERT SECTION CalleeHomeImpl }; }; // // entry point // extern "C" { #ifdef _WIN32 __declspec(dllexport) #else #endif ::Components::HomeExecutorBase_ptr create_CalleeHomeE(void); } #endif
[ "tom@798282e8-cfd4-0310-a90d-ae7fb11434eb" ]
[ [ [ 1, 195 ] ] ]
2c474e9687b0809f70fab396591324b4a5ab4c3b
a9afa168fac234c3b838dd29af4a5966a6acb328
/ExtractMethod/src/Expense.cpp
bc41977fff25b48a84a1c1bc9ecb9e2b941b08da
[]
no_license
unclebob/tddrefcpp
38a4170c38f612c180a8b9e5bdb2ec9f8971832e
9124a6fad27349911658606392ba5730ff0d1e15
refs/heads/master
2021-01-25T07:34:57.626817
2010-05-10T20:01:39
2010-05-10T20:01:39
659,579
8
5
null
null
null
null
UTF-8
C++
false
false
186
cpp
#include "Expense.h" Expense::Expense(ExpenseType type, int amount) : type(type), amountInCents(amount) { } int Expense::getTotal() const { return amountInCents; }
[ [ [ 1, 16 ] ] ]
95fab91adb9c988bcaab969fd7738957b9a6cf5e
1c80a726376d6134744d82eec3129456b0ab0cbf
/Project/C++/C++/vc源码/FakeQQ/FakeQQ/ViewLogDlg.cpp
b3b4b9106636cb7ff340c78c3eaf4cdf84adaaff
[]
no_license
dabaopku/project_pku
338a8971586b6c4cdc52bf82cdd301d398ad909f
b97f3f15cdc3f85a9407e6bf35587116b5129334
refs/heads/master
2021-01-19T11:35:53.500533
2010-09-01T03:42:40
2010-09-01T03:42:40
null
0
0
null
null
null
null
GB18030
C++
false
false
3,148
cpp
// ViewLogDlg.cpp : implementation file // #include "stdafx.h" #include "FakeQQ.h" #include "ViewLogDlg.h" #include "ChatRecordSet.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CViewLogDlg dialog CViewLogDlg::CViewLogDlg(CWnd* pParent /*=NULL*/) : CDialog(CViewLogDlg::IDD, pParent) { //{{AFX_DATA_INIT(CViewLogDlg) m_ChatMsg = _T(""); m_UserName = _T(""); m_MsgTime = _T(""); m_Address = _T(""); //}}AFX_DATA_INIT } void CViewLogDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CViewLogDlg) DDX_Control(pDX, IDC_USER_FACE, m_UserFace); DDX_Control(pDX, IDC_LOG_LIST, m_LogList); DDX_Text(pDX, ID_CHAT_MSG, m_ChatMsg); DDX_Text(pDX, IDC_USER_NAME, m_UserName); DDX_Text(pDX, IDC_MSG_TIME, m_MsgTime); DDX_Text(pDX, IDC_ADDRESS, m_Address); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CViewLogDlg, CDialog) //{{AFX_MSG_MAP(CViewLogDlg) ON_NOTIFY(LVN_ITEMCHANGED, IDC_LOG_LIST, OnItemChangedLogList) ON_BN_CLICKED(ID_CLEAR_LOG, OnClearLog) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CViewLogDlg message handlers BOOL CViewLogDlg::OnInitDialog() { CDialog::OnInitDialog(); m_LogList.InsertColumn(0, "用户名", LVCFMT_LEFT, 80); m_LogList.InsertColumn(1, "讯息内容", LVCFMT_LEFT, 280); DWORD NewStyle = m_LogList.GetExtendedStyle(); NewStyle |= LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES; m_LogList.SetExtendedStyle(NewStyle); RefreshList(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CViewLogDlg::OnItemChangedLogList(NMHDR* pNMHDR, LRESULT* pResult) { HD_NOTIFY *phdn = (HD_NOTIFY *) pNMHDR; if(phdn->iItem >= 0) { CChatRecordSet crs(&::ChatDB); crs.m_strFilter.Format("ID=%d", m_LogList.GetItemData(phdn->iItem)); crs.Open(); if(!crs.IsEOF()) { m_ChatMsg = crs.m_ChatMsg; m_Address = crs.m_Address; m_UserName = crs.m_UserName; m_UserFace.SetIcon(::FaceIcon[crs.m_UserFace]); CTime MsgTime(crs.m_MsgTime); m_MsgTime = MsgTime.Format("%Y-%m-%d %H:%M:%S"); UpdateData(false); } } *pResult = 0; } void CViewLogDlg::OnClearLog() { if(MessageBox("该操作将删除所有讯息记录,是否继续?", "警告", MB_YESNO | MB_ICONEXCLAMATION) != IDYES) return; try { ::ChatDB.ExecuteSQL("delete from chat"); } catch(CException *e) { e->Delete(); } RefreshList(); } void CViewLogDlg::RefreshList() { m_LogList.DeleteAllItems(); try { CChatRecordSet crs(&::ChatDB); crs.Open(); int nItem = 0; while(!crs.IsEOF()) { nItem = m_LogList.InsertItem(nItem, crs.m_UserName, crs.m_UserFace); m_LogList.SetItemText(nItem, 1, crs.m_ChatMsg); m_LogList.SetItemData(nItem, (DWORD)crs.m_ID); crs.MoveNext(); } } catch(CException *e) { e->Delete(); } }
[ "[email protected]@592586dc-1302-11df-8689-7786f20063ad" ]
[ [ [ 1, 130 ] ] ]
0c589d9e3654a4f26cc1e85822361e7bda54b818
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/serialization/test/test_object.cpp
640697f5b965efe907c2371e287d47f33acc41dd
[ "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,891
cpp
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 // test_object.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) // test implementation level "object_serializable" // 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/level.hpp> #include <boost/serialization/nvp.hpp> class A { friend class boost::serialization::access; template<class Archive> void serialize(Archive & /* ar */, const unsigned int /* file_version */){ } }; BOOST_CLASS_IMPLEMENTATION(A, boost::serialization::object_serializable) // note: version can be assigned only to objects whose implementation // level is object_class_info. So, doing the following will result in // a static assertion // BOOST_CLASS_VERSION(A, 2); void out(const char *testfile, A & a) { test_ostream os(testfile, TEST_STREAM_FLAGS); test_oarchive oa(os); oa << BOOST_SERIALIZATION_NVP(a); } void in(const char *testfile, A & a) { test_istream is(testfile, TEST_STREAM_FLAGS); test_iarchive ia(is); ia >> BOOST_SERIALIZATION_NVP(a); } int test_main( int /* argc */, char* /* argv */[] ) { const char * testfile = boost::archive::tmpnam(NULL); BOOST_REQUIRE(NULL != testfile); A a; out(testfile, a); in(testfile, a); std::remove(testfile); return EXIT_SUCCESS; } // EOF
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 71 ] ] ]
6ef8933330c5b4edfa7d955cf5c9967e6e9b5379
a36d7a42310a8351aa0d427fe38b4c6eece305ea
/core_billiard/my_open_al_imp.h
6cc07d092fb40ce0972063358dcef65c2dd05346
[]
no_license
newpolaris/mybilliard01
ca92888373c97606033c16c84a423de54146386a
dc3b21c63b5bfc762d6b1741b550021b347432e8
refs/heads/master
2020-04-21T06:08:04.412207
2009-09-21T15:18:27
2009-09-21T15:18:27
39,947,400
0
0
null
null
null
null
UTF-8
C++
false
false
381
h
#pragma once #include "my_open_al.h" namespace my_open_al_imp { using namespace std; using namespace std::tr1; using namespace my_utility; using namespace my_open_al; class MyOpenALImp; class SoundHandleImp; MY_SMART_PTR( MyOpenALImp ); MY_SMART_PTR( SoundHandleImp ); } #include "MyOpenALImp.h" #include "SoundHandleImp.h"
[ "wrice127@af801a76-7f76-11de-8b9f-9be6f49bd635" ]
[ [ [ 1, 20 ] ] ]
df4cd91bd4206c4f6d1a75663c6b82e6c5352dbe
fb7d4d40bf4c170328263629acbd0bbc765c34aa
/SpaceBattle/SpaceBattleLib/GeneratedCode/Vue/Implementation/VueFabriqueImpl.h
d152d69315731b6699b307e6e9a0a9665ee88bd3
[]
no_license
bvannier/SpaceBattle
e146cda9bac1608141ad8377620623514174c0cb
6b3e1a8acc5d765223cc2b135d2b98c8400adf06
refs/heads/master
2020-05-18T03:40:16.782219
2011-11-28T22:49:36
2011-11-28T22:49:36
2,659,535
0
1
null
null
null
null
UTF-8
C++
false
false
1,546
h
//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Changes to this file will be lost if the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ #pragma once #define WANTDLLEXP #ifdef WANTDLLEXP //exportation dll #define DLL __declspec( dllexport ) #define EXTERNC extern "C" #else #define DLL //standard #define EXTERNC #endif #include "Plateau.h" using namespace VueInterfaces; #include "VuePlateau.h" using namespace VueInterfaces; #include "Vaisseau.h" using namespace VueInterfaces; #include "VueVaisseau.h" using namespace VueInterfaces; #include "Des.h" using namespace VueInterfaces; #include "VueDes.h" using namespace VueInterfaces; #include "VueFabrique.h" using namespace VueInterfaces; #include<vector> namespace VueImplementation { class VueFabriqueImpl : public VueFabrique { private : protected : public : private : protected : public : virtual VuePlateau creerVuePlateau(Plateau Modele); virtual VueVaisseau creerVueVaisseau(Vaisseau Modele); virtual VueDes creerVueDes(Des Modele); }; EXTERNC DLL VuePlateau VUEFABRIQUEIMPL_creerVuePlateau(VueFabriqueImpl*, Plateau Modele); EXTERNC DLL VueVaisseau VUEFABRIQUEIMPL_creerVueVaisseau(VueFabriqueImpl*, Vaisseau Modele); EXTERNC DLL VueDes VUEFABRIQUEIMPL_creerVueDes(VueFabriqueImpl*, Des Modele); }
[ [ [ 1, 62 ] ] ]
b46cb01e724d253a7ff68544869473e4c4fefb0d
6ee200c9dba87a5d622c2bd525b50680e92b8dab
/Walkyrie Dx9/Valkyrie/Moteur/Polygon.cpp
2b575c4b5976e26ccee7c2175836a7ca5f793a1f
[]
no_license
Ishoa/bizon
4dbcbbe94d1b380f213115251e1caac5e3139f4d
d7820563ab6831d19e973a9ded259d9649e20e27
refs/heads/master
2016-09-05T11:44:00.831438
2010-03-10T23:14:22
2010-03-10T23:14:22
32,632,823
0
0
null
null
null
null
ISO-8859-1
C++
false
false
5,457
cpp
#include "Polygon.h" // Constructeur de la classe E_Polygon. CPolygon::CPolygon() { m_pBoundingBox = NULL; m_pBoundingSphere = NULL; m_pVertex[0] = D3DXVECTOR3( 0.0f, 0.0f, 0.0f ); m_pVertex[1] = D3DXVECTOR3( 0.0f, 0.0f, 0.0f ); m_pVertex[2] = D3DXVECTOR3( 0.0f, 0.0f, 0.0f ); } // Deuxième constructeur de la classe E_Polygon. CPolygon::CPolygon( D3DXVECTOR3 Vertex1, D3DXVECTOR3 Vertex2, D3DXVECTOR3 Vertex3 ) { m_pBoundingBox = NULL; m_pBoundingSphere = NULL; m_pVertex[0] = Vertex1; m_pVertex[1] = Vertex2; m_pVertex[2] = Vertex3; } // Destructeur de la classe E_Polygon. CPolygon::~CPolygon() { // On nettoie les ressources de l'objet BoundingBox. if ( m_pBoundingBox != NULL ) { delete m_pBoundingBox; m_pBoundingBox = NULL; } // On nettoie les ressources de l'objet BoundingSphere. if ( m_pBoundingSphere != NULL ) { delete m_pBoundingSphere; m_pBoundingSphere = NULL; } } // Obtient le sommet à l'index spécifié. D3DXVECTOR3 CPolygon::GetVertex( int Index ) { // On applique un masque binaire de 3 sur l'index (valeur binaire 0011), // ceci afin de garantir que l'utilisateur ne pourra jamais dépasser les // valeurs limites du tableau de sommets. C'est ce que l'on appelle un // tableau circulaire. return m_pVertex[Index&3]; } // Définit le sommet à l'index spécifié. bool CPolygon::SetVertex( int Index, D3DXVECTOR3 Vertex ) { // On applique un masque binaire de 3 sur l'index (valeur binaire 0011), // ceci afin de garantir que l'utilisateur ne pourra jamais dépasser les // valeurs limites du tableau de sommets. C'est ce que l'on appelle un // tableau circulaire. m_pVertex[Index&3] = Vertex; UpdateBounding(); return true; } // Obtient la coordonnée du premier sommet du polygone. D3DXVECTOR3 CPolygon::GetVertex1() { return m_pVertex[0]; } // Définit la coordonnée du premier sommet du polygone. void CPolygon::SetVertex1( D3DXVECTOR3 Value ) { m_pVertex[0] = Value; UpdateBounding(); } // Obtient la coordonnée du deuxième sommet du polygone. D3DXVECTOR3 CPolygon::GetVertex2() { return m_pVertex[1]; } // Définit la coordonnée du deuxième sommet du polygone. void CPolygon::SetVertex2( D3DXVECTOR3 Value ) { m_pVertex[1] = Value; UpdateBounding(); } // Obtient la coordonnée du troisième sommet du polygone. D3DXVECTOR3 CPolygon::GetVertex3() { return m_pVertex[2]; } // Définit la coordonnée du troisième sommet du polygone. void CPolygon::SetVertex3( D3DXVECTOR3 Value ) { m_pVertex[2] = Value; UpdateBounding(); } // Obtient la boîte de collision du polygone. CBoundingBox* CPolygon::GetBoundingBox() { if ( m_pBoundingBox == NULL ) { m_pBoundingBox = new CBoundingBox(); if ( m_pBoundingBox == NULL ) { return NULL; } } return m_pBoundingBox; } // Obtient la sphere de collision du polygone. CBoundingSphere* CPolygon::GetBoundingSphere() { if ( m_pBoundingSphere == NULL ) { m_pBoundingSphere = new CBoundingSphere(); if ( m_pBoundingSphere == NULL ) { return NULL; } } return m_pBoundingSphere; } // Cette fonction met à jour les données de la boîte de collisions. void CPolygon::UpdateBounding() { if ( m_pBoundingBox != NULL ) { for ( int i = 0; i < 3; i++ ) { m_pBoundingBox->SetMax ( CMaths::GetMaxValue( m_pVertex[i], m_pBoundingBox->GetMax() ) ); m_pBoundingBox->SetMin ( CMaths::GetMinValue( m_pVertex[i], m_pBoundingBox->GetMin() ) ); } } if ( m_pBoundingSphere != NULL ) { D3DXVECTOR3 center = GetCenter(); m_pBoundingSphere->SetCenter( center); float fRadius = (float)sqrt( (m_pVertex[0].x-center.x)*(m_pVertex[0].x-center.x)+ (m_pVertex[0].y-center.y)*(m_pVertex[0].y-center.y)+ (m_pVertex[0].z-center.z)*(m_pVertex[0].z-center.z)); m_pBoundingSphere->SetRadius(fRadius); } } // Obtient le plan du polygone. D3DXPLANE CPolygon::GetPlane() { D3DXPLANE thePlane; D3DXPlaneFromPoints( &thePlane, &m_pVertex[0], &m_pVertex[1], &m_pVertex[2] ); return thePlane; } // Obtient le point central du polygone. D3DXVECTOR3 CPolygon::GetCenter() { return D3DXVECTOR3 ( ( ( m_pVertex[0].x + m_pVertex[1].x + m_pVertex[2].x ) / 3.0f ), ( ( m_pVertex[0].y + m_pVertex[1].y + m_pVertex[2].y ) / 3.0f ), ( ( m_pVertex[0].z + m_pVertex[1].z + m_pVertex[2].z ) / 3.0f ) ); } // Obtient un clone du polygone. CPolygon CPolygon::GetClone() { return CPolygon( m_pVertex[0], m_pVertex[1], m_pVertex[2] ); } // Obtient un clone du polygone transformé selon une matrice donnée. CPolygon CPolygon::ApplyMatrix( D3DXMATRIXA16 &Matrix ) { D3DXVECTOR3 TVertex[3]; D3DXVec3TransformCoord( &TVertex[0], &m_pVertex[0], &Matrix ); D3DXVec3TransformCoord( &TVertex[1], &m_pVertex[1], &Matrix ); D3DXVec3TransformCoord( &TVertex[2], &m_pVertex[2], &Matrix ); return CPolygon( TVertex[0], TVertex[1], TVertex[2] ); }
[ "Colas.Vincent@ab19582e-f48f-11de-8f43-4547254af6c6" ]
[ [ [ 1, 209 ] ] ]
430a525c3451328598c550f6a348586ec2b3cb2f
92be0bd8bb55b9ecf67d9313eda7a633502c2774
/StrangeWorld/StrangeHerbivore.cpp
d642ac2840655d0ba22c729e4f734afcf05f68b3
[]
no_license
fredlebel/StrangeWorld4
4b58ab4d283a59528394dda610df882b037102ea
080c5980ed34b0226875a5795db2096db7b739e5
refs/heads/master
2016-08-03T01:24:39.425510
2011-04-25T18:14:33
2011-04-25T18:14:33
1,580,337
0
1
null
null
null
null
UTF-8
C++
false
false
2,639
cpp
#include "StrangeCreatureOperation.h" #include "StrangeHerbivore.h" #include "StrangeNNGene.h" #include "StrangeWorldSettings.h" int StrangeHerbivore::CREATURE_COUNT = 0; int StrangeHerbivore::ourAverageAge = 0; int StrangeHerbivore::ourAverageSpawnCount = 0; int StrangeHerbivore::ourAverageFeedCount = 0; int StrangeHerbivore::ourDeathCount = 0; // Elite gene, depends wether the dead creature lived longer than the average age std::auto_ptr<StrangeNNGene> StrangeHerbivore::ourEliteGene; // Function name : StrangeHerbivore::StrangeHerbivore // Description : // Return type : // Argument : StrangeNNGene* aGene StrangeHerbivore::StrangeHerbivore( StrangeNNGene* aGene ) : StrangeLivingCreature( aGene ) { ++StrangeHerbivore::CREATURE_COUNT; } // Function name : StrangeHerbivore::~StrangeHerbivore // Description : // Return type : StrangeHerbivore::~StrangeHerbivore() { --StrangeHerbivore::CREATURE_COUNT; } // Function name : StrangeHerbivore::accept // Description : // Return type : bool // Argument : StrangeCreatureOperation* operation bool StrangeHerbivore::accept( StrangeCreatureOperation* operation ) { operation->visit_Herbivore( this ); return true; } // Function name : StrangeHerbivore::getWidth // Description : // Return type : int int StrangeHerbivore::getRadius() { return bodyRadius_; } // Function name : StrangeHerbivore::die // Description : // Return type : void void StrangeHerbivore::die() { bool isElite = false; #if defined( ELITE_IS_OLDEST ) // Save this gene as the elite one if ( age_ > ourAverageAge ) // if we are older than the average creature { isElite = true; } #endif #if defined( ELITE_IS_PROLIFIC ) if ( spawnCount_ >= ourAverageSpawnCount ) // if we have spawned more times than the average creature { isElite = true; } #endif #if defined( ELITE_EATS_MOST ) if ( feedCount_ >= ourAverageFeedCount ) // if we have spawned more times than the average creature { isElite = true; } #endif if ( isElite ) { ourEliteGene = gene_; } ourAverageAge = ( ( ourAverageAge * ELITE_SAMPLING ) + age_ ) / (ELITE_SAMPLING+1); ourAverageSpawnCount = ( ( ourAverageSpawnCount * ELITE_SAMPLING ) + spawnCount_ ) / (ELITE_SAMPLING+1); ourAverageFeedCount = ( ( ourAverageFeedCount * ELITE_SAMPLING ) + feedCount_ ) / (ELITE_SAMPLING+1); ++ourDeathCount; }
[ [ [ 1, 96 ] ] ]
dc4f49478f22ee214695cb294e78d1256c054c6b
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/nebula2/src/tinyxml/tinyxmlerror.cc
c88e1161aef5adfbb4b5f821c0d6907fef1cc7dc
[ "Zlib" ]
permissive
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,729
cc
#include "precompiled/pchxml.h" /* www.sourceforge.net/projects/tinyxml Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "tinyxml/tinyxml.h" // The goal of the seperate error file is to make the first // step towards localization. tinyxml (currently) only supports // latin-1, but at least the error messages could now be translated. // // It also cleans up the code a bit. // const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] = { "No error", "Error", "Failed to open file", "Memory allocation failed.", "Error parsing Element.", "Failed to read Element name", "Error reading Element value.", "Error reading Attributes.", "Error: empty tag.", "Error reading end tag.", "Error parsing Unknown.", "Error parsing Comment.", "Error parsing Declaration.", "Error document empty." };
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 51 ] ] ]
350ff2d0735087153cbcdf78a7e9fd888358d309
e7c45d18fa1e4285e5227e5984e07c47f8867d1d
/Common/Models/SIZEDST1/Sqszdst1.cpp
a755ba0fb19548c37322060ae6890f5326df4acd
[]
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
237,181
cpp
//================== SysCAD - Copyright Kenwalt (Pty) Ltd =================== // $Nokeywords: $ //=========================================================================== // SysCAD Copyright Kenwalt (Pty) Ltd 1992 #include "stdafx.h" #define __SQSZDST1_CPP #include "sc_defs.h" #include "sp_db.h" #include "mdlcfg.h" #include "sqszbase.h" #include "sqszdst1.h" #include "executiv.h" #include "dbgmngr.h" //#include "optoff.h" //TODO Manual size distribution //set this to 1 to allow user to enter manual size distribution sieve size ranges #define UseManualSizeDefn 0 #define WithSauterMeanD 0 #define dbgSzDist WITHDEBUG #if dbgSzDist static CDbgMngr dbgSzDistSplits("SzDist", "Splits"); #endif //=========================================================================== // // // //=========================================================================== #define MoveDistList 0 //static flag fSzAscend=false;//true; //const MaxDSizes=15; //const ActDSizes=5; //struct dSizeInfo {double d; char * Name;}; //const dSizeInfo dSzInfo[ActDSizes] = // { // {0.99, "d99"}, // {0.80, "d80"}, // {0.50, "d50"}, // {0.30, "d30"}, // {0.20, "d20"}, // }; const int Id_CurShow = 1; const int Id_CurHide = 2; const int Id_RqdSauterl32 = 3; // KGAFIX - check position / use etc of this / should not always be setable const int Id_TopSize = 30; const int Id_BotSize = 31; const int Id_IntervalCnt = 32; const int Id_SzAscend = 33; const int Id_GrWidth = 34; const int Id_GrHeight = 35; const int Id_GrOn = 36; const int Id_DispRetained = 37; const int Id_AutoScale = 38; const int Id_PartStepped = 39; const int Id_ApplyToDist = 40; const int Id_Cumulative = 41; const int Id_Fractional = 42; const int Id_XLog = 43; const int Id_XMin = 44; const int Id_XMax = 45; const int Id_XIntRng = 46; const int Id_XInt = 47; const int Id_PartLen = 48; const int Id_PartSizeDefn = 49; const int Id_DistOn = 50; const int Id_DistOff = Id_DistOn+MaxDistributions; const int Id_dSize = Id_DistOff+MaxDistributions; const int Id_YMin = Id_dSize+MaxCSDMeasurements*MaxColumns; const int Id_YFMax = Id_YMin +MaxColumns; const int Id_XIntRange = Id_YFMax; const int Id_YQmTtl = Id_YFMax+MaxColumns; const int Id_YSelection = Id_YQmTtl; const int Id_YData = Id_YQmTtl+MaxColumns; const int Id_YMode = Id_YData+MaxColumns; const int Id_YState = Id_YMode+MaxColumns; const int Id_YTitle = Id_YState+MaxColumns; const int Id_YGrfOn = Id_YTitle+MaxColumns; const int Id_CopyTest = Id_YGrfOn+MaxColumns; #ifdef USE_PSD_TB const int Id_TestDataChk = Id_CopyTest+MaxColumns; const int Id_Last = Id_TestDataChk+MaxColumns; // New Ids can start from this point for CPSDTB #endif XID xidPartSizeDefn = Qual0XID(0); XID xidPartLength = Qual0XID(1); XID xidPartCurves = Qual0XID(2); XID xidApplyToDist = Qual0XID(3); XID xidPartCrvMode_F = Qual0XID(4); XID xidPartCrvMode_C = Qual0XID(5); XID xidPartCrvState_On = Qual0XID(6); XID xidPartCrvState_Off = Qual0XID(7); XID xidPartCrvMode = Qual0XID(8); XID xidPartCrvState = xidPartCrvMode+(1*MaxColumns); XID xidPartCrvEdit = xidPartCrvMode+(2*MaxColumns); XID xidPartCrvAutoCorrect = xidPartCrvMode+(3*MaxColumns); XID xidPartCrvTitle = xidPartCrvMode+(4*MaxColumns); XID xidPartCrvCnvIndex = xidPartCrvMode+(5*MaxColumns); XID xidPartCrvCnvText = xidPartCrvMode+(6*MaxColumns); XID xidPartCrvRangeLo = xidPartCrvMode+(7*MaxColumns); XID xidPartCrvRangeHi = xidPartCrvMode+(8*MaxColumns); XID xidUsedClassID = xidPartCrvMode+(9*MaxColumns); //XID xidSzCol = Qual0XID(MaxColumns*20); see sizedst1.h XID xidSzAllowSizeEdits = xidSzCol+MaxDistributions*MaxIntervals*MaxColumns; XID xidSzDistUsed = xidSzAllowSizeEdits+1; XID xidSzDistTopSize = xidSzDistUsed+1; XID xidSzDistBottomSize = xidSzDistTopSize+1; XID xidDistSzIntervalCnt = xidSzDistBottomSize+1; XID xidSzDistPresent = xidDistSzIntervalCnt+1; XID xidSzDistOnOff = xidSzDistPresent +MaxDistributions; XID xidSzSeriesUsed = xidSzDistOnOff +MaxDistributions; XID xidSzTopSize = xidSzSeriesUsed +MaxDistributions; XID xidSzBotSize = xidSzTopSize +MaxDistributions; XID xidSzQmTtl = xidSzBotSize +MaxDistributions; XID xidSzMeas = xidSzQmTtl +(MaxDistributions*MaxColumns); XID xidSzNext = xidSzMeas +(MaxDistributions*MaxCSDMeasurements*MaxColumns); #ifdef USE_PSD_TB XID xidSzTestData = xidSzNext +(MaxDistributions*MaxCSDMeasurements*MaxColumns); // Do not know how much space // xidSzNext needs??? Does not appear to be used XID XID_Last = xidSzTestData + 1; // New XIDs can start from this point for CPSDTB #endif // ========================================================================== // // Dief'ed from Precip PSD Stuff // // ========================================================================== // ********************************************************************** // Moment: Function to calculate moment of psd // ********************************************************************** double moment_(double *dist, long j, long npts, double *x) { // System generated locals long i__1; double ret_val; // Builtin functions //double pow_di(double *, long *); // Local variables long i; // ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // // Local Variables Used // npts number of points in discretization of psd // x midpoints of discretization // Dist particle size distribution // i counter in do loop // j index of moment // ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // // Parameter adjustments // Function Body ret_val = 0.; // initialize i__1 = npts; for(i = 0; i < i__1; ++i) { ret_val += dist[i] * pow(1e6*x[i], j); // note x is midpoint } return ret_val; } // moment_ // ********************************************************************** // Number_to_Mass: Subroutine to convert number fraction psd to // mass (or volume) fraction psd // ********************************************************************** // Subroutine int number_to_mass__(double *dist, long npts, double *x) { // System generated locals long i__1; double d__1, d__2; // Local variables double const_; long ii; double mom3; // ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // // Local Variables Used // npts number of points in discretization of psd // x midpoints of discretization // const normalizing factor // dist particle size distribution // ii counter in do loop // mom3 3rd moment of psd // ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // // Functions Used // Moment Calculates moments from psd // ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // // Function Body mom3 = moment_(&dist[0], 3, npts, &x[0]); if(mom3 >= 1e-20) { const_ = 1. / mom3; } else { const_ = 0.; } i__1 = npts; for(ii = 0; ii < i__1; ++ii) { // Computing 3rd power d__1 = 1e6*x[ii], d__2 = d__1; dist[ii] = const_ * (d__2 * (d__1 * d__1)) * dist[ii]; } return 0; } // number_to_mass__ int mass_to_number__(double *dist, long npts, double *x) { // System generated locals long i__1; double d__1;//, d__2; // Local variables long ii; double sum; double scl; // ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // // Local Variables Used // npts number of points in discretization of psd // x midpoints of discretization // const normalizing factor // dist particle size distribution // ii counter in do loop // ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // // Functions Used // Moment Calculates moments from psd // ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // // Parameter adjustments sum=0; i__1 = npts; for(ii = 0; ii < i__1; ++ii) { // Computing 3rd power d__1 = 1e6*x[ii]; dist[ii] = dist[ii] / pow(d__1, 3); sum+=dist[ii]; } if (sum >= 1e-20) scl= 1/sum; else scl=0.0; for(ii = 0; ii < i__1; ++ii) dist[ii] *= scl; return 0; } // number_to_mass__ // ********************************************************************** // Dist_Sauter: Subroutine calculates bin numbers for exponential // number psd given the Sauter mean diameter // ********************************************************************** // Subroutine int dist_sauter__(double *psd, double l32, long npts, double *x) { // System generated locals long i__1; // Builtin functions //double exp(double); // Local variables long i; double mom0; // cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // // Local Variables Used // npts number of points in discretization of psd // x midpoints of discretization // i counter in do loop // L32 Sauter mean diameter // mom0 0th moment // psd particle size distribution // ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // // Functions Used // Moment Calculates moments from psd // ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // // Parameter adjustments // Function Body i__1 = npts; for(i = 0; i < i__1; ++i) { psd[i] = 1e6*x[i] * exp(x[i] * -3. / l32); // note interval prop to x } mom0 = moment_(&psd[0], 0, npts, &x[0]); i__1 = npts; for(i = 0; i < i__1; ++i) { psd[i] /= mom0; // normalize } return 0; } // dist_sauter__ // ========================================================================== // // // // ========================================================================== SQSzDistFractionInfo::SQSzDistFractionInfo(SzPartCrv1 & PartFn, int CurveNo): m_PartFn(PartFn) { m_CurveNo=CurveNo; m_ByePass2Fines=0; m_ByePass2Coarse=0; //m_SpSplit.SetSize(SDB.No()); m_pSQFines=NULL; m_pSQCoarse=NULL; m_FineMass=dNAN; m_CoarseMass=dNAN; }; // ========================================================================== // // // // ========================================================================== IMPLEMENT_SPARES(SQSzDist1, 400); IMPLEMENT_TAGOBJEDTDERIVED(SQSzDist1, "SpQuality", "SzDist", "", "SZD", TOC_ALL|TOC_GRP_SIZEDST|TOC_SIZEDIST, SQSzDist1Edt, "Size Distribution", "Specie Quality to describe the distribution of a specie with size", SQSzDist1TagObjClass); IMPLEMENT_BUILDDATADEFNGLOBAL(SQSzDist1); SQSzDist1::SQSzDist1(pTagObjClass pClass_, pchar Tag_, pTaggedObject pAttach, TagObjAttachment eAttach) : SpQuality(pClass_, Tag_, pAttach, eAttach)//, { Distributions.SetSize(SD_Defn.NDistributions()); fAllowSizeEdits=0; iRqdDistOff = -1; iRqdDistOn = -1; iDistUsed = 0; #ifdef USE_PSD_TB bAllowTestData = false; m_PSDTB = new CPSDTB(); #endif }; // -------------------------------------------------------------------------- SQSzDist1::~SQSzDist1() { for (int d=0; d<NDistributions(); d++) FreeDist(d); #ifdef USE_PSD_TB delete m_PSDTB; #endif }; // -------------------------------------------------------------------------- /*#ifndef _RELEASE SQSzDist1 & SQSzDist1::operator=(const SQSzDist1 & S) { ASSERT(0); // assignment prevent its use return *this; } #endif*/ // -------------------------------------------------------------------------- void SQSzDist1::AllocDist(int d) { ASSERT(d<NDistributions()); ASSERT_RDB(iDistUsed==d, "Why not!?!?!", __FILE__, __LINE__); if (Distributions[d]==NULL) { Distributions[d]=new CSD_Distribution(SD_Defn.GetDist(d)); } } // -------------------------------------------------------------------------- void SQSzDist1::FreeDist(int d) { if (Distributions[d]) { delete Distributions[d]; Distributions[d]=NULL; } } // -------------------------------------------------------------------------- void SQSzDist1::ChangeToDist(int d) { ASSERT(d<NDistributions()); iDistUsed = d; if (Distributions[d]==NULL) { for (int i=0; i<NDistributions(); i++) if (Distributions[i]) FreeDist(i); AllocDist(d); } } // -------------------------------------------------------------------------- //Does Nothing: //void SQSzDist1::BuildDataDefn_Lcl(DataDefnBlk & DDB) // { // } // -------------------------------------------------------------------------- flag SQSzDist1::BuildDataDefnGlobal(TagObjClass *pClass, TaggedObject * pOwner, DataDefnBlk & DDB) { //LPTSTR ClassId="Glbl_SQSzDist1Glbl"; if (DDB.BeginObject(pOwner, "SQSzDist1", "SQSzDist1_Glbl")) { DDB.BeginStruct(pOwner, "VarSlct", NULL, DDB_OptPage, UIGlobalDX|pClass->IdNo()); DDB.Text("Variable Selection"); DDB.CheckBoxBtn("FracPass", "", DC_ , "", SzDSlct_Fp , pOwner, isParm); DDB.CheckBoxBtn("MassFlow", "", DC_ , "", SzDSlct_Qm , pOwner, isParm); DDB.CheckBoxBtn("Mass", "", DC_ , "", SzDSlct_M , pOwner, isParm); DDB.CheckBoxBtn("CountFracPass", "", DC_ , "", SzDSlct_NFp , pOwner, isParm); DDB.CheckBoxBtn("CountFlow", "", DC_ , "", SzDSlct_Qn , pOwner, isParm); DDB.CheckBoxBtn("Count", "", DC_ , "", SzDSlct_N , pOwner, isParm); DDB.CheckBoxBtn("SpecCount", "", DC_ , "", SzDSlct_NpM , pOwner, isParm); DDB.CheckBoxBtn("Cumulative", "", DC_ , "", SzDSlct_Cum , pOwner, isParm); #if UseAllColumns DDB.CheckBoxBtn("CumulativeInv", "", DC_ , "", SzDSlct_CumG, pOwner, isParm); #endif DDB.EndStruct(); } DDB.EndObject(); return true; }; // -------------------------------------------------------------------------- flag SQSzDist1::DataXchgGlobal(TagObjClass *pClass, TaggedObject * pOwner, DataChangeBlk & DCB) { if (DCB.dwUserInfo==(UIGlobalDX|pClass->IdNo())) { switch (DCB.lHandle) { case SzDSlct_Fp: case SzDSlct_Qm: case SzDSlct_M: case SzDSlct_NFp: case SzDSlct_Qn: case SzDSlct_N: case SzDSlct_NpM: case SzDSlct_Cum: #if UseAllColumns case SzDSlct_CumG: #endif if (DCB.rB) CSD_Column::sm_VarSlctMask = *DCB.rB ? (CSD_Column::sm_VarSlctMask | DCB.lHandle) : (CSD_Column::sm_VarSlctMask & ~DCB.lHandle); DCB.B = (CSD_Column::sm_VarSlctMask & DCB.lHandle)!=0; return true; } }; return false; } // -------------------------------------------------------------------------- void SQSzDist1::BuildDataDefn(DataDefnBlk & DDB) { int d; Strng Nm; #if MoveDistList //if (DDB.ForView()) { //DDEF_Flags Vis=DDB.GetVisibility(); //DDB.Visibility(); DDB.Text("Distributions"); DDB.Text("-------------"); for (d=0; d<NDistributions(); d++) { CSD_DistDefn &DD=*SD_Defn.GetDist(d); Nm.Set("Dist%02d", d); //DDB.CheckBoxBtn(Nm(), "", DC_, "", xidSzDistOnOff+d, this, isParm|DDEF_AFFECTSSTRUCT, DDBYesNo); //DDB.Bool(Nm(), "", DC_, "", xidSzDistOnOff+d, this, isParmStopped|/*DDEF_AFFECTSSTRUCT|*/noFileAtAll); DDB.Bool(Nm(), "", DC_, "", xidSzDistOnOff+d, this, isParmStopped/*DDEF_AFFECTSSTRUCT|*/); DDB.TagComment(DD.Name()); } //DDB.Visibility(Vis); } DDB.Bool("AllowSizeEdits", "", DC_, "", xidSzAllowSizeEdits, this, isParm|InitHidden|noFileAtAll); #endif //find one & only active distribution... d=0; CSD_Distribution* pD = d<NDistributions() ? Distributions[d] : NULL; while (d<NDistributions() && pD==NULL) { d++; pD = d<NDistributions() ? Distributions[d] : NULL; } if (pD==NULL && NDistributions()>0) { d = 0; iDistUsed=d; AllocDist(d); pD = Distributions[d]; } /*DDB.BeginObject(this, "Sz", "SzQual", NULL, DDB_OptPage); for (int d_=0; d_<NDistributions(); d_++) { //CSD_Distribution* pD_ = Distributions[d_]; //CSD_DistDefn &DD = *SD_Defn.GetDist(d_); DDB.Bool("Present", "", DC_, "", xidSzDistPresent+d_, this, isParm); DDB.Double("TopSize", "", SD_Defn.TBCnv.Index(), SD_Defn.TBCnv.Text(), xidSzTopSize+d, this, noFileAtAll); if (d==0) DDB.Bool("AllowSizeEdits", "", DC_, "", xidSzAllowSizeEdits, this, isParm|InitHidden|noFileAtAll); } DDB.EndObject();*/ //DDB.Long("SizeDefn", "", DC_ , "", xidSzDistUsed, this, isParm); /*if (d==1) { CSD_DistDefn &DDefn=*SD_Defn.GetDist(0); DDB.BeginObject(this, DDefn.Name(), "xx", NULL, DDB_OptPage); DDB.Long("SizeDefn", "", DC_ , "", xidSzDistUsed, this, isParm); DDB.EndObject(); }*/ if (pD) { DDB.BeginObject(this, "Sz", SQSzDist1Class.ClassId(), NULL, DDB_OptPage); DDB.Long("SizeDefn", "", DC_ , "", xidSzDistUsed, this, isParm|AffectsStruct); DDB.Bool("AllowSizeEdits", "", DC_, "", xidSzAllowSizeEdits, this, isParm|InitHidden|noFileAtAll); DDB.Double("TopSize", "", DC_L, "um", xidSzDistTopSize, this, isResult|InitHidden|noFileAtAll); DDB.Double("BottomSize", "", DC_L, "um", xidSzDistBottomSize, this, isResult|InitHidden|noFileAtAll); DDB.Long("IntervalCnt", "", DC_, "", xidDistSzIntervalCnt, this, isResult|InitHidden|noFileAtAll); // Check Box whether to display PSD Test Data or not #ifdef USE_PSD_TB // if (fAllowSizeEdits) DDB.Bool("AllowTestData", "", DC_, "", xidSzTestData , this, isParm|SetOnChange); // Build the Data Definition for the PSD Test Data Entry // We do it here because if we do it at the end of the routine // the data is displayed independent of the EditView and we get Invalid Parameter // error messages - Needs further investigation. if (bAllowTestData) { m_PSDTB->SetIDOffsets( Id_Last , XID_Last ); m_PSDTB->SetDistribution(&pD->rDefn); m_PSDTB->BuildDataDefn(DDB,this); } #endif /*for (int d_=0; d_<NDistributions(); d_++) { CSD_DistDefn &DD = *SD_Defn.GetDist(d_); Strng Tg; if (d_==0) { DDB.Long("SizeDefn", "", DC_ , "", xidSzDistUsed, this, isParm); DDB.Bool("AllowSizeEdits", "", DC_, "", xidSzAllowSizeEdits, this, isParm|InitHidden|noFileAtAll); } Tg.Set("%s_TopSize", DD.Name()); DDB.Double(Tg(), "", SD_Defn.TBCnv.Index(), SD_Defn.TBCnv.Text(), xidSzTopSize+d_, this, noFileAtAll); //Tg.Set("%s_Present", DD.Name()); //DDB.Bool(Tg(), "", DC_, "", xidSzDistPresent+d_, this, isParm); }*/ //find one & only active distribution... d=0; CSD_Distribution* pD = d<NDistributions() ? Distributions[d] : NULL; while (d<NDistributions() && pD==NULL) { d++; pD = d<NDistributions() ? Distributions[d] : NULL; } CSD_DistDefn &DDefn=*SD_Defn.GetDist(d); ASSERT_RDB(pD!=NULL, "What!!!", __FILE__, __LINE__); //pD = Distributions[d]; if (pD && pModel->UseAsFlow()) { CSD_Distribution &D=*pD; if (!DDB.ForFileSnpScn()) { if (DDB.BeginObject(this, "QmTtl", "SzQmTtl", NULL, DDB_OptPage)) { //CArray <flag, flag> Done; for (int c=0; c<DDefn.Columns.GetSize(); c++) if (DDefn.Columns[c].Avail(*pModel)) { CSD_Column &C=DDefn.Columns[c]; // Done.SetSize(Max(C.iSpId+1, Done.GetSize())); if (C.iSpId>=0)// && !Done[C.iSpId]) { //Done[C.iSpId]=true; //Nm.Set("%s.QmTtl", C.sSpName()); Nm=C.sSpName(); DDB.Double(Nm(),"", SD_Defn.YQmCnv.Index(), SD_Defn.YQmCnv.Text(), xidSzQmTtl + (d*MaxDistributions) + c, this, DDEF_WRITEPROTECT|noFileAtAll|DupHandlesOk); } } } DDB.EndObject(); } } ASSERT_RDB(Distributions[d]!=NULL, "Double damn What!!!", __FILE__, __LINE__); pD = Distributions[d]; if (pD) { CSD_Distribution &D=*pD; for (int i=0; i<D.NIntervals(); i++) { Nm.Set("I%i", i); DDB.BeginObject(this, Nm(), "SzInts", NULL, DDB_OptPage); DDB.Double("Size", "", DC_L, "um", &D.rIntervals[i], this, DDEF_WRITEPROTECT); DDB.Double("SzRange", "", DC_L, "um", &D.rIntervals[i], this, DDEF_WRITEPROTECT|noFileAtAll); if (DDB.ForView() || DDB.ForFiling() || DDB.ForSnapShot()) { for (int ci=0; ci<DDefn.FileColIndices.GetSize(); ci++) { int c=DDefn.FileColIndices[ci]; if (DDefn.Columns[c].Avail(*pModel)) { CSD_Column &C=DDefn.Columns[c]; DDB.Double(C.sFullName(), (PrjFileVerNo()<23) ? C.sFullNameColon() : "", C.pCnv->Index(), C.pCnv->Text(), xidSzCol+d*MaxColumns*MaxIntervals + i*MaxColumns + c, this, isParm);//C.dwSaveFlags); } } } else { for (int c=0; c<DDefn.Columns.GetSize(); c++) if (DDefn.Columns[c].Avail(*pModel)) { CSD_Column &C=DDefn.Columns[c]; DDB.Double(C.sFullName(), (PrjFileVerNo()<23) ? C.sFullNameColon() : "", C.pCnv->Index(), C.pCnv->Text(), xidSzCol+d*MaxColumns*MaxIntervals + i*MaxColumns + c, this, C.dwSaveFlags); } } DDB.EndObject(); } if (!DDB.ForView() && !DDB.ForFiling() && !DDB.ForSnapShot()) //if (!DDB.ForFiling() && !DDB.ForSnapShot()) { const long NMeas=D.Defn().Measurements.GetSize(); for (i=0; i<NMeas; i++) { CSD_Measurement &M=D.Defn().Measurements[i]; //Nm.Set("%i", i); if (M.m_eType!=eSDMT_Text) { DDB.BeginObject(this, M.m_sName(), "SzInts", NULL, DDB_OptPage); for (int c=0; c<DDefn.Columns.GetSize(); c++) { if (DDefn.Columns[c].Avail(*pModel)) { CSD_Column &C=DDefn.Columns[c]; DDB.Double(C.sSpName(), "", M.Cnv.Index(), M.Cnv.Text(), xidSzMeas + d*MaxColumns*MaxCSDMeasurements + i*MaxColumns + c, this, DDEF_WRITEPROTECT/*C.dwSaveFlags*/|noFile|noSnap|DupHandlesOk); } } DDB.EndObject(); } } } } if (DDB.ForView()) { DDB.Object(pModel, this, NULL, NULL, DDB_RqdPage); } DDB.EndObject(); } else if (NDistributions()>0) { CSD_DistDefn &DDefn=*SD_Defn.GetDist(0); DDB.BeginObject(this, DDefn.Name(), SQSzDist1Class.ClassId(), NULL, DDB_OptPage); DDB.Long("SizeDefn", "", DC_ , "", xidSzDistUsed, this, isParm); /*for (int d_=0; d_<NDistributions(); d_++) { CSD_DistDefn &DD = *SD_Defn.GetDist(d_); Strng Tg; //Tg.Set("%s_Present", DD.Name()); //DDB.Bool(Tg(), "", DC_, "", xidSzDistPresent+d_, this, isParm); if (d_==0) { DDB.Long("SizeDefn", "", DC_ , "", xidSzDistUsed, this, isParm); DDB.Bool("AllowSizeEdits", "", DC_, "", xidSzAllowSizeEdits, this, isParm|InitHidden|noFileAtAll); } Tg.Set("%s_TopSize", DD.Name()); DDB.Double(Tg(), "", SD_Defn.TBCnv.Index(), SD_Defn.TBCnv.Text(), xidSzTopSize+d_, this, noFileAtAll); }*/ DDB.EndObject(); } /*if (d==0 && NDistributions()>1) { CSD_DistDefn &DDefn=*SD_Defn.GetDist(1); DDB.BeginObject(this, DDefn.Name(), "xx", NULL, DDB_OptPage); DDB.Long("SizeDefn", "", DC_ , "", xidSzDistUsed, this, isParm); DDB.EndObject(); }*/ } // -------------------------------------------------------------------------- flag SQSzDist1::DataXchg(DataChangeBlk & DCB) { switch (DCB.lHandle) { case xidSzAllowSizeEdits: if (DCB.rB && (pAttachedTo==NULL)) fAllowSizeEdits=*DCB.rB; DCB.B=(pAttachedTo ? AllowSizeEdits() : fAllowSizeEdits); return 1; case xidSzDistUsed: if (DCB.rL) { iDistUsed = Range(0, (int)*DCB.rL, NDistributions()-1); ChangeToDist(iDistUsed); } DCB.L=iDistUsed; return 1; case xidSzDistTopSize: DCB.D=SD_Defn.GetDist(iDistUsed)->TopSize(); return 1; case xidSzDistBottomSize: DCB.D=SD_Defn.GetDist(iDistUsed)->BottomSize(); return 1; case xidDistSzIntervalCnt: DCB.L=SD_Defn.GetDist(iDistUsed)->NIntervals(); return 1; #ifdef USE_PSD_TB case xidSzTestData: if (DCB.rB) bAllowTestData=(*DCB.rB!=0); DCB.B=bAllowTestData; return 1; #endif } #if MoveDistList if (DCB.lHandle>=xidSzDistOnOff && DCB.lHandle<xidSzDistOnOff+MaxDistributions) { const int d=DCB.lHandle-xidSzDistOnOff; flag ff = DCB.ForFiling(); flag fv = DCB.ForView(); flag fe = (Distributions[d]!=NULL); if (DCB.rB) { if (*DCB.rB) { AllocDist(d); iRqdDistOn = d; } else { FreeDist(d); iRqdDistOff = d; } //View().DoRebuild(); //perhaps post message to alloc/remove distribution? } DCB.B=(Distributions[d]!=NULL); return 1; } #endif if (DCB.lHandle>=xidSzDistPresent && DCB.lHandle<xidSzDistPresent+MaxDistributions) { const int d=DCB.lHandle-xidSzDistPresent; #if MoveDistList flag ff = DCB.ForFiling(); flag fv = DCB.ForView(); flag fe = (Distributions[d]!=NULL); #endif if (DCB.rB) { if (*DCB.rB) { //if (d!=iRqdDistOff) AllocDist(d); //else // iRqdDistOff = -1; } else { //if (d!=iRqdDistOn) // FreeDist(d); //else // iRqdDistOn = -1; } } DCB.B=(Distributions[d]!=NULL); return 1; } if (DCB.lHandle>=xidSzTopSize && DCB.lHandle<xidSzTopSize+MaxDistributions) { const int d=DCB.lHandle-xidSzTopSize; if (DistExists(d)) { //if (DCB.rD) //Distributions[d]->settopsize??? DCB.D=Distributions[d]->TopSize(); } return 1; } if (DCB.lHandle>=xidSzQmTtl && DCB.lHandle<xidSzQmTtl+(MaxDistributions*MaxColumns) && pModel->UseAsFlow()) { const int i=DCB.lHandle-xidSzQmTtl; const int d=i/MaxDistributions; const int c=i%MaxDistributions; if (DistExists(d)) { CSD_Column &C=SD_Defn.GetDist(d)->Columns[c]; //if (DCB.rD) //Distributions[d]->settopsize??? if (C.iSpId>=0) DCB.D=Distributions[d]->GetMass(&pModel->m_Ovr, pModel->MArray(), C.iSpId); } return 1; } if (DCB.lHandle>=xidSzCol && DCB.lHandle<xidSzCol+MaxDistributions*MaxIntervals*MaxColumns) { const int i=DCB.lHandle-xidSzCol; const int d=i/(MaxIntervals*MaxColumns); const int iSz=(i/MaxColumns)%MaxIntervals; const int c=i%MaxColumns; if (DistExists(d)) { CSD_Column &C=SD_Defn.GetDist(d)->Columns[c]; CSD_Distribution &D=*Distributions[d]; if (C.iDataId==DI_MFp) { if (C.iSpId>=0) { if (DCB.rD) { D.PriSp[C.iSpId]->FracPass[iSz]=*DCB.rD; } DCB.D=D.PriSp[C.iSpId]->FracPass[iSz]; return 1; } // else // DCB.D=dNAN; // return 1; } D.CalculateResults(&pModel->m_Ovr, pModel->MArray(), C.iDataId, C.iSpId); // if (C.iSpId>=0) DCB.D=D.Results()[iSz]; // else // DCB.D=dNAN; return 1; } } if (DCB.lHandle>=xidSzMeas && DCB.lHandle<xidSzMeas+MaxCSDMeasurements*MaxDistributions*MaxColumns) { int i=DCB.lHandle-xidSzMeas; int d=i/(MaxCSDMeasurements*MaxColumns); int iSz=(i/MaxColumns)%MaxCSDMeasurements; int c=i%MaxColumns; CSD_Measurement &M=SD_Defn.GetDist(d)->Measurements[iSz]; DCB.D=dNAN; if (DistExists(d)) { switch (M.m_eType) { case eSDMT_SizePassFrac: DCB.D=SizePassingFraction(d, SD_Defn.GetDist(d)->Columns[c].iSpId, M.m_dValue); break; case eSDMT_FracPassSize: DCB.D=FractionPassingSize(d, SD_Defn.GetDist(d)->Columns[c].iSpId, M.m_dValue); break; case eSDMT_SAM: DCB.D=SurfaceAreaPerGram(d, SD_Defn.GetDist(d)->Columns[c].iSpId); break; case eSDMT_SAL: DCB.D=SurfaceAreaPerLitre(d, SD_Defn.GetDist(d)->Columns[c].iSpId); break; case eSDMT_PPG: DCB.D=ParticleCountPerMass(d, SD_Defn.GetDist(d)->Columns[c].iSpId); break; } } return 1; } #ifdef USE_PSD_TB if (DCB.lHandle>=XID_Last) { int val = m_PSDTB->DataXchg(DCB); if (val != 0) return(1); } #endif return SpQuality::DataXchg(DCB); }; // -------------------------------------------------------------------------- flag SQSzDist1::ValidateData(ValidateDataBlk & VDB) { flag OK=true; for (int d=0; d<NDistributions(); d++) { if (Distributions[d]) { Strng s; CSD_Distribution& D = *Distributions[d]; OK = OK && D.ValidateData(VDB); double Err; for (int c=0; c<SD_Defn.GetDist(d)->Columns.GetSize(); c++) { CSD_Column& C = SD_Defn.GetDist(d)->Columns[c]; // if (C.iDataId==DI_MFp && C.iSpId>=0 && !TaggedObject::GetXWritesBusy() && AllowSizeEdits() && D.GetMass(pModel->MArray(), C.iSpId)>1.0e-9) if (C.iDataId==DI_MFp && C.iSpId>=0 && AllowSizeEdits() && D.GetMass(&pModel->m_Ovr, pModel->MArray(), C.iSpId)>1.0e-9) { if (D.PriSp[C.iSpId]->FracPass.AdjustCumulativeEnd(1.0, 0.0, 1.0, Err)) LogWarning(UsedByTag(), 0, "Sizes adjusted to ensure correct sum (%s column %d) Error=%g", UsedByFullTag(s), c, Err); } } } } if (OK) Equilibrate(); return OK; } // -------------------------------------------------------------------------- void SQSzDist1::ExchangeSpecies(SpQuality * Other) { OnDataChange(); }; // -------------------------------------------------------------------------- void SQSzDist1::Equilibrate() { OnDataChange(); // SMBayerBase * pB=dynamic_cast<SMBayerBase *>(pModel); // if (pB) // { // for (int d=0; d<NDistributions(); d++) // { ////TODO the 1 in the line below needs to a configurable flag // // the config extras needs to be on a per PriSpecie and Distribution basis. // if (DistExists(d) && 1) // { // const double temp = pB->Temp(); // const double dens = pB->THADens(temp); //why THA density? // const double psa = Distributions[d]->PartSurfaceArea(dens); // // Convert m^2/kg to m^2/g // pB->SetSAM(0.001*psa, true); // } // } // } }; // -------------------------------------------------------------------------- flag SQSzDist1::AllowSizeEdits() { return SQEditable(); //return true if model allows size distribution fractions to be set //if (pAttachedTo && pAttachedTo->pAttachedTo) // { // if (_stricmp(pAttachedTo->pAttachedTo->Tag(), "Qo")==0 || //used in link // _stricmp(pAttachedTo->pAttachedTo->Tag(), "Disch")==0 || //used in mill,crush1,rollscrusher // _stricmp(pAttachedTo->pAttachedTo->Tag(), "Flows")==0) //used in feeder // return false; // } //return true; } // -------------------------------------------------------------------------- char* SQSzDist1::UsedByTag() { return pAttachedTo ? pAttachedTo->BaseTag() : BaseTag(); } // -------------------------------------------------------------------------- char* SQSzDist1::UsedByFullTag(Strng& Str) { Str=(pAttachedTo ? pAttachedTo->FullObjTag() : FullObjTag()); return Str(); } // -------------------------------------------------------------------------- void SQSzDist1::ZeroMass() { OnDataChange(); for (int d=0; d<NDistributions(); d++) { if (Distributions[d]) Distributions[d]->ZeroMass(); //if (Distributions[d]) // FreeDist(d); } } // -------------------------------------------------------------------------- void SQSzDist1::ZeroDeriv() { } // -------------------------------------------------------------------------- void SQSzDist1::ScaleMass(PhMask PhaseM__, double Mult) { if (Mult < 1.0e-6) ZeroMass(); } // -------------------------------------------------------------------------- void SQSzDist1::ScaleMass(CIArray & SpIds, double Mult) { if (Mult < 1.0e-6) ZeroMass(); } // -------------------------------------------------------------------------- void SQSzDist1::ScaleMass(CSysVector &Scl, double Mult) { if (Mult < 1.0e-6) ZeroMass(); } // -------------------------------------------------------------------------- void SQSzDist1::SetMassF(CSysVector &M1, SpQuality * pQual2) { OnDataChange(); SQSzDist1 & P2=*(SQSzDist1*)pQual2; for (int d=0; d<P2.NDistributions(); d++) if (P2.Distributions[d]) { iDistUsed=d; AllocDist(d); *Distributions[d]=*P2.Distributions[d]; } else FreeDist(d); }; // -------------------------------------------------------------------------- void SQSzDist1::AddMassF(CSysVector &M1, SpQuality * pQual2, CSysVector &M2) { OnDataChange(); if (pQual2) { SQSzDist1 & P2=*(SQSzDist1*)pQual2; /*for (int d=0; d<P2.NDistributions(); d++) if (Distributions[d]) Distributions[d]->AddMassF(M1, 1.0, P2.Distributions[d], M2, 1.0); else if (P2.Distributions[d]) { iDistUsed=d; AllocDist(d); Distributions[d]->AddMassF(M1, 1.0, P2.Distributions[d], M2, 1.0); } }*/ const flag b1 = DistributionsExist(); const flag b2 = P2.DistributionsExist(); if (b1 || b2) { bool FixRqd=false; if (!b1) { //LogWarning(FullObjTag(), 0, "No Size data Create default! [%s]", P2.FullObjTag()); iDistUsed=P2.iDistUsed; AllocDist(iDistUsed); } else if (!b2) { //LogWarning(FullObjTag(), 0, "No Size data! [%s]", P2.FullObjTag()); } if (b2 && iDistUsed!=P2.iDistUsed) { LogWarning(FullObjTag(), 0, "Distributions don't match! [%s]", P2.FullObjTag()); //todo convert!!! FixRqd=true; } Distributions[iDistUsed]->AddMassF(M1, 1.0, P2.Distributions[P2.iDistUsed], M2, 1.0); /*if (FixRqd) for (s=0; s<Distributions[iDistUsed]->NPriIds(); s++) Distributions[iDistUsed]->PriSp[s]->FracPass.AdjustCumulativeEnd(1.0, 0.0, 1.0);*/ } } }; // -------------------------------------------------------------------------- void SQSzDist1::SubMassF(CSysVector &M1, SpQuality * pQual2, CSysVector &M2) { OnDataChange(); }; // -------------------------------------------------------------------------- void SQSzDist1::Copy(pSpModel pMdl2, SpQuality * pQual2) { OnDataChange(); SQSzDist1 & P2=*(SQSzDist1*)pQual2; for (int d=0; d<P2.NDistributions(); d++) if (P2.Distributions[d]) { iDistUsed=d; AllocDist(d); *Distributions[d]=*P2.Distributions[d]; } else FreeDist(d); }; // -------------------------------------------------------------------------- void SQSzDist1::AddDeriv(pSpModel pMdl2, SpQuality * pQual2, double Sgn_) { // There should not be any code here // Qualities are added in Discrete }; // -------------------------------------------------------------------------- void SQSzDist1::AddDiscrete(pSpModel pMdl2, SpQuality * pQual2, double Sgn_) { OnDataChange(); if (pQual2)// && pQ2->iOreId>=0) { SQSzDist1 & P2=*(SQSzDist1*)pQual2; for (int d=0; d<P2.NDistributions(); d++) if (Distributions[d]) Distributions[d]->AddMassF(pModel->MArray(), 1.0, P2.Distributions[d], pMdl2->MArray(), ICGetTimeInc()); else if (P2.Distributions[d]) { iDistUsed=d; AllocDist(d); Distributions[d]->AddMassF(pModel->MArray(), 1.0, P2.Distributions[d], pMdl2->MArray(), ICGetTimeInc()); } } }; // -------------------------------------------------------------------------- void SQSzDist1::ODEOperate(CODEDataBlock & ODB) { switch (ODB.m_Cmd) { case eStateAdvance: case eStateConverge: case eStateLoad: case eStateDiskLoad: OnDataChange(); break; case eStateFixDV: case eStateTest: case eStateSave: case eStateDiskSave: break; } }; // -------------------------------------------------------------------------- flag SQSzDist1::ChangeDistribution(SpConduit &QFeed, SpConduit &QProd, int iDistRqd) { SpModel * pMdli = QFeed.Model(); SQSzDist1 * pSzi = SQSzDist1::Ptr(pMdli, true); if (pSzi==NULL || !pSzi->DistributionsExist()) return false; int indexi = pSzi->DistIndex(); if (iDistRqd==indexi) return true; //already correct distribution SpModel * pMdlo = QProd.Model(); SQSzDist1 * pSzo = SQSzDist1::Ptr(pMdlo, true); if (pSzo==NULL || !pSzo->DistributionsExist()) return false; ASSERT_RDB(pMdli!=pMdlo, "Why are these pointing to same!!!", __FILE__, __LINE__); pSzo->ChangeToDist(iDistRqd); int indexo = pSzo->DistIndex(); if (indexi==indexo) return false; CSD_Distribution &Di=pSzi->Dist(indexi); CSD_Distribution &Do=pSzo->Dist(indexo); const int leni = Di.Intervals().GetSize(); const int leno = Do.Intervals().GetSize(); const double xi_min = Di.Intervals()[0]; const double xi_max = Di.Intervals()[leni-1]; const double xi_bot = Di.BottomSize(); const int Ns = Di.NPriIds(); CDArray Cumi(Ns); CDArray Cumo(Ns); for (int s=0; s<Ns; s++) { Cumi[s] = 0.0; Cumo[s] = 0.0; } double xi, x2, xo; int i = 0; int o = 0; xo = Do.Intervals()[o]; xi = xi_bot; x2 = xi_min; for (s=0; s<Ns; s++) { CDArray & Sizei = Di.PriSp[s]->FracPass; Cumi[s] += Sizei[i]; } while (xo<=xi_max && o<leno && i<leni) { while (x2<xo && i<leni-1) { i++; xi = x2; x2 = Di.Intervals()[i]; for (int s=0; s<Ns; s++) { CDArray & Sizei = Di.PriSp[s]->FracPass; Cumi[s] += Sizei[i]; } } if (x2>=xo && i<leni) { //LogNote("xx", 0, "%2d: B %.4gmm between (%d and %d) %.4gmm and %.4gmm", o, xo, i-1, i, xi, x2); //Use cumulative. Convert to log scale (RR), then use linear interpolation on this scale const double xlog1 = log(x2); const double xlog2 = log(xi); const double xlogr = log(xo); //required size for (int s=0; s<Ns; s++) { CDArray & Sizei = Di.PriSp[s]->FracPass; CDArray & Sizeo = Do.PriSp[s]->FracPass; const double fp1 = Cumi[s]; const double fp2 = Cumi[s]-Sizei[i]; if (fabs(fp2-fp1)<1.0e-9) { //Sizeo[o] = 0.0; Sizeo[o] = Max(0.0, fp1-Cumo[s]); Cumo[s] += Sizeo[o]; } else { const double loglog1 = log(-log(Min(fp1, 0.999999999))); const double loglog2 = log(-log(Max(fp2, 0.000000001))); const double m = (loglog2-loglog1) / (xlog2-xlog1); const double loglogr = loglog1 + m * (xlogr-xlog1); const double Prevcumo = Cumo[s]; Cumo[s] = exp(-exp(loglogr)); Sizeo[o] = Cumo[s]-Prevcumo; } } o++; if (o<leno) xo = Do.Intervals()[o]; } } //top end if (o<leno) { for (int s=0; s<Ns; s++) { CDArray & Sizeo = Do.PriSp[s]->FracPass; Sizeo[o] = 1.0 - Cumo[s]; } o++; if (o<leno) xo = Do.Intervals()[o]; } while (o<leno) { //LogNote("xx", 0, "%2d: C %.4gmm", o, xo); for (int s=0; s<Do.NPriIds(); s++) { CDArray & Sizeo = Do.PriSp[s]->FracPass; Sizeo[o] = 0.0; } o++; if (o<leno) xo = Do.Intervals()[o]; } //ensure math is exactly correct... for (s=0; s<Do.NPriIds(); s++) Do.PriSp[s]->FracPass.AdjustCumulativeEnd(1.0, 0.0, 1.0); return true; } // -------------------------------------------------------------------------- class SPFFnd : public MRootFinderBase { public: SQSzDist1 *pSz; int iDistNo, iPriId; double dDX; static CToleranceBlock s_Tol; SPFFnd(double DX, SQSzDist1 *Sz, int DistNo, int PriId) : MRootFinderBase("SPFFnd", s_Tol) { dDX=DX; pSz=Sz; iDistNo=DistNo; iPriId=PriId;}; LPCTSTR ObjTag() { return (LPCTSTR)pSz->FullObjTag(); }; double Function(double x) { return pSz->FractionPassingSize(iDistNo, iPriId, x)-dDX; }; }; CToleranceBlock SPFFnd::s_Tol(TBF_Both, "SizeDst:SPFFnd", 0, 1.0e-9); // -------------------------------------------------------------------------- double SQSzDist1::SizePassingFraction(int DistNo, int PriId, double dFrac) { int d0, dN; GetApplyToDists(DistNo, d0, dN); int GotOne=0; double BottomSize=1e10; double TopSize=0.0; for (int d=d0; d<dN; d++) if (DistExists(d)) { GotOne=1; CSD_Distribution &D=Dist(d); BottomSize=Min(BottomSize, D.BottomSize()); TopSize=Max(TopSize, D.TopSize()); } if (GotOne) { double CutSize=Sqrt(BottomSize*TopSize); SPFFnd SPFF(dFrac, this, DistNo, PriId); SPFF.SetTarget(0.0); int iErr=SPFF.Start(BottomSize, TopSize); if (iErr==RF_OK) { if (SPFF.Solve_Brent()!=RF_OK) LogWarning(FullObjTag(), 0, "SQSzDist1::SPF() - Brent Not Converged"); else return SPFF.Result(); } //else // LogWarning(FullObjTag(), 0, "SQSzDist1::SPF() - Brent Not Started"); return dNAN; } return dNAN; } // -------------------------------------------------------------------------- double SQSzDist1::FractionPassingSize(int DistNo, int PriId, double dSize) { if (!Valid(dSize)) return dNAN; int d0, dN; GetApplyToDists(DistNo, d0, dN); int GotOne=0; double SPF = 0.0; double TotMass = 0.0; for (int d=d0; d<dN; d++) if (DistExists(d)) { GotOne=true; CSD_Distribution &D=Dist(d); int s0=(PriId>=0) ? PriId : 0; int sN=(PriId>=0) ? PriId : D.NPriIds()-1; for (int s=s0; s<=sN; s++) { SpVector & M=pModel->m_M; double Mass=0.0; for (int l=0; l<D.NSecIds(s); l++) Mass+=M[D.SzId(s,l)]; CDArray & Size = D.PriSp[s]->FracPass; if (Size.GetSize()>0) { static CDArray CumSize; CumSize = Size; CumSize.ToCumulative(); double PF = CumSize.LinearInterpolate(dSize, D.Intervals(), false); SPF+=PF*Mass; } TotMass+=Mass; } } if (GotOne) return SPF/GTZ(TotMass); return dNAN; } // -------------------------------------------------------------------------- double SQSzDist1::SurfaceAreaPerGram(int DistNo, int PriId) { int d0, dN; GetApplyToDists(DistNo, d0, dN); double Temp=pModel->Temp(); double Press=pModel->Press(); CDensityInfo C(pModel->Fidelity(), SMO_DensNone, Temp, Press, NULL, pModel->SVData()); double SAM=0; double TotMass=0; for (int d=d0; d<dN; d++) { if (DistExists(d)) { CSD_Distribution &D=Dist(d); int s0=(PriId>=0) ? PriId : 0; int sN=(PriId>=0) ? PriId : D.NPriIds()-1; for (int s=s0; s<=sN; s++) { long NIntervals = D.NIntervals(); CDArray & Size = D.Intervals(); CDArray & FracPass = D.PriSp[s]->FracPass; for (int l=0; l<D.NSecIds(s); l++) { double Dens=SDB[D.SzId(s,l)].DensityXZero(C); double Mass=C.Mass(); TotMass+=Mass; for (long i=0; i<NIntervals; i++) { double DMean = (i==0) ? (Size[i] / 2) : ((Size[i] + Size[i-1]) / 2); double CntPerGram = 0.001 * FracPass[i] * Mass / (Dens * PI/6*pow(DMean, 3)); double AreaPerGram = CntPerGram * (PI*DMean*DMean); SAM+=AreaPerGram; } } } } } return SAM/GTZ(TotMass); } // -------------------------------------------------------------------------- double SQSzDist1::SurfaceAreaPerLitre(int DistNo, int PriId) { int d0, dN; GetApplyToDists(DistNo, d0, dN); double Temp=pModel->Temp(); double Press=pModel->Press(); CDensityInfo C(pModel->Fidelity(), SMO_DensNone, Temp, Press, NULL, pModel->SVData()); double SAL=0; double TotMass=0; for (int d=d0; d<dN; d++) if (DistExists(d)) { CSD_Distribution &D=Dist(d); int s0=(PriId>=0) ? PriId : 0; int sN=(PriId>=0) ? PriId : D.NPriIds()-1; for (int s=s0; s<=sN; s++) { long NIntervals = D.NIntervals(); CDArray & Size = D.Intervals(); CDArray & FracPass = D.PriSp[s]->FracPass; for (int l=0; l<D.NSecIds(s); l++) { double Dens=SDB[D.SzId(s,l)].DensityXZero(C); double Mass=C.Mass(); TotMass+=Mass; for (long i=0; i<NIntervals; i++) { double DMean = (i==0) ? (Size[i] / 2) : ((Size[i] + Size[i-1]) / 2); double CntPerGram = 0.001 * FracPass[i] * Mass / (Dens * PI/6*pow(DMean, 3)); double AreaPerGram = CntPerGram * (PI*DMean*DMean); SAL+=AreaPerGram*Dens; } } } } return SAL/GTZ(TotMass); } // -------------------------------------------------------------------------- double SQSzDist1::ParticleCountPerMass(int DistNo, int PriId) { int d0, dN; GetApplyToDists(DistNo, d0, dN); if (1)//pModel->AllMassesValid()) { double Temp=pModel->Temp(); double Press=pModel->Press(); CDensityInfo C(pModel->Fidelity(), SMO_DensNone, Temp, Press, NULL, pModel->SVData()); double Cnt=0; double TotMass=0; for (int d=d0; d<dN; d++) if (DistExists(d)) { CSD_Distribution &D=Dist(d); int s0=(PriId>=0) ? PriId : 0; int sN=(PriId>=0) ? PriId : D.NPriIds()-1; for (int s=s0; s<=sN; s++) { long NIntervals = D.NIntervals(); CDArray & Size = D.Intervals(); CDArray & FracPass = D.PriSp[s]->FracPass; for (int l=0; l<D.NSecIds(s); l++) { const double Dens=SDB[D.SzId(s,l)].DensityXZero(C); const double Mass=C.Mass(); TotMass+=Mass; for (long i=0; i<NIntervals; i++) { const double DMean = (i==0) ? (Size[i] / 2) : ((Size[i] + Size[i-1]) / 2); double CntPerKg = FracPass[i] * Mass / (Dens * PI/6*pow(DMean, 3)); Cnt+=CntPerKg; } } } } return Cnt/GTZ(TotMass); } return dNAN; } // -------------------------------------------------------------------------- double SQSzDist1::GeometricMean(int DistNo, int PriId) { /* CDArray & X=SizeFn.Xs(); CDArray & Y=SizeFn.Ys(); double SumDiff=0.0; double SumLnDiff=0.0; double SumY=0.0; int n=SizeFn.Length(); for (int i=0; i<n; i++) { double Diff, LnDiff; if (i==n-1) { Diff=0.0; LnDiff=0.0; } else { Diff=X[i+1]-X[i]; LnDiff=log(Sqrt(X[i+1]*X[i]))*Diff; } SumDiff+=Diff; SumLnDiff+=LnDiff; SumY+=Y[i]; if (i<4) // Fineest 4 } double DLnK=log(X[0])*(1.0-SumY) double D_N= */ return dNAN; } // -------------------------------------------------------------------------- double SQSzDist1::TotalMass(int DistNo, int PriId) { int d0, dN; GetApplyToDists(DistNo, d0, dN); double TotMass = 0.0; for (int d=d0; d<dN; d++) if (DistExists(d)) { CSD_Distribution &D=Dist(d); int s0=(PriId>=0) ? PriId : 0; int sN=(PriId>=0) ? PriId : D.NPriIds()-1; for (int s=s0; s<=sN; s++) { SpVector & M=pModel->m_M; for (int l=0; l<D.NSecIds(s); l++) TotMass+=M[D.SzId(s,l)]; } } return TotMass; } // -------------------------------------------------------------------------- CSD_Distribution * SQSzDist1::FindDistributionFor(int SpecieId) { for (int i=0; i<NDistributions(); i++) if (DistExists(i)) { CSD_Distribution * D=Distributions[i]; for (int j=0; j<D->NPriIds(); j++) if (D->SzId(j, 0)==SpecieId) return D; } return NULL; }; // -------------------------------------------------------------------------- CSD_SpDist * SQSzDist1::FindSpDistributionFor(int SpecieId) { for (int i=0; i<NDistributions(); i++) if (DistExists(i)) { CSD_Distribution * D=Distributions[i]; for (int j=0; j<D->NPriIds(); j++) if (D->SzId(j, 0)==SpecieId) return D->PriSp[j]; } return NULL; }; // -------------------------------------------------------------------------- double SQSzDist1::DoFinesFraction(C2DFn & PartFn, double ByePass2Fines, double ByePass2Grits, flag bSetIt) { OnDataChange(); double Sum0=0.0; double Sum1=0.0; return Sum1/GTZ(Sum0); }; // -------------------------------------------------------------------------- double SQSzDist1::DoGritsFraction(C2DFn & PartFn, double ByePass2Fines, double ByePass2Grits, flag bSetIt) { OnDataChange(); double Sum0=0.0; double Sum1=0.0; return Sum1/GTZ(Sum0); } // -------------------------------------------------------------------------- double SQSzDist1::DoFinesFraction(SQSzDistFractionInfo &Info, flag bSetIt) { OnDataChange(); const int nCrv=Info.m_PartFn.Length(); if (nCrv==0)// || ns==0) return 0.0; #if dbgSzDist if (dbgSzDistSplits()) dbgpln("--------------------------------------------"); #endif double Sum0=0.0; double Sum1=0.0; CDArray & PcX = Info.m_PartFn.SizePts(); double GF = Range(0.0, 1.0 - Info.m_ByePass2Fines /*- ByePass2Grits*/, 1.0); Info.m_SpSplitToFines.SetSpcScalar(dNAN); int d0, dN; Info.m_PartFn.GetApplyToDists(d0, dN); #if WithIndividPartCrv if (Info.m_CurveNo<0) { // NB Info.m_pSQFines Info.m_pSQCoarse // Relies on Fines Dist being structurally the same 'this' after a copy for (int d=d0; d<dN; d++) if (DistExists(d)) { CSD_Distribution &D=Dist(d); double TotMass=TotalMass(d, -1); const int nInt=D.NIntervals(); CDArray & Size=D.Intervals(); const int CrvCount = Info.m_PartFn.NCurves(); const int PriIdsCount = D.NPriIds(); if (CrvCount!=PriIdsCount) { int xx=0; //DO NOT EXPECT THIS } for (int crv=0; crv<CrvCount; crv++) { CDArray & PcY = Info.m_PartFn.Curve(crv); double p0=PcY[0]; double p1=PcY[nCrv-1]; if (Info.m_PartFn.CurveState(crv)==PC_Off) continue; const bool ToCoarse=(Info.m_PartFn.CurveMode(crv)==PC_Frac2Coarse); int iCrvX=0; double Sz0=0.0; double PcX0=0.0; double PcX1=PcX[iCrvX]; double PcY0=ToCoarse ? 0.0 : 1.0; double PcY1=PcY[iCrvX]; #if dbgSzDist if (dbgSzDistSplits()) dbgpln(" ------Size----- SumSplit --------Span------- ---------Pc---------"); #endif for (long iInt=0; iInt<nInt; iInt++) { double Sz=Size[iInt]; double SumSplit=0.0; double SzSpan=Sz-Sz0; for (;;) { if (SzSpan>0.0) //KGA 14/7/98 { //... double PcSpan=Min(Sz,PcX1)-Max(Sz0, PcX0); if (Info.m_PartFn.PartStepped()) SumSplit+=PcY1*PcSpan/SzSpan; else { SumSplit+=PcY1*PcSpan/SzSpan; // ETC ETC //TODO Smooth Partition Curve } #if dbgSzDist if (dbgSzDistSplits()) dbgpln("%3i %3i %12.3f>%12.3f %7.3f %12.3f/%12.3f %12.3f>%12.3f", iInt, iCrvX, Sz0*1e6, Sz*1e6, SumSplit, PcSpan*1e6 ,SzSpan*1e6, PcX0*1e6, PcX1*1e6); #endif } if (PcX1<=Sz) { if (iCrvX<nCrv) { PcX0=PcX1; PcX1=PcX[iCrvX]; PcY1=PcY[iCrvX]; iCrvX++; } else { iCrvX++; PcX0=PcX1; PcX1=1.1*Size[nInt-1]; // TopSize PcY1=1.1*Size[nInt-1]; // TopSize } } else// if (iCrvX>=nCrv) break; } //for (int s=0; s<D.NPriIds(); s++) { double &TotFrac=D.PriSp[crv]->FracPass[iInt]; double TotMass=TotalMass(d, crv); double FineFrac, CoarseFrac; if (ToCoarse) { FineFrac=TotFrac * (Info.m_ByePass2Fines + GF * (1.0-SumSplit)); CoarseFrac=TotFrac * (Info.m_ByePass2Fines + GF * SumSplit); } else { FineFrac=TotFrac * (Info.m_ByePass2Fines + GF * SumSplit); CoarseFrac=TotFrac * (Info.m_ByePass2Fines + GF * (1.0-SumSplit)); } Sum0+=TotFrac*TotMass; Sum1+=FineFrac*TotMass; D.PriSp[crv]->WorkFrac[iInt]=FineFrac; if (Info.m_pSQFines) Info.m_pSQFines->Dist(d).PriSp[crv]->FracPass[iInt]=FineFrac; if (Info.m_pSQCoarse) Info.m_pSQCoarse->Dist(d).PriSp[crv]->FracPass[iInt]=CoarseFrac; } Sz0=Sz; } //for (int s=0; s<D.NPriIds(); s++) { if (Info.m_pSQFines) Info.m_pSQFines->Dist(d).PriSp[crv]->FracPass.Normalise(); if (Info.m_pSQCoarse) Info.m_pSQCoarse->Dist(d).PriSp[crv]->FracPass.Normalise(); } #if dbgSzDist if (dbgSzDistSplits()) { dbgpln("------------------------"); dbgpln(" FP Split FnFP CsFP"); //for (int s=0; s<D.NPriIds(); s++) for (int iInt=0; iInt<nInt; iInt++) { dbgp("%3i %7.3f %7.3f ",iInt, D.PriSp[crv]->FracPass[iInt], D.PriSp[crv]->WorkFrac[iInt]); dbgp(Info.m_pSQFines ? "%7.3f ":" *",Info.m_pSQFines->Dist(d).PriSp[crv]->FracPass[iInt]); dbgp(Info.m_pSQCoarse ? "%7.3f ":" *",Info.m_pSQCoarse->Dist(d).PriSp[crv]->FracPass[iInt]); dbgpln(" %s", SDB[D.SzId(crv,0)].SymOrTag()); } } #endif //for (int sp=0; sp<D.NPriIds(); sp++) { //Must also do the secondary species double SplitToFines=0.0; for (int iInt=0; iInt<nInt; iInt++) SplitToFines+=D.PriSp[crv]->WorkFrac[iInt]; for (int sp1=0; sp1<D.NSecIds(crv); sp1++) { int sc=D.SzId(crv, sp1); Info.m_SpSplitToFines.VValue[sc]=SplitToFines; } #if dbgSzDist if (dbgSzDistSplits()) dbgpln("Split:%7.3f, %s", Info.m_SpSplitToFines[crv], SDB[crv].SymOrTag()); #endif } } } } #endif if (Info.m_CurveNo>=0) { // NB Info.m_pSQFines Info.m_pSQCoarse // Relies on Fines Dist being structurally the same 'this' after a copy for (int d=d0; d<dN; d++) if (DistExists(d)) { CDArray & PcY = Info.m_PartFn.Curve(Info.m_CurveNo); double p0=PcY[0]; double p1=PcY[nCrv-1]; CSD_Distribution &D=Dist(d); double TotMass=TotalMass(d, -1); int nInt=D.NIntervals(); CDArray & Size=D.Intervals(); if (Info.m_PartFn.CurveState(Info.m_CurveNo)==PC_Off) continue; flag ToCoarse=(Info.m_PartFn.CurveMode(Info.m_CurveNo)==PC_Frac2Coarse); int iCrvX=0; double Sz0=0.0; double PcX0=0.0; double PcX1=PcX[iCrvX]; double PcY0=ToCoarse ? 0.0 : 1.0; double PcY1=PcY[iCrvX]; #if dbgSzDist if (dbgSzDistSplits()) dbgpln(" ------Size----- SumSplit --------Span------- ---------Pc---------"); #endif for (long iInt=0; iInt<nInt; iInt++) { double Sz=Size[iInt]; double SumSplit=0.0; double SzSpan=Sz-Sz0; for (;;) { if (SzSpan>0.0) //KGA 14/7/98 { //... double PcSpan=Min(Sz,PcX1)-Max(Sz0, PcX0); if (Info.m_PartFn.PartStepped()) SumSplit+=PcY1*PcSpan/SzSpan; else { SumSplit+=PcY1*PcSpan/SzSpan; // ETC ETC //TODO Smooth Partition Curve } #if dbgSzDist if (dbgSzDistSplits()) dbgpln("%3i %3i %12.3f>%12.3f %7.3f %12.3f/%12.3f %12.3f>%12.3f", iInt, iCrvX, Sz0*1e6, Sz*1e6, SumSplit, PcSpan*1e6 ,SzSpan*1e6, PcX0*1e6, PcX1*1e6); #endif } if (PcX1<=Sz) { if (iCrvX<nCrv) { PcX0=PcX1; PcX1=PcX[iCrvX]; PcY1=PcY[iCrvX]; iCrvX++; } else { iCrvX++; PcX0=PcX1; PcX1=1.1*Size[nInt-1]; // TopSize PcY1=1.1*Size[nInt-1]; // TopSize } } else// if (iCrvX>=nCrv) break; } for (int s=0; s<D.NPriIds(); s++) { double &TotFrac=D.PriSp[s]->FracPass[iInt]; double TotMass=TotalMass(d, s); double FineFrac, CoarseFrac; if (ToCoarse) { FineFrac=TotFrac * (Info.m_ByePass2Fines + GF * (1.0-SumSplit)); CoarseFrac=TotFrac * (Info.m_ByePass2Fines + GF * SumSplit); } else { FineFrac=TotFrac * (Info.m_ByePass2Fines + GF * SumSplit); CoarseFrac=TotFrac * (Info.m_ByePass2Fines + GF * (1.0-SumSplit)); } Sum0+=TotFrac*TotMass; Sum1+=FineFrac*TotMass; D.PriSp[s]->WorkFrac[iInt]=FineFrac; if (Info.m_pSQFines) Info.m_pSQFines->Dist(d).PriSp[s]->FracPass[iInt]=FineFrac; if (Info.m_pSQCoarse) Info.m_pSQCoarse->Dist(d).PriSp[s]->FracPass[iInt]=CoarseFrac; } Sz0=Sz; } for (int s=0; s<D.NPriIds(); s++) { if (Info.m_pSQFines) Info.m_pSQFines->Dist(d).PriSp[s]->FracPass.Normalise(); if (Info.m_pSQCoarse) Info.m_pSQCoarse->Dist(d).PriSp[s]->FracPass.Normalise(); } #if dbgSzDist if (dbgSzDistSplits()) { dbgpln("------------------------"); dbgpln(" FP Split FnFP CsFP"); for (int s=0; s<D.NPriIds(); s++) for (int iInt=0; iInt<nInt; iInt++) { dbgp("%3i %7.3f %7.3f ",iInt, D.PriSp[s]->FracPass[iInt], D.PriSp[s]->WorkFrac[iInt]); dbgp(Info.m_pSQFines ? "%7.3f ":" *",Info.m_pSQFines->Dist(d).PriSp[s]->FracPass[iInt]); dbgp(Info.m_pSQCoarse ? "%7.3f ":" *",Info.m_pSQCoarse->Dist(d).PriSp[s]->FracPass[iInt]); dbgpln(" %s",SDB[D.SzId(s,0)].SymOrTag()); } } #endif for (int sp=0; sp<D.NPriIds(); sp++) { // CNM must also do the secondary species //int s=D.SzId(sp,0); //Info.m_SpSplitToFines[s]=0.0; //for (int iInt=0; iInt<nInt; iInt++) // Info.m_SpSplitToFines[s]+=D.PriSp[sp]->WorkFrac[iInt]; double SplitToFines=0.0; for (int iInt=0; iInt<nInt; iInt++) SplitToFines+=D.PriSp[sp]->WorkFrac[iInt]; for (int sp1=0; sp1<D.NSecIds(sp); sp1++) { int sc=D.SzId(sp, sp1); Info.m_SpSplitToFines.VValue[sc]=SplitToFines; } #if dbgSzDist if (dbgSzDistSplits()) dbgpln("Split:%7.3f, %s", Info.m_SpSplitToFines[sp], SDB[sp].SymOrTag()); #endif } } } return Sum1/GTZ(Sum0); }; // -------------------------------------------------------------------------- double SQSzDist1::DoGritsFraction(SQSzDistFractionInfo &Info, flag bSetIt) { OnDataChange(); double Sum0=0.0; double Sum1=0.0; return Sum1/GTZ(Sum0); } // -------------------------------------------------------------------------- double SQSzDist1::DoSplitSolids(SQSzDistFractionInfo &Info, SpModel &QFine, SpModel &QCoarse) { SpModel &QFeed=*pModel; SQSzDist1 *FSz=SQSzDist1::Ptr(&QFine); SQSzDist1 *CSz=SQSzDist1::Ptr(&QCoarse); // QFine.SetMassM(*this, som_Sol, 0.0, Std_P); // QCoarse.SetMassM(*this, som_Sol, 0.0, Std_P); FSz->Copy(&QFeed, this); CSz->Copy(&QFeed, this); Info.m_pSQFines=FSz; Info.m_pSQCoarse=CSz; double FF=DoFinesFraction(Info, false); double TFn=0.0; double TCs=0.0; for (int s=0; s<SDB.Count(); s++) if (Valid(Info.m_SpSplitToFines[s])) { double MFn=QFeed.m_M[s]*Info.m_SpSplitToFines[s]; double MCs=QFeed.m_M[s]-MFn; QFine.SetVMass(s, QFeed, MFn); QCoarse.SetVMass(s, QFeed, MCs); TFn+=MFn; TCs+=MCs; } Info.m_FineMass=TFn; Info.m_CoarseMass=TCs; return FF; }; // -------------------------------------------------------------------------- double SQSzDist1::Crush0(C2DFn & PartFn) { OnDataChange(); for (int d=0; d<NDistributions(); d++) if (Distributions[d]) { Distributions[d]->Crush0(PartFn); } return 0.0; } // -------------------------------------------------------------------------- double SQSzDist1::Crush0(SzPartCrv1 & PartFn, int CurveNo) { OnDataChange(); for (int d=0; d<NDistributions(); d++) if (Distributions[d]) { Distributions[d]->Crush0(PartFn, CurveNo); } return 0.0; } // -------------------------------------------------------------------------- double SQSzDist1::Break0(SzSelBrk1 & SB) { OnDataChange(); for (int d=0; d<NDistributions(); d++) if (Distributions[d]) { Distributions[d]->Break0(SB); } return 0.0; } // -------------------------------------------------------------------------- double SQSzDist1::CrushExt0(SzPartCrv1 &Extents, SpConduit &QFeed, int CurveNo) { OnDataChange(); SQSzDist1 & FdSz = *SQSzDist1::Ptr(QFeed.Model()); for (int d=0; d<NDistributions(); d++) if (Distributions[d] && FdSz.Distributions[d]) { Distributions[d]->CrushExt0(Extents, *(FdSz.Distributions[d]), CurveNo); } return 0.0; } // -------------------------------------------------------------------------- double SQSzDist1::Crush1(int s, C2DFn & PartFn) { OnDataChange(); for (int d=0; d<NDistributions(); d++) if (Distributions[d] && s<Distributions[d]->NPriIds()) { Distributions[d]->Crush1(s, PartFn); } return 0.0; } // -------------------------------------------------------------------------- double SQSzDist1::Crush1(int s, SzPartCrv1 & PartFn, int CurveNo) { OnDataChange(); for (int d=0; d<NDistributions(); d++) if (Distributions[d] && s<Distributions[d]->NPriIds()) { Distributions[d]->Crush1(s, PartFn, CurveNo); } return 0.0; } // -------------------------------------------------------------------------- double SQSzDist1::CrushExt1(int s, SzPartCrv1 &Extents, SpConduit &QFeed, int CurveNo) { OnDataChange(); SQSzDist1 & FdSz = *SQSzDist1::Ptr(QFeed.Model()); for (int d=0; d<NDistributions(); d++) if (Distributions[d] && FdSz.Distributions[d] && s<Distributions[d]->NPriIds()) { Distributions[d]->CrushExt1(s, Extents, *(FdSz.Distributions[d]), CurveNo); } return 0.0; } // -------------------------------------------------------------------------- flag SQSzDist1::CheckDischIsValid1(int s, SpConduit &QFeed) { SQSzDist1 & FdSz = *SQSzDist1::Ptr(QFeed.Model()); for (int d=0; d<NDistributions(); d++) if (Distributions[d] && FdSz.Distributions[d] && s<Distributions[d]->NPriIds()) { //CSD_Distribution &D=*Distributions[d]; CSD_SpDist & SFeed = *(FdSz.Distributions[d]->PriSp[s]); CSD_SpDist & SDisch = *(Distributions[d]->PriSp[s]); double SumFeed = 0.0; double SumDisch = 0.0; for (int j=Distributions[d]->NIntervals()-1; j>=0; j--) { SumFeed += SFeed.FracPass[j]; SumDisch += SDisch.FracPass[j]; if (SumDisch-SumFeed>1.0e-9) return false; } } return true; } // -------------------------------------------------------------------------- double SQSzDist1::CorrectDisch1(int s, SpConduit &QFeed) { SQSzDist1 & FdSz = *SQSzDist1::Ptr(QFeed.Model()); for (int d=0; d<NDistributions(); d++) if (Distributions[d] && FdSz.Distributions[d] && s<Distributions[d]->NPriIds()) { //CSD_Distribution &D=*Distributions[d]; CSD_SpDist & SFeed = *(FdSz.Distributions[d]->PriSp[s]); CSD_SpDist & SDisch = *(Distributions[d]->PriSp[s]); double SumFeed = 0.0; double SumDisch = 0.0; for (int j=Distributions[d]->NIntervals()-1; j>=0; j--) { SumFeed += SFeed.FracPass[j]; double PrevSumDisch = SumDisch; SumDisch += SDisch.FracPass[j]; if (SumDisch>SumFeed) { if (j==0) SDisch.FracPass[j] = 1.0 - PrevSumDisch; else { double Extra = SumDisch - SumFeed; SDisch.FracPass[j] = SumFeed - PrevSumDisch; double TempSumDisch = SumFeed; if (SumDisch>=1.0) { for (int i=j-1; i>0; i--) { double d = (1.0/j) * Extra; SDisch.FracPass[i] += d; TempSumDisch += SDisch.FracPass[i]; } } else { for (int i=j-1; i>0; i--) { double d = (SDisch.FracPass[i]/(1.0-SumDisch)) * Extra; SDisch.FracPass[i] += d; TempSumDisch += SDisch.FracPass[i]; } } SDisch.FracPass[0] = 1.0 - TempSumDisch; SumDisch = SumFeed; } } } } return 0.0; } // ========================================================================== // // // // ========================================================================== SQSzDist1TagObjClass::SQSzDist1TagObjClass(pchar pClassName, pchar pGroup_, pchar pClassId_, pchar SubClassId, pchar pVersion_, pchar pDrwGroup_, pchar pDefTag_, dword dwCat, pchar ShortDesc, pchar pDesc, DWORD SelectMask) : SQTagObjClass(pClassName, pGroup_, pClassId_, SubClassId, pVersion_/*, pDrwGroup_*/, pDefTag_, dwCat, ShortDesc, pDesc, SelectMask) { FCnv.Set(DC_Frac, "%"); FFmt.Set("", 0, 2, 'f'); } /* NBNB: KGA 13/1/04 : Potential problem? Correlation between tear variables and number of distribution definitions (used or unused!) needs checking!!! More than one distribution may exist in a project (or project cfg file) but only one is ever actually used in a tear stream! */ //--------------------------------------------------------------------------- int SQSzDist1TagObjClass::NTearVariables() { int N=0; for (int d=0; d<SD_Defn.NDistributions(); d++) { CSD_DistDefn &D=*(SD_Defn.GetDist(d)); N+=D.NPriIds()*D.NIntervals(); } return N; }; //--------------------------------------------------------------------------- int SQSzDist1TagObjClass::DefineTearVariables(TearVarArray & TV, int n) { int N=0; for (int d=0; d<SD_Defn.NDistributions(); d++) { CSD_DistDefn &D=*(SD_Defn.GetDist(d)); for (int id=0; id<D.NPriIds(); id++) { int s=D.SzId(id,0); for (int i=0; i<D.NIntervals(); i++) { TV[n].m_Tag.Set("D%i.I%i.%s", d, i, SDB[s].Tag()); TV[n].m_Sym.Set("D%i.I%i.%s", d, i, SDB[s].SymOrTag()); TV[n].m_pDiffCnv=&FCnv; TV[n].m_pDiffFmt=&FFmt; TV[n].m_pMeasCnv=&FCnv; TV[n].m_pMeasFmt=&FFmt; n++; N++; } } } ASSERT(N==NTearVariables()); return N; }; //=========================================================================== // // // //=========================================================================== void SQSzDist1::TearGetInputs(TearVarArray & TV, int n) { double TotMass=pModel->Mass(); for (int d=0; d<SD_Defn.NDistributions(); d++) if (DistExists(d)) { CSD_Distribution &D=Dist(d); for (int id=0; id<D.NPriIds(); id++) { double MF=pModel->VMass[D.SzId(id, 0)]/GTZ(TotMass); flag MFOK=MF>1.0e-8; for (int i=0; i<D.NIntervals(); i++) { TV[n].m_Y[0]=D.PriSp[id]->FracPass[i]; // DoBreak(); TV[n].m_bTestIsValid=MFOK; //TV[n].m_bHoldOutput=false;//!MFOK; n++; } } } }; //--------------------------------------------------------------------------- void SQSzDist1::TearGetOutputs(TearVarArray & TV, int n) { for (int d=0; d<SD_Defn.NDistributions(); d++) if (DistExists(d)) { CSD_Distribution &D=Dist(d); for (int id=0; id<D.NPriIds(); id++) for (int i=0; i<D.NIntervals(); i++) TV[n++].m_X[0]=D.PriSp[id]->FracPass[i]; } }; //--------------------------------------------------------------------------- void SQSzDist1::TearSetOutputs(TearVarArray & TV, int n) { for (int d=0; d<SD_Defn.NDistributions(); d++) if (DistExists(d)) { CSD_Distribution &D=Dist(d); for (int id=0; id<D.NPriIds(); id++) { for (int i=0; i<D.NIntervals(); i++) D.PriSp[id]->FracPass[i]=TV[n++].m_X[0]; //if (!TV[n].bHoldOutput) // { // D.PriSp[id]->FracPass[i]=TV[n].X[0]; // n++; // } D.PriSp[id]->FracPass.Normalise(); } } }; //--------------------------------------------------------------------------- void SQSzDist1::Dump() { for (int d=0; d<SD_Defn.NDistributions(); d++) if (DistExists(d)) { dbgpln("Dist%02i", d); CSD_Distribution &D=Dist(d); for (int id=0; id<D.NPriIds(); id++) { dbgp(" "); for (int i=0; i<D.NIntervals(); i++) dbgp(" %12.8f", D.PriSp[id]->FracPass[i]); dbgpln(""); } } }; //=========================================================================== // // // //=========================================================================== const int SQSzDist1Edt::XPix=10000; const int SQSzDist1Edt::YPix=10000; //const int SQSzDist1Edt::CrvPts=256; const int SQSzDist1Edt::CrvPts=(MaxIntervals+2)*2; int SQSzDist1Edt::iGraphWidth=40; int SQSzDist1Edt::iGraphHeight=15; int SQSzDist1Edt::iGraphOn=1; flag SQSzDist1Edt::fCrvStepped=true; //--------------------------------------------------------------------------- struct MappingSave { POINT VOrg; SIZE VExt; POINT WOrg; SIZE WExt; }; //--------------------------------------------------------------------------- static void PushScaling(rGDIBlk GB, RECT &GraphR, MappingSave &MapSv) { SetMapMode(GB.DC().m_hDC, MM_ANISOTROPIC); SetViewportOrgEx(GB.DC().m_hDC, GraphR.left, GraphR.top, &MapSv.VOrg); SetViewportExtEx(GB.DC().m_hDC, GraphR.right-GraphR.left, GraphR.bottom-GraphR.top, &MapSv.VExt); int XPixFrac=SQSzDist1Edt::XPix/40; int YPixFrac=SQSzDist1Edt::YPix/40; SetWindowOrgEx(GB.DC().m_hDC, -XPixFrac, SQSzDist1Edt::YPix+YPixFrac, &MapSv.WOrg); SetWindowExtEx(GB.DC().m_hDC, SQSzDist1Edt::XPix+2*XPixFrac, -(SQSzDist1Edt::YPix+2*YPixFrac), &MapSv.WExt); // SetWindowOrgEx(GB.DC().m_hDC, 0, SQSzDist1Edt::YPix, &MapSv.WOrg); // SetWindowExtEx(GB.DC().m_hDC, SQSzDist1Edt::XPix, -SQSzDist1Edt::YPix, &MapSv.WExt); } //--------------------------------------------------------------------------- static void PopScaling(rGDIBlk GB, MappingSave &MapSv) { SetMapMode(GB.DC().m_hDC, MM_TEXT); SetViewportOrgEx(GB.DC().m_hDC, MapSv.VOrg.x, MapSv.VOrg.y, NULL); SetViewportExtEx(GB.DC().m_hDC, MapSv.VExt.cx, MapSv.VExt.cy, NULL); SetWindowOrgEx(GB.DC().m_hDC, MapSv.WOrg.x, MapSv.WOrg.y, NULL); SetWindowExtEx(GB.DC().m_hDC, MapSv.WExt.cx, MapSv.WExt.cy, NULL); } //--------------------------------------------------------------------------- SQSzDist1Edt::SQSzDist1Edt(FxdEdtView * pView_, SQSzDist1 * pSD_) : FxdEdtBookRef(pView_), rSD(*pSD_) { iDragPtNo = -1; XMin=0.0; XMax=1.0; XFactor=1.0; iNameWidth=4; iWorkDist=0; iPg1=0; fXtraPg=0; pLabels = new CLabelWnd; pLabels->CreateIt(pView_); pLabels->SetFont(pView_->ScrGB.pFont[0]); pLabels->SetLineCnt(1/*2*/); // pWrkCnv=NULL; // pWrkFmt=NULL; ObjectAttribute *pAttr=ObjAttributes.FindObject("SqSzDist1Edt"); if (pAttr) { pAttr->FieldFmtCnvs("Size", SD_Defn.XFmt, SD_Defn.XCnv); pAttr->FieldFmtCnvs("Frac", SD_Defn.YFFmt, SD_Defn.YFCnv); pAttr->FieldFmtCnvs("Flow", SD_Defn.YQmFmt, SD_Defn.YQmCnv); pAttr->FieldFmtCnvs("Mass", SD_Defn.YMFmt, SD_Defn.YMCnv); pAttr->FieldFmtCnvs("PartFlow", SD_Defn.YQnFmt, SD_Defn.YQnCnv); pAttr->FieldFmtCnvs("PartCount", SD_Defn.YNFmt, SD_Defn.YNCnv); pAttr->FieldFmtCnvs("PartCountFrac", SD_Defn.YNFFmt, SD_Defn.YNFCnv); pAttr->FieldFmtCnvs("SpPartCount", SD_Defn.YNpMFmt, SD_Defn.YNpMCnv); pAttr->FieldFmtCnvs("TopBotSize", SD_Defn.TBFmt, SD_Defn.TBCnv); } CProfINIFile PF(PrjIniFile()); if (ValidDistribution()) { Strng s; for (int i=0; i<NColumns(); i++) if (Columns(i).Avail(Model())) { s=Columns(i).sFullName(); Columns(i).SetOn(PF.RdInt("SqSzDist1Edt", s(), Columns(i).On())); s+="_GrfOn"; Columns(i).SetGrfOn(PF.RdInt("SqSzDist1Edt", s(), Columns(i).GrfOn())); } } SQSzDist1Edt::iGraphWidth=PF.RdInt("SqSzDist1Edt", "GraphWidth", 40); SQSzDist1Edt::iGraphHeight=PF.RdInt("SqSzDist1Edt", "GraphHeight", 15); SQSzDist1Edt::iGraphOn=PF.RdInt("SqSzDist1Edt", "GraphOn", true); SQSzDist1Edt::fCrvStepped=PF.RdInt("SqSzDist1Edt", "CrvStepped", true); fSzAscend=PF.RdInt("SzDistribution", "IntervalsAscending", fSzAscend); } //--------------------------------------------------------------------------- SQSzDist1Edt::~SQSzDist1Edt() { CProfINIFile PF(PrjIniFile()); if (ValidDistribution()) { Strng s; for (int i=0; i<NColumns(); i++) if (Columns(i).Avail(Model())) { s=Columns(i).sFullName(); PF.WrInt("SqSzDist1Edt", s(), Columns(i).On()); s+="_GrfOn"; PF.WrInt("SqSzDist1Edt", s(), Columns(i).GrfOn()); } } PF.WrInt("SqSzDist1Edt", "GraphWidth", SQSzDist1Edt::iGraphWidth); PF.WrInt("SqSzDist1Edt", "GraphHeight", SQSzDist1Edt::iGraphHeight); PF.WrInt("SqSzDist1Edt", "GraphOn", SQSzDist1Edt::iGraphOn); PF.WrInt("SqSzDist1Edt", "CrvStepped", SQSzDist1Edt::fCrvStepped); PF.WrInt("SzDistribution", "IntervalsAscending", fSzAscend); ObjectAttribute *pAttr=ObjAttributes.FindObject("SqSzDist1Edt"); if (pAttr) { pAttr->SetFieldFmt("Size", SD_Defn.XFmt); pAttr->SetFieldCnvs("Size", SD_Defn.XCnv); pAttr->SetFieldFmt("Frac", SD_Defn.YFFmt); pAttr->SetFieldCnvs("Frac", SD_Defn.YFCnv); pAttr->SetFieldFmt("Flow", SD_Defn.YQmFmt); pAttr->SetFieldCnvs("Flow", SD_Defn.YQmCnv); pAttr->SetFieldFmt("Mass", SD_Defn.YMFmt); pAttr->SetFieldCnvs("Mass", SD_Defn.YMCnv); pAttr->SetFieldFmt("PartFlow", SD_Defn.YQnFmt); pAttr->SetFieldCnvs("PartFlow", SD_Defn.YQnCnv); pAttr->SetFieldFmt("PartCount", SD_Defn.YNFmt); pAttr->SetFieldCnvs("PartCount", SD_Defn.YNCnv); pAttr->SetFieldFmt("PartCountFrac", SD_Defn.YNFFmt); pAttr->SetFieldCnvs("PartCountFrac", SD_Defn.YNFCnv); pAttr->SetFieldFmt("SpPartCount", SD_Defn.YNpMFmt); pAttr->SetFieldCnvs("SpPartCount", SD_Defn.YNpMCnv); pAttr->SetFieldFmt("TopBotSize", SD_Defn.TBFmt); pAttr->SetFieldCnvs("TopBotSize", SD_Defn.TBCnv); } pLabels->DestroyWindow(); //cnmdelete pLabels; } //--------------------------------------------------------------------------- int SQSzDist1Edt::DistFromPgNo(int Pg) { //find one & only active distribution... int d=0; CSD_Distribution* pD = d<rSD.NDistributions() ? rSD.Distributions[d] : NULL; while (d<rSD.NDistributions() && pD==NULL) { d++; pD = d<rSD.NDistributions() ? rSD.Distributions[d] : NULL; } return (pD ? d : -1); /*for (int d=0; d<rSD.NDistributions(); d++) if (rSD.Distributions[d]) { if (Pg--==0) return d; } //DoBreak(); return -1;*/ } //--------------------------------------------------------------------------- void SQSzDist1Edt::PutDataStart() { } //--------------------------------------------------------------------------- void SQSzDist1Edt::PutDataDone() { } //--------------------------------------------------------------------------- void SQSzDist1Edt::GetDataStart() { } //--------------------------------------------------------------------------- void SQSzDist1Edt::GetDataDone() { } //--------------------------------------------------------------------------- void SQSzDist1Edt::StartBuild() { } //--------------------------------------------------------------------------- void SQSzDist1Edt::Build() { int d; Strng Tg; Strng S; fXtraPg=0; #if !MoveDistList /*for (d=0; d<rSD.NDistributions(); d++) if (!rSD.Distributions[d]) fXtraPg=1; // fXtraPg=1; if (fXtraPg) { int L=0; StartPage("Sizes"); StartBlk(rSD.NDistributions()+3, 0, NULL); SetDesc(L, "Distributions", -1, 14, 2, " "); L++; SetDesc(L, "-------------", -1, 14, 2, " "); L++; for (int d=0; d<rSD.NDistributions(); d++) //if (!rSD.Distributions[d]) { SetSpace(L, 3); if (rSD.Distributions[d]) //if (Dist(d)) { Tg.Set(SD_Defn.GetDist(d)->Name()); Tg+=" On>Off"; SetButton(L, Tg(), Id_DistOff+d, Max(12, Tg.Len()+2), 0, ""); } else { Tg.Set(SD_Defn.GetDist(d)->Name()); Tg+=" Off>On"; SetButton(L, Tg(), Id_DistOn+d, Max(12, Tg.Len()+2), 0, ""); } L++; } }*/ #endif //find one & only active distribution... d=0; CSD_Distribution* pD = d<rSD.NDistributions() ? rSD.Distributions[d] : NULL; while (d<rSD.NDistributions() && pD==NULL) { d++; pD = d<rSD.NDistributions() ? rSD.Distributions[d] : NULL; } //const int NColmns = rSD.NDistributions() ? NColumns() : 0; SpModel* p = (SpModel*)rSD.pModel; flag AsFlow = (rSD.pModel->UseAsFlow()); iPg1=pView->Pages; //StartPage(pD ? pD->Name() : "Sz", true); StartPage("Sz", true); if (1) // Header 1 Blk { StartBlk(1+rSD.NDistributions(), 0, NULL); int L=(pD && GraphOn()) ? 0 : 1; for (int d_=0; d_<rSD.NDistributions(); d_++) { CSD_Distribution* pD_ = rSD.Distributions[d_]; SetSpace(L, 3); if (pD_) { Tg.Set(SD_Defn.GetDist(d_)->Name()); Tg+=" On>Off"; SetButton(L, Tg(), Id_DistOff+d_, Max(12, Tg.Len()+2), 0, ""); } else { Tg.Set(SD_Defn.GetDist(d_)->Name()); Tg+=" Off>On"; SetButton(L, Tg(), Id_DistOn+d_, Max(12, Tg.Len()+2), 0, ""); } L++; } } if (pD) { SetWorkDist(d); } const int NColmns = pD ? NColumns() : 0; int ColWidth=10; for (int c=0; c<NColmns; c++) if (Columns(c).Reqd(Model())) ColWidth=Max(ColWidth, Columns(c).iColWidth); if (pD) { CSD_DistDefn &DDefn=pD->Defn(); //StartPage(DD().Name(), true);//(strlen(p)>0) ? p : "Fn"); if (1) // Header 2 Blk { int HedLen = (GraphOn() ? 5 : 3); #if WithSauterMeanD HedLen++; #endif StartBlk(HedLen, 0, NULL); int L=0; if (GraphOn()) { SetSpace(L, 1); SetParm(L, "", Id_XMin, 10, 2, ""); SetSpace(L, Max(2,GraphWidth()-20-2)); SetParm(L, "", Id_XMax, 10, 2, ""); SetSpace(L, 1); SetDesc(L, "Graph:", -1, 6, 2, " "); Strng Tg(GraphOn() ? " On > Off " : " Off > On "); SetButton(L, Tg(), Id_GrOn, 10, 0, ""); L++; SetSpace(L, 1); if (XLog()) SetButton(L,"Log > Lin", Id_XLog, 11, 0, ""); else SetButton(L,"Lin > Log", Id_XLog, 11, 0, ""); SetSpace(L, 1); if (AutoScale()) SetButton(L, "Auto > Fixed Scale", Id_AutoScale, 20, 0, ""); else SetButton(L, "Fixed > Auto Scale", Id_AutoScale, 20, 0, ""); SetSpace(L, 1); if (fCrvStepped) SetButton(L,"Stepped > Smooth", Id_PartStepped, 18, 0, " "); else SetButton(L,"Smooth > Stepped", Id_PartStepped, 18, 0, " "); SetSpace(L, 1); L++; } SetSpace(L, 1); L++; SetSpace(L, 1); SetDParm(L, "Show", 5, "", Id_CurShow, 25, 0, " "); int GotOne=0; for (int i=0; i<NColmns; i++) if (!Columns(i).On() && Columns(i).Avail(Model())) { FldHasFixedStrValue(i, Columns(i).DispName()); GotOne=1; } if (!GotOne) FldHasFixedStrValue(-1, " "); //L++; SetSpace(L, 1); SetDParm(L, "Hide", 5, "", Id_CurHide, 25, 0, ""); GotOne=0; for (i=0; i<NColmns; i++) if (Columns(i).On() && Columns(i).Avail(Model())) //if (Columns(i).Avail(Model())) { FldHasFixedStrValue(i, Columns(i).DispName()); GotOne=1; } if (!GotOne) FldHasFixedStrValue(-1, " "); #if WithSauterMeanD L++; SetSpace(L, 1); SetDParm(L, "SauterMeanD", 15, "", Id_RqdSauterl32, 32, 0, ""); #endif } flag DoneGap=false; flag DoneCumGap=false; const flag MultOre = (NColmns && !Columns(0).SimpleNames()); if (0) // Measurements Blk { int HedLen = (MultOre ? 2 : 1); StartBlk(DDefn.Measurements.GetSize()+HedLen, HedLen, NULL); int L=0; //... if (MultOre) { DoneGap=false; DoneCumGap=false; SetSpace(L, 4); for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneCumGap && !DoneGap) { DoneGap=true; SetSpace(L, 10+1); } if (Columns(c).ForCum() && !DoneCumGap) { DoneCumGap = true; SetSpace(L, 2+10+1); } S=Columns(c).sName(); S+=':'; S.SetLength(Min(S.Length(), ColWidth)); SetDesc(L, S(), -1, ColWidth, 1, ""); } } L++; } //... DoneGap=false; DoneCumGap=false; SetDesc(L, "Measurements", -1, 14, 0, " "); for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneCumGap && !DoneGap) { DoneGap=true; SetSpace(L, 1); } if (Columns(c).ForCum() && !DoneCumGap) { DoneCumGap = true; SetSpace(L, (DoneGap ? 2+10+1 : 2+1)); } S=(MultOre ? Columns(c).sSpName() : Columns(c).sName()); S.SetLength(Min(S.Length(), ColWidth)); SetDesc(L, S(), -1, ColWidth, 1, ""); } } L++; for (int iSz=0; iSz<DDefn.Measurements.GetSize(); iSz++) { DoneGap=false; DoneCumGap=false; CSD_Measurement &M=DDefn.Measurements[iSz]; SetDesc(L, M.m_sName(), -1, 14, 2, ""); if (M.m_eType!=eSDMT_Text) { for (ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneCumGap && !DoneGap) { DoneGap=true; SetSpace(L, 1); } if (Columns(c).ForCum() && !DoneCumGap) { DoneCumGap = true; if (DoneGap) { SetSpace(L, 1); SetDesc(L, M.Cnv.Text()/*SD_Defn.XCnv.Text()*/, 0, 12, 0, ""); } else SetSpace(L, 2+1); } SetParm(L, "", Id_dSize+iSz+c*MaxCSDMeasurements, ColWidth, 2, ""); Tg.Set("%s.%s.%s", FullObjTag(), M.m_sName(), Columns(c).sSpName()); SetTag(Tg(), M.Cnv.Text());//SD_Defn.XCnv.Text()); } } } SetSpace(L, 1); SetDesc(L, M.Cnv.Text()/*SD_Defn.XCnv.Text()*/, 0, 16, 0, ""); L++; } } if (1) // Data Blk { int L=0; int HedLen = 2; #ifdef USE_PSD_TB if (rSD.fAllowSizeEdits) { HedLen = 3; if (rSD.bAllowTestData) HedLen++; } #endif if (MultOre) HedLen++; if (rSD.pModel->UseAsFlow()) HedLen++; int BlkLen = D().NIntervals() + HedLen + 1; if (GraphOn()) BlkLen+=2; StartBlk(BlkLen, HedLen, NULL); L=0; if (MultOre && ColWidth>14) ColWidth=14; #ifdef USE_PSD_TB if (rSD.fAllowSizeEdits) { SetSpace(L, 1); SetDesc(L, "Test Data", -1, 10, 1, " "); SetCheckBox(L, "TstDat" , Id_TestDataChk , 2, 2 , "", true); L++; if (rSD.bAllowTestData) { SetSpace(L, 14); for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if ((Columns(c).Editable())&&(Columns(c).iSpId >=0)) { SetButton(L, "Set", Id_CopyTest+ci , ColWidth , 0, ""); } else { SetSpace(L, ColWidth); } } L++; } } #endif //heading... if (MultOre) { DoneGap=false; SetSpace(L, 4); for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneGap) { DoneGap=true; SetDesc(L, "Size", -1, 10, 1, " "); } if (!Columns(c).ForCum()) { S=Columns(c).sName(); S+=':'; S.SetLength(Min(S.Length(), ColWidth)); SetDesc(L, S(), -1, ColWidth, 1, ""); } } } L++; DoneGap=false; SetDesc(L, "Int", -1, 4, 1, ""); for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneGap) { DoneGap=true; SetDesc(L, "Range", -1, 10, 1, " "); } if (!Columns(c).ForCum()) { S=Columns(c).sSpName(); S.SetLength(Min(S.Length(), ColWidth)); SetDesc(L, S(), -1, ColWidth, 1, ""); } } } L++; } else { DoneGap=false; DoneCumGap=false; SetDesc(L, "Int", -1, 4, 1, ""); for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneCumGap && !DoneGap) { DoneGap=true; SetDesc(L, MultOre ? "Range" : "Size Range", -1, 10, 1, " "); } if (Columns(c).ForCum() && !DoneCumGap) { DoneCumGap = true; SetSpace(L, 2); S="Size"; S.SetLength(Min(S.Length(), 10)); SetDesc(L, S(), -1, 10, 1, " "); } S=(MultOre ? Columns(c).sSpName() : Columns(c).sName()); S.SetLength(Min(S.Length(), ColWidth)); SetDesc(L, S(), -1, ColWidth, 1, ""); } } L++; } if (rSD.pModel->UseAsFlow()) { //... if (MultOre) { DoneGap=false; S.Set("Qm Total(%s)", SD_Defn.YQmCnv.Text()); SetDesc(L, S(), -1, 14, 2, " "); for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneGap) DoneGap = true; if (!Columns(c).ForCum()) { if (Columns(c).iSpId>=0) { FxdEdtFld* fef = SetParm(L, "", Id_YQmTtl+c, ColWidth, 2, ""); Tg.Set("%s.QmTtl.%s", FullObjTag(), Columns(c).sSpName()); //pView->SetTag(Tg(), SD_Defn.YQmCnv.Text()); SetTag(Tg(), SD_Defn.YQmCnv.Text()); } else SetSpace(L, ColWidth); } } } SetSpace(L, 1); SetDesc(L, SD_Defn.YQmCnv.Text(), 0, 16, 0, ""); L++; } else { DoneGap=false; DoneCumGap=false; S.Set("Qm Total(%s)", SD_Defn.YQmCnv.Text()); SetDesc(L, S(), -1, 14, 2, " "); for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneCumGap && !DoneGap) DoneGap = true; if (Columns(c).ForCum() && !DoneCumGap) { DoneCumGap = true; if (DoneGap) { SetSpace(L, 1); SetDesc(L, SD_Defn.YQmCnv.Text(), 0, 12, 0, ""); //SetSpace(L, 2+10+1); } } if (Columns(c).iSpId>=0) { FxdEdtFld* fef = SetParm(L, "", Id_YQmTtl+c, ColWidth, 2, ""); Tg.Set("%s.QmTtl.%s", FullObjTag(), Columns(c).sSpName()); //pView->SetTag(Tg(), SD_Defn.YQmCnv.Text()); SetTag(Tg(), SD_Defn.YQmCnv.Text()); } else SetSpace(L, ColWidth); } } SetSpace(L, 1); SetDesc(L, SD_Defn.YQmCnv.Text(), 0, 16, 0, ""); L++; } } //.. if (MultOre) { DoneGap=false; SetSpace(L, 4); for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneGap) { DoneGap = true; SetDesc(L, SD_Defn.XCnv.Text(), -1, 10, 2, " "); } if (!Columns(c).ForCum()) { SetDesc(L, Columns(c).pCnv->Text(), -1, ColWidth, 2, ""); } } } } else { DoneGap=false; DoneCumGap=false; SetSpace(L, 4); for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneCumGap && !DoneGap) { DoneGap = true; SetDesc(L, SD_Defn.XCnv.Text(), -1, 10, 2, " "); } if (Columns(c).ForCum() && !DoneCumGap) { DoneCumGap = true; SetSpace(L, 2); SetDesc(L, SD_Defn.XCnv.Text(), -1, 10, 2, " "); } SetDesc(L, Columns(c).pCnv->Text(), -1, ColWidth, 2, ""); } } } //.. if (MultOre) { const int Intr = D().NIntervals(); int iSz=fSzAscend ? 0 : Intr-1; int inc=fSzAscend ? 1 : -1; for ( ; iSz>=0 && iSz<Intr; iSz+=inc) { L++; S.Set("I%i", iSz); SetDesc(L, S(), -1 , 4, 3, ""); DoneGap=false; for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneGap) { DoneGap = true; SetParm(L, "", Id_XIntRng, 10, 2, " "); Tg.Set("%s.%s.%s", FullObjTag(), S(), "SzRange"); SetTag(Tg(), SD_Defn.XCnv.Text()); } if (!Columns(c).ForCum()) { SetParm(L, "", Id_YData+c, ColWidth, 2, ""); Tg.Set("%s.%s.%s", FullObjTag(), S(), Columns(c).sFullName()); SetTag(Tg(), Columns(c).pCnv->Text()); } } } } if (GraphOn()) { //... L++; DoneGap=false; SetDesc(L, "Grf On", -1, 14, 1, " "); const int FirstPen=3; int iPen=FirstPen; for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneGap) DoneGap = true; if (!Columns(c).ForCum()) { //SetButton(L, Columns(c).GrfOn() ? " On>Off " : " Off>On ", Id_YGrfOn+c, ColWidth-2, 0, " "); SetButton(L, Columns(c).GrfOn() ? " On>Off " : " Off>On ", Id_YGrfOn+c, ColWidth, 0, ""); iPen++; } } } //... L++; DoneGap=false; SetDesc(L, "Disp_Max", -1, 14, 1, " "); for (ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneGap) DoneGap = true; if (!Columns(c).ForCum()) { SetParm(L, "", Id_YFMax+c, ColWidth, 2, ""); } } } } } else { const int Intr = D().NIntervals(); int iSz=fSzAscend ? 0 : Intr-1; int inc=fSzAscend ? 1 : -1; for ( ; iSz>=0 && iSz<Intr; iSz+=inc) { L++; S.Set("I%i", iSz); SetDesc(L, S(), -1 , 4, 3, ""); DoneGap=false; DoneCumGap=false; for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneCumGap && !DoneGap) { DoneGap = true; SetParm(L, "", Id_XIntRng, 10, 2, " "); Tg.Set("%s.%s.%s", FullObjTag(), S(), "SzRange"); SetTag(Tg(), SD_Defn.XCnv.Text()); } if (Columns(c).ForCum() && !DoneCumGap) { DoneCumGap = true; SetSpace(L, 2); SetParm(L, "", Id_XInt, 10, 2, " "); Tg.Set("%s.%s.%s", FullObjTag(), S(), "Size"); SetTag(Tg(), SD_Defn.XCnv.Text()); } SetParm(L, "", Id_YData+c, ColWidth, 2, ""); Tg.Set("%s.%s.%s", FullObjTag(), S(), Columns(c).sFullName()); SetTag(Tg(), Columns(c).pCnv->Text()); } } } if (GraphOn()) { //... L++; DoneGap=false; DoneCumGap=false; SetDesc(L, "Grf On", -1, 14, 1, " "); const int FirstPen=3; int iPen=FirstPen; for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneCumGap && !DoneGap) DoneGap = true; if (Columns(c).ForCum() && !DoneCumGap) { DoneCumGap = true; if (DoneGap) SetSpace(L, 2+10+1); } //SetButton(L, Columns(c).GrfOn() ? " On>Off " : " Off>On ", Id_YGrfOn+c, ColWidth-2, 0, " "); SetButton(L, Columns(c).GrfOn() ? " On>Off " : " Off>On ", Id_YGrfOn+c, ColWidth, 0, ""); iPen++; } } //... L++; DoneGap=false; DoneCumGap=false; SetDesc(L, "Disp_Max", -1, 14, 1, " "); for (ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneCumGap && !DoneGap) DoneGap = true; if (Columns(c).ForCum() && !DoneCumGap) { DoneCumGap = true; if (DoneGap) SetSpace(L, 2+10+1); } SetParm(L, "", Id_YFMax+c, ColWidth, 2, ""); } } } } } //Cumulative data... if (MultOre) if (1) // Cum Data Blk { int L=0; int HedLen = 3; if (rSD.pModel->UseAsFlow()) HedLen++; int BlkLen = D().NIntervals() + HedLen + 1; if (GraphOn()) BlkLen+=2; StartBlk(BlkLen, HedLen, NULL); L=0; if (MultOre) { //heading... DoneGap=false; SetSpace(L, 4); for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (Columns(c).ForCum() && !DoneGap) { DoneGap=true; SetDesc(L, "Size", -1, 10, 1, " "); } if (Columns(c).ForCum()) { S=Columns(c).sName(); S+=':'; S.SetLength(Min(S.Length(), ColWidth)); SetDesc(L, S(), -1, ColWidth, 1, ""); } } } L++; DoneGap=false; SetDesc(L, "Int", -1, 4, 1, ""); for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (Columns(c).ForCum() && !DoneGap) { DoneGap=true; SetDesc(L, "", -1, 10, 1, " "); } if (Columns(c).ForCum()) { S=Columns(c).sSpName(); S.SetLength(Min(S.Length(), ColWidth)); SetDesc(L, S(), -1, ColWidth, 1, ""); } } } L++; if (rSD.pModel->UseAsFlow()) { //... DoneGap=false; S.Set("Qm Total(%s)", SD_Defn.YQmCnv.Text()); SetDesc(L, S(), -1, 14, 2, " "); for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (Columns(c).ForCum() && !DoneGap) DoneGap = true; if (Columns(c).ForCum()) { if (Columns(c).iSpId>=0) { FxdEdtFld* fef = SetParm(L, "", Id_YQmTtl+c, ColWidth, 2, ""); Tg.Set("%s.QmTtl.%s", FullObjTag(), Columns(c).sSpName()); //pView->SetTag(Tg(), SD_Defn.YQmCnv.Text()); SetTag(Tg(), SD_Defn.YQmCnv.Text()); } else SetSpace(L, ColWidth); } } } SetSpace(L, 1); SetDesc(L, SD_Defn.YQmCnv.Text(), 0, 16, 0, ""); L++; } //.. DoneGap=false; SetSpace(L, 4); for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (Columns(c).ForCum() && !DoneGap) { DoneGap = true; SetDesc(L, SD_Defn.XCnv.Text(), -1, 10, 2, " "); } if (Columns(c).ForCum()) { SetDesc(L, Columns(c).pCnv->Text(), -1, ColWidth, 2, ""); } } } //.. const int Intr = D().NIntervals(); int iSz=fSzAscend ? 0 : Intr-1; int inc=fSzAscend ? 1 : -1; for ( ; iSz>=0 && iSz<Intr; iSz+=inc) { L++; S.Set("I%i", iSz); SetDesc(L, S(), -1 , 4, 3, ""); DoneGap=false; for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (Columns(c).ForCum() && !DoneGap) { DoneGap = true; SetParm(L, "", Id_XInt, 10, 2, " "); Tg.Set("%s.%s.%s", FullObjTag(), S(), "Size"); SetTag(Tg(), SD_Defn.XCnv.Text()); } if (Columns(c).ForCum()) { SetParm(L, "", Id_YData+c, ColWidth, 2, ""); Tg.Set("%s.%s.%s", FullObjTag(), S(), Columns(c).sFullName()); SetTag(Tg(), Columns(c).pCnv->Text()); } } } } if (GraphOn()) { //... L++; DoneGap=false; SetDesc(L, "Grf On", -1, 14, 1, " "); const int FirstPen=3; int iPen=FirstPen; for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (Columns(c).ForCum() && !DoneGap) DoneGap = true; if (Columns(c).ForCum()) { //SetButton(L, Columns(c).GrfOn() ? " On>Off " : " Off>On ", Id_YGrfOn+c, ColWidth-2, 0, " "); SetButton(L, Columns(c).GrfOn() ? " On>Off " : " Off>On ", Id_YGrfOn+c, ColWidth, 0, ""); iPen++; } } } //... L++; DoneGap=false; SetDesc(L, "Disp_Max", -1, 14, 1, " "); for (ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (Columns(c).ForCum() && !DoneGap) DoneGap = true; if (Columns(c).ForCum()) { SetParm(L, "", Id_YFMax+c, ColWidth, 2, ""); } } } } } } if (1) // Base Blk { StartBlk(6, 0, NULL); int L=0; SetDesc(L, "Size Intervals :", -1, 16, 2, " "); Strng SzTg(fSzAscend ? " > Descending " : " > Ascending "); SetButton(L, SzTg(), Id_SzAscend, 14, 0, ""); L++; SetDesc(L, "Graph:", -1, 6, 2, " "); Strng Tg(GraphOn() ? " On>Off " : " Off>On "); SetButton(L, Tg(), Id_GrOn, 10, 0, ""); if (GraphOn()) { SetSpace(L, 1); SetDParm(L, "Width", 6, "", Id_GrWidth, 2, 2, ""); SetSpace(L, 1); SetDParm(L, "Height", 7, "", Id_GrHeight, 2, 2, ""); } L++; SetDParm(L, "Top Size", 12, "", Id_TopSize, 12, 2, " "); Tg.Set("%s.%s", FullObjTag(), "TopSize"); SetTag(Tg(), SD_Defn.TBCnv.Text()); SetDesc(L, SD_Defn.TBCnv.Text(), -1, 10, 0, " "); L++; SetDParm(L, "Bottom Size", 12, "", Id_BotSize, 12, 2, " "); Tg.Set("%s.%s", FullObjTag(), "BottomSize"); SetTag(Tg(), SD_Defn.TBCnv.Text()); SetDesc(L, SD_Defn.TBCnv.Text(), -1, 10, 0, " "); L++; SetDParm(L, "Interval Count", 16, "", Id_IntervalCnt, 8, 0, " "); Tg.Set("%s.%s", FullObjTag(), "IntervalCnt"); SetTag(Tg()); L++; } } StartPage("MSz", true); if (pD) { CSD_DistDefn &DDefn=pD->Defn(); flag DoneGap=false; flag DoneCumGap=false; const flag MultOre = (NColmns && !Columns(0).SimpleNames()); if (1) // Measurements Blk { int HedLen = (MultOre ? 2 : 1); StartBlk(DDefn.Measurements.GetSize()+HedLen, HedLen, NULL); int L=0; //... if (MultOre) { DoneGap=false; DoneCumGap=false; SetSpace(L, 4); for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneCumGap && !DoneGap) { DoneGap=true; SetSpace(L, 10+1); } if (Columns(c).ForCum() && !DoneCumGap) { DoneCumGap = true; SetSpace(L, 2+10+1); } S=Columns(c).sName(); S+=':'; S.SetLength(Min(S.Length(), ColWidth)); SetDesc(L, S(), -1, ColWidth, 1, ""); } } L++; } //... DoneGap=false; DoneCumGap=false; SetDesc(L, "Measurements", -1, 14, 0, " "); for (int ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneCumGap && !DoneGap) { DoneGap=true; SetSpace(L, 1); } if (Columns(c).ForCum() && !DoneCumGap) { DoneCumGap = true; SetSpace(L, (DoneGap ? 2+10+1 : 2+1)); } S=(MultOre ? Columns(c).sSpName() : Columns(c).sName()); S.SetLength(Min(S.Length(), ColWidth)); SetDesc(L, S(), -1, ColWidth, 1, ""); } } L++; for (int iSz=0; iSz<DDefn.Measurements.GetSize(); iSz++) { DoneGap=false; DoneCumGap=false; CSD_Measurement &M=DDefn.Measurements[iSz]; SetDesc(L, M.m_sName(), -1, 14, 2, ""); if (M.m_eType!=eSDMT_Text) { for (ci=0; ci<NColmns; ci++) { int c=DDefn.DispColIndices[ci]; //dbgpln("BBB:%3i %3i %3i %-20s %-20s", iSz, ci, c, M.m_sName(), Columns(c).sSpName()); if (Columns(c).Reqd(Model())) { if (!Columns(c).ForCum() && !DoneCumGap && !DoneGap) { DoneGap=true; SetSpace(L, 1); } if (Columns(c).ForCum() && !DoneCumGap) { DoneCumGap = true; if (DoneGap) { SetSpace(L, 1); SetDesc(L, M.Cnv.Text()/*SD_Defn.XCnv.Text()*/, 0, 12, 0, ""); } else SetSpace(L, 2+1); } SetParm(L, "", Id_dSize+iSz+c*MaxCSDMeasurements, ColWidth, 2, ""); Tg.Set("%s.%s.%s", FullObjTag(), M.m_sName(), Columns(c).sSpName()); SetTag(Tg(), M.Cnv.Text());//SD_Defn.XCnv.Text()); } } } SetSpace(L, 1); SetDesc(L, M.Cnv.Text()/*SD_Defn.XCnv.Text()*/, 0, 16, 0, ""); L++; } } } #ifdef USE_PSD_TB // Build the EditView for the PSDTB Pages if (rSD.bAllowTestData) { rSD.m_PSDTB->SetIDOffsets( Id_Last , XID_Last ); rSD.m_PSDTB->Build(this); } #endif } //--------------------------------------------------------------------------- void SQSzDist1Edt::ChangeLayout(rFxdEdtPage Pg, int TotalRows, int TotalCols) { int d=DistFromPgNo(Pg.No-iPg1); if (GraphOn() && (d>=0))//(Pg.No-iPg1>=0)) { Pg.MoveRows(-32000); Pg.MoveRows(GraphHeight()); } } // -------------------------------------------------------------------------- char* SQSzDist1Edt::GetRangeLbl(int i, Strng& Str, flag Range) { if (Range) { if (fSzAscend) { if (i>=D().rIntervals.GetUpperBound()) { Strng S; SD_Defn.XFmt.FormatFloat(SD_Defn.XCnv.Human(D().rIntervals[i-1]), S); Str="+"; Str+=S; } else { Strng S; SD_Defn.XFmt.FormatFloat(SD_Defn.XCnv.Human(D().rIntervals[i]), S); Str="-"; Str+=S; } } else { if (i<D().rIntervals.GetUpperBound()) { i=D().rIntervals.GetUpperBound()-i; Strng S; SD_Defn.XFmt.FormatFloat(SD_Defn.XCnv.Human(D().rIntervals[i-1]), S); Str="+"; Str+=S; } else { Strng S; SD_Defn.XFmt.FormatFloat(SD_Defn.XCnv.Human(D().rIntervals[0]), S); Str="-"; Str+=S; } } } else { if (fSzAscend) { SD_Defn.XFmt.FormatFloat(SD_Defn.XCnv.Human(D().rIntervals[i]), Str); } else { i=D().rIntervals.GetUpperBound()-i; SD_Defn.XFmt.FormatFloat(SD_Defn.XCnv.Human(D().rIntervals[i]), Str); } } return Str(); } //--------------------------------------------------------------------------- inline double SQSzDist1Edt::GetYData(CSD_Column &C, int iInt) { return GetYData(C)[iInt]; } //--------------------------------------------------------------------------- inline CDArray & SQSzDist1Edt::GetYData(CSD_Column &C) { CSD_Distribution & D_ = D(); double x0 = D_.PriSp[0/*C.iSpId*/]->FracPass[0]; double x1 = D_.PriSp[0/*C.iSpId*/]->FracPass[1]; if (D().CalculateResults(&rSD.pModel->m_Ovr, rSD.pModel->MArray(),/*iWorkDist,*/ C.iDataId, C.iSpId)) return D().Results(); return *((CDArray*)NULL); } //--------------------------------------------------------------------------- void SQSzDist1Edt::SetYData(CSD_Column &C, int iInt, double Val) { switch (C.iDataId) { case DI_MFp: if (C.iSpId>=0) D().PriSp[C.iSpId]->FracPass[iInt]=Val; D().PriSp[C.iSpId]->FracPass.AdjustCumulativeEnd(1.0, 0.0, 1.0); break; #if UseExtraColumns case DI_NFp: D().SetCountFrac(&rSD.pModel->m_Ovr, rSD.pModel->MArray(), C.iSpId, iInt, Val);//, rSD.WorkSpace); break; case DI_NpM: D().SetSpCount(&rSD.pModel->m_Ovr, rSD.pModel->MArray(), C.iSpId, iInt, Val);//, rSD.WorkSpace); break; case DI_N : case DI_Qn: if (D().CalculateResults(&rSD.pModel->m_Ovr, rSD.pModel->MArray(),/*iWorkDist,*/ C.iDataId, C.iSpId)) { D().Results()[iInt]=Val; if (C.iSpId>=0) D().PriSp[C.iSpId]->FracPass[iInt]=Val; D().PriSp[C.iSpId]->FracPass.AdjustCumulativeEnd(1.0, 0.0, 1.0); } break; #endif } } //--------------------------------------------------------------------------- void SQSzDist1Edt::Load(FxdEdtInfo &EI, Strng & Str) { //dbgpln("...: %3i %3i %3i %3i %3i ", EI.BlkId, EI.BlkRowNo, EI.FieldId, EI.Index, EI.PageNo); if (CurrentBlk(EI)) {//header 1 int i=(int)(EI.BlkRowNo-EI.Index); } int d=DistFromPgNo(EI.PageNo-iPg1); if (d<0) { if (CurrentBlk(EI)) {//header 2 } } else { SetWorkDist(d); if (CurrentBlk(EI)) {//header 2 int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { case Id_XMin : { SD_Defn.XFmt.FormatFloat(SD_Defn.XCnv.Human(XDispMin()), Str); } break; case Id_XMax : { SD_Defn.XFmt.FormatFloat(SD_Defn.XCnv.Human(XDispMax()), Str); } break; case Id_CurShow: { for (int i=0; i<NColumns(); i++) if (!Columns(i).On() && Columns(i).Avail(Model())) { Str=Columns(i).DispName(); break; } break; } case Id_CurHide: { for (int i=0; i<NColumns(); i++) if (Columns(i).On() && Columns(i).Avail(Model())) { Str=Columns(i).DispName(); break; } break; } #if WithSauterMeanD case Id_RqdSauterl32: { //KGAFIX Str="Set"; break; } #endif } } // Measurements if (0)//CurrentBlk(EI)) { int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); if (EI.FieldId>=Id_dSize && EI.FieldId<Id_dSize+MaxCSDMeasurements*(1+NColumns())) { int c=(EI.FieldId-Id_dSize) / MaxCSDMeasurements; int i=(EI.FieldId-Id_dSize) % MaxCSDMeasurements; int s=Columns(c).iSpId; CSD_Measurement &M=SD_Defn.GetDist(d)->Measurements[i]; double Meas=dNAN; switch (M.m_eType) { case eSDMT_SizePassFrac: Meas=rSD.SizePassingFraction(d, s, M.m_dValue); break; case eSDMT_FracPassSize: Meas=rSD.FractionPassingSize(d, s, M.m_dValue); break; case eSDMT_SAM: Meas=rSD.SurfaceAreaPerGram(d, s); break; case eSDMT_SAL: Meas=rSD.SurfaceAreaPerLitre(d, s); break; case eSDMT_PPG: Meas=rSD.ParticleCountPerMass(d, s); break; } //SD_Defn.XFmt.FormatFloat(SD_Defn.XCnv.Human(Meas), Str); M.Fmt.FormatFloat(M.Cnv.Human(Meas), Str); EI.Fld->fEditable=false; } } if (CurrentBlk(EI)) {//data int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { #ifdef USE_PSD_TB case Id_TestDataChk: // Testing Str.Set("%i", rSD.bAllowTestData); break; #endif case Id_XIntRng: case Id_XInt: GetRangeLbl(i, Str, EI.FieldId==Id_XIntRng); EI.Fld->fEditable=false; break; default: if (EI.FieldId>=Id_YData && EI.FieldId<Id_YData+MaxColumns) { if (!fSzAscend) i = D().rIntervals.GetUpperBound()-i; const int c = EI.FieldId-Id_YData; CSD_Column &C = Columns(c); const double dd = GetYData(C, i); C.pFmt->FormatFloat(C.pCnv->Human(dd), Str); EI.Fld->fEditable = (C.Editable() && C.iSpId>=0 && rSD.fAllowSizeEdits); } else if (EI.FieldId>=Id_YQmTtl && EI.FieldId<Id_YQmTtl+NColumns()) { CSD_Column &C=Columns(EI.FieldId-Id_YQmTtl); SD_Defn.YQmFmt.FormatFloat(SD_Defn.YQmCnv.Human(D().GetMass(&rSD.pModel->m_Ovr, rSD.pModel->MArray(), C.iSpId)), Str); EI.Fld->fEditable = false; } else if (EI.FieldId>=Id_YMin && EI.FieldId<Id_YMin+NColumns()) { CSD_Column &C=Columns(EI.FieldId-Id_YMin); C.pFmt->FormatFloat(C.pCnv->Human(C.dDispMin), Str); } else if (EI.FieldId>=Id_YFMax && EI.FieldId<Id_YFMax+NColumns()) { CSD_Column &C=Columns(EI.FieldId-Id_YFMax); C.pFmt->FormatFloat(C.pCnv->Human(C.dFDispMax), Str); EI.Fld->fEditable = (!AutoScale()); } } } const flag MultOre = (NColumns() && !Columns(0).SimpleNames()); if (MultOre) if (CurrentBlk(EI)) {//cum data int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { case Id_XIntRng: case Id_XInt: GetRangeLbl(i, Str, EI.FieldId==Id_XIntRng); EI.Fld->fEditable=false; break; default: if (EI.FieldId>=Id_YData && EI.FieldId<Id_YData+MaxColumns) { if (!fSzAscend) i = D().rIntervals.GetUpperBound()-i; const int c = EI.FieldId-Id_YData; CSD_Column &C = Columns(c); const double dd = GetYData(C, i); C.pFmt->FormatFloat(C.pCnv->Human(dd), Str); EI.Fld->fEditable = (C.Editable() && C.iSpId>=0 && rSD.fAllowSizeEdits); } else if (EI.FieldId>=Id_YQmTtl && EI.FieldId<Id_YQmTtl+NColumns()) { CSD_Column &C=Columns(EI.FieldId-Id_YQmTtl); SD_Defn.YQmFmt.FormatFloat(SD_Defn.YQmCnv.Human(D().GetMass(&rSD.pModel->m_Ovr, rSD.pModel->MArray(), C.iSpId)), Str); EI.Fld->fEditable = false; } else if (EI.FieldId>=Id_YMin && EI.FieldId<Id_YMin+NColumns()) { CSD_Column &C=Columns(EI.FieldId-Id_YMin); C.pFmt->FormatFloat(C.pCnv->Human(C.dDispMin), Str); } else if (EI.FieldId>=Id_YFMax && EI.FieldId<Id_YFMax+NColumns()) { CSD_Column &C=Columns(EI.FieldId-Id_YFMax); C.pFmt->FormatFloat(C.pCnv->Human(C.dFDispMax), Str); EI.Fld->fEditable = (!AutoScale()); } } } if (CurrentBlk(EI)) {//other switch (EI.FieldId) { case Id_SzAscend: Str.Set("%i", fSzAscend); break; case Id_GrWidth: Str.Set("%i", iGraphWidth); break; case Id_GrHeight: Str.Set("%i", iGraphHeight); break; case Id_GrOn : Str.Set("%i", iGraphOn); break; case Id_TopSize : SD_Defn.TBFmt.FormatFloat(SD_Defn.TBCnv.Human(D().TopSize()), Str); EI.Fld->fEditable=false; break; case Id_BotSize : SD_Defn.TBFmt.FormatFloat(SD_Defn.TBCnv.Human(D().BottomSize()), Str); EI.Fld->fEditable=false; break; case Id_IntervalCnt : Str.Set("%i", D().NIntervals());//SD_Defn.GetDist(d)->NIntervals()); EI.Fld->fEditable=false; break; } } // Measurements if (1)//CurrentBlk(EI)) { int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); if (EI.FieldId>=Id_dSize && EI.FieldId<Id_dSize+MaxCSDMeasurements*(1+NColumns())) { int c=(EI.FieldId-Id_dSize) / MaxCSDMeasurements; int i=(EI.FieldId-Id_dSize) % MaxCSDMeasurements; int s=Columns(c).iSpId; //dbgpln("---: %3i %3i %3i ", c,i,s); const long NMeas=SD_Defn.GetDist(d)->Measurements.GetSize(); if (i<NMeas) { CSD_Measurement &M=SD_Defn.GetDist(d)->Measurements[i]; double Meas=dNAN; switch (M.m_eType) { case eSDMT_SizePassFrac: Meas=rSD.SizePassingFraction(d, s, M.m_dValue); break; case eSDMT_FracPassSize: Meas=rSD.FractionPassingSize(d, s, M.m_dValue); break; case eSDMT_SAM: Meas=rSD.SurfaceAreaPerGram(d, s); break; case eSDMT_SAL: Meas=rSD.SurfaceAreaPerLitre(d, s); break; case eSDMT_PPG: Meas=rSD.ParticleCountPerMass(d, s); break; } //SD_Defn.XFmt.FormatFloat(SD_Defn.XCnv.Human(Meas), Str); M.Fmt.FormatFloat(M.Cnv.Human(Meas), Str); } EI.Fld->fEditable=false; } } } #ifdef USE_PSD_TB // Load PSDBTB Data // if (CurrentBlk(EI)) // { //if (rSD.bAllowTestData) //{ rSD.m_PSDTB->SetIDOffsets( Id_Last , XID_Last ); rSD.m_PSDTB->Load(this,EI,Str); //} // } #endif } //--------------------------------------------------------------------------- long SQSzDist1Edt::Parse(FxdEdtInfo &EI, Strng & Str) { long Fix=0; //set Fix=1 to redraw graph if (CurrentBlk(EI)) {//header 1 int i=(int)(EI.BlkRowNo-EI.Index); } int d=DistFromPgNo(EI.PageNo-iPg1); if (d<0) { if (CurrentBlk(EI)) {//header 2 } } else { SetWorkDist(d); if (CurrentBlk(EI)) {//header 2 //bObjModified=1; int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { case Id_XMin : SetXDispMin(SD_Defn.XCnv.Normal(SafeAtoF(Str, 0.0))); View().DoReload(); break; case Id_XMax : SetXDispMax(SD_Defn.XCnv.Normal(SafeAtoF(Str, 1.0))); View().DoReload(); break; case Id_CurShow: case Id_CurHide: { for (int i=0; i<NColumns(); i++) if (Str.XStrICmp(Columns(i).DispName())==0) { Columns(i).SetOn(!Columns(i).On()); View().DoRebuild(); Fix=1; break; } break; } #if WithSauterMeanD case Id_RqdSauterl32: { // D().rIntervals.GetUpperBound()-i; // if (EI.FieldId>=Id_YData && EI.FieldId<Id_YData+NColumns()) // { // CSD_Column &C=Columns(EI.FieldId-Id_YData); // SetYData(C, i, C.pCnv->Normal(SafeAtoF(Str, 0.0))); //KGAFIX // this does not auto update on entry ??? double psd[1024]={0}; double *x=&D().rIntervals[0]; double l32=SafeAtoF(Str, dNAN); long lNInts=D().rIntervals.GetSize(); if (Valid(l32) && l32>0.0) { dist_sauter__(psd, l32, lNInts, x); number_to_mass__(psd, lNInts, x); for (int i=0; i<lNInts; i++) D().PriSp[0/*C.iSpId*/]->FracPass[i]=psd[i]; } //?? break; } #endif } } // Measurements if (0)//CurrentBlk(EI)) { } if (CurrentBlk(EI)) {//data int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { case Id_XIntRng : /*sprintf(Str, "%g", D().rIntervals[i]); */ break; case Id_XInt : /*sprintf(Str, "%g", D().rIntervals[i]); */ break; default: if (!fSzAscend) i=D().rIntervals.GetUpperBound()-i; if (EI.FieldId>=Id_YData && EI.FieldId<Id_YData+NColumns()) { const int c = EI.FieldId-Id_YData; CSD_Column &C=Columns(c); const double dd = C.pCnv->Normal(SafeAtoF(Str, 0.0)); SetYData(C, i, dd); View().DoReload(); } else if (EI.FieldId>=Id_YQmTtl && EI.FieldId<Id_YQmTtl+NColumns()) { //CSD_Column &C=Columns(EI.FieldId-Id_YQmTtl); //C.dFDispMax=C.pCnv->Normal(SafeAtoF(Str, 1.0)); //View().DoReload(); } else if (EI.FieldId>=Id_YMin && EI.FieldId<Id_YMin+NColumns()) { CSD_Column &C=Columns(EI.FieldId-Id_YMin); C.dDispMin=C.pCnv->Normal(SafeAtoF(Str, 0.0)); View().DoReload(); } else if (EI.FieldId>=Id_YFMax && EI.FieldId<Id_YFMax+NColumns()) { CSD_Column &C=Columns(EI.FieldId-Id_YFMax); C.dFDispMax=C.pCnv->Normal(SafeAtoF(Str, 1.0)); View().DoReload(); } } } const flag MultOre = (NColumns() && !Columns(0).SimpleNames()); if (MultOre) if (CurrentBlk(EI)) {//cum data int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { case Id_XIntRng : /*sprintf(Str, "%g", D().rIntervals[i]); */ break; case Id_XInt : /*sprintf(Str, "%g", D().rIntervals[i]); */ break; default: if (!fSzAscend) i=D().rIntervals.GetUpperBound()-i; if (EI.FieldId>=Id_YData && EI.FieldId<Id_YData+NColumns()) { const int c = EI.FieldId-Id_YData; CSD_Column &C=Columns(c); const double dd = C.pCnv->Normal(SafeAtoF(Str, 0.0)); SetYData(C, i, dd); View().DoReload(); } else if (EI.FieldId>=Id_YQmTtl && EI.FieldId<Id_YQmTtl+NColumns()) { //CSD_Column &C=Columns(EI.FieldId-Id_YQmTtl); //C.dFDispMax=C.pCnv->Normal(SafeAtoF(Str, 1.0)); //View().DoReload(); } else if (EI.FieldId>=Id_YMin && EI.FieldId<Id_YMin+NColumns()) { CSD_Column &C=Columns(EI.FieldId-Id_YMin); C.dDispMin=C.pCnv->Normal(SafeAtoF(Str, 0.0)); View().DoReload(); } else if (EI.FieldId>=Id_YFMax && EI.FieldId<Id_YFMax+NColumns()) { CSD_Column &C=Columns(EI.FieldId-Id_YFMax); C.dFDispMax=C.pCnv->Normal(SafeAtoF(Str, 1.0)); View().DoReload(); } } } if (CurrentBlk(EI)) {//other switch (EI.FieldId) { case Id_SzAscend: fSzAscend = Str.SafeAtoL()!=0; View().DoRebuild(); break; case Id_GrWidth: iGraphWidth = Range(10L, Str.SafeAtoL(), 60L); View().DoRebuild(); break; case Id_GrHeight: iGraphHeight = Range(5L, Str.SafeAtoL(), 30L); View().DoRebuild(); break; case Id_GrOn: iGraphOn= Range(0L, Str.SafeAtoL(), 1L); View().DoRebuild(); break; case Id_TopSize: break; case Id_BotSize: break; case Id_IntervalCnt: break; } } } #ifdef USE_PSD_TB // if (CurrentBlk(EI)) // {//PSD // Parse PSDBTB Data //if (rSD.bAllowTestData) // { rSD.m_PSDTB->SetIDOffsets( Id_Last , XID_Last ); rSD.m_PSDTB->Parse(this,EI,Str); // } // } #endif return Fix; } //--------------------------------------------------------------------------- long SQSzDist1Edt::ButtonPushed(FxdEdtInfo &EI, Strng & Str) { long Fix=0; //set Fix=1 to redraw graph if (CurrentBlk(EI)) {//header 1 int i=(int)(EI.BlkRowNo-EI.Index); if (EI.FieldId>=Id_DistOn && EI.FieldId<Id_DistOn+MaxDistributions) { int d=EI.FieldId-Id_DistOn; rSD.iDistUsed=d; if (!rSD.Distributions[d]) { ChangeToDist(d); View().DoRebuild(); } } if (EI.FieldId>=Id_DistOff && EI.FieldId<Id_DistOff+MaxDistributions) { int d=EI.FieldId-Id_DistOff; if (rSD.Distributions[d]) {//NOT ALLOWED!! //FreeDist(d); //View().DoRebuild(); } } } int d=DistFromPgNo(EI.PageNo-iPg1); #if !MoveDistList if (d<0) { if (CurrentBlk(EI)) {//header 2 /*if (EI.FieldId>=Id_DistOn && EI.FieldId<Id_DistOn+MaxDistributions) { int d=EI.FieldId-Id_DistOn; if (!rSD.Distributions[d]) { AllocDist(d); View().DoRebuild(); } } if (EI.FieldId>=Id_DistOff && EI.FieldId<Id_DistOff+MaxDistributions) { int d=EI.FieldId-Id_DistOff; if (rSD.Distributions[d]) { FreeDist(d); View().DoRebuild(); } }*/ } } else #endif { SetWorkDist(d); if (CurrentBlk(EI)) {//header 2 int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { case Id_DispRetained: SetDispRetained(!DispRetained()); View().DoRebuild(); Fix=1; break; case Id_AutoScale: SetAutoScale(!AutoScale()); SetRanges(); View().DoRebuild(); Fix=1; break; case Id_GrOn : iGraphOn=!iGraphOn; View().DoRebuild(); Fix=1; break; case Id_PartStepped: fCrvStepped = !fCrvStepped; SetRanges(); View().DoRebuild(); Fix=1; break; case Id_XLog: SetXLog(!XLog()); SetRanges(); View().DoRebuild(); Fix=1; break; } } // Measurements if (0)//CurrentBlk(EI)) { } if (CurrentBlk(EI)) {//data int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); #ifdef USE_PSD_TB if (EI.FieldId>=Id_CopyTest && EI.FieldId<Id_CopyTest+MaxColumns) { // Button Pressed to generated data from test PSD data int offset = EI.FieldId - Id_CopyTest; int count = 0; for (int i=0; i<NColumns(); i++) { if (Columns(i).Editable()&&(Columns(i).iSpId>=0)) { if ( i == offset ) { // // Set Button was pressed for this column // so xfer the data from the PSD tab page // // Get the Size Intervals CSD_Intervals Ints = D().rIntervals; // Number of Size Intervals int NInts = D().rIntervals.GetSize(); double ypassi = 0.0; // Fraction Passing at Size Interval i double ypassim1 = 0.0; // Fraction Passing at Size Interval i-1 double yret = 0.0; // Fraction Retained at Size Inreval i-1 double x = 0.0; // Size Interval size for ( int lint = 0 ; lint < NInts ; lint++ ) { x = D().rIntervals[lint]; // Calculate passing value based on test data entered on // PSD tab page for this size //ypassi = rSD.m_PSDTB->m_PSDTestData[count].PercentPassingRR(x); ypassi = rSD.m_PSDTB->m_PSDTestData[count].PercentPassing(x); // Calculate the equivalent retained data yret = ypassi - ypassim1; ypassim1 = ypassi; // Set the columns retained data CSD_Column &lCol = Columns(i); SetYData( lCol , lint , max(0.0,yret) ); } } count++; } } View().DoRebuild(); } if (EI.FieldId==Id_TestDataChk) { rSD.bAllowTestData=!rSD.bAllowTestData; //View().DoRebuild(); Fix=1; } #endif if (EI.FieldId>=Id_YGrfOn && EI.FieldId<Id_YGrfOn+NColumns()) { CSD_Column &C=Columns(EI.FieldId-Id_YGrfOn); C.SetGrfOn(!C.GrfOn()); //View().DoReload(); View().DoRebuild(); Fix=1; } } const flag MultOre = (NColumns() && !Columns(0).SimpleNames()); if (MultOre) if (CurrentBlk(EI)) {//data cum int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); if (EI.FieldId>=Id_YGrfOn && EI.FieldId<Id_YGrfOn+NColumns()) { CSD_Column &C=Columns(EI.FieldId-Id_YGrfOn); C.SetGrfOn(!C.GrfOn()); //View().DoReload(); View().DoRebuild(); Fix=1; } } // Base Blk if (CurrentBlk(EI)) { int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { case Id_SzAscend: fSzAscend=!fSzAscend; View().DoRebuild(); Fix=1; break; case Id_GrOn : iGraphOn=!iGraphOn; View().DoRebuild(); Fix=1; break; } } } return Fix; } //--------------------------------------------------------------------------- void SQSzDist1Edt::SetRanges() { const int len = Length(); const flag IsXLog = XLog(); const flag IsYLog = YLog(); if (AutoScale()) { if (len==0) { SetXDispMin(0.01); SetXDispMax(1.0); for (int c=0; c<NColumns(); c++) { SetYDispMin(c, 0.01); // SetYCDispMax(c, 1.0); SetYFDispMax(c, 1.0); } } else { SetXDispMin(Max(D().rIntervals.ScanMin(), DD().dBottomSizeDisp)); SetXDispMax(Min(D().rIntervals.ScanMax(), DD().dTopSizeDisp)); if (IsXLog) { SetXDispMin(XDispMin()*0.5); SetXDispMax(XDispMax()*1.1); } else { double xBorder = (XDispMax()-XDispMin())/40.0; SetXDispMin(XDispMin()-xBorder); SetXDispMax(XDispMax()+xBorder); } } } SetXDispMax(Max(XDispMax(), XDispMin()+1.0e-6)); if (IsXLog) {//set ranges to nearest decade SetXDispMin(Max(XDispMin(), MinLogVal)); SetXDispMin(pow(10.0, floor(Log10(XDispMin())))); SetXDispMax(pow(10.0, ceil(Log10(XDispMax())))); } if (AutoScale() && len>0) { for (int c=0; c<NColumns(); c++) if (Columns(c).Reqd(Model())) { SetYDispMin(c, 0.0); SetYFDispMax(c, GetYData(c).ScanMax()); } } for (int c=0; c<NColumns(); c++) if (Columns(c).Reqd(Model())) { SetYFDispMax(c, Max(YFDispMax(c), YDispMin(c)+1.0e-6)); if (IsYLog) { SetYDispMin(c, Max(YDispMin(c), MinLogVal)); SetYDispMin(c, pow(10.0, floor(Log10(YDispMin(c))))); SetYFDispMax(c, pow(10.0, ceil(Log10(YFDispMax(c))))); } } } //--------------------------------------------------------------------------- void SQSzDist1Edt::OnDrawBack(rGDIBlk GB,int PgNo, CRgn &ClipRgn) { ASSERT(pView->CPgNo==PgNo); if (GraphOn() && (pView->CPgNo-iPg1>=0) && ValidDistribution() && DistFromPgNo(pView->CPgNo-iPg1)>=0) { SetWorkDist(DistFromPgNo(pView->CPgNo-iPg1)); CDC &DC = GB.DC(); CDCResChk ResChk(DC); SetPosition(GB); flag DoGraph = DC.RectVisible(&GraphR); CGdiObject* OldBrush = (CGdiObject*)DC.SelectObject(GB.pBrushGrfBack); if (DoGraph) {//draw the curve... int Err = ExtSelectClipRgn(DC.m_hDC, (HRGN)ClipRgn.m_hObject, RGN_AND); COLORREF OldBkColor = DC.SetBkColor(GB.crGrfBack); CPen* OldPen = DC.SelectObject(GB.pPenTxtBord); Err = ExtSelectClipRgn(DC.m_hDC, (HRGN)ClipRgn.m_hObject, RGN_AND); DC.DrawEdge(&GraphR, EDGE_SUNKEN, BF_RECT); int EdgeX=GetSystemMetrics(SM_CXEDGE); int EdgeY=GetSystemMetrics(SM_CYEDGE); GraphR.InflateRect(-EdgeX*2, -EdgeY*2); DC.Rectangle(&GraphR); MappingSave MapSv; PushScaling(GB, GraphR, MapSv); CRgn ClipRgnGrf; CRgn CombinedRgn; ClipRgnGrf.CreateRectRgnIndirect(&GraphR); // Err = ExtSelectClipRgn(DC.m_hDC, (HRGN)ClipRgnGrf.m_hObject, RGN_AND); CPoint Org = DC.GetWindowOrg(); CSize Ext = DC.GetWindowExt(); const int len = Length(); const flag IsXLog = XLog(); const flag IsYLog = YLog(); // SetRanges(); // //get normalised values... if (IsXLog) { XMin = Log10(XDispMin()); XMax = Log10(XDispMax()); } else { XMin = XDispMin(); XMax = XDispMax(); } const double dX = GTZ(XMax-XMin); XFactor = XPix/dX; YMin.SetSize(NColumns()); YFMax.SetSize(NColumns()); YFFactor.SetSize(NColumns()); for (int c=0; c<NColumns(); c++) { YMin[c] = YDispMin(c); YFMax[c] = YFDispMax(c); const double dFY = GTZ(YFMax[c]-YMin[c]); YFFactor[c] = YPix/dFY; } //draw axis... ::SelectObject(DC.m_hDC, GB.hLinePenDim[0]); int x1,y1; if (!IsXLog) { x1 = (int)Range((double)-INT_MAX, (0.0-XMin)*XFactor, (double)INT_MAX); DC.MoveTo(x1,Org.y); DC.LineTo(x1,Org.y+Ext.cy); } if (!IsYLog) { for (int c=0; c<NColumns(); c++) { // Fix This ??? Make Axes Coincide y1 = (int)Range((double)-INT_MAX, (0.0-YMin[c])*YFFactor[c], (double)INT_MAX); DC.MoveTo(Org.x,y1); DC.LineTo(Org.x+Ext.cx,y1); } } //draw X log decades... if (IsXLog) { int Decades = (int)(Log10(XDispMax()) - Log10(XDispMin())); double Xv = XDispMin(); for (int j=0; j<Decades; j++) { ::SelectObject(DC.m_hDC, GB.hLinePenDim[1]); for (int i=1; i<10; i++) { x1 = (int)Range((double)-INT_MAX, (Log10(Xv*i)-XMin)*XFactor, (double)INT_MAX); DC.MoveTo(x1,Org.y); DC.LineTo(x1,Org.y+Ext.cy); if (i==1) ::SelectObject(DC.m_hDC, GB.hLinePenDim[0]); if (Decades>4) i++; } Xv *= 10.0; } } ::SelectObject(DC.m_hDC, GB.hLinePen[0]); CDArray & Xs=GetXData(); const int dCrossX = XPix/150; const int dCrossY = YPix/150; const int FirstPen=3; if (0 && (len>0)) { //draw crosses at each point... int iPen=FirstPen; for (int c=0; c<NColumns(); c++) if (Columns(c).Reqd(Model())) { ::SelectObject(DC.m_hDC, GB.hLinePen[iPen++]); double YSum=0.0; for (int j=0; j<len; j++) { CDArray &Ys=GetYData(Columns(c)); x1 = IsXLog ? CalcXLogPix(Xs[j]) : CalcXPix(Xs[j]); y1 = IsYLog ? CalcYFLogPix(c, Ys[j]) : CalcYFPix(c, Ys[j]); DC.MoveTo(x1-dCrossX,y1-dCrossY); DC.LineTo(x1+dCrossX,y1+dCrossY); DC.MoveTo(x1-dCrossX,y1+dCrossY); DC.LineTo(x1+dCrossX,y1-dCrossY); YSum+=Ys[j]; } } } //draw the curves... int iPen=FirstPen; int XYLen=Xs.GetSize(); for (c=0; c<NColumns(); c++) if (Columns(c).Reqd(Model())) { if (Columns(c).GrfOn()) { ::SelectObject(DC.m_hDC, GB.hLinePen[iPen]); CDArray &Ys=GetYData(Columns(c)); POINT XY[CrvPts]; XYLen=0; for (int j=0; j<Xs.GetSize()-1; j++) { const double xval = Xs[j]; if (XYLen<CrvPts-2)//too many points?!? { if (xval>DD().dBottomSizeDisp && xval<DD().dTopSizeDisp) {//only add points in display range int x=IsXLog ? CalcXLogPix(xval) : CalcXPix(xval); int y=IsYLog ? CalcYFLogPix(c, Ys[j]) : CalcYFPix(c, Ys[j]); if (fCrvStepped) { if (XYLen>0) XY[XYLen].x = XY[XYLen-1].x; else XY[XYLen].x = IsXLog ? CalcXLogPix(DD().dBottomSizeDisp) : CalcXPix(DD().dBottomSizeDisp);//-XPix; XY[XYLen].y = y;//XY[XYLen-1].y; XYLen++; } XY[XYLen].x = x; XY[XYLen].y = y; XYLen++; } } } XY[XYLen].x = IsXLog ? CalcXLogPix(DD().dTopSizeDisp) : CalcXPix(DD().dTopSizeDisp); XY[XYLen].y = XY[XYLen-1].y; XYLen++; DC.Polyline(XY, XYLen); } iPen++; } // Restore State PopScaling(GB, MapSv); DC.SelectObject(OldPen); DC.SetBkColor(OldBkColor); DC.SelectClipRgn(NULL); } DC.SelectObject(OldBrush); } } //--------------------------------------------------------------------------- void SQSzDist1Edt::SetPosition(rGDIBlk GB) { int CW = GB.ColWdt(); int RH = GB.RowHgt(); GraphR = GB.LuDataRect(); GraphR.top -= 1; GraphR.right = GraphR.left+GraphWidth()*CW; GraphR.bottom = GraphR.top+GraphHeight()*RH; GraphR.top+=View().CPg->FixedRows*RH; GraphR.bottom+=View().CPg->FixedRows*RH; int EdgeX=GetSystemMetrics(SM_CXEDGE); int EdgeY=GetSystemMetrics(SM_CYEDGE); GraphR.InflateRect(-EdgeX*2, -EdgeY*2); //iNameWidth = Max(rSD.XNameLen(), rSD.YNameLen()); pLabels->SetPosition(GraphR.left, GraphR.bottom+1, iNameWidth + 18); } //--------------------------------------------------------------------------- void SQSzDist1Edt::PointtoLP(POINT &Pt) { CDC* pDC = &(View().ScrGB.DC()); CDCResChk ResChk(pDC); MappingSave MapSv; PushScaling(View().ScrGB, GraphR, MapSv); pDC->DPtoLP(&Pt); PopScaling(View().ScrGB, MapSv); } //--------------------------------------------------------------------------- void SQSzDist1Edt::PointtoWP(POINT Pt, double& x, double& y) { rGDIBlk rGB = View().ScrGB; CDC& rDC = rGB.DC(); CDCResChk ResChk(rDC); MappingSave MapSv; PushScaling(View().ScrGB, GraphR, MapSv); rDC.DPtoLP(&Pt); PopScaling(View().ScrGB, MapSv); if (XLog()) x = CalcXLogVal(Pt.x); else x = CalcXVal(Pt.x); } //--------------------------------------------------------------------------- int SQSzDist1Edt::ClosestPt(CPoint point) { double x,y; PointtoWP(point, x, y); int PtNo = -1; double dist = DBL_MAX; return PtNo; } //--------------------------------------------------------------------------- void SQSzDist1Edt::ToggleDigCursor(POINT &Pt) { CClientDC dc(&Wnd(pView)); CDCResChk ResChk(dc); MappingSave MapSv; PushScaling(View().ScrGB, GraphR, MapSv); CPen APen(PS_SOLID,1,RGB(0xFF, 0xFF, 0xFF));//dc.GetNearestColor(Doc().DigColour)); CGdiObject* OldPen=(CGdiObject*)dc.SelectObject(&APen); int OldMode=dc.SetROP2(R2_XORPEN); dc.MoveTo(Pt.x,0); dc.LineTo(Pt.x,YPix); dc.MoveTo(0, Pt.y); dc.LineTo(XPix, Pt.y); dc.SetROP2(OldMode); PopScaling(View().ScrGB, MapSv); } //--------------------------------------------------------------------------- flag SQSzDist1Edt::DoLButtonDown(UINT nFlags, CPoint point) { if (pView->CPgNo-iPg1>=0 && ValidDistribution() && PtInRect(&GraphR, point)) { if (nFlags & MK_SHIFT) iDragPtNo = ClosestPt(point); return 1; } return 0; } //--------------------------------------------------------------------------- flag SQSzDist1Edt::DoLButtonUp(UINT nFlags, CPoint point) { if (pView->CPgNo-iPg1>=0 && ValidDistribution() && PtInRect(&GraphR, point)) { if (iDragPtNo>=0) { View().DoReload(); iDragPtNo = -1; } return 1; } return 0; } //--------------------------------------------------------------------------- flag SQSzDist1Edt::DoLButtonDblClk(UINT nFlags, CPoint point) { if (pView->CPgNo-iPg1>=0 && PtInRect(&GraphR, point)) { return 1; } return 0; } //--------------------------------------------------------------------------- flag SQSzDist1Edt::DoRButtonDown(UINT nFlags, CPoint point) { if (pView->CPgNo-iPg1>=0 && PtInRect(&GraphR, point)) { return 1; } return 0; } //--------------------------------------------------------------------------- flag SQSzDist1Edt::DoRButtonUp(UINT nFlags, CPoint point) { if (pView->CPgNo-iPg1>=0 && ValidDistribution() && PtInRect(&GraphR, point)) { return 1; } FxdEdtView &Vw=View(); flag ret=false;//FxdEdtView::DoRButtonUp(nFlags, point); if (Vw.CPgNo>=0) { FxdEdtInfo EI; if (Vw.LocateFromCR((int)Vw.ChEditPos.x, (int)Vw.ChEditPos.y, EI)) { ret=true; //if (EI.FieldId<0 && EI.Fld) if (EI.Fld) { int nCols=(ValidDistribution() ? NColumns() : 0); if (EI.FieldId>=0) /* if (EI.FieldId==Id_XInt || EI.FieldId==Id_XIntRng || EI.FieldId==Id_XMin || EI.FieldId==Id_XMax || EI.FieldId==Id_TopSize || EI.FieldId==Id_BotSize || EI.FieldId>=Id_dSize && EI.FieldId<Id_dSize+MaxCSDMeasurements*MaxColumns|| EI.FieldId>=Id_YMin && EI.FieldId<Id_YMin+nCols || // EI.FieldId>=Id_YCMax && EI.FieldId<Id_YCMax+nCols || EI.FieldId>=Id_YFMax && EI.FieldId<Id_YFMax+nCols || EI.FieldId>=Id_YQmTtl && EI.FieldId<Id_YQmTtl+nCols || EI.FieldId>=Id_YData && EI.FieldId<Id_YData+nCols)*/ { CRect WRect; Vw.GetWindowRect(&WRect); CPoint RBPoint; RBPoint.x = WRect.left+point.x; RBPoint.y = WRect.top+point.y; if (EI.FieldId==Id_XInt || EI.FieldId==Id_XIntRng || EI.FieldId==Id_XMin || EI.FieldId==Id_XMax) { WrkIB.Set(EI.Fld->Tag, &SD_Defn.XCnv, &SD_Defn.XFmt); } else if (EI.FieldId>=Id_dSize && EI.FieldId<Id_dSize+MaxCSDMeasurements*(1+NColumns())) { int d=DistFromPgNo(EI.PageNo-iPg1); int c=(EI.FieldId-Id_dSize) / MaxCSDMeasurements; int i=(EI.FieldId-Id_dSize) % MaxCSDMeasurements; const long NMeas=SD_Defn.GetDist(d)->Measurements.GetSize(); if (i<NMeas) { CSD_Measurement &M=SD_Defn.GetDist(d)->Measurements[i]; WrkIB.Set(EI.Fld->Tag, &M.Cnv, &M.Fmt); } else return(ret); } else if (EI.FieldId==Id_TopSize || EI.FieldId==Id_BotSize) { WrkIB.Set(EI.Fld->Tag, &SD_Defn.TBCnv, &SD_Defn.TBFmt); } else if (EI.FieldId>=Id_YQmTtl && EI.FieldId<Id_YQmTtl+nCols) { WrkIB.Set(EI.Fld->Tag, &SD_Defn.YQmCnv, &SD_Defn.YQmFmt); } #ifdef USE_PSD_TB else if (EI.FieldId >= Id_TestDataChk && EI.FieldId <= Id_Last) { int c=(EI.FieldId-Id_YMin)%MaxColumns; CSD_Column &C=Columns(c); WrkIB.Set(EI.Fld->Tag, C.pCnv, C.pFmt); } else { // Must be a right click on the PSD data page // // Need to get Format to use for PSD Tab Data static CnvAttribute lcnv; static FmtAttribute fmt; CnvAttribute* cnvref = &lcnv; cnvref = rSD.m_PSDTB->GetCnv( EI.FieldId ); if (cnvref) WrkIB.Set(EI.Fld->Tag, cnvref , &fmt ); else WrkIB.Set(EI.Fld->Tag, &lcnv , &fmt ); /*Need more work here on conversions and formats*/ //WrkIB.Set(EI.Fld->Tag, &SD_Defn.XCnv, &SD_Defn.XFmt); #else else { return(ret); #endif } CMenu Menu; Menu.CreatePopupMenu(); CMenu FormatMenu; FormatMenu.CreatePopupMenu(); WrkIB.Fmt().AddToMenu(FormatMenu); CMenu CnvMenu; CnvMenu.CreatePopupMenu(); WrkIB.Cnv().AddToMenu(CnvMenu); Menu.AppendMenu(MF_POPUP, (unsigned int)CnvMenu.m_hMenu, "&Conversions"); if (WrkIB.Cnv().Index()<=0)// || !IsFloatData(d.iType)) Menu.EnableMenuItem(0, MF_BYPOSITION|MF_GRAYED); Menu.AppendMenu(MF_POPUP, (unsigned int)FormatMenu.m_hMenu, "&Format"); Menu.AppendMenu(MF_STRING, pView->iSendToTrend, "Send To &Trend"); Menu.AppendMenu(MF_STRING, pView->iSendToQuickView, "Send To &QuickView"); Menu.AppendMenu(MF_STRING|MF_GRAYED, pView->iSendToQuickView, "Send To &Custom"); // rAccNdData d=f(); // RptTagListsBlk * QB = new QuickViewBlk(ObjClassId(), d.sRefTag(), &d.Cnv, &d.Fmt); // ScdMainWnd()->PostMessage(WMU_ADDTOQUICKVIEW, 0, (long)(QB)); Menu.AppendMenu(MF_SEPARATOR); Menu.AppendMenu(MF_STRING, pView->iCmdCopyTag, "Copy Full &Tag"); if (EI.Fld->Tag==NULL) Menu.EnableMenuItem(pView->iCmdCopyTag, MF_BYCOMMAND|MF_GRAYED); Menu.AppendMenu(MF_STRING, pView->iCmdCopyVal, "Copy &Value"); Menu.TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON, RBPoint.x, RBPoint.y, /*(CWnd*)*/&View()); Menu.DestroyMenu(); } } } } return ret; } //--------------------------------------------------------------------------- flag SQSzDist1Edt::DoRButtonDblClk(UINT nFlags, CPoint point) { if (pView->CPgNo-iPg1>=0 && PtInRect(&GraphR, point)) { return 1; } return 0; } //--------------------------------------------------------------------------- flag SQSzDist1Edt::DoMouseMove(UINT nFlags, CPoint point) { if (GraphOn() && pView->CPgNo-iPg1>=0 && ValidDistribution() && PtInRect(&GraphR, point)) { double x,y; PointtoWP(point, x, y); char Buff[256], Buff2[256]; iNameWidth=4; SD_Defn.XFmt.FormatFloat(SD_Defn.XCnv.Human(x), Buff2, sizeof(Buff2)); sprintf(Buff, "%*s:%s", iNameWidth, "Size", Buff2); pLabels->SetText(0, Buff); pLabels->Show(); pLabels->Invalidate(); if (nFlags & MK_LBUTTON) { if (nFlags & MK_SHIFT) { if (iDragPtNo>=0) { } } else iDragPtNo = -1; Wnd(pView).InvalidateRect(&GraphR); } return 1; } else { pLabels->Hide(); } return 0; } //--------------------------------------------------------------------------- flag SQSzDist1Edt::DoAccCnv(UINT Id) { pCDataCnv pC=Cnvs[WrkIB.Cnv().Index()]; for (int i=Id; i>0; i--) pC=pC->Next(); if (pC) { WrkIB.Cnv().SetText(pC->Txt()); } View().DoRebuild(); return true; } //--------------------------------------------------------------------------- flag SQSzDist1Edt::DoAccFmt(UINT Id) { for (UINT i=0; i<(UINT)DefinedFmts.GetSize(); i++) if (i==Id) break; if (i<(UINT)DefinedFmts.GetSize()) { WrkIB.Fmt()=DefinedFmts[i]; View().DoRebuild(); } return true; } //--------------------------------------------------------------------------- flag SQSzDist1Edt::DoAccRptTagLists() { return FxdEdtBookRef::DoAccRptTagLists(); //TagInfoBlk * IB = new TagInfoBlk(WrkIB.ObjClassId(), WrkIB.RefTag(), // WrkIB.CnvOK() ? &WrkIB.Cnv() : NULL, // WrkIB.FmtOK() ? &WrkIB.Fmt() : NULL); //ScdMainWnd()->PostMessage(WMU_ADDTOQUICKVIEW, 0, (long)(IB)); // //return true; }; //=========================================================================== // // // //=========================================================================== IMPLEMENT_SPARES(SzPartCrv1, 200); IMPLEMENT_TAGOBJEDT(SzPartCrv1, "SpPartition", "SzPart", "", "SZP", TOC_ALL|TOC_GRP_SIZEDST|TOC_SIZEDIST, SzPartCrv1Edt, "Size Partition Curve", "Size Partition Curve"); SzPartCrv1::SzPartCrv1(pTagObjClass pClass_, pchar Tag_, pTaggedObject pAttach, TagObjAttachment eAttach) : TaggedObject(pClass_, Tag_, pAttach, eAttach)//, { CommonConstruct(); } // -------------------------------------------------------------------------- SzPartCrv1::SzPartCrv1(pchar Tag_, pTaggedObject pAttach, TagObjAttachment eAttach) : TaggedObject(&SzPartCrv1Class, Tag_, pAttach, eAttach)//, { CommonConstruct(); } // -------------------------------------------------------------------------- void SzPartCrv1::CommonConstruct() { fPartStepped=true; fFracViewActive=true; iApplyToDist=-1; dBottomSize=1.0e-8; dBottomSizeDisp=1.0e-8; dTopSize=10.0; dTopSizeDisp=10.0; SetSizeDefn(0); sPCStateStrings[PC_On]="On"; sPCStateStrings[PC_Off]="Off"; sPCModeStrings[PC_Frac2Fine]="Fine", sPCModeStrings[PC_Frac2Coarse]="Coarse", fPCMode_Shown=true; fPCState_Shown=false; fPCGraph_Shown=true; //fPCCumOrFrac_Shown=true; fPCCumShown=false; fPCSizeRangeRows=true; iRngWidth=8; iCrvCount=0; iColSortGroup=1; } // -------------------------------------------------------------------------- SzPartCrv1::~SzPartCrv1() { } // -------------------------------------------------------------------------- void SzPartCrv1::SetModeVisibility(flag Shown, char* FineTag, char* CoarseTag) { fPCMode_Shown=Shown; if (FineTag && strlen(FineTag)>0) sPCModeStrings[PC_Frac2Fine]=FineTag; if (CoarseTag && strlen(CoarseTag)>0) sPCModeStrings[PC_Frac2Coarse]=CoarseTag; } // -------------------------------------------------------------------------- void SzPartCrv1::SetStateVisibility(flag Shown, char* OnTag, char* OffTag) { fPCState_Shown=Shown; if (OnTag && strlen(OnTag)>0) sPCStateStrings[PC_On]=OnTag; if (OffTag && strlen(OffTag)>0) sPCStateStrings[PC_Off]=OffTag; } // -------------------------------------------------------------------------- char* SzPartCrv1::GetRangeLbl(int i, Strng& Str, flag Ascend, flag Range) { if (Range) { if (Ascend) { if (i>=SizePts().GetUpperBound()) { Strng S; PCG.XFmt.FormatFloat(PCG.XCnv.Human(SizePts()[i-1]), S); Str="+"; Str+=S; } else { Strng S; PCG.XFmt.FormatFloat(PCG.XCnv.Human(SizePts()[i]), S); Str="-"; Str+=S; } //iRngWidth=Min(32, Max(iRngWidth, Str.Len())); Str.LPad(iRngWidth); } else { if (i<SizePts().GetUpperBound()) { i=SizePts().GetUpperBound()-i; Str=""; Strng S; if (SD_Defn.LabelStyle()==LS_Full) { Strng S; PCG.XFmt.FormatFloat(PCG.XCnv.Human(SizePts()[i]), S); Str+="-"; Str+=S; } PCG.XFmt.FormatFloat(PCG.XCnv.Human(SizePts()[i-1]), S); Str+="+"; Str+=S; } else { Strng S; PCG.XFmt.FormatFloat(PCG.XCnv.Human(SizePts()[0]), S); Str="-"; Str+=S; if (SD_Defn.LabelStyle()==LS_Full) { PCG.XFmt.FormatFloat(PCG.XCnv.Human(BottomSize()), S); Str+="+"; Str+=S; } } } } else { if (!Ascend) i=SizePts().GetUpperBound()-i; PCG.XFmt.FormatFloat(PCG.XCnv.Human(SizePts()[i]), Str); } return Str(); } // -------------------------------------------------------------------------- void SzPartCrv1::CalcCumValues() { if (fPCCumShown) { if (Crvs.GetSize()<=iCrvCount) SetNCurves(iCrvCount); for (int c=0; c<NCurves(); c++) { Crvs[c+NCurves()]=Crvs[c]; Crvs[c+NCurves()].ToCumulative(); } } } // -------------------------------------------------------------------------- void SzPartCrv1::SetSizeDefn(int iDef) { iSizeDefn=iDef;//MAX_INT; #if !UseManualSizeDefn if (iSizeDefn<0) iSizeDefn=0; #endif int L=Length(); if (iSizeDefn>=0 && iSizeDefn<SD_Defn.NDistributions()) { CSD_DistDefn &D=*SD_Defn.GetDist(iSizeDefn); dBottomSize=D.BottomSize(); dTopSize=D.TopSize(); dBottomSizeDisp=D.BottomSizeDisp(); dTopSizeDisp=D.TopSizeDisp(); LclSz.SetSize(0); CSD_Intervals &Intervals=D.Intervals; //use intervals from specified distribution const int icnt = Intervals.GetSize(); for (int i=0; i<icnt; i++) if ((Intervals[i]>=dBottomSize) && (Intervals[i]<=dTopSize)) { const double d = Intervals[i]; LclSz.Add(d); } if ((icnt==0) || (Intervals[icnt-1]<dTopSize)) LclSz.Add(dTopSize); // Oversize Interval //double OvrInt=dTopSizeDisp;//BigSizeInterval; //LclSz.Add(OvrInt); // Oversize Interval } //todo: if changing from one iSizeDefn to another the perhaps data should be changed intelligently!? SetLength(Length()); } // -------------------------------------------------------------------------- void SzPartCrv1::SetLength(int N) { if (!UserSizePts()) N=SizePts().GetSize(); else { N=Max(2, N); SizePts().SetSize(N); } Crvs.SetSizes(Crvs.GetSize(), N); } // -------------------------------------------------------------------------- void SzPartCrv1::SetNCurves(int N) { N=Min(N, MaxPartCurves); iCrvCount = N; const int F=(fPCCumShown ? 2 : 1); const int N0=CrvInfo.GetSize()/F; CrvInfo.SetSize(N*F); Crvs.SetSize(N*F); const int nPts = SizePts().GetSize(); SetLength(nPts); for (int i=N0; i<N; i++) { if (nPts>0) Crvs[i][nPts-1] = 1.0; CrvInfo[i].SetDefaultValues(); CrvInfo[i].Title.Set("Frac%d", i); } if (fPCCumShown) { for (int i=N; i<N*2; i++) { CrvInfo[i].SetDefaultValues(); CrvInfo[i].Title.Set("Cum%d", i-N); CrvInfo[i].Edit=false; } } } // -------------------------------------------------------------------------- void SzPartCrv1::SetCumulativeVisibility(flag Shown) { int N=NCurves(); fPCCumShown=Shown; SetNCurves(N); } // -------------------------------------------------------------------------- //Does Nothing: //void SzPartCrv1::BuildDataDefn_Lcl(DataDefnBlk & DDB) // { // } // -------------------------------------------------------------------------- void SzPartCrv1::BuildDataDefn(DataDefnBlk & DDB) { DDB.BeginObject(this, Tag(), SzPartCrv1Class.ClassId(), NULL, DDB_OptPage); DDBValueLstMem DDB0; DDB0.Empty(); for (int i=0; i<SD_Defn.NIntervals(); i++) DDB0.Add(i, SD_Defn.GetIntervals(i)->Name()); #if UseManualSizeDefn DDB0.Add(-1, "Manual"); #endif DDB.Long("SizeDefn", "", DC_ , "", xidPartSizeDefn, this, isParm, DDB0()); DDB.Long("Length", "", DC_ , "", xidPartLength, this, isParm); DDB.Long("Curves", "", DC_ , "", xidPartCurves, this, isParm); DDB0.Empty(); for (i=0; i<SD_Defn.NDistributions(); i++) DDB0.Add(i, SD_Defn.GetDist(i)->Name()); DDB0.Add(-1, "All"); #if UseManualSizeDefn DDB.Long("ApplyTo", "", DC_, "", xidApplyToDist, this, isParm, DDB0()); #endif static DDBValueLst DDB1[]={ {0, "Smooth"}, {1, "Stepped"}, {0}}; DDB.Bool("Shape", "", DC_, "", &fPartStepped, this, isParm, DDB1); DDB.Double("XDispMin", "", DC_, "", &PCG.dSzDispMin, this, isParm); DDB.Double("XDispMax", "", DC_, "", &PCG.dSzDispMax, this, isParm); DDB.Bool ("PCState_Shown", "", DC_, "", &fPCState_Shown, this, isParm|InitHidden|noFileAtAll); DDB.Bool ("PCMode_Shown", "", DC_, "", &fPCMode_Shown, this, isParm|InitHidden|noFileAtAll); DDB.Bool ("PCGraph_Shown", "", DC_, "", &fPCGraph_Shown, this, isParm|InitHidden|noFileAtAll); DDB.Bool ("PCCum_Shown", "", DC_, "", &fPCCumShown, this, isParm|InitHidden|noFileAtAll); DDB.Bool ("PCSizeRangeRows", "", DC_, "", &fPCSizeRangeRows, this, isParm|InitHidden|noFileAtAll); DDB.String("UsedClassID", "", DC_, "", xidUsedClassID, this, isParm|InitHidden|noFileAtAll); DDB.String("PCMode_F", "", DC_, "", xidPartCrvMode_F, this, isParm|InitHidden|noFileAtAll); DDB.String("PCMode_C", "", DC_, "", xidPartCrvMode_C, this, isParm|InitHidden|noFileAtAll); DDB.String("PCState_On", "", DC_, "", xidPartCrvState_On, this, isParm|InitHidden|noFileAtAll); DDB.String("PCState_Off", "", DC_, "", xidPartCrvState_Off, this, isParm|InitHidden|noFileAtAll); if (fPCCumShown && Crvs.GetSize()<=iCrvCount) CalcCumValues(); Strng Nm; for (i=0; i<NCurves(); i++) { Nm.Set("Mode%i", i); static DDBValueLst DDBMode[]= { {PC_Frac2Fine, sPCModeStrings[PC_Frac2Fine]()}, {PC_Frac2Coarse, sPCModeStrings[PC_Frac2Coarse]()}, {0}}; DDB.Byte(Nm(), "", DC_, "", xidPartCrvMode+i, this, isParm, DDBMode); Nm.Set("State%i", i); static DDBValueLst DDBState[]={ {PC_On, sPCStateStrings[PC_On]()}, {PC_Off, sPCStateStrings[PC_Off]()}, {0}}; DDB.Byte(Nm(), "", DC_, "", xidPartCrvState+i, this, isParm, DDBState); Nm.Set("Edit%i", i); DDB.Byte(Nm(), "", DC_, "", xidPartCrvEdit+i, this, isParm|noFileAtAll); Nm.Set("AutoCorrect%i", i); DDB.Byte(Nm(), "", DC_, "", xidPartCrvAutoCorrect+i, this, isParm|noFileAtAll); Nm.Set("Title%i", i); DDB.String(Nm(), "", DC_, "", xidPartCrvTitle+i, this, isParm|noFileAtAll); Nm.Set("CnvIndex%i", i); DDB.Short(Nm(), "", DC_, "", xidPartCrvCnvIndex+i, this, isParm|noFileAtAll); Nm.Set("CnvText%i", i); DDB.String(Nm(), "", DC_, "", xidPartCrvCnvText+i, this, isParm|noFileAtAll); Nm.Set("RangeLo%i", i); DDB.Double(Nm(), "", DC_, "", xidPartCrvRangeLo+i, this, isParm|noFileAtAll); Nm.Set("RangeHi%i", i); DDB.Double(Nm(), "", DC_, "", xidPartCrvRangeHi+i, this, isParm|noFileAtAll); } if (DDB.BeginArray(this, "SZPrtCrv", "SZPrtCrv", Length())) for (int d=0; d<Length(); d++) if (DDB.BeginElement(this, d)) { if (DDB.ForView()) { //DDB.Double("Size", "", DC_L, "um", &SizePts()[d], this, isResult|noFileAtAll); //DDB.Double("SzRange", "", DC_L, "um", &SizePts()[d], this, isResult|noFileAtAll); } else { DDB.Double("Size", "", DC_L, "um", &SizePts()[d], this, iSizeDefn < 0 ? isParm : DDEF_WRITEPROTECT); DDB.Double("SzRange", "", DC_L, "um", &SizePts()[d], this, DDEF_WRITEPROTECT|noFileAtAll); } for (int c=0; c<NCurves(); c++) { //DDB.Double(CrvInfo[c].Title(), "", DC_Frac, "%", &Crvs[c][d], this, isParm); DDB.Double(CrvInfo[c].Title(), "", CrvInfo[c].DataCnv.Index(), CrvInfo[c].DataCnv.Text(), &Crvs[c][d], this, isParm); //dbgpln("B:%s %3i %3i = %12.6f ", DDB.DoingGetData()?"Get":"Put", c,d, Crvs[c][d]); } if (fPCCumShown) { for (c=NCurves(); c<NCurves()*2; c++) DDB.Double(CrvInfo[c].Title(), "", CrvInfo[c].DataCnv.Index(), CrvInfo[c].DataCnv.Text(), &Crvs[c][d], this, noFileAtAll);//|DDEF_WRITEPROTECT);//isParm); } } DDB.EndArray(); DDB.EndObject(); } // -------------------------------------------------------------------------- flag SzPartCrv1::DataXchg(DataChangeBlk & DCB) { switch (DCB.lHandle) { case xidPartSizeDefn: if (DCB.rL) //SetSizeDefn(Range(-1L, *DCB.rL, SD_Defn.NIntervals()-1L)); SetSizeDefn(Range(-1L, *DCB.rL, SD_Defn.NDistributions()-1L)); DCB.L=iSizeDefn; return 1; #if UseManualSizeDefn case xidApplyToDist: if (DCB.rL) { iApplyToDist=Range(-1L, *DCB.rL, SD_Defn.NDistributions()-1L); SetSizeDefn(iSizeDefn); } DCB.L=iApplyToDist; return 1; #endif case xidPartLength: if (DCB.rL) SetLength(*DCB.rL); DCB.L=Length(); return 1; case xidPartCurves: // AttachedTo must set the Number of curves if (DCB.rL && (pAttachedTo==NULL)) SetNCurves(*DCB.rL); DCB.L=NCurves(); return 1; case xidUsedClassID: if (DCB.rpC && strlen(DCB.rpC)>0) sUsedClassID=DCB.rpC; DCB.pC=(pAttachedTo ? pAttachedTo->ClassId() : sUsedClassID()); return 1; case xidPartCrvMode_F: if (DCB.rpC) sPCModeStrings[PC_Frac2Fine]=DCB.rpC; DCB.pC=sPCModeStrings[PC_Frac2Fine](); return 1; case xidPartCrvMode_C: if (DCB.rpC) sPCModeStrings[PC_Frac2Coarse]=DCB.rpC; DCB.pC=sPCModeStrings[PC_Frac2Coarse](); return 1; case xidPartCrvState_On: if (DCB.rpC) sPCStateStrings[PC_On]=DCB.rpC; DCB.pC=sPCStateStrings[PC_On](); return 1; case xidPartCrvState_Off: if (DCB.rpC) sPCStateStrings[PC_Off]=DCB.rpC; DCB.pC=sPCStateStrings[PC_Off](); return 1; default: if (DCB.lHandle>=xidPartCrvMode && DCB.lHandle<xidPartCrvMode+MaxColumns) { if (DCB.rB) SetCurveMode(DCB.lHandle-xidPartCrvMode, *DCB.rB); DCB.B=CurveMode(DCB.lHandle-xidPartCrvMode); return 1; } else if (DCB.lHandle>=xidPartCrvState && DCB.lHandle<xidPartCrvState+MaxColumns) { if (DCB.rB) SetCurveState(DCB.lHandle-xidPartCrvState, *DCB.rB); DCB.B=CurveState(DCB.lHandle-xidPartCrvState); return 1; } else if (DCB.lHandle>=xidPartCrvEdit && DCB.lHandle<xidPartCrvEdit+MaxColumns) { if (DCB.rB) SetEditable(DCB.lHandle-xidPartCrvEdit, *DCB.rB); DCB.B=Editable(DCB.lHandle-xidPartCrvEdit); return 1; } else if (DCB.lHandle>=xidPartCrvAutoCorrect && DCB.lHandle<xidPartCrvAutoCorrect+MaxColumns) { if (DCB.rB) CrvInfo[DCB.lHandle-xidPartCrvAutoCorrect].AutoCorrect=*DCB.rB; DCB.B=CrvInfo[DCB.lHandle-xidPartCrvAutoCorrect].AutoCorrect; return 1; } else if (DCB.lHandle>=xidPartCrvTitle && DCB.lHandle<xidPartCrvTitle+MaxColumns) { if (DCB.rpC) SetTitle(DCB.lHandle-xidPartCrvTitle, DCB.rpC); DCB.pC=Title(DCB.lHandle-xidPartCrvTitle); return 1; } else if (DCB.lHandle>=xidPartCrvCnvIndex && DCB.lHandle<xidPartCrvCnvIndex+MaxColumns) { if (DCB.rS) CrvInfo[DCB.lHandle-xidPartCrvCnvIndex].DataCnv.SetIndex(*DCB.rS); DCB.S=CrvInfo[DCB.lHandle-xidPartCrvCnvIndex].DataCnv.Index(); return 1; } else if (DCB.lHandle>=xidPartCrvCnvText && DCB.lHandle<xidPartCrvCnvText+MaxColumns) { if (DCB.rpC) CrvInfo[DCB.lHandle-xidPartCrvCnvText].DataCnv.SetText(DCB.rpC); DCB.pC=CrvInfo[DCB.lHandle-xidPartCrvCnvText].DataCnv.Text(); return 1; } else if (DCB.lHandle>=xidPartCrvRangeLo && DCB.lHandle<xidPartCrvRangeLo+MaxColumns) { if (DCB.rD) CrvInfo[DCB.lHandle-xidPartCrvRangeLo].dLoRange=*DCB.rD; DCB.D=CrvInfo[DCB.lHandle-xidPartCrvRangeLo].dLoRange; return 1; } else if (DCB.lHandle>=xidPartCrvRangeHi && DCB.lHandle<xidPartCrvRangeHi+MaxColumns) { if (DCB.rD) CrvInfo[DCB.lHandle-xidPartCrvRangeHi].dHiRange=*DCB.rD; DCB.D=CrvInfo[DCB.lHandle-xidPartCrvRangeHi].dHiRange; return 1; } } return TaggedObject::DataXchg(DCB); } // -------------------------------------------------------------------------- flag SzPartCrv1::ValidateData(ValidateDataBlk & VDB) { for (int c=0; c<Crvs.GetSize(); c++) for (int j=0; j<Crvs[c].GetSize(); j++) { Crvs[c][j] = Range(CrvInfo[c].dLoRange, Crvs[c][j], CrvInfo[c].dHiRange); //dbgpln("A:%3i %3i = %12.6f %12.6f %12.6f ", c,j, CrvInfo[c].dLoRange, Crvs[c][j], CrvInfo[c].dHiRange); } for (c=0; c<NCurves(); c++) { // if (CrvInfo[c].AutoCorrect && !TaggedObject::GetXWritesBusy()) if (CrvInfo[c].AutoCorrect) { double Err=0.0; if (Crvs[c].AdjustCumulativeEnd(CrvInfo[c].dHiRange, CrvInfo[c].dLoRange, CrvInfo[c].dHiRange, Err)) if (pAttachedTo) LogWarning(pAttachedTo->Tag(), 0, "Sizes adjusted to ensure correct sum (%s.%s column %d) Error=%g", pAttachedTo->Tag(), Tag(), c, Err); else LogWarning("Tag?", 0, "Sizes adjusted to ensure correct sum (%s.%s column %d) Error=%g", "Tag?", Tag(), c, Err); } } if (fPCCumShown) CalcCumValues(); return true; } // -------------------------------------------------------------------------- double SzPartCrv1::SizePassingFraction(int CurveNo, double dFrac) { return dNAN; } // -------------------------------------------------------------------------- double SzPartCrv1::FractionPassingSize(int CurveNo, double dSize) { double Frac=0.0; const long len = Length(); switch (len) { case 0 : Frac=0.0; break; case 1 : Frac=Crvs[CurveNo][0]; break; default : { CDArray & X = SizePts(); CDArray & Y = Crvs[CurveNo]; for (long i=0; (i<len-2) && (dSize>=X[i+1]); i++) { }; //if (fabs(X[i+1] - X[i]) > 1.0e-12) // break; int xx=0; Frac=Y[i]+(Y[i+1] - Y[i]) * (dSize - X[i]) / GTZ(X[i+1] - X[i]); break; } } return Range(0.0, Frac, 1.0); } //=========================================================================== // // // //=========================================================================== const int SzPartCrv1Edt::XPix=10000; const int SzPartCrv1Edt::YPix=10000; const int SzPartCrv1Edt::CrvPts=(MaxIntervals+2)*2; int SzPartCrv1Edt::iGraphWidth=40; int SzPartCrv1Edt::iGraphHeight=15; int SzPartCrv1Edt::iGraphOn=1; //------------------------------------------------------------------------------ SzPartCrv1Edt::SzPartCrv1Edt(pFxdEdtView pView_, pSzPartCrv1 pSD_) : FxdEdtBookRef(pView_), PC(*pSD_), PCG(pSD_->PCG) { iDragPtNo = -1; XMin=0.0; XMax=1.0; XFactor=1.0; iNameWidth=4; iWorkDist=0; iPg1=0; // fXtraPg=0; pLabels = new CLabelWnd; pLabels->CreateIt(pView_); pLabels->SetFont(pView_->ScrGB.pFont[0]); pLabels->SetLineCnt(1/*2*/); //pWrkCnv=NULL; //pWrkFmt=NULL; Strng Section; Section.Set("%s_%s", PC.Tag(), PC.sUsedClassID()/*PC.pAttachedTo->ClassId()*/); ObjectAttribute *pAttr=ObjAttributes.FindObject(Section()); if (pAttr) { pAttr->FieldFmtCnvs("Size", PCG.XFmt, PCG.XCnv); pAttr->FieldFmtCnvs("Frac", PCG.YFmt, PCG.YCnv); } CProfINIFile PF(PrjIniFile()); SzPartCrv1Edt::iGraphWidth=PF.RdInt(Section(), "GraphWidth", 40); SzPartCrv1Edt::iGraphHeight=PF.RdInt(Section(), "GraphHeight", 15); SzPartCrv1Edt::iGraphOn=PF.RdInt(Section(), "GraphOn", true); fSzAscend=PF.RdInt("SzDistribution", "IntervalsAscending", fSzAscend); } //--------------------------------------------------------------------------- SzPartCrv1Edt::~SzPartCrv1Edt() { CProfINIFile PF(PrjIniFile()); Strng Section; Section.Set("%s_%s", PC.Tag(), PC.sUsedClassID()/*PC.pAttachedTo->ClassId()*/); PF.WrInt(Section(), "GraphWidth", SzPartCrv1Edt::iGraphWidth); PF.WrInt(Section(), "GraphHeight", SzPartCrv1Edt::iGraphHeight); PF.WrInt(Section(), "GraphOn", SzPartCrv1Edt::iGraphOn); PF.WrInt("SzDistribution", "IntervalsAscending", fSzAscend); ObjectAttribute *pAttr=ObjAttributes.FindObject(Section()); if (pAttr) { pAttr->SetFieldFmt("Size", PCG.XFmt); pAttr->SetFieldCnvs("Size", PCG.XCnv); pAttr->SetFieldFmt("Frac", PCG.YFmt); pAttr->SetFieldCnvs("Frac", PCG.YCnv); } pLabels->DestroyWindow(); //cnmdelete pLabels; } //--------------------------------------------------------------------------- //int SzPartCrv1Edt::DistFromPgNo(int Pg) // { // return 0; //// for (int d=0; d<NCurves(); d++) //// if (rSD.Distributions[d]) //// if (Pg--==0) return d; // //DoBreak(); // return -1; // } //--------------------------------------------------------------------------- void SzPartCrv1Edt::PutDataStart() { } //--------------------------------------------------------------------------- void SzPartCrv1Edt::PutDataDone() { } //--------------------------------------------------------------------------- void SzPartCrv1Edt::GetDataStart() { } //--------------------------------------------------------------------------- void SzPartCrv1Edt::GetDataDone() { } //--------------------------------------------------------------------------- void SzPartCrv1Edt::StartBuild() { } //--------------------------------------------------------------------------- void SzPartCrv1Edt::Build() { Strng Tg, S, St; /*PCG.sNames.SetSize(NCurves()); for (int i=0; i<NCurves(); i++) PCG.sNames[i].Set("Frac%i", i);*/ if (PC.fPCCumShown)// && PC.Crvs.GetSize()<=PC.iCrvCount) PC.CalcCumValues(); iPg1=pView->Pages; StartPage(PC.Tag()); if (1) // Head Blk { #if UseManualSizeDefn int HedLen=(SD_Defn.NDistributions()>1 ? 3 : 2);//PC.UserSizePts() ? 4 : 3; #else int HedLen=0; #endif HedLen+=(GraphOn() ? 2 : 0); StartBlk(HedLen, 0, NULL); int L=0; if (GraphOn()) { SetSpace(L, 1); SetParm(L, "", Id_XMin, 10, 2, ""); SetSpace(L, Max(2,GraphWidth()-20-2)); SetParm(L, "", Id_XMax, 10, 2, ""); SetSpace(L, 1); SetDesc(L, "Graph:", -1, 6, 2, " "); Strng Tg(GraphOn() ? " On > Off " : " Off > On "); SetButton(L, Tg(), Id_GrOn, 10, 0, ""); L++; //SetSpace(L, 1); if (XLog()) SetButton(L,"Log > Lin", Id_XLog, 10, 0, ""); else SetButton(L,"Lin > Log", Id_XLog, 10, 0, ""); SetSpace(L, 1); if (AutoScale()) SetButton(L,"Auto > Fixed Scale", Id_AutoScale, 20, 0, ""); else SetButton(L,"Fixed > Auto Scale", Id_AutoScale, 20, 0, ""); SetSpace(L, 1); //SetDesc(L, "Type", -1, 5, 0, " "); if (PartStepped()) SetButton(L, "Stepped > Smooth", Id_PartStepped, 18, 0, " "); else SetButton(L, "Smooth > Stepped", Id_PartStepped, 18, 0, " "); L++; } #if UseManualSizeDefn L++; int FLen=8; for (int i=0; i<SD_Defn.Intervals.GetSize(); i++) FLen=Max(FLen, SD_Defn.Intervals[i]->NameLength()); SetDParm(L, "SizeDefn", 10, "", Id_PartSizeDefn, FLen, 0, ""); for (i=0; i<SD_Defn.Intervals.GetSize(); i++) FldHasFixedStrValue(i, SD_Defn.Intervals[i]->Name()); FldHasFixedStrValue(-1, "Manual"); SetSpace(L, 5); SetDParm(L, "Length", 8, "", Id_PartLen, 3, 0, ""); L++; if (SD_Defn.NDistributions()>1) { FLen=8; for (i=0; i<SD_Defn.NDistributions(); i++) FLen=Max(FLen, SD_Defn.Distributions[i]->NameLength()); SetDParm(L, "Apply To", 10, "", Id_ApplyToDist, FLen, 0, ""); for (i=0; i<SD_Defn.NDistributions(); i++) FldHasFixedStrValue(i, SD_Defn.Distributions[i]->Name()); FldHasFixedStrValue(-1, "All"); L++; } #endif } if (1) // Stats Blk { } int SzRngLen = 12; if (1) // Data Blk { int HedLen = 2; if (PC.fPCMode_Shown) HedLen++; if (PC.fPCState_Shown) HedLen++; StartBlk(Length()+HedLen+1, HedLen, NULL); int L=0; SetDesc(L, " ", -1, 4, 1, ""); SetDesc(L, PC.fPCSizeRangeRows ? "Size Range" : "Size", -1, SzRngLen, 1, " "); for (int c=0; c<NCurves(); c++) { S=PC.CrvInfo[c].Title(); S.SetLength(Min(S.Length(), 10)); SetDesc(L, S(), -1, 10, 1, ""); } if (PC.fPCCumShown) { SetSpace(L, 2); for (c=NCurves(); c<NCurves()*2; c++) { S=PC.CrvInfo[c].Title(); S.SetLength(Min(S.Length(), 10)); SetDesc(L, S(), -1, 10, 1, ""); } } //... if (PC.fPCMode_Shown) { L++; SetDesc(L, "Mode", -1, SzRngLen+4, 2, " "); for (c=0; c<NCurves(); c++) { SetParm(L, "", Id_YMode+c, 8, 0, " "); for (int i=0; i<MaxPCModes; i++) FldHasFixedStrValue(i, PC.sPCModeStrings[i]()); Tg.Set("%s.Mode%i", FullObjTag(), c); SetTag(Tg()); } } //... if (PC.fPCState_Shown) { L++; SetDesc(L, "State", -1, SzRngLen+4, 2, " "); for (c=0; c<NCurves(); c++) { SetParm(L, "", Id_YState+c, 8, 0, " "); for (int i=0; i<MaxPCStates; i++) FldHasFixedStrValue(i, PC.sPCStateStrings[i]()); Tg.Set("%s.State%i", FullObjTag(), c); SetTag(Tg()); } } //... L++; SetDesc(L, PCG.XCnv.Text(), -1, SzRngLen+4, 2, " "); for (c=0; c<NCurves(); c++) //SetDesc(L, PCG.YCnv.Text(), -1, 10, 2, ""); SetDesc(L, PC.CrvInfo[c].DataCnv.Text(), -1, 10, 2, ""); if (PC.fPCCumShown) { SetSpace(L, 2); SetDesc(L, "Size", -1, 10, 1, " "); for (c=NCurves(); c<NCurves()*2; c++) SetDesc(L, PC.CrvInfo[c].DataCnv.Text(), -1, 10, 2, ""); } //.. int iSz=fSzAscend ? 0 : Length()-1; int inc=fSzAscend ? 1 : -1; for ( ; iSz>=0 && iSz<Length(); iSz+=inc) // for (int iSz=0; iSz<Length(); iSz++) { L++; S.Set("%i", iSz); St.Set("SZPrtCrv.[%i]", iSz); SetDesc(L, S(), -1 , 4, 3, ""); SetParm(L, "", PC.fPCSizeRangeRows ? Id_XIntRng : Id_XInt, SzRngLen, 2, " "); Tg.Set("%s.%s.%s", FullObjTag(), St(), PC.fPCSizeRangeRows ? "SzRange" : "Size"); SetTag(Tg(), PCG.XCnv.Text()); for (c=0; c<NCurves(); c++) { SetParm(L, "", Id_YData+c, 10, 2, ""); Tg.Set("%s.%s.%s", FullObjTag(), St(), PC.CrvInfo[c].Title()); //SetTag(Tg(), PCG.YCnv.Text()); SetTag(Tg(), PC.CrvInfo[c].DataCnv.Text()); } if (PC.fPCCumShown) { SetSpace(L, 2); //S.Set("%i", iSz); St.Set("SZPrtCrv.[%i]", iSz); SetParm(L, "", Id_XInt, 10, 2, " "); Tg.Set("%s.%s.%s", FullObjTag(), St(), "Size"); SetTag(Tg(), PCG.XCnv.Text()); for (c=NCurves(); c<NCurves()*2; c++) { SetParm(L, "", Id_YData+c, 10, 2, ""); Tg.Set("%s.%s.%s", FullObjTag(), St(), PC.CrvInfo[c].Title()); //SetTag(Tg(), PCG.YCnv.Text()); SetTag(Tg(), PC.CrvInfo[c].DataCnv.Text()); } } } } if (1) // Base Blk { StartBlk(PC.fPCGraph_Shown ? 3 : 2, 0, NULL); int L=0; SetDesc(L, "Size Intervals :", -1, 16, 2, " "); Strng SzTg(fSzAscend ? " > Descending " : " > Ascending "); SetButton(L, SzTg(), Id_SzAscend, 14, 0, ""); L++; if (PC.fPCGraph_Shown) { SetDesc(L, "Graph:", -1, 6, 2, " "); Strng Tg(GraphOn() ? " On > Off " : " Off > On "); SetButton(L, Tg(), Id_GrOn, 10, 0, ""); if (GraphOn()) { SetSpace(L, 1); SetDParm(L, "Width", 6, "", Id_GrWidth, 2, 2, ""); SetSpace(L, 1); SetDParm(L, "Height", 7, "", Id_GrHeight, 2, 2, ""); } L++; } } } //--------------------------------------------------------------------------- void SzPartCrv1Edt::ChangeLayout(rFxdEdtPage Pg, int TotalRows, int TotalCols) { if (GraphOn() && (Pg.No-iPg1>=0)) { Pg.MoveRows(-32000); Pg.MoveRows(GraphHeight()); } } //--------------------------------------------------------------------------- void SzPartCrv1Edt::Load(FxdEdtInfo &EI, Strng & Str) { if (CurrentBlk(EI)) {//header int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { case Id_XMin : PCG.XFmt.FormatFloat(PCG.XCnv.Human(XDispMin()), Str); break; case Id_XMax : PCG.XFmt.FormatFloat(PCG.XCnv.Human(XDispMax()), Str); break; case Id_PartLen: Str.Set("%i", Length()); EI.Fld->fEditable=PC.UserSizePts(); break; #if UseManualSizeDefn case Id_PartSizeDefn: if (!PC.UserSizePts())//iSizeDefn<SD_Defn.Intervals.GetSize()) Str=SD_Defn.GetIntervals(PC.iSizeDefn)->Name(); else Str="Manual"; break; case Id_ApplyToDist: if (PC.iApplyToDist>=0)//iSizeDefn<SD_Defn.Intervals.GetSize()) Str=SD_Defn.GetDist(PC.iApplyToDist)->Name(); else Str="All"; break; #endif } } if (CurrentBlk(EI)) {//data int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { case Id_XInt: case Id_XIntRng: PC.GetRangeLbl(i, Str, fSzAscend, EI.FieldId==Id_XIntRng); EI.Fld->fEditable=PC.UserSizePts(); break; default: if (EI.FieldId>=Id_YData && EI.FieldId<Id_YData+(NCurves()*2)) { if (!fSzAscend) i=PC.SizePts().GetUpperBound()-i; //PCG.YFmt.FormatFloat(PCG.YCnv.Human(PC.Crvs[EI.FieldId-Id_YData][i]), Str); PCG.YFmt.FormatFloat(PC.CrvInfo[EI.FieldId-Id_YData].DataCnv.Human(PC.Crvs[EI.FieldId-Id_YData][i]), Str); EI.Fld->fEditable = PC.Editable(EI.FieldId-Id_YData); } else if (EI.FieldId>=Id_YMode && EI.FieldId<Id_YMode+(NCurves()*2)) { Str=PC.sPCModeStrings[PC.CrvInfo[EI.FieldId-Id_YMode].Mode](); } else if (EI.FieldId>=Id_YState && EI.FieldId<Id_YState+(NCurves()*2)) { Str=PC.sPCStateStrings[PC.CrvInfo[EI.FieldId-Id_YState].State](); } } } if (CurrentBlk(EI)) {//other switch (EI.FieldId) { case Id_SzAscend: Str.Set("%i", fSzAscend); break; case Id_GrWidth: Str.Set("%i", iGraphWidth); break; case Id_GrHeight: Str.Set("%i", iGraphHeight); break; case Id_GrOn : Str.Set("%i", iGraphOn); break; } } } //--------------------------------------------------------------------------- long SzPartCrv1Edt::Parse(FxdEdtInfo &EI, Strng & Str) { long Fix=0; //set Fix=1 to redraw graph if (CurrentBlk(EI)) {//header //bObjModified=1; int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { case Id_XMin : SetXDispMin(PCG.XCnv.Normal(SafeAtoF(Str, 0.0))); View().DoReload(); break; case Id_XMax : SetXDispMax(PCG.XCnv.Normal(SafeAtoF(Str, 1.0))); View().DoReload(); break; case Id_PartLen: PC.SetLength(Range(3L,SafeAtoL(Str,5),100L)); View().DoRebuild(); break; #if UseManualSizeDefn case Id_PartSizeDefn: { int i; for (i=SD_Defn.NIntervals()-1; i>=0; i--) if (Str.XStrICmp(SD_Defn.GetIntervals(i)->Name())==0) break; PC.SetSizeDefn(i); // if not found will become Manual (-1) View().DoRebuild(); } break; case Id_ApplyToDist: { int i; for (i=SD_Defn.NDistributions()-1; i>=0; i--) if (Str.XStrICmp(SD_Defn.GetDist(i)->Name())==0) break; PC.SetApplyToDist(i); View().DoRebuild(); } break; #endif } } if (CurrentBlk(EI)) {//data int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { case Id_XInt: case Id_XIntRng: if (!fSzAscend) i=PC.SizePts().GetUpperBound()-i; PC.SizePts()[i]=PCG.XCnv.Normal(SafeAtoF(Str,0.0)); break; default: if (!fSzAscend) i=PC.SizePts().GetUpperBound()-i; if (EI.FieldId>=Id_YData && EI.FieldId<Id_YData+(NCurves()*2)) { const int c = EI.FieldId-Id_YData; //PC.Crvs[c][i]=Range(0.0, PCG.YCnv.Normal(SafeAtoF(Str,0.0)),1.0); PC.Crvs[c][i]=Range(PC.CrvInfo[c].dLoRange, PC.CrvInfo[c].DataCnv.Normal(SafeAtoF(Str,0.0)), PC.CrvInfo[c].dHiRange); if (PC.CrvInfo[c].AutoCorrect && c<NCurves()) PC.Crvs[c].AdjustCumulativeEnd(PC.CrvInfo[c].dHiRange, PC.CrvInfo[c].dLoRange, PC.CrvInfo[c].dHiRange); PC.CalcCumValues(); View().DoReload(); } else if (EI.FieldId>=Id_YMode && EI.FieldId<Id_YMode+(NCurves()*2)) { int i; for (i=0; i<MaxPCModes; i++) if (Str.XStrICmp(PC.sPCModeStrings[i]())==0) break; if (i>=MaxPCModes) i=PC_Frac2Fine; PC.SetCurveMode(EI.FieldId-Id_YMode, i); } else if (EI.FieldId>=Id_YState && EI.FieldId<Id_YState+(NCurves()*2)) { int i; for (i=0; i<MaxPCStates; i++) if (Str.XStrICmp(PC.sPCStateStrings[i]())==0) break; if (i>=MaxPCStates) i=PC_On; PC.SetCurveState(EI.FieldId-Id_YState, i); } } } if (CurrentBlk(EI)) {//other switch (EI.FieldId) { case Id_SzAscend: fSzAscend = Str.SafeAtoL()!=0; View().DoRebuild(); break; case Id_GrWidth: iGraphWidth = Range(10L, Str.SafeAtoL(), 60L); View().DoRebuild(); break; case Id_GrHeight: iGraphHeight = Range(5L, Str.SafeAtoL(), 30L); View().DoRebuild(); break; case Id_GrOn: iGraphOn= Range(0L, Str.SafeAtoL(), 1L); View().DoRebuild(); break; } } return Fix; } //--------------------------------------------------------------------------- long SzPartCrv1Edt::ButtonPushed(FxdEdtInfo &EI, Strng & Str) { long Fix=0; //set Fix=1 to redraw graph if (CurrentBlk(EI)) {//header int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { case Id_AutoScale: SetAutoScale(!AutoScale()); SetRanges(); View().DoRebuild(); Fix=1; break; case Id_XLog: SetXLog(!XLog()); SetRanges(); View().DoRebuild(); Fix=1; break; case Id_PartStepped: SetPartStepped(!PartStepped()); SetRanges(); //bShowOther = !bShowOther; View().DoRebuild(); Fix=1; break; case Id_GrOn : iGraphOn=!iGraphOn; View().DoRebuild(); Fix=1; break; } } if (CurrentBlk(EI)) {//data /*int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { }*/ } // Base Blk if (CurrentBlk(EI)) { int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { case Id_SzAscend: fSzAscend=!fSzAscend; View().DoRebuild(); Fix=1; break; case Id_GrOn : iGraphOn=!iGraphOn; View().DoRebuild(); Fix=1; break; } } return Fix; } //--------------------------------------------------------------------------- void SzPartCrv1Edt::SetRanges() { const int len = Length(); const flag IsXLog = XLog(); const flag IsYLog = YLog(); if (AutoScale()) { if (len==0) { SetXDispMin(0.01); SetXDispMax(1.0); for (int c=0; c<NCurves(); c++) { SetYDispMin(c, 0.00); SetYFDispMax(c, 1.0); } } else { SetXDispMin(PC.SizePts().ScanMin()); SetXDispMax(PC.SizePts().ScanMax()); if (IsXLog) { SetXDispMin(XDispMin()*0.5); SetXDispMax(XDispMax()*1.1); } else { double xBorder = (XDispMax()-XDispMin())/40.0; SetXDispMin(XDispMin()-xBorder); SetXDispMax(XDispMax()+xBorder); } } } SetXDispMax(Max(XDispMax(), XDispMin()+1.0e-6)); if (IsXLog) {//set ranges to nearest decade SetXDispMin(Max(XDispMin(), MinLogVal)); SetXDispMin(pow(10.0, floor(Log10(XDispMin())))); SetXDispMax(pow(10.0, ceil(Log10(XDispMax())))); } if (AutoScale() && len>0) { for (int c=0; c<NCurves(); c++) { SetYDispMin(c, 0.0); SetYFDispMax(c, PC.Crvs[c].ScanMax()); } } for (int c=0; c<NCurves(); c++) { SetYFDispMax(c, Max(YFDispMax(c), YDispMin(c)+1.0e-6)); if (IsYLog) { SetYDispMin(c, Max(YDispMin(c), MinLogVal)); SetYDispMin(c, pow(10.0, floor(Log10(YDispMin(c))))); SetYFDispMax(c, pow(10.0, ceil(Log10(YFDispMax(c))))); } } } //--------------------------------------------------------------------------- void SzPartCrv1Edt::OnDrawBack(rGDIBlk GB,int PgNo, CRgn &ClipRgn) { if (GraphOn() && (PgNo-iPg1>=0)) { // SetWorkDist(DistFromPgNo(PgNo-iPg1)); CDC &DC = GB.DC(); CDCResChk ResChk(DC); SetPosition(GB); //calulate size of GraphR flag DoGraph = DC.RectVisible(&GraphR); CGdiObject* OldBrush = (CGdiObject*)DC.SelectObject(GB.pBrushGrfBack); if (DoGraph) {//draw the curve... int Err = ExtSelectClipRgn(DC.m_hDC, (HRGN)ClipRgn.m_hObject, RGN_AND); COLORREF OldBkColor = DC.SetBkColor(GB.crGrfBack); CPen* OldPen = DC.SelectObject(GB.pPenTxtBord); //CombinedRgn.CombineRgn(&ClipRgnGrf, &ClipRgn, RGN_AND); //int Err = ExtSelectClipRgn(DC.m_hDC, (HRGN)CombinedRgn.m_hObject, RGN_AND); Err = ExtSelectClipRgn(DC.m_hDC, (HRGN)ClipRgn.m_hObject, RGN_AND); DC.DrawEdge(&GraphR, EDGE_SUNKEN, BF_RECT); int EdgeX=GetSystemMetrics(SM_CXEDGE); int EdgeY=GetSystemMetrics(SM_CYEDGE); GraphR.InflateRect(-EdgeX*2, -EdgeY*2); DC.Rectangle(&GraphR); MappingSave MapSv; PushScaling(GB, GraphR, MapSv); CRgn ClipRgnGrf; CRgn CombinedRgn; ClipRgnGrf.CreateRectRgnIndirect(&GraphR); // //CombinedRgn.CombineRgn(&ClipRgnGrf, &ClipRgn, RGN_AND); //int Err = ExtSelectClipRgn(DC.m_hDC, (HRGN)CombinedRgn.m_hObject, RGN_AND); Err = ExtSelectClipRgn(DC.m_hDC, (HRGN)ClipRgnGrf.m_hObject, RGN_AND); CPoint Org = DC.GetWindowOrg(); CSize Ext = DC.GetWindowExt(); const int len = Length(); const flag IsXLog = XLog(); const flag IsYLog = YLog(); // SetRanges(); // //get normalised values... if (IsXLog) { XMin = Log10(XDispMin()); XMax = Log10(XDispMax()); } else { XMin = XDispMin(); XMax = XDispMax(); } const double dX = GTZ(XMax-XMin); XFactor = XPix/dX; YMin.SetSize(NCurves()); // YCMax.SetSize(NCurves()); YFMax.SetSize(NCurves()); // YCFactor.SetSize(NCurves()); YFFactor.SetSize(NCurves()); for (int c=0; c<NCurves(); c++) { YMin[c] = YDispMin(c); // YCMax[c] = YCDispMax(c); YFMax[c] = YFDispMax(c); // const double dCY = GTZ(YCMax[c]-YMin[c]); const double dFY = GTZ(YFMax[c]-YMin[c]); // YCFactor[c] = YPix/dCY; YFFactor[c] = YPix/dFY; } //draw axis... ::SelectObject(DC.m_hDC, GB.hLinePenDim[0]); int x1,y1; if (!IsXLog) { x1 = (int)Range((double)-INT_MAX, (0.0-XMin)*XFactor, (double)INT_MAX); //x1 = (int)Range((double)-INT_MAX, (rSD.GetNormX(0.0)-XMin)*XFactor, (double)INT_MAX); DC.MoveTo(x1,Org.y); DC.LineTo(x1,Org.y+Ext.cy); } if (!IsYLog) { for (int c=0; c<NCurves(); c++) { // Fix This ??? Make Axes Coincide y1 = (int)Range((double)-INT_MAX, (0.0-YMin[c])*YFFactor[c], (double)INT_MAX); //y1 = (int)Range((double)-INT_MAX, (rSD.GetNormY(0.0)-YMin)*YFactor, (double)INT_MAX); DC.MoveTo(Org.x,y1); DC.LineTo(Org.x+Ext.cx,y1); } } //draw X log decades... if (IsXLog) { int Decades = (int)(Log10(XDispMax()) - Log10(XDispMin())); double Xv = XDispMin(); for (int j=0; j<Decades; j++) { ::SelectObject(DC.m_hDC, GB.hLinePenDim[1]); for (int i=1; i<10; i++) { x1 = (int)Range((double)-INT_MAX, (Log10(Xv*i)-XMin)*XFactor, (double)INT_MAX); DC.MoveTo(x1,Org.y); DC.LineTo(x1,Org.y+Ext.cy); if (i==1) ::SelectObject(DC.m_hDC, GB.hLinePenDim[0]); if (Decades>4) i++; } Xv *= 10.0; } } ::SelectObject(DC.m_hDC, GB.hLinePen[0]); CDArray & Xs=PC.SizePts();//GetXData(); const int dCrossX = XPix/150; const int dCrossY = YPix/150; const int FirstPen=3; //draw the curves... int iPen=FirstPen; int XYLen; if (Xs.GetSize()>0) for (c=0; c<NCurves(); c++) { ::SelectObject(DC.m_hDC, GB.hLinePen[iPen++]); CDArray &Ys=PC.Crvs[c]; POINT XY[CrvPts]; XYLen=0; for (int j=0; j<Xs.GetSize()/*-1*/; j++) { int x=IsXLog ? CalcXLogPix(Xs[j]) : CalcXPix(Xs[j]); int y=IsYLog ? CalcYFLogPix(c, Ys[j]) : CalcYFPix(c, Ys[j]); if (PartStepped()) { if (XYLen>0) XY[XYLen].x = XY[XYLen-1].x; else XY[XYLen].x = IsXLog ? CalcXLogPix(PC.BottomSizeDisp()) : CalcXPix(PC.BottomSizeDisp());//-XPix; XY[XYLen].y = y;//XY[XYLen-1].y; XYLen++; } XY[XYLen].x = x; XY[XYLen].y = y; XYLen++; } XY[XYLen].x = IsXLog ? CalcXLogPix(PC.TopSizeDisp()) : CalcXPix(PC.TopSizeDisp()); XY[XYLen].y = XY[XYLen-1].y; XYLen++; DC.Polyline(XY, XYLen); } //} // Restore State PopScaling(GB, MapSv); DC.SelectObject(OldPen); DC.SetBkColor(OldBkColor); DC.SelectClipRgn(NULL); } DC.SelectObject(OldBrush); } } //--------------------------------------------------------------------------- void SzPartCrv1Edt::SetPosition(rGDIBlk GB) { int CW = GB.ColWdt(); int RH = GB.RowHgt(); GraphR = GB.LuDataRect(); GraphR.top -= 1; GraphR.right = GraphR.left+GraphWidth()*CW; GraphR.bottom = GraphR.top+GraphHeight()*RH; GraphR.top+=View().CPg->FixedRows*RH; GraphR.bottom+=View().CPg->FixedRows*RH; int EdgeX=GetSystemMetrics(SM_CXEDGE); int EdgeY=GetSystemMetrics(SM_CYEDGE); GraphR.InflateRect(-EdgeX*2, -EdgeY*2); //iNameWidth = Max(rSD.XNameLen(), rSD.YNameLen()); pLabels->SetPosition(GraphR.left, GraphR.bottom+1, iNameWidth + 18); } //--------------------------------------------------------------------------- void SzPartCrv1Edt::PointtoLP(POINT &Pt) { CDC* pDC = &(View().ScrGB.DC()); CDCResChk ResChk(pDC); MappingSave MapSv; PushScaling(View().ScrGB, GraphR, MapSv); pDC->DPtoLP(&Pt); PopScaling(View().ScrGB, MapSv); } //--------------------------------------------------------------------------- void SzPartCrv1Edt::PointtoWP(POINT Pt, double& x, double& y) { rGDIBlk rGB = View().ScrGB; CDC& rDC = rGB.DC(); CDCResChk ResChk(rDC); MappingSave MapSv; PushScaling(View().ScrGB, GraphR, MapSv); rDC.DPtoLP(&Pt); PopScaling(View().ScrGB, MapSv); if (XLog()) x = CalcXLogVal(Pt.x); else x = CalcXVal(Pt.x); } //--------------------------------------------------------------------------- int SzPartCrv1Edt::ClosestPt(CPoint point) { double x,y; PointtoWP(point, x, y); int PtNo = -1; double dist = DBL_MAX; return PtNo; } //--------------------------------------------------------------------------- void SzPartCrv1Edt::ToggleDigCursor(POINT &Pt) { CClientDC dc(&Wnd(pView)); CDCResChk ResChk(dc); MappingSave MapSv; PushScaling(View().ScrGB, GraphR, MapSv); CPen APen(PS_SOLID,1,RGB(0xFF, 0xFF, 0xFF));//dc.GetNearestColor(Doc().DigColour)); CGdiObject* OldPen=(CGdiObject*)dc.SelectObject(&APen); int OldMode=dc.SetROP2(R2_XORPEN); dc.MoveTo(Pt.x,0); dc.LineTo(Pt.x,YPix); dc.MoveTo(0, Pt.y); dc.LineTo(XPix, Pt.y); dc.SetROP2(OldMode); PopScaling(View().ScrGB, MapSv); } //--------------------------------------------------------------------------- flag SzPartCrv1Edt::DoLButtonDown(UINT nFlags, CPoint point) { if (PtInRect(&GraphR, point)) { if (nFlags & MK_SHIFT) iDragPtNo = ClosestPt(point); return 1; } return 0; } //--------------------------------------------------------------------------- flag SzPartCrv1Edt::DoLButtonUp(UINT nFlags, CPoint point) { if (PtInRect(&GraphR, point)) { if (iDragPtNo>=0) { View().DoReload(); iDragPtNo = -1; } return 1; } return 0; } //--------------------------------------------------------------------------- flag SzPartCrv1Edt::DoLButtonDblClk(UINT nFlags, CPoint point) { if (PtInRect(&GraphR, point)) { return 1; } return 0; } //--------------------------------------------------------------------------- flag SzPartCrv1Edt::DoRButtonDown(UINT nFlags, CPoint point) { if (pView->CPgNo-iPg1>=0 && PtInRect(&GraphR, point)) { return 1; } return 0; } //--------------------------------------------------------------------------- flag SzPartCrv1Edt::DoRButtonUp(UINT nFlags, CPoint point) { if (pView->CPgNo-iPg1>=0 && PtInRect(&GraphR, point)) { return 1; } FxdEdtView &Vw=View(); flag ret=false;//FxdEdtView::DoRButtonUp(nFlags, point); if (Vw.CPgNo>=0) { FxdEdtInfo EI; if (Vw.LocateFromCR((int)Vw.ChEditPos.x, (int)Vw.ChEditPos.y, EI)) { ret=true; //if (EI.FieldId<0 && EI.Fld) if (EI.Fld) { int nCols=MaxColumns;//NCurves(); if (EI.FieldId==Id_XInt || EI.FieldId==Id_XIntRng || EI.FieldId==Id_XMin || EI.FieldId==Id_XMax || (EI.FieldId>=Id_YMode && EI.FieldId<Id_YMode+nCols) || (EI.FieldId>=Id_YState && EI.FieldId<Id_YState+nCols) || (EI.FieldId>=Id_YTitle && EI.FieldId<Id_YTitle+nCols) || (EI.FieldId>=Id_dSize && EI.FieldId<Id_dSize+MaxCSDMeasurements*MaxColumns) || (EI.FieldId>=Id_YMin && EI.FieldId<Id_YMin+nCols) || // EI.FieldId>=Id_YCMax && EI.FieldId<Id_YCMax+nCols || (EI.FieldId>=Id_YFMax && EI.FieldId<Id_YFMax+nCols) || (EI.FieldId>=Id_YData && EI.FieldId<Id_YData+nCols) ) { CRect WRect; Vw.GetWindowRect(&WRect); CPoint RBPoint; RBPoint.x = WRect.left+point.x; RBPoint.y = WRect.top+point.y; if ( (EI.FieldId>=Id_YMode && EI.FieldId<Id_YMode+nCols) || (EI.FieldId>=Id_YState && EI.FieldId<Id_YState+nCols) || (EI.FieldId>=Id_YTitle && EI.FieldId<Id_YTitle+nCols) ) { //pWrkFmt=NULL; //pWrkCnv=NULL; WrkIB.Set(EI.Fld->Tag); } else if (EI.FieldId==Id_XInt || EI.FieldId==Id_XIntRng || EI.FieldId==Id_XMin || EI.FieldId==Id_XMax || EI.FieldId>=Id_dSize && EI.FieldId<Id_dSize+MaxCSDMeasurements*MaxColumns) { WrkIB.Set(EI.Fld->Tag, &PCG.XCnv, &PCG.XFmt); //pWrkFmt=&PCG.XFmt; //pWrkCnv=&PCG.XCnv; } else { int c=(EI.FieldId-Id_YMin)%MaxColumns; //pWrkFmt=&PCG.YFmt; //pWrkCnv=&PCG.YCnv; //pWrkCnv=&(PC.CrvInfo[c].DataCnv); WrkIB.Set(EI.Fld->Tag, &(PC.CrvInfo[c].DataCnv), &PCG.YFmt); } CMenu Menu; Menu.CreatePopupMenu(); CMenu FormatMenu; FormatMenu.CreatePopupMenu(); if (WrkIB.FmtOK()) { WrkIB.Fmt().AddToMenu(FormatMenu); CMenu CnvMenu; CnvMenu.CreatePopupMenu(); WrkIB.Cnv().AddToMenu(CnvMenu); Menu.AppendMenu(MF_POPUP, (unsigned int)CnvMenu.m_hMenu, "&Conversions"); if (WrkIB.Cnv().Index()<=0)// || !IsFloatData(d.iType)) Menu.EnableMenuItem(0, MF_BYPOSITION|MF_GRAYED); Menu.AppendMenu(MF_POPUP, (unsigned int)FormatMenu.m_hMenu, "&Format"); Menu.AppendMenu(MF_STRING, pView->iSendToTrend, "Send To &Trend"); Menu.AppendMenu(MF_STRING, pView->iSendToQuickView, "Send To &QuickView"); Menu.AppendMenu(MF_STRING|MF_GRAYED, pView->iSendToQuickView, "Send To &Custom"); Menu.AppendMenu(MF_SEPARATOR); } Menu.AppendMenu(MF_STRING, pView->iCmdCopyTag, "Copy Full &Tag"); if (EI.Fld->Tag==NULL) Menu.EnableMenuItem(pView->iCmdCopyTag, MF_BYCOMMAND|MF_GRAYED); Menu.AppendMenu(MF_STRING, pView->iCmdCopyVal, "Copy &Value"); Menu.TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON, RBPoint.x, RBPoint.y, /*(CWnd*)*/&View()); Menu.DestroyMenu(); } } } } return ret; //return 0; } //--------------------------------------------------------------------------- flag SzPartCrv1Edt::DoRButtonDblClk(UINT nFlags, CPoint point) { if (pView->CPgNo-iPg1>=0 && PtInRect(&GraphR, point)) { return 1; } return 0; } //--------------------------------------------------------------------------- flag SzPartCrv1Edt::DoMouseMove(UINT nFlags, CPoint point) { if (GraphOn() && PtInRect(&GraphR, point)) { double x,y; PointtoWP(point, x, y); char Buff[256], Buff2[256]; iNameWidth=4; PCG.XFmt.FormatFloat(PCG.XCnv.Human(x), Buff2, sizeof(Buff2)); sprintf(Buff, "%*s:%s", iNameWidth, "Size", Buff2); pLabels->SetText(0, Buff); pLabels->Show(); pLabels->Invalidate(); if (nFlags & MK_LBUTTON) { if (nFlags & MK_SHIFT) { if (iDragPtNo>=0) { //rSD.MovePt(iDragPtNo, x, y); //rSD.bObjModified = 1; } } else iDragPtNo = -1; Wnd(pView).InvalidateRect(&GraphR); } return 1; } else { pLabels->Hide(); } return 0; } //--------------------------------------------------------------------------- flag SzPartCrv1Edt::DoAccCnv(UINT Id) { pCDataCnv pC=Cnvs[WrkIB.Cnv().Index()]; for (int i=Id; i>0; i--) pC=pC->Next(); if (pC) { WrkIB.Cnv().SetText(pC->Txt()); } View().DoRebuild(); return true; }; //--------------------------------------------------------------------------- flag SzPartCrv1Edt::DoAccFmt(UINT Id) { for (UINT i=0; i<(UINT)DefinedFmts.GetSize(); i++) if (i==Id) break; if (i<(UINT)DefinedFmts.GetSize()) { WrkIB.Fmt()=DefinedFmts[i]; View().DoRebuild(); } return true; }; //--------------------------------------------------------------------------- flag SzPartCrv1Edt::DoAccRptTagLists() { return FxdEdtBookRef::DoAccRptTagLists(); //TagInfoBlk * IB = new TagInfoBlk(WrkIB.ObjClassId(), WrkIB.RefTag(), // WrkIB.CnvOK() ? &WrkIB.Cnv() : NULL, // WrkIB.FmtOK() ? &WrkIB.Fmt() : NULL); //ScdMainWnd()->PostMessage(WMU_ADDTOQUICKVIEW, 0, (long)(IB)); // //return true; }; //=========================================================================== // // // //=========================================================================== #if WITHSELBRK IMPLEMENT_SPARES(SzSelBrk1, 100); IMPLEMENT_TAGOBJEDT(SzSelBrk1, "SpSelBreak", "SzSelBrk", "", "SZSB", TOC_ALL|TOC_GRP_SIZEDST|TOC_SIZEDIST, SzSelBrk1Edt, "Size Selection & Breakage", "Size Selection & Breakage"); SzSelBrk1::SzSelBrk1(pTagObjClass pClass_, pchar Tag_, pTaggedObject pAttach, TagObjAttachment eAttach) : TaggedObject(pClass_, Tag_, pAttach, eAttach)//, { iApplyToDist=0; SetSizeDefn(0); } // -------------------------------------------------------------------------- SzSelBrk1::SzSelBrk1(pchar Tag_, pTaggedObject pAttach, TagObjAttachment eAttach) : TaggedObject(&SzSelBrk1Class, Tag_, pAttach, eAttach)//, { iApplyToDist=0; SetSizeDefn(0); } // -------------------------------------------------------------------------- SzSelBrk1::~SzSelBrk1() { } // -------------------------------------------------------------------------- void SzSelBrk1::SetSizeDefn(int iDef) { iSizeDefn=iDef;//MAX_INT; #if !UseManualSizeDefn if (iSizeDefn<0) iSizeDefn=0; #endif int L=Length(); if (iSizeDefn>=0 && SD_Defn.NIntervals()>iSizeDefn) { double dBottomSize=1.0e6; double dTopSize=0.0; if (0) {//old code... double dBottomSizeDisp=1.0e6; double dTopSizeDisp=0.0; int d0, dN; GetApplyToDists(d0, dN); for (int d=d0; d<dN; d++) if (DistExists(d)) { CSD_DistDefn &D=*SD_Defn.GetDist(d); dBottomSize=Min(dBottomSize, D.BottomSize()); dTopSize=Max(dTopSize, D.TopSize()); dBottomSizeDisp=Min(dBottomSizeDisp, D.BottomSizeDisp()); dTopSizeDisp=Max(dTopSizeDisp, D.TopSizeDisp()); } } else {//new code March 2003 CSD_DistDefn &D=*SD_Defn.GetDist(iSizeDefn); dBottomSize=D.BottomSize(); dTopSize=D.TopSize(); } LclSz.SetSize(0); CSD_Intervals &Intervals=*SD_Defn.GetIntervals(iSizeDefn); const int icnt = Intervals.GetSize(); for (int i=0; i<icnt; i++) { if ((Intervals[i]>=dBottomSize) && ((Intervals.GetSize()==0) || (Intervals[i]<=dTopSize))) LclSz.Add(Intervals[i]); } if (icnt==0 || Intervals[icnt-1]<dTopSize) LclSz.Add(dTopSize); // Oversize Interval //double OvrInt=dTopSizeDisp;//BigSizeInterval; //LclSz.Add(OvrInt); // Oversize Interval } L=SB.GetSize(); SetLength(Length()); if (Length()>L) { for (int s=L; s<Length(); s++) { SB[s][s]=0.1; for (int d=L; d<s; d++) SB[s][d]=0; } SB[0][0]=0.0; } CheckSB(); } // -------------------------------------------------------------------------- void SzSelBrk1::CheckSB() { for (int s=0; s<Length(); s++) { SB[s][s]=Range(0.0, SB[s][s], 1.0); double t=0; for (int d=0; d<s; d++) t+=SB[s][d]; double Err=t-1.0; for (d=0; d<s; d++) { double Rqd=Range(0.0, SB[s][d]-Err, 1.0); Err+=Rqd-SB[s][d]; SB[s][d]=Rqd; } } SB[0][0]=0.0; } // -------------------------------------------------------------------------- void SzSelBrk1::SetLength(int N) { SB.SetSizes(N, N); } // -------------------------------------------------------------------------- //Does Nothing: //void SzSelBrk1::BuildDataDefn_Lcl(DataDefnBlk & DDB) // { // } // -------------------------------------------------------------------------- void SzSelBrk1::BuildDataDefn(DataDefnBlk & DDB) { DDB.BeginObject(this, Tag(), SzSelBrk1Class.ClassId(), NULL, DDB_OptPage); DDBValueLstMem DDB0; DDB0.Empty(); for (int i=0; i<SD_Defn.NIntervals(); i++) DDB0.Add(i, SD_Defn.GetIntervals(i)->Name()); #if UseManualSizeDefn DDB0.Add(-1, "Manual"); #endif DDB.Long("SizeDefn", "", DC_ , "", xidPartSizeDefn, this, isParm, DDB0()); DDB.Long("Length", "", DC_ , "", xidPartLength, this, isParm); DDB0.Empty(); for (i=0; i<SD_Defn.NDistributions(); i++) DDB0.Add(i, SD_Defn.GetDist(i)->Name()); DDB0.Add(-1, "All"); DDB.Long("ApplyTo", "", DC_ , "", xidApplyToDist, this, isParm, DDB0()); Strng Nm; if (DDB.BeginArray(this, "SZSB", "SZSB", Length())) for (int s=0; s<Length(); s++) if (DDB.BeginElement(this, s)) { //DDB.Double("Size", "", DC_L, "um", &SizePts()[s], this, isParm); DDB.Double("SzRange", "", DC_L, "um", &SizePts()[s], this, DDEF_WRITEPROTECT|noFileAtAll); DDB.Double("Selection", "", DC_Frac, "%", &SB[s][s], this, isParm); for (int d=0; d<s; d++) { Nm.Set("Brk%i", d); DDB.Double(Nm(), "", DC_Frac, "%", &SB[s][d], this, isParm); } } DDB.EndArray(); DDB.EndObject(); } // -------------------------------------------------------------------------- flag SzSelBrk1::DataXchg(DataChangeBlk & DCB) { switch (DCB.lHandle) { case xidPartSizeDefn: if (DCB.rL) SetSizeDefn(Range(-1L, *DCB.rL, SD_Defn.NIntervals()-1L)); DCB.L=iSizeDefn; return 1; case xidApplyToDist: if (DCB.rL) { iApplyToDist=Range(-1L, *DCB.rL, SD_Defn.NDistributions()-1L); SetSizeDefn(iSizeDefn); } DCB.L=iApplyToDist; return 1; case xidPartLength: if (DCB.rL) SetLength(*DCB.rL); DCB.L=Length(); return 1; } return TaggedObject::DataXchg(DCB); } // -------------------------------------------------------------------------- flag SzSelBrk1::ValidateData(ValidateDataBlk & VDB) { //flag OK=true; return true; } // -------------------------------------------------------------------------- char* SzSelBrk1::GetRangeLbl(int i, Strng& Str, flag Ascend, flag Range) { if (Range) { if (fSzAscend) { if (i>=SizePts().GetUpperBound()) { Strng S; PCG.XFmt.FormatFloat(PCG.XCnv.Human(SizePts()[i-1]), S); Str="+"; Str+=S; } else { Strng S; PCG.XFmt.FormatFloat(PCG.XCnv.Human(SizePts()[i]), S); Str="-"; Str+=S; } } else { if (i>0) { Str=""; Strng S; PCG.XFmt.FormatFloat(PCG.XCnv.Human(SizePts()[i-1]), S); Str+="+"; Str+=S; } else { Strng S; PCG.XFmt.FormatFloat(PCG.XCnv.Human(SizePts()[0]), S); Str="-"; Str+=S; } } } else { PCG.XFmt.FormatFloat(PCG.XCnv.Human(SizePts()[i]), Str); } return Str(); } //=========================================================================== // // // //=========================================================================== SzSelBrk1Edt::SzSelBrk1Edt(pFxdEdtView pView_, pSzSelBrk1 pSD_) : FxdEdtBookRef(pView_), PC(*pSD_), PCG(pSD_->PCG) { iNameWidth=4; iWorkDist=0; iPg1=0; //pWrkCnv=NULL; //pWrkFmt=NULL; ObjectAttribute *pAttr=ObjAttributes.FindObject("SzSelBrk1Edt"); if (pAttr) { pAttr->FieldFmtCnvs("Size", PCG.XFmt, PCG.XCnv); pAttr->FieldFmtCnvs("Frac", PCG.YFmt, PCG.YCnv); } } //--------------------------------------------------------------------------- SzSelBrk1Edt::~SzSelBrk1Edt() { ObjectAttribute *pAttr=ObjAttributes.FindObject("SzSelBrk1Edt"); if (pAttr) { pAttr->SetFieldFmt("Size", PCG.XFmt); pAttr->SetFieldCnvs("Size", PCG.XCnv); pAttr->SetFieldFmt("Frac", PCG.YFmt); pAttr->SetFieldCnvs("Frac", PCG.YCnv); } } //--------------------------------------------------------------------------- void SzSelBrk1Edt::PutDataStart() { } //--------------------------------------------------------------------------- void SzSelBrk1Edt::PutDataDone() { } //--------------------------------------------------------------------------- void SzSelBrk1Edt::GetDataStart() { } //--------------------------------------------------------------------------- void SzSelBrk1Edt::GetDataDone() { } //--------------------------------------------------------------------------- void SzSelBrk1Edt::StartBuild() { } //--------------------------------------------------------------------------- void SzSelBrk1Edt::Build() { Strng Tg; Strng S; iPg1=pView->Pages; StartPage("SelBrk"); if (1) // Head Blk { #if UseManualSizeDefn int HedLen=(SD_Defn.NDistributions()>1 ? 3 : 2); #else int HedLen=0; #endif StartBlk(HedLen, 0, NULL); int L=0; #if UseManualSizeDefn int FLen=8; for (int i=0; i<SD_Defn.Intervals.GetSize(); i++) FLen=Max(FLen, SD_Defn.Intervals[i]->NameLength()); SetDParm(L, "SizeDefn", 10, "", Id_PartSizeDefn, FLen, 0, ""); for (i=0; i<SD_Defn.Intervals.GetSize(); i++) FldHasFixedStrValue(i, SD_Defn.Intervals[i]->Name()); FldHasFixedStrValue(-1, "Manual"); SetSpace(L, 5); SetDParm(L, "Length", 10, "", Id_PartLen, 3, 0, ""); L++; if (SD_Defn.NDistributions()>1) { FLen=8; for (i=0; i<SD_Defn.NDistributions(); i++) FLen=Max(FLen, SD_Defn.Distributions[i]->NameLength()); SetDParm(L, "Apply To", 10, "", Id_ApplyToDist, FLen, 0, ""); for (i=0; i<SD_Defn.NDistributions(); i++) FldHasFixedStrValue(i, SD_Defn.Distributions[i]->Name()); FldHasFixedStrValue(-1, "All"); L++; } #endif } int SzRngLen = 10; if (1) // Data Blk { int HedLen=4; StartBlk(Length()+HedLen+2, HedLen, NULL); int L=0; //.. L++; Tg.Set("SzRange(%s)", PCG.XCnv.Text()); SetDesc(L, Tg(), -1, SzRngLen+4, 2, " "); for (int iSz=0; iSz<Length()-1; iSz++) { SetParm(L, "", Id_XIntRange+iSz, 8, 2, ""); Tg.Set("%s.SZSB.[%i].%s", FullObjTag(), Length()-1-iSz, "SzRange"); SetTag(Tg(), PCG.XCnv.Text()); } //.. L++; Tg.Set("Selection (%s)", PCG.YCnv.Text()); SetDesc(L, Tg(), -1, SzRngLen+4, 2, " "); for (iSz=0; iSz<Length()-1; iSz++) { SetParm(L, "", Id_YSelection+iSz, 8, 2, ""); Tg.Set("%s.SZSB.[%i].Selection", FullObjTag(), Length()-1-iSz); SetTag(Tg(), PCG.YCnv.Text()); } //.. L++; for (iSz=0; iSz<Length(); iSz++) { L++; S.Set("%2i", Length()-1-iSz); SetDesc(L, S(), -1 , 4, 3, ""); SetParm(L, "", Id_XIntRng, SzRngLen, 2, " "); Tg.Set("%s.SZSB.[%i].%s", FullObjTag(), Length()-1-iSz, "SzRange"); SetTag(Tg(), PCG.XCnv.Text()); if (iSz==0) { Tg.Set("Breakage (%s)", PCG.YCnv.Text()); SetDesc(L, Tg(), -1, 20, 0, " "); } for (int c=0; c<iSz; c++) { SetParm(L, "", Id_YData+c, 8, 2, ""); Tg.Set("%s.SZSB.[%i].Brk%i", FullObjTag(), Length()-1-c, Length()-1-iSz); SetTag(Tg(), PCG.YCnv.Text()); } } //.. L++; Tg.Set("SzRange(%s)", PCG.XCnv.Text()); SetDesc(L, Tg(), -1, SzRngLen+4, 2, " "); for (iSz=0; iSz<Length()-1; iSz++) { SetParm(L, "", Id_XIntRange+iSz, 8, 2, ""); Tg.Set("%s.SZSB.[%i].%s", FullObjTag(), Length()-1-iSz, "SzRange"); SetTag(Tg(), PCG.XCnv.Text()); } /* //.. Tg.Set("SzRange(%s)", PCG.XCnv.Text()); SetDesc(L, Tg(), -1, SzRngLen+4, 2, " "); SetParm(L, "", Id_YData+1, 8, 2, ""); Tg.Set("%s.[%i].%s", FullObjTag(), Length()-1, "SzRange"); SetTag(Tg(), PCG.XCnv.Text()); SetSpace(L, 10); Tg.Set("Select / Breakage(%s)", PCG.YCnv.Text()); SetDesc(L, Tg(), -1, 20, 0, " "); //.. for (int iSz=0; iSz<Length(); iSz++) { L++; S.Set("%2i", Length()-1-iSz); SetDesc(L, S(), -1 , 4, 3, ""); SetParm(L, "", Id_XIntRng, SzRngLen, 2, " "); Tg.Set("%s.SZSB.[%i].%s", FullObjTag(), Length()-1-iSz, "SzRange"); SetTag(Tg(), PCG.XCnv.Text()); for (int c=0; c<=iSz; c++) { SetParm(L, "", Id_YData+c, 8, 2, ""); if (c==iSz) Tg.Set("%s.SZSB.[%i].Selection", FullObjTag(), Length()-1-iSz); else Tg.Set("%s.SZSB.[%i].Brk%i", FullObjTag(), Length()-1-c, Length()-1-iSz); SetTag(Tg(), PCG.YCnv.Text()); } if (iSz<Length()-1) { SetParm(L, "", Id_YData+iSz+1, 8, 2, ""); S.Set("%2i", Length()-2-iSz); Tg.Set("%s.%s.%s", FullObjTag(), S(), "SzRange"); SetTag(Tg(), PCG.XCnv.Text()); } }*/ } } //--------------------------------------------------------------------------- void SzSelBrk1Edt::Load(FxdEdtInfo &EI, Strng & Str) { if (CurrentBlk(EI)) {//header int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { case Id_PartLen: Str.Set("%i", Length()); EI.Fld->fEditable=PC.UserSizePts(); break; case Id_PartSizeDefn: if (!PC.UserSizePts())//iSizeDefn<SD_Defn.Intervals.GetSize()) Str=SD_Defn.GetIntervals(PC.iSizeDefn)->Name(); else Str="Manual"; break; case Id_ApplyToDist: if (PC.iApplyToDist>=0)//iSizeDefn<SD_Defn.Intervals.GetSize()) Str=SD_Defn.GetDist(PC.iApplyToDist)->Name(); else Str="All"; break; } } if (CurrentBlk(EI)) {//data int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { case Id_XInt : case Id_XIntRng : { if (i<0) { } else { int d=Length()-1-i; PC.GetRangeLbl(d, Str, fSzAscend, EI.FieldId==Id_XIntRng); } EI.Fld->fEditable=PC.UserSizePts(); break; } default: if (EI.FieldId>=Id_YSelection && EI.FieldId<Id_YSelection+MaxColumns) { const int s=Length()-1-(EI.FieldId-Id_YSelection); PCG.YFmt.FormatFloat(PCG.YCnv.Human(PC.SB[s][s]), Str); } else if (EI.FieldId>=Id_XIntRange && EI.FieldId<Id_XIntRange+MaxColumns) { const int d=Length()-1-(EI.FieldId-Id_XIntRange); PC.GetRangeLbl(d, Str, fSzAscend, true); EI.Fld->fEditable=false; } else if (EI.FieldId>=Id_YData && EI.FieldId<Id_YData+Length()) { const int d=Length()-1-i; const int s=Length()-1-(EI.FieldId-Id_YData); PCG.YFmt.FormatFloat(PCG.YCnv.Human(PC.SB[s][d]), Str); } } } } //--------------------------------------------------------------------------- long SzSelBrk1Edt::Parse(FxdEdtInfo &EI, Strng & Str) { long Fix=0; //set Fix=1 to redraw graph if (CurrentBlk(EI)) {//header //bObjModified=1; int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { case Id_PartLen: PC.SetLength(Range(3L,SafeAtoL(Str,5),100L)); View().DoRebuild(); break; case Id_PartSizeDefn: { int i; for (i=SD_Defn.NIntervals()-1; i>=0; i--) if (Str.XStrICmp(SD_Defn.GetIntervals(i)->Name())==0) break; PC.SetSizeDefn(i); // if not found will become Manual (-1) View().DoRebuild(); } break; case Id_ApplyToDist: { int i; for (i=SD_Defn.NDistributions()-1; i>=0; i--) if (Str.XStrICmp(SD_Defn.GetDist(i)->Name())==0) break; PC.SetApplyToDist(i); View().DoRebuild(); } break; } } if (CurrentBlk(EI)) {//data int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); switch (EI.FieldId) { case Id_XInt : PC.SizePts()[i]=PCG.XCnv.Normal(SafeAtoF(Str, 0.0)); break; case Id_XIntRng : PC.SizePts()[i]=PCG.XCnv.Normal(SafeAtoF(Str, 0.0)); break; default: if (EI.FieldId>=Id_YData && EI.FieldId<Id_YData+Length()) { int d=Length()-1-i; int s=Length()-1-(EI.FieldId-Id_YData);//int s=EI.FieldId-Id_YData; PC.SB[s][d]=Range(0.0, PCG.YCnv.Normal(SafeAtoF(Str, 0.0)), 1.0); PC.CheckSB(); View().DoReload(); } else if (EI.FieldId>=Id_YSelection && EI.FieldId<Id_YSelection+Length()) { int s=Length()-1-(EI.FieldId-Id_YSelection); PC.SB[s][s]=Range(0.0, PCG.YCnv.Normal(SafeAtoF(Str, 0.0)), 1.0); //PC.CheckSB(); //View().DoReload(); } } } return Fix; } //--------------------------------------------------------------------------- long SzSelBrk1Edt::ButtonPushed(FxdEdtInfo &EI, Strng & Str) { long Fix=0; //set Fix=1 to redraw graph if (CurrentBlk(EI)) {//header int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); // switch (EI.FieldId) // { // //case Id_DispRetained: // // SetDispRetained(!DispRetained()); // // View().DoRebuild(); // // Fix=1; // // break; // case Id_AutoScale: // SetAutoScale(!AutoScale()); // SetRanges(); // View().DoRebuild(); // Fix=1; // break; // case Id_XLog: // SetXLog(!XLog()); // SetRanges(); // View().DoRebuild(); // Fix=1; // break; // } } if (CurrentBlk(EI)) {//data int p=EI.PageNo; int i=(int)(EI.BlkRowNo-EI.Index); // switch (EI.FieldId) // { // case Id_PartStepped: // SetPartStepped(!PartStepped()); // SetRanges(); // //bShowOther = !bShowOther; // View().DoRebuild(); // Fix=1; // break; // case Id_Cumulative: // SetCumulativeOn(!CumulativeOn()); // SetRanges(); // //bShowOther = !bShowOther; // View().DoRebuild(); // Fix=1; // break; // case Id_Fractional: // SetFractionalOn(!FractionalOn()); // SetRanges(); // //bShowOther = !bShowOther; // View().DoRebuild(); // Fix=1; // break; // } } // // Base Blk // if (CurrentBlk(EI)) // { // int p=EI.PageNo; // int i=(int)(EI.BlkRowNo-EI.Index); // switch (EI.FieldId) // { // case Id_GrOn : // iGraphOn=!iGraphOn; // View().DoRebuild(); // Fix=1; // break; // } // } return Fix; } //--------------------------------------------------------------------------- flag SzSelBrk1Edt::DoLButtonDown(UINT nFlags, CPoint point) { // if (PtInRect(&GraphR, point)) // { // if (nFlags & MK_SHIFT) // iDragPtNo = ClosestPt(point); // return 1; // } return 0; } //--------------------------------------------------------------------------- flag SzSelBrk1Edt::DoLButtonUp(UINT nFlags, CPoint point) { // if (PtInRect(&GraphR, point)) // { // if (iDragPtNo>=0) // { // View().DoReload(); // iDragPtNo = -1; // } // return 1; // } return 0; } //--------------------------------------------------------------------------- flag SzSelBrk1Edt::DoLButtonDblClk(UINT nFlags, CPoint point) { // if (PtInRect(&GraphR, point)) // { // return 1; // } return 0; } //--------------------------------------------------------------------------- flag SzSelBrk1Edt::DoRButtonDown(UINT nFlags, CPoint point) { // if (pView->CPgNo-iPg1>=0 && PtInRect(&GraphR, point)) // { // return 1; // } return 0; } //--------------------------------------------------------------------------- flag SzSelBrk1Edt::DoRButtonUp(UINT nFlags, CPoint point) { // if (pView->CPgNo-iPg1>=0 && PtInRect(&GraphR, point)) // { // return 1; // } FxdEdtView &Vw=View(); flag ret=false;//FxdEdtView::DoRButtonUp(nFlags, point); if (Vw.CPgNo>=0) { FxdEdtInfo EI; if (Vw.LocateFromCR((int)Vw.ChEditPos.x, (int)Vw.ChEditPos.y, EI)) { ret=true; //if (EI.FieldId<0 && EI.Fld) if (EI.Fld) { int nCols=Length(); if (EI.FieldId==Id_XInt || EI.FieldId==Id_XIntRng || EI.FieldId>=Id_XIntRange && EI.FieldId<Id_XIntRange+nCols || EI.FieldId>=Id_YData && EI.FieldId<Id_YData+nCols || EI.FieldId>=Id_YSelection && EI.FieldId<Id_YSelection+nCols) { CRect WRect; Vw.GetWindowRect(&WRect); CPoint RBPoint; RBPoint.x = WRect.left+point.x; RBPoint.y = WRect.top+point.y; if ( (EI.FieldId>=Id_YMode && EI.FieldId<Id_YMode+nCols) ) { //pWrkFmt=NULL; //pWrkCnv=NULL; WrkIB.Set(EI.Fld->Tag); } else if (EI.FieldId==Id_XInt || EI.FieldId==Id_XIntRng || EI.FieldId>=Id_XIntRange && EI.FieldId<Id_XIntRange+nCols) { //pWrkFmt=&PCG.XFmt; //pWrkCnv=&PCG.XCnv; WrkIB.Set(EI.Fld->Tag, &PCG.XCnv, &PCG.XFmt); } else { //int c=(EI.FieldId-Id_YMin)%MaxColumns; //CSD_Column &C=PC.Crvs[c]; //pWrkFmt=C.pFmt; //pWrkCnv=C.pCnv; //pWrkFmt=&PCG.YFmt; //pWrkCnv=&PCG.YCnv; WrkIB.Set(EI.Fld->Tag, &PCG.YCnv, &PCG.YFmt); } CMenu Menu; Menu.CreatePopupMenu(); CMenu FormatMenu; FormatMenu.CreatePopupMenu(); if (WrkIB.FmtOK()) { WrkIB.Fmt().AddToMenu(FormatMenu); CMenu CnvMenu; CnvMenu.CreatePopupMenu(); WrkIB.Cnv().AddToMenu(CnvMenu); Menu.AppendMenu(MF_POPUP, (unsigned int)CnvMenu.m_hMenu, "&Conversions"); if (WrkIB.Cnv().Index()<=0)// || !IsFloatData(d.iType)) Menu.EnableMenuItem(0, MF_BYPOSITION|MF_GRAYED); Menu.AppendMenu(MF_POPUP, (unsigned int)FormatMenu.m_hMenu, "&Format"); Menu.AppendMenu(MF_STRING, pView->iSendToTrend, "Send To &Trend"); Menu.AppendMenu(MF_STRING, pView->iSendToQuickView, "Send To &QuickView"); Menu.AppendMenu(MF_STRING|MF_GRAYED, pView->iSendToQuickView, "Send To &Custom"); Menu.AppendMenu(MF_SEPARATOR); } Menu.AppendMenu(MF_STRING, pView->iCmdCopyTag, "Copy Full &Tag"); if (EI.Fld->Tag==NULL) Menu.EnableMenuItem(pView->iCmdCopyTag, MF_BYCOMMAND|MF_GRAYED); Menu.AppendMenu(MF_STRING, pView->iCmdCopyVal, "Copy &Value"); Menu.TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON, RBPoint.x, RBPoint.y, /*(CWnd*)*/&View()); Menu.DestroyMenu(); } } } } return ret; //return 0; } //--------------------------------------------------------------------------- flag SzSelBrk1Edt::DoRButtonDblClk(UINT nFlags, CPoint point) { // if (pView->CPgNo-iPg1>=0 && PtInRect(&GraphR, point)) // { // return 1; // } return 0; } //--------------------------------------------------------------------------- flag SzSelBrk1Edt::DoMouseMove(UINT nFlags, CPoint point) { // if (GraphOn() && PtInRect(&GraphR, point)) // { // double x,y; // PointtoWP(point, x, y); // char Buff[256], Buff2[256]; // iNameWidth=4; // PCG.XFmt.FormatFloat(PCG.XCnv.Human(x), Buff2, sizeof(Buff2)); // sprintf(Buff, "%*s:%s", iNameWidth, "Size", Buff2); // pLabels->SetText(0, Buff); // pLabels->Show(); // pLabels->Invalidate(); // if (nFlags & MK_LBUTTON) // { // if (nFlags & MK_SHIFT) // { // if (iDragPtNo>=0) // { // //rSD.MovePt(iDragPtNo, x, y); // //rSD.bObjModified = 1; // } // } // else // iDragPtNo = -1; // Wnd(pView).InvalidateRect(&GraphR); // } // return 1; // } // else // { // pLabels->Hide(); // } return 0; } //--------------------------------------------------------------------------- flag SzSelBrk1Edt::DoAccCnv(UINT Id) { pCDataCnv pC=Cnvs[WrkIB.Cnv().Index()]; for (int i=Id; i>0; i--) pC=pC->Next(); if (pC) { WrkIB.Cnv().SetText(pC->Txt()); } View().DoRebuild(); return true; }; //--------------------------------------------------------------------------- flag SzSelBrk1Edt::DoAccFmt(UINT Id) { for (UINT i=0; i<(UINT)DefinedFmts.GetSize(); i++) if (i==Id) break; if (i<(UINT)DefinedFmts.GetSize()) { WrkIB.Fmt()=DefinedFmts[i]; View().DoRebuild(); } return true; }; //--------------------------------------------------------------------------- flag SzSelBrk1Edt::DoAccRptTagLists() { return FxdEdtBookRef::DoAccRptTagLists(); //TagInfoBlk * IB = new TagInfoBlk(WrkIB.ObjClassId(), WrkIB.RefTag(), // WrkIB.CnvOK() ? &WrkIB.Cnv() : NULL, // WrkIB.FmtOK() ? &WrkIB.Fmt() : NULL); //ScdMainWnd()->PostMessage(WMU_ADDTOQUICKVIEW, 0, (long)(IB)); // //return true; }; #endif
[ [ [ 1, 20 ], [ 22, 22 ], [ 24, 51 ], [ 55, 111 ], [ 116, 405 ], [ 407, 463 ], [ 465, 465 ], [ 467, 489 ], [ 491, 491 ], [ 493, 570 ], [ 574, 616 ], [ 618, 645 ], [ 647, 752 ], [ 754, 754 ], [ 783, 1015 ], [ 1019, 1076 ], [ 1086, 1238 ], [ 1240, 1469 ], [ 1472, 1474 ], [ 1476, 1488 ], [ 1491, 1501 ], [ 1503, 1515 ], [ 1518, 1533 ], [ 1536, 1560 ], [ 1563, 1578 ], [ 1581, 1714 ], [ 1716, 1718 ], [ 1756, 1758 ], [ 1854, 1856 ], [ 1869, 1870 ], [ 1882, 1882 ], [ 1894, 1899 ], [ 1904, 2039 ], [ 2041, 2044 ], [ 2046, 2322 ], [ 2329, 2357 ], [ 2359, 2360 ], [ 2362, 2377 ], [ 2379, 2392 ], [ 2394, 2430 ], [ 2433, 2745 ], [ 2751, 2795 ], [ 2797, 2809 ], [ 2811, 2813 ], [ 2815, 2920 ], [ 2922, 2923 ], [ 2925, 2928 ], [ 2932, 2932 ], [ 2935, 2942 ], [ 2945, 2945 ], [ 2947, 2959 ], [ 2961, 2973 ], [ 2975, 2983 ], [ 2985, 2988 ], [ 3037, 3039 ], [ 3044, 3044 ], [ 3046, 3049 ], [ 3051, 3052 ], [ 3054, 3054 ], [ 3057, 3057 ], [ 3062, 3062 ], [ 3081, 3081 ], [ 3093, 3093 ], [ 3119, 3119 ], [ 3123, 3125 ], [ 3149, 3151 ], [ 3154, 3158 ], [ 3160, 3160 ], [ 3163, 3165 ], [ 3192, 3192 ], [ 3203, 3204 ], [ 3219, 3219 ], [ 3246, 3249 ], [ 3251, 3251 ], [ 3256, 3256 ], [ 3298, 3298 ], [ 3314, 3314 ], [ 3322, 3322 ], [ 3336, 3339 ], [ 3357, 3357 ], [ 3359, 3359 ], [ 3361, 3365 ], [ 3367, 3367 ], [ 3370, 3370 ], [ 3372, 3372 ], [ 3377, 3380 ], [ 3382, 3382 ], [ 3385, 3388 ], [ 3390, 3390 ], [ 3399, 3402 ], [ 3437, 3437 ], [ 3440, 3443 ], [ 3446, 3446 ], [ 3450, 3450 ], [ 3526, 3529 ], [ 3531, 3561 ], [ 3566, 3791 ], [ 3793, 3808 ], [ 3810, 3867 ], [ 3869, 3874 ], [ 3876, 3927 ], [ 3971, 4021 ], [ 4026, 4137 ], [ 4139, 4161 ], [ 4163, 4213 ], [ 4259, 4283 ], [ 4286, 4489 ], [ 4506, 4720 ], [ 4722, 4759 ], [ 4762, 4779 ], [ 4781, 5006 ], [ 5008, 5014 ], [ 5028, 5055 ], [ 5057, 5159 ], [ 5161, 5736 ], [ 5738, 6554 ], [ 6556, 6929 ], [ 6931, 7876 ], [ 7878, 7882 ] ], [ [ 21, 21 ], [ 23, 23 ], [ 112, 115 ], [ 464, 464 ], [ 466, 466 ], [ 490, 490 ], [ 492, 492 ], [ 571, 573 ], [ 753, 753 ], [ 755, 782 ], [ 2746, 2750 ], [ 2796, 2796 ], [ 2810, 2810 ], [ 2814, 2814 ], [ 2921, 2921 ], [ 2924, 2924 ], [ 2929, 2931 ], [ 2933, 2934 ], [ 2943, 2944 ], [ 2946, 2946 ], [ 2960, 2960 ], [ 2974, 2974 ], [ 2984, 2984 ], [ 2989, 3036 ], [ 3040, 3043 ], [ 3045, 3045 ], [ 3050, 3050 ], [ 3053, 3053 ], [ 3055, 3056 ], [ 3058, 3061 ], [ 3063, 3080 ], [ 3082, 3092 ], [ 3094, 3118 ], [ 3120, 3122 ], [ 3126, 3148 ], [ 3152, 3153 ], [ 3159, 3159 ], [ 3161, 3162 ], [ 3166, 3191 ], [ 3193, 3202 ], [ 3205, 3218 ], [ 3220, 3245 ], [ 3250, 3250 ], [ 3252, 3255 ], [ 3257, 3297 ], [ 3299, 3313 ], [ 3315, 3321 ], [ 3323, 3335 ], [ 3340, 3356 ], [ 3358, 3358 ], [ 3360, 3360 ], [ 3366, 3366 ], [ 3368, 3369 ], [ 3371, 3371 ], [ 3373, 3376 ], [ 3381, 3381 ], [ 3383, 3384 ], [ 3389, 3389 ], [ 3391, 3398 ], [ 3403, 3436 ], [ 3438, 3439 ], [ 3444, 3445 ], [ 3447, 3449 ], [ 3451, 3525 ], [ 3530, 3530 ], [ 3792, 3792 ], [ 3809, 3809 ], [ 3868, 3868 ], [ 3875, 3875 ], [ 3928, 3970 ], [ 4023, 4023 ], [ 4138, 4138 ], [ 4162, 4162 ], [ 4214, 4258 ], [ 4490, 4505 ], [ 5007, 5007 ], [ 5015, 5027 ] ], [ [ 52, 54 ], [ 406, 406 ], [ 617, 617 ], [ 646, 646 ], [ 1016, 1018 ], [ 1077, 1085 ], [ 1239, 1239 ], [ 1470, 1471 ], [ 1475, 1475 ], [ 1489, 1490 ], [ 1502, 1502 ], [ 1516, 1517 ], [ 1534, 1535 ], [ 1561, 1562 ], [ 1579, 1580 ], [ 1715, 1715 ], [ 1719, 1755 ], [ 1759, 1853 ], [ 1857, 1868 ], [ 1871, 1881 ], [ 1883, 1893 ], [ 1900, 1903 ], [ 2040, 2040 ], [ 2045, 2045 ], [ 2323, 2328 ], [ 2358, 2358 ], [ 2361, 2361 ], [ 2378, 2378 ], [ 2393, 2393 ], [ 2431, 2432 ], [ 3562, 3565 ], [ 4022, 4022 ], [ 4024, 4025 ], [ 4284, 4285 ], [ 4721, 4721 ], [ 4760, 4761 ], [ 4780, 4780 ], [ 5056, 5056 ], [ 5160, 5160 ], [ 5737, 5737 ], [ 6555, 6555 ], [ 6930, 6930 ], [ 7877, 7877 ] ] ]
123b327f3cabeb2a4fe064cc36ce31b71d64fc46
dd7d419eb5bb1158f198a1009b0a4268b05d5a29
/ProyectoGame/Graphics/GraphicManager.cpp
09c8b4bb4413b681fbf360b4512911f0a6219fb5
[]
no_license
carlixyz/galacticinvaders
6cb09540a725357e118a1f4dcd45a2461536561f
1e08405b62846b7909144331fe72452737bc6d7d
refs/heads/master
2018-01-08T16:49:50.443309
2010-06-10T17:51:06
2010-06-10T17:51:06
36,534,643
0
0
null
null
null
null
ISO-8859-1
C++
false
false
4,017
cpp
#include "GraphicManager.h" void cGraphicManager::Init() { // Initializing the Handle mHandle = GetStdHandle(STD_OUTPUT_HANDLE); // Initializing the Backbuffer memset(macBackBuffer,' ',kuiConsoleArea); ShowTheCursor(false); // apagar el cursor //Initializing the color buffer to black and white memset(macColorBuffer, 0x0F,kuiConsoleArea); } void cGraphicManager::Deinit() { ShowTheCursor(true); } void cGraphicManager::ShowTheCursor(bool lbShow) // Mostrar/Ocultar el Cursor { CONSOLE_CURSOR_INFO lCursor; if (GetConsoleCursorInfo(mHandle, &lCursor)) { lCursor.bVisible = lbShow; SetConsoleCursorInfo(mHandle, &lCursor); } } void cGraphicManager::SwapBuffer() { //Initializate the coordinates COORD lCoord = {0, 0}; //Set the position SetConsoleCursorPosition(mHandle, lCoord); //Lock the console LockWindowUpdate(GetConsoleWindow()); // Prepare the vars unsigned luiStart = 0; unsigned char lcColor = macColorBuffer[0]; //For each Characters in the Buffers for (unsigned luiIndex = 1; luiIndex < kuiConsoleArea; ++luiIndex) { // If the color changed if (macColorBuffer[luiIndex] != lcColor){ //Set the color SetConsoleTextAttribute(mHandle, (WORD)lcColor); //Print the Characters DWORD liCount; int liCharacterCount = luiIndex - luiStart; WriteConsole(mHandle, &(macBackBuffer[luiStart]), liCharacterCount, &liCount, NULL); //Update Information luiStart = luiIndex; lcColor = macColorBuffer[ luiIndex]; } } //Set the color SetConsoleTextAttribute(mHandle, (WORD)lcColor); //Print the last chunk DWORD liCount; int liCharacterCount = kuiConsoleArea - luiStart; WriteConsole(mHandle, &(macBackBuffer[luiStart]), liCharacterCount, &liCount, NULL); //Set the position SetConsoleCursorPosition(mHandle,lCoord); //UnLock the console LockWindowUpdate(NULL); } void cGraphicManager::ClearBuffer() { memset(macBackBuffer, ' ', kuiConsoleArea); memset(macColorBuffer, mcCurrentColor, kuiConsoleArea); } void cGraphicManager::WriteChar( unsigned luiX, unsigned luiY, char lChar ) { unsigned luiIndex = luiX + luiY * kuiConsoleDimX; macBackBuffer[luiIndex] = lChar; // asigna un char al indicie con nuestras coordenadas macColorBuffer[luiIndex] = mcCurrentColor ; } void cGraphicManager::WriteChars( unsigned int luiX, unsigned int luiY,const char * lacStr, unsigned int luiLen) { unsigned luiIndex = luiX + luiY * kuiConsoleDimX; //inicia un indice con nuestras coordenadas assert( luiIndex + luiLen < kuiConsoleArea ); // controla que la cadena no séa más grande que el area de la consola memcpy(&(macBackBuffer[luiIndex]), lacStr, luiLen);// copia en la memoria del BackBuffer la cadena en su lugar memset(&(macColorBuffer[luiIndex]), mcCurrentColor, luiLen); } void cGraphicManager::WriteChars(unsigned int luiX, unsigned int luiY,const char *lacStr) { WriteChars(luiX, luiY, lacStr, strlen(lacStr) ); // determina la longitud de la cadena y la pasa al metodo sobrecargado para terminar } void cGraphicManager::SetColor(eColor leFore, eColor leBack) { unsigned char lcForeColor = (unsigned char)leFore; unsigned char lcBackColor = (unsigned char)leBack; lcBackColor <<= 4; mcCurrentColor = (lcForeColor | lcBackColor); } void cGraphicManager::SetForegroundColor(eColor leColor) { //make 0 the old ForeColor unsigned char lcBackColor = (mcCurrentColor & 0xF0); unsigned char lcForeColor = (unsigned char) leColor ; mcCurrentColor = (lcBackColor |lcForeColor); } void cGraphicManager::SetBackgroundColor( eColor leColor) { // Displace the color back color to the right position unsigned char lcBackColor = (unsigned char)leColor << 4; // Make 0 the old background color unsigned char lcForeColor = (mcCurrentColor & 0x0F); mcCurrentColor = (lcBackColor|lcForeColor); }
[ [ [ 1, 138 ] ] ]
fc796af8630b391194f5e302fb4f65bb47684a05
4b0f51aeecddecf3f57a29ffa7a184ae48f1dc61
/CleanProject/Include/GuiManager.h
ae6a2d7adf324b9b82f021176f5b2ff203f33f93
[]
no_license
bahao247/apeengine2
56560dbf6d262364fbc0f9f96ba4231e5e4ed301
f2617b2a42bdf2907c6d56e334c0d027fb62062d
refs/heads/master
2021-01-10T14:04:02.319337
2009-08-26T08:23:33
2009-08-26T08:23:33
45,979,392
0
1
null
null
null
null
ISO-8859-10
C++
false
false
4,212
h
/*! @file @author Pablo Nuņez @date 13/2009 @module *//* This file is part of the Nebula Engine. Nebula 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. Nebula 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 Nebula Engine. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _GUI_TASK_H #define _GUI_TASK_H #include "EnginePrerequisites.h" //enum WindowPosition //{ // ALIGN_TOP_LEFT, // ALIGN_TOP_CENTER, // ALIGN_TOP_RIGHT, // // ALIGN_MIDDLE_LEFT, // ALIGN_MIDDLE, // ALIGN_MIDDLE_RIGHT, // // ALIGN_BOTTOM_LEFT, // ALIGN_BOTTOM, // ALIGN_BOTTOM_RIGHT, //}; namespace Nebula { class Console; class NebulaDllPrivate GuiManager : public ITask, public Ogre::Singleton<GuiManager> { public: GuiManager(); ~GuiManager(); static GuiManager& getSingleton(void); static GuiManager* getSingletonPtr(void); bool start(); void onSuspend(); void update(); void onResume(); void stop(); //Ogre::Vector2 calculateWidgetPosition(Vector2 widgetSize, WindowPosition align); void setWindowCaption(const std::string & _text); void setWallpaper(const std::string & _filename); void setBindings(); void command(const Ogre::UTFString & _key, const Ogre::UTFString & _value); Console* getConsole(); void hideMainMenuItems(); CppEvent2<bool,GameObject*, Ogre::Vector3> eventMouseMovedOverObject; CppEvent2<bool,GameObject*, Ogre::Vector3> eventMouseMovedEnterOverObject; CppEvent2<bool,GameObject*, Ogre::Vector3> eventMouseMovedLeaveOverObject; CppEvent3<bool,GameObject*, Ogre::Vector3, int> eventMousePressedObject; CppEvent3<bool,GameObject*, Ogre::Vector3, int> eventMouseReleasedObject; GameObject* castRayFromMouse(const OIS::MouseEvent &e, OIS::MouseButtonID id, bool mouseButtonDown); GameObject* getMouseSelectedObject() { return mMouseOverObject; } private: MyGUI::Gui *mGUI; Console* mConsole; GameObject* mMouseOverObject; bool mMainMenuVisible; bool mDisplayFPS; bool mDisplayWireFrame; bool mDisplayNodes; MyGUI::StaticImagePtr mBackgroundImage; MyGUI::StaticImagePtr mMenuImage_Play; MyGUI::StaticImagePtr mMenuImage_Load; MyGUI::StaticImagePtr mMenuImage_Save; MyGUI::StaticImagePtr mMenuImage_Options; MyGUI::StaticImagePtr mMenuImage_Exit; void notifyMouseButtonClick_Play(MyGUI::WidgetPtr _sender, int _left, int _top, MyGUI::MouseButton _id); void notifyMouseButtonClick_Load(MyGUI::WidgetPtr _sender, int _left, int _top, MyGUI::MouseButton _id); void notifyMouseButtonClick_Save(MyGUI::WidgetPtr _sender, int _left, int _top, MyGUI::MouseButton _id); void notifyMouseButtonClick_Options(MyGUI::WidgetPtr _sender, int _left, int _top, MyGUI::MouseButton _id); void notifyMouseButtonClick_Exit(MyGUI::WidgetPtr _sender,int _left, int _top, MyGUI::MouseButton _id); unsigned long mhWnd; unsigned int mWidth; unsigned int mHeight; MyGUI::EditPtr mEdit; MyGUI::StaticImagePtr getWallpaper(); bool createConsole(); void setDescriptionText(const Ogre::UTFString & _text); void registerEvents(); bool OnMouseMoved( const OIS::MouseEvent &arg ); bool OnMousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id ); bool OnMouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id ); bool OnKeyPressed( const OIS::KeyEvent &arg ); bool OnKeyReleased( const OIS::KeyEvent &arg ); bool OnWindowResized(Ogre::RenderWindow* rw); bool OnWindowClosed(Ogre::RenderWindow* rw); MyGUI::StaticImagePtr addMainMenuItem(Ogre::String name, Ogre::Vector2 position); }; } //end namespace #endif
[ "pablosn@06488772-1f9a-11de-8b5c-13accb87f508" ]
[ [ [ 1, 145 ] ] ]
4e328486462347dd19cb7f162248787b54caff1c
78fb44a7f01825c19d61e9eaaa3e558ce80dcdf5
/guidriverMyGUIOgre/include/guceMyGUIOgre_CModule.h
78aba2840b18803c1594f46d7bc788dcb68e2798
[]
no_license
LiberatorUSA/GUCE
a2d193e78d91657ccc4eab50fab06de31bc38021
a4d6aa5421f8799cedc7c9f7dc496df4327ac37f
refs/heads/master
2021-01-02T08:14:08.541536
2011-09-08T03:00:46
2011-09-08T03:00:46
41,840,441
0
0
null
null
null
null
UTF-8
C++
false
false
3,759
h
/* * guceMyGUIOgre: glue module for the MyGUI+Ogre GUI backend * Copyright (C) 2002 - 2008. Dinand Vanvelzen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef GUCE_MYGUIOGRE_CMODULE_H #define GUCE_MYGUIOGRE_CMODULE_H /*-------------------------------------------------------------------------// // // // INCLUDES // // // //-------------------------------------------------------------------------*/ #ifndef GUCE_MYGUIOGRE_MACROS_H #include "guceMyGUIOgre_macros.h" /* often used macros */ #define GUCE_MYGUIOGRE_MACROS_H #endif /* GUCE_MYGUIOGRE_MACROS_H ? */ /*-------------------------------------------------------------------------// // // // NAMESPACE // // // //-------------------------------------------------------------------------*/ namespace GUCE { namespace MYGUIOGRE { /*-------------------------------------------------------------------------// // // // CLASSES // // // //-------------------------------------------------------------------------*/ class GUCE_MYGUIOGRE_EXPORT_CPP CModule { public: static bool Load( void ); static bool Unload( void ); private: CModule( void ); CModule( const CModule& src ); ~CModule(); CModule& operator=( const CModule& src ); }; /*-------------------------------------------------------------------------// // // // NAMESPACE // // // //-------------------------------------------------------------------------*/ }; /* namespace MYGUIOGRE */ }; /* namespace GUCE */ /*-------------------------------------------------------------------------*/ #endif /* GUCE_MYGUIOGRE_CMODULE_H ? */ /*-------------------------------------------------------------------------// // // // Info & Changes // // // //-------------------------------------------------------------------------// - 18-08-2007 : - Initial implementation -----------------------------------------------------------------------------*/
[ [ [ 1, 86 ] ] ]
d7674517ff26b5bcf024f004630f239a65a6d672
854ee643a4e4d0b7a202fce237ee76b6930315ec
/arcemu_svn/src/arcemu-world/SpellFixes.cpp
d22bb2d3400e6ca4d9ed92162890c3e67fe0987a
[]
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
205,641
cpp
/* * ArcEmu MMORPG Server * Copyright (C) 2005-2007 Ascent Team <http://www.ascentemu.com/> * Copyright (C) 2008 <http://www.ArcEmu.org/> * * 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" void CreateDummySpell(uint32 id) { const char * name = "Dummy Trigger"; SpellEntry * sp = new SpellEntry; memset(sp, 0, sizeof(SpellEntry)); sp->Id = id; sp->Attributes = 384; sp->AttributesEx = 268435456; sp->AttributesExB = 4; sp->CastingTimeIndex=1; sp->procChance=75; sp->rangeIndex=13; sp->EquippedItemClass=uint32(-1); sp->Effect[0]=3; sp->EffectImplicitTargetA[0]=25; sp->NameHash=crc32((const unsigned char*)name, (unsigned int)strlen(name)); sp->dmg_multiplier[0]=1.0f; sp->StanceBarOrder=-1; dbcSpell.SetRow(id,sp); sWorld.dummyspells.push_back(sp); } void Apply112SpellFixes() { SpellEntry * sp; // Spell 1455 Proc Chance (Life Tap Rank 2) sp = dbcSpell.LookupEntryForced(1455); if(sp != NULL) sp->procChance = 100; // Spell 1456 Proc Chance (Life Tap Rank 3) sp = dbcSpell.LookupEntryForced(1456); if(sp != NULL) sp->procChance = 100; // Spell 3391 Proc Chance (Thrash ) sp = dbcSpell.LookupEntryForced(3391); if(sp != NULL) sp->procChance = 10; // Spell 8033 Proc Chance (Frostbrand Weapon Rank 1) sp = dbcSpell.LookupEntryForced(8033); if(sp != NULL) sp->procChance = 10; // Spell 8034 Proc Chance (Frostbrand Attack Rank 1) sp = dbcSpell.LookupEntryForced(8034); if(sp != NULL) sp->procChance = 10; // Spell 8037 Proc Chance (Frostbrand Attack Rank 2) sp = dbcSpell.LookupEntryForced(8037); if(sp != NULL) sp->procChance = 10; // Spell 8182 Proc Chance (Frost Resistance Rank 1) sp = dbcSpell.LookupEntryForced(8182); if(sp != NULL) sp->procChance = 100; // Spell 8185 Proc Chance (Fire Resistance Rank 1) sp = dbcSpell.LookupEntryForced(8185); if(sp != NULL) sp->procChance = 100; // Spell 8516 Proc Chance (Windfury Totem Rank 1) sp = dbcSpell.LookupEntryForced(8516); if(sp != NULL) sp->procChance = 10; // Spell 10456 Proc Chance (Frostbrand Weapon Rank 3) sp = dbcSpell.LookupEntryForced(10456); if(sp != NULL) sp->procChance = 10; // Spell 10458 Proc Chance (Frostbrand Attack Rank 3) sp = dbcSpell.LookupEntryForced(10458); if(sp != NULL) sp->procChance = 10; // Spell 10476 Proc Chance (Frost Resistance Rank 2) sp = dbcSpell.LookupEntryForced(10476); if(sp != NULL) sp->procChance = 100; // Spell 10477 Proc Chance (Frost Resistance Rank 3) sp = dbcSpell.LookupEntryForced(10477); if(sp != NULL) sp->procChance = 100; // Spell 10534 Proc Chance (Fire Resistance Rank 2) sp = dbcSpell.LookupEntryForced(10534); if(sp != NULL) sp->procChance = 100; // Spell 10535 Proc Chance (Fire Resistance Rank 3) sp = dbcSpell.LookupEntryForced(10535); if(sp != NULL) sp->procChance = 100; // Spell 10608 Proc Chance (Windfury Totem Rank 2) sp = dbcSpell.LookupEntryForced(10608); if(sp != NULL) sp->procChance = 10; // Spell 10610 Proc Chance (Windfury Totem Rank 3) sp = dbcSpell.LookupEntryForced(10610); if(sp != NULL) sp->procChance = 10; // Spell 11175 Group Relation (Permafrost Rank 1) sp = dbcSpell.LookupEntryForced(11175); if(sp != NULL) { sp->EffectMiscValue[1] = SMT_MISC_EFFECT; } // Spell 11687 Proc Chance (Life Tap Rank 4) sp = dbcSpell.LookupEntryForced(11687); if(sp != NULL) sp->procChance = 100; // Spell 11688 Proc Chance (Life Tap Rank 5) sp = dbcSpell.LookupEntryForced(11688); if(sp != NULL) sp->procChance = 100; // Spell 11689 Proc Chance (Life Tap Rank 6) sp = dbcSpell.LookupEntryForced(11689); if(sp != NULL) sp->procChance = 100; // Spell 12284 Proc Chance (Mace Specialization Rank 1) sp = dbcSpell.LookupEntryForced(12284); if(sp != NULL) sp->procChance = 1; // Spell 12292 Proc Chance (Death Wish ) sp = dbcSpell.LookupEntryForced(12292); if(sp != NULL) sp->procChance = 100; // Spell 12322 Proc Chance (Unbridled Wrath Rank 1) sp = dbcSpell.LookupEntryForced(12322); if(sp != NULL) sp->procChance = 8; // Spell 12569 Group Relation (Permafrost Rank 2) sp = dbcSpell.LookupEntryForced(12569); if(sp != NULL) { sp->EffectMiscValue[1] = SMT_MISC_EFFECT; } // Spell 12571 Group Relation (Permafrost Rank 3) sp = dbcSpell.LookupEntryForced(12571); if(sp != NULL) { sp->EffectMiscValue[1] = SMT_MISC_EFFECT; } // Spell 23689 Proc Chance (Darkmoon Card: Heroism) sp = dbcSpell.LookupEntryForced(23689); if(sp != NULL) sp->procChance = 10; // Spell 12701 Proc Chance (Mace Specialization Rank 2) sp = dbcSpell.LookupEntryForced(12701); if(sp != NULL) sp->procChance = 2; // Spell 12702 Proc Chance (Mace Specialization Rank 3) sp = dbcSpell.LookupEntryForced(12702); if(sp != NULL) sp->procChance = 3; // Spell 12703 Proc Chance (Mace Specialization Rank 4) sp = dbcSpell.LookupEntryForced(12703); if(sp != NULL) sp->procChance = 4; // Spell 12704 Proc Chance (Mace Specialization Rank 5) sp = dbcSpell.LookupEntryForced(12704); if(sp != NULL) sp->procChance = 6; // Spell 12999 Proc Chance (Unbridled Wrath Rank 2) sp = dbcSpell.LookupEntryForced(12999); if(sp != NULL) sp->procChance = 16; // Spell 13000 Proc Chance (Unbridled Wrath Rank 3) sp = dbcSpell.LookupEntryForced(13000); if(sp != NULL) sp->procChance = 24; // Spell 13001 Proc Chance (Unbridled Wrath Rank 4) sp = dbcSpell.LookupEntryForced(13001); if(sp != NULL) sp->procChance = 32; // Spell 13002 Proc Chance (Unbridled Wrath Rank 5) sp = dbcSpell.LookupEntryForced(13002); if(sp != NULL) sp->procChance = 40; // Spell 14076 Proc Chance (Dirty Tricks Rank 1) sp = dbcSpell.LookupEntryForced(14076); if(sp != NULL) sp->procChance = 30; // Spell 14094 Proc Chance (Dirty Tricks Rank 2) sp = dbcSpell.LookupEntryForced(14094); if(sp != NULL) sp->procChance = 60; // Spell 14177 Group Relation\Interrupt Flag (Cold Blood ) sp = dbcSpell.LookupEntryForced(14177); if(sp != NULL) { sp->AuraInterruptFlags = AURA_INTERRUPT_ON_AFTER_CAST_SPELL; } // Spell 15494 Proc Chance (Fury of Forgewright ) sp = dbcSpell.LookupEntryForced(15494); if(sp != NULL) sp->procChance = 10; // Spell 15600 Proc Chance (Hand of Justice ) sp = dbcSpell.LookupEntryForced(15600); if(sp != NULL) sp->procChance = 2; // Spell 15601 Proc Chance (Hand of Justice ) sp = dbcSpell.LookupEntryForced(15601); if(sp != NULL) sp->procChance = 10; // Spell 15642 Proc Chance (Ironfoe ) sp = dbcSpell.LookupEntryForced(15642); if(sp != NULL) sp->procChance = 10; // Spell 16246 Group Relation (Clearcasting ) sp = dbcSpell.LookupEntryForced(16246); if(sp != NULL) { sp->procCharges = 3; // Should be 2 but now 1 is used when spell triggers leaving 2 sp->procFlags = PROC_ON_CAST_SPELL; } // Spell 16352 Proc Chance (Frostbrand Attack Rank 4) sp = dbcSpell.LookupEntryForced(16352); if(sp != NULL) sp->procChance = 10; // Spell 16353 Proc Chance (Frostbrand Attack Rank 5) sp = dbcSpell.LookupEntryForced(16353); if(sp != NULL) sp->procChance = 10; // Spell 16355 Proc Chance (Frostbrand Weapon Rank 4) sp = dbcSpell.LookupEntryForced(16355); if(sp != NULL) sp->procChance = 10; // Spell 16356 Proc Chance (Frostbrand Weapon Rank 5) sp = dbcSpell.LookupEntryForced(16356); if(sp != NULL) sp->procChance = 10; // Spell 16459 Proc Chance (Sword Specialization ) sp = dbcSpell.LookupEntryForced(16459); if(sp != NULL) sp->procChance = 10; // Spell 16843 Proc Chance (Crimson Fury ) sp = dbcSpell.LookupEntryForced(16843); if(sp != NULL) sp->procChance = 10; // Spell 16850 Proc Chance (Celestial Focus Rank 1) sp = dbcSpell.LookupEntryForced(16850); if(sp != NULL) sp->procChance = 3; // Spell 16923 Proc Chance (Celestial Focus Rank 2) sp = dbcSpell.LookupEntryForced(16923); if(sp != NULL) sp->procChance = 6; // Spell 16924 Proc Chance (Celestial Focus Rank 3) sp = dbcSpell.LookupEntryForced(16924); if(sp != NULL) sp->procChance = 9; // Spell 18797 Proc Chance (Flurry Axe ) sp = dbcSpell.LookupEntryForced(18797); if(sp != NULL) sp->procChance = 10; // Spell 18803 Proc Chance (Focus ) sp = dbcSpell.LookupEntryForced(18803); if(sp != NULL) sp->procChance = 100; // Spell 19105 Proc Chance (MHTest01 Effect ) sp = dbcSpell.LookupEntryForced(19105); if(sp != NULL) sp->procChance = 10; // Spell 19109 Proc Chance (MHTest02 Effect ) sp = dbcSpell.LookupEntryForced(19109); if(sp != NULL) sp->procChance = 10; // Spell 19184 Proc Chance (Entrapment Rank 1) sp = dbcSpell.LookupEntryForced(19184); if(sp != NULL) sp->procChance = 5; // Spell 19228 Proc Chance (Improved Wing Clip Rank 1) sp = dbcSpell.LookupEntryForced(19228); if(sp != NULL) sp->procChance = 4; // Spell 19232 Proc Chance (Improved Wing Clip Rank 2) sp = dbcSpell.LookupEntryForced(19232); if(sp != NULL) sp->procChance = 8; // Spell 19233 Proc Chance (Improved Wing Clip Rank 3) sp = dbcSpell.LookupEntryForced(19233); if(sp != NULL) sp->procChance = 12; // Spell 19387 Proc Chance (Entrapment Rank 2) sp = dbcSpell.LookupEntryForced(19387); if(sp != NULL) sp->procChance = 10; // Spell 19388 Proc Chance (Entrapment Rank 3) sp = dbcSpell.LookupEntryForced(19388); if(sp != NULL) sp->procChance = 15; // Spell 20178 Proc Chance (Reckoning ) sp = dbcSpell.LookupEntryForced(20178); if(sp != NULL) sp->procChance = 10; // Spell 21919 Proc Chance (Thrash ) sp = dbcSpell.LookupEntryForced(21919); if(sp != NULL) sp->procChance = 10; // Spell 23158 Proc Chance (Concussive Shot Cooldown Reduction ) sp = dbcSpell.LookupEntryForced(23158); if(sp != NULL) sp->procChance = 4; // Spell 26022 Proc Chance (Pursuit of Justice Rank 1) sp = dbcSpell.LookupEntryForced(26022); if(sp != NULL) sp->procChance = 100; // Spell 26023 Proc Chance (Pursuit of Justice Rank 2) sp = dbcSpell.LookupEntryForced(26023); if(sp != NULL) sp->procChance = 100; // Spell 27035 Proc Chance (Sword Specialization (OLD) ) sp = dbcSpell.LookupEntryForced(27035); if(sp != NULL) sp->procChance = 10; // Spell 27521 Proc Chance (Mana Restore ) sp = dbcSpell.LookupEntryForced(27521); if(sp != NULL) sp->procChance = 2; // Spell 27867 Proc Chance (Freeze ) sp = dbcSpell.LookupEntryForced(27867); if(sp != NULL) sp->procChance = 2; // Spell 25500 Proc Chance (Frostbrand Weapon Rank 6) sp = dbcSpell.LookupEntryForced(25500); if(sp != NULL) sp->procChance = 10; // Spell 25501 Proc Chance (Frostbrand Attack Rank 6) sp = dbcSpell.LookupEntryForced(25501); if(sp != NULL) sp->procChance = 10; // Spell 38617 Proc Chance (Frostbrand Attack ) sp = dbcSpell.LookupEntryForced(38617); if(sp != NULL) sp->procChance = 10; } void ApplyNormalFixes() { //Updating spell.dbc Log.Notice("World", "Processing %u spells...", dbcSpell.GetNumRows()); Apply112SpellFixes(); uint32 cnt = dbcSpell.GetNumRows(); uint32 All_Seal_Groups_Combined=0; // Relation Groups map<uint32, uint32> talentSpells; map<uint32,uint32>::iterator talentSpellIterator; unsigned int i,j; for(i = 0; i < dbcTalent.GetNumRows(); ++i) { TalentEntry * tal = dbcTalent.LookupRow(i); for(j = 0; j < 5; ++j) if(tal->RankID[j] != 0) talentSpells.insert(make_pair(tal->RankID[j], tal->TalentTree)); } for(uint32 x=0; x < cnt; x++) { // Read every SpellEntry row SpellEntry * sp = dbcSpell.LookupRow(x); uint32 rank = 0; uint32 namehash = 0; sp->self_cast_only = false; sp->apply_on_shapeshift_change = false; sp->always_apply = false; // hash the name //!!!!!!! representing all strings on 32 bits is dangerous. There is a chance to get same hash for a lot of strings ;) namehash = crc32((const unsigned char*)sp->Name, (unsigned int)strlen(sp->Name)); sp->NameHash = namehash; //need these set before we start processing spells float radius=std::max(::GetRadius(dbcSpellRadius.LookupEntry(sp->EffectRadiusIndex[0])),::GetRadius(dbcSpellRadius.LookupEntry(sp->EffectRadiusIndex[1]))); radius=std::max(::GetRadius(dbcSpellRadius.LookupEntry(sp->EffectRadiusIndex[2])),radius); radius=std::max(GetMaxRange(dbcSpellRange.LookupEntry(sp->rangeIndex)),radius); sp->base_range_or_radius_sqr = radius*radius; sp->ai_target_type = GetAiTargetType( sp ); // NEW SCHOOLS AS OF 2.4.0: /* (bitwise) SCHOOL_NORMAL = 1, SCHOOL_HOLY = 2, SCHOOL_FIRE = 4, SCHOOL_NATURE = 8, SCHOOL_FROST = 16, SCHOOL_SHADOW = 32, SCHOOL_ARCANE = 64 */ // Save School as SchoolMask, and set School as an index sp->SchoolMask = sp->School; for (i=0; i<8; i++) { if (sp->School & (1<<i)) { sp->School = i; break; } } /* AURASTATE_FLAG_DODGE_BLOCK = 1, //1 AURASTATE_FLAG_HEALTH20 = 2, //2 AURASTATE_FLAG_BERSERK = 4, //3 AURASTATE_FLAG_JUDGEMENT = 16, //5 AURASTATE_FLAG_PARRY = 64, //7 AURASTATE_FLAG_LASTKILLWITHHONOR = 512, //10 AURASTATE_FLAG_CRITICAL = 1024, //11 AURASTATE_FLAG_HEALTH35 = 4096, //13 AURASTATE_FLAG_IMMOLATE = 8192, //14 AURASTATE_FLAG_REJUVENATE = 16384, //15 //where do i use this ? AURASTATE_FLAG_POISON = 32768, //16 */ // correct caster aura state if( sp->CasterAuraState != 0 ) { switch( sp->CasterAuraState ) { case 1: sp->CasterAuraState = AURASTATE_FLAG_DODGE_BLOCK; break; case 2: sp->CasterAuraState = AURASTATE_FLAG_HEALTH20; break; case 3: sp->CasterAuraState = AURASTATE_FLAG_BERSERK; break; case 5: sp->CasterAuraState = AURASTATE_FLAG_JUDGEMENT; break; case 7: sp->CasterAuraState = AURASTATE_FLAG_PARRY; break; case 10: sp->CasterAuraState = AURASTATE_FLAG_LASTKILLWITHHONOR; break; case 11: sp->CasterAuraState = AURASTATE_FLAG_CRITICAL; break; case 13: sp->CasterAuraState = AURASTATE_FLAG_HEALTH35; break; case 14: sp->CasterAuraState = AURASTATE_FLAG_IMMOLATE; break; case 15: sp->CasterAuraState = AURASTATE_FLAG_REJUVENATE; break; case 16: sp->CasterAuraState = AURASTATE_FLAG_POISON; break; default: Log.Error("AuraState", "Spell %u (%s) has unknown caster aura state %u\n", sp->Id, sp->Name, sp->CasterAuraState); break; } } if( sp->TargetAuraState != 0 ) { switch( sp->TargetAuraState ) { case 1: sp->TargetAuraState = AURASTATE_FLAG_DODGE_BLOCK; break; case 2: sp->TargetAuraState = AURASTATE_FLAG_HEALTH20; break; case 3: sp->TargetAuraState = AURASTATE_FLAG_BERSERK; break; case 5: sp->TargetAuraState = AURASTATE_FLAG_JUDGEMENT; break; case 7: sp->TargetAuraState = AURASTATE_FLAG_PARRY; break; case 10: sp->TargetAuraState = AURASTATE_FLAG_LASTKILLWITHHONOR; break; case 11: sp->TargetAuraState = AURASTATE_FLAG_CRITICAL; break; case 13: sp->TargetAuraState = AURASTATE_FLAG_HEALTH35; break; case 14: sp->TargetAuraState = AURASTATE_FLAG_IMMOLATE; break; case 15: sp->TargetAuraState = AURASTATE_FLAG_REJUVENATE; break; case 16: sp->TargetAuraState = AURASTATE_FLAG_POISON; break; default: Log.Error("AuraState", "Spell %u (%s) has unknown target aura state %u\n", sp->Id, sp->Name, sp->TargetAuraState); break; } } // apply on shapeshift change if( sp->NameHash == SPELL_HASH_TRACK_HUMANOIDS ) sp->apply_on_shapeshift_change = true; if( sp->NameHash == SPELL_HASH_BLOOD_FURY || sp->NameHash == SPELL_HASH_SHADOWSTEP ) sp->always_apply = true; //there are some spells that change the "damage" value of 1 effect to another : devastate = bonus first then damage //this is a total bullshit so remove it when spell system supports effect overwriting for( uint32 col1_swap = 0; col1_swap < 2 ; col1_swap++ ) for( uint32 col2_swap = col1_swap ; col2_swap < 3 ; col2_swap++ ) if( sp->Effect[col1_swap] == SPELL_EFFECT_WEAPON_PERCENT_DAMAGE && sp->Effect[col2_swap] == SPELL_EFFECT_DUMMYMELEE ) { uint32 temp; float ftemp; temp = sp->Effect[col1_swap]; sp->Effect[col1_swap] = sp->Effect[col2_swap] ; sp->Effect[col2_swap] = temp; temp = sp->EffectDieSides[col1_swap]; sp->EffectDieSides[col1_swap] = sp->EffectDieSides[col2_swap] ; sp->EffectDieSides[col2_swap] = temp; temp = sp->EffectBaseDice[col1_swap]; sp->EffectBaseDice[col1_swap] = sp->EffectBaseDice[col2_swap] ; sp->EffectBaseDice[col2_swap] = temp; ftemp = sp->EffectDicePerLevel[col1_swap]; sp->EffectDicePerLevel[col1_swap] = sp->EffectDicePerLevel[col2_swap] ; sp->EffectDicePerLevel[col2_swap] = ftemp; ftemp = sp->EffectRealPointsPerLevel[col1_swap]; sp->EffectRealPointsPerLevel[col1_swap] = sp->EffectRealPointsPerLevel[col2_swap] ; sp->EffectRealPointsPerLevel[col2_swap] = ftemp; temp = sp->EffectBasePoints[col1_swap]; sp->EffectBasePoints[col1_swap] = sp->EffectBasePoints[col2_swap] ; sp->EffectBasePoints[col2_swap] = temp; temp = sp->EffectMechanic[col1_swap]; sp->EffectMechanic[col1_swap] = sp->EffectMechanic[col2_swap] ; sp->EffectMechanic[col2_swap] = temp; temp = sp->EffectImplicitTargetA[col1_swap]; sp->EffectImplicitTargetA[col1_swap] = sp->EffectImplicitTargetA[col2_swap] ; sp->EffectImplicitTargetA[col2_swap] = temp; temp = sp->EffectImplicitTargetB[col1_swap]; sp->EffectImplicitTargetB[col1_swap] = sp->EffectImplicitTargetB[col2_swap] ; sp->EffectImplicitTargetB[col2_swap] = temp; temp = sp->EffectRadiusIndex[col1_swap]; sp->EffectRadiusIndex[col1_swap] = sp->EffectRadiusIndex[col2_swap] ; sp->EffectRadiusIndex[col2_swap] = temp; temp = sp->EffectApplyAuraName[col1_swap]; sp->EffectApplyAuraName[col1_swap] = sp->EffectApplyAuraName[col2_swap] ; sp->EffectApplyAuraName[col2_swap] = temp; temp = sp->EffectAmplitude[col1_swap]; sp->EffectAmplitude[col1_swap] = sp->EffectAmplitude[col2_swap] ; sp->EffectAmplitude[col2_swap] = temp; ftemp = sp->Effectunknown[col1_swap]; sp->Effectunknown[col1_swap] = sp->Effectunknown[col2_swap] ; sp->Effectunknown[col2_swap] = ftemp; temp = sp->EffectChainTarget[col1_swap]; sp->EffectChainTarget[col1_swap] = sp->EffectChainTarget[col2_swap] ; sp->EffectChainTarget[col2_swap] = temp; temp = sp->EffectMiscValue[col1_swap]; sp->EffectMiscValue[col1_swap] = sp->EffectMiscValue[col2_swap] ; sp->EffectMiscValue[col2_swap] = temp; temp = sp->EffectTriggerSpell[col1_swap]; sp->EffectTriggerSpell[col1_swap] = sp->EffectTriggerSpell[col2_swap] ; sp->EffectTriggerSpell[col2_swap] = temp; ftemp = sp->EffectPointsPerComboPoint[col1_swap]; sp->EffectPointsPerComboPoint[col1_swap] = sp->EffectPointsPerComboPoint[col2_swap] ; sp->EffectPointsPerComboPoint[col2_swap] = ftemp; } for(uint32 b=0;b<3;++b) { if(sp->EffectTriggerSpell[b] != 0 && dbcSpell.LookupEntryForced(sp->EffectTriggerSpell[b]) == NULL) { /* proc spell referencing non-existant spell. create a dummy spell for use w/ it. */ CreateDummySpell(sp->EffectTriggerSpell[b]); } /** Load teaching spells (used for hunters when learning pets wild abilities) */ if(sp->Effect[b]==SPELL_EFFECT_LEARN_SPELL && sp->EffectImplicitTargetA[b]==EFF_TARGET_PET) { map<uint32,uint32>::iterator itr = sWorld.TeachingSpellMap.find(sp->EffectTriggerSpell[b]); if(itr == sWorld.TeachingSpellMap.end()) sWorld.TeachingSpellMap.insert(make_pair(sp->EffectTriggerSpell[b],sp->Id)); } if( sp->Attributes & ATTRIBUTES_ONLY_OUTDOORS && sp->EffectApplyAuraName[b] == SPELL_AURA_MOUNTED ) { sp->Attributes &= ~ATTRIBUTES_ONLY_OUTDOORS; } // fill in more here /*switch( sp->EffectImplicitTargetA[b] ) { case 1: case 9: sp->self_cast_only = true; break; } // fill in more here too switch( sp->EffectImplicitTargetB[b] ) { case 1: case 9: sp->self_cast_only = true; break; }*/ } /*if(sp->self_cast_only && !(sp->Attributes&64)) printf("SPELL SELF CAST ONLY: %s %u\n", sp->Name, sp->Id);*/ if(!strcmp(sp->Name, "Hearthstone") || !strcmp(sp->Name, "Stuck") || !strcmp(sp->Name, "Astral Recall")) sp->self_cast_only = true; sp->proc_interval = 0;//trigger at each event sp->c_is_flags = 0; sp->spell_coef_flags = 0; sp->Dspell_coef_override = -1; sp->OTspell_coef_override = -1; sp->casttime_coef = 0; sp->fixed_dddhcoef = -1; sp->fixed_hotdotcoef = -1; talentSpellIterator = talentSpells.find(sp->Id); if(talentSpellIterator == talentSpells.end()) sp->talent_tree = 0; else sp->talent_tree = talentSpellIterator->second; // parse rank text if( !sscanf( sp->Rank, "Rank %d", (unsigned int*)&rank) ) rank = 0; //seal of light if( namehash == SPELL_HASH_SEAL_OF_LIGHT ) sp->procChance = 45; /* this will do */ //seal of command else if( namehash == SPELL_HASH_SEAL_OF_COMMAND ) sp->Spell_Dmg_Type = SPELL_DMG_TYPE_MAGIC; //judgement of command else if( namehash == SPELL_HASH_JUDGEMENT_OF_COMMAND ) sp->Spell_Dmg_Type = SPELL_DMG_TYPE_MAGIC; else if( namehash == SPELL_HASH_ARCANE_SHOT ) sp->c_is_flags |= SPELL_FLAG_IS_NOT_USING_DMG_BONUS; else if( namehash == SPELL_HASH_SERPENT_STING ) sp->c_is_flags |= SPELL_FLAG_IS_NOT_USING_DMG_BONUS; //Rogue: Posion time fix for 2.3 if( strstr( sp->Name, "Crippling Poison") && sp->Effect[0] == 54 ) //I, II sp->EffectBasePoints[0] = 3599; if( strstr( sp->Name, "Mind-numbing Poison") && sp->Effect[0] == 54 ) //I,II,III sp->EffectBasePoints[0] = 3599; if( strstr( sp->Name, "Instant Poison") && sp->Effect[0] == 54 ) //I,II,III,IV,V,VI,VII sp->EffectBasePoints[0] = 3599; if( strstr( sp->Name, "Deadly Poison") && sp->Effect[0] == 54 ) //I,II,III,IV,V,VI,VII sp->EffectBasePoints[0] = 3599; if( strstr( sp->Name, "Wound Poison") && sp->Effect[0] == 54 ) //I,II,III,IV,V sp->EffectBasePoints[0] = 3599; if( strstr( sp->Name, "Anesthetic Poison") && sp->Effect[0] == 54 ) //I sp->EffectBasePoints[0] = 3599; if( strstr( sp->Name, "Sharpen Blade") && sp->Effect[0] == 54 ) //All BS stones sp->EffectBasePoints[0] = 3599; //these mostly do not mix so we can use else // look for seal, etc in name if( strstr( sp->Name, "Seal")) { sp->BGR_one_buff_on_target |= SPELL_TYPE_SEAL; All_Seal_Groups_Combined |= sp->SpellGroupType; } else if( strstr( sp->Name, "Blessing")) sp->BGR_one_buff_on_target |= SPELL_TYPE_BLESSING; else if( strstr( sp->Name, "Curse")) sp->BGR_one_buff_on_target |= SPELL_TYPE_CURSE; else if( strstr( sp->Name, "Corruption")) sp->BGR_one_buff_on_target |= SPELL_TYPE_CORRUPTION; else if( strstr( sp->Name, "Aspect")) sp->BGR_one_buff_on_target |= SPELL_TYPE_ASPECT; else if( strstr( sp->Name, "Sting") || strstr( sp->Name, "sting")) sp->BGR_one_buff_on_target |= SPELL_TYPE_STING; // don't break armor items! else if(strstr( sp->Name, "Fel Armor") || strstr( sp->Name, "Frost Armor") || strstr( sp->Name, "Ice Armor") || strstr( sp->Name, "Mage Armor") || strstr( sp->Name, "Molten Armor") || strstr( sp->Name, "Demon Skin") || strstr( sp->Name, "Demon Armor")) sp->BGR_one_buff_on_target |= SPELL_TYPE_ARMOR; else if( strstr( sp->Name, "Aura") && !strstr( sp->Name, "Trueshot") && !strstr( sp->Name, "Moonkin") && !strstr( sp->Name, "Crusader") && !strstr( sp->Name, "Sanctity") && !strstr( sp->Name, "Devotion") && !strstr( sp->Name, "Retribution") && !strstr( sp->Name, "Concentration") && !strstr( sp->Name, "Shadow Resistance") && !strstr( sp->Name, "Frost Resistance") && !strstr( sp->Name, "Fire Resistance") ) sp->BGR_one_buff_on_target |= SPELL_TYPE_AURA; else if( strstr( sp->Name, "Track")==sp->Name) sp->BGR_one_buff_on_target |= SPELL_TYPE_TRACK; else if( namehash == SPELL_HASH_GIFT_OF_THE_WILD || namehash == SPELL_HASH_MARK_OF_THE_WILD ) sp->BGR_one_buff_on_target |= SPELL_TYPE_MARK_GIFT; else if( namehash == SPELL_HASH_IMMOLATION_TRAP || namehash == SPELL_HASH_FREEZING_TRAP || namehash == SPELL_HASH_FROST_TRAP || namehash == SPELL_HASH_EXPLOSIVE_TRAP || namehash == SPELL_HASH_SNAKE_TRAP ) sp->BGR_one_buff_on_target |= SPELL_TYPE_HUNTER_TRAP; else if( namehash == SPELL_HASH_ARCANE_INTELLECT || namehash == SPELL_HASH_ARCANE_BRILLIANCE ) sp->BGR_one_buff_on_target |= SPELL_TYPE_MAGE_INTEL; else if( namehash == SPELL_HASH_AMPLIFY_MAGIC || namehash == SPELL_HASH_DAMPEN_MAGIC ) sp->BGR_one_buff_on_target |= SPELL_TYPE_MAGE_MAGI; else if( namehash == SPELL_HASH_FIRE_WARD || namehash == SPELL_HASH_FROST_WARD ) sp->BGR_one_buff_on_target |= SPELL_TYPE_MAGE_WARDS; else if( namehash == SPELL_HASH_SHADOW_PROTECTION || namehash == SPELL_HASH_PRAYER_OF_SHADOW_PROTECTION ) sp->BGR_one_buff_on_target |= SPELL_TYPE_PRIEST_SH_PPROT; else if( namehash == SPELL_HASH_WATER_SHIELD || namehash == SPELL_HASH_EARTH_SHIELD || namehash == SPELL_HASH_LIGHTNING_SHIELD ) sp->BGR_one_buff_on_target |= SPELL_TYPE_SHIELD; else if( namehash == SPELL_HASH_POWER_WORD__FORTITUDE || namehash == SPELL_HASH_PRAYER_OF_FORTITUDE ) sp->BGR_one_buff_on_target |= SPELL_TYPE_FORTITUDE; else if( namehash == SPELL_HASH_DIVINE_SPIRIT || namehash == SPELL_HASH_PRAYER_OF_SPIRIT ) sp->BGR_one_buff_on_target |= SPELL_TYPE_SPIRIT; // else if( strstr( sp->Name, "Curse of Weakness") || strstr( sp->Name, "Curse of Agony") || strstr( sp->Name, "Curse of Recklessness") || strstr( sp->Name, "Curse of Tongues") || strstr( sp->Name, "Curse of the Elements") || strstr( sp->Name, "Curse of Idiocy") || strstr( sp->Name, "Curse of Shadow") || strstr( sp->Name, "Curse of Doom")) // else if(namehash==4129426293 || namehash==885131426 || namehash==626036062 || namehash==3551228837 || namehash==2784647472 || namehash==776142553 || namehash==3407058720 || namehash==202747424) // else if( strstr( sp->Name, "Curse of ")) // type |= SPELL_TYPE_WARLOCK_CURSES; else if( strstr( sp->Name, "Immolate") || strstr( sp->Name, "Conflagrate")) sp->BGR_one_buff_on_target |= SPELL_TYPE_WARLOCK_IMMOLATE; else if( strstr( sp->Name, "Amplify Magic") || strstr( sp->Name, "Dampen Magic")) sp->BGR_one_buff_on_target |= SPELL_TYPE_MAGE_AMPL_DUMP; else if( strstr( sp->Description, "Battle Elixir")) sp->BGR_one_buff_on_target |= SPELL_TYPE_ELIXIR_BATTLE; else if( strstr( sp->Description, "Guardian Elixir")) sp->BGR_one_buff_on_target |= SPELL_TYPE_ELIXIR_GUARDIAN; else if( strstr( sp->Description, "Battle and Guardian elixir")) sp->BGR_one_buff_on_target |= SPELL_TYPE_ELIXIR_FLASK; else if( namehash == SPELL_HASH_HUNTER_S_MARK ) // hunter's mark sp->BGR_one_buff_on_target |= SPELL_TYPE_HUNTER_MARK; else if( namehash == SPELL_HASH_COMMANDING_SHOUT || namehash == SPELL_HASH_BATTLE_SHOUT ) sp->BGR_one_buff_on_target |= SPELL_TYPE_WARRIOR_SHOUT; else if( strstr( sp->Description, "Finishing move")==sp->Description) sp->c_is_flags |= SPELL_FLAG_IS_FINISHING_MOVE; if( IsDamagingSpell( sp ) ) sp->c_is_flags |= SPELL_FLAG_IS_DAMAGING; if( IsHealingSpell( sp ) ) sp->c_is_flags |= SPELL_FLAG_IS_HEALING; if( IsTargetingStealthed( sp ) ) sp->c_is_flags |= SPELL_FLAG_IS_TARGETINGSTEALTHED; if( sp->NameHash == SPELL_HASH_HEMORRHAGE ) sp->c_is_flags |= SPELL_FLAG_IS_MAXSTACK_FOR_DEBUFF; //stupid spell ranking problem if(sp->spellLevel==0) { uint32 new_level=0; if( strstr( sp->Name, "Apprentice ")) new_level = 1; else if( strstr( sp->Name, "Journeyman ")) new_level = 2; else if( strstr( sp->Name, "Expert ")) new_level = 3; else if( strstr( sp->Name, "Artisan ")) new_level = 4; else if( strstr( sp->Name, "Master ")) new_level = 5; if(new_level!=0) { uint32 teachspell=0; if(sp->Effect[0]==SPELL_EFFECT_LEARN_SPELL) teachspell = sp->EffectTriggerSpell[0]; else if(sp->Effect[1]==SPELL_EFFECT_LEARN_SPELL) teachspell = sp->EffectTriggerSpell[1]; else if(sp->Effect[2]==SPELL_EFFECT_LEARN_SPELL) teachspell = sp->EffectTriggerSpell[2]; if(teachspell) { SpellEntry *spellInfo; spellInfo = dbcSpell.LookupEntryForced(teachspell); spellInfo->spellLevel = new_level; sp->spellLevel = new_level; } } } /*FILE * f = fopen("C:\\spells.txt", "a"); fprintf(f, "case 0x%08X: // %s\n", namehash, sp->Name); fclose(f);*/ // find diminishing status sp->DiminishStatus = GetDiminishingGroup(namehash); //another grouping rule //Quivers, Ammo Pouches and Thori'dal the Star's Fury if( ( namehash == SPELL_HASH_HASTE && sp->Attributes & 0x10000 ) || sp->Id == 44972 ) { sp->Attributes &= ~ATTRIBUTES_PASSIVE;//Otherwise we couldn't remove them sp->BGR_one_buff_on_target |= SPELL_TYPE_QUIVER_HASTE; } switch(namehash) { case SPELL_HASH_SANCTITY_AURA: case SPELL_HASH_DEVOTION_AURA: case SPELL_HASH_RETRIBUTION_AURA: case SPELL_HASH_CONCENTRATION_AURA: case SPELL_HASH_SHADOW_RESISTANCE_AURA: case SPELL_HASH_FIRE_RESISTANCE_AURA: case SPELL_HASH_FROST_RESISTANCE_AURA: case SPELL_HASH_CRUSADER_AURA: sp->BGR_one_buff_from_caster_on_self = SPELL_TYPE2_PALADIN_AURA; break; } //grouping rule switch(namehash) { case SPELL_HASH_HUNTER_S_MARK: // Hunter's mark sp->BGR_one_buff_from_caster_on_1target = SPELL_TYPE_INDEX_MARK; break; case SPELL_HASH_POLYMORPH: // Polymorph case SPELL_HASH_POLYMORPH__CHICKEN: // Polymorph: Chicken case SPELL_HASH_POLYMORPH__PIG: // Polymorph: Pig case SPELL_HASH_POLYMORPH__SHEEP: // Polymorph: Sheep case SPELL_HASH_POLYMORPH__TURTLE: // Polymorph: Turtle sp->BGR_one_buff_from_caster_on_1target = SPELL_TYPE_INDEX_POLYMORPH; break; case SPELL_HASH_FEAR: // Fear sp->BGR_one_buff_from_caster_on_1target = SPELL_TYPE_INDEX_FEAR; break; case SPELL_HASH_SAP: // Sap sp->BGR_one_buff_from_caster_on_1target = SPELL_TYPE_INDEX_SAP; break; case SPELL_HASH_SCARE_BEAST: // Scare Beast sp->BGR_one_buff_from_caster_on_1target = SPELL_TYPE_INDEX_SCARE_BEAST; break; case SPELL_HASH_HIBERNATE: // Hibernate sp->BGR_one_buff_from_caster_on_1target = SPELL_TYPE_INDEX_HIBERNATE; break; case SPELL_HASH_EARTH_SHIELD: // Earth Shield sp->BGR_one_buff_from_caster_on_1target = SPELL_TYPE_INDEX_EARTH_SHIELD; break; case SPELL_HASH_CYCLONE: // Cyclone sp->BGR_one_buff_from_caster_on_1target = SPELL_TYPE_INDEX_CYCLONE; break; case SPELL_HASH_BANISH: // Banish sp->BGR_one_buff_from_caster_on_1target = SPELL_TYPE_INDEX_BANISH; break; //case SPELL_HASH_JUDGEMENT_OF_VENGEANCE: case SPELL_HASH_JUDGEMENT_OF_THE_CRUSADER: case SPELL_HASH_JUDGEMENT_OF_LIGHT: case SPELL_HASH_JUDGEMENT_OF_WISDOM: case SPELL_HASH_JUDGEMENT_OF_JUSTICE: sp->BGR_one_buff_from_caster_on_1target = SPELL_TYPE_INDEX_JUDGEMENT; break; } // HACK FIX: Break roots/fear on damage.. this needs to be fixed properly! if(!(sp->AuraInterruptFlags & AURA_INTERRUPT_ON_ANY_DAMAGE_TAKEN)) { for(uint32 z = 0; z < 3; ++z) { if(sp->EffectApplyAuraName[z] == SPELL_AURA_MOD_FEAR || sp->EffectApplyAuraName[z] == SPELL_AURA_MOD_ROOT) { sp->AuraInterruptFlags |= AURA_INTERRUPT_ON_UNUSED2; break; } if( ( sp->Effect[z] == SPELL_EFFECT_SCHOOL_DAMAGE && sp->Spell_Dmg_Type == SPELL_DMG_TYPE_MELEE ) || sp->Effect[z] == SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL || sp->Effect[z] == SPELL_EFFECT_WEAPON_DAMAGE || sp->Effect[z] == SPELL_EFFECT_WEAPON_PERCENT_DAMAGE || sp->Effect[z] == SPELL_EFFECT_DUMMYMELEE ) sp->is_melee_spell = true; if( ( sp->Effect[z] == SPELL_EFFECT_SCHOOL_DAMAGE && sp->Spell_Dmg_Type == SPELL_DMG_TYPE_RANGED ) ) { //Log.Notice( "SpellFixes" , "Ranged Spell: %u [%s]" , sp->Id , sp->Name ); sp->is_ranged_spell = true; } } } // set extra properties sp->RankNumber = rank; if (sp->procFlags == 0x200000) { sp->procFlags = PROC_ON_TRAP_TRIGGER; } else if (sp->procFlags == 0x28) { sp->procFlags = PROC_ON_MELEE_ATTACK_VICTIM; } else if (sp->procFlags == 0x2A8 && sp->Attributes&0x50000 && sp->AttributesExC&0x2) { sp->procFlags = PROC_ON_BLOCK_VICTIM; } else if (sp->procFlags == 0x2A8) { sp->procFlags = PROC_ON_MELEE_ATTACK_VICTIM | PROC_ON_RANGED_ATTACK_VICTIM; } else if (sp->procFlags == 0x10000) { sp->procFlags = PROC_ON_CAST_SPELL; } else if (sp->procFlags == 0x15550 && (sp->AttributesExD&0x40 || sp->AttributesEx&0x20)) { sp->AuraInterruptFlags = AURA_INTERRUPT_ON_AFTER_CAST_SPELL; } else if (sp->procFlags == 0x15550) { sp->procFlags = PROC_ON_CAST_SPELL; } else if (sp->procFlags == 0x222A8 && sp->Attributes == 0x1D0 && !(sp->AttributesExD&0x80000)) { sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM | PROC_ON_SPELL_CRIT_HIT_VICTIM; } else if (sp->procFlags == 0x222A8) { sp->procFlags = PROC_ON_SPELL_HIT_VICTIM | PROC_ON_RANGED_ATTACK_VICTIM | PROC_ON_MELEE_ATTACK_VICTIM; } else if (sp->procFlags == 0xA22A8) { // ON_HEALTH_DROP } else if (sp->procFlags == 0x14 && sp->AttributesExC&0x4000000) { sp->procFlags = PROC_ON_CRIT_ATTACK; } else if (sp->procFlags == 0x14) { sp->procFlags = PROC_ON_MELEE_ATTACK; } else if (sp->procFlags == 0x1) { } else if (sp->procFlags == 0x2) { } else if (sp->procFlags == 0x100000) { } else if (sp->procFlags == 0x11154 && sp->Attributes == 0x1D0) { sp->procFlags = PROC_ON_CRIT_ATTACK | PROC_ON_RANGED_CRIT_ATTACK | PROC_ON_SPELL_CRIT_HIT; } else if (sp->procFlags == 0x11154 && sp->Attributes == 0x50010) { sp->procFlags = PROC_ON_MELEE_ATTACK; } else if (sp->procFlags != 0) { // sLog.outString("unhandled procFlag = 0x%x, spellid=%d", sp->procFlags, sp->Id); // sp->procFlags = 0; } if( strstr( sp->Description, "Must remain seated")) { sp->RecoveryTime = 1000; sp->CategoryRecoveryTime = 1000; } ////////////////////////////////////////////////////////////////////////////////////////////////////// // procintervals ////////////////////////////////////////////////////////////////////////////////////////////////////// //omg lighning shield trigger spell id's are all wrong ? //if you are bored you could make thiese by hand but i guess we might find other spells with this problem..and this way it's safe if( strstr( sp->Name, "Lightning Shield" ) && sp->EffectTriggerSpell[0] ) { //check if we can find in the desription char *startofid = strstr(sp->Description, "for $"); if( startofid ) { startofid += strlen("for $"); sp->EffectTriggerSpell[0] = atoi( startofid ); //get new lightning shield trigger id } sp->proc_interval = 3000; //few seconds } //mage ignite talent should proc only on some chances else if( strstr( sp->Name, "Ignite") && sp->Id>=11119 && sp->Id<=12848 && sp->EffectApplyAuraName[0] == 4 ) { //check if we can find in the desription char *startofid=strstr(sp->Description, "an additional "); if(startofid) { startofid += strlen("an additional "); sp->EffectBasePoints[0]=atoi(startofid); //get new value. This is actually level*8 ;) } sp->Effect[0] = 6; //aura sp->EffectApplyAuraName[0] = 42; //force him to use procspell effect sp->EffectTriggerSpell[0] = 12654; //evil , but this is good for us :D sp->procFlags = PROC_ON_SPELL_CRIT_HIT; //add procflag here since this was not processed with the others ! } // Winter's Chill handled by frost school else if( strstr( sp->Name, "Winter's Chill")) { sp->School = 4; } // Blackout handled by Shadow school else if( strstr( sp->Name, "Blackout")) { sp->School = 5; } #ifndef NEW_PROCFLAGS // Shadow Weaving else if( strstr( sp->Name, "Shadow Weaving")) { sp->School = 5; sp->EffectApplyAuraName[0] = 42; sp->procChance = sp->EffectBasePoints[0] + 1; sp->procFlags = PROC_ON_CAST_SPECIFIC_SPELL; } #endif //more triggered spell ids are wrong. I think blizz is trying to outsmart us :S //Chain Heal all ranks %50 heal value (49 + 1) else if( strstr( sp->Name, "Chain Heal")) { sp->EffectDieSides[0] = 49; } else if( strstr( sp->Name, "Holy Shock")) { //check if we can find in the desription char *startofid=strstr(sp->Description, "causing $"); if(startofid) { startofid += strlen("causing $"); sp->EffectTriggerSpell[0] = atoi(startofid); } //check if we can find in the desription startofid=strstr(sp->Description, " or $"); if(startofid) { startofid += strlen(" or $"); sp->EffectTriggerSpell[1]=atoi(startofid); } } else if( strstr( sp->Name, "Touch of Weakness")) { //check if we can find in the desription char *startofid=strstr(sp->Description, "cause $"); if(startofid) { startofid += strlen("cause $"); sp->EffectTriggerSpell[0] = atoi(startofid); sp->EffectTriggerSpell[1]=sp->EffectTriggerSpell[0]; //later versions of this spell changed to eff[1] the aura sp->procFlags = uint32(PROC_ON_MELEE_ATTACK_VICTIM); } } else if( strstr( sp->Name, "Firestone Passive")) { //Enchants the main hand weapon with fire, granting each attack a chance to deal $17809s1 additional fire damage. //check if we can find in the desription char * startofid=strstr(sp->Description, "to deal $"); if(startofid) { startofid += strlen("to deal $"); sp->EffectTriggerSpell[0] = atoi(startofid); sp->EffectApplyAuraName[0] = 42; sp->procFlags = PROC_ON_MELEE_ATTACK; sp->procChance = 50; } } //some procs trigger at intervals else if( strstr( sp->Name, "Water Shield")) { sp->proc_interval = 3000; //few seconds sp->procFlags |= PROC_TARGET_SELF; } else if( strstr( sp->Name, "Earth Shield")) sp->proc_interval = 3000; //few seconds else if( strstr( sp->Name, "Shadowguard")) sp->proc_interval = 3000; //few seconds else if( strstr( sp->Name, "Poison Shield")) sp->proc_interval = 3000; //few seconds else if( strstr( sp->Name, "Infused Mushroom")) sp->proc_interval = 10000; //10 seconds else if( strstr( sp->Name, "Aviana's Purpose")) sp->proc_interval = 10000; //10 seconds //don't change to namehash since we are searching only a protion of the name else if( strstr( sp->Name, "Crippling Poison")) { sp->SpellGroupType |= 16384; //some of them do have the flags but i's hard to write down those some from 130 spells sp->c_is_flags |= SPELL_FLAG_IS_POISON; } else if( strstr( sp->Name, "Mind-numbing Poison")) { sp->SpellGroupType |= 32768; //some of them do have the flags but i's hard to write down those some from 130 spells sp->c_is_flags |= SPELL_FLAG_IS_POISON; } else if( strstr( sp->Name, "Instant Poison")) { sp->SpellGroupType |= 8192; //some of them do have the flags but i's hard to write down those some from 130 spells sp->c_is_flags |= SPELL_FLAG_IS_POISON; } else if( strstr( sp->Name, "Deadly Poison")) { sp->SpellGroupType |= 65536; //some of them do have the flags but i's hard to write down those some from 130 spells sp->c_is_flags |= SPELL_FLAG_IS_POISON; } else if( strstr( sp->Name, "Wound Poison")) { sp->SpellGroupType |= 268435456; //some of them do have the flags but i's hard to write down those some from 130 spells sp->c_is_flags |= SPELL_FLAG_IS_POISON; } else if( strstr( sp->Name, "Scorpid Poison") ) { // groups? sp->c_is_flags |= SPELL_FLAG_IS_POISON; } //warlock - shadow bolt if( sp->NameHash == SPELL_HASH_SHADOW_BOLT ) sp->SpellGroupType |= 1; //some of them do have the flags but i's hard to write down those some from 130 spells /* else if( strstr( sp->Name, "Anesthetic Poison")) sp->SpellGroupType |= 0; //not yet known ? else if( strstr( sp->Name, "Blinding Powder")) sp->SpellGroupType |= 0; //not yet known ? else if( sp->NameHash == SPELL_HASH_ILLUMINATION ) sp->EffectTriggerSpell[0] = 20272;*/ // broken trigger spell, do not use //sp->dummy=result; /* //if there is a proc spell and has 0 as charges then it's probably going to triger infinite times. Better not save these if(sp->procCharges==0) sp->procCharges=-1;*/ if( sp->NameHash == SPELL_HASH_ILLUMINATION ) sp->procFlags |= PROC_TARGET_SELF; // Set default mechanics if we don't already have one if( !sp->MechanicsType ) { //Set Silencing spells mechanic. if( sp->EffectApplyAuraName[0] == 27 || sp->EffectApplyAuraName[1] == 27 || sp->EffectApplyAuraName[2] == 27 ) sp->MechanicsType = MECHANIC_SILENCED; //Set Stunning spells mechanic. if( sp->EffectApplyAuraName[0] == 12 || sp->EffectApplyAuraName[1] == 12 || sp->EffectApplyAuraName[2] == 12 ) sp->MechanicsType = MECHANIC_STUNNED; //Set Fearing spells mechanic if( sp->EffectApplyAuraName[0] == 7 || sp->EffectApplyAuraName[1] == 7 || sp->EffectApplyAuraName[2] == 7 ) sp->MechanicsType = MECHANIC_FLEEING; //Set Interrupted spells mech if( sp->Effect[0] == SPELL_EFFECT_INTERRUPT_CAST || sp->Effect[1] == SPELL_EFFECT_INTERRUPT_CAST || sp->Effect[2] == SPELL_EFFECT_INTERRUPT_CAST ) sp->MechanicsType = MECHANIC_INTERRUPTED; } if( sp->proc_interval != 0 ) sp->procFlags |= PROC_REMOVEONUSE; // Seal of Command - Proc Chance if( sp->NameHash == SPELL_HASH_SEAL_OF_COMMAND ) { sp->procChance = 25; sp->School = SCHOOL_HOLY; //the procspells of the original seal of command have fizical school instead of holy sp->Spell_Dmg_Type = SPELL_DMG_TYPE_MAGIC; //heh, crazy spell uses melee/ranged/magic dmg type for 1 spell. Now which one is correct ? } //Seal of Jusice - Proc Chance if( sp->NameHash == SPELL_HASH_SEAL_OF_JUSTICE ) sp->procChance = 25; /* Decapitate */ if( sp->NameHash == SPELL_HASH_DECAPITATE ) sp->procChance = 30; //shaman - shock, has no spellgroup.very dangerous move ! if( sp->NameHash == SPELL_HASH_SHOCK ) sp->SpellGroupType = 4; //mage - fireball. Only some of the spell has the flags if( sp->NameHash == SPELL_HASH_FIREBALL ) sp->SpellGroupType |= 1; if( sp->NameHash == SPELL_HASH_DIVINE_SHIELD || sp->NameHash == SPELL_HASH_DIVINE_PROTECTION || sp->NameHash == SPELL_HASH_BLESSING_OF_PROTECTION ) sp->MechanicsType = MECHANIC_INVULNARABLE; /* hackfix for this - FIX ME LATER - Burlex */ if( namehash == SPELL_HASH_SEAL_FATE ) sp->procFlags = 0; if( ((sp->Attributes & ATTRIBUTES_TRIGGER_COOLDOWN) && (sp->AttributesEx & ATTRIBUTESEX_NOT_BREAK_STEALTH)) //rogue cold blood || ((sp->Attributes & ATTRIBUTES_TRIGGER_COOLDOWN) && (!sp->AttributesEx || sp->AttributesEx & ATTRIBUTESEX_REMAIN_OOC)) ) { sp->c_is_flags |= SPELL_FLAG_IS_REQUIRECOOLDOWNUPDATE; } if( namehash == SPELL_HASH_SHRED || namehash == SPELL_HASH_BACKSTAB || namehash == SPELL_HASH_AMBUSH || namehash == SPELL_HASH_GARROTE || namehash == SPELL_HASH_MUTILATE || namehash == SPELL_HASH_RAVAGE ) { // FIXME: needs different flag check sp->FacingCasterFlags = SPELL_INFRONT_STATUS_REQUIRE_INBACK; } //junk code to get me has :P //if(sp->Id==11267 || sp->Id==11289 || sp->Id==6409) // printf("!!!!!!! name %s , id %u , hash %u \n",sp->Name,sp->Id, namehash); } ///////////////////////////////////////////////////////////////// //SPELL COEFFICIENT SETTINGS START ////////////////////////////////////////////////////////////////// for(uint32 x=0; x < cnt; x++) { // get spellentry SpellEntry * sp = dbcSpell.LookupRow(x); //Setting Cast Time Coefficient SpellCastTime *sd = dbcSpellCastTime.LookupEntry(sp->CastingTimeIndex); float castaff = float(GetCastTime(sd)); if(castaff < 1500) castaff = 1500; else if(castaff > 7000) castaff = 7000; sp->casttime_coef = castaff / 3500; SpellEntry * spz; bool spcheck = false; //Flag for DoT and HoT for( uint8 i = 0 ; i < 3 ; i++ ) { if (sp->EffectApplyAuraName[i] == SPELL_AURA_PERIODIC_DAMAGE || sp->EffectApplyAuraName[i] == SPELL_AURA_PERIODIC_HEAL || sp->EffectApplyAuraName[i] == SPELL_AURA_PERIODIC_LEECH ) { sp->spell_coef_flags |= SPELL_FLAG_IS_DOT_OR_HOT_SPELL; break; } } //Flag for DD or DH for( uint8 i = 0 ; i < 3 ; i++ ) { if ( sp->EffectApplyAuraName[i] == SPELL_AURA_PERIODIC_TRIGGER_SPELL && sp->EffectTriggerSpell[i] ) { spz = dbcSpell.LookupEntry( sp->EffectTriggerSpell[i] ); if( spz && spz->Effect[i] == SPELL_EFFECT_SCHOOL_DAMAGE || spz->Effect[i] == SPELL_EFFECT_HEAL ) spcheck = true; } if (sp->Effect[i] == SPELL_EFFECT_SCHOOL_DAMAGE || sp->Effect[i] == SPELL_EFFECT_HEAL || spcheck ) { sp->spell_coef_flags |= SPELL_FLAG_IS_DD_OR_DH_SPELL; break; } } for(uint8 i = 0 ; i < 3; i++) { switch (sp->EffectImplicitTargetA[i]) { //AoE case EFF_TARGET_ALL_TARGETABLE_AROUND_LOCATION_IN_RADIUS: case EFF_TARGET_ALL_ENEMY_IN_AREA: case EFF_TARGET_ALL_ENEMY_IN_AREA_INSTANT: case EFF_TARGET_ALL_PARTY_AROUND_CASTER: case EFF_TARGET_ALL_ENEMIES_AROUND_CASTER: case EFF_TARGET_IN_FRONT_OF_CASTER: case EFF_TARGET_ALL_ENEMY_IN_AREA_CHANNELED: case EFF_TARGET_ALL_PARTY_IN_AREA_CHANNELED: case EFF_TARGET_ALL_FRIENDLY_IN_AREA: case EFF_TARGET_ALL_TARGETABLE_AROUND_LOCATION_IN_RADIUS_OVER_TIME: case EFF_TARGET_ALL_PARTY: case EFF_TARGET_LOCATION_INFRONT_CASTER: case EFF_TARGET_BEHIND_TARGET_LOCATION: case EFF_TARGET_LOCATION_INFRONT_CASTER_AT_RANGE: { sp->spell_coef_flags |= SPELL_FLAG_AOE_SPELL; break; } } } for(uint8 i = 0 ; i < 3 ; i++) { switch (sp->EffectImplicitTargetB[i]) { //AoE case EFF_TARGET_ALL_TARGETABLE_AROUND_LOCATION_IN_RADIUS: case EFF_TARGET_ALL_ENEMY_IN_AREA: case EFF_TARGET_ALL_ENEMY_IN_AREA_INSTANT: case EFF_TARGET_ALL_PARTY_AROUND_CASTER: case EFF_TARGET_ALL_ENEMIES_AROUND_CASTER: case EFF_TARGET_IN_FRONT_OF_CASTER: case EFF_TARGET_ALL_ENEMY_IN_AREA_CHANNELED: case EFF_TARGET_ALL_PARTY_IN_AREA_CHANNELED: case EFF_TARGET_ALL_FRIENDLY_IN_AREA: case EFF_TARGET_ALL_TARGETABLE_AROUND_LOCATION_IN_RADIUS_OVER_TIME: case EFF_TARGET_ALL_PARTY: case EFF_TARGET_LOCATION_INFRONT_CASTER: case EFF_TARGET_BEHIND_TARGET_LOCATION: case EFF_TARGET_LOCATION_INFRONT_CASTER_AT_RANGE: { sp->spell_coef_flags |= SPELL_FLAG_AOE_SPELL; break; } } } //Special Cases //Holy Light & Flash of Light if(sp->NameHash == SPELL_HASH_HOLY_LIGHT || sp->NameHash == SPELL_HASH_FLASH_OF_LIGHT) sp->spell_coef_flags |= SPELL_FLAG_IS_DD_OR_DH_SPELL; //Additional Effect (not healing or damaging) for( uint8 i = 0 ; i < 3 ; i++ ) { if(sp->Effect[i] == 0) continue; switch (sp->Effect[i]) { case SPELL_EFFECT_SCHOOL_DAMAGE: case SPELL_EFFECT_ENVIRONMENTAL_DAMAGE: case SPELL_EFFECT_HEALTH_LEECH: case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: case SPELL_EFFECT_ADD_EXTRA_ATTACKS: case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: case SPELL_EFFECT_POWER_BURN: case SPELL_EFFECT_ATTACK: case SPELL_EFFECT_HEAL: case SPELL_EFFECT_HEALTH_FUNNEL: case SPELL_EFFECT_HEAL_MAX_HEALTH: case SPELL_EFFECT_DUMMY: continue; } switch (sp->EffectApplyAuraName[i]) { case SPELL_AURA_PERIODIC_DAMAGE: case SPELL_AURA_PROC_TRIGGER_DAMAGE: case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: case SPELL_AURA_POWER_BURN: case SPELL_AURA_PERIODIC_HEAL: case SPELL_AURA_MOD_INCREASE_HEALTH: case SPELL_AURA_PERIODIC_HEALTH_FUNNEL: case SPELL_AURA_DUMMY: continue; } sp->spell_coef_flags |= SPELL_FLAG_ADITIONAL_EFFECT; break; } //Calculating fixed coeficients //Channeled spells if( sp->ChannelInterruptFlags != 0 ) { float Duration = float( GetDuration( dbcSpellDuration.LookupEntry( sp->DurationIndex ) )); if(Duration < 1500) Duration = 1500; else if(Duration > 7000) Duration = 7000; sp->fixed_hotdotcoef = (Duration / 3500.0f); if( sp->spell_coef_flags & SPELL_FLAG_ADITIONAL_EFFECT ) sp->fixed_hotdotcoef *= 0.95f; if( sp->spell_coef_flags & SPELL_FLAG_AOE_SPELL ) sp->fixed_hotdotcoef *= 0.5f; } //Standard spells else if( (sp->spell_coef_flags & SPELL_FLAG_IS_DD_OR_DH_SPELL) && !(sp->spell_coef_flags & SPELL_FLAG_IS_DOT_OR_HOT_SPELL) ) { sp->fixed_dddhcoef = sp->casttime_coef; if( sp->spell_coef_flags & SPELL_FLAG_ADITIONAL_EFFECT ) sp->fixed_dddhcoef *= 0.95f; if( sp->spell_coef_flags & SPELL_FLAG_AOE_SPELL ) sp->fixed_dddhcoef *= 0.5f; } //Over-time spells else if( !(sp->spell_coef_flags & SPELL_FLAG_IS_DD_OR_DH_SPELL) && (sp->spell_coef_flags & SPELL_FLAG_IS_DOT_OR_HOT_SPELL) ) { float Duration = float( GetDuration( dbcSpellDuration.LookupEntry( sp->DurationIndex ) )); sp->fixed_hotdotcoef = (Duration / 15000.0f); if( sp->spell_coef_flags & SPELL_FLAG_ADITIONAL_EFFECT ) sp->fixed_hotdotcoef *= 0.95f; if( sp->spell_coef_flags & SPELL_FLAG_AOE_SPELL ) sp->fixed_hotdotcoef *= 0.5f; } //Combined standard and over-time spells else if( sp->spell_coef_flags & SPELL_FLAG_IS_DD_DH_DOT_SPELL ) { float Duration = float( GetDuration( dbcSpellDuration.LookupEntry( sp->DurationIndex ) )); float Portion_to_Over_Time = (Duration / 15000.0f) / ((Duration / 15000.0f) + sp->casttime_coef ); float Portion_to_Standard = 1.0f - Portion_to_Over_Time; sp->fixed_dddhcoef = sp->casttime_coef * Portion_to_Standard; sp->fixed_hotdotcoef = (Duration / 15000.0f) * Portion_to_Over_Time; if( sp->spell_coef_flags & SPELL_FLAG_ADITIONAL_EFFECT ) { sp->fixed_dddhcoef *= 0.95f; sp->fixed_hotdotcoef *= 0.95f; } if( sp->spell_coef_flags & SPELL_FLAG_AOE_SPELL ) { sp->fixed_dddhcoef *= 0.5f; sp->fixed_hotdotcoef *= 0.5f; } } /// SPELLS CAN CRIT /// sp->spell_can_crit = true; // - except in special cases noted in this section ////////////////////////////////////////////////////// // CLASS-SPECIFIC SPELL FIXES // ////////////////////////////////////////////////////// /* Note: when applying spell hackfixes, please follow a template */ /* Please don't put fixes like "sp = dbcSpell.LookupEntryForced( 15270 );" inside the loop */ ////////////////////////////////////////// // WARRIOR // ////////////////////////////////////////// ////////////////////////////////////////// // PALADIN // ////////////////////////////////////////// // Insert paladin spell fixes here // Seal of Righteousness - cannot crit if( sp->NameHash == SPELL_HASH_SEAL_OF_RIGHTEOUSNESS ) sp->spell_can_crit = false; // Forbearance - Is forced debuff if( sp->NameHash == SPELL_HASH_FORBEARANCE ) sp->c_is_flags |= SPELL_FLAG_IS_FORCEDDEBUFF; ////////////////////////////////////////// // HUNTER // ////////////////////////////////////////// // Insert hunter spell fixes here // THESE FIXES ARE GROUPED FOR CODE CLEANLINESS. //Mend Pet if( sp->NameHash == SPELL_HASH_MEND_PET ) sp->ChannelInterruptFlags = 0; /* // Concussive Shot, Distracting Shot, Silencing Shot - ranged spells if( sp->NameHash == SPELL_HASH_CONCUSSIVE_SHOT || sp->NameHash == SPELL_HASH_DISTRACTING_SHOT || sp->NameHash == SPELL_HASH_SILENCING_SHOT || sp->NameHash == SPELL_HASH_SCATTER_SHOT || sp->NameHash == SPELL_HASH_TRANQUILIZING_SHOT ) sp->is_ranged_spell = true; // All stings - ranged spells if( sp->NameHash == SPELL_HASH_SERPENT_STING || sp->NameHash == SPELL_HASH_SCORPID_STING || sp->NameHash == SPELL_HASH_VIPER_STING || sp->NameHash == SPELL_HASH_WYVERN STING ) sp->is_ranged_spell = true; */ // come to think of it... anything *castable* requiring a ranged weapon is a ranged spell -.- // Note that talents etc also come under this, however it does not matter // if they get flagged as ranged spells because is_ranged_spell is only used for // differentiating between resistable and physically avoidable spells. // if( sp->EquippedItemClass == 2 && sp->EquippedItemSubClass & 262156 ) // 4 + 8 + 262144 ( becomes item classes 2, 3 and 18 which correspond to bow, gun and crossbow respectively) // sp->is_ranged_spell = true; /* // !!! not sure this is good !!! have to test // Hunter's mark r1 sp = dbcSpell.LookupEntryForced( 1130 ); if( sp != NULL ) sp->maxstack = (sp->EffectBasePoints[1]*3) / (sp->EffectBasePoints[1]/10); sp = dbcSpell.LookupEntryForced( 14323 ); if( sp != NULL ) sp->maxstack = (sp->EffectBasePoints[1]*3) / (sp->EffectBasePoints[1]/10); sp = dbcSpell.LookupEntryForced( 14324 ); if( sp != NULL ) sp->maxstack = (sp->EffectBasePoints[1]*3) / (sp->EffectBasePoints[1]/10); sp = dbcSpell.LookupEntryForced( 14325 ); if( sp != NULL ) sp->maxstack = (sp->EffectBasePoints[1]*3) / (sp->EffectBasePoints[1]/10); */ ////////////////////////////////////////// // ROGUE // ////////////////////////////////////////// // Insert rogue spell fixes here ////////////////////////////////////////// // PRIEST // ////////////////////////////////////////// // Insert priest spell fixes here // Mind Flay,reduces target's movement speed by 50% if ( sp->NameHash == SPELL_HASH_MIND_FLAY ) sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_DECREASE_SPEED; // Weakened Soul - Is forced debuff if( sp->NameHash == SPELL_HASH_WEAKENED_SOUL ) sp->c_is_flags |= SPELL_FLAG_IS_FORCEDDEBUFF; ////////////////////////////////////////// // SHAMAN // ////////////////////////////////////////// // Insert shaman spell fixes here // Lightning Shield - cannot crit if( sp->NameHash == SPELL_HASH_LIGHTNING_SHIELD ) // not a mistake, the correct proc spell for lightning shield is also called lightning shield sp->spell_can_crit = false; // Frostbrand Weapon - 10% spd coefficient if( sp->NameHash == SPELL_HASH_FROSTBRAND_ATTACK ) sp->fixed_dddhcoef = 0.1f; // Fire Nova - 0% spd coefficient if( sp->NameHash == SPELL_HASH_FIRE_NOVA ) sp->fixed_dddhcoef = 0.0f; // Searing Totem - 8% spd coefficient if( sp->NameHash == SPELL_HASH_ATTACK ) sp->fixed_dddhcoef = 0.08f; // Healing Stream Totem - 8% healing coefficient if( sp->NameHash == SPELL_HASH_HEALING_STREAM ) sp->OTspell_coef_override = 0.08f; // Nature's Guardian if( sp->NameHash == SPELL_HASH_NATURE_S_GUARDIAN ){ sp->procFlags = PROC_ON_SPELL_HIT_VICTIM | PROC_ON_MELEE_ATTACK_VICTIM | PROC_ON_RANGED_ATTACK_VICTIM | PROC_ON_ANY_DAMAGE_VICTIM; sp->proc_interval = 5000; sp->EffectTriggerSpell[0] = 31616; } ////////////////////////////////////////// // MAGE // ////////////////////////////////////////// // Insert mage spell fixes here // Hypothermia: undispellable if( sp->NameHash == SPELL_HASH_HYPOTHERMIA ) sp->c_is_flags |= SPELL_FLAG_IS_FORCEDDEBUFF; ////////////////////////////////////////// // WARLOCK // ////////////////////////////////////////// // Insert warlock spell fixes here ////////////////////////////////////////// // DRUID // ////////////////////////////////////////// // Insert druid spell fixes here } //Settings for special cases QueryResult * resultx = WorldDatabase.Query("SELECT * FROM spell_coef_override"); if( resultx != NULL ) { do { Field * f; f = resultx->Fetch(); SpellEntry * sp = dbcSpell.LookupEntryForced( f[0].GetUInt32() ); if( sp != NULL ) { sp->Dspell_coef_override = f[2].GetFloat(); sp->OTspell_coef_override = f[3].GetFloat(); } else Log.Warning("SpellCoefOverride", "Has nonexistant spell %u.", f[0].GetUInt32()); } while( resultx->NextRow() ); delete resultx; } //Fully loaded coefficients, we must share channeled coefficient to its triggered spells for(uint32 x=0; x < cnt; x++) { // get spellentry SpellEntry * sp = dbcSpell.LookupRow(x); SpellEntry * spz; //Case SPELL_AURA_PERIODIC_TRIGGER_SPELL for( uint8 i = 0 ; i < 3 ; i++ ) { if ( sp->EffectApplyAuraName[i] == SPELL_AURA_PERIODIC_TRIGGER_SPELL ) { spz = dbcSpell.LookupEntry( sp->EffectTriggerSpell[i] ); if( spz != NULL ) { if( sp->Dspell_coef_override >= 0 ) spz->Dspell_coef_override = sp->Dspell_coef_override; else { //we must set bonus per tick on triggered spells now (i.e. Arcane Missiles) if( sp->ChannelInterruptFlags != 0 ) { float Duration = float( GetDuration( dbcSpellDuration.LookupEntry( sp->DurationIndex ) )); float amp = float(sp->EffectAmplitude[i]); sp->fixed_dddhcoef = sp->fixed_hotdotcoef * amp / Duration; } spz->fixed_dddhcoef = sp->fixed_dddhcoef; } if( sp->OTspell_coef_override >= 0 ) spz->OTspell_coef_override = sp->OTspell_coef_override; else { //we must set bonus per tick on triggered spells now (i.e. Arcane Missiles) if( sp->ChannelInterruptFlags != 0 ) { float Duration = float( GetDuration( dbcSpellDuration.LookupEntry( sp->DurationIndex ) )); float amp = float(sp->EffectAmplitude[i]); sp->fixed_hotdotcoef *= amp / Duration; } spz->fixed_hotdotcoef = sp->fixed_hotdotcoef; } break; } } } } ///////////////////////////////////////////////////////////////// //SPELL COEFFICIENT SETTINGS END ///////////////////////////////////////////////////////////////// SpellEntry* sp; EnchantEntry* Enchantment; // Flametongue weapon Enchantment = dbcEnchant.LookupEntryForced( 2634 ); if( Enchantment != NULL ) { Enchantment->type[0] = 1; Enchantment->spell[0] = 25488; } Enchantment = dbcEnchant.LookupEntryForced( 1666 ); if( Enchantment != NULL ) { Enchantment->type[0] = 1; Enchantment->spell[0] = 16344; } Enchantment = dbcEnchant.LookupEntryForced( 1665 ); if( Enchantment != NULL ) { Enchantment->type[0] = 1; Enchantment->spell[0] = 16343; } Enchantment = dbcEnchant.LookupEntryForced( 523 ); if( Enchantment != NULL ) { Enchantment->type[0] = 1; Enchantment->spell[0] = 10445; } Enchantment = dbcEnchant.LookupEntryForced( 3 ); if( Enchantment != NULL ) { Enchantment->type[0] = 1; Enchantment->spell[0] = 8029; } Enchantment = dbcEnchant.LookupEntryForced( 4 ); if( Enchantment != NULL ) { Enchantment->type[0] = 1; Enchantment->spell[0] = 8028; } Enchantment = dbcEnchant.LookupEntryForced( 5 ); if( Enchantment != NULL ) { Enchantment->type[0] = 1; Enchantment->spell[0] = 8026; } // Flametongue totem Enchantment = dbcEnchant.LookupEntryForced( 124 ); if( Enchantment != NULL ) { Enchantment->type[0] = 1; Enchantment->spell[0] = 8253; } Enchantment = dbcEnchant.LookupEntryForced( 285 ); if( Enchantment != NULL ) { Enchantment->type[0] = 1; Enchantment->spell[0] = 8248; } Enchantment = dbcEnchant.LookupEntryForced( 543 ); if( Enchantment != NULL ) { Enchantment->type[0] = 1; Enchantment->spell[0] = 10523; } Enchantment = dbcEnchant.LookupEntryForced( 1683 ); if( Enchantment != NULL ) { Enchantment->type[0] = 1; Enchantment->spell[0] = 16389; } Enchantment = dbcEnchant.LookupEntryForced( 2637 ); if( Enchantment != NULL ) { Enchantment->type[0] = 1; Enchantment->spell[0] = 25555; } /******************************************************** * Windfury Enchantment ********************************************************/ Enchantment = dbcEnchant.LookupEntryForced( 283 ); if( Enchantment != NULL ) { Enchantment->spell[0] = 33757; //this is actually good sp = dbcSpell.LookupEntryForced( 33757 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procFlags = PROC_ON_MELEE_ATTACK; //we do not need proc on spell ;) sp->EffectTriggerSpell[0] = 8232; //for the logs and rest sp->procChance = 20; sp->proc_interval = 3000;//http://www.wowwiki.com/Windfury_Weapon sp->maxstack = 1; } } Enchantment = dbcEnchant.LookupEntryForced( 284 ); if( Enchantment != NULL ) { Enchantment->spell[0] = 33756; sp = dbcSpell.LookupEntryForced( 33756 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procFlags = PROC_ON_MELEE_ATTACK; //we do not need proc on spell ;) sp->EffectTriggerSpell[0] = 8235; //for the logs and rest sp->procChance = 20; sp->proc_interval = 3000; //http://www.wowwiki.com/Windfury_Weapon sp->maxstack = 1; } } Enchantment = dbcEnchant.LookupEntryForced( 525 ); if( Enchantment != NULL ) { Enchantment->spell[0] = 33755; sp = dbcSpell.LookupEntryForced( 33755 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procFlags = PROC_ON_MELEE_ATTACK; //we do not need proc on spell ;) sp->EffectTriggerSpell[0] = 10486; //for the logs and rest sp->procChance = 20; sp->proc_interval = 3000;//http://www.wowwiki.com/Windfury_Weapon sp->maxstack = 1; } } Enchantment = dbcEnchant.LookupEntryForced( 1669 ); if( Enchantment != NULL ) { Enchantment->spell[0] = 33754; sp = dbcSpell.LookupEntryForced( 33754 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procFlags = PROC_ON_MELEE_ATTACK; //we do not need proc on spell ;) sp->EffectTriggerSpell[0] = 16362; //for the logs and rest sp->procChance = 20; sp->proc_interval = 3000;//http://www.wowwiki.com/Windfury_Weapon sp->maxstack = 1; } } Enchantment = dbcEnchant.LookupEntryForced( 2636 ); if( Enchantment != NULL ) { Enchantment->spell[0] = 33727; sp = dbcSpell.LookupEntryForced( 33727 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procFlags = PROC_ON_MELEE_ATTACK; //we do not need proc on spell ;) sp->EffectTriggerSpell[0] = 25505; //for the logs and rest sp->procChance = 20; sp->proc_interval = 3000;//http://www.wowwiki.com/Windfury_Weapon sp->maxstack = 1; } } /********************************************************** * PROFFESION - Enchant Cloak - Major Resistance **********************************************************/ sp = dbcSpell.LookupEntryForced( 27962 ); if( sp != NULL ) sp->EffectMiscValue[0] = 2998; sp = dbcSpell.LookupEntryForced( 36285 ); if( sp != NULL ) sp->EffectMiscValue[0] = 2998; /********************************************************** * Wand Shoot **********************************************************/ sp = dbcSpell.LookupEntryForced( 5019 ); if( sp != NULL ) sp->SpellGroupType = 134217728; /********************************************************** * Berserking - TROLL'S RACIAL SPELL **********************************************************/ sp = dbcSpell.LookupEntryForced( 20554 ); if( sp != NULL ) { sp->Effect[0] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 26635; } sp = dbcSpell.LookupEntryForced( 26296 ); if( sp != NULL ) { sp->Effect[0] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 26635; } sp = dbcSpell.LookupEntryForced( 26297 ); if( sp != NULL ) { sp->Effect[0] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 26635; } sp = dbcSpell.LookupEntryForced( 20134 ); // << --- WTF? if( sp != NULL ) sp->procChance = 50; /********************************************************** * Mana Tap - BLOOD ELF RACIAL **********************************************************/ sp = dbcSpell.LookupEntryForced( 28734 ); if( sp != NULL ) // sp->Effect[0] = SPELL_EFFECT_POWER_BURN; // should be Power Burn, not Power Drain. Power Drain leeches mana which is incorrect. //Zazk : tested on retail and it is only leech and not burn ! sp->Effect[0] = SPELL_EFFECT_POWER_DRAIN; // should be Power Burn, not Power Drain. Power Drain leeches mana which is incorrect. /********************************************************** * thrown - add a 1.6 second cooldown **********************************************************/ const static uint32 thrown_spells[] = {SPELL_RANGED_GENERAL,SPELL_RANGED_THROW,SPELL_RANGED_WAND, 26679, 27084, 29436, 37074, 41182, 41346, 0}; for(i = 0; thrown_spells[i] != 0; ++i) { sp = dbcSpell.LookupEntryForced( thrown_spells[i] ); if( sp != NULL && sp->RecoveryTime==0 && sp->StartRecoveryTime == 0 ){ if ( sp->Id == SPELL_RANGED_GENERAL ) sp->RecoveryTime = 500; // cebernic: hunter general with 0.5s else sp->RecoveryTime = 1500; // 1.5cd } } /********************************************************** * Wands **********************************************************/ sp = dbcSpell.LookupEntryForced( SPELL_RANGED_WAND ); if( sp != NULL ) sp->Spell_Dmg_Type = SPELL_DMG_TYPE_RANGED; /********************************************************** * Misc stuff (questfixes etc) **********************************************************/ sp = dbcSpell.LookupEntryForced( 30877 ); if( sp != NULL ) { sp->EffectImplicitTargetB[0]=0; } sp = dbcSpell.LookupEntryForced(23179); if( sp != NULL ) sp->EffectMiscValue[0] = 1434; // list of guardians that should inherit casters level //fire elemental sp = dbcSpell.LookupEntryForced(32982); if( sp != NULL ) sp->c_is_flags |= SPELL_FLAG_IS_INHERITING_LEVEL; //Earth elemental sp = dbcSpell.LookupEntryForced(33663); if( sp != NULL ) sp->c_is_flags |= SPELL_FLAG_IS_INHERITING_LEVEL; ////////////////////////////////////////////////////// // CLASS-SPECIFIC SPELL FIXES // ////////////////////////////////////////////////////// /* Note: when applying spell hackfixes, please follow a template */ ////////////////////////////////////////// // WARRIOR // ////////////////////////////////////////// // Insert warrior spell fixes here //Warrior - Enrage Procflags sp = dbcSpell.LookupEntryForced( 12317 ); if(sp != NULL) sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM | PROC_ON_SPELL_CRIT_HIT_VICTIM; sp = dbcSpell.LookupEntryForced( 13045 ); if(sp != NULL) sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM | PROC_ON_SPELL_CRIT_HIT_VICTIM; sp = dbcSpell.LookupEntryForced( 13046 ); if(sp != NULL) sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM | PROC_ON_SPELL_CRIT_HIT_VICTIM; sp = dbcSpell.LookupEntryForced( 13047 ); if(sp != NULL) sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM | PROC_ON_SPELL_CRIT_HIT_VICTIM; sp = dbcSpell.LookupEntryForced( 13048 ); if(sp != NULL) sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM | PROC_ON_SPELL_CRIT_HIT_VICTIM; /* Remove the charges only on melee attacks */ sp = dbcSpell.LookupEntryForced( 12880 ); if(sp != NULL) sp->procFlags = PROC_ON_MELEE_ATTACK; sp = dbcSpell.LookupEntryForced( 14201 ); if(sp != NULL) sp->procFlags = PROC_ON_MELEE_ATTACK; sp = dbcSpell.LookupEntryForced( 14202 ); if(sp != NULL) sp->procFlags = PROC_ON_MELEE_ATTACK; sp = dbcSpell.LookupEntryForced( 14203 ); if(sp != NULL) sp->procFlags = PROC_ON_MELEE_ATTACK; sp = dbcSpell.LookupEntryForced( 14204 ); if(sp != NULL) sp->procFlags = PROC_ON_MELEE_ATTACK; //Warrior - Blood Craze Procflags sp = dbcSpell.LookupEntryForced( 16487 ); if( sp != NULL ) sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM | PROC_ON_SPELL_CRIT_HIT_VICTIM; sp = dbcSpell.LookupEntryForced( 16489 ); if( sp != NULL ) sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM | PROC_ON_SPELL_CRIT_HIT_VICTIM; sp = dbcSpell.LookupEntryForced( 16492 ); if( sp != NULL ) sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM | PROC_ON_SPELL_CRIT_HIT_VICTIM; //Warrior - Deep Wounds sp = dbcSpell.LookupEntryForced( 12834 ); if(sp != NULL) { sp->EffectTriggerSpell[0] = 12721; sp->procFlags = PROC_ON_CRIT_ATTACK | PROC_ON_RANGED_CRIT_ATTACK | PROC_ON_SPELL_CRIT_HIT; } sp = dbcSpell.LookupEntryForced( 12849 ); if(sp != NULL) { sp->EffectTriggerSpell[0] = 12721; sp->procFlags = PROC_ON_CRIT_ATTACK | PROC_ON_RANGED_CRIT_ATTACK | PROC_ON_SPELL_CRIT_HIT; } sp = dbcSpell.LookupEntryForced( 12867 ); if(sp != NULL) { sp->EffectTriggerSpell[0] = 12721; sp->procFlags = PROC_ON_CRIT_ATTACK | PROC_ON_RANGED_CRIT_ATTACK | PROC_ON_SPELL_CRIT_HIT; } //Warrior - Charge Rank 1 sp = dbcSpell.LookupEntryForced(100); if(sp != NULL) { sp->Effect[1] = SPELL_EFFECT_DUMMY; sp->EffectMiscValue[1] = 90; } //Warrior - Charge Rank 2 sp = dbcSpell.LookupEntryForced(6178); if(sp != NULL) { sp->Effect[1] = SPELL_EFFECT_DUMMY; sp->EffectMiscValue[1] = 120; } //Warrior - Charge Rank 3 sp = dbcSpell.LookupEntryForced(11578); if(sp != NULL) { sp->Effect[1] = SPELL_EFFECT_DUMMY; sp->EffectMiscValue[1] = 150; } //Warrior - Improved Hamstring Rank 1 sp = dbcSpell.LookupEntryForced(12289); if(sp != NULL) { sp->EffectTriggerSpell[1]=23694;// Improved Hamstring : Immobilized. 5 seconds remaining. sp->procFlags = PROC_ON_CAST_SPECIFIC_SPELL; sp->procChance = 5; } //Warrior - Improved Hamstring Rank 2 sp = dbcSpell.LookupEntryForced(12668); if(sp != NULL) { sp->EffectTriggerSpell[1]=23694;// Improved Hamstring : Immobilized. 5 seconds remaining. sp->procFlags = PROC_ON_CAST_SPECIFIC_SPELL; sp->procChance = 10; } //Warrior - Improved Hamstring Rank 3 sp = dbcSpell.LookupEntryForced(23695); if(sp != NULL) { sp->EffectTriggerSpell[1]=23694;// Improved Hamstring : Immobilized. 5 seconds remaining. sp->procFlags = PROC_ON_CAST_SPECIFIC_SPELL; sp->procChance = 15; } //Warrior - Retaliation sp = dbcSpell.LookupEntryForced( 20230 ); if( sp != NULL ) { sp->Effect[0] = 6; //aura sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 22858; //evil , but this is good for us :D sp->procFlags = PROC_ON_MELEE_ATTACK_VICTIM; //add procflag here since this was not processed with the others ! } //"bloodthirst" new version is ok but old version is wrong from now on :( sp = dbcSpell.LookupEntryForced( 23881 ); if( sp != NULL ) { sp->Effect[1] = 64; //cast on us, it is good sp->EffectTriggerSpell[1] = 23885; //evil , but this is good for us :D } sp = dbcSpell.LookupEntryForced( 23892 ); if( sp != NULL ) { sp->Effect[1] = 64; sp->EffectTriggerSpell[1] = 23886; //evil , but this is good for us :D } sp = dbcSpell.LookupEntryForced( 23893 ); if( sp != NULL ) { sp->Effect[1] = 64; // sp->EffectTriggerSpell[1] = 23887; //evil , but this is good for us :D } sp = dbcSpell.LookupEntryForced( 23894 ); if( sp != NULL ) { sp->Effect[1] = 64; // sp->EffectTriggerSpell[1] = 23888; //evil , but this is good for us :D } sp = dbcSpell.LookupEntryForced( 25251 ); if( sp != NULL ) { sp->Effect[1] = 64; //aura sp->EffectTriggerSpell[1] = 25252; //evil , but this is good for us :D } sp = dbcSpell.LookupEntryForced( 30335 ); if( sp != NULL ) { sp->Effect[1] = 64; //aura sp->EffectTriggerSpell[1] = 30339; //evil , but this is good for us :D } //rend sp = dbcSpell.LookupEntryForced( 772 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 6546 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 6547 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 6548 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 11572 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 11573 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 11574 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 25208 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; //warrior - Rampage sp = dbcSpell.LookupEntryForced( 29801 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procFlags = PROC_ON_MELEE_ATTACK | static_cast<uint32>(PROC_TARGET_SELF); sp->EffectTriggerSpell[0] = sp->EffectTriggerSpell[1]; } sp = dbcSpell.LookupEntryForced( 30030 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procFlags = PROC_ON_MELEE_ATTACK | static_cast<uint32>(PROC_TARGET_SELF); sp->EffectTriggerSpell[0] = sp->EffectTriggerSpell[1]; } sp = dbcSpell.LookupEntryForced( 30033 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procFlags = PROC_ON_MELEE_ATTACK | static_cast<uint32>(PROC_TARGET_SELF); sp->EffectTriggerSpell[0] = sp->EffectTriggerSpell[1]; } #ifdef NEW_PROCFLAGS //warrior - deep wounds sp = dbcSpell.LookupEntry( 12162); if ( sp!=NULL ) sp->SpellGroupType = 32; sp = dbcSpell.LookupEntry( 12850); if ( sp!=NULL ) sp->SpellGroupType = 32; sp = dbcSpell.LookupEntry( 12868); if ( sp!=NULL ) sp->SpellGroupType = 32; #endif //warrior - second wind should trigger on self sp = dbcSpell.LookupEntryForced( 29841 ); if( sp != NULL ) sp->procFlags |= PROC_TARGET_SELF; sp = dbcSpell.LookupEntryForced( 29842 ); if( sp != NULL ) sp->procFlags |= PROC_TARGET_SELF; //warrior - Berserker Rage sp = dbcSpell.LookupEntryForced( 18499 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_DUMMY;//Forcing a dummy aura, so we can add the missing 4th effect. sp->Effect[1] = 0; sp->Effect[2] = 0; } //warrior - improved berserker rage sp = dbcSpell.LookupEntryForced( 20500 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL | static_cast<uint32>(PROC_TARGET_SELF); sp = dbcSpell.LookupEntryForced( 20501 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL | static_cast<uint32>(PROC_TARGET_SELF); //warrior - Blood Frenzy sp = dbcSpell.LookupEntryForced( 29836 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; } sp = dbcSpell.LookupEntryForced( 29859 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; } //warrior - Unbridled Wrath sp = dbcSpell.LookupEntryForced( 12322 ); if( sp != NULL ) sp->procFlags = PROC_ON_MELEE_ATTACK | static_cast<uint32>(PROC_TARGET_SELF); sp = dbcSpell.LookupEntryForced( 12999 ); if( sp != NULL ) sp->procFlags = PROC_ON_MELEE_ATTACK | static_cast<uint32>(PROC_TARGET_SELF); sp = dbcSpell.LookupEntryForced( 13000 ); if( sp != NULL ) sp->procFlags = PROC_ON_MELEE_ATTACK | static_cast<uint32>(PROC_TARGET_SELF); sp = dbcSpell.LookupEntryForced( 13001 ); if( sp != NULL ) sp->procFlags = PROC_ON_MELEE_ATTACK | static_cast<uint32>(PROC_TARGET_SELF); sp = dbcSpell.LookupEntryForced( 13002 ); if( sp != NULL ) sp->procFlags = PROC_ON_MELEE_ATTACK | static_cast<uint32>(PROC_TARGET_SELF); // Insert warrior spell fixes here //Warrior - Overpower Rank 1 sp = dbcSpell.LookupEntryForced(7384); if(sp != NULL) sp->Attributes |= ATTRIBUTES_CANT_BE_DPB; //Warrior - Overpower Rank 2 sp = dbcSpell.LookupEntryForced(7887); if(sp != NULL) sp->Attributes |= ATTRIBUTES_CANT_BE_DPB; //Warrior - Overpower Rank 3 sp = dbcSpell.LookupEntryForced(11584); if(sp != NULL) sp->Attributes |= ATTRIBUTES_CANT_BE_DPB; //Warrior - Overpower Rank 4 sp = dbcSpell.LookupEntryForced(11585); if(sp != NULL) sp->Attributes |= ATTRIBUTES_CANT_BE_DPB; //Warrior - Tactical Mastery Rank 1 sp = dbcSpell.LookupEntry(0x00003007); if(sp != NULL) sp->RequiredShapeShift = 0x00070000; //Warrior - Tactical Mastery Rank 2 sp = dbcSpell.LookupEntry(0x00003184); if(sp != NULL) sp->RequiredShapeShift = 0x00070000; //Warrior - Tactical Mastery Rank 3 sp = dbcSpell.LookupEntry(0x00003185); if(sp != NULL) sp->RequiredShapeShift = 0x00070000; ////////////////////////////////////////// // DRUID // ////////////////////////////////////////// //Force of Nature sp = dbcSpell.LookupEntryForced(33831); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_INHERITING_LEVEL; sp->EffectImplicitTargetA[0] = EFF_TARGET_SELF; //some land under target is used that gathers multiple targets ... sp->EffectImplicitTargetA[1] = EFF_TARGET_NONE; } // Spell 22570 (Maim Rank 1) sp = dbcSpell.LookupEntryForced(22570); if( sp != NULL ) sp->AuraInterruptFlags |= AURA_INTERRUPT_ON_ANY_DAMAGE_TAKEN; ////////////////////////////////////////// // PALADIN // ////////////////////////////////////////// // Insert paladin spell fixes here // Seal of Command - Holy damage, but melee mechanics (crit damage, chance, etc) sp = dbcSpell.LookupEntryForced( 20424 ); if( sp != NULL ) sp->is_melee_spell = true; // paladin - Vindication sp = dbcSpell.LookupEntryForced( 26021 ); if( sp != NULL ) { sp->procChance = 30; sp->procFlags = PROC_ON_MELEE_ATTACK; } sp = dbcSpell.LookupEntryForced( 26016 ); if( sp != NULL ) { sp->procChance = 30; sp->procFlags = PROC_ON_MELEE_ATTACK; } sp = dbcSpell.LookupEntryForced( 9452 ); if( sp != NULL ) { sp->procChance = 30; sp->procFlags = PROC_ON_MELEE_ATTACK; } /********************************************************** * Blessing of Light **********************************************************/ sp = dbcSpell.LookupEntryForced( 19977 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_DUMMY; sp->EffectApplyAuraName[1] = SPELL_AURA_DUMMY; } sp = dbcSpell.LookupEntryForced( 19978 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_DUMMY; sp->EffectApplyAuraName[1] = SPELL_AURA_DUMMY; } sp = dbcSpell.LookupEntryForced( 19979 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_DUMMY; sp->EffectApplyAuraName[1] = SPELL_AURA_DUMMY; } sp = dbcSpell.LookupEntryForced( 27144 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_DUMMY; sp->EffectApplyAuraName[1] = SPELL_AURA_DUMMY; } sp = dbcSpell.LookupEntryForced( 32770 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_DUMMY; sp->EffectApplyAuraName[1] = SPELL_AURA_DUMMY; } /********************************************************** * Seal of Vengeance **********************************************************/ sp = dbcSpell.LookupEntryForced( 31801 ); if( sp != NULL ) { sp->procFlags = PROC_ON_MELEE_ATTACK; sp->EffectTriggerSpell[0] = 31803; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; } /********************************************************** * Reckoning **********************************************************/ sp = dbcSpell.LookupEntryForced( 20177 ); if( sp != NULL ) sp->procFlags = PROC_ON_ANY_DAMAGE_VICTIM | static_cast<uint32>(PROC_TARGET_SELF); sp = dbcSpell.LookupEntryForced( 20179 ); if( sp != NULL ) sp->procFlags = PROC_ON_ANY_DAMAGE_VICTIM | static_cast<uint32>(PROC_TARGET_SELF); sp = dbcSpell.LookupEntryForced( 20180 ); if( sp != NULL ) sp->procFlags = PROC_ON_ANY_DAMAGE_VICTIM | static_cast<uint32>(PROC_TARGET_SELF); sp = dbcSpell.LookupEntryForced( 20181 ); if( sp != NULL ) sp->procFlags = PROC_ON_ANY_DAMAGE_VICTIM | static_cast<uint32>(PROC_TARGET_SELF); sp = dbcSpell.LookupEntryForced( 20182 ); if( sp != NULL ) sp->procFlags = PROC_ON_ANY_DAMAGE_VICTIM | static_cast<uint32>(PROC_TARGET_SELF); /********************************************************** * Reckoning Effect **********************************************************/ sp = dbcSpell.LookupEntryForced( 20178 ); if( sp != NULL ) { sp->procChance = 100; sp->procFlags = PROC_ON_MELEE_ATTACK | static_cast<uint32>(PROC_TARGET_SELF); } /********************************************************** * Judgement of Wisdom **********************************************************/ sp = dbcSpell.LookupEntryForced( 20186 ); if( sp != NULL ) { sp->procFlags = PROC_ON_ANY_DAMAGE_VICTIM; sp->EffectTriggerSpell[0] = 20268; } sp = dbcSpell.LookupEntryForced( 20354 ); if( sp != NULL ) { sp->procFlags = PROC_ON_ANY_DAMAGE_VICTIM; sp->EffectTriggerSpell[0] = 20352; } sp = dbcSpell.LookupEntryForced( 20355 ); if( sp != NULL ) { sp->procFlags = PROC_ON_ANY_DAMAGE_VICTIM; sp->EffectTriggerSpell[0] = 20353; } sp = dbcSpell.LookupEntryForced( 27164 ); if( sp != NULL ) { sp->procFlags = PROC_ON_ANY_DAMAGE_VICTIM; sp->EffectTriggerSpell[0] = 27165; } sp = dbcSpell.LookupEntryForced( 20268 ); if( sp != NULL ) sp->EffectImplicitTargetA[0] = EFF_TARGET_SINGLE_ENEMY; sp = dbcSpell.LookupEntryForced( 20352 ); if( sp != NULL ) sp->EffectImplicitTargetA[0] = EFF_TARGET_SINGLE_ENEMY; sp = dbcSpell.LookupEntryForced( 20353 ); if( sp != NULL ) sp->EffectImplicitTargetA[0] = EFF_TARGET_SINGLE_ENEMY; sp = dbcSpell.LookupEntryForced( 27165 ); if( sp != NULL ) sp->EffectImplicitTargetA[0] = EFF_TARGET_SINGLE_ENEMY; /********************************************************** * Judgement of Light **********************************************************/ sp = dbcSpell.LookupEntryForced( 20185 ); if( sp != NULL ) { sp->procFlags = PROC_ON_MELEE_ATTACK_VICTIM; sp->EffectTriggerSpell[0] = 20267; } sp = dbcSpell.LookupEntryForced( 20344 ); if( sp != NULL ) { sp->procFlags = PROC_ON_MELEE_ATTACK_VICTIM; sp->EffectTriggerSpell[0] = 20341; } sp = dbcSpell.LookupEntryForced( 20345 ); if( sp != NULL ) { sp->procFlags = PROC_ON_MELEE_ATTACK_VICTIM; sp->EffectTriggerSpell[0] = 20342; } sp = dbcSpell.LookupEntryForced( 20346 ); if( sp != NULL ) { sp->procFlags = PROC_ON_MELEE_ATTACK_VICTIM; sp->EffectTriggerSpell[0] = 20343; } sp = dbcSpell.LookupEntryForced( 27162 ); if( sp != NULL ) { sp->procFlags = PROC_ON_MELEE_ATTACK_VICTIM; sp->EffectTriggerSpell[0] = 27163; } sp = dbcSpell.LookupEntryForced( 20267 ); if( sp != NULL ) sp->EffectImplicitTargetA[0] = EFF_TARGET_SINGLE_ENEMY; sp = dbcSpell.LookupEntryForced( 20341 ); if( sp != NULL ) sp->EffectImplicitTargetA[0] = EFF_TARGET_SINGLE_ENEMY; sp = dbcSpell.LookupEntryForced( 20342 ); if( sp != NULL ) sp->EffectImplicitTargetA[0] = EFF_TARGET_SINGLE_ENEMY; sp = dbcSpell.LookupEntryForced( 20343 ); if( sp != NULL ) sp->EffectImplicitTargetA[0] = EFF_TARGET_SINGLE_ENEMY; sp = dbcSpell.LookupEntryForced( 27163 ); if( sp != NULL ) sp->EffectImplicitTargetA[0] = EFF_TARGET_SINGLE_ENEMY; /********************************************************** * Eye for an Eye **********************************************************/ sp = dbcSpell.LookupEntryForced( 9799 ); if( sp != NULL ) { sp->procFlags = PROC_ON_SPELL_CRIT_HIT_VICTIM; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 25997; sp->fixed_dddhcoef = 0.0f; } sp = dbcSpell.LookupEntryForced( 25988 ); if( sp != NULL ) { sp->procFlags = PROC_ON_SPELL_CRIT_HIT_VICTIM; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 25997; sp->fixed_dddhcoef = 0.0f; } sp = dbcSpell.LookupEntryForced( 25997 ); if( sp != NULL ) sp->fixed_dddhcoef = 0.0f; /********************************************************** * sanctified judgement **********************************************************/ sp = dbcSpell.LookupEntryForced( 31876 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 31930; sp->procChance = sp->EffectBasePoints[0]+1; sp->EffectBasePoints[0] = 79; } sp = dbcSpell.LookupEntryForced( 31877 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 31930; sp->procChance = sp->EffectBasePoints[0]+1; sp->EffectBasePoints[0] = 79; } sp = dbcSpell.LookupEntryForced( 31878 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 31930; sp->procChance = sp->EffectBasePoints[0]+1; sp->EffectBasePoints[0] = 79; } /********************************************************** * Blessed Life **********************************************************/ sp = dbcSpell.LookupEntryForced( 31828 ); if( sp != NULL ) { sp->EffectTriggerSpell[0] = 31828; } sp = dbcSpell.LookupEntryForced( 31829 ); if( sp != NULL ) { sp->EffectTriggerSpell[0] = 31828; } sp = dbcSpell.LookupEntryForced( 31830 ); if( sp != NULL ) { sp->EffectTriggerSpell[0] = 31828; } /********************************************************** * Light's Grace **********************************************************/ sp = dbcSpell.LookupEntryForced( 31833 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL; sp = dbcSpell.LookupEntryForced( 31835 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL; sp = dbcSpell.LookupEntryForced( 31836 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL; //Paladin: Seal of Wisdom uint32 procchance = 0; sp = dbcSpell.LookupEntryForced( 27116 ); if( sp != NULL ) procchance = sp->procChance; sp = dbcSpell.LookupEntryForced( 20166 ); if( sp != NULL ) sp->procChance = procchance; sp = dbcSpell.LookupEntryForced( 20356 ); if( sp != NULL ) sp->procChance = procchance; sp = dbcSpell.LookupEntryForced( 20357 ); if( sp != NULL ) sp->procChance = procchance; sp = dbcSpell.LookupEntryForced( 27166 ); if( sp != NULL ) sp->procChance = procchance; //paladin - seal of blood sp = dbcSpell.LookupEntryForced( 31892 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 31893; } sp = dbcSpell.LookupEntryForced( 38008 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 31893; } //paladin - Spiritual Attunement sp = dbcSpell.LookupEntryForced( 31785 ); if( sp != NULL ) { sp->procFlags = PROC_ON_SPELL_LAND_VICTIM | static_cast<uint32>(PROC_TARGET_SELF) ; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 31786; } sp = dbcSpell.LookupEntryForced( 33776 ); if( sp != NULL ) { sp->procFlags = PROC_ON_SPELL_LAND_VICTIM | static_cast<uint32>(PROC_TARGET_SELF); sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 31786; } //Seal of Justice -lowered proc chance (experimental values !) sp = dbcSpell.LookupEntryForced( 20164 ); if( sp != NULL ) sp->procChance = 20; sp = dbcSpell.LookupEntryForced( 31895 ); if( sp != NULL ) sp->procChance = 20; // paladin - Improved Sanctity Aura sp = dbcSpell.LookupEntryForced( 31869 ); if( sp != NULL ) { sp->EffectMiscValue[0] = SMT_MISC_EFFECT; } sp = dbcSpell.LookupEntryForced( 31870 ); if( sp != NULL ) { sp->EffectMiscValue[0] = SMT_MISC_EFFECT; } //Paladin - Improved Lay on Hands sp = dbcSpell.LookupEntryForced( 20234 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL; sp = dbcSpell.LookupEntryForced( 20235 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL; //Paladin - Crusader Strike sp = dbcSpell.LookupEntryForced( 35395 ); if( sp != NULL ) sp->noproc = true; ////////////////////////////////////////// // HUNTER // ////////////////////////////////////////// // Insert hunter spell fixes here //Hunter - Bestial Wrath sp = dbcSpell.LookupEntryForced( 19574 ); if( sp != NULL ) sp->EffectApplyAuraName[2] = SPELL_AURA_DUMMY; //Hunter - The Beast Within sp = dbcSpell.LookupEntryForced( 34692 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procFlags = PROC_ON_CAST_SPELL; sp->procChance = 100; sp->EffectTriggerSpell[0] = 34471; } sp = dbcSpell.LookupEntryForced( 34471 ); if( sp != NULL ) sp->EffectApplyAuraName[2] = SPELL_AURA_DUMMY; //Hunter - Go for the Throat sp = dbcSpell.LookupEntryForced( 34950 ); if( sp != NULL ) sp->procFlags = PROC_ON_RANGED_CRIT_ATTACK; sp = dbcSpell.LookupEntryForced( 34954 ); if( sp != NULL ) sp->procFlags = PROC_ON_RANGED_CRIT_ATTACK; sp = dbcSpell.LookupEntryForced( 34952 ); if( sp != NULL ) sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; sp = dbcSpell.LookupEntryForced( 34953 ); if( sp != NULL ) sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; // Hunter - Improved Wing Clip sp = dbcSpell.LookupEntryForced( 19228 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPECIFIC_SPELL; sp->ProcOnNameHash[0] = SPELL_HASH_WING_CLIP; } sp = dbcSpell.LookupEntryForced( 19232 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPECIFIC_SPELL; sp->ProcOnNameHash[0] = SPELL_HASH_WING_CLIP; } sp = dbcSpell.LookupEntryForced( 19233 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPECIFIC_SPELL; sp->ProcOnNameHash[0] = SPELL_HASH_WING_CLIP; } // Hunter - Master Tactician sp = dbcSpell.LookupEntryForced( 34506 ); if( sp != NULL ) sp->procFlags = PROC_ON_RANGED_ATTACK | static_cast<uint32>(PROC_TARGET_SELF); sp = dbcSpell.LookupEntryForced( 34507 ); if( sp != NULL ) sp->procFlags = PROC_ON_RANGED_ATTACK | static_cast<uint32>(PROC_TARGET_SELF); sp = dbcSpell.LookupEntryForced( 34508 ); if( sp != NULL ) sp->procFlags = PROC_ON_RANGED_ATTACK | static_cast<uint32>(PROC_TARGET_SELF); sp = dbcSpell.LookupEntryForced( 34838 ); if( sp != NULL ) sp->procFlags = PROC_ON_RANGED_ATTACK | static_cast<uint32>(PROC_TARGET_SELF); sp = dbcSpell.LookupEntryForced( 34839 ); if( sp != NULL ) sp->procFlags = PROC_ON_RANGED_ATTACK | static_cast<uint32>(PROC_TARGET_SELF); // Hunter - Spirit Bond sp = dbcSpell.LookupEntryForced( 19578 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_PET_OWNER | SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 19579; } sp = dbcSpell.LookupEntryForced( 20895 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_PET_OWNER | SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 24529; } sp = dbcSpell.LookupEntryForced( 19579 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[1] = SPELL_EFFECT_APPLY_AURA; //we should do the same for player too as we did for pet sp->EffectApplyAuraName[1] = sp->EffectApplyAuraName[0]; sp->EffectImplicitTargetA[1] = EFF_TARGET_PET; sp->EffectBasePoints[1] = sp->EffectBasePoints[0]; sp->EffectAmplitude[1] = sp->EffectAmplitude[0]; sp->EffectDieSides[1] = sp->EffectDieSides[0]; } sp = dbcSpell.LookupEntryForced( 24529 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[1] = SPELL_EFFECT_APPLY_AURA; //we should do the same for player too as we did for pet sp->EffectApplyAuraName[1] = sp->EffectApplyAuraName[0]; sp->EffectImplicitTargetA[1] = EFF_TARGET_PET; sp->EffectBasePoints[1] = sp->EffectBasePoints[0]; sp->EffectAmplitude[1] = sp->EffectAmplitude[0]; sp->EffectDieSides[1] = sp->EffectDieSides[0]; } //Hunter Silencing Shot //http://www.naxxramas.net/bug_list/showreport.php?bugid=234 NTY sp = dbcSpell.LookupEntryForced(34490); if(sp != NULL) { sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_SILENCE ; } // Hunter - Ferocious Inspiration sp = dbcSpell.LookupEntryForced( 34455 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; sp->EffectTriggerSpell[0] = 34456; sp->procFlags = PROC_ON_CRIT_ATTACK | PROC_ON_SPELL_CRIT_HIT | static_cast<uint32>(PROC_TARGET_SELF); //maybe target master ? sp->Effect[1] = 0; //remove this } sp = dbcSpell.LookupEntryForced( 34459 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; sp->EffectTriggerSpell[0] = 34456; sp->procFlags = PROC_ON_CRIT_ATTACK | PROC_ON_SPELL_CRIT_HIT | static_cast<uint32>(PROC_TARGET_SELF); sp->Effect[1] = 0; //remove this } sp = dbcSpell.LookupEntryForced( 34460 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; sp->EffectTriggerSpell[0] = 34456; sp->procFlags = PROC_ON_CRIT_ATTACK | PROC_ON_SPELL_CRIT_HIT | static_cast<uint32>(PROC_TARGET_SELF); sp->Effect[1] = 0; //remove this } // Hunter - Focused Fire sp = dbcSpell.LookupEntryForced( 35029 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_PET_OWNER | SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 35060; } sp = dbcSpell.LookupEntryForced( 35030 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_PET_OWNER | SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 35061; } sp = dbcSpell.LookupEntryForced( 35060 ); if( sp != NULL ) sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; sp = dbcSpell.LookupEntryForced( 35061 ); if( sp != NULL ) sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; // Hunter - Thrill of the Hunt sp = dbcSpell.LookupEntryForced( 34497 ); if( sp != NULL ) { sp->procFlags = PROC_ON_SPELL_CRIT_HIT | static_cast<uint32>(PROC_TARGET_SELF); sp->procChance = sp->EffectBasePoints[0]+1; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 34720; } sp = dbcSpell.LookupEntryForced( 34498 ); if( sp != NULL ) { sp->procFlags = PROC_ON_SPELL_CRIT_HIT | static_cast<uint32>(PROC_TARGET_SELF); sp->procChance = sp->EffectBasePoints[0]+1; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 34720; } sp = dbcSpell.LookupEntryForced( 34499 ); if( sp != NULL ) { sp->procFlags = PROC_ON_SPELL_CRIT_HIT | static_cast<uint32>(PROC_TARGET_SELF); sp->procChance = sp->EffectBasePoints[0]+1; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 34720; } // Hunter - Expose Weakness sp = dbcSpell.LookupEntryForced( 34500 ); if( sp != NULL ) sp->procFlags = PROC_ON_RANGED_CRIT_ATTACK; sp = dbcSpell.LookupEntryForced( 34502 ); if( sp != NULL ) sp->procFlags = PROC_ON_RANGED_CRIT_ATTACK; sp = dbcSpell.LookupEntryForced( 34503 ); if( sp != NULL ) sp->procFlags = PROC_ON_RANGED_CRIT_ATTACK; //Hunter - Frenzy sp = dbcSpell.LookupEntryForced( 19621 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 19615; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; sp->procChance = sp->EffectBasePoints[0]; sp->procFlags = PROC_ON_CRIT_ATTACK; sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET | SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET | static_cast<uint32>(PROC_TARGET_SELF); } sp = dbcSpell.LookupEntryForced( 19622 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 19615; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; sp->procChance = sp->EffectBasePoints[0]; sp->procFlags = PROC_ON_CRIT_ATTACK; sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET | SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET | static_cast<uint32>(PROC_TARGET_SELF); } sp = dbcSpell.LookupEntryForced( 19623 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 19615; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; sp->procChance = sp->EffectBasePoints[0]; sp->procFlags = PROC_ON_CRIT_ATTACK; sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET | SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET | static_cast<uint32>(PROC_TARGET_SELF); } sp = dbcSpell.LookupEntryForced( 19624 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 19615; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; sp->procChance = sp->EffectBasePoints[0]; sp->procFlags = PROC_ON_CRIT_ATTACK; sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET | SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET | static_cast<uint32>(PROC_TARGET_SELF); } sp = dbcSpell.LookupEntryForced( 19625 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 19615; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; sp->procChance = sp->EffectBasePoints[0]; sp->procFlags = PROC_ON_CRIT_ATTACK; sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET | SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET | static_cast<uint32>(PROC_TARGET_SELF); } //Hunter : Pathfinding sp = dbcSpell.LookupEntryForced( 19559 ); if( sp != NULL ) { sp->EffectMiscValue[0] = SMT_MISC_EFFECT; } sp = dbcSpell.LookupEntryForced( 19560 ); if( sp != NULL ) { sp->EffectMiscValue[0] = SMT_MISC_EFFECT; } sp = dbcSpell.LookupEntryForced( 5131 ); if( sp != NULL ) sp->SpellGroupType = 2097152; sp = dbcSpell.LookupEntryForced( 13160 ); if( sp != NULL ) sp->SpellGroupType = 2097152; //Hunter : Rapid Killing - might need to add honor trigger too here. I'm guessing you receive Xp too so i'm avoiding double proc sp = dbcSpell.LookupEntryForced( 34948 ); if( sp != NULL ) { sp->procFlags = PROC_ON_GAIN_EXPIERIENCE | static_cast<uint32>(PROC_TARGET_SELF); } sp = dbcSpell.LookupEntryForced( 34949 ); if( sp != NULL ) { sp->procFlags = PROC_ON_GAIN_EXPIERIENCE | static_cast<uint32>(PROC_TARGET_SELF); } //we need to adress this somehow : shot sp = dbcSpell.LookupEntryForced( 3018 ); if( sp != NULL ) sp->SpellGroupType = 4; //Hunter : Entrapment sp = dbcSpell.LookupEntryForced( 19184 ); if( sp != NULL ) sp->procFlags = PROC_ON_TRAP_TRIGGER; sp = dbcSpell.LookupEntryForced( 19387 ); if( sp != NULL ) sp->procFlags = PROC_ON_TRAP_TRIGGER; sp = dbcSpell.LookupEntryForced( 19388 ); if( sp != NULL ) sp->procFlags = PROC_ON_TRAP_TRIGGER; /* aspect of the pack - change to AA */ sp = dbcSpell.LookupEntryForced( 13159 ); if( sp != NULL ) sp->procFlags = PROC_ON_ANY_DAMAGE_VICTIM; /* aspect of the cheetah - add proc flags */ sp = dbcSpell.LookupEntryForced( 5118 ); if( sp != NULL ) sp->procFlags = PROC_ON_ANY_DAMAGE_VICTIM; ////////////////////////////////////////// // ROGUE // ////////////////////////////////////////// // Insert rogue spell fixes here /********************************************************** * Garrote - this is used? **********************************************************/ sp = dbcSpell.LookupEntryForced( 37066 ); if( sp != NULL ) { sp->EffectImplicitTargetA[0] = EFF_TARGET_SINGLE_ENEMY; sp->EffectImplicitTargetA[1] = EFF_TARGET_SINGLE_ENEMY; } //rogue - Find Weakness. sp = dbcSpell.LookupEntryForced( 31233 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL; sp = dbcSpell.LookupEntryForced( 31239 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL; sp = dbcSpell.LookupEntryForced( 31240 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL; sp = dbcSpell.LookupEntryForced( 31241 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL; sp = dbcSpell.LookupEntryForced( 31242 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL; //rogue - Camouflage. sp = dbcSpell.LookupEntryForced( 13975 ); if( sp != NULL ) { sp->EffectMiscValue[0] = SMT_MISC_EFFECT; } sp = dbcSpell.LookupEntryForced( 14062 ); if( sp != NULL ) { sp->EffectMiscValue[0] = SMT_MISC_EFFECT; } sp = dbcSpell.LookupEntryForced( 14063 ); if( sp != NULL ) { sp->EffectMiscValue[0] = SMT_MISC_EFFECT; } sp = dbcSpell.LookupEntryForced( 14064 ); if( sp != NULL ) { sp->EffectMiscValue[0] = SMT_MISC_EFFECT; } sp = dbcSpell.LookupEntryForced( 14065 ); if( sp != NULL ) { sp->EffectMiscValue[0] = SMT_MISC_EFFECT; } //rogue - Vanish : Second Trigger Spell sp = dbcSpell.LookupEntryForced( 18461 ); if( sp != NULL ) sp->AttributesEx |= ATTRIBUTESEX_NOT_BREAK_STEALTH; // rogue - shadowstep // sp = dbcSpell.LookupEntryForced( 36554 ); // if( sp != NULL ) // sp->AttributesEx |= ATTRIBUTESEX_NOT_BREAK_STEALTH; // rogue - Blind (Make it able to miss!) sp = dbcSpell.LookupEntryForced( 2094 ); if( sp != NULL ) { sp->Spell_Dmg_Type = SPELL_DMG_TYPE_RANGED; sp->is_ranged_spell = true; } //rogue - Mace Specialization. sp = dbcSpell.LookupEntryForced( 13709 ); if( sp != NULL ) sp->procFlags = PROC_ON_MELEE_ATTACK; sp = dbcSpell.LookupEntryForced( 13800 ); if( sp != NULL ) sp->procFlags = PROC_ON_MELEE_ATTACK; sp = dbcSpell.LookupEntryForced( 13801 ); if( sp != NULL ) sp->procFlags = PROC_ON_MELEE_ATTACK; sp = dbcSpell.LookupEntryForced( 13802 ); if( sp != NULL ) sp->procFlags = PROC_ON_MELEE_ATTACK; sp = dbcSpell.LookupEntryForced( 13803 ); if( sp != NULL ) sp->procFlags = PROC_ON_MELEE_ATTACK; //rogue - Shadowstep sp = dbcSpell.LookupEntryForced( 36563 ); if( sp != NULL ) { sp->EffectMiscValue[2] = SMT_MISC_EFFECT; // sp->EffectTriggerSpell[1] = 36554; // sp->EffectTriggerSpell[2] = 44373; // sp->procFlags = PROC_ON_CAST_SPELL; } // Still related to shadowstep - prevent the trigger spells from breaking stealth. sp = dbcSpell.LookupEntryForced( 44373 ); if( sp ) sp->AttributesEx |= ATTRIBUTESEX_NOT_BREAK_STEALTH; sp = dbcSpell.LookupEntryForced( 36563 ); if( sp ) sp->AttributesEx |= ATTRIBUTESEX_NOT_BREAK_STEALTH; sp = dbcSpell.LookupEntryForced( 36554 ); if( sp != NULL ) sp->AttributesEx |= ATTRIBUTESEX_NOT_BREAK_STEALTH; //rogue - Seal Fate sp = dbcSpell.LookupEntryForced( 14186 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 14189; sp->procFlags = PROC_ON_CRIT_ATTACK; sp->procChance = 20; } sp = dbcSpell.LookupEntryForced( 14190 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 14189; sp->procFlags = PROC_ON_CRIT_ATTACK; sp->procChance = 40; } sp = dbcSpell.LookupEntryForced( 14193 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 14189; sp->procFlags = PROC_ON_CRIT_ATTACK; sp->procChance = 60; } sp = dbcSpell.LookupEntryForced( 14194 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 14189; sp->procFlags = PROC_ON_CRIT_ATTACK; sp->procChance = 80; } sp = dbcSpell.LookupEntryForced( 14195 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 14189; sp->procFlags = PROC_ON_CRIT_ATTACK; sp->procChance = 100; } #ifndef NEW_PROCFLAGS //Improved Sprint sp = dbcSpell.LookupEntryForced( 13743 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->procChance = 50; } sp = dbcSpell.LookupEntryForced( 13875 ); if( sp != NULL ) { sp->procChance = 100; sp->procFlags = PROC_ON_CAST_SPELL; } #else //Improved Sprint sp = dbcSpell.LookupEntryForced( 13743 ); if( sp != NULL ) sp->EffectSpellGroupRelation[0]=64; sp = dbcSpell.LookupEntryForced( 13875 ); if( sp != NULL ) sp->EffectSpellGroupRelation[0]=64; #endif //garrot sp = dbcSpell.LookupEntryForced( 703 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 8631 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 8632 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 8633 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 11289 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 11290 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 26839 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 26884 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; //rupture sp = dbcSpell.LookupEntryForced( 1943 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 8639 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 8640 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 11273 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 11274 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 11275 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 26867 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; #ifndef NEW_PROCFLAGS //Relentless Strikes sp = dbcSpell.LookupEntryForced( 14179 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL;//proc spell sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectBasePoints[1] = 20; //client showes 20% chance but whe do not have it ? :O } #else //Relentless Strikes sp = dbcSpell.LookupEntryForced( 14179 ); if( sp != NULL ) sp->EffectSpellGroupRelation[0]= 262144 | 2097152 | 8388608 | 8519680 | 524288 | 1048576 | 8388608; #endif #ifndef NEW_PROCFLAGS //rogue - intiative sp = dbcSpell.LookupEntryForced( 13976 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procFlags = uint32(PROC_ON_CAST_SPELL|PROC_TARGET_SELF); } sp = dbcSpell.LookupEntryForced( 13979 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procFlags = uint32(PROC_ON_CAST_SPELL|PROC_TARGET_SELF); } sp = dbcSpell.LookupEntryForced( 13980 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procFlags = uint32(PROC_ON_CAST_SPELL|PROC_TARGET_SELF); } #else //rogue - intiative sp = dbcSpell.LookupEntryForced( 13976 ); if( sp != NULL ) sp->EffectSpellGroupRelation[0] = 8389120 | 256 | 1024; sp = dbcSpell.LookupEntryForced( 13979 ); if( sp != NULL ) sp->EffectSpellGroupRelation[0] = 8389120 | 256 | 1024; sp = dbcSpell.LookupEntryForced( 13980 ); if( sp != NULL ) sp->EffectSpellGroupRelation[0] = 8389120 | 256 | 1024; #endif ////////////////////////////////////////// // PRIEST // ////////////////////////////////////////// // Insert priest spell fixes here // Prayer of mending. !very very overwriten // how it is after rewriten : we simply proc on damage and prochandler will get new target + do healing sp = dbcSpell.LookupEntryForced( 33076 ); if( sp != NULL ) { //we use this heal spell when we jump to other player SpellEntry *healsp = dbcSpell.LookupEntryForced( sp->EffectTriggerSpell[1] ); if( healsp ) { healsp->Effect[0] = SPELL_EFFECT_HEAL; healsp->Effect[1] = healsp->Effect[2] = SPELL_EFFECT_NULL; healsp->EffectBasePoints[0] = sp->EffectBasePoints[0]; healsp->EffectBaseDice[0] = sp->EffectBaseDice[0]; healsp->EffectDicePerLevel[0] = sp->EffectDicePerLevel[0]; healsp->EffectDieSides[0] = sp->EffectDieSides[0]; healsp->EffectImplicitTargetA[0] = EFF_TARGET_PARTY_MEMBER; } //this spell is just to register the proc SpellEntry *procsp = dbcSpell.LookupEntryForced( sp->EffectTriggerSpell[0] ); if( procsp ) { procsp->Effect[0] = SPELL_EFFECT_APPLY_AURA; healsp->Effect[1] = healsp->Effect[2] = SPELL_EFFECT_NULL; procsp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; procsp->EffectBasePoints[0] = sp->procCharges - 1; //we loose 1 charge each time we cast so we need this value mobile procsp->EffectImplicitTargetA[0] = EFF_TARGET_PARTY_MEMBER; //we jump on an injured party member procsp->EffectTriggerSpell[0] = sp->EffectTriggerSpell[1]; //!we proc self but our system does not allow proc loops ! procsp->procCharges = 1; procsp->procFlags = PROC_ON_ANY_DAMAGE_VICTIM | static_cast<uint32>(PROC_TARGET_SELF); } //simplify old system with a simple cast spell sp->Effect[0] = SPELL_EFFECT_TRIGGER_SPELL; sp->Effect[1] = SPELL_EFFECT_NULL; sp->Effect[2] = SPELL_EFFECT_NULL; } // Spirit Tap sp = dbcSpell.LookupEntryForced( 15270 ); //rank 1 if( sp != NULL ) { // sp->procFlags = PROC_ON_TARGET_DIE; sp->procFlags = PROC_ON_GAIN_EXPIERIENCE; } sp = dbcSpell.LookupEntryForced( 15335 ); //rank 2 if( sp != NULL ) { // sp->procFlags = PROC_ON_TARGET_DIE; sp->procFlags = PROC_ON_GAIN_EXPIERIENCE; } sp = dbcSpell.LookupEntryForced( 15336 ); //rank 3 if( sp != NULL ) { // sp->procFlags = PROC_ON_TARGET_DIE; sp->procFlags = PROC_ON_GAIN_EXPIERIENCE; } sp = dbcSpell.LookupEntryForced( 15337 ); //rank 4 if( sp != NULL ) { // sp->procFlags = PROC_ON_TARGET_DIE; sp->procFlags = PROC_ON_GAIN_EXPIERIENCE; } sp = dbcSpell.LookupEntryForced( 15338 ); //rank 5 if( sp != NULL ) { // sp->procFlags = PROC_ON_TARGET_DIE; sp->procFlags = PROC_ON_GAIN_EXPIERIENCE; } /********************************************************** * Holy Nova **********************************************************/ sp = dbcSpell.LookupEntryForced( 15237 ); if( sp != NULL ) { sp->Effect[1] = 64; sp->EffectTriggerSpell[1] = 23455; } sp = dbcSpell.LookupEntryForced( 15430 ); if( sp != NULL ) { sp->Effect[1] = 64; sp->EffectTriggerSpell[1] = 23458; } sp = dbcSpell.LookupEntryForced( 15431 ); if( sp != NULL ) { sp->Effect[1] = 64; sp->EffectTriggerSpell[1] = 23459; } sp = dbcSpell.LookupEntryForced( 27799 ); if( sp != NULL ) { sp->Effect[1] = 64; sp->EffectTriggerSpell[1] = 27803; } sp = dbcSpell.LookupEntryForced( 27800 ); if( sp != NULL ) { sp->Effect[1] = 64; sp->EffectTriggerSpell[1] = 27804; } sp = dbcSpell.LookupEntryForced( 27801 ); if( sp != NULL ) { sp->Effect[1] = 64; sp->EffectTriggerSpell[1] = 27805; } sp = dbcSpell.LookupEntryForced( 25331 ); if( sp != NULL ) { sp->Effect[1] = 64; sp->EffectTriggerSpell[1] = 25329; } //priest - Holy Concentration sp = dbcSpell.LookupEntryForced( 34753 ); if (sp != NULL) sp->procFlags = PROC_ON_CAST_SPELL; sp = dbcSpell.LookupEntryForced( 34859 ); if (sp != NULL) sp->procFlags = PROC_ON_CAST_SPELL; sp = dbcSpell.LookupEntryForced( 34860 ); if (sp != NULL) sp->procFlags = PROC_ON_CAST_SPELL; //Priest: Blessed Recovery sp = dbcSpell.LookupEntryForced(27811); if(sp != NULL) { sp->EffectTriggerSpell[0] = 27813; sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM; } sp = dbcSpell.LookupEntryForced(27815); if(sp != NULL) { sp->EffectTriggerSpell[0] = 27817; sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM; } sp = dbcSpell.LookupEntryForced(27816); if(sp != NULL) { sp->EffectTriggerSpell[0] = 27818; sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM; } //priest- Blessed Resilience sp = dbcSpell.LookupEntryForced( 33142 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_SPELL_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM; sp->procChance = 20; } sp = dbcSpell.LookupEntryForced( 33145 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_SPELL_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM; sp->procChance = 40; } sp = dbcSpell.LookupEntryForced( 33146 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_SPELL_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM; sp->procChance = 60; } //priest- Focused Will sp = dbcSpell.LookupEntryForced( 45234 ); if( sp != NULL ) sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_SPELL_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM; sp = dbcSpell.LookupEntryForced( 45243 ); if( sp != NULL ) sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_SPELL_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM; sp = dbcSpell.LookupEntryForced( 45244 ); if( sp != NULL ) sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_SPELL_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM; //Priest: Shadowguard sp = dbcSpell.LookupEntryForced( 18137 ); if( sp != NULL ) { sp->procFlags = PROC_ON_SPELL_HIT_VICTIM | PROC_ON_RANGED_ATTACK_VICTIM | PROC_ON_MELEE_ATTACK_VICTIM; sp->proc_interval = 3000; //every 3 seconds sp->EffectTriggerSpell[0] = 28377; } sp = dbcSpell.LookupEntryForced( 19308 ); if( sp != NULL ) { sp->procFlags = PROC_ON_SPELL_HIT_VICTIM | PROC_ON_RANGED_ATTACK_VICTIM | PROC_ON_MELEE_ATTACK_VICTIM; sp->proc_interval = 3000; //every 3 seconds sp->EffectTriggerSpell[0] = 28378; } sp = dbcSpell.LookupEntryForced( 19309 ); if( sp != NULL ) { sp->procFlags = PROC_ON_SPELL_HIT_VICTIM | PROC_ON_RANGED_ATTACK_VICTIM | PROC_ON_MELEE_ATTACK_VICTIM; sp->proc_interval = 3000; //every 3 seconds sp->EffectTriggerSpell[0] = 28379; } sp = dbcSpell.LookupEntryForced( 19310 ); if( sp != NULL ) { sp->procFlags = PROC_ON_SPELL_HIT_VICTIM | PROC_ON_RANGED_ATTACK_VICTIM | PROC_ON_MELEE_ATTACK_VICTIM; sp->proc_interval = 3000; //every 3 seconds sp->EffectTriggerSpell[0] = 28380; } sp = dbcSpell.LookupEntryForced( 19311 ); if( sp != NULL ) { sp->procFlags = PROC_ON_SPELL_HIT_VICTIM | PROC_ON_RANGED_ATTACK_VICTIM | PROC_ON_MELEE_ATTACK_VICTIM; sp->proc_interval = 3000; //every 3 seconds sp->EffectTriggerSpell[0] = 28381; } sp = dbcSpell.LookupEntryForced( 19312 ); if( sp != NULL ) { sp->procFlags = PROC_ON_SPELL_HIT_VICTIM | PROC_ON_RANGED_ATTACK_VICTIM | PROC_ON_MELEE_ATTACK_VICTIM; sp->proc_interval = 3000; //every 3 seconds sp->EffectTriggerSpell[0] = 28382; } sp = dbcSpell.LookupEntryForced( 25477 ); if( sp != NULL ) { sp->procFlags = PROC_ON_SPELL_HIT_VICTIM | PROC_ON_RANGED_ATTACK_VICTIM | PROC_ON_MELEE_ATTACK_VICTIM; sp->proc_interval = 3000; //every 3 seconds sp->EffectTriggerSpell[0] = 28385; } //Priest - Wand Specialization sp = dbcSpell.LookupEntryForced( 14524 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectMiscValue[0] = SMT_MISC_EFFECT; } sp = dbcSpell.LookupEntryForced( 14525 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectMiscValue[0] = SMT_MISC_EFFECT; } sp = dbcSpell.LookupEntryForced( 14526 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectMiscValue[0] = SMT_MISC_EFFECT; } sp = dbcSpell.LookupEntryForced( 14527 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectMiscValue[0] = SMT_MISC_EFFECT; } sp = dbcSpell.LookupEntryForced( 14528 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectMiscValue[0] = SMT_MISC_EFFECT; } #ifdef NEW_PROCFLAGS //priest - Shadow Weaving if (sp != NULL) { uint32 group = sp->EffectSpellGroupRelation[0]; sp = dbcSpell.LookupEntryForced(15334); if (sp !=NULL) sp->EffectSpellGroupRelation[0] = group; sp = dbcSpell.LookupEntryForced(15333); if (sp !=NULL) sp->EffectSpellGroupRelation[0] = group; sp = dbcSpell.LookupEntryForced(15332); if (sp !=NULL) sp->EffectSpellGroupRelation[0] = group; sp = dbcSpell.LookupEntryForced(15331); if (sp !=NULL) sp->EffectSpellGroupRelation[0] = group; sp = dbcSpell.LookupEntryForced(15257); if (sp !=NULL) sp->EffectSpellGroupRelation[0] = group; } #endif //Priest - Inspiration proc spell sp = dbcSpell.LookupEntryForced( 14893 ); if( sp != NULL ) sp->rangeIndex = 4; sp = dbcSpell.LookupEntryForced( 15357 ); if( sp != NULL ) sp->rangeIndex = 4; sp = dbcSpell.LookupEntryForced( 15359 ); if( sp != NULL ) sp->rangeIndex = 4; //priest - surge of light sp = dbcSpell.LookupEntryForced( 33150 ); if( sp != NULL ) sp->procFlags = uint32(PROC_ON_SPELL_CRIT_HIT | static_cast<uint32>(PROC_TARGET_SELF)); sp = dbcSpell.LookupEntryForced( 33154 ); if( sp != NULL ) sp->procFlags = uint32(PROC_ON_SPELL_CRIT_HIT | static_cast<uint32>(PROC_TARGET_SELF)); sp = dbcSpell.LookupEntryForced( 33151 ); if( sp != NULL ) { sp->AuraInterruptFlags = AURA_INTERRUPT_ON_CAST_SPELL; } // priest - Reflective Shield sp = dbcSpell.LookupEntryForced( 33201 ); if( sp != NULL ) { sp->procFlags = PROC_ON_ABSORB; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 33619; //!! WRONG spell, we will make direct dmg here } sp = dbcSpell.LookupEntryForced( 33202 ); if( sp != NULL ) { sp->procFlags = PROC_ON_ABSORB; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 33619; //!! WRONG spell, we will make direct dmg here } sp = dbcSpell.LookupEntryForced( 33203 ); if( sp != NULL ) { sp->procFlags = PROC_ON_ABSORB; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 33619; //!! WRONG spell, we will make direct dmg here } sp = dbcSpell.LookupEntryForced( 33204 ); if( sp != NULL ) { sp->procFlags = PROC_ON_ABSORB; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 33619; //!! WRONG spell, we will make direct dmg here } sp = dbcSpell.LookupEntryForced( 33205 ); if( sp != NULL ) { sp->procFlags = PROC_ON_ABSORB; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 33619; //!! WRONG spell, we will make direct dmg here } ////////////////////////////////////////// // SHAMAN // ////////////////////////////////////////// // Insert shaman spell fixes here /********************************************************** * Elemental Mastery **********************************************************/ sp = dbcSpell.LookupEntryForced(16166); if(sp != NULL) { sp->AuraInterruptFlags = AURA_INTERRUPT_ON_AFTER_CAST_SPELL; } /********************************************************** * Shamanistic Rage **********************************************************/ SpellEntry* parentsp = dbcSpell.LookupEntryForced( 30823 ); SpellEntry* triggersp = dbcSpell.LookupEntryForced( 30824 ); if( parentsp != NULL && triggersp != NULL ) triggersp->EffectBasePoints[0] = parentsp->EffectBasePoints[0]; //summon only 1 elemental totem sp = dbcSpell.LookupEntryForced( 2894 ); if( sp != NULL && sp->Id == 2894 ) sp->EffectImplicitTargetA[0] = EFF_TARGET_TOTEM_FIRE; //remove this targeting. it is enough to get 1 target //summon only 1 elemental totem sp = dbcSpell.LookupEntryForced( 2062 ); if( sp != NULL && sp->Id == 2062 ) sp->EffectImplicitTargetA[0] = EFF_TARGET_TOTEM_EARTH; //remove this targeting. it is enough to get 1 target /********************************************************** * Elemental Focus **********************************************************/ sp = dbcSpell.LookupEntryForced( 16164 ); if( sp != NULL && sp->Id == 16164 ) sp->procFlags = PROC_ON_SPELL_CRIT_HIT; /********************************************************** * Stormstrike **********************************************************/ sp = dbcSpell.LookupEntryForced( 17364 ); if( sp != NULL && sp->Id == 17364 ) { sp->procFlags=PROC_ON_SPELL_HIT_VICTIM ; } /********************************************************** * Bloodlust **********************************************************/ sp = dbcSpell.LookupEntryForced( 2825 ); if( sp != NULL ) { sp->EffectImplicitTargetA[0] = EFF_TARGET_ALL_PARTY; sp->EffectImplicitTargetA[1] = EFF_TARGET_ALL_PARTY; sp->EffectImplicitTargetA[2] = EFF_TARGET_ALL_PARTY; sp->EffectImplicitTargetB[0] = 0; sp->EffectImplicitTargetB[1] = 0; sp->EffectImplicitTargetB[2] = 0; } /********************************************************** * Heroism **********************************************************/ sp = dbcSpell.LookupEntryForced( 32182 ); if( sp != NULL ) { sp->EffectImplicitTargetA[0] = EFF_TARGET_ALL_PARTY; sp->EffectImplicitTargetA[1] = EFF_TARGET_ALL_PARTY; sp->EffectImplicitTargetA[2] = EFF_TARGET_ALL_PARTY; sp->EffectImplicitTargetB[0] = 0; sp->EffectImplicitTargetB[1] = 0; sp->EffectImplicitTargetB[2] = 0; } /********************************************************** * Lightning Overload **********************************************************/ sp = dbcSpell.LookupEntryForced( 30675 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 39805;//proc something (we will owerride this) sp->procFlags = PROC_ON_SPELL_HIT; } sp = dbcSpell.LookupEntryForced( 30678 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 39805;//proc something (we will owerride this) sp->procFlags = PROC_ON_SPELL_HIT; } sp = dbcSpell.LookupEntryForced( 30679 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 39805;//proc something (we will owerride this) sp->procFlags = PROC_ON_SPELL_HIT; } sp = dbcSpell.LookupEntryForced( 30680 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 39805;//proc something (we will owerride this) sp->procFlags = PROC_ON_SPELL_HIT; } sp = dbcSpell.LookupEntryForced( 30681 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 39805;//proc something (we will owerride this) sp->procFlags = PROC_ON_SPELL_HIT; } /********************************************************** * Purge **********************************************************/ sp = dbcSpell.LookupEntryForced( 370 ); if( sp != NULL ) sp->DispelType = DISPEL_MAGIC; sp = dbcSpell.LookupEntryForced( 8012 ); if( sp != NULL ) sp->DispelType = DISPEL_MAGIC; sp = dbcSpell.LookupEntryForced( 27626 ); if( sp != NULL ) sp->DispelType = DISPEL_MAGIC; sp = dbcSpell.LookupEntryForced( 33625 ); if( sp != NULL ) sp->DispelType = DISPEL_MAGIC; /********************************************************** * Eye of the Storm **********************************************************/ sp = dbcSpell.LookupEntryForced( 29062 ); if( sp != NULL ) sp->procFlags = PROC_ON_CRIT_HIT_VICTIM; sp = dbcSpell.LookupEntryForced( 29064 ); if( sp != NULL ) sp->procFlags = PROC_ON_CRIT_HIT_VICTIM; sp = dbcSpell.LookupEntryForced( 29065 ); if( sp != NULL ) sp->procFlags = PROC_ON_CRIT_HIT_VICTIM; /********************************************************** * Shamanistic Focus **********************************************************/ sp = dbcSpell.LookupEntryForced( 43338 ); if( sp != NULL ) sp->procFlags = PROC_ON_CRIT_ATTACK; sp = dbcSpell.LookupEntryForced( 43339 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } //shaman - Improved Chain Heal sp = dbcSpell.LookupEntryForced( 30873 ); if( sp != NULL ){ sp->EffectDieSides[0] = 0; } sp = dbcSpell.LookupEntryForced( 30872 ); if( sp != NULL ){ sp->EffectDieSides[0] = 0; } // Flametongue Weapon - 10% spd coefficient sp = dbcSpell.LookupEntryForced( 29469 ); if( sp != NULL ) sp->fixed_dddhcoef = 0.1f; // Flametongue Totem - 0% spd coefficient sp = dbcSpell.LookupEntryForced( 16368 ); if( sp != NULL ) sp->fixed_dddhcoef = 0.0f; //shaman - Improved Weapon Totems sp = dbcSpell.LookupEntryForced( 29193 ); if( sp != NULL ){ sp->EffectApplyAuraName[0]=SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectApplyAuraName[1]=SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectMiscValue[0] = SMT_MISC_EFFECT; sp->EffectMiscValue[1] = SMT_MISC_EFFECT; } sp = dbcSpell.LookupEntryForced( 29192 ); if( sp != NULL ){ sp->EffectApplyAuraName[0]=SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectApplyAuraName[1]=SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectMiscValue[0] = SMT_MISC_EFFECT; sp->EffectMiscValue[1] = SMT_MISC_EFFECT; } // Shaman - Improved Fire Totems sp = dbcSpell.LookupEntryForced( 16544 ); if( sp != NULL ){ sp->EffectMiscValue[0] = SMT_DURATION; } sp = dbcSpell.LookupEntryForced( 16086 ); if( sp != NULL ){ sp->EffectMiscValue[0] = SMT_DURATION; } // Shaman Arena totems fix // Totem of Survival sp = dbcSpell.LookupEntryForced( 46097 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } sp = dbcSpell.LookupEntryForced( 43860 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } sp = dbcSpell.LookupEntryForced( 43861 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } sp = dbcSpell.LookupEntryForced( 43862 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } // Totem of Indomitability sp = dbcSpell.LookupEntryForced( 43859 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } sp = dbcSpell.LookupEntryForced( 46096 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } sp = dbcSpell.LookupEntryForced( 43857 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } sp = dbcSpell.LookupEntryForced( 43858 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } // Totem of Third WInd sp = dbcSpell.LookupEntryForced( 46098 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } sp = dbcSpell.LookupEntryForced( 34138 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } sp = dbcSpell.LookupEntryForced( 42370 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } sp = dbcSpell.LookupEntryForced( 43728 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } //shaman - Elemental Weapons sp = dbcSpell.LookupEntryForced( 29080 ); if( sp != NULL ){ sp->EffectMiscValue[1] = SMT_DAMAGE_DONE; sp->EffectMiscValue[2] = SMT_DAMAGE_DONE; } sp = dbcSpell.LookupEntryForced( 29079 ); if( sp != NULL ){ sp->EffectMiscValue[1] = SMT_DAMAGE_DONE; sp->EffectMiscValue[2] = SMT_DAMAGE_DONE; } sp = dbcSpell.LookupEntryForced( 16266 ); if( sp != NULL ){ sp->EffectMiscValue[1] = SMT_DAMAGE_DONE; sp->EffectMiscValue[2] = SMT_DAMAGE_DONE; } // Magma Totem - 0% spd coefficient sp = dbcSpell.LookupEntryForced( 25550 ); if( sp != NULL ) sp->fixed_dddhcoef = 0.0f; sp = dbcSpell.LookupEntryForced( 10581 ); if( sp != NULL ) sp->fixed_dddhcoef = 0.0f; sp = dbcSpell.LookupEntryForced( 10580 ); if( sp != NULL ) sp->fixed_dddhcoef = 0.0f; sp = dbcSpell.LookupEntryForced( 10579 ); if( sp != NULL ) sp->fixed_dddhcoef = 0.0f; sp = dbcSpell.LookupEntryForced( 8187 ); if( sp != NULL ) sp->fixed_dddhcoef = 0.0f; /********************************************************** * Healing Way **********************************************************/ /* Zack : disabled this to not create confusion that it is working. Burlex deleted code so it needs to be reverted in order to work sp = dbcSpell.LookupEntryForced( 29202 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectImplicitTargetA[0] = EFF_TARGET_SCRIPTED_OR_SINGLE_TARGET; sp->procChance = sp->EffectBasePoints[0] + 1; } sp = dbcSpell.LookupEntryForced( 29205 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectImplicitTargetA[0] = EFF_TARGET_SCRIPTED_OR_SINGLE_TARGET; sp->procChance = sp->EffectBasePoints[0] + 1; } sp = dbcSpell.LookupEntryForced( 29206 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectImplicitTargetA[0] = EFF_TARGET_SCRIPTED_OR_SINGLE_TARGET; sp->procChance = sp->EffectBasePoints[0] + 1; } */ /********************************************************** * Elemental Devastation **********************************************************/ sp = dbcSpell.LookupEntryForced( 29179 ); if( sp != NULL ) sp->procFlags = PROC_ON_SPELL_CRIT_HIT; sp = dbcSpell.LookupEntryForced( 29180 ); if( sp != NULL ) sp->procFlags = PROC_ON_SPELL_CRIT_HIT; sp = dbcSpell.LookupEntryForced( 30160 ); if( sp != NULL ) sp->procFlags = PROC_ON_SPELL_CRIT_HIT; /********************************************************** * Ancestral healing **********************************************************/ sp = dbcSpell.LookupEntryForced( 16176 ); if( sp != NULL ) sp->procFlags = PROC_ON_SPELL_CRIT_HIT; sp = dbcSpell.LookupEntryForced( 16235 ); if( sp != NULL ) sp->procFlags = PROC_ON_SPELL_CRIT_HIT; sp = dbcSpell.LookupEntryForced( 16240 ); if( sp != NULL ) sp->procFlags = PROC_ON_SPELL_CRIT_HIT; /********************************************************** * Ancestral healing proc spell **********************************************************/ sp = dbcSpell.LookupEntryForced( 16177 ); if( sp != NULL ) sp->rangeIndex = 4; sp = dbcSpell.LookupEntryForced( 16236 ); if( sp != NULL ) sp->rangeIndex = 4; sp = dbcSpell.LookupEntryForced( 16237 ); if( sp != NULL ) sp->rangeIndex = 4; //wrath of air totem targets sorounding creatures instead of us sp = dbcSpell.LookupEntryForced( 2895 ); if( sp != NULL ) { sp->EffectImplicitTargetA[0] = EFF_TARGET_SELF; sp->EffectImplicitTargetA[1] = EFF_TARGET_SELF; sp->EffectImplicitTargetA[2] = 0; sp->EffectImplicitTargetB[0] = 0; sp->EffectImplicitTargetB[1] = 0; sp->EffectImplicitTargetB[2] = 0; } sp = dbcSpell.LookupEntryForced( 20608 ); //Reincarnation if( sp != NULL ) { for(uint32 i=0;i<8;i++) { if(sp->Reagent[i]) { sp->Reagent[i] = 0; sp->ReagentCount[i] = 0; } } } ////////////////////////////////////////// // MAGE // ////////////////////////////////////////// // Insert mage spell fixes here /********************************************************** * Improved Blink by Alice **********************************************************/ //Improved Blink - *Rank 1* sp = dbcSpell.LookupEntryForced( 31569 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPECIFIC_SPELL; } //Improved Blink - *Rank 2* sp = dbcSpell.LookupEntryForced( 31570 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPECIFIC_SPELL; } /********************************************************** * Arcane Concentration **********************************************************/ sp = dbcSpell.LookupEntryForced( 11213 ); if( sp != NULL ) sp->procFlags = PROC_ON_SPELL_HIT | static_cast<uint32>(PROC_TARGET_SELF); sp = dbcSpell.LookupEntryForced( 12574 ); if( sp != NULL ) sp->procFlags = PROC_ON_SPELL_HIT | static_cast<uint32>(PROC_TARGET_SELF); sp = dbcSpell.LookupEntryForced( 12575 ); if( sp != NULL ) sp->procFlags = PROC_ON_SPELL_HIT | static_cast<uint32>(PROC_TARGET_SELF); sp = dbcSpell.LookupEntryForced( 12576 ); if( sp != NULL ) sp->procFlags = PROC_ON_SPELL_HIT | static_cast<uint32>(PROC_TARGET_SELF); sp = dbcSpell.LookupEntryForced( 12577 ); if( sp != NULL ) sp->procFlags = PROC_ON_SPELL_HIT | static_cast<uint32>(PROC_TARGET_SELF); //Mage - Wand Specialization. Not the forst thing we messed up. Blizz uses attack as magic and wandds as weapons :S sp = dbcSpell.LookupEntryForced( 6057 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectMiscValue[0] = SMT_MISC_EFFECT; } sp = dbcSpell.LookupEntryForced( 6085 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectMiscValue[0] = SMT_MISC_EFFECT; } //Mage - Spell Power sp = dbcSpell.LookupEntryForced( 35578 ); if( sp != NULL ) { sp->EffectMiscValue[0] = SMT_CRITICAL_DAMAGE; sp->EffectApplyAuraName[0] = SPELL_AURA_ADD_PCT_MODIFIER; } sp = dbcSpell.LookupEntryForced( 35581 ); if( sp != NULL ) { sp->EffectMiscValue[0] = SMT_CRITICAL_DAMAGE; sp->EffectApplyAuraName[0] = SPELL_AURA_ADD_PCT_MODIFIER; } //Mage - Elemental Precision sp = dbcSpell.LookupEntryForced( 29438 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectMiscValue[0] = SMT_COST; } sp = dbcSpell.LookupEntryForced( 29439 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectMiscValue[0] = SMT_COST; } sp = dbcSpell.LookupEntryForced( 29440 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectMiscValue[0] = SMT_COST; } //Mage - Arcane Blast sp = dbcSpell.LookupEntryForced( 30451 ); if( sp != NULL ) { sp->EffectApplyAuraName[1] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[1] = 36032; sp->procFlags = PROC_ON_CAST_SPECIFIC_SPELL; } //mage : Empowered Arcane Missiles sp = dbcSpell.LookupEntryForced( 31579 ); if( sp != NULL ) { sp->EffectBasePoints[0] *= 5; //heh B thinks he is smart by adding this to description ? If it doesn;t work std then it still needs to made by hand } sp = dbcSpell.LookupEntryForced( 31582 ); if( sp != NULL ) { sp->EffectBasePoints[0] *= 5; //heh B thinks he is smart by adding this to description ? If it doesn;t work std then it still needs to made by hand } sp = dbcSpell.LookupEntryForced( 31583 ); if( sp != NULL ) { sp->EffectBasePoints[0] *= 5; //heh B thinks he is smart by adding this to description ? If it doesn;t work std then it still needs to made by hand } //Mage - Improved Blizzard sp = dbcSpell.LookupEntryForced( 11185 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 12484; sp->procFlags = PROC_ON_CAST_SPELL; } sp = dbcSpell.LookupEntryForced( 12487 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 12485; sp->procFlags = PROC_ON_CAST_SPELL; } sp = dbcSpell.LookupEntryForced( 12488 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 12486; sp->procFlags = PROC_ON_CAST_SPELL; } // cebernic: not for self? // impact sp = dbcSpell.LookupEntryForced( 12355 ); if( sp != NULL ) { // passive rank: 11103, 12357, 12358 ,12359,12360 :D sp->procFlags = PROC_ON_ANY_DAMAGE_VICTIM | PROC_ON_SPELL_CRIT_HIT ; sp->EffectImplicitTargetA[0] = EFF_TARGET_ALL_ENEMIES_AROUND_CASTER; sp->EffectImplicitTargetB[0] = EFF_TARGET_ALL_ENEMIES_AROUND_CASTER; sp->EffectImplicitTargetA[1] = EFF_TARGET_ALL_ENEMIES_AROUND_CASTER; sp->EffectImplicitTargetB[1] = EFF_TARGET_ALL_ENEMIES_AROUND_CASTER; sp->EffectImplicitTargetA[2] = EFF_TARGET_ALL_ENEMIES_AROUND_CASTER; sp->EffectImplicitTargetB[2] = EFF_TARGET_ALL_ENEMIES_AROUND_CASTER; sp->c_is_flags |= SPELL_FLAG_IS_FORCEDDEBUFF; } //Invisibility sp = dbcSpell.LookupEntryForced( 66 ); if( sp != NULL ) { sp->EffectApplyAuraName[2] = SPELL_AURA_PERIODIC_TRIGGER_SPELL; sp->Effect[2] = SPELL_EFFECT_APPLY_AURA; sp->EffectAmplitude[2] = 6000; sp->EffectImplicitTargetA[2] = EFF_TARGET_SELF; sp->EffectBaseDice[2] = 1; sp->EffectDieSides[2] = 1; sp->EffectTriggerSpell[2] = 32612; sp->EffectBasePoints[2] = -1; } //Invisibility triggered spell, should be removed on cast sp = dbcSpell.LookupEntryForced( 32612 ); if( sp != NULL ) { sp->AuraInterruptFlags |= AURA_INTERRUPT_ON_CAST_SPELL; } //mage - Combustion sp = dbcSpell.LookupEntryForced( 11129 ); if( sp != NULL ) { sp->Effect[0] = 0; sp->Effect[1] = SPELL_EFFECT_APPLY_AURA; sp->EffectApplyAuraName[1] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[1] = 28682; sp->procFlags = PROC_ON_SPELL_HIT | PROC_ON_SPELL_CRIT_HIT | static_cast<uint32>(PROC_TARGET_SELF); sp->procCharges = 0; sp->c_is_flags |= SPELL_FLAG_IS_REQUIRECOOLDOWNUPDATE; } //mage - Master of Elements sp = dbcSpell.LookupEntryForced( 29074 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 29077; sp->procFlags = uint32(PROC_ON_SPELL_CRIT_HIT|PROC_TARGET_SELF); sp->procChance = 100; } sp = dbcSpell.LookupEntryForced( 29075 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 29077; sp->procFlags = uint32(PROC_ON_SPELL_CRIT_HIT|PROC_TARGET_SELF); sp->procChance = 100; } sp = dbcSpell.LookupEntryForced( 29076 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 29077; sp->procFlags = uint32(PROC_ON_SPELL_CRIT_HIT|PROC_TARGET_SELF); sp->procChance = 100; } //mage: Blazing Speed sp = dbcSpell.LookupEntryForced( 31641 ); if( sp != NULL ) sp->EffectTriggerSpell[0] = 31643; sp = dbcSpell.LookupEntryForced( 31642 ); if( sp != NULL ) sp->EffectTriggerSpell[0] = 31643; //mage talent "frostbyte". we make it to be dummy sp = dbcSpell.LookupEntryForced( 11071 ); if( sp != NULL ) sp->EffectApplyAuraName[0] = SPELL_AURA_DUMMY; sp = dbcSpell.LookupEntryForced( 12496 ); if( sp != NULL ) sp->EffectApplyAuraName[0] = SPELL_AURA_DUMMY; sp = dbcSpell.LookupEntryForced( 12497 ); if( sp != NULL ) sp->EffectApplyAuraName[0] = SPELL_AURA_DUMMY; //Mage - Improved Scorch sp = dbcSpell.LookupEntryForced( 11095 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procChance =33; sp->procFlags = PROC_ON_CAST_SPELL; } sp = dbcSpell.LookupEntryForced( 12872 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procChance =66; sp->procFlags = PROC_ON_CAST_SPELL; } sp = dbcSpell.LookupEntryForced( 12873 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procChance =100; sp->procFlags = PROC_ON_CAST_SPELL; } // mage - Frost Warding sp = dbcSpell.LookupEntryForced( 11189 ); if( sp != NULL ) { sp->procChance = 10; } sp = dbcSpell.LookupEntryForced( 28332 ); if( sp != NULL ) { sp->procChance = 20; } // mage - Conjure Refreshment Table sp = dbcSpell.LookupEntryForced( 43985 ); if ( sp != NULL ) sp->EffectImplicitTargetA[0] = EFF_TARGET_DYNAMIC_OBJECT; ////////////////////////////////////////// // WARLOCK // ////////////////////////////////////////// // Insert warlock spell fixes here sp = dbcSpell.LookupEntryForced( 31117 ); if (sp != NULL) sp->c_is_flags |= SPELL_FLAG_IS_FORCEDDEBUFF; /********************************************************** * Nether Protection **********************************************************/ sp = dbcSpell.LookupEntryForced( 30299 ); if (sp != NULL) { sp->procChance = 10; sp->proc_interval = 13000; } sp = dbcSpell.LookupEntryForced( 30301 ); if (sp != NULL) { sp->procChance = 20; sp->proc_interval = 13000; } sp = dbcSpell.LookupEntryForced( 30302 ); if (sp != NULL) { sp->procChance = 30; sp->proc_interval = 13000; } /********************************************************** * Backlash **********************************************************/ sp = dbcSpell.LookupEntryForced( 34935 ); if (sp != NULL) { sp->proc_interval = 8000; sp->procFlags |= PROC_ON_MELEE_ATTACK_VICTIM | static_cast<uint32>(PROC_TARGET_SELF); } sp = dbcSpell.LookupEntryForced( 34938 ); if (sp != NULL) { sp->proc_interval = 8000; sp->procFlags |= PROC_ON_MELEE_ATTACK_VICTIM | static_cast<uint32>(PROC_TARGET_SELF); } sp = dbcSpell.LookupEntryForced( 34939 ); if (sp != NULL) { sp->proc_interval = 8000; sp->procFlags |= PROC_ON_MELEE_ATTACK_VICTIM | static_cast<uint32>(PROC_TARGET_SELF); } sp = dbcSpell.LookupEntryForced( 34936 ); if (sp != NULL) { sp->AuraInterruptFlags = AURA_INTERRUPT_ON_CAST_SPELL; } /********************************************************** * Demonic Knowledge **********************************************************/ sp = dbcSpell.LookupEntryForced( 35691 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_MOD_DAMAGE_DONE; sp->EffectImplicitTargetA[0] = EFF_TARGET_SELF; sp->Effect[1] = 6; sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_DONE; sp->EffectBasePoints[1] = sp->EffectBasePoints[0]; sp->EffectImplicitTargetA[1]= EFF_TARGET_PET; sp->Effect[2] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[2] = 35696; sp->EffectImplicitTargetA[2]=EFF_TARGET_PET; sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_PET_OWNER | SPELL_FLAG_IS_EXPIREING_WITH_PET; } sp = dbcSpell.LookupEntryForced( 35692 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_MOD_DAMAGE_DONE; sp->EffectImplicitTargetA[0] = EFF_TARGET_SELF; sp->Effect[1] = 6; sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_DONE; sp->EffectBasePoints[1] = sp->EffectBasePoints[0]; sp->EffectImplicitTargetA[1] = EFF_TARGET_PET; sp->Effect[2] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[2] = 35696; sp->EffectImplicitTargetA[2] = EFF_TARGET_PET; sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_PET_OWNER | SPELL_FLAG_IS_EXPIREING_WITH_PET; } sp = dbcSpell.LookupEntryForced( 35693 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_MOD_DAMAGE_DONE; sp->EffectImplicitTargetA[0] = EFF_TARGET_SELF; sp->Effect[1] = 6; sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_DONE; sp->EffectBasePoints[1] = sp->EffectBasePoints[0]; sp->EffectImplicitTargetA[1] = EFF_TARGET_PET; sp->Effect[2] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[2] = 35696; sp->EffectImplicitTargetA[2] = EFF_TARGET_PET; sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_PET_OWNER | SPELL_FLAG_IS_EXPIREING_WITH_PET; } sp = dbcSpell.LookupEntryForced( 35696 ); if( sp != NULL ) { sp->Effect[0] = 6; //making this only for the visible effect sp->EffectApplyAuraName[0] = SPELL_AURA_DUMMY; //no effect here sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; } //warlock - Seed of Corruption sp = dbcSpell.LookupEntryForced( 27243 ); if( sp != NULL ) { sp->EffectApplyAuraName[1] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[1] = 27285; sp->procFlags = PROC_ON_SPELL_HIT_VICTIM | PROC_ON_DIE; sp->procChance = 100; } //warlock - soul link sp = dbcSpell.LookupEntryForced( 19028 ); if( sp != NULL ) { //this is for the trigger effect sp->Effect[0]=SPELL_EFFECT_APPLY_AURA; sp->EffectApplyAuraName[0] = SPELL_AURA_SPLIT_DAMAGE; sp->EffectMiscValue[0]=20; //sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; //this is for the extra 5% dmg for caster and pet sp->Effect[1] = 6; sp->EffectApplyAuraName[1] = 79; sp->EffectBasePoints[1] = 4; //4+1=5 sp->EffectImplicitTargetA[1] = EFF_TARGET_SELF; sp->EffectImplicitTargetB[1] = EFF_TARGET_PET; sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; } //warlock: Nightfall sp = dbcSpell.LookupEntryForced( 18094 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 17941; sp->procFlags = PROC_ON_ANY_HOSTILE_ACTION | static_cast<uint32>(PROC_TARGET_SELF); sp->procChance = 2; } sp = dbcSpell.LookupEntryForced( 18095 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 17941; sp->procFlags = PROC_ON_ANY_HOSTILE_ACTION | static_cast<uint32>(PROC_TARGET_SELF); sp->procChance = 4; } //Shadow Trance should be removed on the first SB sp = dbcSpell.LookupEntryForced( 17941 ); if( sp != NULL ) { sp->AuraInterruptFlags = AURA_INTERRUPT_ON_CAST_SPELL; } //warlock: Empowered Corruption sp = dbcSpell.LookupEntryForced( 32381 ); if( sp != NULL ) { sp->EffectBasePoints[0] *= 6; } sp = dbcSpell.LookupEntryForced( 32382 ); if( sp != NULL ) { sp->EffectBasePoints[0] *= 6; } sp = dbcSpell.LookupEntryForced( 32383 ); if( sp != NULL ) { sp->EffectBasePoints[0] *= 6; } //warlock: Improved Enslave Demon sp = dbcSpell.LookupEntryForced( 18821 ); if( sp != NULL ) { sp->EffectMiscValue[0]=SMT_SPELL_VALUE_PCT; sp->EffectBasePoints[0] = -(sp->EffectBasePoints[0]+2); } //warlock - Demonic Sacrifice sp = dbcSpell.LookupEntryForced( 18789 ); if( sp != NULL ) sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_ON_PET; sp = dbcSpell.LookupEntryForced( 18790 ); if( sp != NULL ) sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_ON_PET; sp = dbcSpell.LookupEntryForced( 18791 ); if( sp != NULL ) sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_ON_PET; sp = dbcSpell.LookupEntryForced( 18792 ); if( sp != NULL ) sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_ON_PET; sp = dbcSpell.LookupEntryForced( 35701 ); if( sp != NULL ) sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_ON_PET; //warlock - Demonic Tactics sp = dbcSpell.LookupEntryForced( 30242 ); if( sp != NULL ) { sp->Effect[0] = 0; //disble this. This is just blizz crap. Pure proove that they suck :P sp->EffectImplicitTargetB[1] = EFF_TARGET_PET; sp->EffectApplyAuraName[2] = SPELL_AURA_MOD_SPELL_CRIT_CHANCE; //lvl 1 has it fucked up :O sp->EffectImplicitTargetB[2] = EFF_TARGET_PET; sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_PET_OWNER ; } sp = dbcSpell.LookupEntryForced( 30245 ); if( sp != NULL ) { sp->Effect[0] = 0; //disble this. This is just blizz crap. Pure proove that they suck :P sp->EffectImplicitTargetB[1] = EFF_TARGET_PET; sp->EffectImplicitTargetB[2] = EFF_TARGET_PET; sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_PET_OWNER ; } sp = dbcSpell.LookupEntryForced( 30246 ); if( sp != NULL ) { sp->Effect[0] = 0; //disble this. This is just blizz crap. Pure proove that they suck :P sp->EffectImplicitTargetB[1] = EFF_TARGET_PET; sp->EffectImplicitTargetB[2] = EFF_TARGET_PET; sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_PET_OWNER ; } sp = dbcSpell.LookupEntryForced( 30247 ); if( sp != NULL ) { sp->Effect[0] = 0; //disble this. This is just blizz crap. Pure proove that they suck :P sp->EffectImplicitTargetB[1] = EFF_TARGET_PET; sp->EffectImplicitTargetB[2] = EFF_TARGET_PET; sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_PET_OWNER ; } sp = dbcSpell.LookupEntryForced( 30248 ); if( sp != NULL ) { sp->Effect[0] = 0; //disble this. This is just blizz crap. Pure proove that they suck :P sp->EffectImplicitTargetB[1] = EFF_TARGET_PET; sp->EffectImplicitTargetB[2] = EFF_TARGET_PET; sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_PET_OWNER ; } //warlock - Demonic Resilience sp = dbcSpell.LookupEntryForced( 30319 ); if( sp != NULL ) { sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN; sp->EffectImplicitTargetA[1] = EFF_TARGET_PET; sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_PET_OWNER ; } sp = dbcSpell.LookupEntryForced( 30320 ); if( sp != NULL ) { sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN; sp->EffectImplicitTargetA[1] = EFF_TARGET_PET; sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_PET_OWNER ; } sp = dbcSpell.LookupEntryForced( 30321 ); if( sp != NULL ) { sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN; sp->EffectImplicitTargetA[1] = EFF_TARGET_PET; sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_PET_OWNER ; } //warlock - Improved Imp sp = dbcSpell.LookupEntryForced( 18694 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; } sp = dbcSpell.LookupEntryForced( 18695 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; } sp = dbcSpell.LookupEntryForced( 18696 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; } //warlock - Improved Voidwalker sp = dbcSpell.LookupEntryForced( 18705 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; } sp = dbcSpell.LookupEntryForced( 18706 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; } sp = dbcSpell.LookupEntryForced( 18707 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; } //warlock - Improved Succubus sp = dbcSpell.LookupEntryForced( 18754 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; sp->EffectImplicitTargetA[1] = EFF_TARGET_PET; } sp = dbcSpell.LookupEntryForced( 18755 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; sp->EffectImplicitTargetA[1] = EFF_TARGET_PET; } sp = dbcSpell.LookupEntryForced( 18756 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; sp->EffectImplicitTargetA[1] = EFF_TARGET_PET; } //warlock - Fel Intellect sp = dbcSpell.LookupEntryForced( 18731 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectApplyAuraName[0] = SPELL_AURA_MOD_PERCENT_STAT; sp->EffectMiscValue[0] = 3; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; } sp = dbcSpell.LookupEntryForced( 18743 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectApplyAuraName[0] = SPELL_AURA_MOD_PERCENT_STAT; sp->EffectMiscValue[0] = 3; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; } sp = dbcSpell.LookupEntryForced( 18744 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectApplyAuraName[0] = SPELL_AURA_MOD_PERCENT_STAT; sp->EffectMiscValue[0] = 3; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; } //warlock - Fel Stamina sp = dbcSpell.LookupEntryForced( 18748 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectApplyAuraName[0] = SPELL_AURA_MOD_PERCENT_STAT; sp->EffectMiscValue[0] = 2; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; } sp = dbcSpell.LookupEntryForced( 18749 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectApplyAuraName[0] = SPELL_AURA_MOD_PERCENT_STAT; sp->EffectMiscValue[0] = 2; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; } sp = dbcSpell.LookupEntryForced( 18750 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectApplyAuraName[0] = SPELL_AURA_MOD_PERCENT_STAT; sp->EffectMiscValue[0] = 2; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; } //warlock - Demonic Tactics sp = dbcSpell.LookupEntryForced( 30242 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectApplyAuraName[0] = SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; //this is required since blizz uses spells for melee attacks while we use fixed functions sp->Effect[1] = SPELL_EFFECT_APPLY_AURA; sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_PERCENT_DONE; sp->EffectImplicitTargetA[1] = EFF_TARGET_PET; sp->EffectMiscValue[1] = SCHOOL_NORMAL; sp->EffectBasePoints[1] = sp->EffectBasePoints[0] ; } //warlock - Unholy Power sp = dbcSpell.LookupEntryForced( 18769 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectApplyAuraName[0] = SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; //this is required since blizz uses spells for melee attacks while we use fixed functions sp->Effect[1] = SPELL_EFFECT_APPLY_AURA; sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_PERCENT_DONE; sp->EffectImplicitTargetA[1] = EFF_TARGET_PET; sp->EffectMiscValue[1] = SCHOOL_NORMAL; sp->EffectBasePoints[1] = sp->EffectBasePoints[0] ; } sp = dbcSpell.LookupEntryForced( 18770 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectApplyAuraName[0] = SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; //this is required since blizz uses spells for melee attacks while we use fixed functions sp->Effect[1] = SPELL_EFFECT_APPLY_AURA; sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_PERCENT_DONE; sp->EffectImplicitTargetA[1] = EFF_TARGET_PET; sp->EffectMiscValue[1] = SCHOOL_NORMAL; sp->EffectBasePoints[1] = sp->EffectBasePoints[0] ; } sp = dbcSpell.LookupEntryForced( 18771 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectApplyAuraName[0] = SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; //this is required since blizz uses spells for melee attacks while we use fixed functions sp->Effect[1] = SPELL_EFFECT_APPLY_AURA; sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_PERCENT_DONE; sp->EffectImplicitTargetA[1] = EFF_TARGET_PET; sp->EffectMiscValue[1] = SCHOOL_NORMAL; sp->EffectBasePoints[1] = sp->EffectBasePoints[0] ; } sp = dbcSpell.LookupEntryForced( 18772 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectApplyAuraName[0] = SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; //this is required since blizz uses spells for melee attacks while we use fixed functions sp->Effect[1] = SPELL_EFFECT_APPLY_AURA; sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_PERCENT_DONE; sp->EffectImplicitTargetA[1] = EFF_TARGET_PET; sp->EffectMiscValue[1] = SCHOOL_NORMAL; sp->EffectBasePoints[1] = sp->EffectBasePoints[0] ; } sp = dbcSpell.LookupEntryForced( 18773 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET ; sp->EffectApplyAuraName[0] = SPELL_AURA_ADD_PCT_MODIFIER; sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; //this is required since blizz uses spells for melee attacks while we use fixed functions sp->Effect[1] = SPELL_EFFECT_APPLY_AURA; sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_PERCENT_DONE; sp->EffectImplicitTargetA[1] = EFF_TARGET_PET; sp->EffectMiscValue[1] = SCHOOL_NORMAL; sp->EffectBasePoints[1] = sp->EffectBasePoints[0] ; } //warlock - Master Demonologist - 25 spells here sp = dbcSpell.LookupEntryForced( 23785 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET | SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 23784; } sp = dbcSpell.LookupEntryForced( 23822 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET | SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 23830; } sp = dbcSpell.LookupEntryForced( 23823 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET | SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 23831; } sp = dbcSpell.LookupEntryForced( 23824 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET | SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 23832; } sp = dbcSpell.LookupEntryForced( 23825 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_CASTED_ON_PET_SUMMON_ON_PET | SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 35708; } //and the rest sp = dbcSpell.LookupEntryForced( 23784 ); if( sp != NULL ) sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; sp = dbcSpell.LookupEntryForced( 23830 ); if( sp != NULL ) sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; sp = dbcSpell.LookupEntryForced( 23831 ); if( sp != NULL ) sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; sp = dbcSpell.LookupEntryForced( 23832 ); if( sp != NULL ) sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; sp = dbcSpell.LookupEntryForced( 35708 ); if( sp != NULL ) sp->EffectImplicitTargetA[0] = EFF_TARGET_PET; sp = dbcSpell.LookupEntryForced( 23759 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_APPLY_AURA; } sp = dbcSpell.LookupEntryForced( 23760 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_APPLY_AURA; } sp = dbcSpell.LookupEntryForced( 23761 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_APPLY_AURA; } sp = dbcSpell.LookupEntryForced( 23762 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_APPLY_AURA; } sp = dbcSpell.LookupEntryForced( 23826 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_APPLY_AURA; } sp = dbcSpell.LookupEntryForced( 23827 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_APPLY_AURA; } sp = dbcSpell.LookupEntryForced( 23828 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_APPLY_AURA; } sp = dbcSpell.LookupEntryForced( 23829 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_APPLY_AURA; } for(uint32 i=23833;i<=23844;i++) { sp = dbcSpell.LookupEntryForced( i ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_APPLY_AURA; } } sp = dbcSpell.LookupEntryForced( 35702 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_APPLY_AURA; sp->Effect[1] = 0; //hacks, we are handling this in another way } sp = dbcSpell.LookupEntryForced( 35703 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_APPLY_AURA; sp->Effect[1] = 0; //hacks, we are handling this in another way } sp = dbcSpell.LookupEntryForced( 35704 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_APPLY_AURA; sp->Effect[1] = 0; //hacks, we are handling this in another way } sp = dbcSpell.LookupEntryForced( 35705 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_APPLY_AURA; sp->Effect[1] = 0; //hacks, we are handling this in another way } sp = dbcSpell.LookupEntryForced( 35706 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_EXPIREING_WITH_PET; sp->Effect[0] = SPELL_EFFECT_APPLY_AURA; sp->Effect[1] = 0; //hacks, we are handling this in another way } //warlock - Improved Drain Soul sp = dbcSpell.LookupEntryForced( 18213 ); if( sp != NULL ) { sp->procFlags = PROC_ON_TARGET_DIE | static_cast<uint32>(PROC_TARGET_SELF); sp->procChance = 100; sp->Effect[0] = SPELL_EFFECT_APPLY_AURA; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 18371; sp->EffectImplicitTargetA[0] = EFF_TARGET_SELF; sp->Effect[2] = 0 ; //remove this effect } sp = dbcSpell.LookupEntryForced( 18372 ); if( sp != NULL ) { sp->procFlags = PROC_ON_TARGET_DIE | static_cast<uint32>(PROC_TARGET_SELF); sp->procChance = 100; sp->Effect[0] = SPELL_EFFECT_APPLY_AURA; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 18371; sp->EffectImplicitTargetA[0] = EFF_TARGET_SELF; sp->Effect[2] = 0 ; //remove this effect } //warlock - Shadow Embrace sp = dbcSpell.LookupEntryForced( 32385 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->Effect[1] = 0 ; //remove this effect ? Maybe remove the other one :P xD } sp = dbcSpell.LookupEntryForced( 32387 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->Effect[1] = 0 ; //remove this effect ? Maybe remove the other one :P xD } sp = dbcSpell.LookupEntryForced( 32392 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->Effect[1] = 0 ; //remove this effect ? Maybe remove the other one :P xD } sp = dbcSpell.LookupEntryForced( 32393 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->Effect[1] = 0 ; //remove this effect ? Maybe remove the other one :P xD } sp = dbcSpell.LookupEntryForced( 32394 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->Effect[1] = 0 ; //remove this effect ? Maybe remove the other one :P xD } //warlock - soul leech sp = dbcSpell.LookupEntryForced( 30293 ); if( sp != NULL ) { sp->Effect[0] = 6; //aura sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 30294; sp->procFlags = uint32(PROC_ON_CAST_SPELL|PROC_TARGET_SELF); } sp = dbcSpell.LookupEntryForced( 30295 ); if( sp != NULL ) { sp->Effect[0] = 6; //aura sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 30294; sp->procFlags = uint32(PROC_ON_CAST_SPELL|PROC_TARGET_SELF); } sp = dbcSpell.LookupEntryForced( 30296 ); if( sp != NULL ) { sp->Effect[0] = 6; //aura sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 30294; sp->procFlags = uint32(PROC_ON_CAST_SPELL|PROC_TARGET_SELF); } //warlock - Pyroclasm sp = dbcSpell.LookupEntryForced( 18073 ); if( sp != NULL ) { sp->Effect[0] = 0; //delete this owerride effect :P sp->EffectTriggerSpell[1] = 18093; //trigger spell was wrong :P sp->procFlags = PROC_ON_ANY_HOSTILE_ACTION; sp->procChance = 13; //god, save us from fixed values ! } sp = dbcSpell.LookupEntryForced( 18096 ); if( sp != NULL ) { sp->Effect[0] = 0; //delete this owerride effect :P sp->EffectTriggerSpell[1] = 18093; //trigger spell was wrong :P sp->procFlags = PROC_ON_ANY_HOSTILE_ACTION; sp->procChance = 26; //god, save us from fixed values ! } ////////////////////////////////////////// // DRUID // ////////////////////////////////////////// // Insert druid spell fixes here //Druid: Feral Swiftness sp = dbcSpell.LookupEntryForced( 17002 ); if ( sp != NULL ) { sp->Effect[1] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[1] = 24867; } sp = dbcSpell.LookupEntryForced( 24866 ); if ( sp != NULL ) { sp->Effect[1] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[1] = 24864; } //Druid: Natural Perfection sp = dbcSpell.LookupEntryForced( 33881 ); if ( sp != NULL ) sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_SPELL_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM; sp = dbcSpell.LookupEntryForced( 33882 ); if ( sp != NULL ) sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_SPELL_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM; sp = dbcSpell.LookupEntryForced( 33883 ); if ( sp != NULL ) sp->procFlags = PROC_ON_CRIT_HIT_VICTIM | PROC_ON_SPELL_CRIT_HIT_VICTIM | PROC_ON_RANGED_CRIT_ATTACK_VICTIM; //Druid: Frenzied Regeneration sp = dbcSpell.LookupEntryForced( 22842 ); if( sp != NULL ) { sp->Effect[0] = 6; sp->EffectApplyAuraName[0] = SPELL_AURA_PERIODIC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 22845; } sp = dbcSpell.LookupEntryForced( 22895 ); if( sp != NULL ) { sp->Effect[0] = 6; sp->EffectApplyAuraName[0] = SPELL_AURA_PERIODIC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 22845; } sp = dbcSpell.LookupEntryForced( 22896 ); if( sp != NULL ) { sp->Effect[0] = 6; sp->EffectApplyAuraName[0] = SPELL_AURA_PERIODIC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 22845; } sp = dbcSpell.LookupEntryForced( 26999 ); if( sp != NULL ) { sp->Effect[0] = 6; sp->EffectApplyAuraName[0] = SPELL_AURA_PERIODIC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 22845; } //Druid - Celestial Focus sp = dbcSpell.LookupEntryForced( 16850 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } sp = dbcSpell.LookupEntryForced( 16923 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } sp = dbcSpell.LookupEntryForced( 16924 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } //Druid: Leader of the Pack sp = dbcSpell.LookupEntryForced( 24932 ); if( sp != NULL ) { sp->Effect[1] = 0; sp->Effect[2] = 0; //removing strange effects. } //Druid: Improved Leader of the Pack sp = dbcSpell.LookupEntryForced( 34299 ); if( sp != NULL ) sp->proc_interval = 6000;//6 secs //druid - Primal Fury (talent) sp = dbcSpell.LookupEntryForced( 37116 ); if( sp != NULL ) sp->RequiredShapeShift = 0; sp = dbcSpell.LookupEntryForced( 37117 ); if( sp != NULL ) sp->RequiredShapeShift = 0; //druid - Blood Frenzy (proc) sp = dbcSpell.LookupEntryForced( 16954 ); if( sp != NULL ) sp->procFlags = PROC_ON_CRIT_ATTACK; sp = dbcSpell.LookupEntryForced( 16952 ); if( sp != NULL ) sp->procFlags = PROC_ON_CRIT_ATTACK; //druid - Primal Fury (proc) sp = dbcSpell.LookupEntryForced( 16961 ); if( sp != NULL ) sp->procFlags = PROC_ON_CRIT_ATTACK; sp = dbcSpell.LookupEntryForced( 16958 ); if( sp != NULL ) sp->procFlags = PROC_ON_CRIT_ATTACK; //druid - Intensity sp = dbcSpell.LookupEntryForced( 17106 ); if( sp != NULL ) { sp->EffectApplyAuraName[1] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procFlags = PROC_ON_CAST_SPELL; } sp = dbcSpell.LookupEntryForced( 17107 ); if( sp != NULL ) { sp->EffectApplyAuraName[1] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procFlags = PROC_ON_CAST_SPELL; } sp = dbcSpell.LookupEntryForced( 17108 ); if( sp != NULL ) { sp->EffectApplyAuraName[1] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procFlags = PROC_ON_CAST_SPELL; } //Nature's Grasp sp = dbcSpell.LookupEntryForced( 16689 ); if( sp != NULL ) { sp->Effect[0] = 6; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 339; sp->Effect[1] = 0; sp->procFlags = PROC_ON_MELEE_ATTACK_VICTIM | PROC_REMOVEONUSE; sp->AuraInterruptFlags = 0; //we remove it on proc or timeout } sp = dbcSpell.LookupEntryForced( 16810 ); if( sp != NULL ) { sp->Effect[0] = 6; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 1062; sp->Effect[1] = 0; sp->procFlags = PROC_ON_MELEE_ATTACK_VICTIM | PROC_REMOVEONUSE; sp->AuraInterruptFlags = 0; //we remove it on proc or timeout } sp = dbcSpell.LookupEntryForced( 16811 ); if( sp != NULL ) { sp->Effect[0] = 6; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 5195; sp->Effect[1] = 0; sp->procFlags = PROC_ON_MELEE_ATTACK_VICTIM | PROC_REMOVEONUSE; sp->AuraInterruptFlags = 0; //we remove it on proc or timeout } sp = dbcSpell.LookupEntryForced( 16812 ); if( sp != NULL ) { sp->Effect[0] = 6; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 5196; sp->Effect[1] = 0; sp->procFlags = PROC_ON_MELEE_ATTACK_VICTIM | PROC_REMOVEONUSE; sp->AuraInterruptFlags = 0; //we remove it on proc or timeout } sp = dbcSpell.LookupEntryForced( 16813 ); if( sp != NULL ) { sp->Effect[0] = 6; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 9852; sp->Effect[1] = 0; sp->procFlags = PROC_ON_MELEE_ATTACK_VICTIM | PROC_REMOVEONUSE; sp->AuraInterruptFlags = 0; //we remove it on proc or timeout } sp = dbcSpell.LookupEntryForced( 17329 ); if( sp != NULL ) { sp->Effect[0] = 6; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 9853; sp->Effect[1] = 0; sp->procFlags = PROC_ON_MELEE_ATTACK_VICTIM | PROC_REMOVEONUSE; sp->AuraInterruptFlags = 0; //we remove it on proc or timeout } sp = dbcSpell.LookupEntryForced( 27009 ); if( sp != NULL ) { sp->Effect[0] = 6; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 26989; sp->Effect[1] = 0; sp->procFlags = PROC_ON_MELEE_ATTACK_VICTIM | PROC_REMOVEONUSE; sp->AuraInterruptFlags = 0; //we remove it on proc or timeout } //pounce sp = dbcSpell.LookupEntryForced( 9007 ); if( sp != NULL ) { sp->MechanicsType = MECHANIC_BLEEDING; } sp = dbcSpell.LookupEntryForced( 9824 ); if( sp != NULL ) { sp->MechanicsType = MECHANIC_BLEEDING; } sp = dbcSpell.LookupEntryForced( 9826 ); if( sp != NULL ) { sp->MechanicsType = MECHANIC_BLEEDING; } sp = dbcSpell.LookupEntryForced( 27007 ); if( sp != NULL ) { sp->MechanicsType = MECHANIC_BLEEDING; } //rip sp = dbcSpell.LookupEntryForced( 1079 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 9492 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 9493 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 9752 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 9894 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 9896 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 27008 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; //rake sp = dbcSpell.LookupEntryForced( 1822 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 1823 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 1824 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 9904 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; sp = dbcSpell.LookupEntryForced( 27003 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; //lacerate sp = dbcSpell.LookupEntryForced( 33745 ); if( sp != NULL ) sp->MechanicsType = MECHANIC_BLEEDING; //Pounce Bleed sp = dbcSpell.LookupEntryForced( 9007 ); if( sp != NULL ) sp->DurationIndex = 18000; sp = dbcSpell.LookupEntryForced( 9824 ); if( sp != NULL ) sp->DurationIndex = 18000; sp = dbcSpell.LookupEntryForced( 9826 ); if( sp != NULL ) sp->DurationIndex = 18000; sp = dbcSpell.LookupEntryForced( 27007 ); if( sp != NULL ) sp->DurationIndex = 18000; //Druid: Natural Shapeshifter sp = dbcSpell.LookupEntryForced( 16833 ); if( sp != NULL ) sp->DurationIndex = 0; sp = dbcSpell.LookupEntryForced( 16834 ); if( sp != NULL ) sp->DurationIndex = 0; sp = dbcSpell.LookupEntryForced( 16835 ); if( sp != NULL ) sp->DurationIndex = 0; // druid - Naturalist sp = dbcSpell.LookupEntryForced( 17069 ); if( sp != NULL ) { sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_PERCENT_DONE; sp->EffectMiscValue[1] = 1; } sp = dbcSpell.LookupEntryForced( 17070 ); if( sp != NULL ) { sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_PERCENT_DONE; sp->EffectMiscValue[1] = 1; } sp = dbcSpell.LookupEntryForced( 17071 ); if( sp != NULL ) { sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_PERCENT_DONE; sp->EffectMiscValue[1] = 1; } sp = dbcSpell.LookupEntryForced( 17072 ); if( sp != NULL ) { sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_PERCENT_DONE; sp->EffectMiscValue[1] = 1; } sp = dbcSpell.LookupEntryForced( 17073 ); if( sp != NULL ) { sp->EffectApplyAuraName[1] = SPELL_AURA_MOD_DAMAGE_PERCENT_DONE; sp->EffectMiscValue[1] = 1; } // druid - Nature's Grace sp = dbcSpell.LookupEntryForced( 16880 ); if( sp != NULL ) { sp->procFlags = PROC_ON_SPELL_CRIT_HIT | static_cast<uint32>(PROC_TARGET_SELF); sp->procChance = 100; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 16886; sp->Effect[0] = SPELL_EFFECT_APPLY_AURA; } sp = dbcSpell.LookupEntryForced( 16886 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->procChance = 100; sp->procCharges = 2; // i know.. hacky.. but first charge gets lost when it gets procced } // Druid: Omen of Clarity sp = dbcSpell.LookupEntryForced( 16864 ); if( sp != NULL ) { sp->procChance=100; //procchance dynamic. 3ppm sp->procFlags = PROC_ON_MELEE_ATTACK | PROC_ON_CRIT_ATTACK; } uint32 mm = (1<<(FORM_BEAR-1))|(1<<(FORM_DIREBEAR-1))|(1<<(FORM_MOONKIN-1))|(1<<(FORM_CAT-1)); sp = dbcSpell.LookupEntryForced( 16972 ); if( sp != NULL ) sp->RequiredShapeShift = mm; sp = dbcSpell.LookupEntryForced( 16974 ); if( sp != NULL ) sp->RequiredShapeShift = mm; sp = dbcSpell.LookupEntryForced( 16975 ); if( sp != NULL ) sp->RequiredShapeShift = mm; ////////////////////////////////////////// // ITEMS // ////////////////////////////////////////// // Insert items spell fixes here #ifdef NEW_PROCFLAGS //Bonescythe Armor sp = dbcSpell.LookupEntryForced( 28814 ); if (sp != NULL) sp->EffectSpellGroupRelation[0]=8519680; //Tome of the Lightbringer sp = dbcSpell.LookupEntryForced( 41042 ); if (sp != NULL) sp->EffectSpellGroupRelation[0]=8388608; //Gladiator's Libram of Fortitude sp = dbcSpell.LookupEntryForced( 43850 ); if (sp != NULL) sp->EffectSpellGroupRelation[0]=8388608; //Vengeful Gladiator's Libram of Fortitude sp = dbcSpell.LookupEntryForced( 43852 ); if (sp != NULL) sp->EffectSpellGroupRelation[0]=8388608; //Merciless Gladiator's Libram of Fortitude sp = dbcSpell.LookupEntryForced( 43851 ); if (sp != NULL) sp->EffectSpellGroupRelation[0]=8388608; //Gladiator's Libram of Vengeance sp = dbcSpell.LookupEntryForced( 43854 ); if (sp != NULL) sp->EffectSpellGroupRelation_high[0]=64; //Merciless Gladiator's Libram of Vengeance sp = dbcSpell.LookupEntryForced( 43855 ); if (sp != NULL) sp->EffectSpellGroupRelation_high[0]=64; //Vengeful Gladiator's Libram of Vengeance sp = dbcSpell.LookupEntryForced( 43856 ); if (sp != NULL) sp->EffectSpellGroupRelation_high[0]=64; //The Earthshatterer sp = dbcSpell.LookupEntryForced( 28821 ); if (sp != NULL) sp->EffectSpellGroupRelation[0]=1024; //Idol of the White Stag sp = dbcSpell.LookupEntryForced( 41037 ); if (sp != NULL) sp->EffectSpellGroupRelation_high[0]=64 | 1024; //Merciless Gladiator's Idol of Resolve sp = dbcSpell.LookupEntryForced( 43842 ); if (sp != NULL) sp->EffectSpellGroupRelation_high[0]=64 | 1024; //Vengeful Gladiator's Idol of Resolve sp = dbcSpell.LookupEntryForced( 43843 ); if (sp != NULL) sp->EffectSpellGroupRelation_high[0]=64 | 1024; //Merciless Gladiator's Idol of Steadfastness sp = dbcSpell.LookupEntryForced( 43844 ); if (sp != NULL) sp->EffectSpellGroupRelation[0]=2; //Vengeful Gladiator's Idol of Steadfastness sp = dbcSpell.LookupEntryForced( 43845 ); if (sp != NULL) sp->EffectSpellGroupRelation[0]=2; //Merciless Gladiator's Totem of Indomitability sp = dbcSpell.LookupEntryForced( 43858 ); if (sp != NULL) sp->EffectSpellGroupRelation_high[0]=16; //Vengeful Gladiator's Totem of Indomitability sp = dbcSpell.LookupEntryForced( 43859 ); if (sp != NULL) sp->EffectSpellGroupRelation_high[0]=16; //Gladiator's Totem of Indomitability sp = dbcSpell.LookupEntryForced( 43857 ); if (sp != NULL) sp->EffectSpellGroupRelation_high[0]=16; //Merciless Gladiator's Totem of Survival sp = dbcSpell.LookupEntryForced( 43861 ); if (sp != NULL) sp->EffectSpellGroupRelation[0]= 1048576 |268435456 | 2147483648; //Vengeful Gladiator's Totem of Survival sp = dbcSpell.LookupEntryForced( 43862 ); if (sp != NULL) sp->EffectSpellGroupRelation[0]= 1048576 |268435456 | 2147483648; //Gladiator's Totem of Survival sp = dbcSpell.LookupEntryForced( 43861 ); if (sp != NULL) sp->EffectSpellGroupRelation[0]= 1048576 |268435456 | 2147483648; //Wolfshead Helm sp = dbcSpell.LookupEntryForced( 17768 ); if (sp != NULL) { sp->EffectSpellGroupRelation[0]= 1073741824; sp->EffectSpellGroupRelation[1]= 2147483648; } //Set: Plagueheart Raiment sp = dbcSpell.LookupEntryForced( 28831 ); if (sp != NULL) sp->EffectSpellGroupRelation[0]= 1; //Set: Gladiator's Idol of Resolve sp = dbcSpell.LookupEntryForced( 37191 ); if (sp != NULL) sp->EffectSpellGroupRelation_high[0]=64 | 1024; //Set: Gladiator's Idol of Steadfastness sp = dbcSpell.LookupEntryForced( 43841 ); if (sp != NULL) sp->EffectSpellGroupRelation[0]=2; //Set: Incarnate Raiment sp = dbcSpell.LookupEntryForced( 37564 ); if (sp != NULL) sp->EffectSpellGroupRelation[0]=512; //Talon of Al'ar sp = dbcSpell.LookupEntryForced( 37507 ); if (sp != NULL) sp->EffectSpellGroupRelation[0]=2048; //Set: Crystalforge Armor sp = dbcSpell.LookupEntryForced( 37191 ); if (sp != NULL) sp->EffectSpellGroupRelation_high[0]=64; //Set: Redemption Armor sp = dbcSpell.LookupEntryForced( 28787 ); if (sp != NULL) sp->EffectSpellGroupRelation[0]=4096; //Idol of the Claw sp = dbcSpell.LookupEntryForced( 34323 ); if( sp != NULL ) { sp->Flags5 = FLAGS5_PROCCHANCE_COMBOBASED; sp->EffectSpellGroupRelation[0]=8388608; sp->EffectSpellGroupRelation_high[0]=128; } #endif //Compact Harvest Reaper sp = dbcSpell.LookupEntryForced( 4078 ); if( sp != NULL ) { sp->DurationIndex = 6; } //Graccu's Mince Meat Fruitcake sp = dbcSpell.LookupEntryForced(25990); if( sp != NULL ) { sp->EffectAmplitude[1] = 1000; } //Extract Gas sp = dbcSpell.LookupEntryForced( 30427 ); if( sp != NULL ) { sp->Effect[0] = SPELL_EFFECT_DUMMY; } //Relic - Idol of the Unseen Moon sp = dbcSpell.LookupEntryForced( 43739 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 43740; } //Lunar Grace - Idol of the Unseen Moon proc sp = dbcSpell.LookupEntryForced( 43740 ); if( sp != NULL ) { sp->ProcOnNameHash[0] = SPELL_HASH_MOONFIRE; } //Relic - Idol of Terror sp = dbcSpell.LookupEntryForced( 43737 ); if( sp != NULL ) { sp->proc_interval = 10001; //block proc when is already active.. (Primal Instinct duration = 10 sec) sp->procFlags = PROC_ON_CAST_SPELL | PROC_TARGET_SELF; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 43738; sp->procChance=85; } //Primal Instinct - Idol of Terror proc sp = dbcSpell.LookupEntryForced( 43738 ); if( sp != NULL ) { sp->self_cast_only = true; sp->ProcOnNameHash[0] = SPELL_HASH_MANGLE__CAT_; sp->ProcOnNameHash[1] = SPELL_HASH_MANGLE__BEAR_; } //Tome of Fiery Redemption sp = dbcSpell.LookupEntryForced( 37197 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 37198; sp->procChance = 15; } //Thunderfury sp = dbcSpell.LookupEntryForced( 21992 ); if( sp != NULL ) { sp->Effect[2] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[2] = 27648; sp->EffectImplicitTargetA[2] = EFF_TARGET_ALL_ENEMIES_AROUND_CASTER; // cebernic: for enemies not self } //Energized sp = dbcSpell.LookupEntryForced( 43750 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL; //Spell Haste Trinket sp = dbcSpell.LookupEntryForced( 33297 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL | static_cast<uint32>(PROC_TARGET_SELF); //Spell Focus Trigger (Mystical Skyfire Diamond) sp = dbcSpell.LookupEntryForced( 32837 ); if( sp != NULL ) sp->procChance = 15; // Band of the Eternal Sage sp = dbcSpell.LookupEntryForced( 35083 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL; // Band of the Eternal Restorer sp = dbcSpell.LookupEntryForced( 35086 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL; // Ashtongue Talisman of Shadows sp = dbcSpell.LookupEntryForced( 40478 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL; // Ashtongue Talisman of Swiftness sp = dbcSpell.LookupEntryForced( 40485 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL; // Ashtongue Talisman of Valor sp = dbcSpell.LookupEntryForced( 40458 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL; // Memento of Tyrande sp = dbcSpell.LookupEntryForced( 37655 ); if( sp != NULL ) sp->procFlags = PROC_ON_CAST_SPELL; // Ashtongue Talisman of Insight sp = dbcSpell.LookupEntryForced( 40482 ); if( sp != NULL ) sp->procFlags = PROC_ON_SPELL_CRIT_HIT; //Ashtongue Talisman of Equilibrium sp = dbcSpell.LookupEntryForced( 40442 ); if( sp != NULL ) { sp->Effect[0] = 6; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procChance = 40; sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectTriggerSpell[0] = 40452; sp->maxstack = 1; sp->Effect[1] = 6; sp->EffectApplyAuraName[1] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procChance = 25; sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectTriggerSpell[1] = 40445; sp->maxstack = 1; sp->Effect[2] = 6; sp->EffectApplyAuraName[2] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procChance = 25; sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectTriggerSpell[2] = 40446; sp->maxstack = 1; } //Ashtongue Talisman of Acumen sp = dbcSpell.LookupEntryForced( 40438 ); if( sp != NULL ) { sp->Effect[0] = 6; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procChance = 10; sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectTriggerSpell[0] = 40441; sp->maxstack = 1; sp->Effect[1] = 6; sp->EffectApplyAuraName[1] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procChance = 10; sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectTriggerSpell[1] = 40440; sp->maxstack = 1; } // Drums of war targets sorounding party members instead of us sp = dbcSpell.LookupEntryForced( 35475 ); if( sp != NULL ) { sp->EffectImplicitTargetA[0] = EFF_TARGET_ALL_PARTY; sp->EffectImplicitTargetA[1] = EFF_TARGET_ALL_PARTY; sp->EffectImplicitTargetA[2] = 0; sp->EffectImplicitTargetB[0] = 0; sp->EffectImplicitTargetB[1] = 0; sp->EffectImplicitTargetB[2] = 0; } // Symbol of Hope targets sorounding party members instead of us sp = dbcSpell.LookupEntryForced( 32548 ); if( sp != NULL ) { sp->EffectImplicitTargetA[0] = EFF_TARGET_ALL_PARTY; sp->EffectImplicitTargetA[1] = EFF_TARGET_ALL_PARTY; sp->EffectImplicitTargetA[2] = 0; sp->EffectImplicitTargetB[0] = 0; sp->EffectImplicitTargetB[1] = 0; sp->EffectImplicitTargetB[2] = 0; } // Drums of Battle targets sorounding party members instead of us sp = dbcSpell.LookupEntryForced( 35476 ); if( sp != NULL ) { sp->EffectImplicitTargetA[0] = EFF_TARGET_ALL_PARTY; sp->EffectImplicitTargetA[1] = EFF_TARGET_ALL_PARTY; sp->EffectImplicitTargetA[2] = 0; sp->EffectImplicitTargetB[0] = 0; sp->EffectImplicitTargetB[1] = 0; sp->EffectImplicitTargetB[2] = 0; } // Drums of Panic targets sorounding creatures instead of us sp = dbcSpell.LookupEntryForced( 35474 ); if( sp != NULL ) { sp->EffectImplicitTargetA[0] = EFF_TARGET_ALL_ENEMIES_AROUND_CASTER; sp->EffectImplicitTargetA[1] = EFF_TARGET_ALL_ENEMIES_AROUND_CASTER; sp->EffectImplicitTargetA[2] = 0; sp->EffectImplicitTargetB[0] = 0; sp->EffectImplicitTargetB[1] = 0; sp->EffectImplicitTargetB[2] = 0; } // Drums of Restoration targets sorounding party members instead of us sp = dbcSpell.LookupEntryForced( 35478 ); if( sp != NULL ) { sp->EffectImplicitTargetA[0] = EFF_TARGET_ALL_PARTY; sp->EffectImplicitTargetA[1] = EFF_TARGET_ALL_PARTY; sp->EffectImplicitTargetA[2] = 0; sp->EffectImplicitTargetB[0] = 0; sp->EffectImplicitTargetB[1] = 0; sp->EffectImplicitTargetB[2] = 0; } // Drums of Speed targets sorounding party members instead of us sp = dbcSpell.LookupEntryForced( 35477 ); if( sp != NULL ) { sp->EffectImplicitTargetA[0] = EFF_TARGET_ALL_PARTY; sp->EffectImplicitTargetA[1] = EFF_TARGET_ALL_PARTY; sp->EffectImplicitTargetA[2] = 0; sp->EffectImplicitTargetB[0] = 0; sp->EffectImplicitTargetB[1] = 0; sp->EffectImplicitTargetB[2] = 0; } // Dragonspine Trophy sp = dbcSpell.LookupEntryForced( 34774 ); if( sp != NULL ){ sp->procChance = 6; sp->procFlags = PROC_ON_MELEE_ATTACK | PROC_ON_RANGED_ATTACK; sp->proc_interval = 30000; } #ifndef NEW_PROCFLAGS //Ashtongue Talisman of Lethality sp = dbcSpell.LookupEntryForced( 40460 ); if( sp != NULL ) { sp->Effect[0] = 6; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procChance = 20; sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectTriggerSpell[0] = 40461; sp->maxstack = 1; } #else sp = dbcSpell.LookupEntryForced( 40460 ); if( sp != NULL ) sp->EffectSpellGroupRelation[0] = 262144 | 2097152 | 8388608 | 8519680 | 524288 | 1048576 | 8388608; #endif //Serpent-Coil Braid sp = dbcSpell.LookupEntryForced( 37447 ); if( sp != NULL ) { sp->Effect[0] = 6; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procChance = 100; sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectTriggerSpell[0] = 37445; sp->maxstack = 1; } // Band of the Eternal Champion sp = dbcSpell.LookupEntryForced( 35080 ); if( sp != NULL ){ sp->procFlags = PROC_ON_MELEE_ATTACK; sp->proc_interval = 60000; } // Band of the Eternal Sage sp = dbcSpell.LookupEntryForced( 35083 ); if( sp != NULL ){ sp->procFlags = PROC_ON_CAST_SPELL; sp->proc_interval = 60000; } // Band of the Eternal Restorer sp = dbcSpell.LookupEntryForced( 35086 ); if( sp != NULL ){ sp->procFlags = PROC_ON_CAST_SPELL; sp->proc_interval = 60000; } // Band of the Eternal Defender sp = dbcSpell.LookupEntryForced( 35077 ); if( sp != NULL ){ sp->procFlags = PROC_ON_MELEE_ATTACK_VICTIM | PROC_ON_SPELL_HIT_VICTIM | PROC_ON_RANGED_ATTACK_VICTIM; sp->proc_interval = 60000; } //Item Set: Malorne Harness sp = dbcSpell.LookupEntryForced( 37306 ); if( sp != NULL ) { sp->procChance = 4; sp->procFlags = PROC_ON_MELEE_ATTACK; } sp = dbcSpell.LookupEntryForced( 37311 ); if( sp != NULL ) { sp->procChance = 4; sp->procFlags = PROC_ON_MELEE_ATTACK; } //Item Set: Deathmantle sp = dbcSpell.LookupEntryForced( 37170 ); if( sp != NULL ) { sp->procChance = 4; sp->procFlags = PROC_ON_MELEE_ATTACK; } //Item Set: Netherblade sp = dbcSpell.LookupEntryForced( 37168 ); if( sp != NULL ) { sp->procChance = 15; //sp->procFlags = PROC_ON_CAST_SPELL; Need new flag - PROC_ON_FINISH_MOVE; } //Item Set: Tirisfal Regalia sp = dbcSpell.LookupEntryForced( 37443 ); if( sp != NULL ) { sp->procFlags = PROC_ON_SPELL_CRIT_HIT; } //Item Set: Avatar Regalia sp = dbcSpell.LookupEntryForced( 37600 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->procChance = 6; } //Item Set: Incarnate Raiment sp = dbcSpell.LookupEntryForced( 37568 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } //Item Set: Voidheart Raiment sp = dbcSpell.LookupEntryForced( 37377 ); if( sp != NULL ) { sp->Effect[0] = 6; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procChance = 5; sp->procFlags = PROC_ON_CAST_SPELL; sp->proc_interval = 20; sp->EffectTriggerSpell[0] = 37379; } sp = dbcSpell.LookupEntryForced( 39437 ); if( sp != NULL ) { sp->Effect[0] = 6; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->procChance = 5; sp->procFlags = PROC_ON_CAST_SPELL; sp->proc_interval = 20; sp->EffectTriggerSpell[0] = 37378; } //Item Set: Cataclysm Raiment sp = dbcSpell.LookupEntryForced( 37227 ); if( sp != NULL ) { sp->proc_interval = 60000; sp->procChance = 100; sp->procFlags = PROC_ON_SPELL_CRIT_HIT; } //Item Set: Cataclysm Regalia sp = dbcSpell.LookupEntryForced( 37228 ); if( sp != NULL ) { sp->procChance = 7; sp->procFlags = PROC_ON_CAST_SPELL; } sp = dbcSpell.LookupEntryForced( 37237 ); if( sp != NULL ) { sp->procChance = 25; sp->procFlags = PROC_ON_SPELL_CRIT_HIT; } //Item Set: Cataclysm Harness sp = dbcSpell.LookupEntryForced( 37239 ); if( sp != NULL ) { sp->procChance = 2; sp->procFlags = PROC_ON_MELEE_ATTACK; } //Item Set: Cyclone Regalia sp = dbcSpell.LookupEntryForced( 37213 ); if( sp != NULL ) { sp->procChance = 11; sp->procFlags = PROC_ON_SPELL_CRIT_HIT; } //Item Set: Lightbringer Battlegear sp = dbcSpell.LookupEntryForced( 38427 ); if( sp != NULL ) { sp->procFlags = PROC_ON_MELEE_ATTACK; sp->procChance = 20; } //Item Set: Crystalforge Armor sp = dbcSpell.LookupEntryForced( 37191 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } //Item Set: Crystalforge Battlegear sp = dbcSpell.LookupEntryForced( 37195 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->procChance = 6; } //Item Set: Crystalforge Raiment sp = dbcSpell.LookupEntryForced( 37189 ); if( sp != NULL ) { sp->procFlags = PROC_ON_SPELL_CRIT_HIT; sp->proc_interval = 60000; } sp = dbcSpell.LookupEntryForced( 37188 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; } //Item Set: Destroyer Armor sp = dbcSpell.LookupEntryForced( 37525 ); if( sp != NULL ) { sp->procFlags = PROC_ON_MELEE_ATTACK_VICTIM; sp->procChance = 7; } //Item Set: Destroyer Battlegear sp = dbcSpell.LookupEntryForced( 37528 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->procChance = 100; } //Item Set: Warbringer Armor sp = dbcSpell.LookupEntryForced( 37516 ); if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->procChance = 100; } //all Drums sp = dbcSpell.LookupEntryForced( 35474 ); if( sp != NULL ) sp->RequiredShapeShift = 0; sp = dbcSpell.LookupEntryForced( 35475 ); if( sp != NULL ) sp->RequiredShapeShift = 0; sp = dbcSpell.LookupEntryForced( 35476 ); if( sp != NULL ) sp->RequiredShapeShift = 0; sp = dbcSpell.LookupEntryForced( 35477 ); if( sp != NULL ) sp->RequiredShapeShift = 0; sp = dbcSpell.LookupEntryForced( 35478 ); if( sp != NULL ) sp->RequiredShapeShift = 0; //this an on equip item spell(2824) : ice arrow(29501) sp = dbcSpell.LookupEntryForced( 29501 ); if( sp != NULL ) { sp->procChance = 30;//some say it is triggered every now and then sp->procFlags = PROC_ON_RANGED_ATTACK; } //Purify helboar meat sp = dbcSpell.LookupEntryForced( 29200 ); if( sp != NULL ) { sp->Reagent[1] = 0; sp->ReagentCount[1] = 0; sp->Effect[0] = 24; } // - Warrior - Warbringer Armor // 2 pieces: You have a chance each time you parry to gain Blade Turning, absorbing 200 damage for 15 sec. // SPELL ID = 37514 (http://www.wowhead.com/?spell=37514) sp = dbcSpell.LookupEntryForced( 37514 ); if( sp != NULL ) { sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 37515; sp->procChance = 25; } //Thorium Grenade sp = dbcSpell.LookupEntryForced(19769); if(sp != NULL) { sp->InterruptFlags |= ~(CAST_INTERRUPT_ON_MOVEMENT); } //M73 Frag Grenade sp = dbcSpell.LookupEntryForced(13808); if(sp != NULL) { sp->InterruptFlags |= ~(CAST_INTERRUPT_ON_MOVEMENT); } //Iron Grenade sp = dbcSpell.LookupEntryForced(4068); if(sp != NULL) { sp->InterruptFlags |= ~(CAST_INTERRUPT_ON_MOVEMENT); } //Frost Grenade sp = dbcSpell.LookupEntryForced(39965); if(sp != NULL) { sp->InterruptFlags |= ~(CAST_INTERRUPT_ON_MOVEMENT); } //Adamantine Grenade sp = dbcSpell.LookupEntryForced(30217); if(sp != NULL) { sp->InterruptFlags |= ~(CAST_INTERRUPT_ON_MOVEMENT); } sp = dbcSpell.LookupEntryForced( 40475 ); // Black temple melee trinket if( sp != NULL ) sp->procChance = 50; // Band of the Eternal Champion: reduced proc rate sp = dbcSpell.LookupEntryForced( 35080 ); if( sp != NULL ) sp->procChance = 5; // Band of the Eternal Sage: reduced proc rate sp = dbcSpell.LookupEntryForced( 35083 ); if( sp != NULL ) sp->procChance = 5; // Band of the Eternal Defender: reduced proc rate sp = dbcSpell.LookupEntryForced( 35077 ); if( sp != NULL ) sp->procChance = 5; // Band of the Eternal Restorer: reduced proc rate sp = dbcSpell.LookupEntryForced( 35086 ); if( sp != NULL ) sp->procChance = 5; // Deadly Throw Interrupt sp = dbcSpell.LookupEntryForced( 32748 ); if( sp != NULL ) { sp->procFlags = PROC_ON_RANGED_ATTACK | PROC_ON_CAST_SPELL; } ////////////////////////////////////////// // BOSSES // ////////////////////////////////////////// // Insert boss spell fixes here // Dark Glare sp = dbcSpell.LookupEntryForced( 26029 ); if( sp != NULL ) sp->cone_width = 15.0f; // 15 degree cone // Drain Power (Malacrass) // bugged - the charges fade even when refreshed with new ones. This makes them everlasting. sp = dbcSpell.LookupEntryForced( 44131 ); if( sp != NULL ) sp->DurationIndex = 21; sp = dbcSpell.LookupEntryForced( 44132 ); if( sp != NULL ) sp->DurationIndex = 21; // Zul'jin spell, proc from Creeping Paralysis sp = dbcSpell.LookupEntryForced( 43437 ); if( sp != NULL ) { sp->EffectImplicitTargetA[0] = 0; sp->EffectImplicitTargetA[1] = 0; } // Recently Dropped Flag sp = dbcSpell.LookupEntryForced( 42792 ); if (sp != NULL) sp->c_is_flags |= SPELL_FLAG_IS_FORCEDDEBUFF; /* cebernic 's fixes */ //resurrection sickness sp = dbcSpell.LookupEntryForced( 15007 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_FORCEDDEBUFF; } // ghost ,NIGHTELF ghost & sprit sp = dbcSpell.LookupEntryForced( 20584 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_FORCEDDEBUFF; } sp = dbcSpell.LookupEntryForced( 9036 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_FORCEDDEBUFF; } sp = dbcSpell.LookupEntryForced( 8326 ); if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_FORCEDDEBUFF; } sp = dbcSpell.LookupEntryForced( 26013 ); //bg deserter if( sp != NULL ) { sp->c_is_flags |= SPELL_FLAG_IS_FORCEDDEBUFF; } sp = dbcSpell.LookupEntryForced( 24379 ); //bg Restoration if( sp != NULL ) { sp->EffectTriggerSpell[0] = 23493; sp->c_is_flags = SPELL_FLAG_IS_FORCEDBUFF; } sp = dbcSpell.LookupEntryForced( 23493 ); //bg Restoration if( sp != NULL ) { sp->EffectTriggerSpell[0] = 24379; sp->c_is_flags = SPELL_FLAG_IS_FORCEDBUFF; } sp = dbcSpell.LookupEntryForced ( 5246 ); // why self? if( sp != NULL ) { sp->procFlags = PROC_ON_CAST_SPELL; sp->EffectApplyAuraName[0] = SPELL_AURA_PROC_TRIGGER_SPELL; sp->Effect[0] = SPELL_EFFECT_TRIGGER_SPELL; sp->EffectTriggerSpell[0] = 20511; // cebernic: this just real spell sp->EffectImplicitTargetA[0] = EFF_TARGET_NONE; } //Dazed sp = dbcSpell.LookupEntryForced( 15571 ); if( sp != NULL ) sp->c_is_flags |= SPELL_FLAG_IS_FORCEDDEBUFF; //Bandage sp = dbcSpell.LookupEntryForced( 11196 ); if( sp != NULL ) sp->c_is_flags = SPELL_FLAG_IS_FORCEDDEBUFF; }
[ "[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef" ]
[ [ [ 1, 6159 ] ] ]
1ae5b581191a139fa1f32d62c486716dfdc8e786
fba89bd35ead23881a7f15d3ff0ca300535c9801
/jni/Old/ImageTargets_me_new.cpp
c80043bea6ada163a3cb1df72b726a114c8aa5fa
[]
no_license
masoudsafa/virtualwimbledonpro
56e440be7d32457201bac5508ede9c14676a09c9
72ba75655d49a9cd0ea8ae3308394269ff22a0f1
refs/heads/master
2021-01-10T07:23:18.496832
2011-07-29T15:45:58
2011-07-29T15:45:58
43,097,253
0
0
null
null
null
null
UTF-8
C++
false
false
35,528
cpp
/*============================================================================== Copyright (c) 2010-2011 QUALCOMM Incorporated. All Rights Reserved. Qualcomm Confidential and Proprietary @file ImageTargets.cpp @brief Sample for ImageTargets ==============================================================================*/ #include <jni.h> #include <android/log.h> #include <stdio.h> #include <string.h> #include <assert.h> #include <sys/time.h> #ifdef USE_OPENGL_ES_1_1 #include <GLES/gl.h> #include <GLES/glext.h> #else #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> #endif #include <QCAR/QCAR.h> #include <QCAR/CameraDevice.h> #include <QCAR/Renderer.h> #include <QCAR/VideoBackgroundConfig.h> #include <QCAR/Trackable.h> #include <QCAR/Tool.h> #include <QCAR/Tracker.h> #include <QCAR/CameraCalibration.h> #include "SampleUtils.h" #include "SampleMath.cpp" #include "Texture.h" #include "CubeShaders.h" #include "Teapot.h" #include "boundary.h" #include "justnet.h" #include "ball.h" #ifdef __cplusplus extern "C" { #endif // Demo Code -- to be deleted! float someNumber =0.0f; // 50.0f // -- // Unit cube variables // Used for collision detection QCAR::Vec3F ballBaseVertices[8]; QCAR::Vec3F courtBaseVertices[8]; QCAR::Vec3F cameraBaseVertices[8]; QCAR::Vec3F dominoTransformedVerticesA[8]; QCAR::Vec3F dominoTransformedVerticesB[8]; QCAR::Vec3F dominoNormals[3]; QCAR::Matrix44F transformBall; QCAR::Matrix44F transformCourt; QCAR::Matrix44F ballTransform; QCAR::Matrix44F courtTransform; QCAR::Vec4F cameraPosition; QCAR::Matrix44F cameraTransform; bool collision = false; //-- // Textures: int textureCount = 0; Texture** textures = 0; // OpenGL ES 2.0 specific: #ifdef USE_OPENGL_ES_2_0 unsigned int shaderProgramID = 0; GLint vertexHandle = 0; GLint normalHandle = 0; GLint textureCoordHandle = 0; GLint vertexHandleNet = 1; GLint normalHandleNet = 1; GLint textureCoordHandleNet = 1; GLint mvpMatrixHandle = 0; #endif // Screen dimensions: unsigned int screenWidth = 0; unsigned int screenHeight = 0; // Indicates whether screen is in portrait (true) or landscape (false) mode bool isActivityInPortraitMode = false; //Switch direction int direction = -1; // The projection matrix used for rendering virtual objects: QCAR::Matrix44F projectionMatrix; void initCourtBaseVertices(); void initBallBaseVertices(); void initDominoNormals(); bool checkIntersection(QCAR::Matrix44F transformA, QCAR::Matrix44F transformB,bool camera); bool isSeparatingAxis(QCAR::Vec3F axis); void dumpMVM(const float * matrx); void handleCollision(); void detectAndHandleCollision(); void detectCollision(); // Demo Code -- to be deleted! void animateBall(float*,bool); void updateCourtTransform(); // Constants: static const float kObjectScale = 3.f * 75.0f; float val =1.0f; //Structs struct Vector3 { float x; float y; float z; }; struct BoundingBox { Vector3 max; Vector3 min; }; JNIEXPORT int JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_getOpenGlEsVersionNative(JNIEnv *, jobject) { #ifdef USE_OPENGL_ES_1_1 return 1; #else return 2; #endif } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_setActivityPortraitMode(JNIEnv *, jobject, jboolean isPortrait) { isActivityInPortraitMode = isPortrait; } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_onQCARInitializedNative(JNIEnv *, jobject) { // Comment in to enable tracking of up to 2 targets simultaneously and // split the work over multiple frames: // QCAR::setHint(QCAR::HINT_MAX_SIMULTANEOUS_IMAGE_TARGETS, 2); // QCAR::setHint(QCAR::HINT_IMAGE_TARGET_MULTI_FRAME_ENABLED, 1); // Initialise the unit cube initCourtBaseVertices(); initBallBaseVertices(); initDominoNormals(); } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv *, jobject) { //LOG("Java_com_qualcomm_QCARSamples_ImageTargets_GLRenderer_renderFrame"); // Clear color and depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Render video background: QCAR::State state = QCAR::Renderer::getInstance().begin(); #ifdef USE_OPENGL_ES_1_1 // Set GL11 flags: glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glHint(GL_LINE_SMOOTH_HINT,GL_NICEST); // glHint(GL_POINT_SMOOTH_HINT,GL_NICEST); glEnable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); #endif glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); // Did we find any trackables this frame? for(int tIdx = 0; tIdx < state.getNumActiveTrackables(); tIdx++) { // Get the trackable: const QCAR::Trackable* trackable = state.getActiveTrackable(tIdx); QCAR::Matrix44F modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(trackable->getPose()); #ifdef USE_OPENGL_ES_1_1 LOG("Java_com_qualcomm_QCARSamples_ImageTargets_GLRenderer_renderFrame: USE_OPENGL_ES_1_1 UNSUPPORTED"); #else QCAR::Matrix44F modelViewProjection; //Tennis Court in 3 objects ///////////////////////////////////////////////////////////////////////////////////////// // Camera // ///////////////////////////////////////////////////////////////////////////////////////// QCAR::Matrix44F inverseModelView = SampleMath::Matrix44FInverse(modelViewMatrix); cameraPosition.data[0] = 0.0f; cameraPosition.data[1] = 0.0f; cameraPosition.data[2] = 0.0f; cameraPosition.data[3] = 1.0f; LOG("->Pose Matrix"); dumpMVM(&inverseModelView.data[0]); //inverseModelView = SampleMath::Matrix44FTranspose(inverseModelView); cameraPosition = SampleMath::SampleMath::Vec4FTransform(cameraPosition,inverseModelView); cameraTransform = SampleMath::Matrix44FIdentity(); SampleUtils::translatePoseMatrix(cameraPosition.data[0],cameraPosition.data[1],cameraPosition.data[2], &cameraTransform.data[0]); LOG("Camera Position:: [%f, %f, %f]",cameraPosition.data[0],cameraPosition.data[1],cameraPosition.data[2]); LOG("->Camera Transform"); dumpMVM(&cameraTransform.data[0]); //----- ///////////////////////////////////////////////////////////////////////////////////////// // The Court // ///////////////////////////////////////////////////////////////////////////////////////// transformCourt = QCAR::Tool::convertPose2GLMatrix(trackable->getPose()); float* transformPtr = &transformCourt.data[0]; courtTransform = SampleMath::Matrix44FIdentity(); LOG("Court transform:Before"); dumpMVM(&courtTransform.data[0]); SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, 4*kObjectScale, transformPtr); // SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, 4*kObjectScale, &courtTransform.data[0]); LOG("Court transform:After"); dumpMVM(&courtTransform.data[0]); SampleUtils::multiplyMatrix(&projectionMatrix.data[0], transformPtr , &modelViewProjection.data[0]); // Render the court glUseProgram(shaderProgramID); glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, boundaryVerts); glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, boundaryNormals); glEnableVertexAttribArray(vertexHandle); glEnableVertexAttribArray(normalHandle); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textures[3]->mTextureID); glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)&modelViewProjection.data[0] ); glDrawArrays(GL_TRIANGLE_STRIP, 0, boundaryNumVerts); ///////////////////////////////////////////////////////////////////////////////////////// // Lines & Net // ///////////////////////////////////////////////////////////////////////////////////////// //second object - Lines modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(trackable->getPose()); SampleUtils::translatePoseMatrix(0.0f, 0.0f, 1, &modelViewMatrix.data[0]); SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, 4*kObjectScale, &modelViewMatrix.data[0]); SampleUtils::multiplyMatrix(&projectionMatrix.data[0], &modelViewMatrix.data[0] , &modelViewProjection.data[0]); glEnableVertexAttribArray(vertexHandle); glEnableVertexAttribArray(normalHandle); glBindTexture(GL_TEXTURE_2D, textures[2]->mTextureID); glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)&modelViewProjection.data[0] ); glDrawArrays(GL_LINES, 0, boundaryNumVerts); modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(trackable->getPose()); SampleUtils::translatePoseMatrix(0.0f,0.0f, (kObjectScale / 10), &modelViewMatrix.data[0]); SampleUtils::scalePoseMatrix(2*kObjectScale/3, kObjectScale, kObjectScale, &modelViewMatrix.data[0]); SampleUtils::multiplyMatrix(&projectionMatrix.data[0], &modelViewMatrix.data[0] , &modelViewProjection.data[0]); glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, justnetVerts); glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, justnetNormals); // glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, // justnetTexCoords); glEnableVertexAttribArray(vertexHandle); glEnableVertexAttribArray(normalHandle); // glEnableVertexAttribArray(textureCoordHandle); glBindTexture(GL_TEXTURE_2D, textures[2]->mTextureID); glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)&modelViewProjection.data[0] ); glDrawArrays(GL_LINES, 0, justnetNumVerts); ///////////////////////////////////////////////////////////////////////////////////////// // Ball // ///////////////////////////////////////////////////////////////////////////////////////// transformBall = QCAR::Tool::convertPose2GLMatrix(trackable->getPose()); LOG(" Trackable :"); dumpMVM(&transformBall.data[0]); transformPtr = &transformBall.data[0]; ballTransform = SampleMath::Matrix44FIdentity(); animateBall(transformPtr,true); animateBall(&ballTransform.data[0],false); //updateCourtTransform(); LOG(" In Render7"); // Scaling doesn't work here so neglect it //SampleUtils::scalePoseMatrix((kObjectScale/32), (kObjectScale/32), (kObjectScale/32), &ballTransform.data[0]); SampleUtils::scalePoseMatrix((kObjectScale/32), (kObjectScale/32), (kObjectScale/32), transformPtr); LOG("Court transform:After"); dumpMVM(&ballTransform.data[0]); SampleUtils::multiplyMatrix(&projectionMatrix.data[0], transformPtr, &modelViewProjection.data[0]); // Now render the ball glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, ballVerts); glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, ballTexCoords); glEnableVertexAttribArray(vertexHandle); glEnableVertexAttribArray(textureCoordHandle); glBindTexture(GL_TEXTURE_2D, textures[0]->mTextureID); glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)&modelViewProjection.data[0] ); glDrawArrays(GL_TRIANGLES, 0, ballNumVerts); SampleUtils::checkGlError("ImageTargets renderFrame"); // Done with rendering now check for collision // Uncomment to check out the collision detection detectCollision(); //detectAndHandleCollision(); // -- #endif } glDisable(GL_DEPTH_TEST); #ifdef USE_OPENGL_ES_1_1 glDisable(GL_TEXTURE_2D); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); #else glDisableVertexAttribArray(vertexHandle); glDisableVertexAttribArray(normalHandle); glDisableVertexAttribArray(textureCoordHandle); glDisableVertexAttribArray(vertexHandleNet); glDisableVertexAttribArray(normalHandleNet); #endif QCAR::Renderer::getInstance().end(); } void configureVideoBackground() { // Get the default video mode: QCAR::CameraDevice& cameraDevice = QCAR::CameraDevice::getInstance(); QCAR::VideoMode videoMode = cameraDevice. getVideoMode(QCAR::CameraDevice::MODE_DEFAULT); // Configure the video background QCAR::VideoBackgroundConfig config; config.mEnabled = true; config.mSynchronous = true; config.mPosition.data[0] = 0.0f; config.mPosition.data[1] = 0.0f; if (isActivityInPortraitMode) { //LOG("configureVideoBackground PORTRAIT"); config.mSize.data[0] = videoMode.mHeight * (screenHeight / (float)videoMode.mWidth); config.mSize.data[1] = screenHeight; } else { //LOG("configureVideoBackground LANDSCAPE"); config.mSize.data[0] = screenWidth; config.mSize.data[1] = videoMode.mHeight * (screenWidth / (float)videoMode.mWidth); } // Set the config: QCAR::Renderer::getInstance().setVideoBackgroundConfig(config); } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_initApplicationNative( JNIEnv* env, jobject obj, jint width, jint height) { LOG("Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_initApplicationNative"); // Store screen dimensions screenWidth = width; screenHeight = height; // Handle to the activity class: jclass activityClass = env->GetObjectClass(obj); jmethodID getTextureCountMethodID = env->GetMethodID(activityClass, "getTextureCount", "()I"); if (getTextureCountMethodID == 0) { LOG("Function getTextureCount() not found."); return; } textureCount = env->CallIntMethod(obj, getTextureCountMethodID); if (!textureCount) { LOG("getTextureCount() returned zero."); return; } textures = new Texture*[textureCount]; jmethodID getTextureMethodID = env->GetMethodID(activityClass, "getTexture", "(I)Lcom/qualcomm/QCARSamples/ImageTargets/Texture;"); if (getTextureMethodID == 0) { LOG("Function getTexture() not found."); return; } // Register the textures for (int i = 0; i < textureCount; ++i) { jobject textureObject = env->CallObjectMethod(obj, getTextureMethodID, i); if (textureObject == NULL) { LOG("GetTexture() returned zero pointer"); return; } textures[i] = Texture::create(env, textureObject); } } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_deinitApplicationNative( JNIEnv* env, jobject obj) { LOG("Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_deinitApplicationNative"); // Release texture resources if (textures != 0) { for (int i = 0; i < textureCount; ++i) { delete textures[i]; textures[i] = NULL; } delete[]textures; textures = NULL; textureCount = 0; } } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_startCamera(JNIEnv *, jobject) { LOG("Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_startCamera"); // Initialize the camera: if (!QCAR::CameraDevice::getInstance().init()) return; // Configure the video background configureVideoBackground(); // Select the default mode: if (!QCAR::CameraDevice::getInstance().selectVideoMode( QCAR::CameraDevice::MODE_DEFAULT)) return; // Start the camera: if (!QCAR::CameraDevice::getInstance().start()) return; // Uncomment to enable flash //if(QCAR::CameraDevice::getInstance().setFlashTorchMode(true)) // LOG("IMAGE TARGETS : enabled torch"); // Uncomment to enable infinity focus mode, or any other supported focus mode // See CameraDevice.h for supported focus modes //if(QCAR::CameraDevice::getInstance().setFocusMode(QCAR::CameraDevice::FOCUS_MODE_INFINITY)) // LOG("IMAGE TARGETS : enabled infinity focus"); // Start the tracker: QCAR::Tracker::getInstance().start(); // Cache the projection matrix: const QCAR::Tracker& tracker = QCAR::Tracker::getInstance(); const QCAR::CameraCalibration& cameraCalibration = tracker.getCameraCalibration(); projectionMatrix = QCAR::Tool::getProjectionGL(cameraCalibration, 2.0f, 2000.0f); LOG("Camera projection::startCamera"); dumpMVM(&projectionMatrix.data[0]); } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_stopCamera(JNIEnv *, jobject) { LOG("Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_stopCamera"); QCAR::Tracker::getInstance().stop(); QCAR::CameraDevice::getInstance().stop(); QCAR::CameraDevice::getInstance().deinit(); } JNIEXPORT jboolean JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_toggleFlash(JNIEnv*, jobject, jboolean flash) { return QCAR::CameraDevice::getInstance().setFlashTorchMode((flash==JNI_TRUE)) ? JNI_TRUE : JNI_FALSE; } JNIEXPORT jboolean JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_autofocus(JNIEnv*, jobject) { return QCAR::CameraDevice::getInstance().startAutoFocus()?JNI_TRUE:JNI_FALSE; } JNIEXPORT jboolean JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_setFocusMode(JNIEnv*, jobject, jint mode) { return QCAR::CameraDevice::getInstance().setFocusMode(mode)?JNI_TRUE:JNI_FALSE; } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_initRendering( JNIEnv* env, jobject obj) { LOG("Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_initRendering"); // Define clear color glClearColor(0.0f, 0.0f, 0.0f, QCAR::requiresAlpha() ? 0.0f : 1.0f); // Now generate the OpenGL texture objects and add settings for (int i = 0; i < textureCount; ++i) { glGenTextures(1, &(textures[i]->mTextureID)); glBindTexture(GL_TEXTURE_2D, textures[i]->mTextureID); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textures[i]->mWidth, textures[i]->mHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) textures[i]->mData); } #ifndef USE_OPENGL_ES_1_1 shaderProgramID = SampleUtils::createProgramFromBuffer(cubeMeshVertexShader, cubeFragmentShader); vertexHandle = glGetAttribLocation(shaderProgramID, "vertexPosition"); normalHandle = glGetAttribLocation(shaderProgramID, "vertexNormal"); textureCoordHandle = glGetAttribLocation(shaderProgramID, "vertexTexCoord"); mvpMatrixHandle = glGetUniformLocation(shaderProgramID, "modelViewProjectionMatrix"); #endif } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_updateRendering( JNIEnv* env, jobject obj, jint width, jint height) { LOG("Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_updateRendering"); // Update screen dimensions screenWidth = width; screenHeight = height; // Reconfigure the video background configureVideoBackground(); } /////////////////////////////////////////////////// //Custom Methods double getCurrentTime() { struct timeval tv; gettimeofday(&tv, NULL); double t = tv.tv_sec + tv.tv_usec/1000000.0; return t; } // Demo code -- to be deleted/changed //void //animateBall(float* transform) //{ // //if(!collision&&someNumber<=50.0f){ //// someNumber-=0.5f; //// //// } //// else { //// if(collision||someNumber==-50.0f){ //// someNumber+=0.5f; //// if(someNumber==50.0f) //// collision = false; // Reset collision //// //// } //// } //// //// //// SampleUtils::translatePoseMatrix(50.0f, 0.0f, float(someNumber), //// transform); // // //static float rotateBowlAngle = 0.0f; //static double prevTime = getCurrentTime(); //double time = getCurrentTime(); //float dt = (float)(time-prevTime); // // if(collision){ // direction*=-1; // collision = false; // LOG("Calling animate after collision6"); // val+=5.0f; // //animateBall(transform); // // // } // // // dt*=direction; //Switches ball direction // // rotateBowlAngle += dt * 180.0f/3.1415f; // Animate angle based on time // LOG("Rotate angle:%f",rotateBowlAngle); // // // // SampleUtils::rotatePoseMatrix(rotateBowlAngle, 1.0f, 0.0f, 0.0f, // transform); // // //SampleUtils::translatePoseMatrix(0.0f, -0.50f*120.0f, 1.35f*120.0f, //// transform); // // SampleUtils::translatePoseMatrix(0.0f, 0.7f*120.0f, 0.0f, // transform); // // SampleUtils::rotatePoseMatrix(-90.0f, 1.0f, 0, 0, // transform); // // prevTime = time; // // //} // // //// This is likely to be changed later //// Temporary fix! //void updateCourtTransform(){ // // //update the x, y co-ordinates to correctly detect collision instead of just origin // // QCAR::Matrix44F ball = SampleMath::Matrix44FInverse(ballTransform); // // // LOG("Dumping ball inverse:"); // dumpMVM(&ball.data[0]); // // // float xpos = ball.data[3]; // X transformation // float ypos = ball.data[7]; // Y Transformation // float zpos = ball.data[11]; // Z Transformation // // LOG("Positions: [%f %f %f ]", -xpos, -ypos, -zpos); // // SampleUtils::translatePoseMatrix( -xpos, -ypos, courtTransform.data[2], // &courtTransform.data[0]); // // // // // } // New Code void animateBall(float* transform,bool isRenderTransform) { //if(!collision&&someNumber<=50.0f){ // // someNumber-=0.5f; // // // // } // // else { // // if(collision||someNumber==-50.0f){ // // someNumber+=0.5f; // // if(someNumber==50.0f) // // collision = false; // Reset collision // // // // } // // } // // // // // // SampleUtils::translatePoseMatrix(50.0f, 0.0f, float(someNumber), // // transform); // // static float rotateBowlAngle = 0.0f; static double prevTime = getCurrentTime(); double time = getCurrentTime(); float dt = (float)(time-prevTime); static float val=1.0f; if(collision){ //direction*=-1; collision=false; LOG("Calling animate after collision99"); val+=5.0f; rotateBowlAngle=0.0f; animateBall(transform,isRenderTransform); } if (isRenderTransform) { dt*=direction; //Switches ball direction rotateBowlAngle += dt * 180.0f/3.1415f; // Animate angle based on time LOG("Rotate angle:%f",rotateBowlAngle); } SampleUtils::translatePoseMatrix(0.0f, 40.0f, 0.0f, // Move it just to the end of the court transform); SampleUtils::rotatePoseMatrix(rotateBowlAngle, val, 0.0f, 0.0f, transform); SampleUtils::translatePoseMatrix(0.0f, 40.0f, 0.0f, transform); SampleUtils::rotatePoseMatrix(rotateBowlAngle, 0.0f, val, 0, transform); if (isRenderTransform) { prevTime = time; } } JNIEXPORT jfloatArray JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_getBallModelView(JNIEnv* env){ LOG("MVM Ball::native"); //Global mvm of ball jfloatArray ballMVM; int size=16; ballMVM = env->NewFloatArray(size); if (ballMVM == NULL) { LOG("Cannot Allocated MVM"); return NULL; } jfloat fill[size]; for (int i = 0; i < size; i++) { fill[i] = ballTransform.data[i]; // LOG("ballmvm:%d",fill[i]); } // move from the temp structure to the java structure env->SetFloatArrayRegion(ballMVM, 0, size, fill); return ballMVM; } JNIEXPORT jfloatArray JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_getCourtModelView(JNIEnv* env, jobject obj){ LOG("Court MVM::native"); /* //Global mvm of ball jfloatArray courtMVM; int size=16; courtMVM = env->NewFloatArray(size); if (courtMVM == NULL) { LOG("Cannot Allocated MVM"); return NULL; } jfloat fill[size]; for (int i = 0; i < size; i++) { fill[i] = mvmCourt[i]; } // move from the temp structure to the java structure env->SetFloatArrayRegion(courtMVM, 0, size, fill); return courtMVM; */ } JNIEXPORT void JNICALL Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_dumpBallMVM(JNIEnv* env, jobject){ LOG("dumpBallMVM"); //SampleUtils::printMatrix(mvmBall); } // Change it later to send actual ball bounce JNIEXPORT jboolean JNICALL Java_com_vmp_main_GamePlay_isBallBounce(JNIEnv*, jobject) { LOG("isBallBounce::Native"); if(collision) return JNI_TRUE; return JNI_FALSE; } JNIEXPORT jboolean JNICALL Java_com_vmp_main_GamePlay_isBallHit(JNIEnv*, jobject) { if(collision) return JNI_TRUE; return JNI_FALSE; } void dumpMVM(const float* mvm){ LOG("Dumping MVM:"); SampleUtils::printMatrix(mvm); } // Collision detection // ---------------------------------------------------------------------------- // Collision detection // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Unitcube as bounding box - initialization // ---------------------------------------------------------------------------- void initBallBaseVertices() { // Initialize a set of vertices describing the Bouding box for Ball ballBaseVertices[0] = QCAR::Vec3F(1.0f, 1.0f, 1.0f); ballBaseVertices[1] = QCAR::Vec3F(-1.0f, 1.0f, 1.0f); ballBaseVertices[2] = QCAR::Vec3F(1.0f, -1.0f, 1.0f); ballBaseVertices[3] = QCAR::Vec3F(-1.0f, -1.0f, 1.0f); ballBaseVertices[4] = QCAR::Vec3F(1.0f, 1.0f, -1.0f); ballBaseVertices[5] = QCAR::Vec3F(-1.0f, 1.0f, -1.0f); ballBaseVertices[6] = QCAR::Vec3F(1.0f, -1.0f, -1.0f); ballBaseVertices[7] = QCAR::Vec3F(-1.0f, -1.0f, -1.0f); } void initCourtBaseVertices() { // Initialize a set of vertices describing the bounding box of Court courtBaseVertices[0] = QCAR::Vec3F(kObjectScale/2, kObjectScale/2, 1.0f); courtBaseVertices[1] = QCAR::Vec3F(-kObjectScale/2, kObjectScale/2, 1.0f); courtBaseVertices[2] = QCAR::Vec3F(kObjectScale/2, -kObjectScale/2, 1.0f); courtBaseVertices[3] = QCAR::Vec3F(-kObjectScale/2, -kObjectScale/2, 1.0f); courtBaseVertices[4] = QCAR::Vec3F(kObjectScale/2, kObjectScale/2, -1.0f); courtBaseVertices[5] = QCAR::Vec3F(-kObjectScale/2, kObjectScale/2, -1.0f); courtBaseVertices[6] = QCAR::Vec3F(kObjectScale/2, -kObjectScale/2, -1.0f); courtBaseVertices[7] = QCAR::Vec3F(-kObjectScale/2, -kObjectScale/2, -1.0f); } void initCameraBaseVertices() { // Initialize a set of vertices describing the bounding box of Court cameraBaseVertices[0] = QCAR::Vec3F(kObjectScale/2, kObjectScale/2, kObjectScale/2); cameraBaseVertices[1] = QCAR::Vec3F(-kObjectScale/2, kObjectScale/2, kObjectScale/2); cameraBaseVertices[2] = QCAR::Vec3F(kObjectScale/2, -kObjectScale/2, kObjectScale/2); cameraBaseVertices[3] = QCAR::Vec3F(-kObjectScale/2, -kObjectScale/2, kObjectScale/2); cameraBaseVertices[4] = QCAR::Vec3F(kObjectScale/2, kObjectScale/2, -kObjectScale/2); cameraBaseVertices[5] = QCAR::Vec3F(-kObjectScale/2, kObjectScale/2, -kObjectScale/2); cameraBaseVertices[6] = QCAR::Vec3F(kObjectScale/2, -kObjectScale/2, -kObjectScale/2); cameraBaseVertices[7] = QCAR::Vec3F(-kObjectScale/2, -kObjectScale/2, -kObjectScale/2); } void initDominoNormals() { // Initialize a set of normals for the unit cube dominoNormals[0] = QCAR::Vec3F(1, 0, 0); dominoNormals[1] = QCAR::Vec3F(0, 1, 0); dominoNormals[2] = QCAR::Vec3F(0, 0, 1); } bool checkIntersection(QCAR::Matrix44F transformA, QCAR::Matrix44F transformB,bool camera) { // Use the separating axis theorem to determine whether or not // two object-oriented bounding boxes are intersecting transformA = SampleMath::Matrix44FTranspose(transformA); transformB = SampleMath::Matrix44FTranspose(transformB); LOG("--Printing tranforms--"); LOG("Ball::"); dumpMVM(&transformA.data[0]); LOG("Court::"); dumpMVM(&transformB.data[0]); QCAR::Vec3F normalA1 = SampleMath::Vec3FTransformNormal(dominoNormals[0], transformA); QCAR::Vec3F normalA2 = SampleMath::Vec3FTransformNormal(dominoNormals[1], transformA); QCAR::Vec3F normalA3 = SampleMath::Vec3FTransformNormal(dominoNormals[2], transformA); QCAR::Vec3F normalB1 = SampleMath::Vec3FTransformNormal(dominoNormals[0], transformB); QCAR::Vec3F normalB2 = SampleMath::Vec3FTransformNormal(dominoNormals[1], transformB); QCAR::Vec3F normalB3 = SampleMath::Vec3FTransformNormal(dominoNormals[2], transformB); QCAR::Vec3F edgeAxisA1B1 = SampleMath::Vec3FCross(normalA1, normalB1); QCAR::Vec3F edgeAxisA1B2 = SampleMath::Vec3FCross(normalA1, normalB2); QCAR::Vec3F edgeAxisA1B3 = SampleMath::Vec3FCross(normalA1, normalB3); QCAR::Vec3F edgeAxisA2B1 = SampleMath::Vec3FCross(normalA2, normalB1); QCAR::Vec3F edgeAxisA2B2 = SampleMath::Vec3FCross(normalA2, normalB2); QCAR::Vec3F edgeAxisA2B3 = SampleMath::Vec3FCross(normalA2, normalB3); QCAR::Vec3F edgeAxisA3B1 = SampleMath::Vec3FCross(normalA3, normalB1); QCAR::Vec3F edgeAxisA3B2 = SampleMath::Vec3FCross(normalA3, normalB2); QCAR::Vec3F edgeAxisA3B3 = SampleMath::Vec3FCross(normalA3, normalB3); for (int i = 0; i < 8; i++) { dominoTransformedVerticesA[i] = SampleMath::Vec3FTransform(ballBaseVertices[i], transformA); if(!camera) dominoTransformedVerticesB[i] = SampleMath::Vec3FTransform(courtBaseVertices[i], transformB); else { dominoTransformedVerticesB[i] = SampleMath::Vec3FTransform(cameraBaseVertices[i], transformB); } } if (isSeparatingAxis(normalA1)) return false; if (isSeparatingAxis(normalA2)) return false; if (isSeparatingAxis(normalA3)) return false; if (isSeparatingAxis(normalB1)) return false; if (isSeparatingAxis(normalB2)) return false; if (isSeparatingAxis(normalB3)) return false; if (isSeparatingAxis(edgeAxisA1B1)) return false; if (isSeparatingAxis(edgeAxisA1B2)) return false; if (isSeparatingAxis(edgeAxisA1B3)) return false; if (isSeparatingAxis(edgeAxisA2B1)) return false; if (isSeparatingAxis(edgeAxisA2B2)) return false; if (isSeparatingAxis(edgeAxisA2B3)) return false; if (isSeparatingAxis(edgeAxisA3B1)) return false; if (isSeparatingAxis(edgeAxisA3B2)) return false; if (isSeparatingAxis(edgeAxisA3B3)) return false; return true; } bool isSeparatingAxis(QCAR::Vec3F axis) { // Determine whether or not the given axis separates // the globally stored transformed vertices of the two bounding boxes float magnitude = axis.data[0] * axis.data[0] + axis.data[1] * axis.data[1] + axis.data[2] * axis.data[2]; if (magnitude < 0.00001) return false; float minA, maxA, minB, maxB; minA = maxA = SampleMath::Vec3FDot(dominoTransformedVerticesA[0], axis); minB = maxB = SampleMath::Vec3FDot(dominoTransformedVerticesB[0], axis); float p; for (int i = 1; i < 8; i++) { p = SampleMath::Vec3FDot(dominoTransformedVerticesA[i], axis); if (p < minA) minA = p; if (p > maxA) maxA = p; p = SampleMath::Vec3FDot(dominoTransformedVerticesB[i], axis); if (p < minB) minB = p; if (p > maxB) maxB = p; } if (maxA < minB) return true; if (minA > maxB) return true; return false; } void detectCollision(){ // Dumping MVM LOG("Detecting Collision::"); if(checkIntersection(ballTransform,courtTransform,false)){ LOG("->Collision betweeb ball and court"); handleCollision(); } if(checkIntersection(ballTransform,cameraTransform,true)){ LOG("->Collision betweeb ball and camera"); handleCollision(); } else { LOG("->safe"); } } void handleCollision(){ // Demo code -- to be deleted collision=true; // simulate ball bounce } // void detectAndHandleCollision(){ // Dumping MVM LOG("Detecting Collision::"); if(checkIntersection(ballTransform,courtTransform,false)){ LOG("->Collision betweeb ball and court"); collision=true; } if(checkIntersection(ballTransform,cameraTransform,true)){ LOG("->Collision betweeb ball and camera"); collision=true; } else { LOG("->safe"); collision=false; } } #ifdef __cplusplus } #endif
[ [ [ 1, 1259 ] ] ]
df791f2267c39e401a8d92ae98a0d88468013e09
1e01b697191a910a872e95ddfce27a91cebc57dd
/GrfInvertArray.h
67de567fbc5ae716e8cd8296f2e7478308f7e3eb
[]
no_license
canercandan/codeworker
7c9871076af481e98be42bf487a9ec1256040d08
a68851958b1beef3d40114fd1ceb655f587c49ad
refs/heads/master
2020-05-31T22:53:56.492569
2011-01-29T19:12:59
2011-01-29T19:12:59
1,306,254
7
5
null
null
null
null
IBM852
C++
false
false
1,562
h
/* "CodeWorker": a scripting language for parsing and generating text. Copyright (C) 1996-1997, 1999-2010 CÚdric Lemaire This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA To contact the author: [email protected] */ #ifndef _GrfInvertArray_h_ #define _GrfInvertArray_h_ #include "GrfCommand.h" namespace CodeWorker { class ExprScriptVariable; class GrfInvertArray : public GrfCommand { private: ExprScriptVariable* _pArray; public: GrfInvertArray() : _pArray(NULL) {} virtual ~GrfInvertArray(); virtual const char* getFunctionName() const { return "invertArray"; } inline void setArray(ExprScriptVariable* pArray) { _pArray = pArray; } virtual void compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const; protected: virtual SEQUENCE_INTERRUPTION_LIST executeInternal(DtaScriptVariable& visibility); }; } #endif
[ "cedric.p.r.lemaire@28b3f5f3-d42e-7560-b87f-5f53cf622bc4" ]
[ [ [ 1, 49 ] ] ]
3ef5520b449fa6d163c3e2082d8af0c02090da7a
155c4955c117f0a37bb9481cd1456b392d0e9a77
/Tessa/TessaInstructions/GetSlotInstruction.cpp
8296c02563abffcff1f9175bec86dcd5a2fc833b
[]
no_license
zwetan/tessa
605720899aa2eb4207632700abe7e2ca157d19e6
940404b580054c47f3ced7cf8995794901cf0aaa
refs/heads/master
2021-01-19T19:54:00.236268
2011-08-31T00:18:24
2011-08-31T00:18:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,609
cpp
#include "TessaInstructionHeader.h" namespace TessaInstructions { GetSlotInstruction::GetSlotInstruction(int32_t slotNumber, int32_t slotOffset, TessaInstruction* receiverInstruction, TessaVM::BasicBlock* insertAtEnd) : SlotAccessInstruction(slotNumber, slotOffset, receiverInstruction, insertAtEnd) { } void GetSlotInstruction::print() { char buffer[128]; VMPI_snprintf(buffer, sizeof(buffer), "%s GetSlot %s.slot %d (Offset %d) (Type %s)", this->getPrintPrefix().c_str(), getReceiverObject()->getOperandString().c_str(), this->getSlotNumber(), this->getSlotOffset(), getType()->toString().data()); printf("%s\n", buffer); } void GetSlotInstruction::visit(TessaVisitorInterface* visitor) { visitor->visit(this); } bool GetSlotInstruction::producesValue() { return true; } GetSlotInstruction* GetSlotInstruction::clone(MMgc::GC* gc, MMgc::GCHashtable* originalToCloneMap, TessaVM::BasicBlock* insertCloneAtEnd) { TessaInstruction* clonedReceiver = (TessaInstruction*) (originalToCloneMap->get(this->getReceiverObject())); TessaAssert(clonedReceiver != NULL); GetSlotInstruction* clonedGetSlot = new (gc) GetSlotInstruction(this->getSlotNumber(), getSlotOffset(), clonedReceiver, insertCloneAtEnd); clonedGetSlot->setType(this->getType()); return clonedGetSlot; } List<TessaValue*, LIST_GCObjects>* GetSlotInstruction::getOperands(MMgc::GC* gc) { List<TessaValue*, LIST_GCObjects>* operandList = new (gc) List<TessaValue*, LIST_GCObjects>(gc); operandList->add(getReceiverObject()); return operandList; } }
[ [ [ 1, 41 ] ] ]
4d2b69810bbd25ab83d3cfeff1e1cd32fb6e7133
fb7d4d40bf4c170328263629acbd0bbc765c34aa
/SpaceBattle/SpaceBattleLib/GeneratedCode/Modele/Interfaces/Joueur.h
264aa3b539fac50bb0c66c7c1a67c4ec0a39a362
[]
no_license
bvannier/SpaceBattle
e146cda9bac1608141ad8377620623514174c0cb
6b3e1a8acc5d765223cc2b135d2b98c8400adf06
refs/heads/master
2020-05-18T03:40:16.782219
2011-11-28T22:49:36
2011-11-28T22:49:36
2,659,535
0
1
null
null
null
null
UTF-8
C++
false
false
1,041
h
//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Changes to this file will be lost if the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ #pragma once #define WANTDLLEXP #ifdef WANTDLLEXP //exportation dll #define DLL __declspec( dllexport ) #define EXTERNC extern "C" #else #define DLL //standard #define EXTERNC #endif namespace ModeleInterfaces { class Joueur { public: virtual void deplacer()=0; virtual void initialiserJoueur()=0; virtual void lancerDe()=0; virtual void tirer(object float angle)=0; virtual void deposerArtefact()=0; }; EXTERNC DLL void JOUEUR_deplacer(Joueur*); EXTERNC DLL void JOUEUR_initialiserJoueur(Joueur*); EXTERNC DLL void JOUEUR_lancerDe(Joueur*); EXTERNC DLL void JOUEUR_tirer(Joueur*, object float angle); EXTERNC DLL void JOUEUR_deposerArtefact(Joueur*); }
[ [ [ 1, 39 ] ] ]
71dab7385d24cad0d829734c01f8dd91e5121f71
b14d5833a79518a40d302e5eb40ed5da193cf1b2
/cpp/extern/xercesc++/2.6.0/src/xercesc/com/xml4comCP.h
7fede28174bd5c719a3f1495a869bbdb94570e3e
[ "Apache-2.0" ]
permissive
andyburke/bitflood
dcb3fb62dad7fa5e20cf9f1d58aaa94be30e82bf
fca6c0b635d07da4e6c7fbfa032921c827a981d6
refs/heads/master
2016-09-10T02:14:35.564530
2011-11-17T09:51:49
2011-11-17T09:51:49
2,794,411
1
0
null
null
null
null
UTF-8
C++
false
false
2,573
h
/* * Copyright 1999-2000,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * $Log: xml4comCP.h,v $ * Revision 1.2 2004/09/08 13:55:36 peiyongz * Apache License Version 2.0 * * Revision 1.1.1.1 2002/02/01 22:21:40 peiyongz * sane_include * * Revision 1.2 2000/03/30 02:00:12 abagchi * Initial checkin of working code with Copyright Notice * */ #ifndef _XML4COMCP_H_ #define _XML4COMCP_H_ template <class T> class CProxyXMLDOMDocumentEvents : public IConnectionPointImpl<T, &DIID_XMLDOMDocumentEvents, CComDynamicUnkArray> { //Warning this class may be recreated by the wizard. public: HRESULT Fire_ondataavailable() { CComVariant varResult; T* pT = static_cast<T*>(this); int nConnectionIndex; int nConnections = m_vec.GetSize(); for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++) { pT->Lock(); CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex); pT->Unlock(); IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p); if (pDispatch != NULL) { VariantClear(&varResult); DISPPARAMS disp = { NULL, NULL, 0, 0 }; pDispatch->Invoke(0xc6, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL); } } return varResult.scode; } HRESULT Fire_onreadystatechange() { CComVariant varResult; T* pT = static_cast<T*>(this); int nConnectionIndex; int nConnections = m_vec.GetSize(); for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++) { pT->Lock(); CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex); pT->Unlock(); IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p); if (pDispatch != NULL) { VariantClear(&varResult); DISPPARAMS disp = { NULL, NULL, 0, 0 }; pDispatch->Invoke(DISPID_READYSTATECHANGE, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL); } } return varResult.scode; } }; #endif
[ [ [ 1, 85 ] ] ]
880c4c9e9bdad6fb8bd81390b120f26b30b64860
81ea71bd0cd9eba88abccfa1b112d7bd7dba661e
/sources/wordgrid/Square.h
75286b0838efe19861117f7213db35823d74597a
[]
no_license
Mokona/La-Grille
83751b5a25a21d3dc71b02f9a36e3038f159ab15
6a1d1d15601e04eed8b62fce287e16be16dd5157
refs/heads/master
2016-08-03T12:42:11.787930
2010-02-12T22:25:09
2010-02-12T22:25:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
922
h
#ifndef WORDGRID_SQUARECONTENT #define WORDGRID_SQUARECONTENT namespace Wordgrid { /** A grid square. * * It can contain the letter, a space (letter not set), * be a black square. * * It can also contain annotations (start of words * for example). * */ class Square { public: Square(); Square(char letter); void SetChar(char letter); char GetChar() const; bool IsCharSet() const; bool IsEmpty() const; bool IsBlack() const; static char BlackSquare(); static char EmptySquare(); private: char m_char; }; bool operator == (const Square & first, const Square & second); bool operator != (const Square & first, const Square & second); } // namespace #endif // guard
[ [ [ 1, 40 ] ] ]
ae1f9c78a5227132514149ea359b37e2930f512d
1c9f99b2b2e3835038aba7ec0abc3a228e24a558
/Projects/elastix/elastix_sources_v4/src/Components/Transforms/SimilarityTransform/itkAdvancedSimilarity3DTransform.h
c6ea273445b0a747a835a2dc4053fa10d1cdaaae
[]
no_license
mijc/Diploma
95fa1b04801ba9afb6493b24b53383d0fbd00b33
bae131ed74f1b344b219c0ffe0fffcd90306aeb8
refs/heads/master
2021-01-18T13:57:42.223466
2011-02-15T14:19:49
2011-02-15T14:19:49
1,369,569
0
0
null
null
null
null
UTF-8
C++
false
false
7,495
h
/*========================================================================= Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkAdvancedSimilarity3DTransform.h,v $ Language: C++ Date: $Date: 2006-08-09 04:35:32 $ Version: $Revision: 1.3 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef __itkAdvancedSimilarity3DTransform_h #define __itkAdvancedSimilarity3DTransform_h #include <iostream> #include "itkAdvancedVersorRigid3DTransform.h" namespace itk { /** \brief AdvancedSimilarity3DTransform of a vector space (e.g. space coordinates) * * This transform applies a rotation, translation and isotropic scaling to the space. * * The parameters for this transform can be set either using individual Set * methods or in serialized form using SetParameters() and SetFixedParameters(). * * The serialization of the optimizable parameters is an array of 7 elements. * The first 3 elements are the components of the versor representation * of 3D rotation. The next 3 parameters defines the translation in each * dimension. The last parameter defines the isotropic scaling. * * The serialization of the fixed parameters is an array of 3 elements defining * the center of rotation. * * \ingroup Transforms * * \sa VersorRigid3DTransform */ template < class TScalarType=double > // Data type for scalars (float or double) class ITK_EXPORT AdvancedSimilarity3DTransform : public AdvancedVersorRigid3DTransform< TScalarType > { public: /** Standard class typedefs. */ typedef AdvancedSimilarity3DTransform Self; typedef AdvancedVersorRigid3DTransform< TScalarType > Superclass; typedef SmartPointer<Self> Pointer; typedef SmartPointer<const Self> ConstPointer; /** New macro for creation of through a Smart Pointer. */ itkNewMacro( Self ); /** Run-time type information (and related methods). */ itkTypeMacro( AdvancedSimilarity3DTransform, AdvancedVersorRigid3DTransform ); /** Dimension of parameters. */ itkStaticConstMacro(SpaceDimension, unsigned int, 3); itkStaticConstMacro(InputSpaceDimension, unsigned int, 3); itkStaticConstMacro(OutputSpaceDimension, unsigned int, 3); itkStaticConstMacro(ParametersDimension, unsigned int, 7); /** Parameters Type */ typedef typename Superclass::ParametersType ParametersType; typedef typename Superclass::JacobianType JacobianType; typedef typename Superclass::ScalarType ScalarType; typedef typename Superclass::InputPointType InputPointType; typedef typename Superclass::OutputPointType OutputPointType; typedef typename Superclass::InputVectorType InputVectorType; typedef typename Superclass::OutputVectorType OutputVectorType; typedef typename Superclass::InputVnlVectorType InputVnlVectorType; typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType; typedef typename Superclass::InputCovariantVectorType InputCovariantVectorType; typedef typename Superclass::OutputCovariantVectorType OutputCovariantVectorType; typedef typename Superclass::MatrixType MatrixType; typedef typename Superclass::InverseMatrixType InverseMatrixType; typedef typename Superclass::CenterType CenterType; typedef typename Superclass::OffsetType OffsetType; typedef typename Superclass::TranslationType TranslationType; /** Versor type. */ typedef typename Superclass::VersorType VersorType; typedef typename Superclass::AxisType AxisType; typedef typename Superclass::AngleType AngleType; typedef TScalarType ScaleType; typedef typename Superclass ::NonZeroJacobianIndicesType NonZeroJacobianIndicesType; typedef typename Superclass::SpatialJacobianType SpatialJacobianType; typedef typename Superclass ::JacobianOfSpatialJacobianType JacobianOfSpatialJacobianType; typedef typename Superclass::SpatialHessianType SpatialHessianType; typedef typename Superclass ::JacobianOfSpatialHessianType JacobianOfSpatialHessianType; typedef typename Superclass::InternalMatrixType InternalMatrixType; /** Directly set the rotation matrix of the transform. * \warning The input matrix must be orthogonal with isotropic scaling * to within a specified tolerance, else an exception is thrown. * * \sa MatrixOffsetTransformBase::SetMatrix() */ virtual void SetMatrix(const MatrixType &matrix); /** Set the transformation from a container of parameters This is typically * used by optimizers. There are 7 parameters. The first three represent the * versor, the next three represent the translation and the last one * represents the scaling factor. */ void SetParameters( const ParametersType & parameters ); virtual const ParametersType& GetParameters(void) const; /** Set/Get the value of the isotropic scaling factor */ void SetScale( ScaleType scale ); itkGetConstReferenceMacro( Scale, ScaleType ); /** This method computes the Jacobian matrix of the transformation. */ virtual void GetJacobian( const InputPointType &, JacobianType &, NonZeroJacobianIndicesType & ) const; protected: AdvancedSimilarity3DTransform(unsigned int outputSpaceDim, unsigned int paramDim); AdvancedSimilarity3DTransform(const MatrixType & matrix, const OutputVectorType & offset); AdvancedSimilarity3DTransform(); ~AdvancedSimilarity3DTransform(){}; void PrintSelf(std::ostream &os, Indent indent) const; /** Recomputes the matrix by calling the Superclass::ComputeMatrix() and then * applying the scale factor. */ void ComputeMatrix(); /** Computes the parameters from an input matrix. */ void ComputeMatrixParameters(); /** Update the m_JacobianOfSpatialJacobian. */ virtual void PrecomputeJacobianOfSpatialJacobian(void); private: AdvancedSimilarity3DTransform(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented ScaleType m_Scale; }; //class AdvancedSimilarity3DTransform } // namespace itk // Define instantiation macro for this template. #define ITK_TEMPLATE_AdvancedSimilarity3DTransform(_, EXPORT, x, y) namespace itk { \ _(1(class EXPORT AdvancedSimilarity3DTransform< ITK_TEMPLATE_1 x >)) \ namespace Templates { typedef AdvancedSimilarity3DTransform< ITK_TEMPLATE_1 x > AdvancedSimilarity3DTransform##y; } \ } #if ITK_TEMPLATE_EXPLICIT # include "Templates/itkAdvancedSimilarity3DTransform+-.h" #endif #if ITK_TEMPLATE_TXX # include "itkAdvancedSimilarity3DTransform.txx" #endif #endif /* __itkAdvancedSimilarity3DTransform_h */
[ [ [ 1, 174 ] ] ]
1c44ef110b06aba04ae504c48fd37efa65d5e947
ff44f2ae11d39c5a3dcc0c76ea8e0c7d2543787e
/seqlib/Seq/Sequence.cpp
87d8e30e91d5b8bf3f6a9843f20e0f8710f2ae75
[]
no_license
pjotrp/biopp
0de35b3a8f1c973c61fb394ae57202ba75a7ac63
5214440cff8ff858704377e7dfed57fc026dfcb2
refs/heads/master
2016-09-11T03:42:33.892136
2009-05-22T10:12:04
2009-05-22T10:12:04
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
7,166
cpp
// // File: Sequence.cpp // Created by: Guillaume Deuchst // Julien Dutheil // Created on: Tue Aug 21 2003 // /* Copyright or © or Copr. CNRS, (November 17, 2004) This software is a computer program whose purpose is to provide classes for sequences analysis. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. */ #include "Sequence.h" // class's header file #include "AlphabetTools.h" #include "StringSequenceTools.h" // From utils: #include <Utils/TextTools.h> using namespace bpp; // From the STL: #include <iostream> using namespace std; const bool Sequence::SENSE = true; const bool Sequence::ANTISENSE = false; /** Constructors: ***********************************************************************/ Sequence::Sequence(const string & name, const string & sequence, const Alphabet * alpha) throw (BadCharException) : SymbolList(alpha), _name(name), _sense(true) { setContent(sequence); } Sequence::Sequence(const string & name, const string & sequence, const Comments comments, const Alphabet * alpha) throw (BadCharException) : SymbolList(alpha), _name(name), _comments(comments), _sense(true) { setContent(sequence); } Sequence::Sequence(const string & name, const vector<string> & sequence, const Alphabet * alpha) throw (BadCharException) : SymbolList(sequence, alpha), _name(name), _sense(true) {} Sequence::Sequence(const string & name, const vector<string> & sequence, const Comments comments, const Alphabet * alpha) throw (BadCharException) : SymbolList(sequence, alpha), _name(name), _comments(comments), _sense(true) {} Sequence::Sequence(const string & name, const vector<int> & sequence, const Alphabet * alpha) throw (BadIntException) : SymbolList(sequence, alpha), _name(name), _sense(true) {} Sequence::Sequence(const string & name, const vector<int> & sequence, const Comments comments, const Alphabet * alpha) throw (BadIntException) : SymbolList(sequence, alpha), _name(name), _comments(comments), _sense(true) {} /** Copy constructors: ******************************************************************/ Sequence::Sequence(const Sequence & s) : SymbolList(s), _name(s.getName()), _comments(s.getComments()), _sense(s.getSense()) { } /** Assignation operator: ***************************************************************/ Sequence & Sequence::operator = (const Sequence & s) { _alphabet = s.getAlphabet(); _content = s.getContent(); _comments = s.getComments(); _sense = s.getSense(); _name = s.getName(); return * this; } /****************************************************************************************/ const string Sequence::getName() const { return _name; } void Sequence::setName(const string & name) { _name = name; } /****************************************************************************************/ const Comments Sequence::getComments() const { return _comments; } void Sequence::setComments(const Comments & comments) { _comments = comments; } /****************************************************************************************/ bool Sequence::getSense() const { return _sense; } void Sequence::setSense(bool sense) { _sense = sense; } /****************************************************************************************/ void Sequence::setContent(const string & sequence) throw (BadCharException) { // Remove blanks in sequence _content = StringSequenceTools::codeSequence(TextTools::removeWhiteSpaces(sequence), _alphabet);//Warning, an exception may be casted here! } /****************************************************************************************/ void Sequence::setToSizeR(unsigned int size) { unsigned int seqSize = _content.size(); // Size verification if (size < seqSize) { _content.resize(size); return; } if (size == seqSize) return; // Add gaps up to specified size while(_content.size() < size) _content.push_back(-1); } /****************************************************************************************/ void Sequence::setToSizeL(unsigned int size) { // Size verification unsigned int seqSize = _content.size(); if (size < seqSize) { //We must truncate sequence from the left. //This is a very unefficient method! _content.erase(_content.begin(), _content.begin() + (seqSize - size)); return; } if (size == seqSize) return; // Add gaps up to specified size _content.insert(_content.begin(), size - seqSize, -1); } /****************************************************************************************/ void Sequence::append(const vector<int> & content) throw (BadIntException) { // Check list for incorrect characters for (unsigned int i = 0; i < content.size(); i++) { if(!_alphabet -> isIntInAlphabet(content[i])) throw BadIntException(content[i], "Sequence::append", _alphabet); } //Sequence is valid: for (unsigned int i = 0; i < content.size(); i++) { _content.push_back(content[i]); } } void Sequence::append(const vector<string> & content) throw (BadCharException) { // Check list for incorrect characters for (unsigned int i = 0; i < content.size(); i++) { if(!_alphabet -> isCharInAlphabet(content[i])) throw BadCharException(content[i], "Sequence::append", _alphabet); } //Sequence is valid: for (unsigned int i = 0; i < content.size(); i++) { _content.push_back(_alphabet -> charToInt(content[i])); } } void Sequence::append(const string & content) throw (BadCharException) { append(StringSequenceTools::codeSequence(content, _alphabet)); } /****************************************************************************************/
[ [ [ 1, 223 ] ] ]
fbac1567ef55df22ba6458705dd8fce80e997e74
ea12fed4c32e9c7992956419eb3e2bace91f063a
/zombie/code/zombie/nluaserver/src/lua/lcode.cc
ca3453bf93895b226269ba9540f15bd8832b8b31
[]
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
18,391
cc
/* ** $Id: lcode.cc,v 1.2 2004/03/26 00:39:30 enlight Exp $ ** Code generator for Lua ** See Copyright Notice in lua.h */ #include <stdlib.h> #define lcode_c #include "lua/lua.h" #include "lua/lcode.h" #include "lua/ldebug.h" #include "lua/ldo.h" #include "lua/llex.h" #include "lua/lmem.h" #include "lua/lobject.h" #include "lua/lopcodes.h" #include "lua/lparser.h" #include "lua/ltable.h" #define hasjumps(e) ((e)->t != (e)->f) void luaK_nil (FuncState *fs, int from, int n) { Instruction *previous; if (fs->pc > fs->lasttarget && /* no jumps to current position? */ GET_OPCODE(*(previous = &fs->f->code[fs->pc-1])) == OP_LOADNIL) { int pfrom = GETARG_A(*previous); int pto = GETARG_B(*previous); if (pfrom <= from && from <= pto+1) { /* can connect both? */ if (from+n-1 > pto) SETARG_B(*previous, from+n-1); return; } } luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */ } int luaK_jump (FuncState *fs) { int jpc = fs->jpc; /* save list of jumps to here */ int j; fs->jpc = NO_JUMP; j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP); luaK_concat(fs, &j, jpc); /* keep them on hold */ return j; } static int luaK_condjump (FuncState *fs, OpCode op, int A, int B, int C) { luaK_codeABC(fs, op, A, B, C); return luaK_jump(fs); } static void luaK_fixjump (FuncState *fs, int pc, int dest) { Instruction *jmp = &fs->f->code[pc]; int offset = dest-(pc+1); lua_assert(dest != NO_JUMP); if (abs(offset) > MAXARG_sBx) luaX_syntaxerror(fs->ls, "control structure too long"); SETARG_sBx(*jmp, offset); } /* ** returns current `pc' and marks it as a jump target (to avoid wrong ** optimizations with consecutive instructions not in the same basic block). */ int luaK_getlabel (FuncState *fs) { fs->lasttarget = fs->pc; return fs->pc; } static int luaK_getjump (FuncState *fs, int pc) { int offset = GETARG_sBx(fs->f->code[pc]); if (offset == NO_JUMP) /* point to itself represents end of list */ return NO_JUMP; /* end of list */ else return (pc+1)+offset; /* turn offset into absolute position */ } static Instruction *getjumpcontrol (FuncState *fs, int pc) { Instruction *pi = &fs->f->code[pc]; if (pc >= 1 && testOpMode(GET_OPCODE(*(pi-1)), OpModeT)) return pi-1; else return pi; } /* ** check whether list has any jump that do not produce a value ** (or produce an inverted value) */ static int need_value (FuncState *fs, int list, int cond) { for (; list != NO_JUMP; list = luaK_getjump(fs, list)) { Instruction i = *getjumpcontrol(fs, list); if (GET_OPCODE(i) != OP_TEST || GETARG_C(i) != cond) return 1; } return 0; /* not found */ } static void patchtestreg (Instruction *i, int reg) { if (reg == NO_REG) reg = GETARG_B(*i); SETARG_A(*i, reg); } static void luaK_patchlistaux (FuncState *fs, int list, int ttarget, int treg, int ftarget, int freg, int dtarget) { while (list != NO_JUMP) { int next = luaK_getjump(fs, list); Instruction *i = getjumpcontrol(fs, list); if (GET_OPCODE(*i) != OP_TEST) { lua_assert(dtarget != NO_JUMP); luaK_fixjump(fs, list, dtarget); /* jump to default target */ } else { if (GETARG_C(*i)) { lua_assert(ttarget != NO_JUMP); patchtestreg(i, treg); luaK_fixjump(fs, list, ttarget); } else { lua_assert(ftarget != NO_JUMP); patchtestreg(i, freg); luaK_fixjump(fs, list, ftarget); } } list = next; } } static void luaK_dischargejpc (FuncState *fs) { luaK_patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc, NO_REG, fs->pc); fs->jpc = NO_JUMP; } void luaK_patchlist (FuncState *fs, int list, int target) { if (target == fs->pc) luaK_patchtohere(fs, list); else { lua_assert(target < fs->pc); luaK_patchlistaux(fs, list, target, NO_REG, target, NO_REG, target); } } void luaK_patchtohere (FuncState *fs, int list) { luaK_getlabel(fs); luaK_concat(fs, &fs->jpc, list); } void luaK_concat (FuncState *fs, int *l1, int l2) { if (l2 == NO_JUMP) return; else if (*l1 == NO_JUMP) *l1 = l2; else { int list = *l1; int next; while ((next = luaK_getjump(fs, list)) != NO_JUMP) /* find last element */ list = next; luaK_fixjump(fs, list, l2); } } void luaK_checkstack (FuncState *fs, int n) { int newstack = fs->freereg + n; if (newstack > fs->f->maxstacksize) { if (newstack >= MAXSTACK) luaX_syntaxerror(fs->ls, "function or expression too complex"); fs->f->maxstacksize = cast(lu_byte, newstack); } } void luaK_reserveregs (FuncState *fs, int n) { luaK_checkstack(fs, n); fs->freereg += n; } static void freereg (FuncState *fs, int reg) { if (reg >= fs->nactvar && reg < MAXSTACK) { fs->freereg--; lua_assert(reg == fs->freereg); } } static void freeexp (FuncState *fs, expdesc *e) { if (e->k == VNONRELOC) freereg(fs, e->info); } static int addk (FuncState *fs, TObject *k, TObject *v) { const TObject *idx = luaH_get(fs->h, k); if (ttisnumber(idx)) { lua_assert(luaO_rawequalObj(&fs->f->k[cast(int, nvalue(idx))], v)); return cast(int, nvalue(idx)); } else { /* constant not found; create a new entry */ Proto *f = fs->f; luaM_growvector(fs->L, f->k, fs->nk, f->sizek, TObject, MAXARG_Bx, "constant table overflow"); setobj2n(&f->k[fs->nk], v); setnvalue(luaH_set(fs->L, fs->h, k), cast(lua_Number, fs->nk)); return fs->nk++; } } int luaK_stringK (FuncState *fs, TString *s) { TObject o; setsvalue(&o, s); return addk(fs, &o, &o); } int luaK_numberK (FuncState *fs, lua_Number r) { TObject o; setnvalue(&o, r); return addk(fs, &o, &o); } static int nil_constant (FuncState *fs) { TObject k, v; setnilvalue(&v); sethvalue(&k, fs->h); /* cannot use nil as key; instead use table itself */ return addk(fs, &k, &v); } void luaK_setcallreturns (FuncState *fs, expdesc *e, int nresults) { if (e->k == VCALL) { /* expression is an open function call? */ SETARG_C(getcode(fs, e), nresults+1); if (nresults == 1) { /* `regular' expression? */ e->k = VNONRELOC; e->info = GETARG_A(getcode(fs, e)); } } } void luaK_dischargevars (FuncState *fs, expdesc *e) { switch (e->k) { case VLOCAL: { e->k = VNONRELOC; break; } case VUPVAL: { e->info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->info, 0); e->k = VRELOCABLE; break; } case VGLOBAL: { e->info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->info); e->k = VRELOCABLE; break; } case VINDEXED: { freereg(fs, e->aux); freereg(fs, e->info); e->info = luaK_codeABC(fs, OP_GETTABLE, 0, e->info, e->aux); e->k = VRELOCABLE; break; } case VCALL: { luaK_setcallreturns(fs, e, 1); break; } default: break; /* there is one value available (somewhere) */ } } static int code_label (FuncState *fs, int A, int b, int jump) { luaK_getlabel(fs); /* those instructions may be jump targets */ return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump); } static void discharge2reg (FuncState *fs, expdesc *e, int reg) { luaK_dischargevars(fs, e); switch (e->k) { case VNIL: { luaK_nil(fs, reg, 1); break; } case VFALSE: case VTRUE: { luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0); break; } case VK: { luaK_codeABx(fs, OP_LOADK, reg, e->info); break; } case VRELOCABLE: { Instruction *pc = &getcode(fs, e); SETARG_A(*pc, reg); break; } case VNONRELOC: { if (reg != e->info) luaK_codeABC(fs, OP_MOVE, reg, e->info, 0); break; } default: { lua_assert(e->k == VVOID || e->k == VJMP); return; /* nothing to do... */ } } e->info = reg; e->k = VNONRELOC; } static void discharge2anyreg (FuncState *fs, expdesc *e) { if (e->k != VNONRELOC) { luaK_reserveregs(fs, 1); discharge2reg(fs, e, fs->freereg-1); } } static void luaK_exp2reg (FuncState *fs, expdesc *e, int reg) { discharge2reg(fs, e, reg); if (e->k == VJMP) luaK_concat(fs, &e->t, e->info); /* put this jump in `t' list */ if (hasjumps(e)) { int final; /* position after whole expression */ int p_f = NO_JUMP; /* position of an eventual LOAD false */ int p_t = NO_JUMP; /* position of an eventual LOAD true */ if (need_value(fs, e->t, 1) || need_value(fs, e->f, 0)) { int fj = NO_JUMP; /* first jump (over LOAD ops.) */ if (e->k != VJMP) fj = luaK_jump(fs); p_f = code_label(fs, reg, 0, 1); p_t = code_label(fs, reg, 1, 0); luaK_patchtohere(fs, fj); } final = luaK_getlabel(fs); luaK_patchlistaux(fs, e->f, p_f, NO_REG, final, reg, p_f); luaK_patchlistaux(fs, e->t, final, reg, p_t, NO_REG, p_t); } e->f = e->t = NO_JUMP; e->info = reg; e->k = VNONRELOC; } void luaK_exp2nextreg (FuncState *fs, expdesc *e) { luaK_dischargevars(fs, e); freeexp(fs, e); luaK_reserveregs(fs, 1); luaK_exp2reg(fs, e, fs->freereg - 1); } int luaK_exp2anyreg (FuncState *fs, expdesc *e) { luaK_dischargevars(fs, e); if (e->k == VNONRELOC) { if (!hasjumps(e)) return e->info; /* exp is already in a register */ if (e->info >= fs->nactvar) { /* reg. is not a local? */ luaK_exp2reg(fs, e, e->info); /* put value on it */ return e->info; } } luaK_exp2nextreg(fs, e); /* default */ return e->info; } void luaK_exp2val (FuncState *fs, expdesc *e) { if (hasjumps(e)) luaK_exp2anyreg(fs, e); else luaK_dischargevars(fs, e); } int luaK_exp2RK (FuncState *fs, expdesc *e) { luaK_exp2val(fs, e); switch (e->k) { case VNIL: { if (fs->nk + MAXSTACK <= MAXARG_C) { /* constant fit in argC? */ e->info = nil_constant(fs); e->k = VK; return e->info + MAXSTACK; } else break; } case VK: { if (e->info + MAXSTACK <= MAXARG_C) /* constant fit in argC? */ return e->info + MAXSTACK; else break; } default: break; } /* not a constant in the right range: put it in a register */ return luaK_exp2anyreg(fs, e); } void luaK_storevar (FuncState *fs, expdesc *var, expdesc *exp) { switch (var->k) { case VLOCAL: { freeexp(fs, exp); luaK_exp2reg(fs, exp, var->info); return; } case VUPVAL: { int e = luaK_exp2anyreg(fs, exp); luaK_codeABC(fs, OP_SETUPVAL, e, var->info, 0); break; } case VGLOBAL: { int e = luaK_exp2anyreg(fs, exp); luaK_codeABx(fs, OP_SETGLOBAL, e, var->info); break; } case VINDEXED: { int e = luaK_exp2RK(fs, exp); luaK_codeABC(fs, OP_SETTABLE, var->info, var->aux, e); break; } default: { lua_assert(0); /* invalid var kind to store */ break; } } freeexp(fs, exp); } void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { int func; luaK_exp2anyreg(fs, e); freeexp(fs, e); func = fs->freereg; luaK_reserveregs(fs, 2); luaK_codeABC(fs, OP_SELF, func, e->info, luaK_exp2RK(fs, key)); freeexp(fs, key); e->info = func; e->k = VNONRELOC; } static void invertjump (FuncState *fs, expdesc *e) { Instruction *pc = getjumpcontrol(fs, e->info); lua_assert(testOpMode(GET_OPCODE(*pc), OpModeT) && GET_OPCODE(*pc) != OP_TEST); SETARG_A(*pc, !(GETARG_A(*pc))); } static int jumponcond (FuncState *fs, expdesc *e, int cond) { if (e->k == VRELOCABLE) { Instruction ie = getcode(fs, e); if (GET_OPCODE(ie) == OP_NOT) { fs->pc--; /* remove previous OP_NOT */ return luaK_condjump(fs, OP_TEST, NO_REG, GETARG_B(ie), !cond); } /* else go through */ } discharge2anyreg(fs, e); freeexp(fs, e); return luaK_condjump(fs, OP_TEST, NO_REG, e->info, cond); } void luaK_goiftrue (FuncState *fs, expdesc *e) { int pc; /* pc of last jump */ luaK_dischargevars(fs, e); switch (e->k) { case VK: case VTRUE: { pc = NO_JUMP; /* always true; do nothing */ break; } case VFALSE: { pc = luaK_jump(fs); /* always jump */ break; } case VJMP: { invertjump(fs, e); pc = e->info; break; } default: { pc = jumponcond(fs, e, 0); break; } } luaK_concat(fs, &e->f, pc); /* insert last jump in `f' list */ } void luaK_goiffalse (FuncState *fs, expdesc *e) { int pc; /* pc of last jump */ luaK_dischargevars(fs, e); switch (e->k) { case VNIL: case VFALSE: { pc = NO_JUMP; /* always false; do nothing */ break; } case VTRUE: { pc = luaK_jump(fs); /* always jump */ break; } case VJMP: { pc = e->info; break; } default: { pc = jumponcond(fs, e, 1); break; } } luaK_concat(fs, &e->t, pc); /* insert last jump in `t' list */ } static void codenot (FuncState *fs, expdesc *e) { luaK_dischargevars(fs, e); switch (e->k) { case VNIL: case VFALSE: { e->k = VTRUE; break; } case VK: case VTRUE: { e->k = VFALSE; break; } case VJMP: { invertjump(fs, e); break; } case VRELOCABLE: case VNONRELOC: { discharge2anyreg(fs, e); freeexp(fs, e); e->info = luaK_codeABC(fs, OP_NOT, 0, e->info, 0); e->k = VRELOCABLE; break; } default: { lua_assert(0); /* cannot happen */ break; } } /* interchange true and false lists */ { int temp = e->f; e->f = e->t; e->t = temp; } } void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { t->aux = luaK_exp2RK(fs, k); t->k = VINDEXED; } void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { if (op == OPR_MINUS) { luaK_exp2val(fs, e); if (e->k == VK && ttisnumber(&fs->f->k[e->info])) e->info = luaK_numberK(fs, -nvalue(&fs->f->k[e->info])); else { luaK_exp2anyreg(fs, e); freeexp(fs, e); e->info = luaK_codeABC(fs, OP_UNM, 0, e->info, 0); e->k = VRELOCABLE; } } else /* op == NOT */ codenot(fs, e); } void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { switch (op) { case OPR_AND: { luaK_goiftrue(fs, v); luaK_patchtohere(fs, v->t); v->t = NO_JUMP; break; } case OPR_OR: { luaK_goiffalse(fs, v); luaK_patchtohere(fs, v->f); v->f = NO_JUMP; break; } case OPR_CONCAT: { luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ break; } default: { luaK_exp2RK(fs, v); break; } } } static void codebinop (FuncState *fs, expdesc *res, BinOpr op, int o1, int o2) { if (op <= OPR_POW) { /* arithmetic operator? */ OpCode opc = cast(OpCode, (op - OPR_ADD) + OP_ADD); /* ORDER OP */ res->info = luaK_codeABC(fs, opc, 0, o1, o2); res->k = VRELOCABLE; } else { /* test operator */ static const OpCode ops[] = {OP_EQ, OP_EQ, OP_LT, OP_LE, OP_LT, OP_LE}; int cond = 1; if (op >= OPR_GT) { /* `>' or `>='? */ int temp; /* exchange args and replace by `<' or `<=' */ temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */ } else if (op == OPR_NE) cond = 0; res->info = luaK_condjump(fs, ops[op - OPR_NE], cond, o1, o2); res->k = VJMP; } } void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) { switch (op) { case OPR_AND: { lua_assert(e1->t == NO_JUMP); /* list must be closed */ luaK_dischargevars(fs, e2); luaK_concat(fs, &e1->f, e2->f); e1->k = e2->k; e1->info = e2->info; e1->aux = e2->aux; e1->t = e2->t; break; } case OPR_OR: { lua_assert(e1->f == NO_JUMP); /* list must be closed */ luaK_dischargevars(fs, e2); luaK_concat(fs, &e1->t, e2->t); e1->k = e2->k; e1->info = e2->info; e1->aux = e2->aux; e1->f = e2->f; break; } case OPR_CONCAT: { luaK_exp2val(fs, e2); if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) { lua_assert(e1->info == GETARG_B(getcode(fs, e2))-1); freeexp(fs, e1); SETARG_B(getcode(fs, e2), e1->info); e1->k = e2->k; e1->info = e2->info; } else { luaK_exp2nextreg(fs, e2); freeexp(fs, e2); freeexp(fs, e1); e1->info = luaK_codeABC(fs, OP_CONCAT, 0, e1->info, e2->info); e1->k = VRELOCABLE; } break; } default: { int o1 = luaK_exp2RK(fs, e1); int o2 = luaK_exp2RK(fs, e2); freeexp(fs, e2); freeexp(fs, e1); codebinop(fs, e1, op, o1, o2); } } } void luaK_fixline (FuncState *fs, int line) { fs->f->lineinfo[fs->pc - 1] = line; } int luaK_code (FuncState *fs, Instruction i, int line) { Proto *f = fs->f; luaK_dischargejpc(fs); /* `pc' will change */ /* put new instruction in code array */ luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction, MAX_INT, "code size overflow"); f->code[fs->pc] = i; /* save corresponding line information */ luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int, MAX_INT, "code size overflow"); f->lineinfo[fs->pc] = line; return fs->pc++; } int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { lua_assert(getOpMode(o) == iABC); return luaK_code(fs, CREATE_ABC(o, a, b, c), fs->ls->lastline); } int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline); }
[ "magarcias@c1fa4281-9647-0410-8f2c-f027dd5e0a91" ]
[ [ [ 1, 714 ] ] ]
86c42864d257be61e48d3ff615d16868c32cb8f0
105cc69f4207a288be06fd7af7633787c3f3efb5
/HovercraftUniverse/CoreEngine/DedicatedServer.cpp
83a171ffc2458866be41cd26e6a49205de78afb7
[]
no_license
allenjacksonmaxplayio/uhasseltaacgua
330a6f2751e1d6675d1cf484ea2db0a923c9cdd0
ad54e9aa3ad841b8fc30682bd281c790a997478d
refs/heads/master
2020-12-24T21:21:28.075897
2010-06-09T18:05:23
2010-06-09T18:05:23
56,725,792
0
0
null
null
null
null
UTF-8
C++
false
false
1,774
cpp
#include "DedicatedServer.h" #include "Exception.h" #include <windows.h> #include "Config.h" namespace HovUni { DedicatedServer::DedicatedServer(const std::string& configINI) { mConfigFilename = configINI; } DedicatedServer::~DedicatedServer() { mConfig->saveFile(); delete mConfig; mConfig = 0; } Config* DedicatedServer::mEngineSettings = 0; Config* DedicatedServer::mConfig = 0; Config* DedicatedServer::getEngineSettings() { if (!mEngineSettings) { mEngineSettings = new Config(); } return mEngineSettings; } Config* DedicatedServer::getConfig() { if (!mConfig) { mConfig = new Config(); } return mConfig; } void DedicatedServer::init() { parseIni(); } void DedicatedServer::parseIni() { TCHAR dirpath[MAX_PATH]=TEXT(""); TCHAR** filepath={NULL}; GetFullPathName(mConfigFilename.c_str(), MAX_PATH, dirpath, filepath); std::string fullConfigPath(dirpath); mConfig = getConfig(); mConfig->loadFile(fullConfigPath); //Get(section, name, defaultValue) std::string mDataPath = mConfig->getValue<std::string>("Paths", "DataPath", "data"); DWORD retval=0; TCHAR buffer[MAX_PATH]=TEXT(""); TCHAR** lppPart={NULL}; GetFullPathName(mDataPath.c_str(),MAX_PATH,buffer,lppPart); std::cout << "Changing Working Dir to " << buffer << std::endl; BOOL success = SetCurrentDirectory(buffer); if (!success) { std::string error = "Could not set working dir (check config file DataPath var)!"; std::cerr << error << std::endl; //TODO Throw Exception } //Parse Engine settings mEngineSettings = getEngineSettings(); mEngineSettings->loadFile(mConfig->getValue<std::string>("Server", "EngineSettings", "engine_settings.cfg")); } }
[ "dirk.delahaye@2d55a33c-0a8f-11df-aac0-2d4c26e34a4c", "berghmans.olivier@2d55a33c-0a8f-11df-aac0-2d4c26e34a4c" ]
[ [ [ 1, 46 ], [ 48, 60 ], [ 62, 63 ] ], [ [ 47, 47 ], [ 61, 61 ] ] ]
1d18f6adea7abd06382bd7976f7084a21f017689
74c8da5b29163992a08a376c7819785998afb588
/NetAnimal/addons/pa/ParticleUniverse/include/ParticleUniverseDynamicAttributeTokens.h
3c3321a7794db40035b1bab29154b30e0845e1ea
[]
no_license
dbabox/aomi
dbfb46c1c9417a8078ec9a516cc9c90fe3773b78
4cffc8e59368e82aed997fe0f4dcbd7df626d1d0
refs/heads/master
2021-01-13T14:05:10.813348
2011-06-07T09:36:41
2011-06-07T09:36:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,785
h
/* ----------------------------------------------------------------------------------------------- This source file is part of the Particle Universe product. Copyright (c) 2010 Henry van Merode Usage of this program is licensed under the terms of the Particle Universe Commercial License. You can find a copy of the Commercial License in the Particle Universe package. ----------------------------------------------------------------------------------------------- */ #ifndef __PU_DYNAMIC_ATTRIBUTE_TOKENS_H__ #define __PU_DYNAMIC_ATTRIBUTE_TOKENS_H__ #include "ParticleUniversePrerequisites.h" #include "ParticleUniverseScriptWriter.h" #include "ParticleUniverseScriptDeserializer.h" #include "ParticleUniverseDynamicAttribute.h" namespace ParticleUniverse { /** The DynamicAttributeTranslator parses 'dynamic attributes' tokens */ class _ParticleUniverseExport DynamicAttributeTranslator : public ScriptTranslator { protected: DynamicAttribute* mDynamicAttribute; public: DynamicAttributeTranslator(void); virtual ~DynamicAttributeTranslator(void){}; virtual void translate(Ogre::ScriptCompiler* compiler, const Ogre::AbstractNodePtr &node); }; //------------------------------------------------------------------------- //------------------------------------------------------------------------- //------------------------------------------------------------------------- /** */ class _ParticleUniverseExport DynamicAttributeWriter : public ScriptWriter { public: DynamicAttributeWriter(void) {}; virtual ~DynamicAttributeWriter(void) {}; /** @see ScriptWriter::write */ virtual void write(ParticleScriptSerializer* serializer, const IElement* element); }; } #endif
[ [ [ 1, 53 ] ] ]
df1f3792bacfec4df2da14ca1f822b226d9f865c
a96b15c6a02225d27ac68a7ed5f8a46bddb67544
/SetGame/GazaFile.cpp
5c4002020d10352208234b43df0f74547a09b4e3
[]
no_license
joelverhagen/Gaza-2D-Game-Engine
0dca1549664ff644f61fe0ca45ea6efcbad54591
a3fe5a93e5d21a93adcbd57c67c888388b402938
refs/heads/master
2020-05-15T05:08:38.412819
2011-04-03T22:22:01
2011-04-03T22:22:01
1,519,417
3
0
null
null
null
null
UTF-8
C++
false
false
1,177
cpp
#include "GazaFile.hpp" namespace Gaza { namespace File { int getFileSize(const std::string &filePath) { std::ifstream inputFile(filePath.c_str(), std::ios::in | std::ios::binary); inputFile.seekg (0, std::ios::end); int length = (int)inputFile.tellg(); inputFile.seekg (0, std::ios::beg); inputFile.close(); return length; } char * getFile(const std::string &filePath, bool nullTerminate) { std::ifstream inputFile(filePath.c_str(), std::ios::in | std::ios::binary); if(!inputFile.is_open()) { return 0; } int length = getFileSize(filePath); char * fileContents; if(nullTerminate) { fileContents = new char[length + 1]; inputFile.read(fileContents, length); fileContents[length] = '\0'; } else { fileContents = new char[length]; inputFile.read(fileContents, length); } inputFile.close(); return fileContents; } bool fileExists(const std::string &filePath) { std::ifstream inputFile(filePath.c_str(), std::ios::in | std::ios::binary); inputFile.close(); return inputFile.good(); } } }
[ [ [ 1, 58 ] ] ]
bf46567ba679e8befca0ea9a079343744f2ae8d5
a31e04e907e1d6a8b24d84274d4dd753b40876d0
/MortScript/FunctionsFileReg.cpp
2a343f9b1ee1e490945b49be1858ae47557c7050
[]
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
25,040
cpp
#ifdef SMARTPHONE #include <windows.h> #include "smartphone/mortafx.h" #else #include "stdafx.h" #endif #include <string.h> //#include "Tlhelp32.h" //#include "resource.h" #include "variables.h" #include "inifile.h" #include "interpreter.h" 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; #include "Helpers.h" #include "FunctionsFileReg.h" #include "Interpreter.h" #include "shlobj.h" CValue FctFileExists( CValueArray &params, int &error, CStr &errorMessage ) { if ( params.GetSize() != 1 ) { errorMessage = InvalidParameterCount + L"'FileExists'"; error = 9; return CValue(); } CValue rc; rc = (long)FileOrDirExists( params[0], 0 ); return rc; } CValue FctDirExists( CValueArray &params, int &error, CStr &errorMessage ) { if ( params.GetSize() != 1 ) { errorMessage = InvalidParameterCount + L"'DirExists'"; error = 9; return CValue(); } CValue rc; rc = (long)FileOrDirExists( params[0], 1 ); return rc; } CValue FctMortScriptVersion( CValueArray &params, int &error, CStr &errorMessage ) { if ( params.GetSize() != 0 ) { errorMessage = InvalidParameterCount + L"'MortScriptVersion'"; error = 9; return CValue(); } CValue rc; rc = VERSION; return rc; } CValue FctFileVersion( CValueArray &params, int &error, CStr &errorMessage ) { if ( params.GetSize() != 1 ) { errorMessage = InvalidParameterCount + L"'FileVersion'"; error = 9; return CValue(); } DWORD size, dummy; size = GetFileVersionInfoSize( (LPTSTR)(LPCTSTR)params[0], &dummy ); if ( size == 0 ) { errorMessage.Format( L"Couldn't get version info for '%s'", (LPCTSTR)params.GetAt(0) ); error = 9; return CValue(); } void *verData = malloc( size ); GetFileVersionInfo( (LPTSTR)(LPCTSTR)params[0], NULL, size, verData ); void *fileInfo; UINT size2; VerQueryValue( verData, L"\\", &fileInfo, &size2 ); VS_FIXEDFILEINFO *ffi = (VS_FIXEDFILEINFO*)fileInfo; DWORD ms = ffi->dwFileVersionMS; DWORD ls = ffi->dwFileVersionLS; CStr ver; ver.Format( L"%d.%d.%d.%d", HIWORD(ms), LOWORD(ms), HIWORD(ls), LOWORD(ls) ); CValue rc; rc = ver; free( verData ); return rc; } CValue FctFileAttribute( CValueArray &params, int &error, CStr &errorMessage ) { if ( params.GetSize() != 2 ) { errorMessage = InvalidParameterCount + L"'FileAttribute'"; error = 9; return CValue(); } DWORD attribs = GetFileAttributes( params.GetAt(0) ); DWORD compAttr = 0; if ( ((CStr)(params.GetAt(1))).CompareNoCase( L"directory" ) == 0 ) compAttr = FILE_ATTRIBUTE_DIRECTORY; if ( ((CStr)(params.GetAt(1))).CompareNoCase( L"hidden" ) == 0 ) compAttr = FILE_ATTRIBUTE_HIDDEN; if ( ((CStr)(params.GetAt(1))).CompareNoCase( L"readonly" ) == 0 ) compAttr = FILE_ATTRIBUTE_READONLY; if ( ((CStr)(params.GetAt(1))).CompareNoCase( L"system" ) == 0 ) compAttr = FILE_ATTRIBUTE_SYSTEM; if ( ((CStr)(params.GetAt(1))).CompareNoCase( L"archive" ) == 0 ) compAttr = FILE_ATTRIBUTE_ARCHIVE; #ifndef DESKTOP if ( ((CStr)(params.GetAt(1))).CompareNoCase( L"romfile" ) == 0 ) compAttr = FILE_ATTRIBUTE_INROM; #endif if ( ((CStr)(params.GetAt(1))).CompareNoCase( L"compressed" ) == 0 ) compAttr = FILE_ATTRIBUTE_COMPRESSED; //#endif if ( compAttr == 0 ) { errorMessage = L"Invalid attribute '" + ((CStr)params.GetAt(1)) + L"' for 'FileAttribute'"; error = 9; return CValue(); } CValue rc; if ( attribs != (DWORD)-1 && (attribs & compAttr) == compAttr ) rc = 1L; else rc = 0L; return rc; } CValue FctFileCreateTime( CValueArray &params, int &error, CStr &errorMessage ) { if ( params.GetSize() != 1 ) { errorMessage = InvalidParameterCount + L"'FileCreateTime'"; error = 9; return CValue(); } HANDLE hFile = CreateFile( params[0], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); CValue time; if ( hFile == INVALID_HANDLE_VALUE ) { time = 0L; return time; } TIME_ZONE_INFORMATION tzi; GetTimeZoneInformation( &tzi ); FILETIME filetime; BOOL rc = GetFileTime( hFile, &filetime, NULL, NULL ); time = (long)(FileTimeToUnixTime( filetime ) - tzi.Bias * 60); CloseHandle( hFile ); return time; } CValue FctFileModifyTime( CValueArray &params, int &error, CStr &errorMessage ) { if ( params.GetSize() != 1 ) { errorMessage = InvalidParameterCount + L"'FileModifyTime'"; error = 9; return CValue(); } HANDLE hFile = CreateFile( params[0], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); CValue time; if ( hFile == INVALID_HANDLE_VALUE ) { time = 0L; return time; } TIME_ZONE_INFORMATION tzi; GetTimeZoneInformation( &tzi ); FILETIME filetime; BOOL rc = GetFileTime( hFile, NULL, NULL, &filetime ); time = (long)(FileTimeToUnixTime( filetime ) - tzi.Bias * 60); CloseHandle( hFile ); return time; } CValue FctFileSize( CValueArray &params, int &error, CStr &errorMessage ) { if ( params.GetSize() != 1 && params.GetSize() != 2 ) { errorMessage = InvalidParameterCount + L"'FileSize'"; error = 9; return CValue(); } HANDLE hFile = CreateFile( params[0], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); CValue sizeVal; if ( hFile == INVALID_HANDLE_VALUE ) { sizeVal = 0L; return sizeVal; } DWORD hi; DWORD size = GetFileSize( hFile, &hi ); CloseHandle( hFile ); if ( params.GetSize() > 1 ) { for( int i = 0; i < (long)params[1]; i++ ) { DWORD hiBits = hi << 22; // 32 Bit - 10 shifted size = size >> 10; size |= hiBits; hi = hi >> 10; } } if ( hi != 0 || (long)size < 0 ) size = 2147483647L; sizeVal = (long)size; return sizeVal; } CValue FctDirContents( CValueArray &params, int &error, CStr &errorMessage ) { if ( params.GetSize() != 1 && params.GetSize() != 2 ) { errorMessage = InvalidParameterCount + L"'DirContents'"; error = 9; return CValue(); } short type = 3; if ( params.GetSize() > 1 ) { type = (short)(long)params[1]; } if ( type < 1 || type > 3 ) type = 3; CValue rc; CMapStrToValue *map = rc.GetMap(); int pos = 1; CStr entry; CStr path = ((CStr)params[0]).Left(((CStr)params[0]).ReverseFind('\\')+1); WIN32_FIND_DATA findFileData; HANDLE ffh = FindFirstFile( params[0], &findFileData ); if ( ffh != INVALID_HANDLE_VALUE ) { do { CStr file = path+findFileData.cFileName; if ( findFileData.cFileName[0] != '.' && ( type == 3 || ( type == 1 && (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0 ) || ( type == 2 && (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0 ) ) ) { entry.Format( L"%d", pos ); map->SetAt( entry, findFileData.cFileName ); pos++; } } while ( FindNextFile( ffh, &findFileData ) == TRUE ); FindClose( ffh ); } return rc; } CValue FctSystemPath( CValueArray &params, int &error, CStr &errorMessage ) { if ( params.GetSize() != 1 ) { errorMessage = InvalidParameterCount + L"'SystemPath'"; error = 9; return CValue(); } CStr path; LPTSTR pathBuffer = path.GetBuffer( MAX_PATH ); if ( ((CStr)params[0]).CompareNoCase( L"ProgramsMenu" ) == 0 ) { SHGetSpecialFolderPath( NULL, pathBuffer, CSIDL_PROGRAMS, FALSE ); } //#if defined( PNA ) || !defined( SMARTPHONE ) else if ( ((CStr)params[0]).CompareNoCase( L"StartMenu" ) == 0 ) { SHGetSpecialFolderPath( NULL, pathBuffer, CSIDL_STARTMENU, FALSE ); } //#endif else if ( ((CStr)params[0]).CompareNoCase( L"Startup" ) == 0 ) { SHGetSpecialFolderPath( NULL, pathBuffer, CSIDL_STARTUP, FALSE ); } else if ( ((CStr)params[0]).CompareNoCase( L"Documents" ) == 0 ) { #ifdef POCKETPC // Works only in WM2003 and later OSVERSIONINFO ver; GetVersionEx( &ver ); if ( ( ver.dwMajorVersion > 4 || (ver.dwMajorVersion == 4 && ver.dwMinorVersion >= 20) ) ) { SHGetDocumentsFolder( L"\\", pathBuffer ); } else { errorMessage = L"GetSystemPath: Document path requires WM2003"; error = 9; return CValue(); } #else SHGetSpecialFolderPath( NULL, pathBuffer, CSIDL_PERSONAL, FALSE ); #endif } else if ( ((CStr)params[0]).CompareNoCase( L"ProgramFiles" ) == 0 ) { // Works only in WM2003 and later #ifndef DESKTOP OSVERSIONINFO ver; GetVersionEx( &ver ); if ( ( ver.dwMajorVersion > 4 || (ver.dwMajorVersion == 4 && ver.dwMinorVersion >= 20) ) ) { SHGetSpecialFolderPath( NULL, pathBuffer, CSIDL_PROGRAM_FILES, FALSE ); } else { errorMessage = L"GetSystemPath: Program files path requires WM2003"; error = 9; return CValue(); } #else if ( SHGetSpecialFolderPath( NULL, pathBuffer, 0x0026, FALSE ) == FALSE ) { errorMessage = L"GetSystemPath: Retrieving program files path not supported by your system"; error = 9; return CValue(); } #endif } else if ( ((CStr)params[0]).CompareNoCase( L"AppData" ) == 0 ) { SHGetSpecialFolderPath( NULL, pathBuffer, CSIDL_APPDATA, FALSE ); } else if ( ((CStr)params[0]).CompareNoCase( L"JScripts" ) == 0 || ((CStr)params[0]).CompareNoCase( L"ScriptPath" ) == 0) { int len = CurrentInterpreter->ScriptFile.ReverseFind('\\'); if ( len == -1 ) len = 0; else wcsncpy( pathBuffer, (LPCTSTR)(CurrentInterpreter->ScriptFile), len ); pathBuffer[len] = '\0'; } else if ( ((CStr)params[0]).CompareNoCase( L"ScriptName" ) == 0 ) { int len = CurrentInterpreter->ScriptFile.ReverseFind('\\'); int dot = CurrentInterpreter->ScriptFile.ReverseFind('.'); wcsncpy( pathBuffer, (LPCTSTR)CurrentInterpreter->ScriptFile+len+1, dot-len-1 ); pathBuffer[dot-len-1] = '\0'; } else if ( ((CStr)params[0]).CompareNoCase( L"ScriptExt" ) == 0 ) { int dot = CurrentInterpreter->ScriptFile.ReverseFind('.'); if ( dot == -1 ) pathBuffer[0] = '\0'; else wcscpy( pathBuffer, (LPCTSTR)CurrentInterpreter->ScriptFile.Mid(dot) ); } else if ( ((CStr)params[0]).CompareNoCase( L"ScriptExe" ) == 0 ) { wcscpy( pathBuffer, (LPCTSTR)AppPath ); } else { errorMessage = L"Invalid path type for SystemPath"; error = 9; return CValue(); } path.ReleaseBuffer(); CValue rc; rc = path; return rc; } CValue FctFreeDiskSpace( CValueArray &params, int &error, CStr &errorMessage ) { if ( params.GetSize() != 1 && params.GetSize() != 2 ) { errorMessage = InvalidParameterCount + L"'FreeDiskSpace'"; error = 9; return CValue(); } ULARGE_INTEGER freeBytesAvailableToCaller; ULARGE_INTEGER totalNumberOfBytes; ULARGE_INTEGER totalNumberOfFreeBytes; BOOL fseRc = GetDiskFreeSpaceEx( (LPCTSTR)params[0] , &freeBytesAvailableToCaller , &totalNumberOfBytes , &totalNumberOfFreeBytes ); if ( fseRc == 0 ) { errorMessage = L"Unable to receive free disk space for " + (CStr)params[0]; error = 9; return CValue(); } if ( params.GetSize() > 1 ) { for( int i = 0; i < (long)params[1]; i++ ) { DWORD hiBits = freeBytesAvailableToCaller.HighPart << 22; // 32 Bit - 10 shifted freeBytesAvailableToCaller.LowPart = freeBytesAvailableToCaller.LowPart >> 10; freeBytesAvailableToCaller.LowPart |= hiBits; freeBytesAvailableToCaller.HighPart = freeBytesAvailableToCaller.HighPart >> 10; } } CValue rc; if ( freeBytesAvailableToCaller.HighPart > 0 || (long)freeBytesAvailableToCaller.LowPart < 0 ) rc = 2147483647L; else rc = (long)freeBytesAvailableToCaller.LowPart; return rc; } CValue FctTotalDiskSpace( CValueArray &params, int &error, CStr &errorMessage ) { if ( params.GetSize() != 1 && params.GetSize() != 2 ) { errorMessage = InvalidParameterCount + L"'TotalDiskSpace'"; error = 9; return CValue(); } ULARGE_INTEGER freeBytesAvailableToCaller; ULARGE_INTEGER totalNumberOfBytes; ULARGE_INTEGER totalNumberOfFreeBytes; BOOL fseRc = GetDiskFreeSpaceEx( (LPCTSTR)params[0] , &freeBytesAvailableToCaller , &totalNumberOfBytes , &totalNumberOfFreeBytes ); if ( fseRc == 0 ) { errorMessage = L"Unable to receive disk space for " + (CStr)params[0]; error = 9; return CValue(); } if ( params.GetSize() > 1 ) { for( int i = 0; i < (long)params[1]; i++ ) { DWORD hiBits = totalNumberOfBytes.HighPart << 22; // 32 Bit - 10 shifted totalNumberOfBytes.LowPart = totalNumberOfBytes.LowPart >> 10; totalNumberOfBytes.LowPart |= hiBits; totalNumberOfBytes.HighPart = totalNumberOfBytes.HighPart >> 10; } } CValue rc; if ( totalNumberOfBytes.HighPart > 0 || (long)totalNumberOfBytes.LowPart < 0 ) rc = 2147483647L; else rc = (long)totalNumberOfBytes.LowPart; return rc; } CValue FctReadFile( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; CStr content; if ( params.GetSize() < 1 && params.GetSize() > 3 ) { errorMessage = InvalidParameterCount + L"'ReadFile'"; error = 9; return CValue(); } int size = -1; if ( params.GetSize() == 2 ) { size = (long)params[1]; } int cp = CP_ACP; if ( params.GetSize() == 3 ) cp = GetCodePage( params.GetAt(2) ); int err; #ifndef PNA if ( ((CStr)params[0]).Left(5) == L"http:" || ((CStr)params[0]).Left(4) == L"ftp:" ) { err = CIniFile::ReadWebFile( params[0], content, size, cp ); } else { #endif err = CIniFile::ReadFile( params[0], content, size, cp ); #ifndef PNA } #endif if ( err != 0 ) { CStr msg; switch( err ) { case -1: errorMessage.Format( L"Couldn't open connection to internet" ); break; case -2: case 404: errorMessage.Format( L"'%s' couldn't be opened", (LPCTSTR)params[0] ); break; case -3: errorMessage.Format( L"'%s' is too big", (LPCTSTR)params[0] ); break; case -4: errorMessage.Format( L"Not enough memory to read file '%s'", (LPCTSTR)params[0] ); break; case -5: errorMessage.Format( L"Error reading '%s'", (LPCTSTR)params[0] ); break; default: errorMessage.Format( L"'%s' couldn't be opened (http error %d)", (LPCTSTR)params[0], err ); } error = 9; return CValue(); } rc = content; return rc; } CValue FctReadLine( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; CStr content; if ( params.GetSize() < 1 && params.GetSize() > 2 ) { errorMessage = InvalidParameterCount + L"'ReadLine'"; error = 9; return CValue(); } int cp = CP_ACP; if ( params.GetSize() == 2 ) cp = GetCodePage( params.GetAt(1) ); CStr fileWithPath; fileWithPath = (CStr)params[0]; if ( CurrentInterpreter != NULL && ( fileWithPath.GetLength() < 2 || ( fileWithPath.GetAt(0) != '\\' && fileWithPath.GetAt(1) != ':' ) ) ) { int len = CurrentInterpreter->ScriptFile.ReverseFind('\\'); if ( len == -1 ) fileWithPath = L"\\" + fileWithPath; else fileWithPath = CurrentInterpreter->ScriptFile.Left( len+1 ) + fileWithPath; } fileWithPath.MakeLower(); CFileInfo *fi; //int remaining;//jwz:: if ( FileHandles.Lookup( fileWithPath, (void*&)fi ) == FALSE ) { HANDLE file = CreateFile( fileWithPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if ( file == INVALID_HANDLE_VALUE ) { errorMessage.Format( L"'%s' couldn't be opened", (LPCTSTR)params[0] ); error = 9; return CValue(); } fi = new CFileInfo( file, cp ); int stat = ::ReadFile( file, (void*)fi->data, 4094, &fi->dataSize, NULL ); if ( stat == 0 ) { errorMessage.Format( L"Error reading '%s'", (LPCTSTR)params[0] ); delete fi; error = 9; return CValue(); } fi->data[fi->dataSize] = '\0'; fi->data[fi->dataSize+1] = '\0'; FileHandles.SetAt( fileWithPath, fi ); if ( fi->dataSize < 4094 ) { CloseHandle( fi->handle ); fi->handle = NULL; fi->eof = TRUE; } // Handle encoding prefixes if ( fi->dataSize >= 3 && memcmp( fi->data, (void*)"\xEF\xBB\xBF", 3 ) == 0 ) { fi->encoding = CP_UTF8_PREFIX; memmove( fi->data, fi->data+3, fi->dataSize-1 ); // -3 bytes for prefix, +2 bytes for \0s fi->dataSize -= 3; } if ( fi->dataSize >= 2 && memcmp( fi->data, (void*)"\xFF\xFE", 2 ) == 0 ) { fi->encoding = CP_UNICODE_PREFIX; memmove( fi->data, fi->data+2, fi->dataSize ); // -2 bytes for prefix, +2 bytes for \0s = no difference fi->dataSize -= 2; } } else { if ( fi->dataSize < 2048 && ! fi->eof ) { int oldSize = fi->dataSize; int stat = ::ReadFile( fi->handle, (void*)(fi->data + oldSize), 4094-oldSize, &fi->dataSize, NULL ); if ( stat == 0 ) { errorMessage.Format( L"Error reading '%s'", (LPCTSTR)params[0] ); delete fi; error = 9; return CValue(); } if ( fi->dataSize < (unsigned long)4094-oldSize ) { CloseHandle( fi->handle ); fi->handle = NULL; fi->eof = TRUE; } fi->dataSize += oldSize; fi->data[fi->dataSize] = '\0'; fi->data[fi->dataSize+1] = '\0'; } } if ( fi->dataSize == 0 ) // Nothing in file or EOF exceeded { delete fi; FileHandles.RemoveKey( fileWithPath ); return rc; } else { if ( fi->encoding == CP_UNICODE || fi->encoding == CP_UNICODE_PREFIX ) { TCHAR *lf = wcschr( (TCHAR*)fi->data, '\n' ); if ( lf == NULL ) // last line? { if ( fi->eof ) { rc = (TCHAR*)fi->data; fi->dataSize = 0; } else { errorMessage.Format( L"Line too long in '%s'", (LPCTSTR)params[0] ); delete fi; error = 9; return CValue(); } } else { *lf = 0; // replace LF with string end if ( lf > (TCHAR*)fi->data && *(lf-1) == '\r' ) // CR before LF? *(lf-1) = 0; // replace CR with string end rc = (TCHAR*)fi->data; fi->dataSize -= (BYTE*)lf - fi->data + 2; memmove( fi->data, lf+1, fi->dataSize+2 ); // +2 bytes for \0s } } else { char *lf = strchr( (char*)fi->data, '\n' ); TCHAR tmp[2048]; if ( lf == NULL ) // last line { if ( fi->eof ) { MultiByteToWideChar( fi->encoding, 0, (char*)fi->data, fi->dataSize, tmp, 2048 ); rc = tmp; fi->dataSize = 0; } else { errorMessage.Format( L"Line too long in '%s'", (LPCTSTR)params[0] ); delete fi; error = 9; return CValue(); } } else { *lf = 0; // replace LF with string end if ( lf > (char*)fi->data && *(lf-1) == '\r' ) // CR before LF? *(lf-1) = 0; // replace CR with string end MultiByteToWideChar( fi->encoding, 0, (char*)fi->data, fi->dataSize, tmp, 2048 ); rc = tmp; fi->dataSize -= (BYTE*)lf - fi->data + 1; memmove( fi->data, lf+1, fi->dataSize+2 ); // +2 bytes for \0s } } } return rc; } CValue FctIniRead( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; if ( params.GetSize() != 3 ) { errorMessage = InvalidParameterCount + L"'IniRead'"; error = 9; return CValue(); } CIniFile ini; if ( ini.Read( params[0] ) ) { rc = ini.GetString( params[1], params[2] ); } return rc; } CValue FctRegRead( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; if ( params.GetSize() != 3 ) { errorMessage = InvalidParameterCount + L"'RegRead'"; error = 9; return CValue(); } HKEY root = GetTopKey( params[0] ); if ( root == NULL ) { errorMessage = L"Invalid main key for 'RegKeyExists'"; error = 9; return CValue(); } BOOL result = FALSE; HKEY key; CStr label; DWORD type = REG_NONE, length; BYTE cont[16384]; if ( RegOpenKeyEx( root, params[1], 0, REG_ACCESS_READ, &key ) == ERROR_SUCCESS ) { length = 16384; if ( RegQueryValueEx( key, params[2], NULL, &type, (BYTE*)cont, &length ) != ERROR_SUCCESS ) { length = 0; type = REG_NONE; } RegCloseKey( key ); } switch ( type ) { case REG_BINARY: { CStr content, byte; for ( DWORD i=0; i < length; i++ ) { byte.Format( L"%02X", cont[i] ); content += byte; } rc = content; } break; case REG_DWORD: rc = (long)*((DWORD*)cont); break; case REG_MULTI_SZ: { CMapStrToValue *map = rc.GetMap(); int arrPos = 1, pos = 0, len; CStr key; while ( TRUE ) { len = wcslen( ((LPCTSTR)cont)+pos ); if ( len > 0 ) { key.Format( L"%d", arrPos ); map->SetAt( key, ((LPCTSTR)cont)+pos ); pos += len+1; arrPos++; } else break; } } break; case REG_SZ: case REG_EXPAND_SZ: rc = (LPCTSTR)cont; break; case REG_NONE: rc.Clear(); break; default: rc = L"Not supported registry type"; } return rc; } CValue FctRegKeyExists( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; rc = 0L; if ( params.GetSize() != 2 ) { errorMessage = InvalidParameterCount + L"'RegKeyExists'"; error = 9; return CValue(); } HKEY root = GetTopKey( params[0] ); if ( root == NULL ) { errorMessage = L"Invalid main key for 'RegKeyExists'"; error = 9; return CValue(); } HKEY key; if ( RegOpenKeyEx( root, params[1], 0, REG_ACCESS_READ, &key ) == ERROR_SUCCESS ) { rc = 1L; RegCloseKey( key ); } return rc; } CValue FctRegValueExists( CValueArray &params, int &error, CStr &errorMessage ) { CValue rc; rc = 0L; if ( params.GetSize() != 3 ) { errorMessage = InvalidParameterCount + L"'RegValueExists'"; error = 9; return CValue(); } HKEY root = GetTopKey( params[0] ); if ( root == NULL ) { errorMessage = L"Invalid main key for 'RegValueExists'"; error = 9; return CValue(); } HKEY key; if ( RegOpenKeyEx( root, params[1], 0, REG_ACCESS_READ, &key ) == ERROR_SUCCESS ) { DWORD type, length; TCHAR cont[MAX_PATH]; length = MAX_PATH; int ret = RegQueryValueEx( key, params[2], NULL, &type, (BYTE*)cont, &length ); if ( ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA ) { rc = 1L; } RegCloseKey( key ); } return rc; }
[ "frezgo@c2805876-21d7-11df-8c35-9da929d3dec4" ]
[ [ [ 1, 938 ] ] ]
98ab1727656db84b2ccf075d4ef85c8096e516c9
12732dc8a5dd518f35c8af3f2a805806f5e91e28
/trunk/Plugin/lexer_configuration.h
9515aae0c08d5965ff8041f0402244c5718aee8a
[]
no_license
BackupTheBerlios/codelite-svn
5acd9ac51fdd0663742f69084fc91a213b24ae5c
c9efd7873960706a8ce23cde31a701520bad8861
refs/heads/master
2020-05-20T13:22:34.635394
2007-08-02T21:35:35
2007-08-02T21:35:35
40,669,327
0
0
null
null
null
null
UTF-8
C++
false
false
2,030
h
#ifndef LEXER_CONFIGURATION_H #define LEXER_CONFIGURATION_H #include "wx/string.h" #include "wx/filename.h" #include "attribute_style.h" #include "wx/xml/xml.h" #include "smart_ptr.h" #ifdef WXMAKINGDLL_LE_SDK # define WXDLLIMPEXP_LE_SDK WXEXPORT #elif defined(WXUSINGDLL_LE_SDK) # define WXDLLIMPEXP_LE_SDK WXIMPORT #else /* not making nor using FNB as DLL */ # define WXDLLIMPEXP_LE_SDK #endif // WXMAKINGDLL_LE_SDK class WXDLLIMPEXP_LE_SDK LexerConf { StylePropertyList m_properties; int m_lexerId; wxString m_name; wxString m_keyWords; wxString m_extension; wxXmlDocument m_doc; wxFileName m_fileName; private: // Parse lexer object from xml node void Parse(wxXmlNode *node); // Return an xml representation from this object wxXmlNode *ToXml() const; public: void Save(); LexerConf(const wxString &fileName); virtual ~LexerConf(); /** * Get the lexer ID, which should be in sync with values of Scintilla * \return */ int GetLexerId() const { return m_lexerId; } /** * Set the lexer ID * \param id */ void SetLexerId(int id) { m_lexerId = id; } /** * Return the lexer description as described in the XML file */ const wxString &GetName() const { return m_name; } /** * Return the lexer keywords * \return */ const wxString &GetKeyWords() const { return m_keyWords; } /** * File patterns that this lexer should apply to */ const wxString &GetFileSpec() const { return m_extension; } /** * Return a list of the lexer properties * \return */ const StylePropertyList &GetProperties() const { return m_properties; } /** * Set the lexer properties * \param &properties */ void SetProperties(StylePropertyList &properties) { m_properties = properties; } /** * Set file spec for the lexer * \param &spec */ void SetFileSpec(const wxString &spec) { m_extension = spec; } }; typedef SmartPtr<LexerConf> LexerConfPtr; #endif // LEXER_CONFIGURATION_H
[ "eranif@b1f272c1-3a1e-0410-8d64-bdc0ffbdec4b" ]
[ [ [ 1, 85 ] ] ]
91548d0df143632391dce1d6b1d7fccf4adf403d
c5aa1bfa6d53976c23fe19ee4af4425bca55ce66
/AccuWeather Widget/mybook.cpp
7b500bf96ef5b0befdf1fbf3b9c24db7dbbf63e8
[]
no_license
davicdsalves/accuweather-widget
926e547eb6ec5f1fe5a6f87db190f3b81eb9a9d1
27d7c8134614e3b6757670ffdb65ca4e10dab43b
refs/heads/master
2016-09-16T01:30:42.820650
2011-06-15T03:07:58
2011-06-15T03:07:58
32,118,207
0
0
null
null
null
null
UTF-8
C++
false
false
2,075
cpp
#include "..\include\Lib_Clara.h" #include "..\include\Dir.h" #include "mybook.h" #include "utils\weather.h" MyBook::MyBook() : awBook(new BOOK) , location(NULL) , dayWeather(NULL), nightWeather(NULL) , weatherToDraw(NULL) , error(false) , hourSeted(-1) , bgCursor(0) , cursorDown(false) , wallpaperType(0) , changeWallpaper(false) { gc = get_DisplayGC(); } void MyBook::donothing() {} BOOK* MyBook::getBook() const { return this->awBook; } bool MyBook::getError() const { return this->error; } u16 MyBook::getFTimer() const { return this->ftimer; } GC* MyBook::getGC() const { return this->gc; } int MyBook::getHourSeted() const { return this->hourSeted; } Weather* MyBook::getWeatherToDraw() const { return this->weatherToDraw; } Weather* MyBook::getDayWeather() const { return this->dayWeather; } Weather* MyBook::getNightWeather() const { return this->nightWeather; } wchar_t* MyBook::getLocation() const { return this->location; } int MyBook::getCursor() const { return this->bgCursor; } void MyBook::addCursor(int i) { this->bgCursor += i; } void MyBook::setCursor(int i) { this->bgCursor = i; } void MyBook::freeWDraw() { delete this->weatherToDraw; this->weatherToDraw = NULL; } void MyBook::setHour(int hour) { this->hourSeted = hour; } void MyBook::setWDraw(int one) { (one == 1) ? weatherToDraw = new Weather(dayWeather) : weatherToDraw = new Weather(nightWeather); } void MyBook::setError(bool error) { this->error = error; } void MyBook::setLocation(wchar_t* location) { this->location = location; } void MyBook::setDayWeather(Weather* day) { this->dayWeather = day; } void MyBook::setNightWeather(Weather* night) { this->nightWeather = night; } void MyBook::freeMyVars() { if (location != NULL) { delete location; location = NULL; } if (dayWeather != NULL) { delete dayWeather; dayWeather = NULL; } if (nightWeather != NULL) { delete nightWeather; nightWeather = NULL; } if (weatherToDraw != NULL) { delete weatherToDraw; weatherToDraw = NULL; } }
[ "[email protected]@4f50446f-c819-f47b-67d6-3fd10766a779" ]
[ [ [ 1, 51 ] ] ]
89ae480dd19ff7c0fce51304727b824b5ff2e928
c1c3866586c56ec921cd8c9a690e88ac471adfc8
/Qt_Practise/WorldEditor/Matrices.cpp
9ccc91e7b14959856039c7c995a40e746eb9b8f1
[]
no_license
rtmpnewbie/lai3d
0802dbb5ebe67be2b28d9e8a4d1cc83b4f36b14f
b44c9edfb81fde2b40e180a651793fec7d0e617d
refs/heads/master
2021-01-10T04:29:07.463289
2011-03-22T17:51:24
2011-03-22T17:51:24
36,842,700
1
0
null
null
null
null
GB18030
C++
false
false
5,402
cpp
#include "Matrices.h" #include <MMSystem.h> LPDIRECT3D9 g_pD3D = NULL; // Used to create the D3DDevice LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; // Our rendering device LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL; // Buffer to hold vertices FLOAT g_fYAngle = 0; //----------------------------------------------------------------------------- // Name: InitD3D() // Desc: Initializes Direct3D //----------------------------------------------------------------------------- HRESULT InitD3D( HWND hWnd ) { // Create the D3D object. if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) ) return E_FAIL; // Set up the structure used to create the D3DDevice D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) ); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; // Create the D3DDevice if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pd3dDevice ) ) ) { return E_FAIL; } // Turn off culling, so we see the front and back of the triangle // 关闭剔除,以便三角形的前后都能被我们看到 g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ); // Turn off D3D lighting, since we are providing our own vertex colors // 关闭D3D光照,因为我们提供我们自己的顶点颜色 g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE ); return S_OK; } //----------------------------------------------------------------------------- // Name: InitGeometry() // Desc: Creates the scene geometry //----------------------------------------------------------------------------- HRESULT InitGeometry() { // Initialize three vertices for rendering a triangle CUSTOMVERTEX g_Vertices[] = { { -1.0f,-1.0f, 0.0f, 0xffff0000, }, { 1.0f,-1.0f, 0.0f, 0xff0000ff, }, { 0.0f, 1.0f, 0.0f, 0xffffffff, }, }; // Create the vertex buffer. if( FAILED( g_pd3dDevice->CreateVertexBuffer( 3*sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL ) ) ) { return E_FAIL; } // Fill the vertex buffer. VOID* pVertices; if( FAILED( g_pVB->Lock( 0, sizeof(g_Vertices), (void**)&pVertices, 0 ) ) ) return E_FAIL; memcpy( pVertices, g_Vertices, sizeof(g_Vertices) ); g_pVB->Unlock(); return S_OK; } VOID SetupMatrices() { // For our world matrix, we will just rotate the object about the y-axis. // 物件只围绕y轴旋转 D3DXMATRIXA16 matWorld; // Set up the rotation matrix to generate 1 full rotation (2*PI radians) every 1000 ms. // 配置旋转矩阵为每1000ms一整圈(2*PI 弧度) // To avoid the loss of precision inherent in very high floating point numbers, // 为了避免高浮点数固有的精度损失, // the system time is modulated by the rotation period before conversion to a radian angle. // 系统时间被旋转周期求模,在它被转化成弧度角前 //UINT iTime = timeGetTime() % 1000; //FLOAT fAngle = iTime * (2.0f * D3DX_PI) / 1000.0f; D3DXMatrixRotationY( &matWorld, g_fYAngle ); g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld ); // Set up our view matrix. // 设置视图矩阵 // A view matrix can be defined given an eye point, // a point to lookat, and a direction for which way is up. Here, we set the // eye five units back along the z-axis and up three units, look at the // origin, and define "up" to be in the y-direction. D3DXVECTOR3 vEyePt( 0.0f, 3.0f,-5.0f ); D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f ); D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f ); D3DXMATRIXA16 matView; D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec ); g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView ); // For the projection matrix, we set up a perspective transform (which // transforms geometry from 3D view space to 2D viewport space, with // a perspective divide making objects smaller in the distance). // 投影矩阵,我们配置一个透视转化(把图形从3D视图空间转化到2D视口空间,透视划分使得远的物件小) // To build a perpsective transform, we need the field of view (1/4 pi is common), // the aspect ratio, and the near and far clipping planes (which define at // what distances geometry should be no longer be rendered). // 构建透视转化,四个参数(1)the field of view (2)the aspect ratio (3)the near clipping plane (4)the far clipping plane D3DXMATRIXA16 matProj; D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f ); g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj ); } VOID Render() { // Clear the backbuffer to a black color g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 ); // Begin the scene if( SUCCEEDED( g_pd3dDevice->BeginScene() ) ) { // Setup the world, view, and projection matrices SetupMatrices(); // Render the vertex buffer contents g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 1 ); // End the scene g_pd3dDevice->EndScene(); } // Present the backbuffer contents to the display g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); }
[ "laiyanlin@27d9c402-1b7e-11de-9433-ad2e3fad96c5" ]
[ [ [ 1, 148 ] ] ]
e0f4862f6ec5ce561d42cf0fb5796d1f7bdb8be2
b7b58c5e83ae0e868414e8a6900b92fcfa87b4b1
/Tools/atlas/Pointer.cpp
5b88ea45e8bd85e53ab6ff12547c59ace7069d26
[]
no_license
dailongao/cheat-fusion
87df8bd58845f30808600b72167ff6c778a36245
ab7cd0fe56df0edabb9064da70b93a2856df7fac
refs/heads/master
2021-01-10T12:42:37.958692
2010-12-31T13:42:51
2010-12-31T13:42:51
51,513,373
0
0
null
null
null
null
UTF-8
C++
false
false
10,904
cpp
#include "stdafx.h" #include <string> #include "Pointer.h" #include "AtlasLogger.h" using namespace std; Pointer::Pointer() { AddressType = LINEAR; HeaderSize = 0; } Pointer::~Pointer() { } bool Pointer::SetAddressType(string& Type) { for(int i = 0; i < AddressTypeCount; i++) { if(Type == AddressTypes[i]) { AddressType = i; return true; } } return false; } bool Pointer::SetAddressType(unsigned int Type) { if(Type < AddressTypeCount) { AddressType = Type; return true; } else return false; } void Pointer::SetHeaderSize(const unsigned int Size) { HeaderSize = Size; } unsigned int Pointer::GetAddress(const unsigned int Address) const { return GetMachineAddress(Address); } unsigned int Pointer::GetMachineAddress(unsigned int Address) const { Address -= HeaderSize; switch(AddressType) { case LINEAR_BIG: case LINEAR: return Address; case LOROM00: return GetLoROMAddress(Address); case LOROM80: return GetLoROMAddress(Address) + 0x800000; case HIROM: return GetHiROMAddress(Address); case GB: return GetGBAddress(Address); case GIZMO: return Address; default: return Address; // Error handling } } unsigned int Pointer::GetLoROMAddress(unsigned int Offset) const { char bankbyte = (char) ((Offset & 0xFF0000) >> 16); unsigned short int Word = (unsigned short int) (Offset & 0xFFFF); unsigned int Address = 0; if(Word >= 0x8000) Address = bankbyte * 0x20000 + 0x10000 + Word; else Address = bankbyte * 0x20000 + Word + 0x8000; return Address; } unsigned int Pointer::GetHiROMAddress(unsigned int Offset) const { unsigned int Address = 0; Address = Offset + 0xC00000; return Address; } unsigned int Pointer::GetGBAddress(unsigned int Offset) const { unsigned int Address = 0; unsigned short int Bank = 0; unsigned short int Word = 0; Bank = Offset / 0x4000; Word = Offset % ((Bank+1) * 0x4000); Address = Bank * 0x10000 + Word; return Address; } unsigned char Pointer::GetUpperByte(const unsigned int ScriptPos) const { return GetAddress(ScriptPos) & 0xFF000000; } // #WBB(param) - Working unsigned char Pointer::GetBankByte(const unsigned int ScriptPos) const { return GetAddress(ScriptPos) & 0xFF0000; } // #WHB(param) - Working unsigned char Pointer::GetHighByte(const unsigned int ScriptPos) const { return GetAddress(ScriptPos) & 0xFF00; } // #WLB(param) - Working unsigned char Pointer::GetLowByte(const unsigned int ScriptPos) const { return GetAddress(ScriptPos) & 0xFF; } // #W16(param) - Working unsigned short Pointer::Get16BitPointer(const unsigned int ScriptPos) const { return GetAddress(ScriptPos) & 0xFFFF; } // #W24(param) - Working unsigned int Pointer::Get24BitPointer(const unsigned int ScriptPos) const { return GetAddress(ScriptPos) & 0xFFFFFF; } // #W32 - Not tested unsigned int Pointer::Get32BitPointer(const unsigned int ScriptPos) const { return GetAddress(ScriptPos); } //--------------------------- Custom Pointer ---------------------------------- // \\ // \\ bool CustomPointer::Init(__int64 Offsetting, unsigned int Size, unsigned int HeaderSize) { this->Offsetting = Offsetting; SetHeaderSize(HeaderSize); switch(Size) { case 8: case 16: case 24: case 32: this->Size = Size; break; default: return false; } return true; } unsigned int CustomPointer::GetSize() { return Size; } unsigned int CustomPointer::GetAddress(const unsigned int Address) const { unsigned int Val; Val = (unsigned int) ((__int64)GetMachineAddress(Address) - Offsetting); if(AddressType==LINEAR_BIG){ switch(Size) { case 8: return Val & 0xFF; case 16: return ((Val & 0xFF00)>>8) + ((Val & 0xFF)<<8); case 24: return ((Val & 0xFF0000)>>16) + (Val & 0xFF00) + ((Val & 0xFF)<<16); case 32: return ((Val & 0xFF000000)>>24) + ((Val & 0xFF0000)>>8) + ((Val & 0xFF00)<<8) + ((Val & 0xFF)<<24); default: Logger.BugReport(__LINE__, __FILE__, "Bad size in CustomPointer::GetAddress"); return -1; } } else{ switch(Size) { case 8: return Val & 0xFF; case 16: return Val & 0xFFFF; case 24: return Val & 0xFFFFFF; case 32: return Val; default: Logger.BugReport(__LINE__, __FILE__, "Bad size in CustomPointer::GetAddress"); return -1; } } } //--------------------------- Embedded Pointer -------------------------------- // \\ // \\ EmbeddedPointer::EmbeddedPointer() { TextPos = -1; PointerPos = -1; Size = 0; } EmbeddedPointer::~EmbeddedPointer() { } /*EmbeddedPointer::EmbeddedPointer(const EmbeddedPointer& rhs) { TextPos = rhs.GetTextPosition(); PointerPos = rhs.GetPointerPosition(); Size = rhs.GetSize(); }*/ /*EmbeddedPointer& EmbeddedPointer::operator=(const EmbeddedPointer& rhs) { if(this != &rhs) { TextPos = rhs.GetTextPosition(); PointerPos = rhs.GetPointerPosition(); Size = rhs.GetSize(); } return *this; }*/ // Return true if pointer is ready to write bool EmbeddedPointer::SetPointerPosition(const unsigned int Address) { PointerPos = Address; if(TextPos != -1) return true; else return false; } bool EmbeddedPointer::SetTextPosition(const unsigned int Address) { TextPos = Address; if(PointerPos != -1) return true; else return false; } void EmbeddedPointer::SetSize(const unsigned int size) { Size = size; } unsigned int EmbeddedPointer::GetSize() const { return Size; } void EmbeddedPointer::SetOffsetting(const __int64 Offsetting) { this->Offsetting = Offsetting; } unsigned int EmbeddedPointer::GetPointer() const { unsigned int Val = (unsigned int)(GetAddress(TextPos) - Offsetting); switch(Size) { case 8: return Val & 0xFF; case 16: return Val & 0xFFFF; case 24: return Val & 0xFFFFFF; case 32: return Val & 0xFFFFFFFF; default: Logger.BugReport(__LINE__, __FILE__, "Bad embedded pointer size %d in EmbeddedPointer::GetTextPosition", Size); return 0; } } unsigned int EmbeddedPointer::GetTextPosition() const { return TextPos; } unsigned int EmbeddedPointer::GetPointerPosition() const { return PointerPos; } //------------------------ Embedded Pointer Handler --------------------------- // \\ // \\ EmbeddedPointerHandler::EmbeddedPointerHandler() { PtrSize = 0; HdrSize = 0; Offsetting = 0; } EmbeddedPointerHandler::~EmbeddedPointerHandler() { } bool EmbeddedPointerHandler::SetType(std::string& AddressString, const __int64 Offsetting, const unsigned int PointerSize) { this->Offsetting = Offsetting; switch(PointerSize) { case 8: case 16: case 24: case 32: PtrSize = PointerSize; break; default: // Bad size return false; } return SetAddressType(AddressString); } void EmbeddedPointerHandler::SetHeaderSize(const unsigned int HeaderSize) { HdrSize = HeaderSize; } unsigned int EmbeddedPointerHandler::GetDefaultSize() { return PtrSize; } unsigned int EmbeddedPointerHandler::GetSize(const unsigned int PointerNum) { // Move iterator to PointerNum position in list if(PtrList.size() + 1 < PointerNum) { ReportBug("Should not reach code in EmbeddedPointerHandler::GetSize"); return -1; } ListEmbPtrIt i = PtrList.begin(); for(unsigned int j = 0; j < PointerNum; j++) i++; //if(i == PtrList.end()) // ReportBug("Error: Should not reach code in EmbeddedPointerHandler::GetSize"); //else return i->GetSize(); } bool EmbeddedPointerHandler::SetTextPosition(const unsigned int PointerNum, const unsigned int TextPos) { if(PtrList.size() < PointerNum + 1) // Add default init'd elements { EmbeddedPointer elem; elem.SetAddressType(AddressType); elem.SetSize(PtrSize); elem.SetHeaderSize (HdrSize); elem.SetOffsetting(Offsetting); PtrList.insert(PtrList.end(), PointerNum + 1 - PtrList.size(), elem); } // Move iterator to PointerNum position in list ListEmbPtrIt i = PtrList.begin(); for(unsigned int j = 0; j < PointerNum; j++) i++; if(i->GetTextPosition() == -1 && i->GetPointerPosition() == -1) { i->SetAddressType(AddressType); i->SetSize(PtrSize); i->SetHeaderSize(HdrSize); i->SetOffsetting(Offsetting); } return i->SetTextPosition(TextPos); } bool EmbeddedPointerHandler::SetPointerPosition(const unsigned int PointerNum, const unsigned int PointerPos) { if(PtrList.size() < PointerNum + 1) // Add default init'd elements { EmbeddedPointer elem; elem.SetAddressType(AddressType); elem.SetSize(PtrSize); elem.SetHeaderSize (HdrSize); elem.SetOffsetting(Offsetting); PtrList.insert(PtrList.end(), PointerNum + 1 - PtrList.size(), elem); } // Move iterator to PointerNum position in list ListEmbPtrIt i = PtrList.begin(); for(unsigned int j = 0; j < PointerNum; j++) i++; if(i->GetTextPosition() == -1 && i->GetPointerPosition() == -1) { i->SetAddressType(AddressType); i->SetSize(PtrSize); i->SetHeaderSize(HdrSize); i->SetOffsetting(Offsetting); } return i->SetPointerPosition(PointerPos); } unsigned int EmbeddedPointerHandler::GetPointerValue(const unsigned int PointerNum) { if(PtrList.size() < PointerNum + 1) return -1; // Move iterator to PointerNum position in list ListEmbPtrIt i = PtrList.begin(); for(unsigned int j = 0; j < PointerNum; j++) i++; return i->GetPointer(); } unsigned int EmbeddedPointerHandler::GetTextPosition(const unsigned int PointerNum) { if(PtrList.size() < PointerNum + 1) return -1; // Move iterator to PointerNum position in list ListEmbPtrIt i = PtrList.begin(); for(unsigned int j = 0; j < PointerNum; j++) i++; return i->GetTextPosition(); } unsigned int EmbeddedPointerHandler::GetPointerPosition(const unsigned int PointerNum) { if(PtrList.size() < PointerNum + 1) return -1; // Move iterator to PointerNum position in list ListEmbPtrIt i = PtrList.begin(); for(unsigned int j = 0; j < PointerNum; j++) i++; return i->GetPointerPosition(); } bool EmbeddedPointerHandler::SetAddressType(std::string& Type) { for(int i = 0; i < AddressTypeCount; i++) { if(Type == AddressTypes[i]) { AddressType = i; return true; } } return false; }
[ "forbbsneo@1e91e87a-c719-11dd-86c2-0f8696b7b6f9" ]
[ [ [ 1, 501 ] ] ]
f0a01ad7888dc3c7daf399138ebac6e049992d2c
50040b270d0548cd42756f75b23be4c1fa5d18a8
/worker.cpp
8bbac24f3b39eb17932b18c46411acbaa98d5da0
[]
no_license
martalex/wxmulticam
77b8d83026569713984f2b07f43ae8c303d83da6
4be99048b037115683850332a52b386d01b54257
refs/heads/master
2022-09-10T19:39:53.999222
2011-12-09T02:06:35
2011-12-09T02:06:35
268,398,740
0
0
null
null
null
null
UTF-8
C++
false
false
4,383
cpp
//////////////////////////////////////////////////////////////////// // Package: worker implementation // File: worker.cpp // Purpose: manage checking, switching tasks // // Based on source code of Larry Lart // //////////////////////////////////////////////////////////////////// #ifdef __GNUG__ #pragma implementation #pragma interface #endif #include "stdwx.h" // system headers #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/timeb.h> #include <sys/types.h> #include <sys/stat.h> // wxwidgets includes //#include "wx/wxprec.h" #include "wx/thread.h" #include <wx/string.h> #include <wx/regex.h> #ifndef WX_PRECOMP #include "wx/wx.h" #endif //precompiled headers #include "wxMulticam.h" #include "gui/frame.h" #include "camera/camera.h" // main header include #include "worker.h" #ifdef _DEBUG #define new DEBUG_NEW #endif //////////////////////////////////////////////////////////////////// // Method: Constructor // Class: CCameraWorker // Purpose: Initialize my worker thread // Input: pointer to reference frame // Output: nothing //////////////////////////////////////////////////////////////////// CCameraWorker::CCameraWorker( CGUIFrame *pFrame, CCamera* pCamera ) : wxThread( wxTHREAD_DETACHED ), m_pFrame( pFrame ), // get frame reference m_pCamera( pCamera ) // get camera reference { // start life m_bLife = 1; m_pMutex = new wxMutex( ); return; } //////////////////////////////////////////////////////////////////// // Method: Destructor // Class: CCameraWorker // Purpose: object destructor // Input: nothing // Output: nothing //////////////////////////////////////////////////////////////////// CCameraWorker::~CCameraWorker( ) { m_pMutex = NULL; m_pCamera = NULL; m_pFrame = NULL; } //////////////////////////////////////////////////////////////////// // Method: On Exit // Class: CCameraWorker // Purpose: do something on exit // Input: nothing // Output: nothing //////////////////////////////////////////////////////////////////// void CCameraWorker::OnExit( ) { // destroy - clean my place delete( m_pMutex ); } //////////////////////////////////////////////////////////////////// // Method: GetTime // Class: CCameraWorker // Purpose: routine to get time accurate - this would be called by // all other components to keep in sync // Input: nothing // Output: number = accurate time count //////////////////////////////////////////////////////////////////// double CCameraWorker::GetTime( ) { // struct timeb timeStamp; // get a time stamp ftime( &timeStamp ); double nTime = (double) timeStamp.time*1000 + timeStamp.millitm; return( nTime ); // i removed this for the moment - this was used to calculate time //based on the cpu tick count //return (double)cvGetTickCount()*1e-3/(m_nCpuFreq+1e-10); } //////////////////////////////////////////////////////////////////// // Method: Entry // Class: CCameraWorker // Purpose: the main executable body of my thread // Input: nothing // Output: void pointer //////////////////////////////////////////////////////////////////// void *CCameraWorker::Entry( ) { int i = 0; m_bLife = 1; m_pCamera->Start( ); //////////////////////////////////////////////////////////////// // Start Life Cycle //////////////////////////////////////////////////////////////// // loop as long as flag m_bLife = 1 while( m_bLife ) { if( TestDestroy( ) == 1 ) break; /////////////////////////////////////////////////////////// // START PROCESING BLOCK // first tell camera object to process one frame - if camera // is running if( m_pCamera->m_isRunning ) { m_pCamera->Run( ); } // the here you can insert your extra bit of processing // .... code // END PROCESSING BLOCK /////////////////////////////////////////////////////////// wxThread::Sleep( 1 ); } if( m_pCamera ) m_pCamera->Stop( ); return NULL; } void CCameraWorker::Stop() { if( m_pCamera ) m_pCamera->PauseResume(); // m_pCamera = NULL; Delete(); }
[ [ [ 1, 53 ], [ 58, 75 ], [ 78, 158 ], [ 161, 163 ] ], [ [ 54, 57 ], [ 76, 77 ], [ 159, 160 ], [ 164, 171 ] ] ]
b6b267f80dfe6cf2227781795e22be516cda0acc
de98f880e307627d5ce93dcad1397bd4813751dd
/3libs/ut/include/OXContextHelpPropertySheet.h
9f3fbbe7c7b17f13efb1b24466033f657f52da83
[]
no_license
weimingtom/sls
7d44391bc0c6ae66f83ddcb6381db9ae97ee0dd8
d0d1de9c05ecf8bb6e4eda8a260c7a2f711615dd
refs/heads/master
2021-01-10T22:20:55.638757
2011-03-19T06:23:49
2011-03-19T06:23:49
44,464,621
2
0
null
null
null
null
WINDOWS-1252
C++
false
false
5,498
h
// ========================================================================== // Class Specification : COXContextHelpPropertySheet // ========================================================================== // Header file : OXContextHelpPropertySheet.h // Version: 9.3 // This software along with its related components, documentation and files ("The Libraries") // is © 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is // governed by a software license agreement ("Agreement"). Copies of the Agreement are // available at The Code Project (www.codeproject.com), as part of the package you downloaded // to obtain this file, or directly from our office. For a copy of the license governing // this software, you may contact us at [email protected], or by calling 416-849-8900. // Properties: // YES Abstract class (does not have any objects) // YES Derived from CPropertySheet // // YES Is a CWnd. // YES Two stage creation (constructor & Create()) // YES Has a message map // YES Needs a resource (template) // // NO Persistent objects (saveable on disk) // NO Uses exceptions // // Description: // This class enables the Propertysheet classes derived from it, to have a small question // mark in the upper right-hand corner of their caption bar. Context sensitive help // on every child control as well as toopltips for every child control are supported. // // Remark: // Prerequisites (necessary conditions): ///////////////////////////////////////////////////////////////////////////// #ifndef __OXCONTEXTHELPPROPSHEET_H__ #define __OXCONTEXTHELPPROPSHEET_H__ #if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000 #include "OXDllExt.h" class COXContextHelpPropertyPage; class OX_CLASS_DECL COXContextHelpPropertySheet : public CPropertySheet { DECLARE_DYNAMIC(COXContextHelpPropertySheet) // Data members ------------------------------------------------------------- public: CToolTipCtrl m_Tooltip; protected: BOOL m_bFirstTime; BOOL m_bTooltipActive; private: // Member functions --------------------------------------------------------- public: COXContextHelpPropertySheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); // --- In : nIDCaption : ID of the caption to be used for the property sheet. // pParentWnd : Points to the parent window of the property sheet. If NULL, // the parent window will be the main window of the application. // iSelectPage : The index of the page that will initially be on top. Default is the first page added to the sheet. // --- Out : // --- Returns : // --- Effect : Constructs the object COXContextHelpPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); // --- In : lpszTemplateName : Points to a string containing the caption to be used for the property sheet. Cannot be NULL. // pParentWnd : Points to the parent window of the property sheet. If NULL, // the parent window will be the main window of the application. // iSelectPage : The index of the page that will initially be on top. Default is the first page added to the sheet. // --- Out : // --- Returns : // --- Effect : Constructs the object void AddPage(COXContextHelpPropertyPage* pPage); // --- In : pPage : Points to the page to be added to the property sheet. Cannot be NULL. // --- Out : // --- Returns : // --- Effect : #ifdef _DEBUG virtual void AssertValid() const; // --- In : // --- Out : // --- Returns : // --- Effect : AssertValid performs a validity check on this object // by checking its internal state. // In the Debug version of the library, AssertValid may assert and // thus terminate the program. virtual void Dump(CDumpContext& dc) const; // --- In : dc : The diagnostic dump context for dumping, usually afxDump. // --- Out : // --- Returns : // --- Effect : Dumps the contents of the object to a CDumpContext object. // It provides diagnostic services for yourself and // other users of your class. // Note The Dump function does not print a newline character // at the end of its output. #endif BOOL SetTooltipActive(BOOL bActive = TRUE); // --- In : // --- Out : // --- Returns : succeeded or not // --- Effect : activates or deactivates the tootips for this property sheet BOOL GetTooltipActive(); // --- In : // --- Out : // --- Returns : Whether tootips are activated for this property sheet or not // --- Effect : virtual ~COXContextHelpPropertySheet(); // --- In : // --- Out : // --- Returns : // --- Effect : Destructor of the object protected: virtual const DWORD* GetHelpIDs() = 0; virtual BOOL AdjustToolTips(); virtual BOOL SetupToolTips(); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(COXContextHelpPropertySheet) public: virtual BOOL PreTranslateMessage(MSG* pMsg); protected: //}}AFX_VIRTUAL protected: // Generated message map functions //{{AFX_MSG(COXContextHelpPropertySheet) afx_msg void OnShowWindow(BOOL bShow, UINT nStatus); //}}AFX_MSG afx_msg LONG OnHelp(UINT wParam, LONG lParam); afx_msg LONG OnHelpContextMenu(UINT wParam, LONG lParam); DECLARE_MESSAGE_MAP() private: }; #endif
[ [ [ 1, 157 ] ] ]
83f676a9d7a9d1a30a0edbe7f513ccf66f227a26
6dac9369d44799e368d866638433fbd17873dcf7
/a.i.wars/src/trunk/GameServer.h
4274bf3acf3e08ca69c0c70f244b0c392262cfb2
[]
no_license
christhomas/fusionengine
286b33f2c6a7df785398ffbe7eea1c367e512b8d
95422685027bb19986ba64c612049faa5899690e
refs/heads/master
2020-04-05T22:52:07.491706
2006-10-24T11:21:28
2006-10-24T11:21:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
909
h
#ifndef _GAMESERVER_H_ #define _GAMESERVER_H_ #include <Fusion.h> class ClientBot; class ServerBot; class GameServer{ private: char *m_aidir; virtual void SetAIDir (char *ai); virtual void Update (void); friend bool Run(void); public: GameServer (char *ai); virtual ~GameServer (); virtual void Initialise (void); virtual void InitCD (void); virtual void ProcessCD (void); virtual bool RegisterBot (int key,ClientBot *client); virtual bool RotateBody (int key,int angle); virtual bool RotateLimb (int key,int angle); virtual bool MoveForward (int key,unsigned int distance); virtual bool MoveBackward (int key,unsigned int distance); virtual bool FireOffence (int key, int power); virtual void Death (ServerBot *sb); virtual char * GetAIDir (void); }; #endif // #ifndef _GAMESERVER_H_
[ "chris_a_thomas@1bf15c89-c11e-0410-aefd-b6ca7aeaabe7" ]
[ [ [ 1, 41 ] ] ]
5589133d14a616acd603846c63f6ae20925be5bc
4978f9f8581ca386791f88b6fa38871f1b4ae30e
/sources/common/util/strlcpya.cc
c97ce58b4445e6d02112af27925e30ef74825054
[ "ISC" ]
permissive
umonkey/librascal
94822e43e03d26bc8c2e8f25b515b8134b9bd5cf
ba462431fc26e82511cacb90d1afcdf7d9148f83
refs/heads/master
2020-11-26T23:18:40.026939
2011-05-12T15:26:03
2011-05-12T15:26:03
1,738,915
0
1
null
null
null
null
UTF-8
C++
false
false
484
cc
// Faerion RunTime Library. // Copyright (c) 2002-2004 [email protected] and others. // $Id$ #ifndef HAVE_strlcpya #include <stdarg.h> #include "string.h" void strlcpya(char *buf, size_t size, ...) { va_list vl; const char *arg; va_start(vl, size); while (size != 0 && (arg = va_arg(vl, const char *)) != 0) { while (size != 0 && *arg != '\0') { *buf++ = *arg++; --size; } } if (size == 0) --buf; *buf = '\0'; va_end(vl); } #endif
[ [ [ 1, 29 ] ] ]
c33ac8981eb931a8499110df1c2bd6e22de13321
9403771fd823bda79027cbe7f06c6449c1a44d32
/matlab/code-others/edgebreaker/EBCompression.cpp
d44828ed433bb5e57ce1d1376f0f230ddddf7d27
[]
no_license
fethallah/geodesics4meshes
32d8cc31378a106281f11ca139be9c1b452ebbfa
5fb5e3fc76bb205b8446dda408b3d1078b37cb96
refs/heads/master
2021-01-10T00:54:36.697357
2010-05-07T11:39:01
2010-05-07T11:39:01
33,808,580
2
1
null
null
null
null
UTF-8
C++
false
false
14,544
cpp
/************************************************************************** * * Any use of this code or of the ideas it embodies should be acknowledged * in writing in all publications describing the resulting product or * research contribution as follows: "This solution is based on the * Edgebreaker compression technique and software developed by Prof. * Rossignac and his colleagues at Georgia Institute of Technology." * * * Software developed by: Alla Safonova at Georgia Tech * Last modified: 05/11/20001 * **************************************************************************/ //Include #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <string.h> /***************************** Types *************************************/ struct Coord3D { float x; float y; float z; }; typedef Coord3D Vertex; typedef Coord3D Vector; #define MAX_SIZE 256 enum MeshType {MANIFOLD, TPATCH}; enum FileFormat {BINARY, ASKII}; void initCompression(int c, MeshType eMeshType); void Compress(int c); void CheckHandle(int c); void EncodeDelta(int c); /***************************** Variables *********************************/ //Input arguments static char sOVTable[MAX_SIZE]; static MeshType eMeshType = MANIFOLD; static FileFormat eFileFormat = ASKII; static int nStartCorner = 0; //File Output static FILE* fclers = NULL; //clers file (See File Formats for detais) static FILE* fvertices = NULL; //vertices (See File Formats for detais) static FILE* fhandles = NULL; //handles pairs (See File Formats for detais) //Variables for storing Input OVTable and geometry static int* O = NULL; //Input Opposite table static int* V = NULL; //Input Vertex indices table static Vertex* G = NULL; //Input Geometry table static Vertex* G_est = NULL; //Input Geometry table //Compression variables static int T = 0; //triangles count static int N = 0; //vertices count static int *M = NULL; //Vetex marking array static int *U = NULL; //Triangles marking array /****************************** Main Block *******************************/ void ClearMemoryAndFiles() { //close files if (fclers != NULL) fclose(fclers); if (fvertices != NULL) fclose(fvertices); if (fhandles != NULL) fclose(fhandles); //disallocate memory if (O != NULL) delete [] O; if (V != NULL) delete [] V; if (G != NULL) delete [] G; if (U != NULL) delete [] U; if (M != NULL) delete [] M; } //Print Error string and exit. void PrintErrorAndQuit(char* sErrorString) { printf(sErrorString); ClearMemoryAndFiles(); exit(0); } void ProcessArguments(int argc, char* argv[]) { if (argc != 5) { printf("Wrong number of agruments.\n\n" "Usage: EBCompression OVTable MeshType FileFormat\n\n"); exit(0); } char sMeshType[MAX_SIZE]; char sFileFormat[MAX_SIZE]; char sStartCorner[MAX_SIZE]; strcpy(sOVTable, argv[1]); strcpy(sMeshType, argv[2]); strcpy(sStartCorner, argv[3]); strcpy(sFileFormat, argv[4]); //get mesh type if (strcmp("MANIFOLD", sMeshType)==0) { eMeshType = MANIFOLD; printf("MeshType - MANIFOLD\n"); } else if (strcmp("TPATCH", sMeshType)==0) { eMeshType = TPATCH; printf("MeshType - TPATCH\n"); } else PrintErrorAndQuit("Not supported mesh type\n"); //get start corner nStartCorner = atoi(sStartCorner); //get output file format if (strcmp("BINARY", sFileFormat)==0) { eFileFormat = BINARY; printf("FileFormat - BINARY\n"); } else if (strcmp("ASKII", sFileFormat)==0) { eFileFormat = ASKII; printf("FileFormat - ASKII\n"); } else PrintErrorAndQuit("Not supported file format\n"); } //Open filr for storing clers, geometry and handles void OpenOutputFiles() { fclers = fopen("clers.txt", "w+t"); if (fclers == NULL) PrintErrorAndQuit("Can not open clers file\n"); fvertices = fopen("vertices.txt", "w+t"); if (fvertices == NULL) PrintErrorAndQuit("Can not open vertices file\n"); fhandles = fopen("handles.txt", "w+t"); if (fhandles == NULL) PrintErrorAndQuit("Can not open handles file\n"); } //Process input file and build Vertex and Triangle Arrays. void ProcessInputFile(char* sFileName) { int i = 0; FILE* pInFile = NULL; //Number of Triangles int nNumOfTriangles; //Number of Vertices int nNumOfVertices; //Open the file. pInFile = fopen(sFileName, "rt"); if (pInFile == NULL) PrintErrorAndQuit("Can not open input file\n"); //Read number of triangles from the file if (fscanf(pInFile, "%d", &nNumOfTriangles) == -1) PrintErrorAndQuit("Error reading file\n"); //Allocate memory for V Table V = new int [nNumOfTriangles*3]; //Allocate memory for O Table O = new int [nNumOfTriangles*3]; //Read VO TAble from the file for (i = 0; i<nNumOfTriangles; i++) { if (fscanf(pInFile, "%d %d", &(V[i*3]), &(O[i*3]))==-1) PrintErrorAndQuit("Error reading file\n"); if (fscanf(pInFile, "%d %d", &(V[i*3+1]), &(O[i*3+1])) == -1) PrintErrorAndQuit("Error reading file\n"); if (fscanf(pInFile, "%d %d", &(V[i*3+2]), &(O[i*3+2])) == -1) PrintErrorAndQuit("Error reading file\n"); } //Read number of vertices from the file if (fscanf(pInFile, "%d", &nNumOfVertices) == -1) PrintErrorAndQuit("Error reading file\n"); //Allocate memory for vertex array G = new Vertex [nNumOfVertices]; G_est = new Vertex [nNumOfVertices]; //Read all vertices from the file for (i = 0; i<nNumOfVertices; i++) { if (fscanf(pInFile, "%f %f %f", &(G[i].x), &(G[i].y), &(G[i].z)) == -1) PrintErrorAndQuit("Error reading file\n"); } //Allocate memory for M and U tables M = new int [nNumOfVertices]; //Table for marking visited vetrices U = new int [nNumOfTriangles]; //Table for marking visited triangles //init tables for marking visited vertices and triangles for (i = 0; i<nNumOfVertices; i++) M[i] = 0; for (i = 0; i<nNumOfTriangles; i++) U[i] = 0; //Close the file. fclose(pInFile); } /* * Usage: EBCompression OVTable MeshType FileFormat * * OVTable: Connectivity and geometry of the mesh in OVTable format * (See File Formats for detais) * MeshType: 2 Mesh types are currently supported - MANIFOLD and TPATCH * MANIFOLD - is a manifold mesh, consistently oriented with no holes. * TPATCH - is a manifold mesh with boundary, consistently oriented. * StartCorner: Is the corner where to start EBCompression. * If MeshType is TPATCH it should be a corner corresponding to * the "dummy" vertex. * If MeshType is MANIFOLD it can be any corner, but since the * triangles incident on StartCorner are not stored it is * advantageous to pass a corner that has maximum number of * triangles incident on it as a StartCorner. * FileFormat: BINARY or ASKII * (See File Formats for detais) * */ int main(int argc, char* argv[]) { //Process arguments ProcessArguments(argc, argv); //Open output files OpenOutputFiles(); //Read OVTableFile ProcessInputFile(sOVTable); //Compress Mesh initCompression(nStartCorner, eMeshType); //disallocate memory ClearMemoryAndFiles(); return 0; } /***************************** EB Helper Functions ***********************/ int NextEdge(int edge) { return (3*(edge / 3) + (edge + 1) % 3); } int PrevEdge(int edge) { return NextEdge(NextEdge(edge)); } int RightTri(int c, int* O_table) { //c.r = c.n.r return O_table[NextEdge(c)]; } int LeftTri(int c, int* O_table) { //c.l = c.n.n.r return O_table[NextEdge(NextEdge(c))]; } int E2T(int edge) { return (edge / 3); } /***************************** EB Compression ****************************/ /* * Arguments: * c - start compression from corner c * MeshType: 2 Mesh types are currently supported - MANIFOLD and TPATCH * MANIFOLD - is a manifold mesh, consistently oriented with no holes. * TPATCH - is a manifold mesh with boundary, consistently oriented. * FileFormat: BINARY or ASKII (See File Formats for detais) * */ void initCompression(int c, MeshType eMeshType) { int i = 0; //init tables for marking visited vertices and triangles //was done in ProcessInputFile function //id of the last triangle compressed so far T = 0; c = PrevEdge(c); //estimate 1st vertex EncodeDelta(NextEdge(c)); //if we do not have a hole mark 1st vertex as visited //in which case estimate function can use it for estimation //if we do have a hole, we do not mark 1st vertex as visited //and it is not used for estimation since it is a dummy vertex if (eMeshType==MANIFOLD) M[V[NextEdge(c)]] = 1; //estimate third vertex and mark it as visited EncodeDelta(c); M[V[c]] = 1; //estimate second vertex and mark it as visited EncodeDelta(PrevEdge(c)); M[V[PrevEdge(c)]] = 1; //paint the triangle U[E2T(c)] = 1; // mark the triangle as visited //traverse triangles incident on the first vertex //we do not want to store clers symbols for them int a = O[c]; //we keep a count of number of triangles incident on the first corner int count = 1; //first traverse 'C' triangles while (a != PrevEdge(O[PrevEdge(c)])) { //increment count for number of triangles incident on the first corner count++; //paint the triangle, increment # of triangles U[E2T(a)] = 1; T++; //estimate next vertex and mark it as visited EncodeDelta(a); M[V[a]] = 1; //continue with the right neighbor a = O[NextEdge(a)]; } //traverse 'R' triangle incident on first vertex U[E2T(a)] = 1; T++; count++; //write mesh type to clers file if (eMeshType == MANIFOLD) { if (eFileFormat == ASKII) fprintf(fclers, "%s\n", "MANIFOLD"); } else if (eMeshType == TPATCH) { if (eFileFormat == ASKII) fprintf(fclers, "%d\n", "TPATCH"); } else PrintErrorAndQuit("Not supported mesh type\n"); //write number of triangles incident on first vertex to clers file if (eFileFormat == ASKII) fprintf(fclers, "%d\n", (int)count); //start connectivity compression Compress(O[PrevEdge(a)]); } void Compress(int c) { //start traversal for triangle tree do { //mark the triangle as visited U[E2T(c)] = 1; T++; //check for handles CheckHandle(c); //test whether tip vertex was visited if (M[V[c]] == 0) { //append encoding of C to clers fprintf(fclers, "%c\n", 'C'); //estimate next vertex and mark it as visited EncodeDelta(c); M[V[c]] = 1; //continue with the right neighbor c = RightTri(c, O); } else //test whether right triangle was visited if (U[E2T(RightTri(c, O))] > 0) { //test whether left triangle was visited if (U[E2T(LeftTri(c, O))] > 0) { //append code for E and pop fprintf(fclers, "%c\n", 'E'); return; } else { //append code for R, move to left triangle fprintf(fclers, "%c\n", 'R'); c = LeftTri(c, O); } } else //test whether left triangle was visited if (U[E2T(LeftTri(c, O))] > 0) { //append code for L, move to right triangle fprintf(fclers, "%c\n", 'L'); c = RightTri(c, O); } else { //store corner number in decompression, to support handles U[E2T(c)] = T*3+2; //append code for S fprintf(fclers, "%c\n", 'S'); //recursive call to visit right branch first Compress(RightTri(c, O)); //move to left triangle c = LeftTri(c, O); //if the triangle to the left was visited, then return if (U[E2T(c)]>0) return; } }while(true); } void CheckHandle(int c) { //check for handles from the right if (U[E2T(O[NextEdge(c)])] >1) { //write opposite corners for handle triangles into file fprintf(fhandles, "%d %d\n", U[E2T(O[NextEdge(c)])], T*3+1); } //check for handles from the left if (U[E2T(O[PrevEdge(c)])] >1) { //write opposite corners for handle triangles into file fprintf(fhandles, "%d %d\n", U[E2T(O[PrevEdge(c)])], T*3+2); } } /******************* Vector Operations for Estimate functions ************/ //Returns v1 - v2 Vector VMinus(Vertex v1, Vertex v2) { Vector tempVector; tempVector.x = v1.x - v2.x; tempVector.y = v1.y - v2.y; tempVector.z = v1.z - v2.z; return tempVector; } //Returns v1 + v2 Vector VPlus(Vertex v1, Vector v2) { Vector tempVector; tempVector.x = v2.x + v1.x; tempVector.y = v2.y + v1.y; tempVector.z = v2.z + v1.z; return tempVector; } //Returns v1*k Vector VMult(Vertex v1, float k) { Vector tempVector; tempVector.x = v1.x*k; tempVector.y = v1.y*k; tempVector.z = v1.z*k; return tempVector; } /***************************** Estimate functions ************************/ /* * This function does not do any prediction, it just writes vertices into array */ void EncodeNoPrediction(int c) { //Store vertex coordinates into file fprintf(fvertices, "%f %f %f\n", G[V[c]].x, G[V[c]].y, G[V[c]].z); } void EncodeWithPrediction(int c) { Vector vPred, delta; Vertex zeroV = {0.0, 0.0, 0.0}; if (M[V[O[c]]] > 0 && M[V[PrevEdge(c)]] > 0) { vPred = VPlus(G_est[V[NextEdge(c)]], G_est[V[PrevEdge(c)]]); vPred = VMinus(vPred, G_est[V[O[c]]]); delta = VMinus(G[V[c]], vPred); //return vPred; } else if (M[V[O[c]]] > 0) { vPred = VMult(G_est[V[NextEdge(c)]], 2); vPred = VMinus(vPred, G_est[V[O[c]]]); delta = VMinus(G[V[c]], vPred); //return vPred; } else if (M[V[NextEdge(c)]] > 0 && M[V[PrevEdge(c)]] > 0) { vPred = VPlus(G_est[V[NextEdge(c)]], G_est[V[PrevEdge(c)]]); vPred = VMult(vPred, 0.5f); delta = VMinus(G[V[c]], vPred); //return vPred; } else if (M[V[NextEdge(c)]] > 0) { vPred = G_est[V[NextEdge(c)]]; delta = VMinus(G[V[c]], vPred); //return vPred; } else if (M[V[PrevEdge(c)]] > 0) { vPred = G_est[V[PrevEdge(c)]]; delta = VMinus(G[V[c]], vPred); //return vPred; } else { vPred = zeroV; delta = VMinus(G[V[c]], vPred); } G_est[V[c]] = VPlus(delta, vPred); fprintf(fvertices, "%f %f %f\n", delta.x, delta.y, delta.z); } void EncodeDelta(int c) { EncodeNoPrediction(c); //EncodeWithPrediction(c); }
[ "gabriel.peyre@a6734f8e-26ab-11df-90c7-81228a7a91d5" ]
[ [ [ 1, 607 ] ] ]
25422b6f68328fe3024037e17b1fc666a775f6ea
ecc97a41ac8c7afecdada60a44fc6394d1081b08
/sourceline.h
1f6bbe8b924746505691b61ad7684620a0c79556
[]
no_license
ragnarls08/Compilers1
22036be290ee7319e866454a7ab1846af510e121
acec6df9d5c286844ed698aafcedbefecf4a4769
refs/heads/master
2016-09-09T22:58:46.708592
2011-03-04T21:16:47
2011-03-04T21:16:47
1,288,450
0
0
null
null
null
null
UTF-8
C++
false
false
1,500
h
// ************************************************************** // * * // * S O U R C E L I N E (Header) * // * * // * CLASSES: SourceLine * // * * // ************************************************************** #ifndef sourceline_h #define sourceline_h #define MAX_ERRORS_IN_LINE 10 class LineError { private: /* A class consisting of */ int m_column; /* the column number of the error */ char* m_errorMsg; /* and the associated error message */ public: int getColumn(); char* getError(); void set(int col, char* err); /* Set column number and error */ }; class SourceLine { private: char* m_line; // Characters in current line int m_firstLexemeColumn; // First column number of current lexeme int m_lastLexemeColumn; // Last column number of current lexeme int m_lineNo; // Line number in original source int m_lineErrors; // Number of errors in current line int m_maxLen; // Maximum length of line LineError m_errors[MAX_ERRORS_IN_LINE]; void clearLine(); // clears the line void printErrors(); // prints error messages in current line public: SourceLine(int size); void buildLine(const char* str);// builds the line void printLine(); // prints the line and error messages in line if any void setError(char* msg); // sets an error message void newLine(); // announces a new line in the input }; #endif
[ [ [ 1, 50 ] ] ]
7b8f7b633fb84d76213085d61e906030d0678fc5
c8ab6c440f0e70e848c5f69ccbbfd9fe2913fbad
/bowling/Sound.h
c688555728a8023177e14ed533468b22296895e3
[]
no_license
alyshamsy/power-bowling
2b6426cfd4feb355928de95f1840bd39eb88de0b
dd650b2a8e146f6cdf7b6ce703801b96360a90fe
refs/heads/master
2020-12-24T16:50:09.092801
2011-05-12T14:37:15
2011-05-12T14:37:15
32,115,585
0
0
null
null
null
null
UTF-8
C++
false
false
949
h
#ifndef SOUND_H #define SOUND_H #include<fstream> #include <string> #include <openAL/al.h> #include <openAL/alut.h> using namespace std; #define NUMBER_OF_SOURCES 5 static class Sound { public: Sound(); ~Sound(); int initialize(); void playSound(string file_name); void pauseSound(string file_name); void stopSound(string file_name); void stopAllSounds(); void pauseAllSounds(); void playAllSounds(); void increaseSoundVolume(string sound_name, float volume); void setSoundSourcePosition(float x, float y, float z); void setSoundSourceVelocity(float x, float y, float z); private: int loadSounds(); string fileNames[NUMBER_OF_SOURCES]; ALuint buffer[NUMBER_OF_SOURCES]; ALuint source[NUMBER_OF_SOURCES]; bool soundPlayed[NUMBER_OF_SOURCES]; ALfloat listenerPos[3]; ALfloat listenerVel[3]; ALfloat listenerOri[6]; ALsizei size, freq; ALenum format; ALvoid *data; }; #endif
[ "aly.shamsy@71b57f4a-8c0b-a9ba-d1fe-6729e2c2215a" ]
[ [ [ 1, 46 ] ] ]
920b072f88532ae9a951104807f5de5633d4d6a0
f9a3be79094efa8cfd502678c50a27335bdcc44e
/IUnit.h
5eef508c41b71d4383a24d1a3cc2d9a73f5bb4bf
[]
no_license
k06a/reghope
8946d3a543b910bc48ed82f611168af38f817f79
def9be4ac3873d900bc7af0ddd428ed948018ac1
refs/heads/master
2021-01-19T10:13:55.067659
2010-05-12T18:49:24
2010-05-12T18:49:24
32,887,567
1
0
null
null
null
null
UTF-8
C++
false
false
2,445
h
#ifndef IUNIT_H #define IUNIT_H // Regular Expression Rules: // //---------------------------------------------------------------- // CharConst = ( "\\" | "\." | "\-" | "\?" | "\+" | "\*" | // "\(" | "\)" | "\[" | "\]" | "\{" | "\}" | // "\d{1,3}" | "\xHH" | "\oOOO" | "\bBBBBBBBB" | *) //---------------------------------------------------------------- // CharRange = ("." | (CharConst "-" CharConst)) //---------------------------------------------------------------- // CharSet = "[" ("^")? (CharRange | CharConst)+ "]" //---------------------------------------------------------------- // //---------------------------------------------------------------- // RepeatRange = ("?" | "+" | "*" | ("{" int ("," int?)? "}")) //---------------------------------------------------------------- // //---------------------------------------------------------------- // RegularUnit = (CharSet | CharConst) (RepeatRange)? //---------------------------------------------------------------- // RegularVector = "(" (RegularUnit | RegularVector)+ ")" (RepeatRange)? //---------------------------------------------------------------- // RegularExpression = (RegularVector | RegularUnit)+ //---------------------------------------------------------------- // #include "RegException.h" class QString; namespace RegHope { template<typename T> class IUnit { protected: T firstValue; T currentValue; T lastValue; int minLength; int maxLength; public: virtual ~IUnit() {} // Try to create reg.exp. unit from \str on position \pos. // Returns new object or null, and moves \pos after reg.exp. static IUnit * tryRecognize(QString str, int & pos); // Min and Max bounds T getFirstValue() { return firstValue; } T getCurrentValue() { return currentValue; } T getLastValue() { return lastValue; } int getMinLength() { return minLength; } // Iterative make virtual T makeFirstValue() = 0; virtual T makeNextValue() = 0; virtual bool atEnd() = 0; virtual T getRandValue() = 0; virtual QString print() = 0; virtual quint64 count() = 0; virtual void setMaxLength(int length) {} }; } #endif // IUNIT_H
[ "k06aaa@e37ad884-f61b-dc99-8067-ed2e9741f7e2" ]
[ [ [ 1, 85 ] ] ]
af038624d043c1af15f190d1e4b6b61a8043fcba
74d531abb9fda8dc621c5d8376eb10ec4ef19568
/src/level.cpp
f2de83c2fd4734ac297f5b2bf9c264b6d740d494
[]
no_license
aljosaosep/xsoko
e207d6ec8de3196029e569e7765424a399a50f04
c52440ecee65dc2f3f38d996936e65b3ff3b8b5e
refs/heads/master
2021-01-10T14:27:04.644013
2009-09-02T20:39:53
2009-09-02T20:39:53
49,592,571
0
0
null
null
null
null
UTF-8
C++
false
false
58,318
cpp
/* * codename: xSoko * Copyright (C) Aljosa Osep, Jernej Skrabec, Jernej Halozan 2008 <[email protected], [email protected], [email protected]> * * xSoko project 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. * * xSoko project 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/>. */ #ifdef _WINDOWS #define WIN32_LEAN_AND_MEAN #include <windows.h> #endif #include <GL/gl.h> /* * Codename: xSoko * File: level.h * * Summary: * Includes level class implementation, abstratct grid element imp., and * several others level struct classes implementation * * Author: Aljosa Osep 2008 * Changes: * Aljosa 2008 */ #include "object.h" #include <typeinfo> #include <vector> #include <string> #include <iostream> #include <fstream> #include <iomanip> #include <cstdlib> #include "level.h" #include "renderer/particle.h" #include "CommonStructures.h" using namespace std; using namespace PacGame::GameClasses::GameObjects; namespace PacGame { namespace GameClasses { /***************************************** PLevel constructors *****************************************/ PLevel::PLevel(string filename) : filename(filename), width(0), height(0), player(NULL), gameCore(new PCore), resourceHandle(gameCore->getResources()), endgameFlag(false), fnt(new Font("font")) { fnt->setColor(255,255,0); fnt->setSize(15); } /***************************************** PLevel methods *****************************************/ /***************************************************************** * Function reads two-digit number from stream pointer current * position and skips one character, it is suitable for our * level format only. *****************************************************************/ inline int PLevel::returnNumberFromFile(ifstream &file) { char buff[3]; // char buffer for our number, before it is being parsed into integer char c; // strage for single character file.get(c); // we read first digit if(!(c >= '0' && c <= '9')) // if it isn't a digit, we return an error return -1; else buff[0] = c; // otherwise, we store it into buffer file.get(c); // we read next character if(c >= '0' && c <= '9') // if it is a digit ... { buff[1] = c; // we also store it into buffer buff[2] = '\0'; // and then we close string, because we need two-digit numbers only file.get(); // we skip one character(space) } else // if second character isn't digit buff[1] = '\0'; // terminate string return atoi(buff); // return number read from file, integer } /***************************************************************** * Function validates level format with checking + sign * position. *****************************************************************/ inline bool PLevel::checkPosition(ifstream &file) { char c; // single character buffer file.get(c); // read + sign if(c!='+') // checks if our position is valid { Messages::errorMessage("Invalid level data."); return false; } file.get(); // skip newline return true; // position is ok } /***************************************************************** * Function loops through level and finds teleport with * given id. It returns pointer to that teleport. *****************************************************************/ inline PTeleport *PLevel::returnTeleport(int id) { for(unsigned i=0; i<teleports.size(); i++) // loops thorough vector if(teleports[i]->getId() == id) // if teleport's id matches id we're lookin' for return teleports[i]; // then return it's address return NULL; // otherwise return NULL } /***************************************************************** * Function attaches object to another element in matrix * releases node from original element in matrix * and changes indexes *****************************************************************/ inline void PLevel::reattachNode(int i, int j, int i2, int j2, PLevelObject *obj) { data[i2][j2]->attachToRoot(data[i][j]->returnFirstChild()); data[i][j]->unlinkFirstChild(); if(data[i][j]->getId()==BRIDGE) { if(obj->getId() == PLAYER) { if(data[i][j]->isActiveBomb()){ for(unsigned int k=0;k<bombs.size();k++) if(bombs[k]->i == i && bombs[k]->j == j){ delete bombs[k]; bombs.erase(bombs.begin()+k); } } delete data[i][j]; data[i][j] = new PVoid; } } obj->setIndex(i2, j2); } /***************************************************************** * Function checks in player has moved all cubes to their * spaces *****************************************************************/ inline bool PLevel::isLevelDone() { for(unsigned i=0; i<this->holds.size(); i++) // we loop thorough all holders in level { if(this->holds[i]->returnFirstChild()==NULL) // if hold has no child return false; // level cant be done! else if(((dynamic_cast<PLevelObject*>(this->holds[i]->returnFirstChild()))->getId() & CUBE) == 0) return false; // on this holder there is no valid cubes (valid cubes have the CUBE bits set } return true; // otherwise, player won :) } /****************************************************************** * setButtonFlag * resetButtonFlag * * The set function sets the button flag and reset releases it. * This way we can remember whih buttons are down and which up. ******************************************************************/ void PLevel::setButtonFlag(int flag) { button_flags = flag | button_flags; if((button_flags ^ flag) == 0) // the status of button_flags before adding this flag { switch(flag) { case KB_UP: this->moveObject(Aliases::up, this->getPlayerHandle()); break; case KB_LEFT: this->moveObject(Aliases::left, this->getPlayerHandle()); break; case KB_DOWN: this->moveObject(Aliases::down, this->getPlayerHandle()); break; case KB_RIGHT: this->moveObject(Aliases::right, this->getPlayerHandle()); break; } } } void PLevel::resetButtonFlag(int flag) { button_flags = button_flags & (!flag); } // gameplay related /***************************************************************** * moveObject * Checks object, his current position and his * destination, to try to move it. * A successful move return true, otherwise it returns false. *****************************************************************/ bool PLevel::moveObject(PDirection dir, PLevelObject *obj) { int toI, toJ, dirFacing; // first the object itself must be movable if(obj->isPlayerMovePossible(dir) == 0) { return false; } // cant move in a direction the floor does not allow short floor_id = data[obj->getI()][obj->getJ()]->getId(); // check if its a one way floor if((floor_id == 5) || (floor_id == 6) || (floor_id == 7) || (floor_id == 8)) { // check if the direction doesn't match if(static_cast<POnewayFloor*>(data[obj->getI()][obj->getJ()])->getDirection() != dir ) return false; } switch(dir) { //set destination and direction case Aliases::left: toI = obj->getI(); toJ = obj->getJ()-1; dirFacing = PL_OBJECT_FACE_LEFT; break; case Aliases::right: toI = obj->getI(); toJ = obj->getJ()+1; dirFacing = PL_OBJECT_FACE_RIGHT; break; case Aliases::up: toI = obj->getI()-1; toJ = obj->getJ(); dirFacing = PL_OBJECT_FACE_UP; break; case Aliases::down: toI = obj->getI()+1; toJ = obj->getJ(); dirFacing = PL_OBJECT_FACE_DOWN; break; } // the object can be moved in the wanted direction if(checkMoveTo(toI, toJ, obj, dir)) { obj->moveObject(dirFacing | PL_OBJECT_MOVE); reattachNode(obj->getI(), obj->getJ(), toI, toJ, obj); if(obj->getId() == PLAYER) moves++; return true; }else { // the object can't be moved, it will just turn in the wanted direction obj->moveObject(dirFacing); return false; } } /*********************************************** * chechMoveTo * Checks the destination of an object. * Tries to clear the path by moving * cubes. * Returns true if its free, false if there is something * in the way. * **********************************************/ bool PLevel::checkMoveTo(int toI, int toJ,PLevelObject* obj, PDirection dir) { // check if the move is within level bounds if((unsigned)toI > (this->width-1)|| toI<0 || (unsigned)toJ > (this->height-1) || toJ<0) { Messages::errorIndexOutOfRange(); return false; } short is_move_possible = data[toI][toJ]->isPlayerMovePossible(dir); // if the default PLevelObject method is used, then it is a problem if(is_move_possible == -1) { cout<<"!!! default isPlayerMovePossible used !!!"<<endl; return false; } // if there is no way we could move there if(is_move_possible == 0) return false; // if the space is empty, move freely if(is_move_possible & 1) return true; // we have teleport, object move, and pick up left // we can have all three or just one of them // if one succeeds, but then next fails, the one that succeeded // needs to be undone // we stat with move and pick up, since these are the easyest to undo // teleport is left for last, so we never need to undo it PLevelObject* moved_object = NULL; // first an object must be moved if(is_move_possible & 2) { // only player is capable of moving other objects if(obj->getId() == PLAYER) { moved_object = (PLevelObject*)data[toI][toJ]->returnFirstChild(); // if we can't move the object, we can stop right here if( !moveObject(dir, moved_object) ) return false; }else return false; } bool picked_up = false; // we have a bomb, or other pickup object if(is_move_possible & 4) { // only player can pick up objects if(obj->getId() == PLAYER) { picked_up = true; data[toI][toJ]->releaseFirstChildObject(); this->player->incBombs(); // increase bombs }else return false; // no need to undo any moving, if we couldn't pick it up, we couldn't have moved it either } // its a teleport if(is_move_possible & 8) { // we get the destination coordinates int it = (static_cast<PTeleport*>(data[toI][toJ]))->getChildTeleport()->getI(), jt = (static_cast<PTeleport*>(data[toI][toJ]))->getChildTeleport()->getJ(); // the object at the other side PLevelObject* otherObject = static_cast<PLevelObject*>(data[it][jt]->returnFirstChild()); // no object, can teleport safely if(otherObject == NULL) { return true; }else // we have to try and move the object on the other side in the appropriate direction if(obj->getId() == PLAYER) // only player can move objects { if(moveObject(dir,otherObject)) { return true; } // UNDO // If the player couldn't have moved the object on the other side of the teleport, // than any moving from before needs to be undone if(moved_object != NULL) { reattachNode(moved_object->getI(), moved_object->getJ(), toI, toJ, moved_object); } } return false; } return true; } /*************************************** * activateFloor * The function activates special * floors like teleport or cube holders. * *************************************/ void PLevel::activateFloor(int i, int j) { short floor_id = data[i][j]->getId(); // do we have a teleport to activate if(floor_id >= 9) { int cameraAdjustX, cameraAdjustY; // we get the destination teleport, and the object to teleport PTeleport* destination = static_cast<PTeleport*>(data[i][j])->getChildTeleport(); PLevelObject* object = static_cast<PLevelObject*>(data[i][j]->returnFirstChild()); destination->attachToRoot(data[i][j]->returnFirstChild()); data[i][j]->unlinkFirstChild(); int it = destination->getI(), jt =destination->getJ(); if(object->getId() == PLAYER) { cameraAdjustX = jt - object->getJ(); cameraAdjustY = - it + object->getI(); // adjustCameraAtTeleport(it, jt, object, dir); // adjust the camera gameCore->getCamera()->rotateViewX((float)cameraAdjustX*0.5); gameCore->getCamera()->rotateViewY((float)cameraAdjustY*0.5); } object->setIndex(it, jt); object->setRealI((float)it); object->setRealJ((float)jt); // PDirection dir = Aliases::left; }else if(floor_id == CUBE_PLACE)// if we put a cube in its place { if(this->isLevelDone()) { this->endgameFlag = true; Messages::infoMessage("You won!!!!! :))))"); } }else if(((PLevelObject*) data[i][j]->returnFirstChild())->getId() == PLAYER) // if the child object is a player { if(button_flags != 0)// if we are holding down the button, we want still to move the player { // check which button is still held down, and apply that movement if(button_flags & KB_UP) { this->moveObject(Aliases::up, this->getPlayerHandle()); }else if(button_flags & KB_LEFT) { this->moveObject(Aliases::left, this->getPlayerHandle()); }else if(button_flags & KB_DOWN) { this->moveObject(Aliases::down, this->getPlayerHandle()); }else if(button_flags & KB_RIGHT) { this->moveObject(Aliases::right, this->getPlayerHandle()); } } } } // level functions implementation goes here! ;) /************************************************************** * Function reads file data form file, given by filename * variable into level class **************************************************************/ // function is work in progress, started by Aljosa june 29, 2008 bool PLevel::reloadLevel() { int tmsize; // teleport matrix size PObject *p = NULL; // our pobject pointer; for creating dynamic objects ifstream level; // file handle level.open(this->filename.c_str(), ios::in); // opens level if(!level.good()) // checks if file is properly open { Messages::errorMessage("Level data is in invalid format ot there is not level data at all!"); return false; // if it isn't, end routine } // everything went ok so far Messages::infoMessage("Loading level data... please wait."); while(!level.eof()) // we read file 'till the end { // first read dimension height = this->returnNumberFromFile(level); // dimensions are first two numbers width = this->returnNumberFromFile(level); int num = 0; // number that we get from file // considering dimension, we read first matrix for(unsigned i=0; i<width; i++) { for(unsigned j=0; j<height; j++) { num = returnNumberFromFile(level); // we read number from file and store it into num if(num!=-1) // we check if data is valid { // teleport case if(num >= 9) // if it is > 11, then it is an teleport id { data[i][j] = new PTeleport(i, j, this->gameCore, num); // create object if((resourceHandle->getTextureResource(TELEPORT_RES))==NULL) // texture isn't in memory yet? resourceHandle->loadTextureResource(TELEPORT_RES, "test.tga"); // load it! (dynamic_cast<PTeleport*>(data[i][j]))->setId(num); // set its id // (dynamic_cast<PTeleport*>(data[i][j]))-> // data[i][j] = teleport; // attach it on level this->teleports.push_back(dynamic_cast<PTeleport*>(data[i][j])); // push teleport info on vector } switch(num) // if it is, we create suitable object { case FLOOR: data[i][j] = new PFloor(this->gameCore); if((resourceHandle->getTextureResource(FLOOR_RES))==NULL) // texture isn't in memory yet? resourceHandle->loadTextureResource(FLOOR_RES, "floor.tga"); // load it! break; /* case OW_FLOOR: data[i][j] = new POnewayFloor(this->gameCore); break;*/ case S_WALL: data[i][j] = new PSolidWall(this->gameCore); if((resourceHandle->getTextureResource(S_WALL_RES))==NULL) resourceHandle->loadTextureResource(S_WALL_RES, "wall.tga"); break; case BRIDGE: data[i][j] = new PBridge(this->gameCore); if((resourceHandle->getTextureResource(BRIDGE_RES))==NULL) // texture isn't in memory yet? resourceHandle->loadTextureResource(BRIDGE_RES, "bridge.tga"); // load it! break; case VOID: data[i][j] = new PVoid; break; case CUBE_PLACE: data[i][j] = new PCubeHolder(this->gameCore); this->holds.push_back(dynamic_cast<PCubeHolder*>(data[i][j])); // adds cuneHolder to holds array if((resourceHandle->getTextureResource(CUBE_RES))==NULL) // texture isn't in memory yet? resourceHandle->loadTextureResource(CUBE_RES, "crate.tga"); // load it! break; case OW_FLOOR_L: data[i][j] = new POnewayFloor(this->gameCore, 5); dynamic_cast<POnewayFloor*>(data[i][j])->setDirection(Aliases::left); // data[i][j]->add(p); if((resourceHandle->getTextureResource(OW_FLOOR_RES))==NULL) // texture isn't in memory yet? resourceHandle->loadTextureResource(OW_FLOOR_RES, "onewayfloor.tga"); // load it! // second_matrix[i][j] = 8; // data[i][j]->add(NULL); break; case OW_FLOOR_R: data[i][j] = new POnewayFloor(this->gameCore, 6); dynamic_cast<POnewayFloor*>(data[i][j])->setDirection(Aliases::right); // data[i][j]->add(p); if((resourceHandle->getTextureResource(OW_FLOOR_RES))==NULL) // texture isn't in memory yet? resourceHandle->loadTextureResource(OW_FLOOR_RES, "onewayfloor.tga"); // load it! // second_matrix[i][j] = 9; // data[i][j]->add(NULL); break; case OW_FLOOR_U: data[i][j] = new POnewayFloor(this->gameCore, 7); dynamic_cast<POnewayFloor*>(data[i][j])->setDirection(Aliases::up); // data[i][j]->add(p); if((resourceHandle->getTextureResource(OW_FLOOR_RES))==NULL) // texture isn't in memory yet? resourceHandle->loadTextureResource(OW_FLOOR_RES, "onewayfloor.tga"); // load it! // second_matrix[i][j] = 10; // data[i][j]->add(NULL); break; case OW_FLOOR_D: data[i][j] = new POnewayFloor(this->gameCore, 8); dynamic_cast<POnewayFloor*>(data[i][j])->setDirection(Aliases::down); // data[i][j]->add(p); if((resourceHandle->getTextureResource(OW_FLOOR_RES))==NULL) // texture isn't in memory yet? resourceHandle->loadTextureResource(OW_FLOOR_RES, "onewayfloor.tga"); // load it! // second_matrix[i][j] = 11; // data[i][j]->add(NULL); break; } } else // if it isn't, we return error { Messages::errorMessage("Invalid level data."); return false; } } } // first matrix shoud be in memory by now. if(!checkPosition(level)) return false; // we continue with second matrix for(unsigned i=0; i<width; i++) { for(unsigned j=0; j<height; j++) { num = returnNumberFromFile(level); if(num!=-1) { switch(num) { case PLAYER: p = new PPlayer(i, j, this->gameCore); if((resourceHandle->getTextureResource(PLAYER_RES))==NULL) // texture isn't in memory yet? resourceHandle->loadTextureResource(PLAYER_RES, "player.tga"); // load it! if((resourceHandle->getModelResource(PLAYER_RES)) == NULL) // model isn't in memory yet? { resourceHandle->loadModelResource(PLAYER_RES, "data/player.md2"); // load it! resourceHandle->getModelResource(PLAYER_RES)->SetTexture(resourceHandle->getTextureTesourceId(PLAYER_RES)); // set the texture } this->player = dynamic_cast<PPlayer*>(p); // set class player pointer to player element data[i][j]->add(p); second_matrix[i][j] = PLAYER; break; case CUBE: p = new PCube(i, j, this->gameCore); if((resourceHandle->getTextureResource(CUBE_RES))==NULL) // texture isn't in memory yet? resourceHandle->loadTextureResource(CUBE_RES, "crate.tga"); // load it! data[i][j]->add(p); second_matrix[i][j] = CUBE; break; case 3://OW_CUBE_L: p = new POnewayCube(Aliases::left, i, j, OW_CUBE_L, this->gameCore); data[i][j]->add(p); if((resourceHandle->getTextureResource(OW_CUBE_RES))==NULL) // texture isn't in memory yet? resourceHandle->loadTextureResource(OW_CUBE_RES, "onewaycube.tga"); // load it! second_matrix[i][j] = OW_CUBE_L; break; case 4://OW_CUBE_R: p = new POnewayCube(Aliases::right, i, j, OW_CUBE_R, this->gameCore); data[i][j]->add(p); if((resourceHandle->getTextureResource(OW_CUBE_RES))==NULL) // texture isn't in memory yet? resourceHandle->loadTextureResource(OW_CUBE_RES, "onewaycube.tga"); // load it! second_matrix[i][j] = OW_CUBE_R; break; case 5://OW_CUBE_U: p = new POnewayCube(Aliases::up, i, j, OW_CUBE_U, this->gameCore); data[i][j]->add(p); if((resourceHandle->getTextureResource(OW_CUBE_RES))==NULL) // texture isn't in memory yet? resourceHandle->loadTextureResource(OW_CUBE_RES, "onewaycube.tga"); // load it! second_matrix[i][j] = OW_CUBE_U; break; case 6://OW_CUBE_D: p = new POnewayCube(Aliases::down, i, j, OW_CUBE_D, this->gameCore); data[i][j]->add(p); if((resourceHandle->getTextureResource(OW_CUBE_RES))==NULL) // texture isn't in memory yet? resourceHandle->loadTextureResource(OW_CUBE_RES, "onewaycube.tga"); // load it! second_matrix[i][j] = OW_CUBE_D; break; case 7://BOMB: p = new PBomb(i, j, this->gameCore); data[i][j]->add(p); if((resourceHandle->getTextureResource(BOMB_RES))==NULL) // texture isn't in memory yet? resourceHandle->loadTextureResource(BOMB_RES, "bomb.tga"); // load it! second_matrix[i][j] = BOMB; break; case U_WALL: p = new PUnsolidWall(i,j,this->gameCore); data[i][j]->add(p); if((resourceHandle->getTextureResource(U_WALL_RES))==NULL) resourceHandle->loadTextureResource(U_WALL_RES, "unsolidwall.tga"); second_matrix[i][j] = U_WALL; break; default: // in data[i][j]->add(NULL); second_matrix[i][j] = 0; } } else { Messages::errorMessage("Invalid level data."); return false; } } } // second matrix should be in memory by now // now validate if(!checkPosition(level)) return false; // validation went ok; now we read teleport relationship matrix tmsize = returnNumberFromFile(level); for(int i=0; i<tmsize; i++) { PTeleport *childTeleport; // teleprot we're attaching PTeleport *parentTeleport; // parent teleport parentTeleport = returnTeleport(returnNumberFromFile(level)); // get parent teleport int tmp_i = parentTeleport->getI(); int tmp_j = parentTeleport->getJ(); second_matrix[tmp_i][tmp_j] = parentTeleport->getId(); childTeleport = returnTeleport(returnNumberFromFile(level)); // get child teleport if(parentTeleport!=NULL && childTeleport!=NULL) // if teleports has been found { // parentTeleport->add(childTeleport); // attach them parentTeleport->setChildTeleport(childTeleport); cout<<"Teleport "<<childTeleport->getId()<<" attached to teleport "<<parentTeleport->getId()<<endl; } else { Messages::errorMessage("Invalid level data."); return false; } } // camera setup // set the camera position gameCore->getCamera()->fitCameraToLevel(width, height); // rotate the camera above the player gameCore->getCamera()->rotateViewX( 0.5f * (player->getJ() - ((int)width-1)/2)); gameCore->getCamera()->rotateViewY( 0.5f * (player->getI() - ((int)height-1)/2)); // teleports.clear(); // clear teleport vector, since they are by now in memory and no longer needed break; } Messages::infoMessage("Level data successfully loaded from file."); level.close(); return true; // everything went ok } bool PLevel::saveStateToFile(string file_name) { // cout << "test" << endl; ofstream file (file_name.c_str()); if (file.is_open()) { file << this->width << " " << this->height << endl; // 1st matrix dimension // write 1st matrix data to file for (unsigned i=0; i<this->width; i++) { for (unsigned j=0; j<this->height; j++) { file << data[i][j]->getId() << " "; } file << endl; } file << "+" << endl; for (unsigned i=0; i<this->width; i++) { for (unsigned j=0; j<this->height; j++) { file << second_matrix[i][j] << " "; } file << endl; } file << "+" << endl; file << teleports.size() << endl; for(int i=0; i<(int)teleports.size(); i++) { PTeleport* tmp = teleports.at(i); PTeleport* child = tmp->getChildTeleport(); file << tmp->getId() << " " << child->getId() << endl; } file.close(); return true; } else { cout << "NAPAKA: datoteke ni mogoče ustvariti!" << endl; return false; } } /************************************************************** * Function which reset level data **************************************************************/ bool PLevel::reset() { releaseLevel(); teleports.clear(); holds.clear(); endgameFlag = false; moves = 0; starttime = glfwGetTime(); return reloadLevel(); } /************************************************************** * Function returns pointer to player in level **************************************************************/ PPlayer* PLevel::getPlayerHandle() { return this->player; } /************************************************************** * Function returns pointer to renderer object **************************************************************/ bool PLevel::getEndgameFlag() { return this->endgameFlag; } /************************************************************** * Function initiates level * work in progress **************************************************************/ bool PLevel::initialize() { //data = new if(!this->reloadLevel()) { Messages::errorMessage("Level loading from file failed."); return 0; } // by now, matrix should be initialized with proper classes, if it went ok this far // try to initialize core if(!this->gameCore->init()) { this->gameCore->release(); Messages::initMessage("Game core", false); } else Messages::initMessage("Game core", true); // temporary, dump state this->print(); starttime = glfwGetTime(); moves = 0; button_flags = 0; return true; // everything went ok } /************************************************************** * Function draws level with OpenGL into a window **************************************************************/ void PLevel::draw() { glEnable(GL_LIGHTING); glPushMatrix(); for(unsigned i=0; i<this->width; i++) { for(unsigned j=0; j<this->height; j++) { PLevelObject *obj = (PLevelObject*) data[i][j]->returnFirstChild(); if(obj!=NULL) // if there is boject binded { glPushMatrix(); glTranslatef(obj->getRealI(), obj->getRealJ(), 0.0); obj->draw(); // prints it glPopMatrix(); // if child is player or movable cube, draw also parent if ((static_cast<PLevelObject*>(obj)->getId() & (PLAYER | CUBE)) != 0) { glPushMatrix(); glTranslatef(float(i),float(j),0.0); data[i][j]->draw(); glPopMatrix(); } } else if(data[i][j]!=NULL) { glPushMatrix(); glTranslatef((float)i, (float)j, 0.0); data[i][j]->draw(); // otherwise, print object glPopMatrix(); } // draw activated bombs, if there are any if(this->bombs.size()>0) { for(unsigned i=0; i<bombs.size(); i++) { glPushMatrix(); glTranslatef((float)this->bombs[i]->i, (float)this->bombs[i]->j, 0.0); glColor3f(1.0, 0.0, 0.0); glBindTexture(GL_TEXTURE_2D, this->resourceHandle->getTextureTesourceId(BOMB_RES)); this->gameCore->getRenderer()->drawCube(0.0, 0.0, 0.5); glPopMatrix(); } } } } glPopMatrix(); glDisable(GL_LIGHTING); //Change mode for text glMatrixMode(GL_PROJECTION); // Change Matrix Mode to Projection glLoadIdentity(); // Reset View glOrtho(0, 800, 0, 600, 0, 100); glMatrixMode(GL_MODELVIEW); // Change Projection to Matrix Mode glLoadIdentity(); glTranslatef(0, 600, -0.5); if(!endgameFlag) time = glfwGetTime(); fnt->writeTextAbs(10,-30,"Elapsed time: "+Functions::toString<int>((int)(time-starttime))); fnt->writeTextAbs(170,-30,"Moves: "+Functions::toString<int>(moves)); } /**************************************** * animate * Animates the objects on the field. * When they are done moving it activates * the floor underneath them. * **************************************/ void PLevel::animate(double time) { for(unsigned i=0; i<this->width; i++) { for(unsigned j=0; j<this->height; j++) { PLevelObject *obj = (PLevelObject*) data[i][j]->returnFirstChild(); if(obj != NULL) { if(obj->animate(time)) activateFloor(i,j); } } } } bool PLevel::loadLevelFromFile(string filename){ this->filename = filename; this->endgameFlag = false; starttime = glfwGetTime(); return reset(); } /************************************************************** * Function dumps level data into console * consider it as an alternative render function :D **************************************************************/ void PLevel::print() { cout<<endl; for(unsigned i=0; i<this->width; i++) { cout<<setfill('-')<<setw(73)<<"-"<<endl; // prints line for(unsigned j=0; j<this->height; j++) { PLevelObject *obj = dynamic_cast<PLevelObject*>(data[i][j]->returnFirstChild()); if(obj!=NULL) // if there is boject binded { obj->print(); // prints it // cout<<"ACTIVE BOMB: "<<obj->isActiveBomb()<<false; } else if(data[i][j]!=NULL) data[i][j]->print(); // otherwise, print object } cout<<'|'<<endl; } cout<<setfill('-')<<setw(73)<<"-"<<endl; // prints line cout<<endl; } /************************************************************** * Function dumps level data into console * prints type of level(wall, void, teleport, ...) **************************************************************/ void PLevel::printLevelByType() const { cout<<endl; for(unsigned i=0; i<this->width; i++) { for(unsigned j=0; j<this->height; j++) data[i][j]->print(); // prints objects info cout<<'|'<<endl; } cout<<endl; } /************************************************************** * Function dumps level data into console * prints meta data(what is on level block) **************************************************************/ void PLevel::printLevelByMeta() const { cout<<endl; for(unsigned i=0; i<this->width; i++) { for(unsigned j=0; j<this->height; j++) { PObject *obj = data[i][j]->returnFirstChild(); if(obj!=NULL) // if there is boject binded obj->print(); // prints it else cout<<"| "; // otherwise, print empty } cout<<'|'<<endl; } cout<<endl; } /************************************************************** * releaseLevel() * clear all level data from memory **************************************************************/ void PLevel::releaseLevel() { for(unsigned i=0; i<width; i++) { for(unsigned j=0; j<height; j++) { delete data[i][j]; data[i][j] = NULL; } } delete player; Messages::infoMessage("Level data successfully released from memory."); } unsigned PLevel::getWidth() { return this->width; } unsigned PLevel::getHeight() { return this->height; } /************************************************************** * Dropped Bombs * functions manages them **************************************************************/ void PLevel::processBombs(double current_time) { if(this->bombs.size() != 0) // are there any bombs to trigger? { // get addres of bomb that was released first(is first in the list) PDroppedBomb* firstDroppedBomb = this->bombs[0]; // apparently they are! if(int(current_time-firstDroppedBomb->dropTime+0.5) == 3) // is it time to trigger bomb yet? { // check bomb surrounding fields this->checkAndApplyBombBlast(firstDroppedBomb->i-1, firstDroppedBomb->j); this->checkAndApplyBombBlast(firstDroppedBomb->i+1, firstDroppedBomb->j); this->checkAndApplyBombBlast(firstDroppedBomb->i, firstDroppedBomb->j-1); this->checkAndApplyBombBlast(firstDroppedBomb->i, firstDroppedBomb->j+1); // remove first dropped bomb data[firstDroppedBomb->i][firstDroppedBomb->j]->toogleBombActivity(); delete bombs[0]; this->bombs.erase(this->bombs.begin()); } } } bool PLevel::addDroppedBomb(int i, int j) { if(!data[i][j]->isActiveBomb()) { cout<<"I can attach bomb here ;)"<<endl; // data[i][j]->attachToRoot(new PacGame::GameClasses::GameObjects::PDetonatedBomb()); data[i][j]->toogleBombActivity(); this->bombs.push_back(new PDroppedBomb(i, j)); return true; } return false; } void PLevel::checkAndApplyBombBlast(int i, int j) { // PacGame::RenderMaschine::PParticleEngine particle(i*2.0, j*2.0, -10.0); // (10.05, -11.4, 29.3); // particle.process(100); if((unsigned)i > (this->width-1)|| i<0 || (unsigned)j > (this->height-1) || j<0) { Messages::errorIndexOutOfRange(); return; } if(data[i][j]->returnFirstChild() != NULL) { if((dynamic_cast<PLevelObject*>(this->data[i][j]->returnFirstChild())->getId())==U_WALL) // is there unsolidWall ? { data[i][j]->releaseFirstChildObject(); } } } void PLevel::adjustCameraAtTeleport(int it, int jt, PLevelObject *obj, PDirection dir) { int delta_i = (int)this->data[it][jt]->getI() - (int)obj->getI() ; int delta_j = (int)this->data[it][jt]->getJ() - (int)obj->getJ() ; // 0.5 switch (dir) { case Aliases::up: delta_i ++; break; case Aliases::down: delta_i --; break; case Aliases::left: delta_j ++; break; case Aliases::right: delta_j --; break; } this->gameCore->getCamera()->rotateViewX(0.5, delta_j ); this->gameCore->getCamera()->rotateViewY(0.5, -delta_i ); } ///// temporary? PCore* PLevel::getGameCoreHandle() { return this->gameCore; } /************************************************************** * Destructor * clear all level data from memory **************************************************************/ PLevel::~PLevel() { this->gameCore->deinit(); this->releaseLevel(); delete fnt; } } }
[ "aljosa.osep@d77d96cf-bc4d-0410-95e8-7f58e8f99bdb", "jernej.skrabec@d77d96cf-bc4d-0410-95e8-7f58e8f99bdb", "jernej.halozan@d77d96cf-bc4d-0410-95e8-7f58e8f99bdb", "Martin.Savc@d77d96cf-bc4d-0410-95e8-7f58e8f99bdb" ]
[ [ [ 1, 17 ], [ 22, 22 ], [ 26, 44 ], [ 46, 51 ], [ 55, 55 ], [ 59, 60 ], [ 73, 150 ], [ 152, 152 ], [ 160, 160 ], [ 162, 178 ], [ 182, 186 ], [ 222, 223 ], [ 228, 230 ], [ 249, 250 ], [ 252, 252 ], [ 256, 258 ], [ 262, 263 ], [ 268, 269 ], [ 274, 275 ], [ 481, 489 ], [ 491, 496 ], [ 498, 572 ], [ 575, 656 ], [ 662, 664 ], [ 667, 674 ], [ 677, 678 ], [ 681, 685 ], [ 687, 688 ], [ 691, 695 ], [ 697, 698 ], [ 701, 705 ], [ 707, 708 ], [ 711, 715 ], [ 717, 718 ], [ 720, 725 ], [ 727, 729 ], [ 731, 741 ], [ 743, 756 ], [ 758, 766 ], [ 771, 786 ], [ 797, 804 ], [ 837, 837 ], [ 869, 892 ], [ 894, 910 ], [ 915, 922 ], [ 924, 928 ], [ 930, 932 ], [ 934, 936 ], [ 945, 970 ], [ 987, 987 ], [ 1010, 1010 ], [ 1018, 1100 ], [ 1102, 1126 ], [ 1128, 1135 ], [ 1138, 1160 ], [ 1166, 1200 ], [ 1202, 1218 ], [ 1220, 1224 ] ], [ [ 18, 21 ], [ 23, 25 ], [ 52, 52 ], [ 61, 72 ], [ 153, 153 ], [ 155, 159 ], [ 161, 161 ], [ 281, 282 ], [ 490, 490 ], [ 573, 574 ], [ 793, 794 ], [ 855, 868 ], [ 893, 893 ], [ 911, 913 ], [ 923, 923 ], [ 971, 986 ], [ 1011, 1017 ], [ 1101, 1101 ], [ 1127, 1127 ], [ 1136, 1137 ], [ 1161, 1165 ], [ 1201, 1201 ], [ 1219, 1219 ] ], [ [ 45, 45 ], [ 53, 54 ], [ 56, 58 ], [ 665, 665 ], [ 675, 676 ], [ 686, 686 ], [ 696, 696 ], [ 706, 706 ], [ 716, 716 ], [ 726, 726 ], [ 742, 742 ], [ 757, 757 ], [ 767, 770 ], [ 796, 796 ], [ 805, 836 ], [ 838, 854 ] ], [ [ 151, 151 ], [ 154, 154 ], [ 179, 181 ], [ 187, 221 ], [ 224, 227 ], [ 231, 248 ], [ 251, 251 ], [ 253, 255 ], [ 259, 261 ], [ 264, 267 ], [ 270, 273 ], [ 276, 280 ], [ 283, 480 ], [ 497, 497 ], [ 657, 661 ], [ 666, 666 ], [ 679, 680 ], [ 689, 690 ], [ 699, 700 ], [ 709, 710 ], [ 719, 719 ], [ 730, 730 ], [ 787, 792 ], [ 795, 795 ], [ 914, 914 ], [ 929, 929 ], [ 933, 933 ], [ 937, 944 ], [ 988, 1009 ] ] ]
da5ee976eb42c1dabdaabdad9dcfbd94c6308a09
27c6eed99799f8398fe4c30df2088f30ae317aff
/regexp/trunk/main.cpp
966aec9aa7394dbcf52f5561bb219cab87eb6036
[]
no_license
lit-uriy/ysoft
ae67cd174861e610f7e1519236e94ffb4d350249
6c3f077ff00c8332b162b4e82229879475fc8f97
refs/heads/master
2021-01-10T08:16:45.115964
2009-07-16T00:27:01
2009-07-16T00:27:01
51,699,806
0
0
null
null
null
null
UTF-8
C++
false
false
2,825
cpp
/**************************************************************************** ** ** Copyright (C) 2004-2008 Trolltech ASA. All rights reserved. ** ** This file is part of the example classes of the Qt Toolkit. ** ** This file may be used under the terms of the GNU General Public ** License versions 2.0 or 3.0 as published by the Free Software ** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3 ** included in the packaging of this file. Alternatively you may (at ** your option) use any later version of the GNU General Public ** License if such license has been publicly approved by Trolltech ASA ** (or its successors, if any) and the KDE Free Qt Foundation. In ** addition, as a special exception, Trolltech gives you certain ** additional rights. These rights are described in the Trolltech GPL ** Exception version 1.1, which can be found at ** http://www.trolltech.com/products/qt/gplexception/ and in the file ** GPL_EXCEPTION.txt in this package. ** ** Please review the following information to ensure GNU General ** Public Licensing requirements will be met: ** http://trolltech.com/products/qt/licenses/licensing/opensource/. If ** you are unsure which license is appropriate for your use, please ** review the following information: ** http://trolltech.com/products/qt/licenses/licensing/licensingoverview ** or contact the sales department at [email protected]. ** ** In addition, as a special exception, Trolltech, as the sole ** copyright holder for Qt Designer, grants users of the Qt/Eclipse ** Integration plug-in the right for the Qt/Eclipse Integration to ** link to functionality provided by Qt Designer and its related ** libraries. ** ** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, ** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE. Trolltech reserves all rights not expressly ** granted herein. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ****************************************************************************/ #include <QApplication> #include <QTextCodec> #include <QtGui/QStyleFactory> #include <QtGui/QStyle> #include "regexpdialog.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); // Установим кодировку для функции перевода tr() QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); // Сделаем симпотичный вид QStyle *pStyle = QStyleFactory::create("Plastique");//Cleanlooks QApplication::setStyle(pStyle); // app.setPalette(pStyle->standardPalette()); RegExpDialog dialog; dialog.show(); return dialog.exec(); }
[ "lit-uriy@d7ba3245-3e7b-42d0-9cd4-356c8b94b330" ]
[ [ [ 1, 65 ] ] ]
74a0a91e3d782baa2bc106be3a0fbe9e64a54659
ae2adbf262d2938684664e3195a3b71934f4448c
/trabalho 02/texture.cpp
c13ed88bcf6ac56ba2ed9fa071c19004801ea218
[]
no_license
cmdalbem/saint-ende
e5e251a0b274e40c02233ed4963ca0c619ed31eb
b5aeeea978108d1e906fd168c0c24618a3d35882
refs/heads/master
2020-07-09T08:21:07.963803
2009-12-21T17:32:25
2009-12-21T17:32:25
32,224,226
0
0
null
null
null
null
UTF-8
C++
false
false
2,027
cpp
#include "texture.h" int findTexture(Imagem texture, int originX, int originY) { const int textureTotal = 9, maxBorderSize = 4; texture.convertToGrayScale(); texture.limiarize(texture.bestLimiar()); Imagem textureCell; double comparison[textureTotal] = {0,0,0, 0,0,0, 0,0,0}; int bestChoiceIndex = 0; for(int i = 1; i < textureTotal; ++i) { loadTextureCell(textureCell, i); textureCell.convertToGrayScale(); textureCell.limiarize(textureCell.bestLimiar()); std::cout << std::endl << std::endl; for(int k = 0; k <= maxBorderSize; ++k) { double compareK = compare(texture, textureCell, originX + k, originY + k, textureCell.getW(), textureCell.getH()); std::cout << compareK << ' '; if(compareK >= comparison[i]) comparison[i] = compareK; } std::cout << " -> " << comparison[i] << std::endl; //comparison[i] = compare(texture, textureCell, originX, originY, textureCell.getW(), textureCell.getH()); if(comparison[i] > comparison[bestChoiceIndex]) bestChoiceIndex = i; } std::cout << std::endl << std::endl << "Best: " << comparison[bestChoiceIndex] << std::endl << std::endl ; return bestChoiceIndex; } double compare(Imagem& first, Imagem& second, int originX, int originY, int width, int height) { double total = 0, equals = 0; for(int i = 0; i < width; ++i) for(int j = 0; j < height; ++j) { ++total; if(first.getR(originX + i, originY + j) == second.getR(i,j)){ ++ equals; } } return (total != 0? equals/total : 1); } void loadTextureCell(Imagem& textureCell, int index) { char indexString[5] = "0"; if(index < 9999) sprintf(indexString,"%d",index);//itoa(index, indexString, 10); string texturePath = string("patterns/cell_") + indexString + string(".bmp") ; textureCell.load(texturePath.c_str()); }
[ "lucapus@7df66274-e10c-11de-a155-4d945b6d75ec", "lfzawacki@7df66274-e10c-11de-a155-4d945b6d75ec" ]
[ [ [ 1, 61 ], [ 63, 66 ] ], [ [ 62, 62 ], [ 67, 68 ] ] ]
e94d3b169589af481aa1cd4d843f0152d1dd9435
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/nGENE Proj/RLEEncoder.cpp
a060a0d9a49719f012f5cb5f35bfb45da5acb1f6
[]
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,764
cpp
/* --------------------------------------------------------------------------- This source file is part of nGENE Tech. Copyright (c) 2006- Wojciech Toman This program is free software. File: RLEEncoder.cpp Version: 0.01 --------------------------------------------------------------------------- */ #include "PrecompiledHeaders.h" #include "RLEEncoder.h" namespace nGENE { uint RLEEncoder::encode(char* _result, const char* _data, uint _size) { if(!_size) return 0; char prev = 0; char curr = 0; uint index = 0; const char* pointer = _data; uint count = 0; while(pointer < _data + _size) { curr = (*pointer++); _result[index++] = curr; if(curr == prev) { count = 0; while(count < 255 && pointer < _data + _size) { if((curr = *(pointer++)) == prev) ++count; else break; } _result[index++] = (byte)count; if(count != 255 && curr != prev) _result[index++] = curr; } prev = curr; } return index; } //---------------------------------------------------------------------- void RLEEncoder::encode(ostream& _result, const char* _data, uint _size) { if(!_size) return; char prev = 0; char curr = 0; const char* pointer = _data; uint count = 0; while(pointer < _data + _size) { curr = (*pointer++); _result << curr; if(curr == prev) { count = 0; while(count < 255 && pointer < _data + _size) { if((curr = *(pointer++)) == prev) ++count; else break; } _result << (byte)count; if(count != 255 && curr != prev) _result << curr; } prev = curr; } } //---------------------------------------------------------------------- uint RLEEncoder::decode(char* _result, const char* _data, uint _size) { char curr = 0; char prev = 0; byte count = 0; uint index = 0; const char* pointer = _data; while(pointer < _data + _size) { curr = *(pointer++); _result[index++] = curr; if(curr == prev) { count = *(pointer++); while(count-- > 0) _result[index++] = curr; } prev = curr; } return index; } //---------------------------------------------------------------------- void RLEEncoder::decode(ostream& _result, const char* _data, uint _size) { char curr = 0; char prev = 0; byte count = 0; const char* pointer = _data; while(pointer < _data + _size) { curr = *(pointer++); _result << curr; if(curr == prev) { count = *(pointer++); while(count-- > 0) _result << curr; } prev = curr; } } //---------------------------------------------------------------------- }
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 132 ] ] ]
2fc86354c373b1d0a4d4d08a8e7f95c0b1605be9
2f72d621e6ec03b9ea243a96e8dd947a952da087
/include/Listener.h
7e017ab9445e28d904ebb610b092ff63ce4a1500
[]
no_license
gspu/lol4fg
752358c3c3431026ed025e8cb8777e4807eed7a0
12a08f3ef1126ce679ea05293fe35525065ab253
refs/heads/master
2023-04-30T05:32:03.826238
2011-07-23T23:35:14
2011-07-23T23:35:14
364,193,504
0
0
null
null
null
null
UTF-8
C++
false
false
2,198
h
#ifndef __mSoundListener #define __mSoundListener #include "alc.h" #include "al.h" #include "Ogre.h" #include "Sound.h" #include "OgreSingleton.h" namespace SimpleSound { class Listener: public Ogre::Singleton<Listener> { friend class SoundManager; public: inline void setPosition(Ogre::Vector3 pos) { alGetError(); alListener3f(AL_POSITION,pos.x,pos.y,pos.z); if(alGetError()) { Ogre::LogManager::getSingletonPtr()->logMessage("WAHH ListenerSetPos problem!"); } } inline void setVelocity(Ogre::Vector3 vel) { alListener3f(AL_VELOCITY,vel.x,vel.y,vel.z); } inline void setOrientation(Ogre::Quaternion ornt) { alGetError(); Ogre::Vector3 fore = ornt*Ogre::Vector3::NEGATIVE_UNIT_Z; Ogre::Vector3 up = ornt*Ogre::Vector3::UNIT_Y; float vec[6]; vec[0] = fore.x; vec[1] = fore.y; vec[2] = fore.z; vec[3] = up.x; vec[4] = up.y; vec[5] = up.z; alListenerfv(AL_ORIENTATION, vec); if(alGetError()) { Ogre::LogManager::getSingletonPtr()->logMessage("WAHH ListenerSetOrnt problem!"); } } inline Ogre::Vector3 getPosition() { alGetError(); Ogre::Vector3 pos; alGetListener3f(AL_POSITION,&pos.x,&pos.y,&pos.z); return pos; } inline Ogre::Vector3 getVelocity() { Ogre::Vector3 vel; alListener3f(AL_VELOCITY,vel.x,vel.y,vel.z); return vel; } inline Ogre::Quaternion getOrientation() { alGetError(); float vec[6]; alGetListenerfv(AL_ORIENTATION, vec); Ogre::Vector3 fore; Ogre::Vector3 up; fore.x = vec[0]; fore.y = vec[1]; fore.z = vec[2]; up.x = vec[3]; up.y = vec[4]; up.z = vec[5]; fore.normalise(); up.normalise(); Ogre::Vector3 xAxis = up.crossProduct(-fore); xAxis.normalise(); return Ogre::Quaternion(xAxis,up,-fore); } //sets the gain for the Listener. This is something like the global gain inline void setGain(Ogre::Real gain) { alListenerf( AL_GAIN, gain ); } private: Listener(){}; }; } #endif
[ "praecipitator@bd7a9385-7eed-4fd6-88b1-0096df50a1ac" ]
[ [ [ 1, 94 ] ] ]