void raster_rgba_vline_fade(pb_rgba *pb, int y1, uint32_t color1, int y2, uint32_t color2, int x) { int ydiff = y2 - y1; if (ydiff == 0) return; int c1rd = GET_R(color1); int c1gr = GET_G(color1); int c1bl = GET_B(color1); int c2rd = GET_R(color2); int c2gr = GET_G(color2); int c2bl = GET_B(color2); int rdx = c2rd - c1rd; int gdx = c2gr - c1gr; int bdx = c2bl - c1bl; float factor = 0.0f; float factorStep = 1.0f / (float)ydiff; // draw each pixel in the span for (int y = y1; y < y2; y++) { int rd = c1rd + (int)(rdx*factor); int gr = c1gr + (int)(gdx*factor); int bl = c1bl + (int)(bdx*factor); int fg = RGBA(rd, gr, bl, 255); pb_rgba_set_pixel(pb, x, y, fg); factor += factorStep; } }
int set_pixel_rgb(struct pixmap *p, int x, int y, unsigned char r, unsigned char g, unsigned char b) { int result = 0; if (p) { if (x >= 0 && x < p->width) { if (y >= 0 && y < p->height) { if (p->components == 1) { GET_R(p, x, y) = RED * r + GREEN * g + BLUE * b; } else { GET_R(p, x, y) = r; GET_G(p, x, y) = g; GET_B(p, x, y) = b; } } else { if (!quiet) fprintf(stderr, "%s: set_pixel_rgb: error: y out of range\n", __progname); result = -1; } } else { if (!quiet) fprintf(stderr, "%s: set_pixel_rgb: error: x out of range\n", __progname); result = -1; } } return result; }
void raster_rgba_blend_alphamap(pb_rgba *pb, const int x, const int y, const unsigned char *bitmap, const int w, const int h, const uint32_t color) { int xpos = x; int ypos = y; uint32_t *dstPtr = (uint32_t *)pb->data; uint8_t *srcPtr = (uint8_t *)bitmap; dstPtr += y*pb->pixelpitch + x; uint32_t *dstRowPtr = dstPtr; int srcrow = 0; for (srcrow = 0; srcrow < h; srcrow++) { xpos = x; for (int srccol = 0; srccol < w; srccol++) { if (*srcPtr > 0) { int dstColor = RGBA(GET_R(color), GET_G(color), GET_B(color), *srcPtr); pb_rgba_cover_pixel(pb, xpos, ypos, dstColor); } xpos++; srcPtr += 1; } ypos++; } }
void CGUITextureGL::Begin(UTILS::Color color) { CBaseTexture* texture = m_texture.m_textures[m_currentFrame]; texture->LoadToGPU(); if (m_diffuse.size()) m_diffuse.m_textures[0]->LoadToGPU(); texture->BindToUnit(0); // Setup Colors m_col[0] = (GLubyte)GET_R(color); m_col[1] = (GLubyte)GET_G(color); m_col[2] = (GLubyte)GET_B(color); m_col[3] = (GLubyte)GET_A(color); bool hasAlpha = m_texture.m_textures[m_currentFrame]->HasAlpha() || m_col[3] < 255; if (m_diffuse.size()) { if (m_col[0] == 255 && m_col[1] == 255 && m_col[2] == 255 && m_col[3] == 255 ) { m_renderSystem->EnableShader(SM_MULTI); } else { m_renderSystem->EnableShader(SM_MULTI_BLENDCOLOR); } hasAlpha |= m_diffuse.m_textures[0]->HasAlpha(); m_diffuse.m_textures[0]->BindToUnit(1); } else { if (m_col[0] == 255 && m_col[1] == 255 && m_col[2] == 255 && m_col[3] == 255) { m_renderSystem->EnableShader(SM_TEXTURE_NOBLEND); } else { m_renderSystem->EnableShader(SM_TEXTURE); } } if (hasAlpha) { glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_ONE); glEnable(GL_BLEND); } else { glDisable(GL_BLEND); } m_packedVertices.clear(); m_idx.clear(); }
void test_bitmap_color_transform_macro_c(short* buffer) { short* p = buffer; int n; for (n = 0; n < IMAGE_HEIGHT * IMAGE_WIDTH; ++n, ++p) { int r = GET_R(*p); int g = GET_G(*p); int b = GET_B(*p); *p = (short)TO_RGB(g, b, r); } }
void pb_rgba_cover_pixel(pb_rgba *pb, const unsigned int x, const unsigned int y, const uint32_t value) { // Quick reject if the foreground pixel has both 0 opacity // and 0 for color component values if (0 == value) { return; } if (0 == GET_A(value)) { // Combine the colors, but don't // change the alpha of the background } else if (255 == GET_A(value)) { // The foreground opacity is full, so set // the color // and set the background alpha to full as well pb_rgba_set_pixel(pb, x, y, value); } else { // All other cases where doing a cover of something // other than full opacity uint8_t alpha = GET_A(value); int32_t dstPixel = pb_rgba_get_pixel(pb, x, y); int dstColor = RGBA( lerp255(GET_R(dstPixel), GET_R(value), alpha), lerp255(GET_G(dstPixel), GET_G(value), alpha), lerp255(GET_B(dstPixel), GET_B(value), alpha), lerp255(GET_A(dstPixel), GET_A(value), alpha) ); pb_rgba_set_pixel(pb, x, y, dstColor); /* pix_rgba * B = (pix_rgba *)&pb->data[(y*(pb)->pixelpitch) + x]; B->r = lerp255(B->r, GET_R(value), alpha); B->g = lerp255(B->g, GET_R(value), alpha); B->b = lerp255(B->b, GET_R(value), alpha); B->a = lerp255(B->a, GET_R(value), alpha); */ } }
void CGUITextureGL::DrawQuad(const CRect &rect, color_t color, CBaseTexture *texture, const CRect *texCoords) { if (texture) { glActiveTextureARB(GL_TEXTURE0_ARB); texture->LoadToGPU(); glBindTexture(GL_TEXTURE_2D, texture->GetTextureObject()); glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE1); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); } else glDisable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); // Turn Blending On glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // diffuse coloring glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); VerifyGLState(); glBegin(GL_QUADS); glColor4ub((GLubyte)GET_R(color), (GLubyte)GET_G(color), (GLubyte)GET_B(color), (GLubyte)GET_A(color)); CRect coords = texCoords ? *texCoords : CRect(0.0f, 0.0f, 1.0f, 1.0f); glTexCoord2f(coords.x1, coords.y1); glVertex3f(rect.x1, rect.y1, 0); glTexCoord2f(coords.x2, coords.y1); glVertex3f(rect.x2, rect.y1, 0); glTexCoord2f(coords.x2, coords.y2); glVertex3f(rect.x2, rect.y2, 0); glTexCoord2f(coords.x1, coords.y2); glVertex3f(rect.x1, rect.y2, 0); glEnd(); if (texture) glDisable(GL_TEXTURE_2D); }
bool CRenderSystemGLES::ClearBuffers(color_t color) { if (!m_bRenderCreated) return false; float r = GET_R(color) / 255.0f; float g = GET_G(color) / 255.0f; float b = GET_B(color) / 255.0f; float a = GET_A(color) / 255.0f; glClearColor(r, g, b, a); GLbitfield flags = GL_COLOR_BUFFER_BIT; glClear(flags); return true; }
void CGUITextureGL::Begin(color_t color) { m_col[0] = (GLubyte)GET_R(color); m_col[1] = (GLubyte)GET_G(color); m_col[2] = (GLubyte)GET_B(color); m_col[3] = (GLubyte)GET_A(color); CBaseTexture* texture = m_texture.m_textures[m_currentFrame]; glActiveTextureARB(GL_TEXTURE0_ARB); texture->LoadToGPU(); if (m_diffuse.size()) m_diffuse.m_textures[0]->LoadToGPU(); glBindTexture(GL_TEXTURE_2D, texture->GetTextureObject()); glEnable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); // Turn Blending On glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // diffuse coloring glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); VerifyGLState(); if (m_diffuse.size()) { glActiveTextureARB(GL_TEXTURE1_ARB); glBindTexture(GL_TEXTURE_2D, m_diffuse.m_textures[0]->GetTextureObject()); glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE1); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); VerifyGLState(); } //glDisable(GL_TEXTURE_2D); // uncomment these 2 lines to switch to wireframe rendering //glBegin(GL_LINE_LOOP); glBegin(GL_QUADS); }
bool CRenderSystemGL::ClearBuffers(color_t color) { if (!m_bRenderCreated) return false; /* clear is not affected by stipple pattern, so we can only clear on first frame */ if(m_stereoMode == RENDER_STEREO_MODE_INTERLACED && m_stereoView == RENDER_STEREO_VIEW_RIGHT) return true; float r = GET_R(color) / 255.0f; float g = GET_G(color) / 255.0f; float b = GET_B(color) / 255.0f; float a = GET_A(color) / 255.0f; glClearColor(r, g, b, a); GLbitfield flags = GL_COLOR_BUFFER_BIT; glClear(flags); return true; }
void CEmTubeSplashViewContainer::Draw(const TRect& /*aRect*/) const { CWindowGc& gc = SystemGc(); gc.SetClippingRect( Rect() ); gc.SetBrushColor( KRgbWhite ); gc.Clear( Rect() ); TRect rect = Rect(); TInt x, y; x = (rect.Width() / 2) - (KBitmapSize / 2); y = (rect.Height() / 2) - (KBitmapSize / 2); TInt s_width = iBitmap->ScanLineLength(iBitmap->SizeInPixels().iWidth, EColor16MU ) / 4; TInt s_height = iBitmap->SizeInPixels().iHeight; TInt d_width = iTmpBitmap->ScanLineLength(iTmpBitmap->SizeInPixels().iWidth, EColor16MU ) / 4; // TInt d_height = iTmpBitmap->SizeInPixels().iHeight; iBitmap->LockHeap(ETrue); iTmpBitmap->LockHeap(ETrue); TUint32* src = (TUint32*) iBitmap->DataAddress(); TUint32* dst = (TUint32*) iTmpBitmap->DataAddress(); #define GET_R( rgb ) ((rgb >> 16) & 0xff) #define GET_G( rgb ) ((rgb >> 8) & 0xff) #define GET_B( rgb ) (rgb & 0xff) #define SET_R( r ) ((r & 0xff) << 16 ) #define SET_G( g ) ((g & 0xff) << 8 ) #define SET_B( b ) ( b & 0xff) TUint32 alpha = iAlpha * 255; TUint32 alpha1 = (KAlphaMax - iAlpha); for (TInt i = 0; i < s_height; i++) { TUint32* d = dst; TUint32* s = src; for (TInt j = 0; j < s_width; j++) { TUint32 rgb = *s++; TUint32 r = ((GET_R( rgb ) * alpha1) + alpha) >> 8; TUint32 g = ((GET_G( rgb ) * alpha1) + alpha) >> 8; TUint32 b = ((GET_B( rgb ) * alpha1) + alpha) >> 8; rgb = SET_R( r ) + SET_G( g ) + SET_B( b ); *d++ = rgb; } dst += d_width; src += s_width; } iBitmap->UnlockHeap(ETrue); iTmpBitmap->UnlockHeap(ETrue); gc.BitBlt( TPoint( x, y ), iTmpBitmap); gc.CancelClippingRect(); }
void CGUITextureGL::DrawQuad(const CRect &rect, color_t color, CBaseTexture *texture, const CRect *texCoords) { if (texture) { texture->LoadToGPU(); texture->BindToUnit(0); } glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); // Turn Blending On VerifyGLState(); GLubyte col[4]; GLubyte idx[4] = {0, 1, 3, 2}; //determines order of the vertices GLuint vertexVBO; GLuint indexVBO; struct PackedVertex { float x, y, z; float u1, v1; }vertex[4]; if (texture) g_Windowing.EnableShader(SM_TEXTURE); else g_Windowing.EnableShader(SM_DEFAULT); GLint posLoc = g_Windowing.ShaderGetPos(); GLint tex0Loc = g_Windowing.ShaderGetCoord0(); GLint uniColLoc = g_Windowing.ShaderGetUniCol(); // Setup Colors col[0] = (GLubyte)GET_R(color); col[1] = (GLubyte)GET_G(color); col[2] = (GLubyte)GET_B(color); col[3] = (GLubyte)GET_A(color); glUniform4f(uniColLoc, col[0] / 255.0f, col[1] / 255.0f, col[2] / 255.0f, col[3] / 255.0f); // bottom left vertex[0].x = rect.x1; vertex[0].y = rect.y1; vertex[0].z = 0; // bottom right vertex[1].x = rect.x2; vertex[1].y = rect.y1; vertex[1].z = 0; // top right vertex[2].x = rect.x2; vertex[2].y = rect.y2; vertex[2].z = 0; // top left vertex[3].x = rect.x1; vertex[3].y = rect.y2; vertex[3].z = 0; if (texture) { CRect coords = texCoords ? *texCoords : CRect(0.0f, 0.0f, 1.0f, 1.0f); vertex[0].u1 = vertex[3].u1 = coords.x1; vertex[0].v1 = vertex[1].v1 = coords.y1; vertex[1].u1 = vertex[2].u1 = coords.x2; vertex[2].v1 = vertex[3].v1 = coords.y2; } glGenBuffers(1, &vertexVBO); glBindBuffer(GL_ARRAY_BUFFER, vertexVBO); glBufferData(GL_ARRAY_BUFFER, sizeof(PackedVertex)*4, &vertex[0], GL_STATIC_DRAW); glVertexAttribPointer(posLoc, 3, GL_FLOAT, 0, sizeof(PackedVertex), BUFFER_OFFSET(offsetof(PackedVertex, x))); glEnableVertexAttribArray(posLoc); if (texture) { glVertexAttribPointer(tex0Loc, 2, GL_FLOAT, 0, sizeof(PackedVertex), BUFFER_OFFSET(offsetof(PackedVertex, u1))); glEnableVertexAttribArray(tex0Loc); } glGenBuffers(1, &indexVBO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexVBO); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLubyte)*4, idx, GL_STATIC_DRAW); glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, 0); glDisableVertexAttribArray(posLoc); if (texture) glDisableVertexAttribArray(tex0Loc); glBindBuffer(GL_ARRAY_BUFFER, 0); glDeleteBuffers(1, &vertexVBO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glDeleteBuffers(1, &indexVBO); g_Windowing.DisableShader(); }
void CGUITextureGLES::DrawQuad(const CRect &rect, color_t color, CBaseTexture *texture, const CRect *texCoords) { CRenderSystemGLES *renderSystem = dynamic_cast<CRenderSystemGLES*>(&CServiceBroker::GetRenderSystem()); if (texture) { texture->LoadToGPU(); texture->BindToUnit(0); } glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); // Turn Blending On VerifyGLState(); GLubyte col[4]; GLfloat ver[4][3]; GLfloat tex[4][2]; GLubyte idx[4] = {0, 1, 3, 2}; //determines order of triangle strip if (texture) renderSystem->EnableGUIShader(SM_TEXTURE); else renderSystem->EnableGUIShader(SM_DEFAULT); GLint posLoc = renderSystem->GUIShaderGetPos(); GLint tex0Loc = renderSystem->GUIShaderGetCoord0(); GLint uniColLoc= renderSystem->GUIShaderGetUniCol(); glVertexAttribPointer(posLoc, 3, GL_FLOAT, 0, 0, ver); if (texture) glVertexAttribPointer(tex0Loc, 2, GL_FLOAT, 0, 0, tex); glEnableVertexAttribArray(posLoc); if (texture) glEnableVertexAttribArray(tex0Loc); // Setup Colors col[0] = (GLubyte)GET_R(color); col[1] = (GLubyte)GET_G(color); col[2] = (GLubyte)GET_B(color); col[3] = (GLubyte)GET_A(color); glUniform4f(uniColLoc, col[0] / 255.0f, col[1] / 255.0f, col[2] / 255.0f, col[3] / 255.0f); ver[0][0] = ver[3][0] = rect.x1; ver[0][1] = ver[1][1] = rect.y1; ver[1][0] = ver[2][0] = rect.x2; ver[2][1] = ver[3][1] = rect.y2; ver[0][2] = ver[1][2] = ver[2][2] = ver[3][2]= 0; if (texture) { // Setup texture coordinates CRect coords = texCoords ? *texCoords : CRect(0.0f, 0.0f, 1.0f, 1.0f); tex[0][0] = tex[3][0] = coords.x1; tex[0][1] = tex[1][1] = coords.y1; tex[1][0] = tex[2][0] = coords.x2; tex[2][1] = tex[3][1] = coords.y2; } glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, idx); glDisableVertexAttribArray(posLoc); if (texture) glDisableVertexAttribArray(tex0Loc); renderSystem->DisableGUIShader(); }
void CGUITextureGLES::DrawQuad(const CRect &rect, color_t color, CBaseTexture *texture, const CRect *texCoords) { if (texture) { glActiveTexture(GL_TEXTURE0); texture->LoadToGPU(); glBindTexture(GL_TEXTURE_2D, texture->GetTextureObject()); glEnable(GL_TEXTURE_2D); } else glDisable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); // Turn Blending On VerifyGLState(); GLfloat col[4][4]; GLfloat ver[4][3]; GLfloat tex[4][2]; GLubyte idx[4] = {0, 1, 3, 2}; //determines order of triangle strip g_Windowing.EnableGUIShader(SM_TEXTURE); GLint posLoc = g_Windowing.GUIShaderGetPos(); GLint colLoc = g_Windowing.GUIShaderGetCol(); GLint tex0Loc = g_Windowing.GUIShaderGetCoord0(); glVertexAttribPointer(posLoc, 3, GL_FLOAT, 0, 0, ver); glVertexAttribPointer(colLoc, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, col); glVertexAttribPointer(tex0Loc, 2, GL_FLOAT, 0, 0, tex); glEnableVertexAttribArray(posLoc); glEnableVertexAttribArray(tex0Loc); glEnableVertexAttribArray(colLoc); for (int i=0; i<4; i++) { // Setup Colour Values col[i][0] = (GLubyte)GET_R(color); col[i][1] = (GLubyte)GET_G(color); col[i][2] = (GLubyte)GET_B(color); col[i][3] = (GLubyte)GET_A(color); } // Setup vertex position values // ver[0][3] = ver[1][3] = ver[2][3] = ver[3][3] = 0.0f; // FIXME, ver has only 3 elements - this is not correct ver[0][0] = ver[3][0] = rect.x1; ver[0][1] = ver[1][1] = rect.y1; ver[1][0] = ver[2][0] = rect.x2; ver[2][1] = ver[3][1] = rect.y2; // Setup texture coordinates CRect coords = texCoords ? *texCoords : CRect(0.0f, 0.0f, 1.0f, 1.0f); tex[0][0] = tex[3][0] = coords.x1; tex[0][1] = tex[1][1] = coords.y1; tex[1][0] = tex[2][0] = coords.x2; tex[2][1] = tex[3][1] = coords.y2; glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, idx); glDisableVertexAttribArray(posLoc); glDisableVertexAttribArray(colLoc); glDisableVertexAttribArray(tex0Loc); g_Windowing.DisableGUIShader(); if (texture) glDisable(GL_TEXTURE_2D); }
void CAPet::Mount( bool bMount ) { m_bMount = bMount; // 주인관련 처리 if( m_pOwner ) { CArea* area = m_pOwner->m_pArea; if( bMount ) // 탈때 { if(m_pArea != NULL) // NULL이 아니면 실행, NULL이면 건너뛸것. m_pArea->MoveChar( this, GET_YLAYER(m_pOwner), GET_X(m_pOwner), GET_Z(m_pOwner), GET_H(m_pOwner), GET_R(m_pOwner), MSG_MOVE_STOP, NULL ); // 소환 해제 while ( m_pOwner->m_elementalList) m_pOwner->UnsummonElemental(m_pOwner->m_elementalList); } if(area) { { // 사라졌다 나타나기 CNetMsg::SP rmsg(new CNetMsg); DisappearMsg(rmsg, this); area->SendToCell(rmsg, this, true); } { CNetMsg::SP rmsg(new CNetMsg); AppearMsg(rmsg, this); area->SendToCell(rmsg, this, true); } } if (m_pArea) { CNetMsg::SP rmsg(new CNetMsg); ExAPetStatusMsg( rmsg, this ); m_pArea->SendToCell(rmsg, GetOwner(), true); } m_pOwner->CalcStatus(true); { CNetMsg::SP rmsg(new CNetMsg); ExAPetFuntionMsg( rmsg, MSG_SUB_MOUNT_REP, this , 0 ); m_pOwner->m_pArea->SendToCell(rmsg, m_pOwner, true); } } }
void CSlideShowPic::Render(float *x, float *y, CBaseTexture* pTexture, color_t color) { #ifdef HAS_DX static const DWORD FVF_VERTEX = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1; Vertex vertex[5]; for (int i = 0; i < 4; i++) { vertex[i].pos = XMFLOAT3( x[i], y[i], 0); CD3DHelper::XMStoreColor(&vertex[i].color, color); vertex[i].texCoord = XMFLOAT2(0.0f, 0.0f); vertex[i].texCoord2 = XMFLOAT2(0.0f, 0.0f); } if (pTexture) { vertex[1].texCoord.x = vertex[2].texCoord.x = (float) pTexture->GetWidth() / pTexture->GetTextureWidth(); vertex[2].texCoord.y = vertex[3].texCoord.y = (float) pTexture->GetHeight() / pTexture->GetTextureHeight(); } else { vertex[1].texCoord.x = vertex[2].texCoord.x = 1.0f; vertex[2].texCoord.y = vertex[3].texCoord.y = 1.0f; } vertex[4] = vertex[0]; // Not used when pTexture != NULL CGUIShaderDX* pGUIShader = g_Windowing.GetGUIShader(); pGUIShader->Begin(SHADER_METHOD_RENDER_TEXTURE_BLEND); // Set state to render the image if (pTexture) { pTexture->LoadToGPU(); CDXTexture* dxTexture = reinterpret_cast<CDXTexture*>(pTexture); ID3D11ShaderResourceView* shaderRes = dxTexture->GetShaderResource(); pGUIShader->SetShaderViews(1, &shaderRes); pGUIShader->DrawQuad(vertex[0], vertex[1], vertex[2], vertex[3]); } else { if (!UpdateVertexBuffer(vertex)) return; ID3D11DeviceContext* pContext = g_Windowing.Get3D11Context(); unsigned stride = sizeof(Vertex); unsigned offset = 0; pContext->IASetVertexBuffers(0, 1, &m_vb, &stride, &offset); pContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP); pGUIShader->Draw(5, 0); pGUIShader->RestoreBuffers(); } #elif defined(HAS_GL) if (pTexture) { int unit = 0; pTexture->LoadToGPU(); pTexture->BindToUnit(unit++); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); // Turn Blending On // diffuse coloring glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); if(g_Windowing.UseLimitedColor()) { // compress range pTexture->BindToUnit(unit++); // dummy bind const GLfloat rgba1[4] = {(235.0 - 16.0f) / 255.0f, (235.0 - 16.0f) / 255.0f, (235.0 - 16.0f) / 255.0f, 1.0f}; glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE , GL_COMBINE); glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, rgba1); glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB , GL_MODULATE); glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB , GL_PREVIOUS); glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE1_RGB , GL_CONSTANT); glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB , GL_SRC_COLOR); glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_RGB , GL_SRC_COLOR); glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_ALPHA , GL_REPLACE); glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA , GL_PREVIOUS); // transition pTexture->BindToUnit(unit++); // dummy bind const GLfloat rgba2[4] = {16.0f / 255.0f, 16.0f / 255.0f, 16.0f / 255.0f, 0.0f}; glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE , GL_COMBINE); glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, rgba2); glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB , GL_ADD); glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB , GL_PREVIOUS); glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE1_RGB , GL_CONSTANT); glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB , GL_SRC_COLOR); glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_RGB , GL_SRC_COLOR); glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_ALPHA , GL_REPLACE); glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA , GL_PREVIOUS); } } else glDisable(GL_TEXTURE_2D); glPolygonMode(GL_FRONT_AND_BACK, pTexture ? GL_FILL : GL_LINE); glBegin(GL_QUADS); float u1 = 0, u2 = 1, v1 = 0, v2 = 1; if (pTexture) { u2 = (float)pTexture->GetWidth() / pTexture->GetTextureWidth(); v2 = (float)pTexture->GetHeight() / pTexture->GetTextureHeight(); } glColor4ub((GLubyte)GET_R(color), (GLubyte)GET_G(color), (GLubyte)GET_B(color), (GLubyte)GET_A(color)); glTexCoord2f(u1, v1); glVertex3f(x[0], y[0], 0); // Bottom-left vertex (corner) glColor4ub((GLubyte)GET_R(color), (GLubyte)GET_G(color), (GLubyte)GET_B(color), (GLubyte)GET_A(color)); glTexCoord2f(u2, v1); glVertex3f(x[1], y[1], 0); // Bottom-right vertex (corner) glColor4ub((GLubyte)GET_R(color), (GLubyte)GET_G(color), (GLubyte)GET_B(color), (GLubyte)GET_A(color)); glTexCoord2f(u2, v2); glVertex3f(x[2], y[2], 0); // Top-right vertex (corner) glColor4ub((GLubyte)GET_R(color), (GLubyte)GET_G(color), (GLubyte)GET_B(color), (GLubyte)GET_A(color)); glTexCoord2f(u1, v2); glVertex3f(x[3], y[3], 0); glEnd(); #elif defined(HAS_GLES) if (pTexture) { pTexture->LoadToGPU(); pTexture->BindToUnit(0); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); // Turn Blending On g_Windowing.EnableGUIShader(SM_TEXTURE); } else { glDisable(GL_TEXTURE_2D); g_Windowing.EnableGUIShader(SM_DEFAULT); } float u1 = 0, u2 = 1, v1 = 0, v2 = 1; if (pTexture) { u2 = (float)pTexture->GetWidth() / pTexture->GetTextureWidth(); v2 = (float)pTexture->GetHeight() / pTexture->GetTextureHeight(); } GLubyte col[4]; GLfloat ver[4][3]; GLfloat tex[4][2]; GLubyte idx[4] = {0, 1, 3, 2}; //determines order of triangle strip GLint posLoc = g_Windowing.GUIShaderGetPos(); GLint tex0Loc = g_Windowing.GUIShaderGetCoord0(); GLint uniColLoc= g_Windowing.GUIShaderGetUniCol(); glVertexAttribPointer(posLoc, 3, GL_FLOAT, 0, 0, ver); glVertexAttribPointer(tex0Loc, 2, GL_FLOAT, 0, 0, tex); glEnableVertexAttribArray(posLoc); glEnableVertexAttribArray(tex0Loc); // Setup Colour values col[0] = (GLubyte)GET_R(color); col[1] = (GLubyte)GET_G(color); col[2] = (GLubyte)GET_B(color); col[3] = (GLubyte)GET_A(color); for (int i=0; i<4; i++) { // Setup vertex position values ver[i][0] = x[i]; ver[i][1] = y[i]; ver[i][2] = 0.0f; } // Setup texture coordinates tex[0][0] = tex[3][0] = u1; tex[0][1] = tex[1][1] = v1; tex[1][0] = tex[2][0] = u2; tex[2][1] = tex[3][1] = v2; glUniform4f(uniColLoc,(col[0] / 255.0f), (col[1] / 255.0f), (col[2] / 255.0f), (col[3] / 255.0f)); glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, idx); glDisableVertexAttribArray(posLoc); glDisableVertexAttribArray(tex0Loc); g_Windowing.DisableGUIShader(); #else // SDL render g_Windowing.BlitToScreen(m_pImage, NULL, NULL); #endif }
/*********************************************************************** * plugin main ppu thread ***********************************************************************/ static void vsh_menu_thread(uint64_t arg) { #ifdef DEBUG dbg_init(); dbg_printf("programstart:\n"); #endif uint16_t oldpad = 0, curpad = 0; CellPadData pdata; // wait for XMB, feedback sys_timer_sleep(13); //vshtask_notify("sprx running..."); play_rco_sound("system_plugin", "snd_trophy"); #ifdef HAVE_STARFIELD init_once(/* stars */); #endif // custom bg_color init a = GET_A(bg_color_menu[1]); r = GET_R(bg_color_menu[1]); g = GET_G(bg_color_menu[1]); b = GET_B(bg_color_menu[1]); while(1) { // if VSH Menu is running, we get pad data over our MyPadGetData() // else, we use the vsh pad_data struct if(menu_running) MyPadGetData(0, &pdata); else VSHPadGetData(&pdata); // if pad_data and we are in XMB(vshmain_EB757101() == 0) if((pdata.len > 0) && (vshmain_EB757101() == 0) ) { curpad = (pdata.button[2] | (pdata.button[3] << 8)); if((curpad & PAD_SELECT) && (curpad != oldpad)) { switch(menu_running) { // VSH Menu not running, start VSH Menu case 0: // main view and start on first entry view = line = 0; // pause_RSX_rendering(); // create VSH Menu heap memory from memory container 1("app") create_heap(64); // 64 MB // initialize VSH Menu graphic (init drawing context, alloc buffers, blah, blah, blah...) init_graphic(); // stop vsh pad start_stop_vsh_pad(0); // set menu_running menu_running = 1; break; // VSH Menu is running, stop VSH Menu case 1: stop_VSH_Menu(); // restart vsh pad start_stop_vsh_pad(1); break; } oldpad = 0; sys_timer_usleep(300000); } // VSH Menu is running, draw menu / check pad if(menu_running) { #ifdef DEBUG dbg_printf("%p\n", pdata); #endif draw_frame(&pdata); flip_frame(); if(curpad != oldpad) { if(curpad & PAD_UP) { if(line <= 0){ line = 0; }else{ line--; play_rco_sound("system_plugin", "snd_cursor"); } } if(curpad & PAD_DOWN) { if(line >= max_menu[view]-1){ line = max_menu[view]-1; }else{ line++; play_rco_sound("system_plugin", "snd_cursor"); } } if(curpad & PAD_LEFT || curpad & PAD_RIGHT) do_leftright_action(curpad); if(curpad & PAD_CROSS) do_menu_action(); } // ... sys_timer_usleep(30); } // end VSH Menu is running oldpad = curpad; }else{ oldpad = 0; } } #ifdef DEBUG dbg_fini(); #endif sys_ppu_thread_exit(0); }
void CParticle::render() { // If particle isn't alive, then there is nothing to render if(isAlive() == false) return; // Can't render a particle that does not have a valid texture if(mTexture.getId() == TEXTURE_NOT_LOADED) return; // This OpenGL functions makes the Z-buffer "read only". That means OpenGL will // use current z-buffer values to determine if a particle should be rendered or not, BUT, // if it does render a particle it will NOT set any z-buffer values. Why do we do this? // Well we want the particles to blend, and not cover each other up. So now we can // render them in the same Z-depth and they will blend, but at the same time, they // won't render over top of anything with a lesser Z-depth glDepthMask(false); BYTE red, green, blue; // Set the color based on the life of the particle if(mLife < 1.0f) { // If the particle has less than a second to live, we will // decrease the R, G, and B value of it's color by multipling // by "mLife", this will in turn fade the particle to black, which // is our applications background color red = BYTE(GET_R(mColor) * mLife); green = BYTE(GET_G(mColor) * mLife); blue = BYTE(GET_B(mColor) * mLife); } else { // Just get the RGB components of the color red = GET_R(mColor); green = GET_G(mColor); blue = GET_B(mColor); } // Set the color for rendering glColor3ub(red, green, blue); // Set the texture for rendering mTexture.select(); glPushMatrix(); // Move to the world position of where to draw the particle glTranslatef(mPos.x, mPos.y, mPos.z); float halfSize = mSize * 0.5f; // Draw the particle glBegin(GL_QUADS); glTexCoord2f(0.0f, 1.0f); glVertex3f(-halfSize, halfSize, 0.0f); // Top left vertex glTexCoord2f(0.0f, 0.0f); glVertex3f(-halfSize, -halfSize, 0.0f); // Bottom left vertex glTexCoord2f(1.0f, 0.0f); glVertex3f(halfSize, -halfSize, 0.0f); // Bottom right vertex glTexCoord2f(1.0f, 1.0f); glVertex3f(halfSize, halfSize, 0.0f); // Top right vertex glEnd(); glPopMatrix(); glDepthMask(true); // Put the Z-buffer back into it's normal "Z-read and Z-write" state }
void CGUITextureGLES::DrawQuad(const CRect &rect, color_t color, CBaseTexture *texture, const CRect *texCoords) { if (texture) { glActiveTexture(GL_TEXTURE0); texture->LoadToGPU(); glBindTexture(GL_TEXTURE_2D, texture->GetTextureObject()); } glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); // Turn Blending On VerifyGLState(); GLubyte col[4][4]; GLfloat ver[4][3]; GLfloat tex[4][2]; GLubyte idx[4] = {0, 1, 3, 2}; //determines order of triangle strip if (texture) g_Windowing.EnableGUIShader(SM_TEXTURE); else g_Windowing.EnableGUIShader(SM_DEFAULT); GLint posLoc = g_Windowing.GUIShaderGetPos(); GLint colLoc = g_Windowing.GUIShaderGetCol(); GLint tex0Loc = g_Windowing.GUIShaderGetCoord0(); glVertexAttribPointer(posLoc, 3, GL_FLOAT, 0, 0, ver); if(colLoc >= 0) glVertexAttribPointer(colLoc, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, col); if (texture) glVertexAttribPointer(tex0Loc, 2, GL_FLOAT, 0, 0, tex); glEnableVertexAttribArray(posLoc); if (texture) glEnableVertexAttribArray(tex0Loc); if(colLoc >= 0) glEnableVertexAttribArray(colLoc); for (int i=0; i<4; i++) { // Setup Colour Values col[i][0] = (GLubyte)GET_R(color); col[i][1] = (GLubyte)GET_G(color); col[i][2] = (GLubyte)GET_B(color); col[i][3] = (GLubyte)GET_A(color); } // Setup vertex position values #define ROUND_TO_PIXEL(x) (float)(MathUtils::round_int(x)) ver[0][0] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalXCoord(rect.x1, rect.y1)); ver[0][1] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalYCoord(rect.x1, rect.y1)); ver[0][2] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalZCoord(rect.x1, rect.y1)); ver[1][0] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalXCoord(rect.x2, rect.y1)); ver[1][1] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalYCoord(rect.x2, rect.y1)); ver[1][2] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalZCoord(rect.x2, rect.y1)); ver[2][0] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalXCoord(rect.x2, rect.y2)); ver[2][1] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalYCoord(rect.x2, rect.y2)); ver[2][2] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalZCoord(rect.x2, rect.y2)); ver[3][0] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalXCoord(rect.x1, rect.y2)); ver[3][1] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalYCoord(rect.x1, rect.y2)); ver[3][2] = ROUND_TO_PIXEL(g_graphicsContext.ScaleFinalZCoord(rect.x1, rect.y2)); if (texture) { // Setup texture coordinates CRect coords = texCoords ? *texCoords : CRect(0.0f, 0.0f, 1.0f, 1.0f); tex[0][0] = tex[3][0] = coords.x1; tex[0][1] = tex[1][1] = coords.y1; tex[1][0] = tex[2][0] = coords.x2; tex[2][1] = tex[3][1] = coords.y2; } glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, idx); glDisableVertexAttribArray(posLoc); if(colLoc >= 0) glDisableVertexAttribArray(colLoc); if (texture) glDisableVertexAttribArray(tex0Loc); g_Windowing.DisableGUIShader(); }
void CGUITextureD3D::Begin(color_t color) { int unit = 0; CBaseTexture* texture = m_texture.m_textures[m_currentFrame]; LPDIRECT3DDEVICE9 p3DDevice = g_Windowing.Get3DDevice(); texture->LoadToGPU(); if (m_diffuse.size()) m_diffuse.m_textures[0]->LoadToGPU(); // Set state to render the image texture->BindToUnit(unit); p3DDevice->SetTextureStageState( unit, D3DTSS_COLOROP , D3DTOP_MODULATE ); p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG1, D3DTA_TEXTURE ); p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAOP , D3DTOP_MODULATE ); p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); unit++; if (m_diffuse.size()) { m_diffuse.m_textures[0]->BindToUnit(1); p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG1, D3DTA_TEXTURE ); p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG2, D3DTA_CURRENT ); p3DDevice->SetTextureStageState( unit, D3DTSS_COLOROP , D3DTOP_MODULATE ); p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAARG2, D3DTA_CURRENT ); p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAOP , D3DTOP_MODULATE ); unit++; } if(g_Windowing.UseLimitedColor()) { m_col = D3DCOLOR_RGBA(GET_R(color) * (235 - 16) / 255 , GET_G(color) * (235 - 16) / 255 , GET_B(color) * (235 - 16) / 255 , GET_A(color)); p3DDevice->SetTextureStageState( unit, D3DTSS_COLOROP , D3DTOP_ADD ); p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG1, D3DTA_CURRENT) ; p3DDevice->SetRenderState( D3DRS_TEXTUREFACTOR, D3DCOLOR_RGBA(16,16,16, 0) ); p3DDevice->SetTextureStageState( unit, D3DTSS_COLORARG2, D3DTA_TFACTOR ); unit++; } else m_col = color; p3DDevice->SetTextureStageState( unit, D3DTSS_COLOROP, D3DTOP_DISABLE); p3DDevice->SetTextureStageState( unit, D3DTSS_ALPHAOP, D3DTOP_DISABLE); p3DDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE ); p3DDevice->SetRenderState( D3DRS_ALPHAREF, 0 ); p3DDevice->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL ); p3DDevice->SetRenderState( D3DRS_ZENABLE, FALSE ); p3DDevice->SetRenderState( D3DRS_FOGENABLE, FALSE ); p3DDevice->SetRenderState( D3DRS_FOGTABLEMODE, D3DFOG_NONE ); p3DDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID ); p3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ); p3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ); p3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); p3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); p3DDevice->SetRenderState( D3DRS_LIGHTING, FALSE); p3DDevice->SetFVF( D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX2 ); }
int32_t GLOBALDATA::get_avg_bgcolor(int32_t x1, int32_t y1, int32_t x2, int32_t y2, double xv, double yv) { // Movement int32_t mvx = ROUND(10. * xv); // eliminate slow movement int32_t mvy = ROUND(10. * yv); // eliminate slow movement bool mv_left = mvx < 0; bool mv_right = mvx > 0; bool mv_up = mvy < 0; bool mv_down = mvy > 0; // Boundaries int32_t min_x = 1; int32_t max_x = env.screenWidth - 2; int32_t min_y = env.isBoxed ? MENUHEIGHT + 1 : MENUHEIGHT; int32_t max_y = env.screenHeight - 2; // Coordinates int32_t left = std::max(std::min(x1, x2), min_x); int32_t right = std::min(std::max(x1, x2), max_x); int32_t centre = (x1 + x2) / 2; int32_t top = std::max(std::min(y1, y2), min_y); int32_t bottom = std::min(std::max(y1, y2), max_y); int32_t middle = (y1 + y2) / 2; // Colors: int32_t col_tl, col_tc, col_tr; // top row int32_t col_ml, col_mc, col_mr; // middle row int32_t col_bl, col_bc, col_br; // bottom row int32_t r = 0, g = 0, b = 0; // Get Sky or Terrain colour, whatever fits: /*--------------------- --- Left side --- ---------------------*/ if ( PINK == (col_tl = getpixel(terrain, left, top)) ) col_tl = getpixel(env.sky, left, top); if ( PINK == (col_ml = getpixel(terrain, left, middle)) ) col_ml = getpixel(env.sky, left, middle); if ( PINK == (col_bl = getpixel(terrain, left, bottom)) ) col_bl = getpixel(env.sky, left, bottom); /*--------------------- --- The Center --- ---------------------*/ if ( PINK == (col_tc = getpixel(terrain, centre, top)) ) col_tc = getpixel(env.sky, centre, top); if ( PINK == (col_mc = getpixel(terrain, centre, middle)) ) col_mc = getpixel(env.sky, centre, middle); if ( PINK == (col_bc = getpixel(terrain, centre, bottom)) ) col_bc = getpixel(env.sky, centre, bottom); /*---------------------- --- Right side --- ----------------------*/ if ( PINK == (col_tr = getpixel(terrain, right, top)) ) col_tr = getpixel(env.sky, right, top); if ( PINK == (col_mr = getpixel(terrain, right, middle)) ) col_mr = getpixel(env.sky, right, middle); if ( PINK == (col_br = getpixel(terrain, right, bottom)) ) col_br = getpixel(env.sky, right, bottom); // Fetch the rgb parts, according to movement: /* --- X-Movement --- */ if (mv_left) { // Movement to the left, weight left side colour twice r += (GET_R(col_tl) + GET_R(col_ml) + GET_R(col_bl)) * 2; g += (GET_G(col_tl) + GET_G(col_ml) + GET_G(col_bl)) * 2; b += (GET_B(col_tl) + GET_B(col_ml) + GET_B(col_bl)) * 2; // The others are counted once r += GET_R(col_tc) + GET_R(col_mc) + GET_R(col_bc) + GET_R(col_tr) + GET_R(col_mr) + GET_R(col_br); g += GET_G(col_tc) + GET_G(col_mc) + GET_G(col_bc) + GET_G(col_tr) + GET_G(col_mr) + GET_G(col_br); b += GET_B(col_tc) + GET_B(col_mc) + GET_B(col_bc) + GET_B(col_tr) + GET_B(col_mr) + GET_B(col_br); } else if (mv_right) { // Movement to the right, weight right side colour twice r += (GET_R(col_tr) + GET_R(col_mr) + GET_R(col_br)) * 2; g += (GET_G(col_tr) + GET_G(col_mr) + GET_G(col_br)) * 2; b += (GET_B(col_tr) + GET_B(col_mr) + GET_B(col_br)) * 2; // The others are counted once r += GET_R(col_tc) + GET_R(col_mc) + GET_R(col_bc) + GET_R(col_tl) + GET_R(col_ml) + GET_R(col_bl); g += GET_G(col_tc) + GET_G(col_mc) + GET_G(col_bc) + GET_G(col_tl) + GET_G(col_ml) + GET_G(col_bl); b += GET_B(col_tc) + GET_B(col_mc) + GET_B(col_bc) + GET_B(col_tl) + GET_B(col_ml) + GET_B(col_bl); } else { // No x-movement, weight centre colour twice r += (GET_R(col_tc) + GET_R(col_mc) + GET_R(col_bc)) * 2; g += (GET_G(col_tc) + GET_G(col_mc) + GET_G(col_bc)) * 2; b += (GET_B(col_tc) + GET_B(col_mc) + GET_B(col_bc)) * 2; // The others are counted once r += GET_R(col_tl) + GET_R(col_ml) + GET_R(col_bl) + GET_R(col_tr) + GET_R(col_mr) + GET_R(col_br); g += GET_G(col_tl) + GET_G(col_ml) + GET_G(col_bl) + GET_G(col_tr) + GET_G(col_mr) + GET_G(col_br); b += GET_B(col_tl) + GET_B(col_ml) + GET_B(col_bl) + GET_B(col_tr) + GET_B(col_mr) + GET_B(col_br); } /* --- Y-Movement --- */ if (mv_up) { // Movement upwards, weight top side colour twice r += (GET_R(col_tl) + GET_R(col_tc) + GET_R(col_tr)) * 2; g += (GET_G(col_tl) + GET_G(col_tc) + GET_G(col_tr)) * 2; b += (GET_B(col_tl) + GET_B(col_tc) + GET_B(col_tr)) * 2; // The others are counted once r += GET_R(col_ml) + GET_R(col_mc) + GET_R(col_mr) + GET_R(col_bl) + GET_R(col_bc) + GET_R(col_br); g += GET_G(col_ml) + GET_G(col_mc) + GET_G(col_mr) + GET_G(col_bl) + GET_G(col_bc) + GET_G(col_br); b += GET_B(col_ml) + GET_B(col_mc) + GET_B(col_mr) + GET_B(col_bl) + GET_B(col_bc) + GET_B(col_br); } else if (mv_down) { // Movement downwards, weight bottom side colour twice r += (GET_R(col_bl) + GET_R(col_bc) + GET_R(col_br)) * 2; g += (GET_G(col_bl) + GET_G(col_bc) + GET_G(col_br)) * 2; b += (GET_B(col_bl) + GET_B(col_bc) + GET_B(col_br)) * 2; // The others are counted once r += GET_R(col_ml) + GET_R(col_mc) + GET_R(col_mr) + GET_R(col_tl) + GET_R(col_tc) + GET_R(col_tr); g += GET_G(col_ml) + GET_G(col_mc) + GET_G(col_mr) + GET_G(col_tl) + GET_G(col_tc) + GET_G(col_tr); b += GET_B(col_ml) + GET_B(col_mc) + GET_B(col_mr) + GET_B(col_tl) + GET_B(col_tc) + GET_B(col_tr); } else { // No y-movement, weight middle colour twice r += (GET_R(col_ml) + GET_R(col_mc) + GET_R(col_mr)) * 2; g += (GET_G(col_ml) + GET_G(col_mc) + GET_G(col_mr)) * 2; b += (GET_B(col_ml) + GET_B(col_mc) + GET_B(col_mr)) * 2; // The others are counted once r += GET_R(col_tl) + GET_R(col_tc) + GET_R(col_tr) + GET_R(col_bl) + GET_R(col_bc) + GET_R(col_br); g += GET_G(col_tl) + GET_G(col_tc) + GET_G(col_tr) + GET_G(col_bl) + GET_G(col_bc) + GET_G(col_br); b += GET_B(col_tl) + GET_B(col_tc) + GET_B(col_tr) + GET_B(col_bl) + GET_B(col_bc) + GET_B(col_br); } /* I know this looks weird, but what we now have is some kind of summed * matrix, which is always the same: * Let's assume that xv and yv are both 0.0, so no movement is happening. * The result is: (In counted times) * 2|3|2 ( = 7) * -+-+- * 3|4|3 ( = 10) * -+-+- * 2|3|2 ( = 7) * = 24 * And it is always 24, no matter which movement combination you try */ r /= 24; g /= 24; b /= 24; return makecol(r > 0xff ? 0xff : r, g > 0xff ? 0xff : g, b > 0xff ? 0xff : b); }
void CGUITextureGLES::Begin(color_t color) { CBaseTexture* texture = m_texture.m_textures[m_currentFrame]; glActiveTexture(GL_TEXTURE0); texture->LoadToGPU(); if (m_diffuse.size()) m_diffuse.m_textures[0]->LoadToGPU(); glBindTexture(GL_TEXTURE_2D, texture->GetTextureObject()); // Setup Colors for (int i = 0; i < 4; i++) { m_col[i][0] = (GLubyte)GET_R(color); m_col[i][1] = (GLubyte)GET_G(color); m_col[i][2] = (GLubyte)GET_B(color); m_col[i][3] = (GLubyte)GET_A(color); } bool hasAlpha = m_texture.m_textures[m_currentFrame]->HasAlpha() || m_col[0][3] < 255; if (m_diffuse.size()) { if (m_col[0][0] == 255 && m_col[0][1] == 255 && m_col[0][2] == 255 && m_col[0][3] == 255 ) { g_Windowing.EnableGUIShader(SM_MULTI); } else { g_Windowing.EnableGUIShader(SM_MULTI_BLENDCOLOR); } hasAlpha |= m_diffuse.m_textures[0]->HasAlpha(); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, m_diffuse.m_textures[0]->GetTextureObject()); GLint tex1Loc = g_Windowing.GUIShaderGetCoord1(); glVertexAttribPointer(tex1Loc, 2, GL_FLOAT, 0, 0, m_tex1); glEnableVertexAttribArray(tex1Loc); hasAlpha = true; } else { if ( hasAlpha ) { g_Windowing.EnableGUIShader(SM_TEXTURE); } else { g_Windowing.EnableGUIShader(SM_TEXTURE_NOBLEND); } } GLint posLoc = g_Windowing.GUIShaderGetPos(); GLint colLoc = g_Windowing.GUIShaderGetCol(); GLint tex0Loc = g_Windowing.GUIShaderGetCoord0(); glVertexAttribPointer(posLoc, 3, GL_FLOAT, 0, 0, m_vert); if(colLoc >= 0) glVertexAttribPointer(colLoc, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, m_col); glVertexAttribPointer(tex0Loc, 2, GL_FLOAT, 0, 0, m_tex0); glEnableVertexAttribArray(posLoc); if(colLoc >= 0) glEnableVertexAttribArray(colLoc); glEnableVertexAttribArray(tex0Loc); if ( hasAlpha ) { glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable( GL_BLEND ); } else { glDisable(GL_BLEND); } }
void ProcDead(CNPC* df, CCharacter* of) { CPC* opc = NULL; CNPC* onpc = NULL; CPet* opet = NULL; CElemental* oelemental = NULL; CAPet* oapet = NULL; bool bNPCKilledNPC = false; // npc가 npc를 죽인 경우 꼭 이것을 true로 해줘야한다. switch (of->m_type) { case MSG_CHAR_PC: opc = TO_PC(of); if (opc == NULL) goto END_PROC; break; case MSG_CHAR_NPC: onpc = TO_NPC(of); break; case MSG_CHAR_PET: opet = TO_PET(of); opc = opet->GetOwner(); if (opc == NULL) goto END_PROC; break; case MSG_CHAR_ELEMENTAL: oelemental = TO_ELEMENTAL(of); opc = oelemental->GetOwner(); if (opc == NULL) goto END_PROC; break; case MSG_CHAR_APET: oapet = TO_APET(of); opc = oapet->GetOwner(); if( opc == NULL ) goto END_PROC; break; default: goto END_PROC; } #ifdef SYSTEM_TREASURE_MAP // if( df->m_idNum == TREASURE_BOX_NPC_INDEX) // 보물상자 npc를 잡았다. 정보를 없애주자. // df->m_pZone->RemoveTreasureBoxNpc(df ); #endif // 공주구출 퀘스트 (퍼스널 던전 2) 실패 ProcDead_PD2(df); // 죽은 것이 테이밍 몬스터일 경우 if (df->Check_MobFlag( STATE_MONSTER_TAMING ) ) { CPC* owner = NULL; // 몬스터를 테이밍한 캐릭터 owner = df->GetOwner(); // 몬스터가 테이밍 되었는지 확인 // 주인이 공격하고 있는 타겟을 지워준다. 주인이 테이밍 중이 아닌걸로 바꿔준다. if ( owner ) { owner->DeleteSlave( df ); } goto SKIP_DROP; } // 죽인 것이 테이밍 몬스터일 경우 if (onpc && onpc->Check_MobFlag( STATE_MONSTER_TAMING ) ) { CPC* owner = NULL; // 몬스터를 테이밍한 캐릭터 owner = onpc->GetOwner(); // 몬스터가 테이밍 되었는지 확인 // 주인이 공격하고 있는 타겟을 지워준다. if ( owner ) { owner->SetOwners_target(NULL); // opc에 주인을 넣어준다. opc = owner; bNPCKilledNPC = true; } else goto SKIP_DROP; } else if( onpc && onpc->GetOwner() ) // 공격한 NPC가 오너가 있다면 { CNPC* sumNpc = onpc->GetOwner()->GetSummonNpc(onpc); if( sumNpc ) { if( sumNpc->Check_MobFlag((STATE_MONSTER_MERCENARY)) ) { sumNpc->GetOwner()->SetSummonOwners_target(NULL); } opc = onpc->GetOwner(); bNPCKilledNPC = true; } else goto SKIP_DROP; } if( df && df->GetOwner() ) // 죽은 넘이 owner 있다면 { if( df->Check_MobFlag(STATE_MONSTER_PARASITE) ) // 패러사이트에 걸려있다면. { int parasiteCnt = GetRandom(0,3); parasiteCnt -= df->GetOwner()->GetBombSummonCont(); if( parasiteCnt > 0 ) { int parasiteIdx = df->m_assist.GetSummonNpcIndex(); if( parasiteIdx > 0 ) { int i; for(i=0; i<parasiteCnt; i++) { CNPC* pParasiteNPC; pParasiteNPC = gserver->m_npcProtoList.Create(parasiteIdx, NULL ); if( pParasiteNPC == NULL ) continue; GET_X(pParasiteNPC) = GET_X(df); GET_Z(pParasiteNPC) = GET_Z(df); GET_R(pParasiteNPC) = GET_R(df); GET_YLAYER(pParasiteNPC) = GET_YLAYER(df); float fRand = GetRandom(0,1) ? 1.0f : -1.0f ; float x = 2.0f + ( fRand * (float)(GetRandom( 0 , 200 ) / 100.0f) ); fRand = GetRandom(0,1) ? 1 : -1 ; float z = 2.0f + ( fRand * (float)(GetRandom( 0 , 200 ) / 100.0f) ); pParasiteNPC->m_regenX = GET_X(pParasiteNPC) += x; pParasiteNPC->m_regenZ = GET_Z(pParasiteNPC) += z; pParasiteNPC->m_regenY = GET_YLAYER(pParasiteNPC); pParasiteNPC->CalcStatus(false); CSkill * pSkill = gserver->m_skillProtoList.Create( 1133 ); // 자살 공격 if( pSkill == NULL ) { delete pParasiteNPC ; pParasiteNPC = NULL; continue; } pParasiteNPC->SetOwner(df->GetOwner()); bool bApply; if( 0 != ApplySkill((CCharacter*)df->GetOwner(), (CCharacter*)pParasiteNPC, pSkill, -1, bApply) ) { delete pSkill; pSkill = NULL; delete pParasiteNPC; continue; } delete pSkill; pSkill = NULL; if( bApply == false ) { delete pParasiteNPC ; pParasiteNPC = NULL; continue; } df->GetOwner()->SetBombSummonNPC(pParasiteNPC); int cx, cz; df->m_pArea->AddNPC(pParasiteNPC); df->m_pArea->PointToCellNum(GET_X(pParasiteNPC), GET_Z(pParasiteNPC), &cx, &cz); df->m_pArea->CharToCell(pParasiteNPC, GET_YLAYER(pParasiteNPC), cx, cz); { CNetMsg::SP rmsg(new CNetMsg); AppearMsg(rmsg, pParasiteNPC, true); df->m_pArea->SendToCell(rmsg, GET_YLAYER(pParasiteNPC), cx, cz); } } } } } CNPC* sumNpc = df->GetOwner()->GetSummonNpc(df); if( sumNpc ) { #ifdef BUGFIX_MERCNERAY_DELETE sumNpc->GetOwner()->SummonNpcRemove(df, false); #else sumNpc->GetOwner()->SummonNpcRemove(df); #endif goto SKIP_DROP; } } /* */ // 이곳으로 넘어오면 테이밍이 아니므로, 모든 몬스터는 몬스터에게 죽으면 패스 else if (onpc && !bNPCKilledNPC) { goto SKIP_DROP; } // pc가 npc를 죽이면 테이밍 몬스터의 타겟을 지워준다. if (opc) { opc->SetOwners_target(NULL); opc->SetSummonOwners_target(NULL); } // 리더 사망시 처리 if (!df->m_proto->CheckFlag(NPC_RAID)) ProcFollowNPC(df); // 공성 포인트 계산 if (opc) CalcWarPoint(opc, df); // 죽은 NPC가 공성탑이나 수호병이 아닐 경우 처리 if (!df->m_proto->CheckFlag(NPC_CASTLE_TOWER | NPC_CASTLE_GUARD)) { int level = -1; LONGLONG nTotalDamage = 0; // 우선권 PC, 평균 레벨 구하기 CPC* tpc = FindPreferencePC(df, &level, &nTotalDamage); #ifdef GER_LOG if( IS_PC( of )) { CPC *user = TO_PC( of ); GAMELOGGEM << init( 0, "CHAR_VICTORY" ) << LOG_VAL("account-id", user->m_desc->m_idname ) << blank << LOG_VAL("character-id", user->m_desc->m_pChar->m_name ) << blank << LOG_VAL("zone-id", user->m_desc->m_pChar->m_pZone->m_index ) << blank << LOG_VAL("victim-id", df->m_index ) << blank /*<< LOG_VAL("opponent-id", kill) << blank*/ << LOG_VAL("longitude", GET_X(user) ) << blank << LOG_VAL("latitude", GET_Z(user) ) << blank << endGer; } #endif // 보스몹 if (df->m_proto->CheckFlag(NPC_BOSS | NPC_MBOSS | NPC_RAID)) { GAMELOG << init("MOB DEAD") << "INDEX" << delim << df->m_proto->m_index << delim << "NAME" << delim << df->m_name << delim << "ZONE" << delim << df->m_pZone->m_index << delim << "POSITION" << delim << GET_X(df) << delim << GET_Z(df) << delim << GET_YLAYER(df) << delim << "KILL BY" << delim; if (opc) { GAMELOG << opc->m_index << delim << opc->m_name << delim << opc->m_nick << delim << opc->m_job << delim << opc->m_job2 << delim << opc->m_level; } else { GAMELOG << of->m_type << delim << of->m_index << delim << of->m_name << delim << of->m_level; } GAMELOG << end; if (df->m_proto->CheckFlag(NPC_BOSS | NPC_MBOSS)) { // 카오 성향 회복 : 보스몹을 잡으면 회복 보너스 if (opc && opc->IsChaotic() && tpc == opc) { if( !gserver->m_bNonPK ) opc->m_pkPenalty += df->m_level / 10; if (opc->m_pkPenalty > 0) opc->m_pkPenalty = 0; { CNetMsg::SP rmsg(new CNetMsg); CharStatusMsg(rmsg, opc, 0); opc->m_pArea->SendToCell(rmsg, opc, false); } opc->m_bChangeStatus = true; } } } // 보스몹 if(opc && opc->m_pArea && df->m_proto->m_index == 1002 && df->m_pZone && df->m_pZone->m_index == ZONE_ALTER_OF_DARK) { // 네임드 몬스터 죽은 것으로 체크 opc->m_pArea->m_CTriggerList.Set_TriggerFlag(TRIGGER_FLAG_NAMEDNPC_DEATH1); opc->m_pArea->m_CTriggerList.Set_TriggerFlag(TRIGGER_FLAG_NAMEDNPC_DEATH1002_BEFORE); opc->m_pArea->m_CTriggerList.SaveTriggerInfo(TRIGGER_SAVE_ALTER_OF_DARK_1002, opc->m_nJoinInzone_RoomNo); //트리거 정보 저장 opc->m_pArea->Change_NpcRegenRaid(TRIGGER_SAVE_ALTER_OF_DARK_1002, 1002); } else if(opc && opc->m_pArea && df->m_proto->m_index == 1003 && df->m_pZone && df->m_pZone->m_index == ZONE_ALTER_OF_DARK) { // 네임드 몬스터 죽은 것으로 체크 opc->m_pArea->m_CTriggerList.Set_TriggerFlag(TRIGGER_FLAG_NAMEDNPC_DEATH2); opc->m_pArea->m_CTriggerList.Set_TriggerFlag(TRIGGER_FLAG_NAMEDNPC_DEATH1003_BEFORE); opc->m_pArea->m_CTriggerList.SaveTriggerInfo(TRIGGER_SAVE_ALTER_OF_DARK_1003, opc->m_nJoinInzone_RoomNo); //트리거 정보 저장 opc->m_pArea->Change_NpcRegenRaid(TRIGGER_SAVE_ALTER_OF_DARK_1003, 1003); } else if(opc && opc->m_pArea && df->m_proto->m_index == 1018 && df->m_pZone && df->m_pZone->m_index == ZONE_ALTER_OF_DARK) { // 네임드 몬스터 죽은 것으로 체크 opc->m_pArea->m_CTriggerList.Set_TriggerFlag(TRIGGER_FLAG_NAMEDNPC_DEATH1018_BEFORE); opc->m_pArea->m_CTriggerList.SaveTriggerInfo(TRIGGER_SAVE_ALTER_OF_DARK_1018, opc->m_nJoinInzone_RoomNo); //트리거 정보 저장 opc->m_pArea->Change_NpcRegenRaid(TRIGGER_SAVE_ALTER_OF_DARK_1018, 1018); } else if (opc && opc->m_pArea && df->m_proto->m_index == 963 && df->m_pZone && df->m_pZone->m_index == ZONE_CAPPELLA_1) { // 트리거를 사용하기 위한 npc963 죽은 count 세기 opc->m_pArea->m_CTriggerList.m_nNPC963_KilledCount += 1; } int nObjectData; int nAkanNpcIdx = df->m_proto->m_index; switch(nAkanNpcIdx) { case 1115: // 파독스의 인형(Hard) case 1170: // 파독스의 인형(Normal) { nObjectData = 10; if(opc && opc->m_pArea && df->m_pZone && df->m_pZone->m_index == ZONE_AKAN_TEMPLE) { CNetMsg::SP rmsg(new CNetMsg); RaidSceneMsg(rmsg, OBJECT_TYPE_TODO, KILL_NPC, nAkanNpcIdx, nObjectData); do_ExRaidScene(opc, rmsg); } } break; case 1112: // 툴만 case 1116: // 파독스 case 1120: // 쿤타 case 1124: // 유작 case 1126: // 고위 연금술사 제롬 case 1127: // 고위 마법술사 미엘 case 1128: // 제사장 미쿠 case 1167: // 툴만 case 1171: // 파독스 case 1175: // 쿤타 case 1179: // 유작 case 1180: // 고위 연금술사 제롬 case 1181: // 고위 마법술사 미엘 case 1182: // 제사장 미쿠 { nObjectData = 1; if(opc && opc->m_pArea && df->m_pZone && df->m_pZone->m_index == ZONE_AKAN_TEMPLE) { { CNetMsg::SP rmsg(new CNetMsg); RaidSceneMsg(rmsg, OBJECT_TYPE_TODO, KILL_NPC, nAkanNpcIdx, nObjectData); do_ExRaidScene(opc, rmsg); } } } break; case 1259: //망각의 신전 { nObjectData = 1; if(opc && opc->m_pArea && df->m_pZone && df->m_pZone->m_index == ZONE_DUNGEON4) { CNetMsg::SP rmsg(new CNetMsg); RaidSceneMsg(rmsg, OBJECT_TYPE_TODO, KILL_NPC, nAkanNpcIdx, nObjectData); do_ExRaidScene(opc, rmsg); } } break; case 1364: { if(opc && opc->m_pArea && df->m_pZone && df->m_pZone->m_index == ZONE_TARIAN_DUNGEON) { CNetMsg::SP rmsg(new CNetMsg); RaidSceneMsg(rmsg, OBJECT_TYPE_TODO, KILL_NPC, nAkanNpcIdx, 1); do_ExRaidScene(opc, rmsg); } } break; default: break; } #ifdef REFORM_PK_PENALTY_201108 // PK 패널티 리폼 :: npc를 잡으면 무조건 헌터 쪽으로 향상 시켜준다. if( !gserver->m_bNonPK ) { if(df && opc) { int nlevel = df->m_level - opc->m_level; int pkPenalty = 0; if( nlevel > 4 ) pkPenalty += 15; else if( nlevel > -5 ) pkPenalty += 10; else if( nlevel <= -5 && nlevel >= -10) pkPenalty += 5; // 성향 수치 상승 증폭제를 사용 중이라면 if( opc->m_assist.m_avRate.pkDispositionPointValue > 0 ) { pkPenalty = pkPenalty * opc->m_assist.m_avRate.pkDispositionPointValue; opc->m_assist.CureByItemIndex(7474); // 성향 수치 상승 증폭제 opc->m_assist.CureByItemIndex(7475); // 성향 수치 상승 증폭제 opc->m_assist.CureByItemIndex(7476); // 성향 수치 상승 증폭제 } opc->AddPkPenalty( pkPenalty ); { CNetMsg::SP rmsg(new CNetMsg); CharStatusMsg(rmsg, opc, 0); opc->m_pArea->SendToCell(rmsg, opc, false); } opc->m_bChangeStatus = true; } } #else // REFORM_PK_PENALTY_201108 // PK 패널티 리폼 if (opc && opc->IsChaotic() && df->m_level >= opc->m_level - 5) { opc->m_pkRecoverNPCCount++; if (opc->m_pkRecoverNPCCount >= 25) { opc->m_pkRecoverNPCCount = 0; if( !gserver->m_bNonPK ) opc->m_pkPenalty++; { CNetMsg::SP rmsg(new CNetMsg); CharStatusMsg(rmsg, opc, 0); opc->m_pArea->SendToCell(rmsg, opc, false); } opc->m_bChangeStatus = true; } } // 카오 성향 회복 #endif // REFORM_PK_PENALTY_201108 // PK 패널티 리폼 // Exp, SP 분배 // 이루틴중 레벨업을 하여 존이동을 하였을 경우 나머지 실행하지 않는다. if( DivisionExpSP(df, tpc, nTotalDamage) ) goto END_PROC; // 아이템 드롭 ProcDropItemAfterBattle(df, opc, tpc, level); // 진행중인 Quest 중 죽은 npc로 진행중이면 UpdateData if (opc && opc == tpc) { if( opc->m_pZone->IsPersonalDungeon() ) { opc->m_pArea->m_nMakeNPC++; #if defined ( LC_GAMIGO ) || defined ( LC_KOR ) || defined ( LC_USA ) if( df->m_proto->m_index == 5 ) { if(opc->m_pArea->m_nMakeNPC < 103) goto SKIP_DROP; else { GAMELOG << init("QUEST COMPLETE PD1", opc) << opc->m_pArea->m_nMakeNPC << end; } } else if(df->m_proto->m_index == 201 && opc->m_pArea->m_nMakeNPC < 50) { goto SKIP_DROP; } #else if( (df->m_proto->m_index == 5 || df->m_proto->m_index == 201 ) && opc->m_pArea->m_nMakeNPC < 50 ) { goto SKIP_DROP; } #endif // LC_GAMIGO || LC_KOR || LC_USA } #ifdef PARTY_QUEST_ITEM_BUG_ ProcDeadQuestProc(opc, df, QTYPE_SCALE_PERSONAL); // 내가 어그로도 먹고 몬스터도 막타 쳤단다. #else CQuest* pQuest = NULL; CQuest* pQuestNext = opc->m_questList.GetNextQuest(NULL, QUEST_STATE_RUN); while ((pQuest = pQuestNext)) { pQuestNext = opc->m_questList.GetNextQuest(pQuestNext, QUEST_STATE_RUN); // 퀘스트 있고 수행중이고 반복, 수집, 격파, 구출 퀘스트이면 switch (pQuest->GetQuestType0()) { case QTYPE_KIND_REPEAT: case QTYPE_KIND_COLLECTION: case QTYPE_KIND_DEFEAT: case QTYPE_KIND_SAVE: pQuest->QuestUpdateDataForParty(opc, df); break; default: break; } } if( pQuest == NULL && opc->IsParty() && opc->m_party ) { int i; const CPartyMember* pPartyMember; CPC* pPartyPC; for(i=0; i<MAX_PARTY_MEMBER; ++i) { pPartyMember = opc->m_party->GetMemberByListIndex(i); if(pPartyMember && pPartyMember->GetMemberPCPtr()) { pPartyPC = pPartyMember->GetMemberPCPtr(); if(opc->m_pArea->FindCharInCell(opc, pPartyPC->m_index, MSG_CHAR_PC)) { pQuest = pPartyPC->m_questList.FindQuestByMob( df->m_idNum); if( pQuest == NULL) continue; if( pQuest->GetPartyScale() != QTYPE_SCALE_PARTY) break; switch (pQuest->GetQuestType0()) { case QTYPE_KIND_REPEAT: case QTYPE_KIND_COLLECTION: case QTYPE_KIND_DEFEAT: case QTYPE_KIND_SAVE: pQuest->QuestUpdateData(pPartyPC, df); break; default: break; } } } } } #endif // PARTY_QUEST_ITEM_BUG_ } #ifdef PARTY_QUEST_ITEM_BUG_ else if(opc) // [2010/12/28 derek] opc == NULL 인데도 들어가져서 퀘스트 찾다가 서버 다운되어 추가함. { #ifdef _BATTLEGROUP_QUEST_BUG_PIX if( opc->IsExped() ) // 어글은 않먹었지만 막타로 잡았으면 ProcDeadQuestProc(opc, df, QTYPE_SCALE_BATTLEGROUP); else #endif ProcDeadQuestProc(opc, df, QTYPE_SCALE_PARTY); } #endif //PARTY_QUEST_ITEM_BUG_ } // 죽은 NPC가 공성탑이나 수호병이 아닐 경우 처리 else { int level = -1; LONGLONG nTotalDamage = 0; // 우선권 PC, 평균 레벨 구하기 CPC* tpc = FindPreferencePC(df, &level, &nTotalDamage); DropWarCastleToken(df, opc, tpc, level); } SKIP_DROP: // 수호탑은 DelNPC() 안하고 UpdateGateState() 후에 메시지로 알린다. if (df->m_proto->CheckFlag(NPC_CASTLE_TOWER) != 0) { int gstate_old = 0, gstate_new = 0; CWarCastle * castle = CWarCastle::GetCastleObject(ZONE_MERAC); CDratanCastle * pCastle = CDratanCastle::CreateInstance(); if (of->m_pZone->m_index == ZONE_MERAC) { if (castle != NULL) { gstate_old = castle->GetGateState(); gstate_old |= pCastle->GetGateState(); castle->UpdateGateState(df); gstate_new = castle->GetGateState(); gstate_new |= pCastle->GetGateState(); } } else if (of->m_pZone->m_index == ZONE_DRATAN) { gstate_old = pCastle->GetGateState(); if (castle != NULL) { gstate_old |= castle->GetGateState(); } pCastle->UpdateGateState(df); gstate_new = pCastle->GetGateState(); if (castle != NULL) { gstate_new |= castle->GetGateState(); } if (df->m_proto->CheckFlag(NPC_WARCASTLE) != 0) { // NPC_CASTLE_TOWER 에 NPC_WARCASTLE 면 // 마스터 타워와 부활진지 int qindex = df->m_proto->m_index; if (qindex >= 390 && qindex <= 396) { // 부활진지 파괴 알림 CNetMsg::SP rmsg(new CNetMsg); CastleTowerQuartersCrushMsg(rmsg, qindex); of->m_pArea->SendToAllClient(rmsg); // 부활진지 파괴 처리 /*pCastle->m_nRebrithGuild[df->m_proto->m_index - 390] = -1; memset((void *)pCastle->m_strRebrithGuild[df->m_proto->m_index - 390], 0, 51);*/ } } } if (gstate_old != gstate_new) { CNetMsg::SP rmsg(new CNetMsg); GuildWarGateStateMsg(rmsg, gstate_old, gstate_new); of->m_pArea->SendToAllClient(rmsg); } DelAttackList(df); if (of->m_pZone->m_index == ZONE_DRATAN) { if( df->m_proto->m_index == 351) { // 마스터 타워 // 모든 타워 기능 정지 pCastle->StopCastleTower(); } else if (df->m_proto->CheckFlag(NPC_CASTLE_TOWER) != 0) { // 공격 수호상 (결계의 눈 등..) 로그 GAMELOG << init("DRATAN CASTLE NPC DEAD : ") << df->m_proto->m_name << " BROKEN BY : " << of->m_name << end; // 마스터 타워가 아닌 모든 타워 int i; // 부활 진지 삭제 // for (i=0; i<7; i++) // { // if (pCastle->m_pRebrithNPC[i] == df) // { // pCastle->m_pRebrithNPC[i] = NULL; // pCastle->m_nRebrithGuild[i] = -1; // memset((void *)pCastle->m_strRebrithGuild[i], 0, 51); //#ifdef BUGFIX_WARCASTLE_REGEN // pCastle->m_nRegenTimeRebirthNPC[i] = gserver->getNowSecond() + pCastle->GetRegenNPCRebirthTime(); //#else // pCastle->m_nRegenTimeRebirthNPC[i] = gserver->m_pulse + pCastle->GetRegenNPCRebirthTime(); //#endif // BUGFIX_WARCASTLE_REGEN // } // } // 워프 타워 삭제 for (i=0; i<5; i++) { if (pCastle->m_pWarpNPC[i] == df) { pCastle->m_pWarpNPC[i] = NULL; } } // 결계의 눈 삭제 for (i=0; i<5; i++) { if (pCastle->m_gateNPC[i] == df) { pCastle->m_gateNPC[i] = NULL; } } // 알림 of->m_pArea->CharFromCell(df, true); of->m_pArea->DelNPC(df); } } return ; } // 수호탑은 DelNPC() 안하고 UpdateGateState() 후에 메시지로 알린다. //#endif #ifdef EXTREME_CUBE if(df->m_bCubeRegen) { CCubeSpace* cube = gserver->m_extremeCube.GetExtremeCube(df->m_pArea->m_index); if(cube) { cube->DelMob(df); if(gserver->m_extremeCube.IsGuildCubeTime() && opc && opc->m_guildInfo && opc->m_guildInfo->guild()) { CCubeMemList* CubeMemList; CubeMemList = gserver->m_extremeCube.FindMemList(opc->m_guildInfo->guild()); if(CubeMemList) { time_t lastCubePoint; time(&lastCubePoint); CNetMsg::SP rmsg(new CNetMsg); HelperAddCubePointMsg(rmsg, opc->m_guildInfo->guild()->index(), df->m_level, lastCubePoint); SEND_Q(rmsg, gserver->m_helper); } } } } if(df->m_pZone != NULL && df->m_proto->m_index == 529 && df->m_pZone->IsExtremeCube()) { CCubeSpace* cube = gserver->m_extremeCube.GetExtremeCube(df->m_pArea->m_index); if(cube && (cube->m_crystal == df) ) { // cube->m_crystal = NULL; cube->DelCrystal(false); cube->m_waitTime = gserver->m_pulse + PULSE_REAL_SEC * 10; return ; } } else if(df->m_pZone != NULL && df->m_proto->m_index == 527 && df->m_pZone->IsExtremeCube()) { CCubeSpace* cube = gserver->m_extremeCube.GetExtremeCube(df->m_pArea->m_index); if(cube && (cube->m_crystal == df) ) { // cube->m_crystal = NULL; cube->DelCrystal(false); cube->m_waitTime = gserver->m_pulse + PULSE_REAL_SEC * 10; return ; } } #endif // EXTREME_CUBE if(df && opc) { vec_affinityList_t::iterator it = df->m_proto->m_affinityList.begin(); vec_affinityList_t::iterator endit = df->m_proto->m_affinityList.end(); int point = 0; for(; it != endit; ++it) { CAffinityProto* proto = *(it); CAffinity* affinity = opc->m_affinityList.FindAffinity(proto->m_index); if(affinity) { point = proto->GetAffinityPointOfNPC(df->m_idNum); int bonus = 0; if(opc->m_avPassiveAddition.affinity_monster > 0) { bonus += opc->m_avPassiveAddition.affinity_monster; } if(opc->m_avPassiveRate.affinity_monster > 0) { bonus = point * (opc->m_avPassiveRate.affinity_monster - 100) / SKILL_RATE_UNIT; } affinity->AddPoint( point, opc, bonus); } } } if(df->m_ctCount > 0) { gserver->m_npc_ctTime.erase(df->m_index); } END_PROC: //rvr 존에서 공격시에 동작해야 되는 함수 (NPC 가 죽었을 경우) if(opc != NULL && of->m_pZone->isRVRZone() && df->m_pZone->isRVRZone()) { ProcDead_RVR(opc, df); } // 모든 몬스터는 몬스터에게 죽으면 패스 if ( onpc || bNPCKilledNPC ) { // 해당 에어리어에 죽은 수를 표시한다. 여기서는 바로 안지우고 따로 처리.. // MobActivity.cpp::MobActivity() 타고 들어오면 꼭 여길 거쳐야한다. onpc->m_pArea->m_nNPC_Killed_NPC++; } else { DelAttackList(df); of->m_pArea->CharFromCell(df, true); of->m_pArea->DelNPC(df); } }