blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
5
146
content_id
stringlengths
40
40
detected_licenses
listlengths
0
7
license_type
stringclasses
2 values
repo_name
stringlengths
6
79
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
4 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.07k
426M
star_events_count
int64
0
27
fork_events_count
int64
0
12
gha_license_id
stringclasses
3 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
6 values
src_encoding
stringclasses
26 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
1 class
length_bytes
int64
20
6.28M
extension
stringclasses
20 values
content
stringlengths
20
6.28M
authors
listlengths
1
16
author_lines
listlengths
1
16
b905f9f5f30b80d9ee217e445f3069e5255c049a
cd07acbe92f87b59260478f62a6f8d7d1e218ba9
/src/datagrid.h
3bdacce6fb90711c62a01227267b5a9e667338d0
[]
no_license
niepp/sperm-x
3a071783e573d0c4bae67c2a7f0fe9959516060d
e8f578c640347ca186248527acf82262adb5d327
refs/heads/master
2021-01-10T06:27:15.004646
2011-09-24T03:33:21
2011-09-24T03:33:21
46,690,957
1
1
null
null
null
null
UTF-8
C++
false
false
5,334
h
#if !defined(AFX_DATAGRID_H__4973F3E2_24DC_40D3_B44A_533AD9CAC1B6__INCLUDED_) #define AFX_DATAGRID_H__4973F3E2_24DC_40D3_B44A_533AD9CAC1B6__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++ // NOTE: Do not modify the contents of this file. If this class is regenerated by // Microsoft Visual C++, your modifications will be overwritten. // Dispatch interfaces referenced by this interface class COleFont; class CStdDataFormatsDisp; class CPicture; class CColumns; class CSelBookmarks; class CSplits; ///////////////////////////////////////////////////////////////////////////// // CDataGrid wrapper class class CDataGrid : public CWnd { protected: DECLARE_DYNCREATE(CDataGrid) public: CLSID const& GetClsid() { static CLSID const clsid = { 0xcde57a43, 0x8b86, 0x11d0, { 0xb3, 0xc6, 0x0, 0xa0, 0xc9, 0xa, 0xea, 0x82 } }; return clsid; } virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL) { return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID); } BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE, BSTR bstrLicKey = NULL) { return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID, pPersist, bStorage, bstrLicKey); } // Attributes public: // Operations public: BSTR GetItem(short colIndex); long GetAddNewMode(); BOOL GetAllowAddNew(); void SetAllowAddNew(BOOL bNewValue); BOOL GetAllowArrows(); void SetAllowArrows(BOOL bNewValue); BOOL GetAllowDelete(); void SetAllowDelete(BOOL bNewValue); BOOL GetAllowRowSizing(); void SetAllowRowSizing(BOOL bNewValue); BOOL GetAllowUpdate(); void SetAllowUpdate(BOOL bNewValue); long GetAppearance(); void SetAppearance(long nNewValue); long GetApproxCount(); unsigned long GetBackColor(); void SetBackColor(unsigned long newValue); VARIANT GetBookmark(); void SetBookmark(const VARIANT& newValue); long GetBorderStyle(); void SetBorderStyle(long nNewValue); CString GetCaption(); void SetCaption(LPCTSTR lpszNewValue); short GetCol(); void SetCol(short nNewValue); BOOL GetColumnHeaders(); void SetColumnHeaders(BOOL bNewValue); BOOL GetCurrentCellModified(); void SetCurrentCellModified(BOOL bNewValue); BOOL GetCurrentCellVisible(); void SetCurrentCellVisible(BOOL bNewValue); BOOL GetDataChanged(); void SetDataChanged(BOOL bNewValue); LPUNKNOWN GetDataSource(); void SetRefDataSource(LPUNKNOWN newValue); CString GetDataMember(); void SetDataMember(LPCTSTR lpszNewValue); float GetDefColWidth(); void SetDefColWidth(float newValue); BOOL GetEditActive(); void SetEditActive(BOOL bNewValue); BOOL GetEnabled(); void SetEnabled(BOOL bNewValue); CString GetErrorText(); COleFont GetFont(); void SetRefFont(LPDISPATCH newValue); unsigned long GetForeColor(); void SetForeColor(unsigned long newValue); VARIANT GetFirstRow(); void SetFirstRow(const VARIANT& newValue); COleFont GetHeadFont(); void SetRefHeadFont(LPDISPATCH newValue); float GetHeadLines(); void SetHeadLines(float newValue); long GetHWnd(); long GetHWndEditor(); short GetLeftCol(); void SetLeftCol(short nNewValue); long GetMarqueeStyle(); void SetMarqueeStyle(long nNewValue); BOOL GetRecordSelectors(); void SetRecordSelectors(BOOL bNewValue); BOOL GetRightToLeft(); void SetRightToLeft(BOOL bNewValue); short GetRow(); void SetRow(short nNewValue); long GetRowDividerStyle(); void SetRowDividerStyle(long nNewValue); float GetRowHeight(); void SetRowHeight(float newValue); long GetScrollBars(); void SetScrollBars(long nNewValue); short GetSelEndCol(); void SetSelEndCol(short nNewValue); long GetSelLength(); void SetSelLength(long nNewValue); long GetSelStart(); void SetSelStart(long nNewValue); short GetSelStartCol(); void SetSelStartCol(short nNewValue); CString GetSelText(); void SetSelText(LPCTSTR lpszNewValue); short GetSplit(); void SetSplit(short nNewValue); BOOL GetTabAcrossSplits(); void SetTabAcrossSplits(BOOL bNewValue); long GetTabAction(); void SetTabAction(long nNewValue); CString GetText(); void SetText(LPCTSTR lpszNewValue); short GetVisibleCols(); short GetVisibleRows(); BOOL GetWrapCellPointer(); void SetWrapCellPointer(BOOL bNewValue); CStdDataFormatsDisp GetDataFormats(); CPicture CaptureImage(); void ClearSelCols(); void ClearFields(); short ColContaining(float X); CColumns GetColumns(); VARIANT GetBookmark(long RowNum); void HoldFields(); void ReBind(); void Refresh(); VARIANT RowBookmark(short RowNum); short RowContaining(float Y); float RowTop(short RowNum); void Scroll(long Cols, long Rows); CSelBookmarks GetSelBookmarks(); short SplitContaining(float X, float Y); CSplits GetSplits(); }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_DATAGRID_H__4973F3E2_24DC_40D3_B44A_533AD9CAC1B6__INCLUDED_)
[ "harithchen@e030fd90-5f31-5877-223c-63bd88aa7192" ]
[ [ [ 1, 170 ] ] ]
7dd831d7f7bdeb3e11abfcde72dfd989202049bd
7f6fe18cf018aafec8fa737dfe363d5d5a283805
/ntk/application/src/messenger.cpp
8c7736ccb89bfcdfbb0563a9599c31e3c1b6156d
[]
no_license
snori/ntk
4db91d8a8fc836ca9a0dc2bc41b1ce767010d5ba
86d1a32c4ad831e791ca29f5e7f9e055334e8fe7
refs/heads/master
2020-05-18T05:28:49.149912
2009-08-04T16:47:12
2009-08-04T16:47:12
268,861
2
0
null
null
null
null
SHIFT_JIS
C++
false
false
3,022
cpp
/****************************************************************************** The NTK Library Copyright (C) 1998-2003 Noritaka Suzuki $Id: messenger.cpp,v 1.5 2003/11/11 12:07:05 nsuzuki Exp $ ******************************************************************************/ #define NTK_BUILD #include "ntk/application/messenger.h" #include <assert.h> #include <ntk/windows/windows.h> #include <ntk/support/debug.h> #include <ntk/application/message.h> #include <ntk/application/handler.h> #include <ntk/application/looper.h> namespace ntk { //######################################################## // public methods Messenger::Messenger(Handler* target_, Looper* looper_, status_t* result) : m_target(NULL), m_looper(NULL) { status_t sts = set_target(target_, looper_); if(result) *result = sts; } Messenger::Messenger(const Messenger& messenger) { *this = messenger; } Messenger::~Messenger() { } Messenger& Messenger::operator=(const Messenger& rhs) { if(&rhs == this) return *this; m_target = rhs.m_target; m_looper = rhs.m_looper; return *this; } status_t Messenger::send_message(uint command, Handler* reply_handler) const { return send_message(Message(command), reply_handler); } status_t Messenger::send_message(const Message& message, Handler* reply_handler) const { if(m_looper == NULL) return status_t(st::BAD_VALUE_ERROR, "Messenger::send_message(): ターゲットが不正です"); #ifdef NTK_DEBUG if(m_target) { uint count = m_looper->count_handlers(); bool found = false; for(int i = 0; i<count; ++i) if(m_looper->handler_at(i) == m_target) found = true; if(! found) { error(m_target->name() + ", " + m_looper->name() + "\n"); return status_t(st::ERR, "Messenger::send_message(): target ハンドラは looper に属していません"); } } #endif m_looper->post_message(message, m_target, reply_handler); return st::OK; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // public accessors and manipulators Handler* Messenger::target(Looper** looper_) const { // Looper* Messenger::looper() というアクセッサを作らないのは // Control において NView::looper() とかぶるため if(looper_) *looper_ = m_looper; return m_target; } status_t Messenger::set_target(Handler* target_, Looper* looper_) { if(target_ && looper_ && target_->looper() != looper_) { return st::BAD_VALUE_ERROR; } m_target = target_; m_looper = m_target ? m_target->looper() : looper_; return st::OK; } bool Messenger::is_valid() const { return m_looper || (m_target && m_looper); } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // public operators bool operator==(const Messenger& lhs, const Messenger& rhs) { return lhs.m_target == rhs.m_target && lhs.m_looper == rhs.m_looper; } //######################################################## }// namespace ntk
[ [ [ 1, 135 ] ] ]
c09c784f672268c41d7de16b7771435218a85d4c
ce262ae496ab3eeebfcbb337da86d34eb689c07b
/SEAudioRenderers/SE_OpenAL_Renderer/SEOpenALRendering/SEOpenALResourcesLR.cpp
3b372a6162e515685875d1dd6bb3c04a827f9b63
[]
no_license
pizibing/swingengine
d8d9208c00ec2944817e1aab51287a3c38103bea
e7109d7b3e28c4421c173712eaf872771550669e
refs/heads/master
2021-01-16T18:29:10.689858
2011-06-23T04:27:46
2011-06-23T04:27:46
33,969,301
0
0
null
null
null
null
GB18030
C++
false
false
4,059
cpp
// Swing Engine Version 1 Source Code // Most of techniques in the engine are mainly based on David Eberly's // Wild Magic 4 open-source code.The author of Swing Engine learned a lot // from Eberly's experience of architecture and algorithm. // Several sub-systems are totally new,and others are re-implimented or // re-organized based on Wild Magic 4's sub-systems. // Copyright (c) 2007-2010. All Rights Reserved // // Eberly's permission: // Geometric Tools, Inc. // http://www.geometrictools.com // Copyright (c) 1998-2006. All Rights Reserved // // This library is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 2.1 of the License, or (at // your option) any later version. The license is available for reading at // the location: // http://www.gnu.org/copyleft/lgpl.html #include "SEOpenALRendererPCH.h" #include "SEOpenALRenderer.h" #include "SEOpenALResources.h" #include "SESoundBuffer.h" using namespace Swing; ALenum SEOpenALRenderer::ms_aeWaveType[SEWave::WT_COUNT] = { 0, // WT_MONO4 AL_FORMAT_MONO8, // WT_MONO8 AL_FORMAT_MONO16, // WT_MONO16 0, // WT_STEREO4 AL_FORMAT_STEREO8, // WT_STEREO8 AL_FORMAT_STEREO16, // WT_STEREO16 0, // WT_QUAD16 0, // WT_REAR16 0, // WT_51CHN16 0, // WT_61CHN16 0 // WT_71CHN16 }; //---------------------------------------------------------------------------- // 资源装载与释放. //---------------------------------------------------------------------------- void SEOpenALRenderer::OnLoadSound(SEAudioResourceIdentifier*& rpID, SESound* pSound) { SESoundID* pResource = SE_NEW SESoundID; pResource->SoundObject = pSound; rpID = pResource; SE_AL_BEGIN_DEBUG_ALAPI; alGenSources((ALsizei)1, &pResource->ID); SE_AL_END_DEBUG_ALAPI; } //---------------------------------------------------------------------------- void SEOpenALRenderer::OnReleaseSound(SEAudioResourceIdentifier* pID) { SESoundID* pResource = (SESoundID*)pID; SE_AL_BEGIN_DEBUG_ALAPI; alSourceStop(pResource->ID); alDeleteSources((ALsizei)1, &pResource->ID); SE_AL_END_DEBUG_ALAPI; SE_DELETE pResource; } //---------------------------------------------------------------------------- void SEOpenALRenderer::OnLoadSBuffer(SEAudioResourceIdentifier*& rpID, SESoundBuffer* pSBuffer) { SESBufferID* pResource = SE_NEW SESBufferID; pResource->SBufferObject = pSBuffer; rpID = pResource; pResource->BufferCount = pSBuffer->GetWaveCount(); pResource->Buffers = SE_NEW unsigned int[pResource->BufferCount]; SE_AL_BEGIN_DEBUG_ALAPI; alGenBuffers((ALsizei)pResource->BufferCount, pResource->Buffers); SE_AL_END_DEBUG_ALAPI; for( int i = 0; i < pResource->BufferCount; i++ ) { SEWave* pWave = pSBuffer->GetWave(i); if( pWave ) { // load PCM wave data for this buffer. ALenum eFormat = ms_aeWaveType[pWave->GetFormat()]; SE_AL_BEGIN_DEBUG_ALAPI; alBufferData(pResource->Buffers[i], eFormat, (const ALvoid*)pWave->GetData(), pWave->GetDataSize(), pWave->GetFrequency()); SE_AL_END_DEBUG_ALAPI; } } } //---------------------------------------------------------------------------- void SEOpenALRenderer::OnReleaseSBuffer(SEAudioResourceIdentifier* pID) { SESBufferID* pResource = (SESBufferID*)pID; SE_AL_BEGIN_DEBUG_ALAPI; alDeleteBuffers((ALsizei)pResource->BufferCount, pResource->Buffers); SE_AL_END_DEBUG_ALAPI; SE_DELETE[] pResource->Buffers; SE_DELETE pResource; } //----------------------------------------------------------------------------
[ "[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac" ]
[ [ [ 1, 110 ] ] ]
d5c05651e22e8110e4bdf419941dbf3f9497e4b6
8fd82049c092a6b80f63f402aca243096eb7b3c8
/MFCMailClient/MFCMailClient/AccountDlg.h
eaba23d636fd8d6e56f0c91b8a124490be635e5e
[]
no_license
phucnh/laptrinhmang-k52
47965acb82750b600b543cc5c43d00f59ce5bc54
b27a8a02f9ec8bf953b617402dce37293413bb0f
refs/heads/master
2021-01-18T22:22:24.692192
2010-12-09T02:00:10
2010-12-09T02:00:10
32,262,504
0
0
null
null
null
null
UTF-8
C++
false
false
777
h
#pragma once #ifdef _WIN32_WCE #error "CDHtmlDialog is not supported for Windows CE." #endif // CAccountDlg dialog class CAccountDlg : public CDHtmlDialog { DECLARE_DYNCREATE(CAccountDlg) public: CAccountDlg(CWnd* pParent = NULL); // standard constructor virtual ~CAccountDlg(); // Overrides HRESULT OnButtonOK(IHTMLElement *pElement); HRESULT OnButtonCancel(IHTMLElement *pElement); // Dialog Data enum { IDD = IDD_ACCOUNT_DIALOG, IDH = IDR_HTML_ACCOUNTDLG }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual BOOL OnInitDialog(); DECLARE_MESSAGE_MAP() DECLARE_DHTML_EVENT_MAP() public: afx_msg void OnBnClickedOk(); DWORD m_ServerIP; CString m_UserName; CString m_Password; };
[ "nguyenhongphuc.hut@e1f3f65c-33eb-5b6a-8ef2-7789ca584060" ]
[ [ [ 1, 34 ] ] ]
d280a7dbfd884b65cdd634fc2c53a85ba4e48371
d397b0d420dffcf45713596f5e3db269b0652dee
/src/Axe/EndpointCache.cpp
ac9ec65d25fc5074a0da6a016b4a629d230df5ad
[]
no_license
irov/Axe
62cf29def34ee529b79e6dbcf9b2f9bf3709ac4f
d3de329512a4251470cbc11264ed3868d9261d22
refs/heads/master
2021-01-22T20:35:54.710866
2010-09-15T14:36:43
2010-09-15T14:36:43
85,337,070
0
0
null
null
null
null
UTF-8
C++
false
false
2,551
cpp
# include "pch.hpp" # include <Axe/EndpointCache.hpp> # include <AxeProtocols/GridManager.hpp> namespace Axe { ////////////////////////////////////////////////////////////////////////// EndpointCache::EndpointCache( const Proxy_GridManagerPtr & _gridManagerPrx ) : m_gridManager(_gridManagerPrx) { } ////////////////////////////////////////////////////////////////////////// void EndpointCache::addEndpoint( std::size_t _adapterId, const boost::asio::ip::tcp::endpoint & _endpoint ) { m_endpoints.insert( std::make_pair(_adapterId, _endpoint) ); } ////////////////////////////////////////////////////////////////////////// void EndpointCache::getEndpoint( std::size_t _adapterId, const FEndpointCallback & _cb ) { TMapEndpoints::iterator it_found = m_endpoints.find( _adapterId ); if( it_found == m_endpoints.end() ) { this->provideEndpoint( _adapterId, _cb ); } else { _cb( it_found->second ); } } ////////////////////////////////////////////////////////////////////////// void EndpointCache::provideEndpoint( std::size_t _adapterId, const FEndpointCallback & _cb ) { TMapWantedEndpoints::iterator it_found = m_wantedEndpoints.find( _adapterId ); if( it_found == m_wantedEndpoints.end() ) { m_gridManager->getAdapterEndpoint_async( bindResponse( boost::bind( &EndpointCache::getEndpointResponse, handlePtr(this), _1, _adapterId, _cb ) , noneExceptionFilter() ) , _adapterId ); TListEndpointResponses responses; responses.push_back( _cb ); it_found = m_wantedEndpoints.insert( std::make_pair(_adapterId, responses) ).first; } it_found->second.push_back( _cb ); } ////////////////////////////////////////////////////////////////////////// void EndpointCache::getEndpointResponse( const std::string & _endpoint, std::size_t _adapterId, const FEndpointCallback & _cb ) { std::string addr; unsigned short port; std::stringstream ss( _endpoint ); ss >> addr; ss >> port; boost::asio::ip::address ip_addr = boost::asio::ip::address::from_string( addr ); boost::asio::ip::tcp::endpoint tcp_endpoint( ip_addr, port ); this->addEndpoint( _adapterId, tcp_endpoint ); TMapWantedEndpoints::iterator it_found = m_wantedEndpoints.find( _adapterId ); for( TListEndpointResponses::iterator it = it_found->second.begin(), it_end = it_found->second.end(); it != it_end; ++it ) { (*it)( tcp_endpoint ); } m_wantedEndpoints.erase( it_found ); } }
[ "yuriy_levchenko@b35ac3e7-fb55-4080-a4c2-184bb04a16e0" ]
[ [ [ 1, 84 ] ] ]
a1f6f8e3923fd53d51e142c3c2938b88a76f9b69
40e58042e635ea2a61a6216dc3e143fd3e14709c
/chopshop11/SimpleLog.h
7375230071c815e57f4ff6956729e9434abe5e6a
[]
no_license
chopshop-166/frc-2011
005bb7f0d02050a19bdb2eb33af145d5d2916a4d
7ef98f84e544a17855197f491fc9f80247698dd3
refs/heads/master
2016-09-05T10:59:54.976527
2011-10-20T22:50:17
2011-10-20T22:50:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,108
h
/******************************************************************************* * Project : Framework * File Name : MemoryLog166.h * Owner : Software Group (FIRST Chopshop Team 166) * Creation Date : January 18, 2010 * File Description : Header for general memory logger on chopshop robot *******************************************************************************/ /*----------------------------------------------------------------------------*/ /* Copyright (c) MHS Chopshop Team 166, 2010. All Rights Reserved. */ /*----------------------------------------------------------------------------*/ #pragma once #include <cstdio> #include <ctime> #include <string> #include "FrameworkLogger.h" using std::string; // // This class defines an interface to logging to memory and then into a .csv file // class SimpleLog : public FrameworkLogger { FILE *file; public: SimpleLog(string name); ~SimpleLog(); bool PutOne(double data); // Add some data to the log int DumpToFile(void); // Dump the log into a file string name; };
[ [ [ 1, 31 ] ] ]
5d12b03d91e54c456d273221edd5d5a608929437
463c3b62132d215e245a097a921859ecb498f723
/lib/dlib/svm/svm_threaded_abstract.h
a01a41746f222d5e14f206edaa39353308a32afb
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
athulan/cppagent
58f078cee55b68c08297acdf04a5424c2308cfdc
9027ec4e32647e10c38276e12bcfed526a7e27dd
refs/heads/master
2021-01-18T23:34:34.691846
2009-05-05T00:19:54
2009-05-05T00:19:54
197,038
4
1
null
null
null
null
UTF-8
C++
false
false
2,257
h
// Copyright (C) 2008 Davis E. King ([email protected]) // License: Boost Software License See LICENSE.txt for the full license. #undef DLIB_SVm_THREADED_ABSTRACT_ #ifdef DLIB_SVm_THREADED_ABSTRACT_ #include "../matrix/matrix_abstract.h" #include "../algs.h" #include "../svm.h" namespace dlib { // ---------------------------------------------------------------------------------------- template < typename trainer_type, typename in_sample_vector_type, typename in_scalar_vector_type > const matrix<typename trainer_type::scalar_type, 1, 2, typename trainer_type::mem_manager_type> cross_validate_trainer_threaded ( const trainer_type& trainer, const in_sample_vector_type& x, const in_scalar_vector_type& y, const long folds, const long num_threads ); /*! requires - is_binary_classification_problem(x,y) == true - 1 < folds <= x.nr() - trainer_type == some kind of trainer object (e.g. svm_nu_trainer) - num_threads > 0 ensures - performs k-fold cross validation by using the given trainer to solve the given binary classification problem for the given number of folds. Each fold is tested using the output of the trainer and the average classification accuracy from all folds is returned. - uses num_threads threads of execution in doing the cross validation. - The accuracy is returned in a column vector, let us call it R. Both quantities in R are numbers between 0 and 1 which represent the fraction of examples correctly classified. R(0) is the fraction of +1 examples correctly classified and R(1) is the fraction of -1 examples correctly classified. - The number of folds used is given by the folds argument. throws - any exceptions thrown by trainer.train() - std::bad_alloc !*/ // ---------------------------------------------------------------------------------------- } #endif // DLIB_SVm_THREADED_ABSTRACT_
[ "jimmy@DGJ3X3B1.(none)" ]
[ [ [ 1, 58 ] ] ]
e6a6b91a0b26102cbd1ec4a2d9aa24f675059c96
38926bfe477f933a307f51376dd3c356e7893ffc
/Source/GameDLL/Dead6/Nodes/FlowBuildingControllerNodes.h
8a14932dcc55812c46390a2a8791493c468ee876
[]
no_license
richmondx/dead6
b0e9dd94a0ebb297c0c6e9c4f24c6482ef4d5161
955f76f35d94ed5f991871407f3d3ad83f06a530
refs/heads/master
2021-12-05T14:32:01.782047
2008-01-01T13:13:39
2008-01-01T13:13:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
16,569
h
//////////////////////////////////////////////////// // C&C: The Dead 6 - Core File // Copyright (C), RenEvo Software & Designs, 2007 // // FlowBuildingControllerNodes.h // // Purpose: Flow Nodes for Building Controllers // // File History: // - 8/23/07 : File created - KAK //////////////////////////////////////////////////// #ifndef _D6C_FLOWBUILDINGCONTROLLERNODES_H_ #define _D6C_FLOWBUILDINGCONTROLLERNODES_H_ #include "Nodes/G2FlowBaseNode.h" #include "IBaseManager.h" #include "IBuildingController.h" // CBuildingControllerGeneralListenerNode // Simple node that lets you listen for basic controller events class CBuildingControllerGeneralListenerNode : public CFlowBaseNode, public IBuildingControllerEventListener { protected: // Building GUID BuildingGUID m_nGUID; // Activation info SActivationInfo m_actInfo; public: //////////////////////////////////////////////////// // Constructor //////////////////////////////////////////////////// CBuildingControllerGeneralListenerNode(SActivationInfo * pActInfo); //////////////////////////////////////////////////// // Destructor //////////////////////////////////////////////////// virtual ~CBuildingControllerGeneralListenerNode(); //////////////////////////////////////////////////// // Clone // // Purpose: Used to clone the controller // // In: pActInfo - Activation info //////////////////////////////////////////////////// IFlowNodePtr Clone(SActivationInfo *pActInfo) { return new CBuildingControllerGeneralListenerNode(pActInfo); } //////////////////////////////////////////////////// // Seralize // // Purpose: Used for saving/loading node's instance // // In: pActInfo - Activation info // ser - Serialization object //////////////////////////////////////////////////// void Serialize(SActivationInfo* pActInfo, TSerialize ser); // Input Ports enum EInputPorts { EIP_Enable = 0, // Bool: Turn it on/off EIP_Team, // String: Team name EIP_Class, // String: Class name }; // Output Ports enum EOutputPorts { EOP_Validated = 0, // Triggered when controller has been validated EOP_Reset, // Triggered when controller has been reset EOP_PowerChanged, // Triggered when controller's power status changed EOP_Destroyed, // Triggered when controller is destroyed }; //////////////////////////////////////////////////// // GetConfiguration // // Purpose: Set up and return the configuration for // this node for the Flow Graph // // Out: config - The node's config //////////////////////////////////////////////////// virtual void GetConfiguration(SFlowNodeConfig& config); //////////////////////////////////////////////////// // ProcessEvent // // Purpose: Called when an event is to be processed // // In: event - Flow event to process // pActInfo - Activation info for the event //////////////////////////////////////////////////// virtual void ProcessEvent(EFlowEvent event, SActivationInfo *pActInfo); //////////////////////////////////////////////////// // GetMemoryStatistics // // Purpose: Used by memory management // // In: s - Cry Sizer object //////////////////////////////////////////////////// virtual void GetMemoryStatistics(ICrySizer *s) { s->Add(*this); } //////////////////////////////////////////////////// // AddListener // // Purpose: Add to controller's listener list // // In: pActInfo - Activation info //////////////////////////////////////////////////// virtual void AddListener(SActivationInfo *pActInfo); //////////////////////////////////////////////////// // OnBuildingControllerEvent // // Purpose: Called when event occurs on controller // // In: pController - Building controller object // nGUID - Controller's BuildingGUID // event - Event that occured // // Note: See SControllerEvent //////////////////////////////////////////////////// virtual void OnBuildingControllerEvent(IBuildingController *pController, BuildingGUID nGUID, SControllerEvent &event); }; // CBuildingControllerDamageListenerNode // Simple node that lets you listen for damage-specific controller events class CBuildingControllerDamageListenerNode : public CFlowBaseNode, public IBuildingControllerEventListener { protected: // Building GUID BuildingGUID m_nGUID; // Activation info SActivationInfo m_actInfo; public: //////////////////////////////////////////////////// // Constructor //////////////////////////////////////////////////// CBuildingControllerDamageListenerNode(SActivationInfo * pActInfo); //////////////////////////////////////////////////// // Destructor //////////////////////////////////////////////////// virtual ~CBuildingControllerDamageListenerNode(); //////////////////////////////////////////////////// // Clone // // Purpose: Used to clone the controller // // In: pActInfo - Activation info //////////////////////////////////////////////////// IFlowNodePtr Clone(SActivationInfo *pActInfo) { return new CBuildingControllerDamageListenerNode(pActInfo); } //////////////////////////////////////////////////// // Seralize // // Purpose: Used for saving/loading node's instance // // In: pActInfo - Activation info // ser - Serialization object //////////////////////////////////////////////////// void Serialize(SActivationInfo* pActInfo, TSerialize ser); // Input Ports enum EInputPorts { EIP_Enable = 0, // Bool: Turn it on/off EIP_Team, // String: Team name EIP_Class, // String: Class name EIP_Hits, // Bool: TRUE to listen for hits EIP_Explosions, // Bool: TRUE to listen for explosions // Limiting input ports EIP_ShooterId, EIP_TargetId, EIP_Weapon, EIP_Ammo }; // Output Ports enum EOutputPorts { EOP_OnDamage = 0, // Triggered when damage has occured // Damage-specific items EOP_ShooterId, EOP_TargetId, EOP_WeaponId, EOP_ProjectileId, EOP_HitPos, EOP_HitDir, EOP_HitNormal, EOP_HitType, EOP_Damage, EOP_Material, }; //////////////////////////////////////////////////// // GetConfiguration // // Purpose: Set up and return the configuration for // this node for the Flow Graph // // Out: config - The node's config //////////////////////////////////////////////////// virtual void GetConfiguration(SFlowNodeConfig& config); //////////////////////////////////////////////////// // ProcessEvent // // Purpose: Called when an event is to be processed // // In: event - Flow event to process // pActInfo - Activation info for the event //////////////////////////////////////////////////// virtual void ProcessEvent(EFlowEvent event, SActivationInfo *pActInfo); //////////////////////////////////////////////////// // GetMemoryStatistics // // Purpose: Used by memory management // // In: s - Cry Sizer object //////////////////////////////////////////////////// virtual void GetMemoryStatistics(ICrySizer *s) { s->Add(*this); } //////////////////////////////////////////////////// // AddListener // // Purpose: Add to controller's listener list // // In: pActInfo - Activation info //////////////////////////////////////////////////// virtual void AddListener(SActivationInfo *pActInfo); //////////////////////////////////////////////////// // OnBuildingControllerEvent // // Purpose: Called when event occurs on controller // // In: pController - Building controller object // nGUID - Controller's BuildingGUID // event - Event that occured // // Note: See SControllerEvent //////////////////////////////////////////////////// virtual void OnBuildingControllerEvent(IBuildingController *pController, BuildingGUID nGUID, SControllerEvent &event); }; // CBuildingControllerViewListenerNode // Simple node that lets you listen for view-specific controller events class CBuildingControllerViewListenerNode : public CFlowBaseNode, public IBuildingControllerEventListener { protected: // Building GUID BuildingGUID m_nGUID; // Activation info SActivationInfo m_actInfo; public: //////////////////////////////////////////////////// // Constructor //////////////////////////////////////////////////// CBuildingControllerViewListenerNode(SActivationInfo * pActInfo); //////////////////////////////////////////////////// // Destructor //////////////////////////////////////////////////// virtual ~CBuildingControllerViewListenerNode(); //////////////////////////////////////////////////// // Clone // // Purpose: Used to clone the controller // // In: pActInfo - Activation info //////////////////////////////////////////////////// IFlowNodePtr Clone(SActivationInfo *pActInfo) { return new CBuildingControllerViewListenerNode(pActInfo); } //////////////////////////////////////////////////// // Seralize // // Purpose: Used for saving/loading node's instance // // In: pActInfo - Activation info // ser - Serialization object //////////////////////////////////////////////////// void Serialize(SActivationInfo* pActInfo, TSerialize ser); // Input Ports enum EInputPorts { EIP_Enable = 0, // Bool: Turn it on/off EIP_Team, // String: Team name EIP_Class, // String: Class name }; // Output Ports enum EOutputPorts { EOP_InView = 0, // Triggered when controller is in view by local client EOP_OutOfView, // Triggered when controller is no loner in view by local client }; //////////////////////////////////////////////////// // GetConfiguration // // Purpose: Set up and return the configuration for // this node for the Flow Graph // // Out: config - The node's config //////////////////////////////////////////////////// virtual void GetConfiguration(SFlowNodeConfig& config); //////////////////////////////////////////////////// // ProcessEvent // // Purpose: Called when an event is to be processed // // In: event - Flow event to process // pActInfo - Activation info for the event //////////////////////////////////////////////////// virtual void ProcessEvent(EFlowEvent event, SActivationInfo *pActInfo); //////////////////////////////////////////////////// // GetMemoryStatistics // // Purpose: Used by memory management // // In: s - Cry Sizer object //////////////////////////////////////////////////// virtual void GetMemoryStatistics(ICrySizer *s) { s->Add(*this); } //////////////////////////////////////////////////// // AddListener // // Purpose: Add to controller's listener list // // In: pActInfo - Activation info //////////////////////////////////////////////////// virtual void AddListener(SActivationInfo *pActInfo); //////////////////////////////////////////////////// // OnBuildingControllerEvent // // Purpose: Called when event occurs on controller // // In: pController - Building controller object // nGUID - Controller's BuildingGUID // event - Event that occured // // Note: See SControllerEvent //////////////////////////////////////////////////// virtual void OnBuildingControllerEvent(IBuildingController *pController, BuildingGUID nGUID, SControllerEvent &event); }; // CBuildingControllerHasPowerNode // Simple node that lets you check the power status of a building class CBuildingControllerHasPowerNode : public CFlowBaseNode { public: //////////////////////////////////////////////////// // Constructor //////////////////////////////////////////////////// CBuildingControllerHasPowerNode(SActivationInfo * pActInfo); //////////////////////////////////////////////////// // Destructor //////////////////////////////////////////////////// virtual ~CBuildingControllerHasPowerNode(); //////////////////////////////////////////////////// // Clone // // Purpose: Used to clone the controller // // In: pActInfo - Activation info //////////////////////////////////////////////////// IFlowNodePtr Clone(SActivationInfo *pActInfo) { return new CBuildingControllerHasPowerNode(pActInfo); } //////////////////////////////////////////////////// // Seralize // // Purpose: Used for saving/loading node's instance // // In: pActInfo - Activation info // ser - Serialization object //////////////////////////////////////////////////// void Serialize(SActivationInfo* pActInfo, TSerialize ser); // Input Ports enum EInputPorts { EIP_Check = 0, // Check the power status EIP_Team, // String: Team name EIP_Class, // String: Class name }; // Output Ports enum EOutputPorts { EOP_Status = 0, // Triggered when check occurs. Returns TRUE if controller has power, FALSE if it doesn't. EOP_Power, // Triggered if controller has power EOP_NoPower, // Triggered if controller does not have power }; //////////////////////////////////////////////////// // GetConfiguration // // Purpose: Set up and return the configuration for // this node for the Flow Graph // // Out: config - The node's config //////////////////////////////////////////////////// virtual void GetConfiguration(SFlowNodeConfig& config); //////////////////////////////////////////////////// // ProcessEvent // // Purpose: Called when an event is to be processed // // In: event - Flow event to process // pActInfo - Activation info for the event //////////////////////////////////////////////////// virtual void ProcessEvent(EFlowEvent event, SActivationInfo *pActInfo); //////////////////////////////////////////////////// // GetMemoryStatistics // // Purpose: Used by memory management // // In: s - Cry Sizer object //////////////////////////////////////////////////// virtual void GetMemoryStatistics(ICrySizer *s) { s->Add(*this); } }; // CBuildingControllerSetPowerNode // Simple node that lets you set the power status of a building class CBuildingControllerSetPowerNode : public CFlowBaseNode { public: //////////////////////////////////////////////////// // Constructor //////////////////////////////////////////////////// CBuildingControllerSetPowerNode(SActivationInfo * pActInfo); //////////////////////////////////////////////////// // Destructor //////////////////////////////////////////////////// virtual ~CBuildingControllerSetPowerNode(); //////////////////////////////////////////////////// // Clone // // Purpose: Used to clone the controller // // In: pActInfo - Activation info //////////////////////////////////////////////////// IFlowNodePtr Clone(SActivationInfo *pActInfo) { return new CBuildingControllerSetPowerNode(pActInfo); } //////////////////////////////////////////////////// // Seralize // // Purpose: Used for saving/loading node's instance // // In: pActInfo - Activation info // ser - Serialization object //////////////////////////////////////////////////// void Serialize(SActivationInfo* pActInfo, TSerialize ser); // Input Ports enum EInputPorts { EIP_Set = 0, // Set the power status EIP_SetWithValue, // Set the power status using input value EIP_Team, // String: Team name EIP_Class, // String: Class name EIP_Value, // Bool: Power status }; // Output Ports enum EOutputPorts { EOP_Done = 0, // Triggered when status is set }; //////////////////////////////////////////////////// // GetConfiguration // // Purpose: Set up and return the configuration for // this node for the Flow Graph // // Out: config - The node's config //////////////////////////////////////////////////// virtual void GetConfiguration(SFlowNodeConfig& config); //////////////////////////////////////////////////// // ProcessEvent // // Purpose: Called when an event is to be processed // // In: event - Flow event to process // pActInfo - Activation info for the event //////////////////////////////////////////////////// virtual void ProcessEvent(EFlowEvent event, SActivationInfo *pActInfo); //////////////////////////////////////////////////// // GetMemoryStatistics // // Purpose: Used by memory management // // In: s - Cry Sizer object //////////////////////////////////////////////////// virtual void GetMemoryStatistics(ICrySizer *s) { s->Add(*this); } }; #endif //_D6C_FLOWBUILDINGCONTROLLERNODES_H_
[ "kkirst@c5e09591-5635-0410-80e3-0b71df3ecc31" ]
[ [ [ 1, 555 ] ] ]
0f5167e6977d7384f1e8f63b1b916f42b0af5458
bfe8eca44c0fca696a0031a98037f19a9938dd26
/TelecomDll/StdAfx.cpp
9f268cea1e76b73a12d19d03734b2100a349ab87
[]
no_license
luge/foolject
a190006bc0ed693f685f3a8287ea15b1fe631744
2f4f13a221a0fa2fecab2aaaf7e2af75c160d90c
refs/heads/master
2021-01-10T07:41:06.726526
2011-01-21T10:25:22
2011-01-21T10:25:22
36,303,977
0
0
null
null
null
null
UTF-8
C++
false
false
297
cpp
// stdafx.cpp : source file that includes just the standard includes // TelecomDll.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file
[ "greatfoolbear@756bb6b0-a119-0410-8338-473b6f1ccd30" ]
[ [ [ 1, 8 ] ] ]
e8a902e271b271a1f796ab5fdbbaf14944e43fca
e2e49023f5a82922cb9b134e93ae926ed69675a1
/tools/aosdesigner/view/FreeWindowManager.hpp
69f42a5b434e5ba517743bda19a50b382cca874e
[]
no_license
invy/mjklaim-freewindows
c93c867e93f0e2fe1d33f207306c0b9538ac61d6
30de8e3dfcde4e81a57e9059dfaf54c98cc1135b
refs/heads/master
2021-01-10T10:21:51.579762
2011-12-12T18:56:43
2011-12-12T18:56:43
54,794,395
1
0
null
null
null
null
UTF-8
C++
false
false
757
hpp
#ifndef HGUARD_AOSD_VIEW_FREEWINDOWMANAGER_HPP__ #define HGUARD_AOSD_VIEW_FREEWINDOWMANAGER_HPP__ #pragma once #include <map> #include <memory> #include "view/FreeWindow.hpp" class QWidget; class QMdiArea; namespace aosd { namespace view { /** Manage a set of FreeWindow that are used in an MdiArea. **/ class FreeWindowManager { public: FreeWindowManager( QMdiArea& internal_area ); ~FreeWindowManager(); FreeWindow& add_window( QWidget& widget ); void remove_window( QWidget& widget ); FreeWindow* find_window( QWidget& widget ); void clear(); private: std::map< QWidget*, std::unique_ptr<FreeWindow> > m_windows_registry; QMdiArea& m_internal_area; }; } } #endif
[ "klaim@localhost" ]
[ [ [ 1, 48 ] ] ]
d428865a1b053c67d110da22ba0462652c4813da
619941b532c6d2987c0f4e92b73549c6c945c7e5
/Stellar_/code/Render/resources/resourceId.cc
49cd7cf36d8f9424a262ea6b4df1ca228fe27ded
[]
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
463
cc
//------------------------------------------------------------------------------ // resourceid.cc // (C) 2007 by ctuo //------------------------------------------------------------------------------ #include "stdneb.h" #include "resources/resourceId.h" //------------------------------------------------------------------------------ namespace Resources { //ImplementClass(Resources::ResourceId, 'RSRD', Core::RefCounted); } // namespace Resources
[ "ctuoMail@5f320639-c338-0410-82ad-c55551ec1e38" ]
[ [ [ 1, 13 ] ] ]
1b269f0f1f32157009df45f589501e3e725c9767
fac8de123987842827a68da1b580f1361926ab67
/inc/physics/Common/Base/Memory/Memory/Debug/hkStlDebugMemory.h
c2671d7683010ee08063ac8012ce4ba531a28f86
[]
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
22,520
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. * */ // The demoframework will use hkStlDebugMemory if the demos project properties // is given the "-c" (mem Check) option in 'Debugging->Command Arguments'. // hkStlDebugMemory will not operate in debug configuration as defined by Havok. // Debug configuration is an optimized build with line numbers enabled. // If there are memory leaks, their location and call stack // are printed to the debug window. #ifndef HK_STL_DEBUG_MEMORY_H #define HK_STL_DEBUG_MEMORY_H #include <Common/Base/Memory/Memory/hkMemory.h> #include <Common/Base/Memory/StackTracer/hkStackTracer.h> #include <Common/Base/Thread/CriticalSection/hkCriticalSection.h> #include <Common/Base/Memory/Memory/Debug/hkDebugMemory.h> #include <Common/Base/Memory/hkDebugMemorySnapshot.h> // use STL here so we avoid memory recursion. #include <map> #if defined(HK_PLATFORM_PS3) && (_HAS_EXCEPTIONS==0) && HK_CELL_SDK_VERSION < 0x190002 void std::exception::_Raise() const { HK_BREAKPOINT(0); } #endif #if defined(HK_PLATFORM_WIN32) || defined(HK_PLATFORM_XBOX) || defined(HK_PLATFORM_XBOX360) # define PTR_CLASS _FARQ # else # define PTR_CLASS /*nothing*/ #endif template <typename T> class hkAllocator : public std::allocator<T> { public: hkAllocator() {} template <typename U> hkAllocator(const hkAllocator<U>&) {}; char PTR_CLASS * _Charalloc(size_t size) { return (char PTR_CLASS *)malloc( size ); } T PTR_CLASS * allocate(size_t count) { return (T PTR_CLASS *)malloc( count * sizeof(T) ); } void deallocate(void PTR_CLASS * ptr, size_t ) { free(ptr); } template <typename U> struct rebind { typedef hkAllocator<U> other; }; }; class hkDebugMemorySnapshot; /// Memory implementation to find common memory problems. /// hkStlDebugMemory finds leaks, multiple frees and underrun/overruns. /// hkStlDebugMemory always scrubs allocations in contrast to hkPoolMemory /// which only scrubs when HK_DEBUG is defined. /// See the userguide for more details.<p> class hkStlDebugMemory : public hkDebugMemory { public: typedef void (HK_CALL *OutputStringFunc)(const char* s, void* arg); static void HK_CALL defaultOutputStringFunc(const char* s, void* a); virtual void allocateChunkBatch(void** blocksOut, int nblocks, int nbytes ) { for( int i = 0; i < nblocks; ++i ) { blocksOut[i] = allocateChunk(nbytes, HK_MEMORY_CLASS_ROOT); } } virtual void deallocateChunkBatch(void** blocks, int nblocks, int nbytes ) { for( int i = 0; i < nblocks; ++i ) { deallocateChunk(blocks[i], nbytes, HK_MEMORY_CLASS_ROOT); } } hkStlDebugMemory( OutputStringFunc outFunc = defaultOutputStringFunc, void* funcArg = HK_NULL, hkUint32 maxStackTrace = MAX_STACKTRACE); ~hkStlDebugMemory(); virtual void* allocateChunk(int nbytes, HK_MEMORY_CLASS cl); virtual void deallocateChunk(void*, int nbytes, HK_MEMORY_CLASS ); virtual void preAllocateRuntimeBlock(int nbytes, HK_MEMORY_CLASS cl); virtual void* allocateRuntimeBlock(int nbytes, HK_MEMORY_CLASS cl); virtual void deallocateRuntimeBlock(void*, int nbytes, HK_MEMORY_CLASS cl); virtual void provideRuntimeBlock(void*, int nbytes, HK_MEMORY_CLASS cl); virtual void registerStaticAddress(void*, int nbytes); virtual void freeRuntimeBlocks(); virtual void printStatistics(hkOstream* c); virtual hkBool isOk() const; virtual void* findBaseAddress(void* p, int nbytes); virtual void lockBlock(void* p); virtual void unlockBlock(void* p); virtual void calculateStatistics(hkMemoryStatistics& stats); virtual hkBool hasMemoryAvailable(hk_size_t size); virtual void setLimitedMemoryListener(hkLimitedMemoryListener* listener) { hkCriticalSectionLock lock( &m_section ); m_listener = listener; } virtual hkLimitedMemoryListener* getLimitedMemoryListener() { return m_listener; } virtual void setMemoryHardLimit(hk_size_t maxMemory) { hkCriticalSectionLock lock( &m_section ); if (maxMemory==0) { m_hardLimit = maxMemory; return; } HK_ASSERT(0x3423434,!(maxMemory < hk_size_t(m_sysAllocsSize))); if (maxMemory < hk_size_t(m_sysAllocsSize)) { return; } HK_ASSERT(0x3423434,!(m_softLimit!=0&&maxMemory<m_softLimit)); if (m_softLimit!=0&&maxMemory<m_softLimit) { return; } m_hardLimit = maxMemory; } virtual hk_size_t getMemoryHardLimit() { return m_hardLimit; } virtual void setMemorySoftLimit(hk_size_t maxMemory) { hkCriticalSectionLock lock( &m_section ); if (maxMemory==0) { m_softLimit = 0; return; } HK_ASSERT(0x3424344,!(m_hardLimit && maxMemory > m_hardLimit)); if (m_hardLimit && maxMemory > m_hardLimit) { return; } m_softLimit = maxMemory; } virtual hk_size_t getMemorySoftLimit() { return m_softLimit; } protected: void printMemoryReport(); virtual void* internalAllocate(int nbytes, HK_MEMORY_CLASS, int flags, int alignment=16); virtual void internalFree(void* p, int bytesToFree, int flags); void outputString(const char* s) { (*m_outputStringFunc)(s, m_outputStringArg); } public: /// Overriding hkDebugMemory virtual void setAllocationMark(int mark); virtual int getAllocationMark() { return m_mark; } virtual void getSnapshot(int mark,hkBool mask,hkDebugMemorySnapshot& snapshot); virtual hkBool getPointerInfo(const void* ptr,PointerInfo& out); #if defined ( HK_PLATFORM_WIN32 ) && (HK_COMPILER_MSVC_VERSION >= 1400) typedef std::map<void*, PointerInfo, std::less<void*>, hkAllocator< std::pair <const void*, PointerInfo> > > Map; #else typedef std::map<void*, PointerInfo, std::less<void*> > Map; #endif protected: Map m_activePointers; OutputStringFunc m_outputStringFunc; void* m_outputStringArg; hkUint32 m_maxStackTrace; hkStackTracer m_tracer; mutable hkCriticalSection m_section; int m_mark; /// All the statistics of the same style as the old stats collector int m_numSysAllocs; /// The total number of bytes allocated by the system memory int m_sysAllocsSize; /// The current maximum of the total number of bytes allocated by the system memory int m_sysAllocsHighMark; /// The limited memory listener hkLimitedMemoryListener* m_listener; /// The total amount of memory we're allowing allocation on hk_size_t m_softLimit; hk_size_t m_hardLimit; }; /// The implementation. /// The reason this is not inside of a .cpp file is so that there isn't a dependency in the lib with STL, which is /// what the implementation uses for block tracking. hkStlDebugMemory::hkStlDebugMemory( OutputStringFunc func, void* arg, hkUint32 maxStackTrace) : m_outputStringFunc(func), m_outputStringArg(arg), m_maxStackTrace(maxStackTrace), m_section(0), m_mark(0), m_listener(HK_NULL), m_softLimit(0), m_hardLimit(0) { m_numSysAllocs =0 ; m_sysAllocsSize = 0; m_sysAllocsHighMark = 0; } hkStlDebugMemory::~hkStlDebugMemory() { printMemoryReport(); } hkBool hkStlDebugMemory::hasMemoryAvailable(hk_size_t size) { hk_size_t limit = m_softLimit?m_softLimit:m_hardLimit; if (limit == 0) return true; /// Consider 4k as the minimum memory workspace if (size ==0) size = 4*1024; hk_size_t remaining = limit - m_sysAllocsSize; return size<remaining; } void hkStlDebugMemory::calculateStatistics(hkMemoryStatistics& stats) { stats.m_allocated = m_sysAllocsSize; stats.m_used = m_sysAllocsSize; // <js.todo.a use :: stylee stats.m_available = stats.INFINITE_SIZE; stats.m_totalAvailable = stats.INFINITE_SIZE; stats.m_largestBlock = stats.INFINITE_SIZE; if (m_hardLimit != 0) { stats.m_available = m_hardLimit - m_sysAllocsSize; stats.m_totalAvailable = m_hardLimit - m_sysAllocsSize; stats.m_largestBlock = m_hardLimit - m_sysAllocsSize; } } void // <js.todo.aaa change mask into enum and make it first parameter hkStlDebugMemory::getSnapshot( int mark, hkBool mask, hkDebugMemorySnapshot& snapshot ) { hkCriticalSectionLock lock( &m_section ); snapshot.reset(); int numAllocs = 0; // Determine how many pointers pass the mark/mask filter. const hkStlDebugMemory::Map::iterator m_activePointersEnd = m_activePointers.end(); if( mask && ( mark == 0 ) ) { // If the mark is a mask with no bits set (0x0000), then all pointers pass the filter. numAllocs = m_activePointers.size(); } else { // Gotta count them manually. for( hkStlDebugMemory::Map::iterator i = m_activePointers.begin(); i != m_activePointersEnd; ++i ) { PointerInfo& inInfo = i->second; if (mask) { if (mark == 0 || (mark & inInfo.mark) !=0 ) numAllocs++; } else { if (inInfo.mark == mark) numAllocs++; } } } // If we have no objects to report, we're done if( numAllocs == 0 ) { return; } // Allocate the memory snapshot.m_size = numAllocs; snapshot.m_info = (PointerInfo*)hkSystemMalloc(sizeof(PointerInfo)*numAllocs,16); snapshot.m_pointers = (void**)hkSystemMalloc(sizeof(void*)*numAllocs,16); // Fill up the records PointerInfo* outInfo = snapshot.m_info; void** ptr = snapshot.m_pointers; for( hkStlDebugMemory::Map::iterator i = m_activePointers.begin(); i != m_activePointersEnd; ++i ) { PointerInfo& inInfo = i->second; if (mask) { if (mark != 0 && (mark & inInfo.mark)==0) { continue; } } else { if (inInfo.mark != mark) { continue; } } *ptr = i->first; *outInfo = i->second; outInfo++; ptr++; } HK_ASSERT2( 0xdafec31b, outInfo == ( snapshot.m_info + snapshot.m_size ), "Allocated the wrong number of pointer info records." ); } hkBool hkStlDebugMemory::getPointerInfo(const void* ptrIn,PointerInfo& out) { hkCriticalSectionLock lock( &m_section ); void* ptr = const_cast<void*>(ptrIn); hkStlDebugMemory::Map::iterator i = m_activePointers.find(ptr); if ( i != m_activePointers.end()) { out = i->second; return true; } return false; } void hkStlDebugMemory::printMemoryReport() { hkCriticalSectionLock lock( &m_section ); if( m_activePointers.size() != 0) { hkStlDebugMemory::Map::iterator i = m_activePointers.begin(); hkStlDebugMemory::Map::iterator e = m_activePointers.end(); outputString("**************************************************************\n"); outputString("* BEGIN MEMORY LEAK REPORT *\n"); outputString("**************************************************************\n"); for( ; i!=e; ++i) { const PointerInfo& pinfo = i->second; char buf[256]; hkString::snprintf(buf, 256, "\n%i bytes leaked. Data at 0x%p. Stack trace follows:\n", pinfo.numBytes, i->first ); outputString(buf); // skip first two frames - they are always allocateX/internalAllocate m_tracer.dumpStackTrace( pinfo.stackTraces + 2, pinfo.numStackTrace - 2, m_outputStringFunc, m_outputStringArg ); } outputString("**************************************************************\n"); outputString("* END MEMORY LEAK REPORT *\n"); outputString("**************************************************************\n"); } else { outputString("**************************************************************\n"); outputString("* NO HAVOK MEMORY LEAKS FOUND *\n"); outputString("**************************************************************\n"); } } void hkStlDebugMemory::printStatistics(hkOstream* c) { hkCriticalSectionLock lock( &m_section ); if(c) { c->printf("\n"); c->printf("************************************************************************************** *\n"); c->printf("* Debug memory doesn't support memory classes. Therefore no statistics available here. *\n"); c->printf("************************************************************************************** *\n"); c->printf("\n"); } } static void HK_CALL checkUnderOverrun(void* pfree, const hkDebugMemory::PointerInfo& info) { hkUint8* check = static_cast<hkUint8*>(info.realMem); int prepadBytes = (int)hkUlong( static_cast<char*>(pfree) - static_cast<char*>(info.realMem) ); int i; for( i = 0; i < prepadBytes; ++i ) { HK_ASSERT(0x6af0c498, check[i] == hkMemory::s_fillGuardArea); } check += prepadBytes + info.numBytes; for( i = 0; i < hkStlDebugMemory::MEMORY_PADDING; ++i ) { HK_ASSERT(0x431a98ae, check[i] == hkMemory::s_fillGuardArea); } } void hkStlDebugMemory::setAllocationMark(int mark) { hkCriticalSectionLock lock( &m_section ); m_mark = mark; } void* hkStlDebugMemory::internalAllocate(int nbytes, HK_MEMORY_CLASS, int flags, int alignment ) { if( nbytes ) { hkCriticalSectionLock lock( &m_section ); if (m_hardLimit&&m_sysAllocsSize + hk_size_t(nbytes) > m_hardLimit) { /// Say we can't allocate if (m_listener) { m_listener->cannotAllocate(this,nbytes); /// See if the callback helped... if not we fail if (m_sysAllocsSize + hk_size_t(nbytes) > m_hardLimit) { /// Inform we failed m_listener->allocationFailure(this,nbytes); /// Return NULL return HK_NULL; } } else { // We failed return HK_NULL; } } PointerInfo pointerinfo; pointerinfo.numStackTrace = m_tracer.getStackTrace(pointerinfo.stackTraces, m_maxStackTrace); pointerinfo.numBytes = nbytes; pointerinfo.flags = flags; pointerinfo.mark = m_mark; HK_ASSERT( 0x1be63280, MEMORY_PADDING >= 4 ); HK_ASSERT( 0x1be63281, (MEMORY_PADDING % sizeof(int)) == 0 ); HK_ASSERT( 0x1be63282, (alignment % sizeof(int)) == 0 ); // allocate a little more (MEMORY_PADDING) at each end hk_size_t postpad = MEMORY_PADDING; // if alignment greater than padding is requested we need to be careful hk_size_t prepad = (MEMORY_PADDING >= alignment) ? MEMORY_PADDING : alignment; pointerinfo.realMem = hkSystemMalloc( int(nbytes + prepad + postpad), alignment); char* realMem = static_cast<char*>(pointerinfo.realMem); // scrub memory hkString::memSet( realMem, s_fillGuardArea, int(prepad) ); hkString::memSet( realMem + prepad, s_fillReturnedToUser, nbytes ); hkString::memSet( realMem + prepad + nbytes, s_fillGuardArea, int(postpad) ); // ///// //char* start = realMem + prepad; //char* end = start + nbytes; //char* start4 = (char*)HK_NEXT_MULTIPLE_OF(4, hkUlong(start)); //char* end4 = (char*)HK_NEXT_MULTIPLE_OF(4, hkUlong(end+1)) - 4; //start4 = hkMath::min2(start4, end); //end4 = hkMath::max2(end4, start); //HK_ASSERT2(0xad8750dd, (start4 <= end4) ^ ((hkUlong(start4) & 0x3) || (hkUlong(end4) & 0x3)), "Hmm"); //if (start4 <= end4) //{ // hkString::memSet(start, s_fillReturnedToUser, start4-start); // hkReal max = HK_REAL_MAX; or use nans // hkString::memSet4(start4, (int&)(max), (end4-start4)>>2); // hkString::memSet(end4, s_fillReturnedToUser, end-end4); //} //else //{ // hkString::memSet( realMem + prepad, s_fillReturnedToUser, nbytes ); //} ///// void* memory = realMem + prepad; m_activePointers[memory] = pointerinfo; m_numSysAllocs += 1; m_sysAllocsSize += nbytes; if( m_sysAllocsSize > m_sysAllocsHighMark ) { m_sysAllocsHighMark = m_sysAllocsSize; } return memory; } else { return HK_NULL; } } void hkStlDebugMemory::internalFree(void* pfree, int bytesToFree, int flags) { hkCriticalSectionLock lock( &m_section ); hkStlDebugMemory::Map::iterator i = m_activePointers.find(pfree); HK_ASSERT2( 0x356976c1, i != m_activePointers.end(), "Freeing junk pointer"); const PointerInfo& info = i->second; HK_ASSERT2( 0xaf53fe12, info.m_lockCount <= 0, "Freeing locked memory block."); HK_ASSERT2( 0x5861b912, (info.flags & MEM_ALIGNED) == (flags & MEM_ALIGNED), "Mismatched aligned methods"); HK_ASSERT2( 0x5861b913, (info.flags & MEM_CHUNK) == (flags & MEM_CHUNK), "Mismatched chunk methods"); if(bytesToFree == -1) { HK_ASSERT2( 0x5861b911, (flags & MEM_CHUNK) == 0, "Calling deallocate on a chunk"); } else { HK_ASSERT2( 0x743ce000, info.numBytes == bytesToFree, "Freeing chunk of wrong size"); } checkUnderOverrun(pfree, info); { // scrub area int prepadBytes = (int)hkUlong( static_cast<char*>(pfree) - static_cast<char*>(info.realMem) ); hkString::memSet( info.realMem, s_fillFreeSpace, prepadBytes + info.numBytes + MEMORY_PADDING ); } m_numSysAllocs -= 1; m_sysAllocsSize -= bytesToFree; hkSystemFree( info.realMem ); m_activePointers.erase(i); } void* hkStlDebugMemory::allocateChunk(int nbytes, HK_MEMORY_CLASS c) { return internalAllocate(nbytes, c, MEM_CHUNK); } void hkStlDebugMemory::deallocateChunk(void* p, int nbytes, HK_MEMORY_CLASS cl) { if(p) { internalFree(p, nbytes, MEM_CHUNK); } } hkBool hkStlDebugMemory::isOk() const { hkCriticalSectionLock lock( &m_section ); hkStlDebugMemory::Map::const_iterator i = m_activePointers.begin(); hkStlDebugMemory::Map::const_iterator e = m_activePointers.end(); for( ; i!=e; ++i) { checkUnderOverrun( i->first, i->second ); } return true; } #ifdef HK_PLATFORM_WIN32 # include <Common/Base/Fwd/hkwindows.h> void HK_CALL hkStlDebugMemory::defaultOutputStringFunc( const char* s, void* context) { OutputDebugStringA(s); printf("%s",s); // Also output to console for automated testing } #else # include <Common/Base/Fwd/hkcstdio.h> void HK_CALL hkStlDebugMemory::defaultOutputStringFunc( const char* s, void* context) { using namespace std; printf("%s",s); } #endif void hkStlDebugMemory::preAllocateRuntimeBlock(int nbytes, HK_MEMORY_CLASS cl) { } void* hkStlDebugMemory::allocateRuntimeBlock(int nbytes, HK_MEMORY_CLASS cl) { void* memory = allocateChunk(nbytes, cl); return memory; } void hkStlDebugMemory::deallocateRuntimeBlock(void* p, int nbytes, HK_MEMORY_CLASS cl) { deallocateChunk(p, nbytes, cl); } void hkStlDebugMemory::provideRuntimeBlock(void*, int nbytes, HK_MEMORY_CLASS cl) { } void hkStlDebugMemory::registerStaticAddress(void* address, int nbytes) { PointerInfo pointerinfo; { pointerinfo.numBytes = nbytes; pointerinfo.flags = MEM_CHUNK; pointerinfo.mark = m_mark; pointerinfo.realMem = address; } m_activePointers[address] = pointerinfo; } void hkStlDebugMemory::freeRuntimeBlocks() { } void* hkStlDebugMemory::findBaseAddress(void* p, int nbytes) { // try to use p as a base address { hkStlDebugMemory::Map::iterator i = m_activePointers.find(p); if ( i != m_activePointers.end()) { HK_ON_DEBUG( const PointerInfo& pinfo = i->second; ) HK_ASSERT2( 0xf0457ef5, hkAddByteOffset(p, nbytes) <= hkAddByteOffset(i->first, pinfo.numBytes), "Invalid Block" ); return i->first; } } // try to walk backward from p { void* q = (void*)(HK_NEXT_MULTIPLE_OF(16, hkUlong(p))); for (int n = 0; n < 50; n++) { q = hkAddByteOffset(q, hkUlong(-16)); hkStlDebugMemory::Map::iterator i = m_activePointers.find(q); if ( i != m_activePointers.end()) { HK_ON_DEBUG( const PointerInfo& pinfo = i->second; ) HK_ASSERT2( 0xf0457ef5, hkAddByteOffset(p, nbytes) <= hkAddByteOffset(i->first, pinfo.numBytes), "Invalid Block" ); return i->first; } } } // search the full list { hkStlDebugMemory::Map::iterator i = m_activePointers.begin(); hkStlDebugMemory::Map::iterator e = m_activePointers.end(); for( ; i!=e; ++i) { const PointerInfo& pinfo = i->second; if ( i->first <= p && hkAddByteOffset(p, nbytes) <= hkAddByteOffset(i->first, pinfo.numBytes) ) { return i->first; } } } HK_ASSERT2(0xaf543fe2, false, "Invalid memory block."); return HK_NULL; } void hkStlDebugMemory::lockBlock(void* p) { hkStlDebugMemory::Map::iterator i = m_activePointers.find(p); PointerInfo& pinfo = i->second; pinfo.m_lockCount++; } void hkStlDebugMemory::unlockBlock(void* p) { hkStlDebugMemory::Map::iterator i = m_activePointers.find(p); PointerInfo& pinfo = i->second; pinfo.m_lockCount--; } #endif // HK_STL_DEBUG_MEMORY_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, 727 ] ] ]
473423238367af377be15313322f00cb183285dd
5ac13fa1746046451f1989b5b8734f40d6445322
/minimangalore/Nebula2/code/tutorials/mtutorial05/message/polarsystemvalues.cc
6852c26bf4867b63ec892304f693e3597e30c5a5
[]
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
420
cc
//------------------------------------------------------------------------------ // //------------------------------------------------------------------------------ #include "mtutorial05/message/polarsystemvalues.h" namespace Message { ImplementRtti(Message::PolarSystemValues, Message::Msg); ImplementFactory(Message::PolarSystemValues); ImplementMsgId(Message::PolarSystemValues); } // namespace Message
[ "[email protected]@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c" ]
[ [ [ 1, 11 ] ] ]
e133f70559ad8c0a4763fe6ec748c203a88d0062
14d51a21038a3d46f2fc019bbb161022a9f4854f
/stdafx.cpp
9d7d815f2208e661beef8b8426c2d81445f9ec24
[]
no_license
toraleap/w3plus
44246d8e7373c07ac430ebc66409ba8aae4be59f
a34a9e4fad93f763ea8423f684f04a4e5b466a98
refs/heads/master
2021-01-01T15:50:08.091393
2011-02-18T05:38:32
2011-02-18T05:38:32
32,132,245
0
0
null
null
null
null
GB18030
C++
false
false
2,497
cpp
// stdafx.cpp : 只包括标准包含文件的源文件 // w3plus.pch 将是预编译头 // stdafx.obj 将包含预编译类型信息 #include "stdafx.h" #include <comdef.h> CString GetAppPath(); BOOL IsLeapYear(int year); int GetMonthDays(int year,int month); CString ToStr(_variant_t var); CString GetAppPath() { CString strRet; TCHAR szBuff[_MAX_PATH]; VERIFY(::GetModuleFileName(AfxGetApp()->m_hInstance, szBuff, _MAX_PATH)); strRet=szBuff; int pos=strRet.ReverseFind('\\'); strRet=strRet.Left(pos); return strRet; } int GetMonthDays(int year,int month) { if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) return 31; else if(month == 4 || month == 6 || month == 9 || month == 11) return 30; else if(month == 2) return (IsLeapYear(year)?29:28); ASSERT(FALSE); return -1; } BOOL IsLeapYear(int year) { return ((((year%4==0)&&(year%100!=0))||(year%400 == 0))?TRUE:FALSE); } CString ToStr(_variant_t var) { CString strValue; _variant_t var_t; _bstr_t bst_t; COleCurrency var_currency; COleDateTime dt; switch(var.vt) { case VT_EMPTY:strValue=_T("");break; case VT_UI1:strValue.Format ("%d",var.bVal);break; case VT_UI2:strValue.Format ("%d",var.uiVal);break; case VT_UI4:strValue.Format ("%d",var.ulVal);break; case VT_UINT:strValue.Format("%d",var.uintVal);break; case VT_I2:strValue.Format ("%d",var.iVal );break; case VT_I4:strValue.Format ("%d",var.lVal);break; case VT_R4:strValue.Format ("%f",var.fltVal);break; case VT_R8:strValue.Format ("%f",var.dblVal);break; case VT_INT:strValue.Format ("%d",var.intVal);break; case VT_DECIMAL: { VARIANT newvar; VariantInit(&newvar); VariantChangeType(&newvar,&var,VARIANT_NOVALUEPROP,VT_BSTR); return ToStr(newvar); } break; case VT_CY: var_currency=var; strValue=var_currency.Format(0); break; case VT_BSTR: var_t=var; bst_t=var_t; strValue.Format ("%s",(const char*)bst_t); break; case VT_NULL: strValue=_T(""); break; case VT_DATE: dt = COleDateTime(var.date); strValue.Format("%d年%d月%d日%d时%d分%d秒",dt.GetYear(), dt.GetMonth(), dt.GetDay(), dt.GetHour(), dt.GetMinute(), dt.GetSecond()); break; case VT_BOOL: strValue.Format ("%d",var.boolVal ); break; default: ASSERT(FALSE); strValue=_T(""); break; } //ASSERT(!strValue.IsEmpty()); return strValue; }
[ "[email protected]@00efcefc-f4bc-333f-9454-5c8bce538679" ]
[ [ [ 1, 93 ] ] ]
5c051aa811102026f86c708ed62bcbc1c85be053
95d583eacc45df62b6b6459e2ec79404686cb2b1
/source/test/test_conjunto.cpp
306996d17a2cacd9aabd371e5a8619cbb72af0fa
[]
no_license
sebasrodriguez/teoconj
81a917c57724a718e6288798f7c58863a1dad523
aee99839a8ddb293b0ed1402dfe72b80dbfe0af0
refs/heads/master
2021-01-01T15:36:42.773692
2010-03-13T01:04:12
2010-03-13T01:04:12
32,334,661
0
0
null
null
null
null
UTF-8
C++
false
false
1,379
cpp
#include <stdlib.h> #include <stdio.h> #include "../lib/string_extended.h" #include "../Conjunto.h" #include "../lib/utils.h" #include "../common.h" int main(){ printf("=> TESTEANDO Conjunto.h (ABB de int)\n"); Conjunto c1; ConjuntoCreate(c1); ConjuntoAddValue(c1, 3); ConjuntoAddValue(c1, 17); ConjuntoAddValue(c1, 2); ConjuntoAddValue(c1, 9); ConjuntoAddValue(c1, 4); ConjuntoShow(c1);nl(); Conjunto c2; ConjuntoCreate(c2); ConjuntoAddValue(c2, 4); ConjuntoAddValue(c2, 5); ConjuntoAddValue(c2, 4); ConjuntoAddValue(c2, 2); ConjuntoAddValue(c2, 11); ConjuntoAddValue(c2, 4); ConjuntoShow(c2);nl(); Conjunto c3; ConjuntoCreate(c3); ConjuntoUnion(c1, c2, c3); printf("union = "); ConjuntoShow(c3); nl(); Conjunto c4; ConjuntoCreate(c4); ConjuntoIntersection(c2, c1, c4); printf("intersection = "); ConjuntoShow(c4); nl(); Conjunto c5; ConjuntoCreate(c5); ConjuntoDifference(c3, c4, c5); printf("difference = "); ConjuntoShow(c5); nl(); printf("included = "); printBool(ConjuntoIncluded(c4, c2));nl(); printf("equals = "); printBool(ConjuntoEquals(c4, c2));nl(); printf("member = "); printBool(ConjuntoMember(c3, 11));nl(); ConjuntoSave("pepe.txt", c3); getchar(); return 0; }
[ "srpabliyo@861ad466-0edf-11df-a223-d798cd56f61e", "sebasrodriguez@861ad466-0edf-11df-a223-d798cd56f61e" ]
[ [ [ 1, 5 ], [ 8, 10 ], [ 48, 50 ] ], [ [ 6, 7 ], [ 11, 47 ] ] ]
f886bfc8726e674df903616ec4c94e209c7527a6
e68cf672cdb98181db47dab9fb8c45e69b91e256
/src/StaticDataBuffer.cpp
6d4d3242a5d1658d8622016d1a9df8340427cad5
[]
no_license
jiawen/QD3D11
09fc794f580db59bfc2faffbe3373a442180e0a5
c1411967bd2da8d012eddf640eeb5f7b86e66374
refs/heads/master
2021-01-21T13:52:48.111246
2011-12-19T19:07:17
2011-12-19T19:07:17
2,549,080
5
0
null
null
null
null
UTF-8
C++
false
false
4,444
cpp
#include "StaticDataBuffer.h" #include <common/BasicTypes.h> ////////////////////////////////////////////////////////////////////////// // Public ////////////////////////////////////////////////////////////////////////// // static StaticDataBuffer* StaticDataBuffer::createFloat( ID3D11Device* pDevice, int nElements ) { StaticDataBuffer* output = NULL; int elementSizeBytes = sizeof( float ); D3D11_BUFFER_DESC bd = createStaticBufferDescription( nElements, elementSizeBytes ); ID3D11Buffer* pBuffer; HRESULT hr = pDevice->CreateBuffer( &bd, NULL, &pBuffer ); if( SUCCEEDED( hr ) ) { output = new StaticDataBuffer( pDevice, nElements, elementSizeBytes, DXGI_FORMAT_R32_FLOAT, pBuffer ); } return output; } // static StaticDataBuffer* StaticDataBuffer::createFloat2( ID3D11Device* pDevice, int nElements ) { StaticDataBuffer* output = NULL; int elementSizeBytes = 2 * sizeof( float ); D3D11_BUFFER_DESC bd = createStaticBufferDescription( nElements, elementSizeBytes ); ID3D11Buffer* pBuffer; HRESULT hr = pDevice->CreateBuffer( &bd, NULL, &pBuffer ); if( SUCCEEDED( hr ) ) { output = new StaticDataBuffer( pDevice, nElements, elementSizeBytes, DXGI_FORMAT_R32G32_FLOAT, pBuffer ); } return output; } // static StaticDataBuffer* StaticDataBuffer::createFloat4( ID3D11Device* pDevice, int nElements ) { StaticDataBuffer* output = NULL; int elementSizeBytes = 4 * sizeof( float ); D3D11_BUFFER_DESC bd = createStaticBufferDescription( nElements, elementSizeBytes ); ID3D11Buffer* pBuffer; HRESULT hr = pDevice->CreateBuffer( &bd, NULL, &pBuffer ); if( SUCCEEDED( hr ) ) { output = new StaticDataBuffer( pDevice, nElements, elementSizeBytes, DXGI_FORMAT_R32G32B32A32_FLOAT, pBuffer ); } return output; } // static StaticDataBuffer* StaticDataBuffer::createUInt2( ID3D11Device* pDevice, int nElements ) { StaticDataBuffer* output = NULL; int elementSizeBytes = 2 * sizeof( uint ); D3D11_BUFFER_DESC bd = createStaticBufferDescription( nElements, elementSizeBytes ); ID3D11Buffer* pBuffer; HRESULT hr = pDevice->CreateBuffer( &bd, NULL, &pBuffer ); if( SUCCEEDED( hr ) ) { output = new StaticDataBuffer( pDevice, nElements, elementSizeBytes, DXGI_FORMAT_R32G32_UINT, pBuffer ); } return output; } // virtual StaticDataBuffer::~StaticDataBuffer() { m_pBuffer->Release(); } int StaticDataBuffer::numElements() const { return m_nElements; } int StaticDataBuffer::elementSizeBytes() const { return m_elementSizeBytes; } int StaticDataBuffer::sizeInBytes() const { return numElements() * elementSizeBytes(); } DXGI_FORMAT StaticDataBuffer::format() const { return m_format; } void StaticDataBuffer::update( ID3D11DeviceContext* pContext, const void* srcData ) { pContext->UpdateSubresource( m_pBuffer, 0, NULL, srcData, sizeInBytes(), sizeInBytes() ); } ID3D11Buffer* StaticDataBuffer::buffer() const { return m_pBuffer; } ID3D11ShaderResourceView* StaticDataBuffer::shaderResourceView() const { return m_pSRV; } ////////////////////////////////////////////////////////////////////////// // Private ////////////////////////////////////////////////////////////////////////// StaticDataBuffer::StaticDataBuffer( ID3D11Device* pDevice, int nElements, int elementSizeBytes, DXGI_FORMAT format, ID3D11Buffer* pBuffer ) : m_nElements( nElements ), m_elementSizeBytes( elementSizeBytes ), m_format( format ), m_pBuffer( pBuffer ) { D3D11_SHADER_RESOURCE_VIEW_DESC desc; ZeroMemory( &desc, sizeof( desc ) ); desc.Format = format; desc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER; D3D11_BUFFER_SRV bsrv; bsrv.ElementOffset = 0; bsrv.ElementWidth = numElements(); desc.Buffer = bsrv; HRESULT hr = pDevice->CreateShaderResourceView( m_pBuffer, &desc, &m_pSRV ); } // static D3D11_BUFFER_DESC StaticDataBuffer::createStaticBufferDescription( int nElements, int elementSizeBytes ) { int bufferSize = nElements * elementSizeBytes; D3D11_BUFFER_DESC bd; bd.BindFlags = D3D11_BIND_SHADER_RESOURCE; bd.ByteWidth = bufferSize; bd.CPUAccessFlags = 0; bd.MiscFlags = 0; bd.StructureByteStride = elementSizeBytes; bd.Usage = D3D11_USAGE_DEFAULT; return bd; }
[ [ [ 1, 180 ] ] ]
e0b3756c2ee1c8121568870cc3b1aa36dcbb5725
c429fffcfe1128eeaa44f880bdcb1673633792d2
/dwmaxx/DWMEx.h
28a3f3f60fd0edbe9ed17c38fe7f3ffe61ee2f1c
[]
no_license
steeve/dwmaxx
7362ef753a71d707880b8cdefe65a5688a516f8d
0de4addc3dc8056dc478949b7efdbb5b67048d60
refs/heads/master
2021-01-10T20:13:15.161814
2008-02-18T02:48:15
2008-02-18T02:48:15
1,367,113
10
7
null
null
null
null
UTF-8
C++
false
false
2,254
h
// DWMEx.h : Declaration of the CDWMEx #pragma once #include "resource.h" // main symbols #include "dwmaxx.h" #include <vector> #if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA) #error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms." #endif enum { CMD_OFFSET, CMD_SCALE, }; typedef struct { LONG hWnd; FLOAT X; FLOAT Y; FLOAT SX; FLOAT SY; FLOAT RZ; } t_Command; // CDWMEx class ATL_NO_VTABLE CDWMEx : public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass<CDWMEx, &CLSID_DWMEx>, public IDispatchImpl<IDWMEx, &IID_IDWMEx, &LIBID_dwmaxxLib, /*wMajor =*/ 1, /*wMinor =*/ 0> { public: CDWMEx() { } DECLARE_REGISTRY_RESOURCEID(IDR_DWMEX) BEGIN_COM_MAP(CDWMEx) COM_INTERFACE_ENTRY(IDWMEx) COM_INTERFACE_ENTRY(IDispatch) END_COM_MAP() DECLARE_PROTECT_FINAL_CONSTRUCT() HRESULT FinalConstruct() { return S_OK; } void FinalRelease() { } std::vector<t_Command> _commands; public: public: STDMETHOD(OpenConsole)(void); public: STDMETHOD(CloseConsole)(void); public: STDMETHOD(SetWindowScale)(LONG hWnd, FLOAT ScaleX, FLOAT ScaleY); public: STDMETHOD(SetWindowOffset)(LONG hWnd, FLOAT X, FLOAT Y); public: STDMETHOD(ExecuteBatch)(LONG batchId); public: STDMETHOD(BatchSetWindowMatrix)(LONG hWnd, FLOAT X, FLOAT Y, FLOAT SX, FLOAT SY, FLOAT RZ); public: STDMETHOD(GetRenderOptions)(LONG hWnd, LONG* Options); public: STDMETHOD(SetRenderOptions)(LONG hWnd, LONG Options); public: STDMETHOD(SetWindowMatrix)(LONG hWnd, FLOAT X, FLOAT Y, FLOAT SX, FLOAT SY, FLOAT RZ); public: STDMETHOD(LockRendering)(void); public: STDMETHOD(UnlockRendering)(void); public: STDMETHOD(Test)(LONG hWnd); }; OBJECT_ENTRY_AUTO(__uuidof(DWMEx), CDWMEx)
[ "siwuzzz@d84ac079-a144-0410-96e0-5f9b019a5953" ]
[ [ [ 1, 93 ] ] ]
9835a2e2a2cd8575b996cec9c8f3a0c32a80bb22
16d8b25d0d1c0f957c92f8b0d967f71abff1896d
/OblivionOnlineServer/PlayerManager.cpp
51aa622fa9090e52ef64553c6ac07d4ce918a517
[]
no_license
wlasser/oonline
51973b5ffec0b60407b63b010d0e4e1622cf69b6
fd37ee6985f1de082cbc9f8625d1d9307e8801a6
refs/heads/master
2021-05-28T23:39:16.792763
2010-05-12T22:35:20
2010-05-12T22:35:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,476
cpp
/* This file is part of OblivionOnline Server- An open source game server for the OblivionOnline mod Copyright (C) 2008-2010 Julian Bangert 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 (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 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 "PlayerManager.h" #include "NetworkSystem.h" #include "Packets.h" PlayerManager::PlayerManager(EntityManager *manager,NetworkSystem *Network):_lock(),_mgr(manager),m_MasterClient(0),_net(Network) { } PlayerManager::~PlayerManager(void) { } Player * PlayerManager::GetPlayer( SOCKET connection ) { boost::lock_guard<boost::mutex> guard(_lock); if(_playerIDs.empty()) { throw std::runtime_error("No more Player IDs."); } Player *retval = new Player(this,_playerIDs.top(),connection,boost::bind(&NetworkSystem::OnDisconnect,boost::ref(*_net),_1)); _playerIDs.pop(); insert(retval); raw::PlayerID::Send(*retval,retval,retval->RefID()); IOStream::Instance() << "Sent new player ID "<<retval->RefID()<< " - We now have "<<size()<< " Players"<<endl; if(!m_MasterClient) { ChunkPermissions permissions(MATCH_ALL); //permissions.other = EntityPermission(MASK_ALL,retval->RefID()); //TODO: Might be better! raw::ClientType::Send(*retval,retval->RefID(),1); m_MasterClient = retval->RefID(); retval->SetPermissions(permissions); } else { ChunkPermissions permissions(MASK_ALL,retval->RefID()); // Allowed to change self only permissions.AVMod= EntityPermission(MATCH_ALL); // Affect others! raw::ClientType::Send(*retval,retval->RefID(),0); retval->SetPermissions(permissions); } return retval; } void PlayerManager::RemovePlayer( Player *Player ) { boost::lock_guard<boost::mutex> guard(_lock); _playerIDs.push(Player->RefID()); erase(Player); delete Player; } void PlayerManager::AssignPlayerID( UINT32 ID ) { boost::lock_guard<boost::mutex> guard(_lock); _playerIDs.push(ID); }
[ "obliviononline@2644d07b-d655-0410-af38-4bee65694944" ]
[ [ [ 1, 72 ] ] ]
5a37eb70567cfd82149e24ed2e5000d29994cc95
802817310cdf7c69dbeab815b4abfc9fca393bcc
/src/CameraMotion.cpp
f9ba60a1e3c50fd4266156311f268b35c2592832
[]
no_license
spjoe/echtzeitlu
a77b4c6765c8d4d88e52fda715fb96485f28d0eb
6df1ad920e45c0624405b3620059a2fdf67d5fad
refs/heads/master
2021-01-18T14:22:07.337680
2011-01-25T13:53:39
2011-01-25T13:53:39
32,144,342
0
0
null
null
null
null
UTF-8
C++
false
false
3,590
cpp
#include "CameraMotion.h" using namespace echtzeitlu; CameraMotion::CameraMotion(Camera* c) { camera = c; } void CameraMotion::update(float dTime) { switch(flyState){ case movetoIaround: { glm::vec3 epsi(0.05,0.05,0.05); glm::detail::tvec3<bool> a = glm::gtx::epsilon::equalEpsilon(camera->p,movetoPoint,epsi); if(a.x && a.y && a.z) flyState = around; else moveto2(dTime); break; } case around: { flyaround(dTime); break; } case movetoState: { moveto(dTime); break; } default: break; } } void CameraMotion::flyaround(glm::vec3 startPoint, glm::vec3 center, glm::vec3 pivotPoint, float speed, bool ccw, float movespeed, glm::vec3 startview) { flyState = movetoIaround; movetoPoint = startPoint; this->pivotPoint = pivotPoint; this->center = center; this->speedrad = speed; this->speedunits = movespeed; this->ccw = ccw; this->pathLength = glm::length(movetoPoint - camera->p); this->startview = startview; } void CameraMotion::moveto(glm::vec3 Point, float speed) { flyState = movetoState; movetoPoint = Point; this->speedunits = speed; this->pathLength = glm::length(movetoPoint - camera->p); } void CameraMotion::moveto(float dTime) { glm::vec3 direction = movetoPoint - camera->p; direction = glm::normalize(direction); float l = pathLength - glm::length(movetoPoint - camera->p); float d = 0.01f; //min speed if (l < (pathLength/2)) d += l/(pathLength/2.0f); else d += (pathLength - l)/(pathLength/2.0f); direction = speedunits * dTime * direction * d; camera->translate(direction); } void CameraMotion::moveto2(float dTime) { glm::vec3 direction = movetoPoint - camera->p; direction = glm::normalize(direction); float l = pathLength - glm::length(movetoPoint - camera->p); float d = 0.01f; //min speed if (l < (pathLength/2)) d += l/(pathLength/2.0f); else d += (pathLength - l)/(pathLength/2.0f); direction = speedunits * dTime * direction * d; camera->translate(direction); //camera rotation richtung viewpoint glm::vec3 dist = pivotPoint - startview; dist = (l / pathLength) * dist; camera->lookat(camera->p,startview + dist,glm::vec3(0,0,1)); } void CameraMotion::flyaround(float dTime) { float r = glm::distance(camera->p,center); float alpha = speedrad * dTime; glm::vec3 p1 = camera->p; glm::vec3 c = center; glm::vec3 p2(5,0,5); //todo p2 = r * glm::normalize(p2); glm::vec3 cp1 = p1 - c; glm::vec3 cp2 = p2 - c; glm::vec3 nepsilon = glm::cross(cp1,cp2); glm::vec3 nh = cp1; glm::vec3 ag = glm::cross(nepsilon,nh); float tmp = r * cos(alpha); float tmp2 = r * sin(alpha); glm::vec3 Y = c + tmp * glm::normalize(cp1); glm::vec3 X; if(!ccw){ X = Y - tmp2 * glm::normalize(ag); glm::mat3 m(c,Y,X); if(glm::determinant(m) > 0) X = Y + tmp2 * glm::normalize(ag); }else{ X = Y + tmp2 * glm::normalize(ag); glm::mat3 m(c,Y,X); if(glm::determinant(m) < 0) X = Y - tmp2 * glm::normalize(ag); } //camera->p = X; //camera->translate(glm::vec3(0,0,0)); camera->lookat(X,pivotPoint,glm::vec3(0,0,1)); //camera->orbit(c,glm::normalize(ag),glm::degrees(alpha)); } void CameraMotion::save() { save_camera = *camera; } void CameraMotion::restore() { camera->p = save_camera.p; camera->f = save_camera.f; camera->s = save_camera.s; camera->extrinsic = save_camera.extrinsic; camera->intrinsic = save_camera.intrinsic; }
[ "cdellmour@2895edc6-717a-dc9c-75a2-8897665f464c", "t.moerwald@2895edc6-717a-dc9c-75a2-8897665f464c" ]
[ [ [ 1, 44 ], [ 46, 96 ], [ 98, 138 ] ], [ [ 45, 45 ], [ 97, 97 ] ] ]
4c6a693d40e0a07d296c8238e069f34f9168f4c0
af3b3fd56239cddee37913ee4184e2c62b428659
/src/Settings.h
8830a96f16de731e839cb332e7a5d3785fed1e72
[]
no_license
d3v3r4/clearcase-sponge
7c80405b58c2720777a008e67693869ea835b60e
699a1ef4874b9b9da2c84072774172d22c1d7369
refs/heads/master
2021-01-01T05:32:15.402646
2009-06-15T06:39:38
2009-06-15T06:39:38
41,874,171
0
0
null
null
null
null
UTF-8
C++
false
false
1,272
h
// Settings.h #ifndef SETTINGS_H #define SETTINGS_H #include <text/String.h> #include <util/Array.h> #include <vector> using namespace std; /* * Holds the settings passed into the program by the user. */ class Settings { public: enum timePeriod { DAILY, WEEKLY, MONTHLY, }; Settings(); Settings(const Settings& other); ~Settings(); bool populate(Array<String>& parameters, String& error); bool getMergesExcluded(); bool getMainExcluded(); timePeriod getPeriod(); String getOutputFile(); String getAfterDate(); String getBeforeDate(); vector<String> getUsers(); vector<String> getBrtypes(); vector<String> getExtensions(); vector<String> getPaths(); Settings& operator=(const Settings& other); private: timePeriod parsePeriod(String value, String& error); void parseList(String list, vector<String>& toPopulate); void parseExtensionList(String list, vector<String>& toPopulate, String& error); private: bool m_excludeMerges; bool m_excludeMain; timePeriod m_period; String m_outputFile; String m_afterDate; String m_beforeDate; vector<String> m_users; vector<String> m_brtypes; vector<String> m_extensions; vector<String> m_paths; }; #endif // SETTINGS_H
[ "scott.conger@2a29f4a4-5970-11de-9a1b-6103e4980ab8" ]
[ [ [ 1, 65 ] ] ]
8d9b168b5e9e4d499f0a1db88a02911632f6b967
13f30850677b4b805aeddbad39cd9369d7234929
/ astrocytes --username [email protected]/CT_tutorial/CT_draw.cpp
0bf30b1659075863df53d860258e039575440949
[]
no_license
hksonngan/astrocytes
2548c73bbe45ea4db133e465fa8a90d29dc60f64
e14544d21a077cdbc05356b05148cc408c255e04
refs/heads/master
2021-01-10T10:04:14.265392
2011-11-09T07:42:06
2011-11-09T07:42:06
46,898,541
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
3,911
cpp
#include "AllInc.h" #include <GL/glfw.h> #include "AllDef.h" #include "Mouse.h" #include "Camera.h" #include "Draw.h" #include "output.h" #include <Math.h> #include <ivec3.h> #include "Draw2D.h" #include "Geometry.h" #include "Edist.h" #include "Shader.h" #include "globals.h" vec4 light(1,0,0,0); bool smoothing=1,draw_boxes=0; bool shaders_is=1,anag_left=0; extern ivec2 old_mouse_pos; float sect_radius=0.6; bool transparency[10]; void DrawScene() { static ShaderProgram sp("anag.vs","anag.fs"); cam.SetupPosition(); //домножение текущей матрицы преобразований в соответствии с положением и ориентацией камеры glLightfv(GL_LIGHT0,GL_POSITION, &light.x); glDisable(GL_LIGHTING); glColor4d(0,0,0,1); glBegin(GL_LINES); glLineWidth(3); for(int i=0;i<section.size();i++) { //glColor3d(0,0,0); glVertex3fv(&section[i].v[0].x); //glColor3d(1,1,1); glVertex3fv(&section[i].v[1].x); } for(int i=0;i<section2d.size();i++) { //glColor3d(0,0,0); glVertex2fv(&section2d[i].v[0].x); //glColor3d(1,1,1); glVertex2fv(&section2d[i].v[1].x); } /* float grid_size=2; glColor4d(0.1,0.5,0.1,0.7); glVertex2f(-grid_size,0); glVertex2f(grid_size,0); glVertex2f(0,-grid_size); glVertex2f(0,grid_size); glColor4d(0.1,0.5,0.1,0.3); float grid_step=0.1; for(float i=-grid_size;i<=grid_size;i+=grid_step) { glVertex2f(-grid_size,i); glVertex2f(grid_size,i); glVertex2f(i,-grid_size); glVertex2f(i,grid_size); } */ glEnd(); //glColor4d(0.1,0.5,0.1,0.5); for(int i=1;i<200;i++) DrawCircle(0.1*i,vec2(0),45); psd[cur_psd].Draw(); /* glPointSize(12); glColor4d(0.1,0.5,0.1,0.5); glBegin(GL_POINTS); for(int i=0;i<section2d.size();i++) { glVertex2fv(&section2d[i].v[0].x); glVertex2fv(&section2d[i].v[1].x); } glEnd(); glPointSize(1); //DrawRectangle(vec2(-PI,-PI*0.5),vec2(PI,PI*0.5)); */ glLineWidth(1); glEnable(GL_LIGHTING); if(shaders_is) sp.Use(); SetAnag(&sp,anag,anag_left); sp.SetVar("LightDir",vec3(light)); sp.SetVar("pos",cam.GetPosition()); sp.SetVar("params",vec4(0)); //glEnable(GL_DEPTH_TEST); for(int tr=0;tr<2;tr++) for(int i=0;i<neuron.size();i++) // for(int i=neuron.size()-1;i>=0;i--) if((bool)tr==transparency[i]) for(int j=0;j<neuron[i].size();j++) if(neuron[i][j].color.w) { // if(i!=1 || j==cur_psd) if(!transparency[i]) { sp.SetVar("params",vec4(0,0,0,0)); glColor4fv(&neuron[i][j].color.x); if(smoothing) neuron[i][j].Draw2(); else neuron[i][j].Draw(); } else { sp.SetVar("params",vec4(1,1,0,0)); glCullFace(GL_BACK); glColor4fv(&neuron[i][j].color.x); if(smoothing) neuron[i][j].Draw2(); else neuron[i][j].Draw(); sp.SetVar("params",vec4(1,0,0,0)); glCullFace(GL_FRONT); if(smoothing) neuron[i][j].Draw2(); else neuron[i][j].Draw(); } if(draw_boxes) { if(shaders_is) sp.UnUse(); neuron[i][j].DrawBoxes(); if(shaders_is) sp.Use(); } } if(shaders_is) sp.UnUse(); glColor4d(0,0,0,0.2f); DrawSphere(cam.GetCenter(),sect_radius); glCullFace(GL_BACK); DrawSphere(cam.GetCenter(),sect_radius); glCullFace(GL_FRONT); for(int i=0;i<flat_section.size();i++) flat_section[i].Draw(); /* if(mouse.btn&1) { glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); glViewport(0,0,width,height); Begin2D(width,height); glColor4f(1,1,1,0.6f); DrawRectangle(vec2(old_mouse_pos.x,old_mouse_pos.y),vec2(mouse.oldx,mouse.oldy)); End2D(); glEnable(GL_DEPTH_TEST); }*/ } // рисуем сцену в соответствии со стерео-режимом void FullDraw() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); DrawScene(); }
[ [ [ 1, 184 ] ] ]
591403b5f7cc863e9e6da0f74116ca4f4a83f532
89d2197ed4531892f005d7ee3804774202b1cb8d
/GWEN/src/Controls/SplitterBar.cpp
46a0ced4dc2fbf67703c8e36489ea9efc67c6b16
[ "MIT", "Zlib" ]
permissive
hpidcock/gbsfml
ef8172b6c62b1c17d71d59aec9a7ff2da0131d23
e3aa990dff8c6b95aef92bab3e94affb978409f2
refs/heads/master
2020-05-30T15:01:19.182234
2010-09-29T06:53:53
2010-09-29T06:53:53
35,650,825
0
0
null
null
null
null
UTF-8
C++
false
false
437
cpp
#include "stdafx.h" #include "Gwen/Gwen.h" #include "Gwen/Controls/SplitterBar.h" using namespace Gwen; using namespace Controls; GWEN_CONTROL_CONSTRUCTOR( SplitterBar ) { SetTarget( this ); RestrictToParent( true ); } void SplitterBar::Render( Skin::Base* skin ) { if ( ShouldDrawBackground() ) skin->DrawButton( this, true, false ); } void SplitterBar::Layout( Skin::Base* skin ) { MoveTo( X(), Y() ); }
[ "haza55@5bf3a77f-ad06-ad18-b9fb-7d0f6dabd793" ]
[ [ [ 1, 23 ] ] ]
6c5a0ced1a2c699d9fea09c9587c7677c01f05ab
2982a765bb21c5396587c86ecef8ca5eb100811f
/util/wm5/LibMathematics/Algebra/Wm5GVector.inl
bc754d9f03ef4c07041e15839d9f213d638287ea
[]
no_license
evanw/cs224final
1a68c6be4cf66a82c991c145bcf140d96af847aa
af2af32732535f2f58bf49ecb4615c80f141ea5b
refs/heads/master
2023-05-30T19:48:26.968407
2011-05-10T16:21:37
2011-05-10T16:21:37
1,653,696
27
9
null
null
null
null
UTF-8
C++
false
false
9,871
inl
// Geometric Tools, LLC // Copyright (c) 1998-2010 // Distributed under the Boost Software License, Version 1.0. // http://www.boost.org/LICENSE_1_0.txt // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt // // File Version: 5.0.2 (2011/03/27) //---------------------------------------------------------------------------- template <typename Real> GVector<Real>::GVector (int size) { if (size > 0) { mSize = size; mTuple = new1<Real>(mSize); size_t numBytes = mSize*sizeof(Real); memset(mTuple, 0, numBytes); } else { mSize = 0; mTuple = 0; } } //---------------------------------------------------------------------------- template <typename Real> GVector<Real>::GVector (int size, const Real* tuple) { if (size > 0) { mSize = size; mTuple = new1<Real>(mSize); size_t numBytes = mSize*sizeof(Real); memcpy(mTuple, tuple, numBytes); } else { mSize = 0; mTuple = 0; } } //---------------------------------------------------------------------------- template <typename Real> GVector<Real>::GVector (const GVector& vec) { mSize = vec.mSize; if (mSize > 0) { mTuple = new1<Real>(mSize); size_t numBytes = mSize*sizeof(Real); memcpy(mTuple, vec.mTuple, numBytes); } else { mTuple = 0; } } //---------------------------------------------------------------------------- template <typename Real> GVector<Real>::~GVector () { delete1(mTuple); } //---------------------------------------------------------------------------- template <typename Real> void GVector<Real>::SetSize (int size) { delete1(mTuple); if (size > 0) { mSize = size; mTuple = new1<Real>(mSize); size_t numBytes = mSize*sizeof(Real); memset(mTuple, 0, numBytes); } else { mSize = 0; mTuple = 0; } } //---------------------------------------------------------------------------- template <typename Real> inline int GVector<Real>::GetSize () const { return mSize; } //---------------------------------------------------------------------------- template <typename Real> inline GVector<Real>::operator const Real* () const { return mTuple; } //---------------------------------------------------------------------------- template <typename Real> inline GVector<Real>::operator Real* () { return mTuple; } //---------------------------------------------------------------------------- template <typename Real> inline const Real& GVector<Real>::operator[] (int i) const { assertion(0 <= i && i < mSize, "Invalid index in operator[]\n"); return mTuple[i]; } //---------------------------------------------------------------------------- template <typename Real> inline Real& GVector<Real>::operator[] (int i) { assertion(0 <= i && i < mSize, "Invalid index in operator[]\n"); return mTuple[i]; } //---------------------------------------------------------------------------- template <typename Real> GVector<Real>& GVector<Real>::operator= (const GVector& vec) { if (vec.mSize > 0) { if (mSize != vec.mSize) { delete1(mTuple); mSize = vec.mSize; mTuple = new1<Real>(mSize); } size_t numBytes = mSize*sizeof(Real); memcpy(mTuple, vec.mTuple, numBytes); } else { delete1(mTuple); mSize = 0; mTuple = 0; } return *this; } //---------------------------------------------------------------------------- template <typename Real> bool GVector<Real>::operator== (const GVector& vec) const { return memcmp(mTuple, vec.mTuple, mSize*sizeof(Real)) == 0; } //---------------------------------------------------------------------------- template <typename Real> bool GVector<Real>::operator!= (const GVector& vec) const { return memcmp(mTuple, vec.mTuple, mSize*sizeof(Real)) != 0; } //---------------------------------------------------------------------------- template <typename Real> bool GVector<Real>::operator< (const GVector& vec) const { return memcmp(mTuple, vec.mTuple, mSize*sizeof(Real)) < 0; } //---------------------------------------------------------------------------- template <typename Real> bool GVector<Real>::operator<= (const GVector& vec) const { return memcmp(mTuple, vec.mTuple, mSize*sizeof(Real)) <= 0; } //---------------------------------------------------------------------------- template <typename Real> bool GVector<Real>::operator> (const GVector& vec) const { return memcmp(mTuple, vec.mTuple, mSize*sizeof(Real)) > 0; } //---------------------------------------------------------------------------- template <typename Real> bool GVector<Real>::operator>= (const GVector& vec) const { return memcmp(mTuple, vec.mTuple, mSize*sizeof(Real)) >= 0; } //---------------------------------------------------------------------------- template <typename Real> GVector<Real> GVector<Real>::operator+ (const GVector& vec) const { GVector<Real> result(mSize); for (int i = 0; i < mSize; ++i) { result.mTuple[i] = mTuple[i] + vec.mTuple[i]; } return result; } //---------------------------------------------------------------------------- template <typename Real> GVector<Real> GVector<Real>::operator- (const GVector& vec) const { GVector<Real> result(mSize); for (int i = 0; i < mSize; ++i) { result.mTuple[i] = mTuple[i] - vec.mTuple[i]; } return result; } //---------------------------------------------------------------------------- template <typename Real> GVector<Real> GVector<Real>::operator* (Real scalar) const { GVector<Real> result(mSize); for (int i = 0; i < mSize; ++i) { result.mTuple[i] = scalar*mTuple[i]; } return result; } //---------------------------------------------------------------------------- template <typename Real> GVector<Real> GVector<Real>::operator/ (Real scalar) const { GVector<Real> result(mSize); int i; if (scalar != (Real)0) { Real invScalar = ((Real)1)/scalar; for (i = 0; i < mSize; ++i) { result.mTuple[i] = invScalar*mTuple[i]; } } else { for (i = 0; i < mSize; ++i) { result.mTuple[i] = Math<Real>::MAX_REAL; } } return result; } //---------------------------------------------------------------------------- template <typename Real> GVector<Real> GVector<Real>::operator- () const { GVector<Real> result(mSize); for (int i = 0; i < mSize; ++i) { result.mTuple[i] = -mTuple[i]; } return result; } //---------------------------------------------------------------------------- template <typename Real> GVector<Real>& GVector<Real>::operator+= (const GVector& vec) { for (int i = 0; i < mSize; ++i) { mTuple[i] += vec.mTuple[i]; } return *this; } //---------------------------------------------------------------------------- template <typename Real> GVector<Real>& GVector<Real>::operator-= (const GVector& vec) { for (int i = 0; i < mSize; ++i) { mTuple[i] -= vec.mTuple[i]; } return *this; } //---------------------------------------------------------------------------- template <typename Real> GVector<Real>& GVector<Real>::operator*= (Real scalar) { for (int i = 0; i < mSize; ++i) { mTuple[i] *= scalar; } return *this; } //---------------------------------------------------------------------------- template <typename Real> GVector<Real>& GVector<Real>::operator/= (Real scalar) { int i; if (scalar != (Real)0) { Real invScalar = ((Real)1)/scalar; for (i = 0; i < mSize; ++i) { mTuple[i] *= invScalar; } } else { for (i = 0; i < mSize; ++i) { mTuple[i] = Math<Real>::MAX_REAL; } } return *this; } //---------------------------------------------------------------------------- template <typename Real> Real GVector<Real>::Length () const { Real sqrLength = (Real)0; for (int i = 0; i < mSize; ++i) { sqrLength += mTuple[i]*mTuple[i]; } return Math<Real>::Sqrt(sqrLength); } //---------------------------------------------------------------------------- template <typename Real> Real GVector<Real>::SquaredLength () const { Real sqrLength = (Real)0; for (int i = 0; i < mSize; ++i) { sqrLength += mTuple[i]*mTuple[i]; } return sqrLength; } //---------------------------------------------------------------------------- template <typename Real> Real GVector<Real>::Dot (const GVector& vec) const { Real dotProduct = (Real)0; for (int i = 0; i < mSize; ++i) { dotProduct += mTuple[i]*vec.mTuple[i]; } return dotProduct; } //---------------------------------------------------------------------------- template <typename Real> Real GVector<Real>::Normalize (Real epsilon) { Real length = Length(); int i; if (length > epsilon) { Real invLength = ((Real)1)/length; for (i = 0; i < mSize; ++i) { mTuple[i] *= invLength; } } else { length = (Real)0; for (i = 0; i < mSize; ++i) { mTuple[i] = (Real)0; } } return length; } //----------------------------------------------------------------------------
[ [ [ 1, 356 ] ] ]
42b7f0a5eb071d03481d62db44ecff07a65d46af
23e9e5636c692364688bc9e4df59cb68e2447a58
/Dream/src/Sample/Sample.cpp
078ee52bb4920f8914934345e20a8995afd44aff
[]
no_license
yestein/dream-of-idle
e492af2a4758776958b43e4bf0e4db859a224c40
4e362ab98f232d68535ea26f2fab7b3cbf7bc867
refs/heads/master
2016-09-09T19:49:18.215943
2010-04-23T07:24:19
2010-04-23T07:24:19
34,108,886
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
6,588
cpp
/************************************************************************ filename: Sample.cpp created: 2010/3/5 author: Yu Lei([email protected]) <change list> 1. create file (Yu Lei) purpose: Create First Win32 Window ************************************************************************/ #include "Sample.h" #include "Sprite.h" #include "CEGUI.h" int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrevInst,LPSTR lpCmdLine,int nCmdShow) { YGEGame Game; YGEAppParam AppParam; AppParam.hInstance = hInst; AppParam.pApplication = &Game; AppParam.hPrevInst = hPrevInst; AppParam.bWindowed = true; AppParam.bMulti = false; AppParam.bShowMouse = true; AppParam.uScreenHeight = 600; AppParam.uScreenWidth = 800; _tcsncpy( AppParam.szAppName, (TCHAR*)"Sample", DEFAULT_TITLE_NAME_LEN ); _tcsncpy( AppParam.szWndTitleName, (TCHAR*)"Hello World!", DEFAULT_TITLE_NAME_LEN ); YGEAppFrame App; App.CreateApplication( AppParam ); App.RunApplication( ); return 0; } YGEGame::YGEGame( ) { // m_Sprite = new Sprite( ); // m_Map = new Map( ); // m_uLastTime = ::GetTickCount( ); } int YGEGame::HandleInput( UINT Message,WPARAM wParam,LPARAM lParam ) { switch( Message ) { case WM_CHAR: case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_MBUTTONDOWN: case WM_MBUTTONUP: case WM_MOUSEMOVE: case WM_NCMOUSELEAVE: case WM_MOUSELEAVE: case 0x020A: // WM_MOUSEWHEEL: break; } return 0; } bool YGEGame::Init( ) { using namespace CEGUI; // // we will use of the WindowManager. // WindowManager& winMgr = WindowManager::getSingleton(); // // // load scheme and set up defaults // SchemeManager::getSingleton().loadScheme("TaharezLook.scheme"); // System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow"); // if(!FontManager::getSingleton().isFontPresent("Commonwealth-10")) // FontManager::getSingleton().createFont("Commonwealth-10.font"); // // // load an image to use as a background // ImagesetManager::getSingleton().createImagesetFromImageFile("BackgroundImage", "GPN-2000-001437.tga"); // // // here we will use a StaticImage as the root, then we can use it to place a background image // Window* background = winMgr.createWindow("TaharezLook/StaticImage", "background_wnd"); // // set position and size // background->setPosition(UVector2(cegui_reldim(0), cegui_reldim( 0))); // background->setSize(UVector2(cegui_reldim(1), cegui_reldim( 1))); // // disable frame and standard background // background->setProperty("FrameEnabled", "false"); // background->setProperty("BackgroundEnabled", "false"); // // set the background image // background->setProperty("Image", "set:BackgroundImage image:full_image"); // // install this as the root GUI sheet // System::getSingleton().setGUISheet(background); // // // load the windows for Demo7 from the layout file. // Window* sheet = winMgr.loadWindowLayout("Demo7Windows.layout"); // // attach this to the 'real' root // background->addChildWindow(sheet); // set-up the contents of the list boxes. // m_pRenderer = new YGERender( m_pThisWnd, false, m_uWidth, m_uHeight, 16 ); // m_pRenderer->Initialise( ); // m_pRenderer->m_pDDrawRender->CreateBMPSurface(m_Map->lpSMap,0,0,"background.bmp", DDSCAPS_SYSTEMMEMORY); // m_pRenderer->m_pDDrawRender->CreateBMPSurface(m_Sprite->lpSSprite,0,0,"1.bmp", DDSCAPS_SYSTEMMEMORY); // m_pRenderer->m_pDDrawRender->DDSetColorKey( m_Sprite->lpSSprite, CLR_INVALID ); // // m_pRenderer->m_pDDrawRender->BlitBack( // 0,0,m_Map->lpSMap, // &m_pRenderer->m_pDDrawRender->GetRect(0,0,640,480), // DDBLTFAST_NOCOLORKEY ); // m_pRenderer->m_pDDrawRender->BlitBack( // m_Sprite->GetX(),m_Sprite->GetY(),m_Sprite->lpSSprite, // &m_pRenderer->m_pDDrawRender->GetRect(m_Sprite->GetCurFram()*m_Sprite->GetWidth(),m_Sprite->GetDir()*m_Sprite->GetHeight(),m_Sprite->GetCurFram()*m_Sprite->GetWidth()+m_Sprite->GetWidth(),m_Sprite->GetDir()*m_Sprite->GetHeight()+m_Sprite->GetHeight()), // DDBLTFAST_SRCCOLORKEY ); // //ÏÔʾ // RECT rectWin; // GetClientRect( m_pThisWnd, &rectWin ); // ClientToScreen( m_pThisWnd, (LPPOINT)&rectWin ); // ClientToScreen( m_pThisWnd, (LPPOINT)&rectWin + 1 ); // m_pRenderer->m_pDDrawRender->Flip( &rectWin); m_uLastGameTimeCount = m_uLastRenderTimeCount = ::GetTickCount( ); return true; } bool YGEGame::Loop( ) { m_uCurTimeCount = ::GetTickCount( ); if( m_uCurTimeCount - m_uLastGameTimeCount > 1000 / YGEDefine::GAME_FPS ) { m_uLastGameTimeCount += 1000 / GAME_FPS; // To do } if( m_uCurTimeCount - m_uLastRenderTimeCount > 1000 / YGEDefine::RENDER_FPS ) { // To do float timeElapse = float( m_uCurTimeCount - m_uLastRenderTimeCount ); m_uLastRenderTimeCount += 1000 / RENDER_FPS; DoRender( timeElapse ); } // if( ::GetTickCount() - m_uLastTime >= 1000 ) // { // m_uLastTime += 1000; // m_pRenderer->m_pDDrawRender->BlitBack( // 0,0,m_Map->lpSMap, // &m_pRenderer->m_pDDrawRender->GetRect(0,0,640,480), // DDBLTFAST_NOCOLORKEY ); // m_pRenderer->m_pDDrawRender->BlitBack( // m_Sprite->GetX(),m_Sprite->GetY(),m_Sprite->lpSSprite, // &m_pRenderer->m_pDDrawRender->GetRect(m_Sprite->GetCurFram()*m_Sprite->GetWidth(),m_Sprite->GetDir()*m_Sprite->GetHeight(),m_Sprite->GetCurFram()*m_Sprite->GetWidth()+m_Sprite->GetWidth(),m_Sprite->GetDir()*m_Sprite->GetHeight()+m_Sprite->GetHeight()), // DDBLTFAST_SRCCOLORKEY ); // //ÏÔʾ // RECT rectWin; // GetClientRect( m_pThisWnd, &rectWin ); // ClientToScreen( m_pThisWnd, (LPPOINT)&rectWin ); // ClientToScreen( m_pThisWnd, (LPPOINT)&rectWin + 1 ); // m_pRenderer->m_pDDrawRender->Flip( &rectWin); // } return true; } bool YGEGame::DoRender( float timeElapse ) { HRESULT coop; coop = m_pRenderer->m_pDirect3DDevice->TestCooperativeLevel(); CEGUI::System& guiSystem = CEGUI::System::getSingleton(); guiSystem.injectTimePulse(timeElapse); if (coop == D3DERR_DEVICELOST) { Sleep(500); return false; } else if (coop == D3DERR_DEVICENOTRESET) { } // draw display if (FAILED(m_pRenderer->m_pDirect3DDevice->BeginScene())) { return false; } m_pRenderer->m_pDirect3DDevice->Clear(0, 0, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); guiSystem.renderGUI(); m_pRenderer->m_pDirect3DDevice->EndScene(); m_pRenderer->m_pDirect3DDevice->Present(0, 0, 0, 0); return true; } bool YGEGame::Exit( ) { return true; }
[ "yestein86@6bb0ce84-d3d1-71f5-47c4-2d9a3e80541b" ]
[ [ [ 1, 193 ] ] ]
13117f85c42ae175cae54b6a86ff11a9ee7073fc
d5706b5871d9650b30043ab45cfd7f02878d18e6
/src/b2cinder/Conversions.cpp
304059d9478b7cf16f0c82187ddff02a8a47a3d5
[]
no_license
onedayitwillmake/CinderBox2dOSC
bb8db212ecb644cd51798cc672789e51ba13b071
e76d4b1d522f08df73f7bc0d9c76434326f05f4c
refs/heads/master
2020-06-04T06:33:04.897125
2011-06-10T14:32:05
2011-06-10T14:32:05
1,782,762
0
0
null
null
null
null
UTF-8
C++
false
false
171
cpp
/* * Utils.cpp * BasicBox2D * * Created by David Wicks on 6/7/10. * Copyright 2010 David Wicks. All rights reserved. * */ #include "Conversions.h"
[ [ [ 1, 11 ] ] ]
9a15d3410b55ee7abfc76d6f98f1c21ae6a59c1b
3a577d02f876776b22e2bf1c0db12a083f49086d
/vba2/vba2/paintwidget.h
f40e30545e87d86d54d96a988a81311566a80f9e
[]
no_license
xiaoluoyuan/VisualBoyAdvance-2
d19565617b26e1771f437842dba5f0131d774e73
cadd2193ba48e1846b45f87ff7c36246cd61b6ee
refs/heads/master
2021-01-10T01:19:23.884491
2010-05-12T09:59:37
2010-05-12T09:59:37
46,539,728
0
0
null
null
null
null
UTF-8
C++
false
false
2,080
h
/* VisualBoyAdvance 2 Copyright (C) 2009-2010 VBA development team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef PAINTWIDGET_H #define PAINTWIDGET_H #include <QtOpenGL/QGLWidget> #include "../gba2/common/cdriver_graphics.h" #include "../gba2/common/cdriver_input.h" class QResizeEvent; class QPaintEvent; class QImage; class QPoint; class CAppSettings; // PaintWidget is a Qt Widget that offers GBA graphic output capabilities. class PaintWidget : public QGLWidget, public CDriver_Graphics, public CDriver_Input { Q_OBJECT // ### CDriver_Graphics interface: public: virtual bool displayFrame( const void *const data ); // ### CDriver_Input interface: virtual u16 getKeyStates(); // ### Widget code: public: PaintWidget( CAppSettings &settings, QWidget *parent = 0 ); ~PaintWidget(); protected: void resizeEvent( QResizeEvent *event ); void paintEvent( QPaintEvent *event ); void keyPressEvent( QKeyEvent *event ); void keyReleaseEvent( QKeyEvent *event ); private: CAppSettings &m_settings; QImage *m_pixels; QRectF *m_placement; static const int srcImgWidth = 240; static const int srcImgHeight = 160; static const int srcImgPixelCount = srcImgWidth * srcImgHeight; u16 m_buttonStates; bool m_smooth; public slots: void enableVSync( bool enable ); void enableSmoothStretching( bool enable ); }; #endif // PAINTWIDGET_H
[ "spacy51@5a53c671-dd2d-0410-9261-3f5c817b7aa0" ]
[ [ [ 1, 75 ] ] ]
5a6233e9cee4393e20ed1f8e431448fba6e8aedc
ec805d3ac789760cd67d30e7726f210a08658390
/ActiveShapeModel/Create2DActiveShapeModel/2dasm.cxx
4504f54545dce58e88674081b0dffa84b3e0a594
[]
no_license
midas-journal/midas-journal-812
a91dcf4e726412b1f43522218e1ffd927871dd95
ac6509da43753933cc65a5b6a2f16a6dddb6616e
refs/heads/master
2021-01-22T05:20:33.732601
2011-08-22T13:51:14
2011-08-22T13:51:14
2,248,766
1
0
null
null
null
null
UTF-8
C++
false
false
5,251
cxx
/* Author: John R Durkin Date last modified: 6/13/2011 creates a mean image and set of principle components from a series of training images */ #include "itkImage.h" #include "itkImagePCAShapeModelEstimator.h" #include "itkBinaryThresholdImageFilter.h" #include "itkImageFileReader.h" #include "itkImageFileWriter.h" #include "itkSignedDanielssonDistanceMapImageFilter.h" #include "itkShiftScaleImageFilter.h" #include "itkNumericSeriesFileNames.h" #include <iostream> #if defined(_MSC_VER) #pragma warning ( disable : 4786 ) #endif #ifdef __BORLANDC__ #define ITK_LEAN_AND_MEAN #endif using namespace std; int main( ) { //declaring variables for parameters int NUMTRAININGIMAGES = 6; int NUMPC = 3; std::string IMAGENAME = "fixed"; /* //reading in parameters from console cout << "Enter number of training images " << endl; cin >> NUMTRAININGIMAGES; cout << "Enter number of principle components " << endl; cin >> NUMPC; cout << "Enter the training image prefix for example: for image000.jpg, image001.jpg, image002.jpg... enter \"image\"" << endl; cin >> IMAGENAME; */ //defining internal pixel type typedef float InternalPixelType; const unsigned int Dimension = 2; typedef itk::Image< InternalPixelType, Dimension > InternalImageType; //defining image type for threshold filter and image typedef float BinaryOutputPixelType; typedef itk::Image< BinaryOutputPixelType, Dimension > OutputImageType; typedef itk::BinaryThresholdImageFilter< InternalImageType, OutputImageType> ThresholdingFilterType; //defining types for danielsson distance map image filter typedef float MapOutputPixelType; typedef itk::Image< BinaryOutputPixelType, Dimension> MapInputImageType; typedef itk::Image< MapOutputPixelType, Dimension> MapOutputImageType; typedef itk::SignedDanielssonDistanceMapImageFilter< OutputImageType, MapOutputImageType> FilterType; //setting up reader and writer types typedef itk::ImageFileReader< InternalImageType > ReaderType; typedef itk::ImageFileWriter< InternalImageType > WriterType; //making a vector full of the names of the input files itk::NumericSeriesFileNames::Pointer fileNamesCreator = itk::NumericSeriesFileNames::New(); fileNamesCreator->SetStartIndex( 0 ); fileNamesCreator->SetEndIndex( NUMTRAININGIMAGES ); fileNamesCreator->SetSeriesFormat( IMAGENAME + "%d.tif" ); const std::vector<std::string> & trainingImageNames = fileNamesCreator->GetFileNames(); for( int p = 0; p < NUMTRAININGIMAGES; p++) { cout << trainingImageNames[p].c_str() << endl; } //creating the PCAShapeModelEstimator and initializing typedef itk::ImagePCAShapeModelEstimator<MapOutputImageType, InternalImageType> PCAEstimatorType; PCAEstimatorType::Pointer model = PCAEstimatorType::New(); model->DebugOn(); model->SetNumberOfTrainingImages(NUMTRAININGIMAGES); model->SetNumberOfPrincipalComponentsRequired(NUMPC); //setting up and running the filters on all of the training images for ( unsigned int k = 0; k < NUMTRAININGIMAGES; k++ ) { ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New(); thresholder->SetLowerThreshold( 255 ); thresholder->SetUpperThreshold( 255 ); thresholder->SetOutsideValue( 0 ); thresholder->SetInsideValue( 255 ); ReaderType::Pointer reader = ReaderType::New(); FilterType::Pointer filter = FilterType::New(); reader->SetFileName(trainingImageNames[k].c_str()); thresholder->SetInput(reader->GetOutput()); filter->SetInput(thresholder->GetOutput()); filter->Update(); model->SetInput(k, filter->GetOutput()); } model->Update(); model->Print(cout); //divide filter typedef itk::ShiftScaleImageFilter<InternalImageType, InternalImageType> DivideFilterType; //creating the file names for the output images itk::NumericSeriesFileNames::Pointer fileNamesCreator2 = itk::NumericSeriesFileNames::New(); fileNamesCreator2->SetStartIndex( 0 ); fileNamesCreator2->SetEndIndex( NUMPC - 1 ); fileNamesCreator2->SetSeriesFormat( "pcImage%d.mha" ); const std::vector<std::string> & outputImageNames = fileNamesCreator2->GetFileNames(); //writing the mean images WriterType::Pointer writer = WriterType::New(); writer->SetFileName("meanImage.mha"); writer->SetInput(model->GetOutput(0)); writer->Update(); for( int j = 0; j < NUMPC; j++) { cout << outputImageNames[j].c_str() << endl; } //printin the eigen values vnl_vector<double> eigenValues(NUMPC); eigenValues = model->GetEigenValues(); cout << eigenValues<<endl; //writing the principle components for(unsigned int i = 0; i < NUMPC; i++) { //normalizing the images DivideFilterType::Pointer divider = DivideFilterType::New(); divider->SetInput(model->GetOutput(i+1)); divider->SetScale(1.0/sqrt(eigenValues(i))); WriterType::Pointer myWriter = WriterType::New(); myWriter->SetFileName(outputImageNames[i].c_str()); myWriter->SetInput(divider->GetOutput()); myWriter->Update(); } return 0; }
[ [ [ 1, 182 ] ] ]
23d12d62a0fb50e387cb1e8d09a501d6d62d23b8
38664d844d9fad34e88160f6ebf86c043db9f1c5
/branches/initialize/skin/examples/mfc/mfc42_sb/MainFrm.cpp
3283da57f7973b3271e0979aa307c8585e03e875
[]
no_license
cnsuhao/jezzitest
84074b938b3e06ae820842dac62dae116d5fdaba
9b5f6cf40750511350e5456349ead8346cabb56e
refs/heads/master
2021-05-28T23:08:59.663581
2010-11-25T13:44:57
2010-11-25T13:44:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,509
cpp
// MainFrm.cpp : implementation of the CMainFrame class // #include "stdafx.h" #include "mfc42_sb.h" #include "MainFrm.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMainFrame IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) //{{AFX_MSG_MAP(CMainFrame) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code ! ON_WM_CREATE() //}}AFX_MSG_MAP END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, // status line indicator ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, }; ///////////////////////////////////////////////////////////////////////////// // CMainFrame construction/destruction CMainFrame::CMainFrame() { // TODO: add member initialization code here } CMainFrame::~CMainFrame() { } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } // TODO: Delete these three lines if you don't want the toolbar to // be dockable m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); return 0; } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CFrameWnd::PreCreateWindow(cs) ) return FALSE; // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CMainFrame diagnostics #ifdef _DEBUG void CMainFrame::AssertValid() const { CFrameWnd::AssertValid(); } void CMainFrame::Dump(CDumpContext& dc) const { CFrameWnd::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CMainFrame message handlers
[ "ken.shao@ba8f1dc9-3c1c-0410-9eed-0f8a660c14bd" ]
[ [ [ 1, 107 ] ] ]
5efe01e4291c7362c02d889bac756617cd4dc6c3
b4d726a0321649f907923cc57323942a1e45915b
/CODE/ImpED/FREDDoc.h
bf67e20dda5ba14803c6fc9ae6f3c74de6bb603c
[]
no_license
chief1983/Imperial-Alliance
f1aa664d91f32c9e244867aaac43fffdf42199dc
6db0102a8897deac845a8bd2a7aa2e1b25086448
refs/heads/master
2016-09-06T02:40:39.069630
2010-10-06T22:06:24
2010-10-06T22:06:24
967,775
2
0
null
null
null
null
UTF-8
C++
false
false
5,639
h
/* * Copyright (C) Volition, Inc. 1999. All rights reserved. * * All source code herein is the property of Volition, Inc. You may not sell * or otherwise commercially exploit the source or things you created based on the * source. * */ /* * $Logfile: /Freespace2/code/FRED2/FREDDoc.h $ * $Revision: 1.4 $ * $Date: 2003/09/30 04:05:08 $ * $Author: Goober5000 $ * * FREDDoc.h : interface of the CFREDDoc class * Document class for document/view architechure, which we don't really use in * Fred, but MFC forces you do use like it or not. Handles loading/saving * mainly. Most of the MFC related stuff is handled in FredView. * * $Log: FREDDoc.h,v $ * Revision 1.4 2003/09/30 04:05:08 Goober5000 * updated FRED to import FS1 default weapons loadouts as well as missions * --Goober5000 * * Revision 1.3 2003/09/28 21:22:58 Goober5000 * added the option to import FSM missions, added a replace function, spruced * up my $player, $rank, etc. code, and fixed encrypt being misspelled as 'encrpyt' * --Goober5000 * * Revision 1.2 2002/08/15 01:06:34 penguin * Include filename reorg (to coordinate w/ fs2_open) * * Revision 1.1.1.1 2002/07/15 03:10:57 inquisitor * Initial FRED2 Checking * * * 2 10/07/98 6:28p Dave * Initial checkin. Renamed all relevant stuff to be Fred2 instead of * Fred. Globalized mission and campaign file extensions. Removed Silent * Threat specific code. * * 1 10/07/98 3:01p Dave * * 1 10/07/98 3:00p Dave * * 15 8/17/97 10:22p Hoffoss * Fixed several bugs in Fred with Undo feature. In the process, recoded * a lot of CFile.cpp. * * 14 8/13/97 5:49p Hoffoss * Fixed bugs, made additions. * * 13 8/13/97 12:46p Hoffoss * Added campaign error checker, accelerator table, and mission goal data * listings to sexp tree right click menu. * * 12 6/09/97 4:57p Hoffoss * Added autosave and undo to Fred. * * 11 6/05/97 6:10p Hoffoss * Added features: Autosaving, object hiding. Also fixed some minor bugs. * * 10 5/21/97 5:42p Hoffoss * Added features requested on Todo list. * * 9 2/20/97 4:03p Hoffoss * Several ToDo items: new reinforcement clears arrival cue, reinforcement * control from ship and wing dialogs, show grid toggle. * * 8 2/17/97 5:28p Hoffoss * Checked RCS headers, added them were missing, changing description to * something better, etc where needed. * * 14 2/12/97 12:25p Hoffoss * Expanded on global error checker, added initial orders conflict * checking and warning, added waypoint editor dialog and code. * * 13 1/30/97 2:24p Hoffoss * Added remaining mission file structures and implemented load/save of * them. * * $NoKeywords: $ */ #ifndef _FREDDOC_H #define _FREDDOC_H #include "ship/ailocal.h" #include "MissionSave.h" #define MISSION_BACKUP_NAME "Backup" #define US_WORLD_CHANGED 0x01 #define US_VIEW_CHANGED 0x02 class CFREDDoc : public CDocument { // Attributes protected: // create from serialization only CFREDDoc(); DECLARE_DYNCREATE(CFREDDoc) public: int check_undo(); int autoload(); void file_open(void); void file_save(void); void file_save_as(void); CString trim_extension(CString); int load_mission(char *pathname, int importFSM = 0); int autosave(char *desc); int save_matrix(matrix &m, FILE *fp); int save_vector(vector &v, FILE *fp); BOOL confirm_deleting; BOOL show_capital_ships; BOOL show_elevations; BOOL show_fighters; BOOL show_grid; BOOL show_misc_objects; BOOL show_planets; BOOL show_waypoints; BOOL show_starfield; char mission_pathname[256]; // Operations public: CString undo_desc[BACKUP_DEPTH + 1]; // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CFREDDoc) public: virtual BOOL OnNewDocument(); virtual void Serialize(CArchive& ar); virtual void OnEditClearAll(); virtual void DeleteContents(); virtual BOOL OnOpenDocument(LPCTSTR lpszPathName); virtual BOOL OnSaveDocument(LPCTSTR lpszPathName); virtual void AddToRecentFileList(LPCTSTR lpszPathName); //}}AFX_VIRTUAL // Implementation public: virtual ~CFREDDoc(); static void UpdateStatus(int flags = US_WORLD_CHANGED); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext &dc) const; #endif protected: // Generated message map functions protected: //{{AFX_MSG(CFREDDoc) afx_msg void OnEditDelete(); afx_msg void OnDuplicate(); afx_msg void OnEditCopy(); afx_msg void OnEditCut(); afx_msg void OnEditHold(); afx_msg void OnEditFetch(); afx_msg void OnEditPaste(); afx_msg void OnEditUndo(); afx_msg void OnFilePreferences(); afx_msg void OnFileSave(); afx_msg void OnFileNew(); afx_msg void editor_init_mission(); afx_msg void OnFileImportFSM(); afx_msg void OnFileImportWeapons(); afx_msg void OnFileSaveUpdate(CCmdUI* pCmdUI); //}}AFX_MSG DECLARE_MESSAGE_MAP() private: int save_waypoint_list(waypoint_list &w, FILE *fp); int save_waypoints(FILE *fp); int save_goals(FILE *fp); int save_wings(FILE *fp); int save_objects(FILE *fp); int save_players(FILE *fp); int save_briefing_info(FILE *fp); int save_plot_info(FILE *fp); int save_mission_info(FILE *FP); }; extern int Local_modified; extern int Undo_available; extern int Undo_count; extern CFREDDoc *FREDDoc_ptr; extern CString current_dir; void set_modified(BOOL arg = TRUE); ///////////////////////////////////////////////////////////////////////////// #endif
[ [ [ 1, 200 ] ] ]
5e48e412761b46f350fd8c719f87eec143ca1fc6
ef6b65a1708e7f3589fb2930912062d0c5f9a31b
/src/explosion.cc
034cad27cf9f8aa8abae099d55b548f50c175b93
[]
no_license
aolagers/asteroids
7935873389a8605a02a9b4e5183f2560aba487c8
00c194b99ede6dac1170eef372c415965fb1e0e7
refs/heads/master
2021-01-02T08:57:40.077007
2011-11-26T23:23:31
2011-11-26T23:23:31
511,820
0
0
null
null
null
null
UTF-8
C++
false
false
1,566
cc
#include "explosion.hh" using namespace irr; Explosion::Explosion(PhysicalObject *target) : PhysicalObject(target->getGame()), lifeTime(0) { // create a particle system scene::IParticleSystemSceneNode* ps = getGame()->getSmgr()->addParticleSystemSceneNode(false); scene::IParticleEmitter* em = ps->createSphereEmitter( target->getPosition(), // emitter size 30, //radius core::vector3df(0.0f,0.0f,0.0f),// initial direction 60,80, // emit rate video::SColor(0,255,255,255), // darkest color video::SColor(0,255,255,255), // brightest color 800,2000,0, // min and max age, angle core::dimension2df(10.f,10.f), // min size core::dimension2df(20.f,20.f)); // max size ps->setEmitter(em); // this grabs the emitter em->drop(); // so we can drop it here without deleting it scene::IParticleAffector* paf = ps->createFadeOutParticleAffector(); ps->addAffector(paf); // same goes for the affector paf->drop(); ps->setMaterialFlag(video::EMF_LIGHTING, false); ps->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false); ps->setMaterialTexture(0, getGame()->getDriver()->getTexture(PROJECT_DATA_DIR "/fire.bmp")); ps->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA); setNode(ps); // setSpeed(core::vector3df(0,0,0)); } void Explosion::update(irr::f32 timeStep) { lifeTime += timeStep; //setPosition(getPosition() + 0.3*getSpeed() * timeStep); if(lifeTime > 0.7) setRemove(true); }
[ [ [ 1, 51 ] ] ]
7a4dcfd0c74339b76f4eed5d3f1f6f72c7fa3599
0466568120485fcabdba5aa22a4b0fea13068b8b
/opencv/modules/gpu/test/nvidia/NCVTestSourceProvider.hpp
f4f9a392ecf43960cafafa3c3d8b9c43ddea2730
[]
no_license
coapp-packages/opencv
be25a9aec58d9ac890fc764932ba67914add078d
c78981e0d8f602fde523a82c3a7e2c3fef1f39bc
refs/heads/master
2020-05-17T12:11:25.406742
2011-07-14T17:13:01
2011-07-14T17:13:01
2,048,483
3
0
null
null
null
null
UTF-8
C++
false
false
5,490
hpp
/* * Copyright 1993-2010 NVIDIA Corporation. All rights reserved. * * NVIDIA Corporation and its licensors retain all intellectual * property and proprietary rights in and to this software and * related documentation and any modifications thereto. * Any use, reproduction, disclosure, or distribution of this * software and related documentation without an express license * agreement from NVIDIA Corporation is strictly prohibited. */ #ifndef _ncvtestsourceprovider_hpp_ #define _ncvtestsourceprovider_hpp_ #include <memory> #include "NCV.hpp" #include <opencv2/highgui/highgui.hpp> template <class T> class NCVTestSourceProvider { public: NCVTestSourceProvider(Ncv32u seed, T rangeLow, T rangeHigh, Ncv32u maxWidth, Ncv32u maxHeight) : bInit(false) { ncvAssertPrintReturn(rangeLow < rangeHigh, "NCVTestSourceProvider ctor:: Invalid range", ); int devId; cudaDeviceProp devProp; ncvAssertPrintReturn(cudaSuccess == cudaGetDevice(&devId), "Error returned from cudaGetDevice", ); ncvAssertPrintReturn(cudaSuccess == cudaGetDeviceProperties(&devProp, devId), "Error returned from cudaGetDeviceProperties", ); //Ncv32u maxWpitch = alignUp(maxWidth * sizeof(T), devProp.textureAlignment); allocatorCPU.reset(new NCVMemNativeAllocator(NCVMemoryTypeHostPinned, devProp.textureAlignment)); data.reset(new NCVMatrixAlloc<T>(*this->allocatorCPU.get(), maxWidth, maxHeight)); ncvAssertPrintReturn(data.get()->isMemAllocated(), "NCVTestSourceProvider ctor:: Matrix not allocated", ); this->dataWidth = maxWidth; this->dataHeight = maxHeight; srand(seed); for (Ncv32u i=0; i<maxHeight; i++) { for (Ncv32u j=0; j<data.get()->stride(); j++) { data.get()->ptr()[i * data.get()->stride() + j] = (T)(((1.0 * rand()) / RAND_MAX) * (rangeHigh - rangeLow) + rangeLow); } } this->bInit = true; } NCVTestSourceProvider(std::string pgmFilename) : bInit(false) { ncvAssertPrintReturn(sizeof(T) == 1, "NCVTestSourceProvider ctor:: PGM constructor complies only with 8bit types", ); cv::Mat image = cv::imread(pgmFilename); ncvAssertPrintReturn(!image.empty(), "NCVTestSourceProvider ctor:: PGM file error", ); int devId; cudaDeviceProp devProp; ncvAssertPrintReturn(cudaSuccess == cudaGetDevice(&devId), "Error returned from cudaGetDevice", ); ncvAssertPrintReturn(cudaSuccess == cudaGetDeviceProperties(&devProp, devId), "Error returned from cudaGetDeviceProperties", ); allocatorCPU.reset(new NCVMemNativeAllocator(NCVMemoryTypeHostPinned, devProp.textureAlignment)); data.reset(new NCVMatrixAlloc<T>(*this->allocatorCPU.get(), image.cols, image.rows)); ncvAssertPrintReturn(data.get()->isMemAllocated(), "NCVTestSourceProvider ctor:: Matrix not allocated", ); this->dataWidth = image.cols; this->dataHeight = image.rows; cv::Mat hdr(image.size(), CV_8UC1, data.get()->ptr(), data.get()->pitch()); image.copyTo(hdr); this->bInit = true; } NcvBool fill(NCVMatrix<T> &dst) { ncvAssertReturn(this->isInit() && dst.memType() == allocatorCPU.get()->memType(), false); if (dst.width() == 0 || dst.height() == 0) { return true; } for (Ncv32u i=0; i<dst.height(); i++) { Ncv32u srcLine = i % this->dataHeight; Ncv32u srcFullChunks = dst.width() / this->dataWidth; for (Ncv32u j=0; j<srcFullChunks; j++) { memcpy(dst.ptr() + i * dst.stride() + j * this->dataWidth, this->data.get()->ptr() + this->data.get()->stride() * srcLine, this->dataWidth * sizeof(T)); } Ncv32u srcLastChunk = dst.width() % this->dataWidth; memcpy(dst.ptr() + i * dst.stride() + srcFullChunks * this->dataWidth, this->data.get()->ptr() + this->data.get()->stride() * srcLine, srcLastChunk * sizeof(T)); } return true; } NcvBool fill(NCVVector<T> &dst) { ncvAssertReturn(this->isInit() && dst.memType() == allocatorCPU.get()->memType(), false); if (dst.length() == 0) { return true; } Ncv32u srcLen = this->dataWidth * this->dataHeight; Ncv32u srcFullChunks = (Ncv32u)dst.length() / srcLen; for (Ncv32u j=0; j<srcFullChunks; j++) { memcpy(dst.ptr() + j * srcLen, this->data.get()->ptr(), srcLen * sizeof(T)); } Ncv32u srcLastChunk = dst.length() % srcLen; memcpy(dst.ptr() + srcFullChunks * srcLen, this->data.get()->ptr(), srcLastChunk * sizeof(T)); return true; } ~NCVTestSourceProvider() { data.reset(); allocatorCPU.reset(); } private: NcvBool isInit(void) { return this->bInit; } NcvBool bInit; std::auto_ptr< INCVMemAllocator > allocatorCPU; std::auto_ptr< NCVMatrixAlloc<T> > data; Ncv32u dataWidth; Ncv32u dataHeight; }; #endif // _ncvtestsourceprovider_hpp_
[ "alexeys@73c94f0f-984f-4a5f-82bc-2d8db8d8ee08" ]
[ [ [ 1, 161 ] ] ]
bb6136f81e4c6bd72f66d734aa3de5a77eeb1201
fb4cf44e2c146b26ddde6350180cc420611fe17a
/SDK/CyTeam.cpp
4ccd69dc060bd1055de1e45d269a226f5707a1b5
[]
no_license
dharkness/civ4bullai
93e0685ef53e404ac4ffa5c1aecf4edaf61acd61
e56c8a4f1172e2d2b15eb87eaa78adb9d357fae6
refs/heads/master
2022-09-15T23:31:55.030351
2010-11-13T07:23:13
2010-11-13T07:23:13
267,723,017
0
0
null
null
null
null
UTF-8
C++
false
false
25,167
cpp
// // Python wrapper class for CvTeam // updated 6-5 // #include "CvGameCoreDLL.h" #include "CyTeam.h" #include "CyArea.h" #include "CvTeam.h" CyTeam::CyTeam() : m_pTeam(NULL) { } CyTeam::CyTeam(CvTeam* pTeam) : m_pTeam(pTeam) { } void CyTeam::addTeam(int /*TeamTypes*/ eTeam) { if (m_pTeam) m_pTeam->addTeam((TeamTypes)eTeam); } bool CyTeam::canChangeWarPeace(int /*TeamTypes*/ eTeam) { return m_pTeam ? m_pTeam->canChangeWarPeace((TeamTypes)eTeam) : false; } bool CyTeam::canDeclareWar(int /*TeamTypes*/ eTeam) { return m_pTeam ? m_pTeam->canDeclareWar((TeamTypes)eTeam) : false; } void CyTeam::declareWar(int /*TeamTypes*/ eTeam, bool bNewDiplo, int /*WarPlanTypes*/ eWarPlan) { if (m_pTeam) m_pTeam->declareWar((TeamTypes)eTeam, bNewDiplo, (WarPlanTypes)eWarPlan); } void CyTeam::makePeace(int /*TeamTypes*/ eTeam) { if (m_pTeam) m_pTeam->makePeace((TeamTypes)eTeam); } bool CyTeam::canContact(int /*TeamTypes*/ eTeam) { return m_pTeam ? m_pTeam->canContact((TeamTypes)eTeam) : false; } void CyTeam::meet(int /*TeamTypes*/ eTeam, bool bNewDiplo) { if (m_pTeam) m_pTeam->meet((TeamTypes)eTeam, bNewDiplo); } void CyTeam::signOpenBorders(int /*TeamTypes*/ eTeam) { if (m_pTeam) m_pTeam->signOpenBorders((TeamTypes)eTeam); } void CyTeam::signDefensivePact(int /*TeamTypes*/ eTeam) { if (m_pTeam) m_pTeam->signDefensivePact((TeamTypes)eTeam); } int CyTeam::getAssets() { return m_pTeam ? m_pTeam->getAssets() : -1; } int CyTeam::getPower(bool bIncludeVassals) { return m_pTeam ? m_pTeam->getPower(bIncludeVassals) : -1; } int CyTeam::getDefensivePower() { return m_pTeam ? m_pTeam->getDefensivePower() : -1; } int CyTeam::getNumNukeUnits() { return m_pTeam ? m_pTeam->getNumNukeUnits() : -1; } int CyTeam::getAtWarCount(bool bIgnoreMinors) { return m_pTeam ? m_pTeam->getAtWarCount(bIgnoreMinors) : -1; } int CyTeam::getWarPlanCount(int /*WarPlanTypes*/ eWarPlan, bool bIgnoreMinors) { return m_pTeam ? m_pTeam->getWarPlanCount((WarPlanTypes) eWarPlan, bIgnoreMinors) : -1; } int CyTeam::getAnyWarPlanCount(bool bIgnoreMinors) { return m_pTeam ? m_pTeam->getAnyWarPlanCount(bIgnoreMinors) : -1; } int CyTeam::getChosenWarCount(bool bIgnoreMinors) { return m_pTeam ? m_pTeam->getChosenWarCount(bIgnoreMinors) : -1; } int CyTeam::getHasMetCivCount(bool bIgnoreMinors) { return m_pTeam ? m_pTeam->getHasMetCivCount(bIgnoreMinors) : -1; } bool CyTeam::hasMetHuman() { return m_pTeam ? m_pTeam->hasMetHuman() : false; } int CyTeam::getDefensivePactCount() { return m_pTeam ? m_pTeam->getDefensivePactCount() : -1; } bool CyTeam::isAVassal() const { return m_pTeam ? m_pTeam->isAVassal() : false; } int CyTeam::getUnitClassMaking(int /*UnitClassTypes*/ eUnitClass) { return m_pTeam ? m_pTeam->getUnitClassMaking((UnitClassTypes)eUnitClass) : -1; } int CyTeam::getUnitClassCountPlusMaking(int /*UnitClassTypes*/ eUnitClass) { return m_pTeam ? m_pTeam->getUnitClassCountPlusMaking((UnitClassTypes)eUnitClass) : -1; } int CyTeam::getBuildingClassMaking(int /*BuildingClassTypes*/ eBuildingClass) { return m_pTeam ? m_pTeam->getBuildingClassMaking((BuildingClassTypes)eBuildingClass) : -1; } int CyTeam::getBuildingClassCountPlusMaking(int /*BuildingClassTypes*/ eBuildingClass) { return m_pTeam ? m_pTeam->getBuildingClassCountPlusMaking((BuildingClassTypes)eBuildingClass) : -1; } int CyTeam::getHasReligionCount(int /*ReligionTypes*/ eReligion) { return m_pTeam ? m_pTeam->getHasReligionCount((ReligionTypes)eReligion) : -1; } int CyTeam::getHasCorporationCount(int /*CorporationTypes*/ eReligion) { return m_pTeam ? m_pTeam->getHasCorporationCount((CorporationTypes)eReligion) : -1; } int CyTeam::countTotalCulture() { return m_pTeam ? m_pTeam->countTotalCulture() : -1; } int CyTeam::countNumUnitsByArea(CyArea* pArea) { return m_pTeam ? m_pTeam->countNumUnitsByArea(pArea->getArea()) : -1; } int CyTeam::countNumCitiesByArea(CyArea* pArea) { return m_pTeam ? m_pTeam->countNumCitiesByArea(pArea->getArea()) : -1; } int CyTeam::countTotalPopulationByArea(CyArea* pArea) { return m_pTeam ? m_pTeam->countTotalPopulationByArea(pArea->getArea()) : -1; } int CyTeam::countPowerByArea(CyArea* pArea) { return m_pTeam ? m_pTeam->countPowerByArea(pArea->getArea()) : -1; } int CyTeam::countEnemyPowerByArea(CyArea* pArea) { return m_pTeam ? m_pTeam->countEnemyPowerByArea(pArea->getArea()) : -1; } int CyTeam::countNumAIUnitsByArea(CyArea* pArea, int /*UnitAITypes*/ eUnitAI) { return m_pTeam ? m_pTeam->countNumAIUnitsByArea(pArea->getArea(), (UnitAITypes) eUnitAI) : -1; } int CyTeam::countEnemyDangerByArea(CyArea* pArea) { return m_pTeam ? m_pTeam->countEnemyDangerByArea(pArea->getArea()) : -1; } int CyTeam::getResearchCost(int /*TechTypes*/ eTech) { return m_pTeam ? m_pTeam->getResearchCost((TechTypes)eTech) : -1; } int CyTeam::getResearchLeft(int /*TechTypes*/ eTech) { return m_pTeam ? m_pTeam->getResearchLeft((TechTypes)eTech) : -1; } bool CyTeam::hasHolyCity(int /*ReligionTypes*/ eReligion) { return m_pTeam ? m_pTeam->hasHolyCity((ReligionTypes)eReligion) : false; } bool CyTeam::hasHeadquarters(int /*CorporationTypes*/ eCorporation) { return m_pTeam ? m_pTeam->hasHeadquarters((CorporationTypes)eCorporation) : false; } bool CyTeam::isHuman() { return m_pTeam ? m_pTeam->isHuman() : false; } bool CyTeam::isBarbarian() { return m_pTeam ? m_pTeam->isBarbarian() : false; } bool CyTeam::isMinorCiv() { return m_pTeam ? m_pTeam->isMinorCiv() : false; } int /*PlayerTypes*/ CyTeam::getLeaderID() { return m_pTeam ? m_pTeam->getLeaderID() : -1; } int /*PlayerTypes*/ CyTeam::getSecretaryID() { return m_pTeam ? m_pTeam->getSecretaryID() : -1; } int /*HandicapTypes*/ CyTeam::getHandicapType() { return m_pTeam ? m_pTeam->getHandicapType() : -1; } std::wstring CyTeam::getName() { return m_pTeam ? m_pTeam->getName() : L""; } int CyTeam::getNumMembers() { return m_pTeam ? m_pTeam->getNumMembers() : -1; } bool CyTeam::isAlive() { return m_pTeam ? m_pTeam->isAlive() : false; } bool CyTeam::isEverAlive() { return m_pTeam ? m_pTeam->isEverAlive() : false; } int CyTeam::getNumCities() { return m_pTeam ? m_pTeam->getNumCities() : -1; } int CyTeam::getTotalPopulation() { return m_pTeam ? m_pTeam->getTotalPopulation() : -1; } int CyTeam::getTotalLand() { return m_pTeam ? m_pTeam->getTotalLand() : -1; } int CyTeam::getNukeInterception() { return m_pTeam ? m_pTeam->getNukeInterception() : -1; } void CyTeam::changeNukeInterception(int iChange) { if (m_pTeam) m_pTeam->changeNukeInterception(iChange); } int CyTeam::getForceTeamVoteEligibilityCount(int /*VoteSourceTypes*/ eVoteSource) { return m_pTeam ? m_pTeam->getForceTeamVoteEligibilityCount((VoteSourceTypes)eVoteSource) : -1; } bool CyTeam::isForceTeamVoteEligible(int /*VoteSourceTypes*/ eVoteSource) { return m_pTeam ? m_pTeam->isForceTeamVoteEligible((VoteSourceTypes)eVoteSource) : false; } void CyTeam::changeForceTeamVoteEligibilityCount(int /*VoteSourceTypes*/ eVoteSource, int iChange) { if (m_pTeam) m_pTeam->changeForceTeamVoteEligibilityCount((VoteSourceTypes)eVoteSource, iChange); } int CyTeam::getExtraWaterSeeFromCount() { return m_pTeam ? m_pTeam->getExtraWaterSeeFromCount() : -1; } bool CyTeam::isExtraWaterSeeFrom() { return m_pTeam ? m_pTeam->isExtraWaterSeeFrom() : false; } void CyTeam::changeExtraWaterSeeFromCount(int iChange) { if (m_pTeam) m_pTeam->changeExtraWaterSeeFromCount(iChange); } int CyTeam::getMapTradingCount() { return m_pTeam ? m_pTeam->getMapTradingCount() : -1; } bool CyTeam::isMapTrading() { return m_pTeam ? m_pTeam->isMapTrading() : false; } void CyTeam::changeMapTradingCount(int iChange) { if (m_pTeam) m_pTeam->changeMapTradingCount(iChange); } int CyTeam::getTechTradingCount() { return m_pTeam ? m_pTeam->getTechTradingCount() : -1; } bool CyTeam::isTechTrading() { return m_pTeam ? m_pTeam->isTechTrading() : false; } void CyTeam::changeTechTradingCount(int iChange) { if (m_pTeam) m_pTeam->changeTechTradingCount(iChange); } int CyTeam::getGoldTradingCount() { return m_pTeam ? m_pTeam->getGoldTradingCount() : -1; } bool CyTeam::isGoldTrading() { return m_pTeam ? m_pTeam->isGoldTrading() : false; } void CyTeam::changeGoldTradingCount(int iChange) { if (m_pTeam) m_pTeam->changeGoldTradingCount(iChange); } int CyTeam::getOpenBordersTradingCount() { return m_pTeam ? m_pTeam->getOpenBordersTradingCount() : -1; } bool CyTeam::isOpenBordersTrading() { return m_pTeam ? m_pTeam->isOpenBordersTrading() : false; } void CyTeam::changeOpenBordersTradingCount(int iChange) { if (m_pTeam) m_pTeam->changeOpenBordersTradingCount(iChange); } int CyTeam::getDefensivePactTradingCount() { return m_pTeam ? m_pTeam->getDefensivePactTradingCount() : -1; } bool CyTeam::isDefensivePactTrading() { return m_pTeam ? m_pTeam->isDefensivePactTrading() : false; } void CyTeam::changeDefensivePactTradingCount(int iChange) { if (m_pTeam) m_pTeam->changeDefensivePactTradingCount(iChange); } int CyTeam::getPermanentAllianceTradingCount() { return m_pTeam ? m_pTeam->getPermanentAllianceTradingCount() : -1; } bool CyTeam::isPermanentAllianceTrading() { return m_pTeam ? m_pTeam->isPermanentAllianceTrading() : false; } void CyTeam::changePermanentAllianceTradingCount(int iChange) { if (m_pTeam) m_pTeam->changePermanentAllianceTradingCount(iChange); } int CyTeam::getVassalTradingCount() { return m_pTeam ? m_pTeam->getVassalTradingCount() : -1; } bool CyTeam::isVassalStateTrading() { return m_pTeam ? m_pTeam->isVassalStateTrading() : false; } void CyTeam::changeVassalTradingCount(int iChange) { if (m_pTeam) m_pTeam->changeVassalTradingCount(iChange); } int CyTeam::getBridgeBuildingCount() { return m_pTeam ? m_pTeam->getBridgeBuildingCount() : -1; } bool CyTeam::isBridgeBuilding() { return m_pTeam ? m_pTeam->isBridgeBuilding() : false; } void CyTeam::changeBridgeBuildingCount(int iChange) { if (m_pTeam) m_pTeam->changeBridgeBuildingCount(iChange); } int CyTeam::getIrrigationCount() { return m_pTeam ? m_pTeam->getIrrigationCount() : -1; } bool CyTeam::isIrrigation() { return m_pTeam ? m_pTeam->isIrrigation() : false; } void CyTeam::changeIrrigationCount(int iChange) { if (m_pTeam) m_pTeam->changeIrrigationCount(iChange); } int CyTeam::getIgnoreIrrigationCount() { return m_pTeam ? m_pTeam->getIgnoreIrrigationCount() : -1; } bool CyTeam::isIgnoreIrrigation() { return m_pTeam ? m_pTeam->isIgnoreIrrigation() : false; } void CyTeam::changeIgnoreIrrigationCount(int iChange) { if (m_pTeam) m_pTeam->changeIgnoreIrrigationCount(iChange); } int CyTeam::getWaterWorkCount() { return m_pTeam ? m_pTeam->getWaterWorkCount() : -1; } bool CyTeam::isWaterWork() { return m_pTeam ? m_pTeam->isWaterWork() : false; } void CyTeam::changeWaterWorkCount(int iChange) { if (m_pTeam) m_pTeam->changeWaterWorkCount(iChange); } int CyTeam::getVassalPower() const { return (m_pTeam ? m_pTeam->getVassalPower() : -1); } void CyTeam::setVassalPower(int iPower) { if (m_pTeam) { m_pTeam->setVassalPower(iPower); } } int CyTeam::getMasterPower() const { return (m_pTeam ? m_pTeam->getMasterPower() : -1); } void CyTeam::setMasterPower(int iPower) { if (m_pTeam) { m_pTeam->setMasterPower(iPower); } } int CyTeam::getEnemyWarWearinessModifier() const { return m_pTeam ? m_pTeam->getEnemyWarWearinessModifier() : -1; } void CyTeam::changeEnemyWarWearinessModifier(int iChange) { if (m_pTeam) { m_pTeam->changeEnemyWarWearinessModifier(iChange); } } bool CyTeam::isMapCentering() { return m_pTeam ? m_pTeam->isMapCentering() : false; } void CyTeam::setMapCentering(bool bNewValue) { if (m_pTeam) m_pTeam->setMapCentering(bNewValue); } int CyTeam::getID() { return m_pTeam ? m_pTeam->getID() : -1; } bool CyTeam::isStolenVisibility(int /*TeamTypes*/ eIndex) { return m_pTeam ? m_pTeam->isStolenVisibility((TeamTypes)eIndex) : false; } int CyTeam::getWarWeariness(int /*TeamTypes*/ eIndex) { return m_pTeam ? m_pTeam->getWarWeariness((TeamTypes)eIndex) : -1; } void CyTeam::setWarWeariness(int /*TeamTypes*/ eIndex, int iNewValue) { if (m_pTeam) m_pTeam->setWarWeariness((TeamTypes)eIndex, iNewValue); } void CyTeam::changeWarWeariness(int /*TeamTypes*/ eIndex, int iChange) { if (m_pTeam) m_pTeam->changeWarWeariness((TeamTypes)eIndex, iChange); } int CyTeam::getTechShareCount(int iIndex) { return m_pTeam ? m_pTeam->getTechShareCount(iIndex) : -1; } bool CyTeam::isTechShare(int iIndex) { return m_pTeam ? m_pTeam->isTechShare(iIndex) : false; } void CyTeam::changeTechShareCount(int iIndex, int iChange) { if (m_pTeam) m_pTeam->changeTechShareCount(iIndex, iChange); } int CyTeam::getCommerceFlexibleCount(int /*CommerceTypes*/ eIndex) { return m_pTeam ? m_pTeam->getCommerceFlexibleCount((CommerceTypes)eIndex) : -1; } bool CyTeam::isCommerceFlexible(int /*CommerceTypes*/ eIndex) { return m_pTeam ? m_pTeam->isCommerceFlexible((CommerceTypes)eIndex) : false; } void CyTeam::changeCommerceFlexibleCount(int /*CommerceTypes*/ eIndex, int iChange) { if (m_pTeam) m_pTeam->changeCommerceFlexibleCount((CommerceTypes)eIndex, iChange); } int CyTeam::getExtraMoves(int /*DomainTypes*/ eIndex) { return m_pTeam ? m_pTeam->getExtraMoves((DomainTypes)eIndex) : -1; } void CyTeam::changeExtraMoves(int /*DomainTypes*/ eIndex, int iChange) { if (m_pTeam) m_pTeam->changeExtraMoves((DomainTypes)eIndex, iChange); } bool CyTeam::isHasMet(int /*TeamTypes*/ eIndex) { //Fuyu: Catching Civ4lerts mess-ups FAssertMsg(eIndex >= 0, "eIndex is expected to be non-negative (invalid Index) (Python)"); FAssertMsg(eIndex < MAX_TEAMS, "eIndex is expected to be within maximum bounds (invalid Index) (Python)"); if (eIndex < 0 || eIndex >= MAX_TEAMS) { #ifdef _DEBUG throw new exception(); #endif return false; } return m_pTeam ? m_pTeam->isHasMet((TeamTypes)eIndex) : false; } bool CyTeam::isAtWar(int /*TeamTypes*/ iIndex) { if (iIndex == NO_TEAM) return false; return m_pTeam ? m_pTeam->isAtWar((TeamTypes)iIndex) : false; } bool CyTeam::isPermanentWarPeace(int /*TeamTypes*/ eIndex) { return m_pTeam ? m_pTeam->isPermanentWarPeace((TeamTypes)eIndex) : false; } void CyTeam::setPermanentWarPeace(int /*TeamTypes*/ eIndex, bool bNewValue) { if (m_pTeam) m_pTeam->setPermanentWarPeace((TeamTypes)eIndex, bNewValue); } bool CyTeam::isFreeTrade(int /*TeamTypes*/ eIndex) { return m_pTeam ? m_pTeam->isFreeTrade((TeamTypes)eIndex) : false; } bool CyTeam::isOpenBorders(int /*TeamTypes*/ eIndex) { return m_pTeam ? m_pTeam->isOpenBorders((TeamTypes)eIndex) : false; } bool CyTeam::isForcePeace(int /*TeamTypes*/ eIndex) { return m_pTeam ? m_pTeam->isForcePeace((TeamTypes)eIndex) : false; } bool CyTeam::isVassal(int /*TeamTypes*/ eIndex) { return m_pTeam ? m_pTeam->isVassal((TeamTypes)eIndex) : false; } void CyTeam::setVassal(int /*TeamTypes*/ eIndex, bool bVassal, bool bCapitulated) { if (m_pTeam) { m_pTeam->setVassal((TeamTypes)eIndex, bVassal, bCapitulated); } } void CyTeam::assignVassal(int /*TeamTypes*/ eIndex, bool bSurrender) { if (m_pTeam) { m_pTeam->assignVassal((TeamTypes)eIndex, bSurrender); } } void CyTeam::freeVassal(int /*TeamTypes*/ eIndex) { if (m_pTeam) { m_pTeam->freeVassal((TeamTypes)eIndex); } } bool CyTeam::isDefensivePact(int /*TeamTypes*/ eIndex) { return m_pTeam ? m_pTeam->isDefensivePact((TeamTypes)eIndex) : false; } int CyTeam::getRouteChange(int /*RouteTypes*/ eIndex) { return m_pTeam ? m_pTeam->getRouteChange((RouteTypes)eIndex) : -1; } void CyTeam::changeRouteChange(int /*RouteTypes*/ eIndex, int iChange) { if (m_pTeam) m_pTeam->changeRouteChange((RouteTypes)eIndex, iChange); } int CyTeam::getProjectCount(int /*ProjectTypes*/ eIndex) { return m_pTeam ? m_pTeam->getProjectCount((ProjectTypes)eIndex) : -1; } int CyTeam::getProjectDefaultArtType(int /*ProjectTypes*/ eIndex) { return m_pTeam ? m_pTeam->getProjectDefaultArtType((ProjectTypes)eIndex) : -1; } void CyTeam::setProjectDefaultArtType(int /*ProjectTypes*/ eIndex, int value) { if(m_pTeam != NULL) m_pTeam->setProjectDefaultArtType((ProjectTypes)eIndex, value); } int CyTeam::getProjectArtType(int /*ProjectTypes*/ eIndex, int number) { if(m_pTeam != NULL) return m_pTeam->getProjectArtType((ProjectTypes)eIndex, number); else return -1; } void CyTeam::setProjectArtType(int /*ProjectTypes*/ eIndex, int number, int value) { if(m_pTeam != NULL) m_pTeam->setProjectArtType((ProjectTypes)eIndex, number, value); } bool CyTeam::isProjectMaxedOut(int /*ProjectTypes*/ eIndex, int iExtra) { return m_pTeam ? m_pTeam->isProjectMaxedOut((ProjectTypes)eIndex, iExtra) : false; } bool CyTeam::isProjectAndArtMaxedOut(int /*ProjectTypes*/ eIndex) { return m_pTeam ? m_pTeam->isProjectAndArtMaxedOut((ProjectTypes)eIndex) : false; } void CyTeam::changeProjectCount(int /*ProjectTypes*/ eIndex, int iChange) { if (m_pTeam) m_pTeam->changeProjectCount((ProjectTypes)eIndex, iChange); } int CyTeam::getProjectMaking(int /*ProjectTypes*/ eIndex) { return m_pTeam ? m_pTeam->getProjectMaking((ProjectTypes)eIndex) : -1; } int CyTeam::getUnitClassCount(int /*UnitClassTypes*/ eIndex) { return m_pTeam ? m_pTeam->getUnitClassCount((UnitClassTypes)eIndex) : -1; } bool CyTeam::isUnitClassMaxedOut(int /*UnitClassTypes*/ eIndex, int iExtra) { return m_pTeam ? m_pTeam->isUnitClassMaxedOut((UnitClassTypes)eIndex, iExtra) : false; } int CyTeam::getBuildingClassCount(int /*BuildingClassTypes*/ eIndex) { return m_pTeam ? m_pTeam->getBuildingClassCount((BuildingClassTypes)eIndex) : -1; } bool CyTeam::isBuildingClassMaxedOut(int /*BuildingClassTypes*/ eIndex, int iExtra) { return m_pTeam ? m_pTeam->isBuildingClassMaxedOut((BuildingClassTypes)eIndex, iExtra) : false; } int CyTeam::getObsoleteBuildingCount(int /*BuildingTypes*/ eIndex) { return m_pTeam ? m_pTeam->getObsoleteBuildingCount((BuildingTypes)eIndex) : -1; } bool CyTeam::isObsoleteBuilding(int /*BuildingTypes*/ eIndex) { return m_pTeam ? m_pTeam->isObsoleteBuilding((BuildingTypes)eIndex) : false; } int CyTeam::getResearchProgress(int /*TechTypes*/ eIndex) { return m_pTeam ? m_pTeam->getResearchProgress((TechTypes)eIndex) : -1; } void CyTeam::setResearchProgress(int /*TechTypes*/ eIndex, int iNewValue, int /*PlayerTypes*/ ePlayer) { if (m_pTeam) m_pTeam->setResearchProgress((TechTypes)eIndex, iNewValue, (PlayerTypes)ePlayer); } void CyTeam::changeResearchProgress(int /*TechTypes*/ eIndex, int iChange, int /*PlayerTypes*/ ePlayer) { if (m_pTeam) m_pTeam->changeResearchProgress((TechTypes)eIndex, iChange, (PlayerTypes)ePlayer); } int CyTeam::getTechCount(int /*TechTypes*/ eIndex) { return m_pTeam ? m_pTeam->getTechCount((TechTypes)eIndex) : -1; } bool CyTeam::isTerrainTrade(int /*TerrainTypes*/ eIndex) { if (m_pTeam) { return m_pTeam->isTerrainTrade((TerrainTypes)eIndex); } return false; } bool CyTeam::isRiverTrade() { if (m_pTeam) { return m_pTeam->isRiverTrade(); } return false; } bool CyTeam::isHasTech(int /* TechTypes */ iIndex) { return m_pTeam ? m_pTeam->isHasTech((TechTypes)iIndex) : false; } void CyTeam::setHasTech(int /*TechTypes*/ eIndex, bool bNewValue, int /*PlayerTypes*/ ePlayer, bool bFirst, bool bAnnounce) { if (m_pTeam) m_pTeam->setHasTech((TechTypes)eIndex, bNewValue, (PlayerTypes)ePlayer, bFirst, bAnnounce); } bool CyTeam::isNoTradeTech(int /* TechTypes */ iIndex) { return m_pTeam ? m_pTeam->isNoTradeTech((TechTypes)iIndex) : false; } void CyTeam::setNoTradeTech(int /*TechTypes*/ eIndex, bool bNewValue) { if (m_pTeam) m_pTeam->setNoTradeTech((TechTypes)eIndex, bNewValue); } int CyTeam::getImprovementYieldChange(int /*ImprovementTypes*/ eIndex1, int /*YieldTypes*/ eIndex2) { return m_pTeam ? m_pTeam->getImprovementYieldChange((ImprovementTypes)eIndex1, (YieldTypes)eIndex2) : -1; } void CyTeam::changeImprovementYieldChange(int /*ImprovementTypes*/ eIndex1, int /*YieldTypes*/ eIndex2, int iChange) { if (m_pTeam) m_pTeam->changeImprovementYieldChange((ImprovementTypes)eIndex1, (YieldTypes)eIndex2, iChange); } int CyTeam::getVictoryCountdown(int /*VictoryTypes*/ eVictory) { return (m_pTeam ? m_pTeam->getVictoryCountdown((VictoryTypes)eVictory) : -1); } int CyTeam::getVictoryDelay(int /*VictoryTypes*/ eVictory) { return (m_pTeam ? m_pTeam->getVictoryDelay((VictoryTypes)eVictory) : -1); } bool CyTeam::canLaunch(int /*VictoryTypes*/ eVictory) { return (m_pTeam ? m_pTeam->canLaunch((VictoryTypes)eVictory) : false); } int CyTeam::getLaunchSuccessRate(int /*VictoryTypes*/ eVictory) { return (m_pTeam ? m_pTeam->getLaunchSuccessRate((VictoryTypes)eVictory) : -1); } int CyTeam::getEspionagePointsAgainstTeam(int /*TeamTypes*/ eIndex) { return m_pTeam ? m_pTeam->getEspionagePointsAgainstTeam((TeamTypes) eIndex) : -1; } void CyTeam::setEspionagePointsAgainstTeam(int /*TeamTypes*/ eIndex, int iValue) { if (m_pTeam) m_pTeam->setEspionagePointsAgainstTeam((TeamTypes) eIndex, iValue); } void CyTeam::changeEspionagePointsAgainstTeam(int /*TeamTypes*/ eIndex, int iChange) { if (m_pTeam) m_pTeam->changeEspionagePointsAgainstTeam((TeamTypes) eIndex, iChange); } int CyTeam::getEspionagePointsEver() { return m_pTeam ? m_pTeam->getEspionagePointsEver() : -1; } void CyTeam::setEspionagePointsEver(int iValue) { if (m_pTeam) m_pTeam->setEspionagePointsEver(iValue); } void CyTeam::changeEspionagePointsEver(int iChange) { if (m_pTeam) m_pTeam->changeEspionagePointsEver(iChange); } int CyTeam::getCounterespionageTurnsLeftAgainstTeam(int /*TeamTypes*/ eIndex) { return m_pTeam ? m_pTeam->getCounterespionageTurnsLeftAgainstTeam((TeamTypes) eIndex) : -1; } void CyTeam::setCounterespionageTurnsLeftAgainstTeam(int /*TeamTypes*/ eIndex, int iValue) { if (m_pTeam) m_pTeam->setCounterespionageTurnsLeftAgainstTeam((TeamTypes) eIndex, iValue); } void CyTeam::changeCounterespionageTurnsLeftAgainstTeam(int /*TeamTypes*/ eIndex, int iChange) { if (m_pTeam) m_pTeam->changeCounterespionageTurnsLeftAgainstTeam((TeamTypes) eIndex, iChange); } int CyTeam::getCounterespionageModAgainstTeam(int /*TeamTypes*/ eIndex) { return m_pTeam ? m_pTeam->getCounterespionageModAgainstTeam((TeamTypes) eIndex) : -1; } void CyTeam::setCounterespionageModAgainstTeam(int /*TeamTypes*/ eIndex, int iValue) { if (m_pTeam) m_pTeam->setCounterespionageModAgainstTeam((TeamTypes) eIndex, iValue); } void CyTeam::changeCounterespionageModAgainstTeam(int /*TeamTypes*/ eIndex, int iChange) { if (m_pTeam) m_pTeam->changeCounterespionageModAgainstTeam((TeamTypes) eIndex, iChange); } bool CyTeam::AI_shareWar(int /*TeamTypes*/ eTeam) { return m_pTeam ? m_pTeam->AI_shareWar((TeamTypes)eTeam) : false; } void CyTeam::AI_setWarPlan(int /*TeamTypes*/ eIndex, int /*WarPlanTypes*/ eNewValue) { if (m_pTeam) { m_pTeam->AI_setWarPlan((TeamTypes)eIndex, (WarPlanTypes)eNewValue); } } /************************************************************************************************/ /* BETTER_BTS_AI_MOD 01/12/09 jdog5000 */ /* */ /* Player Interface */ /************************************************************************************************/ int CyTeam::AI_getWarPlan(int /*TeamTypes*/ eIndex) const { return m_pTeam ? m_pTeam->AI_getWarPlan((TeamTypes)eIndex) : -1; } /************************************************************************************************/ /* BETTER_BTS_AI_MOD END */ /************************************************************************************************/ int CyTeam::AI_getAtWarCounter(int /*TeamTypes*/ eTeam) const { return m_pTeam ? m_pTeam->AI_getAtWarCounter((TeamTypes)eTeam) : -1; } int CyTeam::AI_getAtPeaceCounter(int /*TeamTypes*/ eTeam) const { return m_pTeam ? m_pTeam->AI_getAtPeaceCounter((TeamTypes)eTeam) : -1; } int CyTeam::AI_getWarSuccess(int /*TeamTypes*/ eIndex) const { return m_pTeam ? m_pTeam->AI_getWarSuccess((TeamTypes)eIndex) : -1; }
[ "jdog5000@31ee56aa-37e8-4f44-8bdf-1f84a3affbab", "fim-fuyu@31ee56aa-37e8-4f44-8bdf-1f84a3affbab" ]
[ [ [ 1, 621 ], [ 633, 970 ], [ 976, 979 ], [ 983, 998 ] ], [ [ 622, 632 ], [ 971, 975 ], [ 980, 982 ] ] ]
baae4ce7cbe1ec5408d223d6c7b6e3669bc150a7
cce8a4b559cf619b9a5c741b47428af43487c8f6
/Kythuat/STL_File/VeSTL.cpp
a581dae022c7fb4635887e7655690962f1606ef5
[]
no_license
dtbinh/mophongrobot
00cfdfc6787d941bdd69d8888c8f6fd9a6e1eca5
4b8cb5f6b7a998a6e13453499e7190a96e965dd9
refs/heads/master
2021-01-10T12:23:33.743554
2011-10-31T04:11:40
2011-10-31T04:11:40
48,972,243
1
0
null
null
null
null
UTF-8
C++
false
false
4,251
cpp
#include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include "STL_File.h" CSTL_File stl; HWND hWnd; HDC hDC; HGLRC hRC; // Set up pixel format for graphics initialization void SetupPixelFormat() { PIXELFORMATDESCRIPTOR pfd, *ppfd; int pixelformat; ppfd = &pfd; ppfd->nSize = sizeof(PIXELFORMATDESCRIPTOR); ppfd->nVersion = 1; ppfd->dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; ppfd->dwLayerMask = PFD_MAIN_PLANE; ppfd->iPixelType = PFD_TYPE_COLORINDEX; ppfd->cColorBits = 16; ppfd->cDepthBits = 16; ppfd->cAccumBits = 0; ppfd->cStencilBits = 0; pixelformat = ChoosePixelFormat(hDC, ppfd); SetPixelFormat(hDC, pixelformat, ppfd); } // Initialize OpenGL graphics void InitGraphics() { hDC = GetDC(hWnd); SetupPixelFormat(); hRC = wglCreateContext(hDC); wglMakeCurrent(hDC, hRC); glClearColor(0, 0, 0, 0.5); glClearDepth(1.0); glEnable(GL_DEPTH_TEST); stl.LoadAscii("sphere.stl"); } // Resize graphics to fit window void ResizeGraphics() { // Get new window size RECT rect; int width, height; GLfloat aspect; GetClientRect(hWnd, &rect); width = rect.right; height = rect.bottom; aspect = (GLfloat)width / height; // Adjust graphics to window size glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-5, 5, -5/aspect, 5/aspect, 0, 100); // gluPerspective(45.0, aspect, 1.0, 100.0); glMatrixMode(GL_MODELVIEW); } // Draw frame void DrawGraphics() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Set location in front of camera glLoadIdentity(); glTranslated(0, 0, -10); glColor3d(0, 1, 0); stl.Draw(false, false); /* // Draw a square glBegin(GL_QUADS); glColor3d(1, 0, 0); glVertex3d(-2, 2, 0); glVertex3d(2, 2, 0); glVertex3d(2, -2, 0); glVertex3d(-2, -2, 0); glEnd(); */ // Show the new scene SwapBuffers(hDC); } // Handle window events and messages LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_SIZE: ResizeGraphics(); break; case WM_CLOSE: DestroyWindow(hWnd); break; case WM_DESTROY: PostQuitMessage(0); break; // Default event handler default: return DefWindowProc (hWnd, uMsg, wParam, lParam); break; } return 1; } int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { const LPCWSTR appname = TEXT("OpenGL Sample"); WNDCLASS wndclass; MSG msg; // Define the window class wndclass.style = 0; wndclass.lpfnWndProc = (WNDPROC)MainWndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon(hInstance, appname); wndclass.hCursor = LoadCursor(NULL,IDC_ARROW); wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wndclass.lpszMenuName = appname; wndclass.lpszClassName = appname; // Register the window class if (!RegisterClass(&wndclass)) return FALSE; // Create the window hWnd = CreateWindow( appname, appname, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, hInstance, NULL); if (!hWnd) return FALSE; // Initialize OpenGL InitGraphics(); // Display the window ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); // Event loop while (1) { if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) == TRUE) { if (!GetMessage(&msg, NULL, 0, 0)) return TRUE; TranslateMessage(&msg); DispatchMessage(&msg); } DrawGraphics(); } wglDeleteContext(hRC); ReleaseDC(hWnd, hDC); }
[ [ [ 1, 186 ] ] ]
1f39c3407b2c6745ad527dc287b6bdaa262db64d
7b379862f58f587d9327db829ae4c6493b745bb1
/JuceLibraryCode/modules/juce_audio_formats/codecs/juce_QuickTimeAudioFormat.cpp
494326a0361462a19e992133faddbb70fd24bf6d
[]
no_license
owenvallis/Nomestate
75e844e8ab68933d481640c12019f0d734c62065
7fe7c06c2893421a3c77b5180e5f27ab61dd0ffd
refs/heads/master
2021-01-19T07:35:14.301832
2011-12-28T07:42:50
2011-12-28T07:42:50
2,950,072
2
0
null
null
null
null
UTF-8
C++
false
false
14,362
cpp
/* ============================================================================== This file is part of the JUCE library - "Jules' Utility Class Extensions" Copyright 2004-11 by Raw Material Software Ltd. ------------------------------------------------------------------------------ JUCE can be redistributed and/or modified under the terms of the GNU General Public License (Version 2), as published by the Free Software Foundation. A copy of the license is included in the JUCE distribution, or can be found online at www.gnu.org/licenses. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are available: visit www.rawmaterialsoftware.com/juce for more information. ============================================================================== */ #if JUCE_QUICKTIME && ! (JUCE_64BIT || JUCE_IOS) END_JUCE_NAMESPACE #if ! JUCE_WINDOWS #define Point CarbonDummyPointName // (workaround to avoid definition of "Point" by old Carbon headers) #define Component CarbonDummyCompName #include <QuickTime/Movies.h> #include <QuickTime/QTML.h> #include <QuickTime/QuickTimeComponents.h> #include <QuickTime/MediaHandlers.h> #include <QuickTime/ImageCodec.h> #undef Point #undef Component #else #if JUCE_MSVC #pragma warning (push) #pragma warning (disable : 4100) #endif /* If you've got an include error here, you probably need to install the QuickTime SDK and add its header directory to your include path. Alternatively, if you don't need any QuickTime services, just set the JUCE_QUICKTIME flag to 0. */ #undef SIZE_MAX #include <Movies.h> #include <QTML.h> #include <QuickTimeComponents.h> #include <MediaHandlers.h> #include <ImageCodec.h> #undef SIZE_MAX #if JUCE_MSVC #pragma warning (pop) #endif #endif BEGIN_JUCE_NAMESPACE bool juce_OpenQuickTimeMovieFromStream (InputStream* input, Movie& movie, Handle& dataHandle); static const char* const quickTimeFormatName = "QuickTime file"; static const char* const quickTimeExtensions[] = { ".mov", ".mp3", ".mp4", ".m4a", 0 }; //============================================================================== class QTAudioReader : public AudioFormatReader { public: QTAudioReader (InputStream* const input_, const int trackNum_) : AudioFormatReader (input_, TRANS (quickTimeFormatName)), ok (false), movie (0), trackNum (trackNum_), lastSampleRead (0), lastThreadId (0), extractor (0), dataHandle (0) { JUCE_AUTORELEASEPOOL bufferList.calloc (256, 1); #if JUCE_WINDOWS if (InitializeQTML (0) != noErr) return; #endif if (EnterMovies() != noErr) return; bool opened = juce_OpenQuickTimeMovieFromStream (input_, movie, dataHandle); if (! opened) return; { const int numTracks = GetMovieTrackCount (movie); int trackCount = 0; for (int i = 1; i <= numTracks; ++i) { track = GetMovieIndTrack (movie, i); media = GetTrackMedia (track); OSType mediaType; GetMediaHandlerDescription (media, &mediaType, 0, 0); if (mediaType == SoundMediaType && trackCount++ == trackNum_) { ok = true; break; } } } if (! ok) return; ok = false; lengthInSamples = GetMediaDecodeDuration (media); usesFloatingPointData = false; samplesPerFrame = (int) (GetMediaDecodeDuration (media) / GetMediaSampleCount (media)); trackUnitsPerFrame = GetMovieTimeScale (movie) * samplesPerFrame / GetMediaTimeScale (media); OSStatus err = MovieAudioExtractionBegin (movie, 0, &extractor); unsigned long output_layout_size; err = MovieAudioExtractionGetPropertyInfo (extractor, kQTPropertyClass_MovieAudioExtraction_Audio, kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout, 0, &output_layout_size, 0); if (err != noErr) return; HeapBlock <AudioChannelLayout> qt_audio_channel_layout; qt_audio_channel_layout.calloc (output_layout_size, 1); err = MovieAudioExtractionGetProperty (extractor, kQTPropertyClass_MovieAudioExtraction_Audio, kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout, output_layout_size, qt_audio_channel_layout, 0); qt_audio_channel_layout[0].mChannelLayoutTag = kAudioChannelLayoutTag_Stereo; err = MovieAudioExtractionSetProperty (extractor, kQTPropertyClass_MovieAudioExtraction_Audio, kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout, output_layout_size, qt_audio_channel_layout); err = MovieAudioExtractionGetProperty (extractor, kQTPropertyClass_MovieAudioExtraction_Audio, kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription, sizeof (inputStreamDesc), &inputStreamDesc, 0); if (err != noErr) return; inputStreamDesc.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked | kAudioFormatFlagsNativeEndian; inputStreamDesc.mBitsPerChannel = sizeof (SInt16) * 8; inputStreamDesc.mChannelsPerFrame = jmin ((UInt32) 2, inputStreamDesc.mChannelsPerFrame); inputStreamDesc.mBytesPerFrame = sizeof (SInt16) * inputStreamDesc.mChannelsPerFrame; inputStreamDesc.mBytesPerPacket = inputStreamDesc.mBytesPerFrame; err = MovieAudioExtractionSetProperty (extractor, kQTPropertyClass_MovieAudioExtraction_Audio, kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription, sizeof (inputStreamDesc), &inputStreamDesc); if (err != noErr) return; Boolean allChannelsDiscrete = false; err = MovieAudioExtractionSetProperty (extractor, kQTPropertyClass_MovieAudioExtraction_Movie, kQTMovieAudioExtractionMoviePropertyID_AllChannelsDiscrete, sizeof (allChannelsDiscrete), &allChannelsDiscrete); if (err != noErr) return; bufferList->mNumberBuffers = 1; bufferList->mBuffers[0].mNumberChannels = inputStreamDesc.mChannelsPerFrame; bufferList->mBuffers[0].mDataByteSize = jmax ((UInt32) 4096, (UInt32) (samplesPerFrame * inputStreamDesc.mBytesPerFrame) + 16); dataBuffer.malloc (bufferList->mBuffers[0].mDataByteSize); bufferList->mBuffers[0].mData = dataBuffer; sampleRate = inputStreamDesc.mSampleRate; bitsPerSample = 16; numChannels = inputStreamDesc.mChannelsPerFrame; detachThread(); ok = true; } ~QTAudioReader() { JUCE_AUTORELEASEPOOL checkThreadIsAttached(); if (dataHandle != nullptr) DisposeHandle (dataHandle); if (extractor != nullptr) { MovieAudioExtractionEnd (extractor); extractor = nullptr; } DisposeMovie (movie); #if JUCE_MAC ExitMoviesOnThread (); #endif } bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer, int64 startSampleInFile, int numSamples) { JUCE_AUTORELEASEPOOL checkThreadIsAttached(); bool ok = true; while (numSamples > 0) { if (lastSampleRead != startSampleInFile) { TimeRecord time; time.scale = (TimeScale) inputStreamDesc.mSampleRate; time.base = 0; time.value.hi = 0; time.value.lo = (UInt32) startSampleInFile; OSStatus err = MovieAudioExtractionSetProperty (extractor, kQTPropertyClass_MovieAudioExtraction_Movie, kQTMovieAudioExtractionMoviePropertyID_CurrentTime, sizeof (time), &time); if (err != noErr) { ok = false; break; } } int framesToDo = jmin (numSamples, (int) (bufferList->mBuffers[0].mDataByteSize / inputStreamDesc.mBytesPerFrame)); bufferList->mBuffers[0].mDataByteSize = inputStreamDesc.mBytesPerFrame * framesToDo; UInt32 outFlags = 0; UInt32 actualNumFrames = framesToDo; OSStatus err = MovieAudioExtractionFillBuffer (extractor, &actualNumFrames, bufferList, &outFlags); if (err != noErr) { ok = false; break; } lastSampleRead = startSampleInFile + actualNumFrames; const int samplesReceived = actualNumFrames; for (int j = numDestChannels; --j >= 0;) { if (destSamples[j] != nullptr) { const short* src = ((const short*) bufferList->mBuffers[0].mData) + j; for (int i = 0; i < samplesReceived; ++i) { destSamples[j][startOffsetInDestBuffer + i] = (*src << 16); src += numChannels; } } } startOffsetInDestBuffer += samplesReceived; startSampleInFile += samplesReceived; numSamples -= samplesReceived; if (((outFlags & kQTMovieAudioExtractionComplete) != 0 || samplesReceived == 0) && numSamples > 0) { for (int j = numDestChannels; --j >= 0;) if (destSamples[j] != nullptr) zeromem (destSamples[j] + startOffsetInDestBuffer, sizeof (int) * numSamples); break; } } detachThread(); return ok; } bool ok; private: Movie movie; Media media; Track track; const int trackNum; double trackUnitsPerFrame; int samplesPerFrame; int64 lastSampleRead; Thread::ThreadID lastThreadId; MovieAudioExtractionRef extractor; AudioStreamBasicDescription inputStreamDesc; HeapBlock <AudioBufferList> bufferList; HeapBlock <char> dataBuffer; Handle dataHandle; //============================================================================== void checkThreadIsAttached() { #if JUCE_MAC if (Thread::getCurrentThreadId() != lastThreadId) EnterMoviesOnThread (0); AttachMovieToCurrentThread (movie); #endif } void detachThread() { #if JUCE_MAC DetachMovieFromCurrentThread (movie); #endif } JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (QTAudioReader); }; //============================================================================== QuickTimeAudioFormat::QuickTimeAudioFormat() : AudioFormat (TRANS (quickTimeFormatName), StringArray (quickTimeExtensions)) { } QuickTimeAudioFormat::~QuickTimeAudioFormat() { } Array<int> QuickTimeAudioFormat::getPossibleSampleRates() { return Array<int>(); } Array<int> QuickTimeAudioFormat::getPossibleBitDepths() { return Array<int>(); } bool QuickTimeAudioFormat::canDoStereo() { return true; } bool QuickTimeAudioFormat::canDoMono() { return true; } //============================================================================== AudioFormatReader* QuickTimeAudioFormat::createReaderFor (InputStream* sourceStream, const bool deleteStreamIfOpeningFails) { ScopedPointer <QTAudioReader> r (new QTAudioReader (sourceStream, 0)); if (r->ok) return r.release(); if (! deleteStreamIfOpeningFails) r->input = 0; return nullptr; } AudioFormatWriter* QuickTimeAudioFormat::createWriterFor (OutputStream* /*streamToWriteTo*/, double /*sampleRateToUse*/, unsigned int /*numberOfChannels*/, int /*bitsPerSample*/, const StringPairArray& /*metadataValues*/, int /*qualityOptionIndex*/) { jassertfalse; // not yet implemented! return nullptr; } #endif
[ "ow3nskip" ]
[ [ [ 1, 387 ] ] ]
c2223fe0492b2c287f998065d1f8542b7e2956ab
b2d46af9c6152323ce240374afc998c1574db71f
/cursovideojuegos/theflostiproject/Code/Tools/Tests/PhysXTestProcess.h
9780cb890bf044b6d21caae71830a65497832d69
[]
no_license
bugbit/cipsaoscar
601b4da0f0a647e71717ed35ee5c2f2d63c8a0f4
52aa8b4b67d48f59e46cb43527480f8b3552e96d
refs/heads/master
2021-01-10T21:31:18.653163
2011-09-28T16:39:12
2011-09-28T16:39:12
33,032,640
0
0
null
null
null
null
UTF-8
C++
false
false
5,250
h
//---------------------------------------------------------------------------------- // CPhysXTestProcess class // Author: Enric Vergara // // Description: // Test para probar el funcionamiento del modulo de fisicas. //---------------------------------------------------------------------------------- #pragma once #ifndef INC_PHYSX_TEST_PROCESS_H_ #define INC_PHYSX_TEST_PROCESS_H_ //---Engine Includes---- #include "Core/Core.h" #include "Core/Process.h" #include "PhysX/PhysicTriggerReport.h" #include "PhysX/PhysicsManager.h" //----------------------- //--Forward Declaration-- class CRenderManager; class CObject3D; class CPhysicActor; class CInputManager; //----------------------- //---Declaracion de nuevos tipos---- class CGameEntity:public CPhysicUserData { public: CGameEntity(): m_sName("Default"){} ~CGameEntity(){/*Nothing*/} const std::string& GetName() const {return m_sName;} void SetName(const std::string& name) {m_sName = name;} private: std::string m_sName; }; enum CollisioneGroup { GROUP_BASIC_PRIMITIVES, GROUP_GRENADES, }; #define IMPACT_MASK_1 (1<<GROUP_BASIC_PRIMITIVES) #define IMPACT_MASK_2 (1<<GROUP_BASIC_PRIMITIVES | 1<< GROUP_GRENADES) #define COLLIDABLE_MASK (1<<GROUP_BASIC_PRIMITIVES | 1<< GROUP_GRENADES) //---------------------------------- class CPhysXTestProcess: public CProcess, public CPhysicTriggerReport { public: //---Init and End protocols CPhysXTestProcess(const std::string& processName); virtual ~CPhysXTestProcess(void) {Done();} //----CScriptRegister Interface--------------------------------------- virtual void RegisterFunctions (CScriptManager* scriptManager); //----CProcess Interface--------------------------------------- virtual bool Init (); virtual bool Start () {m_bStart = true; return true;} //----CPhysicTriggerReport Interface------------------------------------------------------ virtual void OnEnter (CPhysicUserData* trigger1, CPhysicUserData* trigger2); virtual void OnLeave (CPhysicUserData* trigger1, CPhysicUserData* trigger2); //---CFPSGameProcess Interface virtual void Update (float elapsedTime); virtual void RenderScene (CRenderManager* renderManager, CFontManager* fm); virtual uint32 RenderDebugInfo (CRenderManager* renderManager, CFontManager* fm, float fps); virtual CCamera* GetCamera () const {return m_pCurrentCamera;} //-------------------------------------------------------------- private: //----CProcess Interface------------------- virtual void Release (); //---CFPSGameProcess Interface---------------- void UpdateInputActions (CInputManager* inputManager, float elapsedTime); void UpdateMaxCamera (CInputManager* inputManager, float elapsedTime); void UpdateInputPlayer (CInputManager* inputManager, float elapsedTime); private: CCamera* m_pCurrentCamera; CCamera* m_pPlayerCamera; CObject3D* m_pObject3D; CGameEntity* m_pLastPickedObject; std::string m_sNameImpactObject; std::string m_sNameTrigger1; std::string m_sNameTrigger2; CPhysicSphericalJoint* m_pPhysicSphericalJoint_Light1; CPhysicActor* m_pPhysicActor_BoxLight1; CGameEntity* m_pGameEntity_BoxLight1; CPhysicSphericalJoint* m_pPhysicSphericalJoint_Light20; CPhysicSphericalJoint* m_pPhysicSphericalJoint_Light21; CPhysicSphericalJoint* m_pPhysicSphericalJoint_Light22; CPhysicActor* m_pPhysicActor_BoxLight20; CPhysicActor* m_pPhysicActor_BoxLight21; CPhysicActor* m_pPhysicActor_BoxLight22; CGameEntity* m_pGameEntity_BoxLight2; CPhysicActor* m_pPhysicActor_Box; CGameEntity* m_pGameEntity_Box; CPhysicActor* m_pPhysicActor_Trigger; CGameEntity* m_pGameEntity_Trigger; CPhysicActor* m_pPhysicActor_Sphere; CGameEntity* m_pGameEntity_Sphere; CPhysicActor* m_pPhysicActor_Capsule; CGameEntity* m_pGameEntity_Capsule; CPhysicActor* m_pPhysicActor_Plane; CGameEntity* m_pGameEntity_Plane; CPhysicActor* m_pPhysicActor_Mesh; CGameEntity* m_pGameEntity_Mesh; CPhysicActor* m_pPhysicActor_Mesh_2; CGameEntity* m_pGameEntity_Mesh_2; CPhysicActor* m_pPhysicActor_Composite; CGameEntity* m_pGameEntity_Composite; CPhysicRevoluteJoint* m_pPhysicRevolute_Bridge; CGameEntity* m_pGameEntity_BoxBridge; CPhysicActor* m_pPhysicActor_BoxBridge; CPhysicActor* m_pPhysicActor_BoxPath; CPhysicController* m_pPhysicController1; CGameEntity* m_pGameEntity_Controller1; CPhysicController* m_pPhysicController2; CGameEntity* m_pGameEntity_Controller2; std::vector< std::pair<CPhysicActor*,CGameEntity*> > m_vPhysicActor_Grenades; std::vector< std::pair<CPhysicActor*,CGameEntity*> > m_vPhysicActor_CCDGrenades; }; static CPhysXTestProcess* GetPhysXTest() {return static_cast<CPhysXTestProcess*>(CORE->GetProcess());} #endif //INC_PHYSX_TEST_PROCESS_H_
[ "ohernandezba@71d53fa2-cca5-e1f2-4b5e-677cbd06613a" ]
[ [ [ 1, 154 ] ] ]
78ef186ac9a798522c358d9218a081a3888ade66
74c8da5b29163992a08a376c7819785998afb588
/NetAnimal/Game/wheel/MyWheelController/src/KeyEngineDecorator.cpp
8d2b2919a883d8bf44646d3fe79711a0a2a9ef63
[]
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,623
cpp
#include "MyWheelControllerStableHeaders.h" #include "KeyEngineDecorator.h" #include "WheelEnum.h" #include "WheelEvents.h" #include "WinData.h" using namespace Orz; KeyEngineDecorator::KeyEngineDecorator(WheelEngineInterfacePtr engine):_engine(engine) { //Orz::IInputManager::getSingleton().addKeyListener(this); } KeyEngineDecorator::~KeyEngineDecorator(void) { //Orz::IInputManager::getSingleton().removeKeyListener(this); } bool KeyEngineDecorator::onKeyPressed(const KeyEvent & evt) { switch(evt.getKey()) { case Orz::KC_A: { startGame(14); } break; case Orz::KC_B: { WinData::getInstance().setWinMode(WheelEnum::NONE); WinData::getInstance().setBonus(false, 1000, 0,0 ); WinData::getInstance().setWinner(WheelEnum::Player); WinData::getInstance().clear(); WinData::getInstance().push_back(WheelEnum::AnimalItem(WheelEnum::TYPE0, WheelEnum::Yellow), 20); runGame(); } break; // //case Orz::KC_7: // { // pushRate(); // } // break; default: return false; } return false; } bool KeyEngineDecorator::onKeyReleased(const KeyEvent & evt) { return true; } void KeyEngineDecorator::startGame(size_t time) { _engine->startGame(time); } //void KeyEngineDecorator::pushRate(void) //{ // _engine->pushRate(); //} void KeyEngineDecorator::runGame(void) { _engine->runGame(); } //void KeyEngineDecorator::clickButton(int id, int button) //{ // _engine->clickButton(id, button); //} TimeType KeyEngineDecorator::getTime(void) const { return _engine->getTime(); }
[ [ [ 1, 86 ] ] ]
7fc8733b829484a70c70512b48362e21ea6011a0
11af1673bab82ca2329ef8b596d1f3d2f8b82481
/source/game/g_combat.cpp
a4d8cc03cf7baa716bbfbad5fa94b88fbfdd7b48
[]
no_license
legacyrp/legacyojp
8b33ecf24fd973bee5e7adbd369748cfdd891202
d918151e917ea06e8698f423bbe2cf6ab9d7f180
refs/heads/master
2021-01-10T20:09:55.748893
2011-04-18T21:07:13
2011-04-18T21:07:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
185,273
cpp
// Copyright (C) 1999-2000 Id Software, Inc. // // g_combat.c //#include "g_local.h" #include "b_local.h" #include "bg_saga.h" //[DynamicMusic] //needed to set the death music for the DMS #include "g_dynmusic.h" //[/DynamicMusic] extern int G_ShipSurfaceForSurfName( const char *surfaceName ); extern qboolean G_FlyVehicleDestroySurface( gentity_t *veh, int surface ); extern void G_VehicleSetDamageLocFlags( gentity_t *veh, int impactDir, int deathPoint ); extern void G_VehUpdateShields( gentity_t *targ ); extern void G_LetGoOfWall( gentity_t *ent ); extern void BG_ClearRocketLock( playerState_t *ps ); //[AdminSys] extern void G_CheckTKAutoKickBan( gentity_t *ent ); //[/AdminSys] //rww - pd void BotDamageNotification(gclient_t *bot, gentity_t *attacker); //end rww void ThrowSaberToAttacker(gentity_t *self, gentity_t *attacker); //[CoOp] extern void SP_item_security_key(gentity_t *self); void G_DropKey( gentity_t *self ) {//drop whatever security key I was holding gentity_t *dropped = G_Spawn(); G_SetOrigin(dropped, self->client->ps.origin); //set up the ent SP_item_security_key(self); //Don't throw the key VectorClear( dropped->s.pos.trDelta ); dropped->message = self->message; self->message = NULL; } //[/CoOp] void ObjectDie (gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath ) { if(self->target) { G_UseTargets(self, attacker); } //remove my script_targetname G_FreeEntity( self ); } qboolean G_HeavyMelee( gentity_t *attacker ) { if (g_gametype.integer == GT_SIEGE && attacker && attacker->client && attacker->client->siegeClass != -1 && (bgSiegeClasses[attacker->client->siegeClass].classflags & (1<<CFL_HEAVYMELEE)) ) { return qtrue; } return qfalse; } int G_GetHitLocation(gentity_t *target, vec3_t ppoint) { vec3_t point, point_dir; vec3_t forward, right, up; vec3_t tangles, tcenter; float tradius; float udot, fdot, rdot; int Vertical, Forward, Lateral; int HitLoc; // Get target forward, right and up. if(target->client) { // Ignore player's pitch and roll. VectorSet(tangles, 0, target->r.currentAngles[YAW], 0); } AngleVectors(tangles, forward, right, up); // Get center of target. VectorAdd(target->r.absmin, target->r.absmax, tcenter); VectorScale(tcenter, 0.5, tcenter); // Get radius width of target. tradius = (fabs(target->r.maxs[0]) + fabs(target->r.maxs[1]) + fabs(target->r.mins[0]) + fabs(target->r.mins[1]))/4; // Get impact point. if(ppoint && !VectorCompare(ppoint, vec3_origin)) { VectorCopy(ppoint, point); } else { return HL_NONE; } VectorSubtract(point, tcenter, point_dir); VectorNormalize(point_dir); // Get bottom to top (vertical) position index udot = DotProduct(up, point_dir); if(udot>.800) { Vertical = 4; } else if(udot>.400) { Vertical = 3; } else if(udot>-.333) { Vertical = 2; } else if(udot>-.666) { Vertical = 1; } else { Vertical = 0; } // Get back to front (forward) position index. fdot = DotProduct(forward, point_dir); if(fdot>.666) { Forward = 4; } else if(fdot>.333) { Forward = 3; } else if(fdot>-.333) { Forward = 2; } else if(fdot>-.666) { Forward = 1; } else { Forward = 0; } // Get left to right (lateral) position index. rdot = DotProduct(right, point_dir); if(rdot>.666) { Lateral = 4; } else if(rdot>.333) { Lateral = 3; } else if(rdot>-.333) { Lateral = 2; } else if(rdot>-.666) { Lateral = 1; } else { Lateral = 0; } HitLoc = Vertical * 25 + Forward * 5 + Lateral; if(HitLoc <= 10) { // Feet. if ( rdot > 0 ) { return HL_FOOT_RT; } else { return HL_FOOT_LT; } } else if(HitLoc <= 50) { // Legs. if ( rdot > 0 ) { return HL_LEG_RT; } else { return HL_LEG_LT; } } else if(HitLoc == 56||HitLoc == 60||HitLoc == 61||HitLoc == 65||HitLoc == 66||HitLoc == 70) { // Hands. if ( rdot > 0 ) { return HL_HAND_RT; } else { return HL_HAND_LT; } } else if(HitLoc == 83||HitLoc == 87||HitLoc == 88||HitLoc == 92||HitLoc == 93||HitLoc == 97) { // Arms. if ( rdot > 0 ) { return HL_ARM_RT; } else { return HL_ARM_LT; } } else if((HitLoc >= 107 && HitLoc <= 109)||(HitLoc >= 112 && HitLoc <= 114)||(HitLoc >= 117 && HitLoc <= 119)) { // Head. return HL_HEAD; } else { if(udot < 0.3) { return HL_WAIST; } else if(fdot < 0) { if(rdot > 0.4) { return HL_BACK_RT; } else if(rdot < -0.4) { return HL_BACK_LT; } else if(fdot < 0) { return HL_BACK; } } else { if(rdot > 0.3) { return HL_CHEST_RT; } else if(rdot < -0.3) { return HL_CHEST_LT; } else if(fdot < 0) { return HL_CHEST; } } } return HL_NONE; } void ExplodeDeath( gentity_t *self ) { // gentity_t *tent; vec3_t forward; self->takedamage = qfalse;//stop chain reaction runaway loops self->s.loopSound = 0; self->s.loopIsSoundset = qfalse; VectorCopy( self->r.currentOrigin, self->s.pos.trBase ); AngleVectors(self->s.angles, forward, NULL, NULL); if(self->splashDamage > 0 && self->splashRadius > 0) { gentity_t *attacker = self; if ( self->parent ) { attacker = self->parent; } G_RadiusDamage( self->r.currentOrigin, attacker, self->splashDamage, self->splashRadius, attacker, NULL, MOD_UNKNOWN ); } ObjectDie( self, self, self, 20, 0 ); } /* ============ ScorePlum ============ */ void ScorePlum( gentity_t *ent, vec3_t origin, int score ) { gentity_t *plum; plum = G_TempEntity( origin, EV_SCOREPLUM ); // only send this temp entity to a single client plum->r.svFlags |= SVF_SINGLECLIENT; plum->r.singleClient = ent->s.number; // plum->s.otherEntityNum = ent->s.number; plum->s.time = score; } /* ============ AddScore Adds score to both the client and his team ============ */ extern qboolean g_dontPenalizeTeam; //g_cmds.c void AddScore( gentity_t *ent, vec3_t origin, int score ) { if ( !ent->client ) { return; } // no scoring during pre-match warmup if ( level.warmupTime ) { return; } ent->client->ps.persistant[PERS_SCORE] += score; if ( g_gametype.integer == GT_TEAM && !g_dontPenalizeTeam ) level.teamScores[ ent->client->ps.persistant[PERS_TEAM] ] += score; CalculateRanks(); } /* ================= TossClientItems rww - Toss the weapon away from the player in the specified direction ================= */ void TossClientWeapon(gentity_t *self, vec3_t direction, float speed) { vec3_t vel; gitem_t *item; gentity_t *launched; int weapon = self->s.weapon; int ammoSub; if (g_gametype.integer == GT_SIEGE) { //no dropping weaps return; } if (weapon <= WP_BRYAR_PISTOL) { //can't have this return; } if (weapon == WP_EMPLACED_GUN || weapon == WP_TURRET) { return; } // find the item type for this weapon item = BG_FindItemForWeapon( weapon ); ammoSub = (self->client->ps.ammo[weaponData[weapon].ammoIndex] - bg_itemlist[BG_GetItemIndexByTag(weapon, IT_WEAPON)].quantity); if (ammoSub < 0) { int ammoQuan = item->quantity; ammoQuan -= (-ammoSub); if (ammoQuan <= 0) { //no ammo return; } } vel[0] = direction[0]*speed; vel[1] = direction[1]*speed; vel[2] = direction[2]*speed; launched = LaunchItem(item, self->client->ps.origin, vel); launched->s.generic1 = self->s.number; launched->s.powerups = level.time + 1500; //[WeaponSys] launched->count = self->client->ps.ammo[weaponData[weapon].ammoIndex]; self->client->ps.ammo[weaponData[weapon].ammoIndex] = 0; //[/WeaponSys] if ((self->client->ps.ammo[weaponData[weapon].ammoIndex] < 1 && weapon != WP_DET_PACK) || (weapon != WP_THERMAL && weapon != WP_DET_PACK && weapon != WP_GRENADE)) { int i = 0; int weap = -1; self->client->ps.stats[STAT_WEAPONS] &= ~(1 << weapon); while (i < WP_NUM_WEAPONS) { if ((self->client->ps.stats[STAT_WEAPONS] & (1 << i)) && i != WP_NONE) { //this one's good weap = i; break; } i++; } if (weap != -1) { self->s.weapon = weap; self->client->ps.weapon = weap; } else { self->s.weapon = 0; self->client->ps.weapon = 0; } G_AddEvent(self, EV_NOAMMO, weapon); } } /* ================= TossClientItems Toss the weapon and powerups for the killed player ================= */ //[CoOp] extern gitem_t *BG_FindItemForAmmo( ammo_t ammo ); extern gentity_t *WP_DropThermal( gentity_t *ent ); //[/CoOp] void TossClientItems( gentity_t *self ) { gitem_t *item; int weapon; float angle; int i; gentity_t *drop; //[CoOp] gentity_t *dropped = NULL; //[/CoOp] if (g_gametype.integer == GT_SIEGE) { //just don't drop anything then return; } //[CoOp] if ( self->client->NPC_class == CLASS_SEEKER || self->client->NPC_class == CLASS_REMOTE || self->client->NPC_class == CLASS_SABER_DROID || self->client->NPC_class == CLASS_VEHICLE || self->client->NPC_class == CLASS_ATST) {//these NPCs don't drop items. // these things are so small that they shouldn't bother throwing anything return; } //[/CoOp] // drop the weapon if not a gauntlet or machinegun weapon = self->s.weapon; // make a special check to see if they are changing to a new // weapon that isn't the mg or gauntlet. Without this, a client // can pick up a weapon, be killed, and not drop the weapon because // their weapon change hasn't completed yet and they are still holding the MG. if ( weapon == WP_BRYAR_PISTOL) { if ( self->client->ps.weaponstate == WEAPON_DROPPING ) { weapon = self->client->pers.cmd.weapon; } if ( !( self->client->ps.stats[STAT_WEAPONS] & ( 1 << weapon ) ) ) { weapon = WP_NONE; } } //racc - this sets the weapon that the player body will use. self->s.bolt2 = weapon; //[CoOp] if ( weapon > WP_SABER && weapon <= MAX_PLAYER_WEAPONS && weapon != WP_BRYAR_PISTOL && weapon != WP_MELEE )//&& self->client->ps.ammo[ weaponData[weapon].ammoIndex ] { self->s.weapon = WP_NONE; if ( weapon == WP_THERMAL && self->client->ps.torsoAnim == BOTH_ATTACK10 ) {//we were getting ready to throw the thermal, drop it! self->client->ps.weaponChargeTime = level.time - FRAMETIME;//so it just kind of drops it dropped = WP_DropThermal( self ); item = NULL; } else {// find the item type for this weapon item = BG_FindItemForWeapon( (weapon_t) weapon ); } if ( item && !dropped ) {//we have a weapon and we haven't already dropped it. gentity_t *te; //temp entity used to tell the clients to remove the body's // spawn the item dropped = Drop_Item( self, item, 0 ); //TEST: dropped items never go away dropped->think = NULL; dropped->nextthink = -1; //[WeaponSys] //give it ammo based on how much ammo the entity had dropped->count = self->client->ps.ammo[weaponData[item->giTag].ammoIndex]; self->client->ps.ammo[weaponData[item->giTag].ammoIndex] = 0; //[/WeaponSys] //MP version // tell all clients to remove the weapon model on this guy until he respawns te = G_TempEntity( vec3_origin, EV_DESTROY_WEAPON_MODEL ); te->r.svFlags |= SVF_BROADCAST; te->s.eventParm = self->s.number; } } else if ( self->client->NPC_class == CLASS_MARK1 ) { if (Q_irand( 1, 2 )>1) { item = BG_FindItemForAmmo( AMMO_METAL_BOLTS ); } else { item = BG_FindItemForAmmo( AMMO_BLASTER ); } Drop_Item( self, item, 0 ); } else if ( self->client->NPC_class == CLASS_MARK2 ) { if (Q_irand( 1, 2 )>1) { item = BG_FindItemForAmmo( AMMO_METAL_BOLTS ); } else { item = BG_FindItemForAmmo( AMMO_POWERCELL ); } Drop_Item( self, item, 0 ); } //[/CoOp] // drop all the powerups if not in teamplay if ( g_gametype.integer != GT_TEAM && g_gametype.integer != GT_SIEGE ) { angle = 45; for ( i = 1 ; i < PW_NUM_POWERUPS ; i++ ) { if ( self->client->ps.powerups[ i ] > level.time ) { item = BG_FindItemForPowerup( i ); if ( !item ) { continue; } drop = Drop_Item( self, item, angle ); // decide how many seconds it has left drop->count = ( self->client->ps.powerups[ i ] - level.time ) / 1000; if ( drop->count < 1 ) { drop->count = 1; } angle += 45; } } } } /* ================== LookAtKiller ================== */ void LookAtKiller( gentity_t *self, gentity_t *inflictor, gentity_t *attacker ) { vec3_t dir; vec3_t angles; if ( attacker && attacker != self ) { VectorSubtract (attacker->s.pos.trBase, self->s.pos.trBase, dir); } else if ( inflictor && inflictor != self ) { VectorSubtract (inflictor->s.pos.trBase, self->s.pos.trBase, dir); } else { self->client->ps.stats[STAT_DEAD_YAW] = self->s.angles[YAW]; return; } self->client->ps.stats[STAT_DEAD_YAW] = vectoyaw ( dir ); angles[YAW] = vectoyaw ( dir ); angles[PITCH] = 0; angles[ROLL] = 0; } /* ================== GibEntity ================== */ void GibEntity( gentity_t *self, int killer ) { G_AddEvent( self, EV_GIB_PLAYER, killer ); self->takedamage = qfalse; self->s.eType = ET_INVISIBLE; self->r.contents = 0; } void BodyRid(gentity_t *ent) { trap_UnlinkEntity( ent ); ent->physicsObject = qfalse; } /* ================== body_die ================== */ void body_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath ) { // NOTENOTE No gibbing right now, this is star wars. qboolean doDisint = qfalse; if (self->s.eType == ET_NPC) { //well, just rem it then, so long as it's done with its death anim and it's not a standard weapon. if ( self->client && self->client->ps.torsoTimer <= 0 && (meansOfDeath == MOD_UNKNOWN || meansOfDeath == MOD_WATER || meansOfDeath == MOD_SLIME || meansOfDeath == MOD_LAVA || meansOfDeath == MOD_CRUSH || meansOfDeath == MOD_TELEFRAG || meansOfDeath == MOD_FALLING || meansOfDeath == MOD_SUICIDE || meansOfDeath == MOD_TARGET_LASER || meansOfDeath == MOD_TRIGGER_HURT) ) { self->think = G_FreeEntity; self->nextthink = level.time; } return; } if (self->health < (GIB_HEALTH+1)) { self->health = GIB_HEALTH+1; if (self->client && (level.time - self->client->respawnTime) < 2000) { doDisint = qfalse; } else { doDisint = qtrue; } } if (self->client && (self->client->ps.eFlags & EF_DISINTEGRATION)) { return; } else if (self->s.eFlags & EF_DISINTEGRATION) { return; } if (doDisint) { if (self->client) { self->client->ps.eFlags |= EF_DISINTEGRATION; VectorCopy(self->client->ps.origin, self->client->ps.lastHitLoc); } else { self->s.eFlags |= EF_DISINTEGRATION; VectorCopy(self->r.currentOrigin, self->s.origin2); //since it's the corpse entity, tell it to "remove" itself self->think = BodyRid; self->nextthink = level.time + 1000; } return; } } // these are just for logging, the client prints its own messages char *modNames[MOD_MAX] = { "MOD_UNKNOWN", "MOD_STUN_BATON", "MOD_MELEE", "MOD_SABER", "MOD_BRYAR_PISTOL", "MOD_BRYAR_PISTOL_ALT", "MOD_BLASTER", "MOD_TURBLAST", "MOD_DISRUPTOR", "MOD_DISRUPTOR_SPLASH", "MOD_DISRUPTOR_SNIPER", "MOD_BOWCASTER", "MOD_REPEATER", "MOD_REPEATER_ALT", "MOD_REPEATER_ALT_SPLASH", "MOD_DEMP2", "MOD_DEMP2_ALT", "MOD_FLECHETTE", "MOD_FLECHETTE_ALT_SPLASH", "MOD_ROCKET", "MOD_ROCKET_SPLASH", "MOD_ROCKET_HOMING", "MOD_ROCKET_HOMING_SPLASH", "MOD_THERMAL", "MOD_THERMAL_SPLASH", "MOD_TRIP_MINE_SPLASH", "MOD_TIMED_MINE_SPLASH", "MOD_DET_PACK_SPLASH", "MOD_VEHICLE", "MOD_CONC", "MOD_CONC_ALT", "MOD_FORCE_DARK", "MOD_SENTRY", "MOD_WATER", "MOD_SLIME", "MOD_LAVA", "MOD_CRUSH", "MOD_TELEFRAG", "MOD_FALLING", "MOD_SUICIDE", "MOD_TARGET_LASER", "MOD_TRIGGER_HURT" }; qboolean G_InKnockDown( playerState_t *ps ) { switch ( (ps->legsAnim) ) { case BOTH_KNOCKDOWN1: case BOTH_KNOCKDOWN2: case BOTH_KNOCKDOWN3: case BOTH_KNOCKDOWN4: case BOTH_KNOCKDOWN5: return qtrue; break; case BOTH_GETUP1: case BOTH_GETUP2: case BOTH_GETUP3: case BOTH_GETUP4: case BOTH_GETUP5: case BOTH_FORCE_GETUP_F1: case BOTH_FORCE_GETUP_F2: case BOTH_FORCE_GETUP_B1: case BOTH_FORCE_GETUP_B2: case BOTH_FORCE_GETUP_B3: case BOTH_FORCE_GETUP_B4: case BOTH_FORCE_GETUP_B5: return qtrue; break; } return qfalse; } static int G_CheckSpecialDeathAnim( gentity_t *self, vec3_t point, int damage, int mod, int hitLoc ) { int deathAnim = -1; if ( BG_InRoll( &self->client->ps, self->client->ps.legsAnim ) ) { deathAnim = BOTH_DEATH_ROLL; //# Death anim from a roll } else if ( BG_FlippingAnim( self->client->ps.legsAnim ) ) { deathAnim = BOTH_DEATH_FLIP; //# Death anim from a flip } else if ( G_InKnockDown( &self->client->ps ) ) {//since these happen a lot, let's handle them case by case int animLength = bgAllAnims[self->localAnimIndex].anims[self->client->ps.legsAnim].numFrames * fabs((float)(bgHumanoidAnimations[self->client->ps.legsAnim].frameLerp)); switch ( self->client->ps.legsAnim ) { case BOTH_KNOCKDOWN1: if ( animLength - self->client->ps.legsTimer > 100 ) {//on our way down if ( self->client->ps.legsTimer > 600 ) {//still partially up deathAnim = BOTH_DEATH_FALLING_UP; } else {//down deathAnim = BOTH_DEATH_LYING_UP; } } break; case BOTH_KNOCKDOWN2: if ( animLength - self->client->ps.legsTimer > 700 ) {//on our way down if ( self->client->ps.legsTimer > 600 ) {//still partially up deathAnim = BOTH_DEATH_FALLING_UP; } else {//down deathAnim = BOTH_DEATH_LYING_UP; } } break; case BOTH_KNOCKDOWN3: if ( animLength - self->client->ps.legsTimer > 100 ) {//on our way down if ( self->client->ps.legsTimer > 1300 ) {//still partially up deathAnim = BOTH_DEATH_FALLING_DN; } else {//down deathAnim = BOTH_DEATH_LYING_DN; } } break; case BOTH_KNOCKDOWN4: if ( animLength - self->client->ps.legsTimer > 300 ) {//on our way down if ( self->client->ps.legsTimer > 350 ) {//still partially up deathAnim = BOTH_DEATH_FALLING_UP; } else {//down deathAnim = BOTH_DEATH_LYING_UP; } } else {//crouch death vec3_t fwd; float thrown = 0; AngleVectors( self->client->ps.viewangles, fwd, NULL, NULL ); thrown = DotProduct( fwd, self->client->ps.velocity ); if ( thrown < -150 ) { deathAnim = BOTH_DEATHBACKWARD1; //# Death anim when crouched and thrown back } else { deathAnim = BOTH_DEATH_CROUCHED; //# Death anim when crouched } } break; case BOTH_KNOCKDOWN5: if ( self->client->ps.legsTimer < 750 ) {//flat deathAnim = BOTH_DEATH_LYING_DN; } break; case BOTH_GETUP1: if ( self->client->ps.legsTimer < 350 ) {//standing up } else if ( self->client->ps.legsTimer < 800 ) {//crouching vec3_t fwd; float thrown = 0; AngleVectors( self->client->ps.viewangles, fwd, NULL, NULL ); thrown = DotProduct( fwd, self->client->ps.velocity ); if ( thrown < -150 ) { deathAnim = BOTH_DEATHBACKWARD1; //# Death anim when crouched and thrown back } else { deathAnim = BOTH_DEATH_CROUCHED; //# Death anim when crouched } } else {//lying down if ( animLength - self->client->ps.legsTimer > 450 ) {//partially up deathAnim = BOTH_DEATH_FALLING_UP; } else {//down deathAnim = BOTH_DEATH_LYING_UP; } } break; case BOTH_GETUP2: if ( self->client->ps.legsTimer < 150 ) {//standing up } else if ( self->client->ps.legsTimer < 850 ) {//crouching vec3_t fwd; float thrown = 0; AngleVectors( self->client->ps.viewangles, fwd, NULL, NULL ); thrown = DotProduct( fwd, self->client->ps.velocity ); if ( thrown < -150 ) { deathAnim = BOTH_DEATHBACKWARD1; //# Death anim when crouched and thrown back } else { deathAnim = BOTH_DEATH_CROUCHED; //# Death anim when crouched } } else {//lying down if ( animLength - self->client->ps.legsTimer > 500 ) {//partially up deathAnim = BOTH_DEATH_FALLING_UP; } else {//down deathAnim = BOTH_DEATH_LYING_UP; } } break; case BOTH_GETUP3: if ( self->client->ps.legsTimer < 250 ) {//standing up } else if ( self->client->ps.legsTimer < 600 ) {//crouching vec3_t fwd; float thrown = 0; AngleVectors( self->client->ps.viewangles, fwd, NULL, NULL ); thrown = DotProduct( fwd, self->client->ps.velocity ); if ( thrown < -150 ) { deathAnim = BOTH_DEATHBACKWARD1; //# Death anim when crouched and thrown back } else { deathAnim = BOTH_DEATH_CROUCHED; //# Death anim when crouched } } else {//lying down if ( animLength - self->client->ps.legsTimer > 150 ) {//partially up deathAnim = BOTH_DEATH_FALLING_DN; } else {//down deathAnim = BOTH_DEATH_LYING_DN; } } break; case BOTH_GETUP4: if ( self->client->ps.legsTimer < 250 ) {//standing up } else if ( self->client->ps.legsTimer < 600 ) {//crouching vec3_t fwd; float thrown = 0; AngleVectors( self->client->ps.viewangles, fwd, NULL, NULL ); thrown = DotProduct( fwd, self->client->ps.velocity ); if ( thrown < -150 ) { deathAnim = BOTH_DEATHBACKWARD1; //# Death anim when crouched and thrown back } else { deathAnim = BOTH_DEATH_CROUCHED; //# Death anim when crouched } } else {//lying down if ( animLength - self->client->ps.legsTimer > 850 ) {//partially up deathAnim = BOTH_DEATH_FALLING_DN; } else {//down deathAnim = BOTH_DEATH_LYING_UP; } } break; case BOTH_GETUP5: if ( self->client->ps.legsTimer > 850 ) {//lying down if ( animLength - self->client->ps.legsTimer > 1500 ) {//partially up deathAnim = BOTH_DEATH_FALLING_DN; } else {//down deathAnim = BOTH_DEATH_LYING_DN; } } break; case BOTH_GETUP_CROUCH_B1: if ( self->client->ps.legsTimer < 800 ) {//crouching vec3_t fwd; float thrown = 0; AngleVectors( self->client->ps.viewangles, fwd, NULL, NULL ); thrown = DotProduct( fwd, self->client->ps.velocity ); if ( thrown < -150 ) { deathAnim = BOTH_DEATHBACKWARD1; //# Death anim when crouched and thrown back } else { deathAnim = BOTH_DEATH_CROUCHED; //# Death anim when crouched } } else {//lying down if ( animLength - self->client->ps.legsTimer > 400 ) {//partially up deathAnim = BOTH_DEATH_FALLING_UP; } else {//down deathAnim = BOTH_DEATH_LYING_UP; } } break; case BOTH_GETUP_CROUCH_F1: if ( self->client->ps.legsTimer < 800 ) {//crouching vec3_t fwd; float thrown = 0; AngleVectors( self->client->ps.viewangles, fwd, NULL, NULL ); thrown = DotProduct( fwd, self->client->ps.velocity ); if ( thrown < -150 ) { deathAnim = BOTH_DEATHBACKWARD1; //# Death anim when crouched and thrown back } else { deathAnim = BOTH_DEATH_CROUCHED; //# Death anim when crouched } } else {//lying down if ( animLength - self->client->ps.legsTimer > 150 ) {//partially up deathAnim = BOTH_DEATH_FALLING_DN; } else {//down deathAnim = BOTH_DEATH_LYING_DN; } } break; case BOTH_FORCE_GETUP_B1: if ( self->client->ps.legsTimer < 325 ) {//standing up } else if ( self->client->ps.legsTimer < 725 ) {//spinning up deathAnim = BOTH_DEATH_SPIN_180; //# Death anim when facing backwards } else if ( self->client->ps.legsTimer < 900 ) {//crouching vec3_t fwd; float thrown = 0; AngleVectors( self->client->ps.viewangles, fwd, NULL, NULL ); thrown = DotProduct( fwd, self->client->ps.velocity ); if ( thrown < -150 ) { deathAnim = BOTH_DEATHBACKWARD1; //# Death anim when crouched and thrown back } else { deathAnim = BOTH_DEATH_CROUCHED; //# Death anim when crouched } } else {//lying down if ( animLength - self->client->ps.legsTimer > 50 ) {//partially up deathAnim = BOTH_DEATH_FALLING_UP; } else {//down deathAnim = BOTH_DEATH_LYING_UP; } } break; case BOTH_FORCE_GETUP_B2: if ( self->client->ps.legsTimer < 575 ) {//standing up } else if ( self->client->ps.legsTimer < 875 ) {//spinning up deathAnim = BOTH_DEATH_SPIN_180; //# Death anim when facing backwards } else if ( self->client->ps.legsTimer < 900 ) {//crouching vec3_t fwd; float thrown = 0; AngleVectors( self->client->ps.viewangles, fwd, NULL, NULL ); thrown = DotProduct( fwd, self->client->ps.velocity ); if ( thrown < -150 ) { deathAnim = BOTH_DEATHBACKWARD1; //# Death anim when crouched and thrown back } else { deathAnim = BOTH_DEATH_CROUCHED; //# Death anim when crouched } } else {//lying down //partially up deathAnim = BOTH_DEATH_FALLING_UP; } break; case BOTH_FORCE_GETUP_B3: if ( self->client->ps.legsTimer < 150 ) {//standing up } else if ( self->client->ps.legsTimer < 775 ) {//flipping deathAnim = BOTH_DEATHBACKWARD2; //backflip } else {//lying down //partially up deathAnim = BOTH_DEATH_FALLING_UP; } break; case BOTH_FORCE_GETUP_B4: if ( self->client->ps.legsTimer < 325 ) {//standing up } else {//lying down if ( animLength - self->client->ps.legsTimer > 150 ) {//partially up deathAnim = BOTH_DEATH_FALLING_UP; } else {//down deathAnim = BOTH_DEATH_LYING_UP; } } break; case BOTH_FORCE_GETUP_B5: if ( self->client->ps.legsTimer < 550 ) {//standing up } else if ( self->client->ps.legsTimer < 1025 ) {//kicking up deathAnim = BOTH_DEATHBACKWARD2; //backflip } else {//lying down if ( animLength - self->client->ps.legsTimer > 50 ) {//partially up deathAnim = BOTH_DEATH_FALLING_UP; } else {//down deathAnim = BOTH_DEATH_LYING_UP; } } break; case BOTH_FORCE_GETUP_B6: if ( self->client->ps.legsTimer < 225 ) {//standing up } else if ( self->client->ps.legsTimer < 425 ) {//crouching up vec3_t fwd; float thrown = 0; AngleVectors( self->client->ps.viewangles, fwd, NULL, NULL ); thrown = DotProduct( fwd, self->client->ps.velocity ); if ( thrown < -150 ) { deathAnim = BOTH_DEATHBACKWARD1; //# Death anim when crouched and thrown back } else { deathAnim = BOTH_DEATH_CROUCHED; //# Death anim when crouched } } else if ( self->client->ps.legsTimer < 825 ) {//flipping up deathAnim = BOTH_DEATHFORWARD3; //backflip } else {//lying down if ( animLength - self->client->ps.legsTimer > 225 ) {//partially up deathAnim = BOTH_DEATH_FALLING_UP; } else {//down deathAnim = BOTH_DEATH_LYING_UP; } } break; case BOTH_FORCE_GETUP_F1: if ( self->client->ps.legsTimer < 275 ) {//standing up } else if ( self->client->ps.legsTimer < 750 ) {//flipping deathAnim = BOTH_DEATH14; } else {//lying down if ( animLength - self->client->ps.legsTimer > 100 ) {//partially up deathAnim = BOTH_DEATH_FALLING_DN; } else {//down deathAnim = BOTH_DEATH_LYING_DN; } } break; case BOTH_FORCE_GETUP_F2: if ( self->client->ps.legsTimer < 1200 ) {//standing } else {//lying down if ( animLength - self->client->ps.legsTimer > 225 ) {//partially up deathAnim = BOTH_DEATH_FALLING_DN; } else {//down deathAnim = BOTH_DEATH_LYING_DN; } } break; } } return deathAnim; } int G_PickDeathAnim( gentity_t *self, vec3_t point, int damage, int mod, int hitLoc ) {//FIXME: play dead flop anims on body if in an appropriate _DEAD anim when this func is called int deathAnim = -1; int max_health; int legAnim = 0; vec3_t objVelocity; if (!self || !self->client) { if (!self || self->s.eType != ET_NPC) { //g2animent return 0; } } if (self->client) { max_health = self->client->ps.stats[STAT_MAX_HEALTH]; if (self->client->inSpaceIndex && self->client->inSpaceIndex != ENTITYNUM_NONE) { return BOTH_CHOKE3; } } else { max_health = 60; } if (self->client) { VectorCopy(self->client->ps.velocity, objVelocity); } else { VectorCopy(self->s.pos.trDelta, objVelocity); } if ( hitLoc == HL_NONE ) { hitLoc = G_GetHitLocation( self, point );//self->hitLoc } if (self->client) { legAnim = self->client->ps.legsAnim; } else { legAnim = self->s.legsAnim; } if (gGAvoidDismember) { return BOTH_RIGHTHANDCHOPPEDOFF; } //dead flops switch( legAnim ) { case BOTH_DEATH1: //# First Death anim case BOTH_DEAD1: case BOTH_DEATH2: //# Second Death anim case BOTH_DEAD2: case BOTH_DEATH8: //# case BOTH_DEAD8: case BOTH_DEATH13: //# case BOTH_DEAD13: case BOTH_DEATH14: //# case BOTH_DEAD14: case BOTH_DEATH16: //# case BOTH_DEAD16: case BOTH_DEADBACKWARD1: //# First thrown backward death finished pose case BOTH_DEADBACKWARD2: //# Second thrown backward death finished pose case BOTH_DEATH10: //# case BOTH_DEAD10: case BOTH_DEATH15: //# case BOTH_DEAD15: case BOTH_DEADFORWARD1: //# First thrown forward death finished pose case BOTH_DEADFORWARD2: //# Second thrown forward death finished pose case BOTH_DEADFLOP1: case BOTH_DEAD3: //# Third Death finished pose case BOTH_DEAD4: //# Fourth Death finished pose case BOTH_DEAD5: //# Fifth Death finished pose case BOTH_DEAD6: //# Sixth Death finished pose case BOTH_DEAD7: //# Seventh Death finished pose case BOTH_DEAD9: //# case BOTH_DEAD11: //# case BOTH_DEAD12: //# case BOTH_DEAD17: //# case BOTH_DEAD18: //# case BOTH_DEAD19: //# case BOTH_LYINGDEAD1: //# Killed lying down death finished pose case BOTH_STUMBLEDEAD1: //# Stumble forward death finished pose case BOTH_FALLDEAD1LAND: //# Fall forward and splat death finished pose case BOTH_DEATH3: //# Third Death anim case BOTH_DEATH4: //# Fourth Death anim case BOTH_DEATH5: //# Fifth Death anim case BOTH_DEATH6: //# Sixth Death anim case BOTH_DEATH7: //# Seventh Death anim case BOTH_DEATH9: //# case BOTH_DEATH11: //# case BOTH_DEATH12: //# case BOTH_DEATH17: //# case BOTH_DEATH18: //# case BOTH_DEATH19: //# case BOTH_DEATHFORWARD1: //# First Death in which they get thrown forward case BOTH_DEATHFORWARD2: //# Second Death in which they get thrown forward case BOTH_DEATHBACKWARD1: //# First Death in which they get thrown backward case BOTH_DEATHBACKWARD2: //# Second Death in which they get thrown backward case BOTH_DEATH1IDLE: //# Idle while close to death case BOTH_LYINGDEATH1: //# Death to play when killed lying down case BOTH_STUMBLEDEATH1: //# Stumble forward and fall face first death case BOTH_FALLDEATH1: //# Fall forward off a high cliff and splat death - start case BOTH_FALLDEATH1INAIR: //# Fall forward off a high cliff and splat death - loop case BOTH_FALLDEATH1LAND: //# Fall forward off a high cliff and splat death - hit bottom deathAnim = -2; break; } if ( deathAnim == -1 ) { if (self->client) { deathAnim = G_CheckSpecialDeathAnim( self, point, damage, mod, hitLoc ); } if (deathAnim == -1) { //death anims switch( hitLoc ) { case HL_FOOT_RT: case HL_FOOT_LT: if ( mod == MOD_SABER && !Q_irand( 0, 2 ) ) { return BOTH_DEATH10;//chest: back flip } else if ( !Q_irand( 0, 2 ) ) { deathAnim = BOTH_DEATH4;//back: forward } else if ( !Q_irand( 0, 1 ) ) { deathAnim = BOTH_DEATH5;//same as 4 } else { deathAnim = BOTH_DEATH15;//back: forward } break; case HL_LEG_RT: if ( !Q_irand( 0, 2 ) ) { deathAnim = BOTH_DEATH4;//back: forward } else if ( !Q_irand( 0, 1 ) ) { deathAnim = BOTH_DEATH5;//same as 4 } else { deathAnim = BOTH_DEATH15;//back: forward } break; case HL_LEG_LT: if ( !Q_irand( 0, 2 ) ) { deathAnim = BOTH_DEATH4;//back: forward } else if ( !Q_irand( 0, 1 ) ) { deathAnim = BOTH_DEATH5;//same as 4 } else { deathAnim = BOTH_DEATH15;//back: forward } break; case HL_BACK: if ( !VectorLengthSquared( objVelocity ) ) { deathAnim = BOTH_DEATH17;//head/back: croak } else { if ( !Q_irand( 0, 2 ) ) { deathAnim = BOTH_DEATH4;//back: forward } else if ( !Q_irand( 0, 1 ) ) { deathAnim = BOTH_DEATH5;//same as 4 } else { deathAnim = BOTH_DEATH15;//back: forward } } break; case HL_CHEST_RT: case HL_ARM_RT: case HL_HAND_RT: case HL_BACK_RT: if ( damage <= max_health*0.25 ) { deathAnim = BOTH_DEATH9;//chest right: snap, fall forward } else if ( damage <= max_health*0.5 ) { deathAnim = BOTH_DEATH3;//chest right: back } else if ( damage <= max_health*0.75 ) { deathAnim = BOTH_DEATH6;//chest right: spin } else { //TEMP HACK: play spinny deaths less often if ( Q_irand( 0, 1 ) ) { deathAnim = BOTH_DEATH8;//chest right: spin high } else { switch ( Q_irand( 0, 2 ) ) { default: case 0: deathAnim = BOTH_DEATH9;//chest right: snap, fall forward break; case 1: deathAnim = BOTH_DEATH3;//chest right: back break; case 2: deathAnim = BOTH_DEATH6;//chest right: spin break; } } } break; case HL_CHEST_LT: case HL_ARM_LT: case HL_HAND_LT: case HL_BACK_LT: if ( damage <= max_health*0.25 ) { deathAnim = BOTH_DEATH11;//chest left: snap, fall forward } else if ( damage <= max_health*0.5 ) { deathAnim = BOTH_DEATH7;//chest left: back } else if ( damage <= max_health*0.75 ) { deathAnim = BOTH_DEATH12;//chest left: spin } else { //TEMP HACK: play spinny deaths less often if ( Q_irand( 0, 1 ) ) { deathAnim = BOTH_DEATH14;//chest left: spin high } else { switch ( Q_irand( 0, 2 ) ) { default: case 0: deathAnim = BOTH_DEATH11;//chest left: snap, fall forward break; case 1: deathAnim = BOTH_DEATH7;//chest left: back break; case 2: deathAnim = BOTH_DEATH12;//chest left: spin break; } } } break; case HL_CHEST: case HL_WAIST: if ( damage <= max_health*0.25 || !VectorLengthSquared( objVelocity ) ) { if ( !Q_irand( 0, 1 ) ) { deathAnim = BOTH_DEATH18;//gut: fall right } else { deathAnim = BOTH_DEATH19;//gut: fall left } } else if ( damage <= max_health*0.5 ) { deathAnim = BOTH_DEATH2;//chest: backward short } else if ( damage <= max_health*0.75 ) { if ( !Q_irand( 0, 1 ) ) { deathAnim = BOTH_DEATH1;//chest: backward med } else { deathAnim = BOTH_DEATH16;//same as 1 } } else { deathAnim = BOTH_DEATH10;//chest: back flip } break; case HL_HEAD: if ( damage <= max_health*0.5 ) { deathAnim = BOTH_DEATH17;//head/back: croak } else { deathAnim = BOTH_DEATH13;//head: stumble, fall back } break; default: break; } } } // Validate..... if ( deathAnim == -1 || !BG_HasAnimation( self->localAnimIndex, deathAnim )) { // I guess we'll take what we can get..... deathAnim = BG_PickAnim( self->localAnimIndex, BOTH_DEATH1, BOTH_DEATH25 ); } return deathAnim; } //[SPPortComplete] //[KnockdownSys] static int G_CheckForLedge( gentity_t *self, vec3_t fallCheckDir, float checkDist ); int G_CheckLedgeDive( gentity_t *self, float checkDist, const vec3_t checkVel, qboolean tryOpposite, qboolean tryPerp ) { // Intelligent Ledge-Diving Deaths: // If I'm an NPC, check for nearby ledges and fall off it if possible // How should/would/could this interact with knockback if we already have some? // Ideally - apply knockback if there are no ledges or a ledge in that dir // But if there is a ledge and it's not in the dir of my knockback, fall off the ledge instead vec3_t fallForwardDir, fallRightDir; vec3_t angles; float fallDist; int cliff_fall = 0; VectorCopy(vec3_origin, angles); if ( !self || !self->client ) { return 0; } if ( checkVel && !VectorCompare( checkVel, vec3_origin ) ) {//already moving in a dir angles[1] = vectoyaw( self->client->ps.velocity ); AngleVectors( angles, fallForwardDir, fallRightDir, NULL ); } else {//try forward first angles[1] = self->client->ps.viewangles[1]; AngleVectors( angles, fallForwardDir, fallRightDir, NULL ); } VectorNormalize( fallForwardDir ); fallDist = G_CheckForLedge( self, fallForwardDir, checkDist ); if ( fallDist >= 128 ) { VectorClear( self->client->ps.velocity ); G_Throw( self, fallForwardDir, 85 ); self->client->ps.velocity[2] = 100; self->client->ps.groundEntityNum = ENTITYNUM_NONE; } else if ( tryOpposite ) { VectorScale( fallForwardDir, -1, fallForwardDir ); fallDist = G_CheckForLedge( self, fallForwardDir, checkDist ); if ( fallDist >= 128 ) { VectorClear( self->client->ps.velocity ); G_Throw( self, fallForwardDir, 85 ); self->client->ps.velocity[2] = 100; self->client->ps.groundEntityNum = ENTITYNUM_NONE; } } if ( !cliff_fall && tryPerp ) {//try sides VectorNormalize( fallRightDir ); fallDist = G_CheckForLedge( self, fallRightDir, checkDist ); if ( fallDist >= 128 ) { VectorClear( self->client->ps.velocity ); G_Throw( self, fallRightDir, 85 ); self->client->ps.velocity[2] = 100; } else { VectorScale( fallRightDir, -1, fallRightDir ); fallDist = G_CheckForLedge( self, fallRightDir, checkDist ); if ( fallDist >= 128 ) { VectorClear( self->client->ps.velocity ); G_Throw( self, fallRightDir, 85 ); self->client->ps.velocity[2] = 100; } } } if ( fallDist >= 256 ) { cliff_fall = 2; } else if ( fallDist >= 128 ) { cliff_fall = 1; } return cliff_fall; } //[/KnockdownSys] //[/SPPortComplete] gentity_t *G_GetJediMaster(void) { int i = 0; gentity_t *ent; while (i < MAX_CLIENTS) { ent = &g_entities[i]; if (ent && ent->inuse && ent->client && ent->client->ps.isJediMaster) { return ent; } i++; } return NULL; } /* ------------------------- G_AlertTeam ------------------------- */ void G_AlertTeam( gentity_t *victim, gentity_t *attacker, float radius, float soundDist ) { int radiusEnts[ 128 ]; gentity_t *check; vec3_t mins, maxs; int numEnts; int i; float distSq, sndDistSq = (soundDist*soundDist); if ( attacker == NULL || attacker->client == NULL ) return; //Setup the bbox to search in for ( i = 0; i < 3; i++ ) { mins[i] = victim->r.currentOrigin[i] - radius; maxs[i] = victim->r.currentOrigin[i] + radius; } //Get the number of entities in a given space numEnts = trap_EntitiesInBox( mins, maxs, radiusEnts, 128 ); //Cull this list for ( i = 0; i < numEnts; i++ ) { check = &g_entities[radiusEnts[i]]; //Validate clients if ( check->client == NULL ) continue; //only want NPCs if ( check->NPC == NULL ) continue; //[CoOp] //reenabling the IGNORE_ENEMIES flag if ( check->NPC->scriptFlags & SCF_IGNORE_ENEMIES ) continue; //[/CoOp] //Don't bother if they're ignoring enemies // if ( check->svFlags & SVF_IGNORE_ENEMIES ) // continue; //This NPC specifically flagged to ignore alerts if ( check->NPC->scriptFlags & SCF_IGNORE_ALERTS ) continue; //This NPC specifically flagged to ignore alerts if ( !(check->NPC->scriptFlags&SCF_LOOK_FOR_ENEMIES) ) continue; //this ent does not participate in group AI if ( (check->NPC->scriptFlags&SCF_NO_GROUPS) ) continue; //Skip the requested avoid check if present if ( check == victim ) continue; //Skip the attacker if ( check == attacker ) continue; //Must be on the same team if ( check->client->playerTeam != victim->client->playerTeam ) continue; //Must be alive if ( check->health <= 0 ) continue; if ( check->enemy == NULL ) {//only do this if they're not already mad at someone distSq = DistanceSquared( check->r.currentOrigin, victim->r.currentOrigin ); if ( distSq > 16384 /*128 squared*/ && !trap_InPVS( victim->r.currentOrigin, check->r.currentOrigin ) ) {//not even potentially visible/hearable continue; } //NOTE: this allows sound alerts to still go through doors/PVS if the teammate is within 128 of the victim... if ( soundDist <= 0 || distSq > sndDistSq ) {//out of sound range if ( !InFOV( victim, check, check->NPC->stats.hfov, check->NPC->stats.vfov ) || !NPC_ClearLOS2( check, victim->r.currentOrigin ) ) {//out of FOV or no LOS continue; } } //FIXME: This can have a nasty cascading effect if setup wrong... G_SetEnemy( check, attacker ); } } } /* ------------------------- G_DeathAlert ------------------------- */ #define DEATH_ALERT_RADIUS 512 #define DEATH_ALERT_SOUND_RADIUS 512 void G_DeathAlert( gentity_t *victim, gentity_t *attacker ) {//FIXME: with all the other alert stuff, do we really need this? G_AlertTeam( victim, attacker, DEATH_ALERT_RADIUS, DEATH_ALERT_SOUND_RADIUS ); } /* ---------------------------------------- DeathFX Applies appropriate special effects that occur while the entity is dying Not to be confused with NPC_RemoveBodyEffects (NPC.cpp), which only applies effect when removing the body ---------------------------------------- */ void DeathFX( gentity_t *ent ) { vec3_t effectPos, right; vec3_t defaultDir; if ( !ent || !ent->client ) return; VectorSet(defaultDir, 0, 0, 1); // team no longer indicates species/race. NPC_class should be used to identify certain npc types switch(ent->client->NPC_class) { case CLASS_MOUSE: VectorCopy( ent->r.currentOrigin, effectPos ); effectPos[2] -= 20; G_PlayEffectID( G_EffectIndex("env/small_explode"), effectPos, defaultDir ); G_Sound( ent, CHAN_AUTO, G_SoundIndex("sound/chars/mouse/misc/death1") ); break; case CLASS_PROBE: VectorCopy( ent->r.currentOrigin, effectPos ); effectPos[2] += 50; G_PlayEffectID( G_EffectIndex("explosions/probeexplosion1"), effectPos, defaultDir ); break; case CLASS_ATST: AngleVectors( ent->r.currentAngles, NULL, right, NULL ); VectorMA( ent->r.currentOrigin, 20, right, effectPos ); effectPos[2] += 180; G_PlayEffectID( G_EffectIndex("explosions/droidexplosion1"), effectPos, defaultDir ); VectorMA( effectPos, -40, right, effectPos ); G_PlayEffectID( G_EffectIndex("explosions/droidexplosion1"), effectPos, defaultDir ); break; case CLASS_SEEKER: case CLASS_REMOTE: G_PlayEffectID( G_EffectIndex("env/small_explode"), ent->r.currentOrigin, defaultDir ); break; case CLASS_GONK: VectorCopy( ent->r.currentOrigin, effectPos ); effectPos[2] -= 5; // statusTextIndex = Q_irand( IGT_RESISTANCEISFUTILE, IGT_NAMEIS8OF12 ); G_Sound( ent, CHAN_AUTO, G_SoundIndex(va("sound/chars/gonk/misc/death%d.wav",Q_irand( 1, 3 ))) ); G_PlayEffectID( G_EffectIndex("env/med_explode"), effectPos, defaultDir ); break; // should list all remaining droids here, hope I didn't miss any case CLASS_R2D2: VectorCopy( ent->r.currentOrigin, effectPos ); effectPos[2] -= 10; G_PlayEffectID( G_EffectIndex("env/med_explode"), effectPos, defaultDir ); G_Sound( ent, CHAN_AUTO, G_SoundIndex("sound/chars/mark2/misc/mark2_explo") ); break; case CLASS_PROTOCOL: //c3p0 case CLASS_R5D2: VectorCopy( ent->r.currentOrigin, effectPos ); effectPos[2] -= 10; G_PlayEffectID( G_EffectIndex("env/med_explode"), effectPos, defaultDir ); G_Sound( ent, CHAN_AUTO, G_SoundIndex("sound/chars/mark2/misc/mark2_explo") ); break; case CLASS_MARK2: VectorCopy( ent->r.currentOrigin, effectPos ); effectPos[2] -= 15; G_PlayEffectID( G_EffectIndex("explosions/droidexplosion1"), effectPos, defaultDir ); G_Sound( ent, CHAN_AUTO, G_SoundIndex("sound/chars/mark2/misc/mark2_explo") ); break; case CLASS_INTERROGATOR: VectorCopy( ent->r.currentOrigin, effectPos ); effectPos[2] -= 15; G_PlayEffectID( G_EffectIndex("explosions/droidexplosion1"), effectPos, defaultDir ); G_Sound( ent, CHAN_AUTO, G_SoundIndex("sound/chars/interrogator/misc/int_droid_explo") ); break; case CLASS_MARK1: AngleVectors( ent->r.currentAngles, NULL, right, NULL ); VectorMA( ent->r.currentOrigin, 10, right, effectPos ); effectPos[2] -= 15; G_PlayEffectID( G_EffectIndex("explosions/droidexplosion1"), effectPos, defaultDir ); VectorMA( effectPos, -20, right, effectPos ); G_PlayEffectID( G_EffectIndex("explosions/droidexplosion1"), effectPos, defaultDir ); VectorMA( effectPos, -20, right, effectPos ); G_PlayEffectID( G_EffectIndex("explosions/droidexplosion1"), effectPos, defaultDir ); G_Sound( ent, CHAN_AUTO, G_SoundIndex("sound/chars/mark1/misc/mark1_explo") ); break; case CLASS_SENTRY: G_Sound( ent, CHAN_AUTO, G_SoundIndex("sound/chars/sentry/misc/sentry_explo") ); VectorCopy( ent->r.currentOrigin, effectPos ); G_PlayEffectID( G_EffectIndex("env/med_explode"), effectPos, defaultDir ); break; default: break; } } void G_CheckVictoryScript(gentity_t *self) { if ( !G_ActivateBehavior( self, BSET_VICTORY ) ) { if ( self->NPC && self->s.weapon == WP_SABER ) {//Jedi taunt from within their AI self->NPC->blockedSpeechDebounceTime = 0;//get them ready to taunt return; } if ( self->client && self->client->NPC_class == CLASS_GALAKMECH ) { self->wait = 1; TIMER_Set( self, "gloatTime", Q_irand( 5000, 8000 ) ); self->NPC->blockedSpeechDebounceTime = 0;//get him ready to taunt return; } //FIXME: any way to not say this *right away*? Wait for victim's death anim/scream to finish? if ( self->NPC && self->NPC->group && self->NPC->group->commander && self->NPC->group->commander->NPC && self->NPC->group->commander->NPC->rank > self->NPC->rank && !Q_irand( 0, 2 ) ) {//sometimes have the group commander speak instead self->NPC->group->commander->NPC->greetingDebounceTime = level.time + Q_irand( 2000, 5000 ); //G_AddVoiceEvent( self->NPC->group->commander, Q_irand(EV_VICTORY1, EV_VICTORY3), 2000 ); } else if ( self->NPC ) { self->NPC->greetingDebounceTime = level.time + Q_irand( 2000, 5000 ); //G_AddVoiceEvent( self, Q_irand(EV_VICTORY1, EV_VICTORY3), 2000 ); } } } void G_AddPowerDuelScore(int team, int score) { int i = 0; gentity_t *check; while (i < MAX_CLIENTS) { check = &g_entities[i]; if (check->inuse && check->client && check->client->pers.connected == CON_CONNECTED && !check->client->iAmALoser && check->client->ps.stats[STAT_HEALTH] > 0 && check->client->sess.sessionTeam != TEAM_SPECTATOR && check->client->sess.duelTeam == team) { //found a living client on the specified team check->client->sess.wins += score; ClientUserinfoChanged(check->s.number); } i++; } } void G_AddPowerDuelLoserScore(int team, int score) { int i = 0; gentity_t *check; while (i < MAX_CLIENTS) { check = &g_entities[i]; if (check->inuse && check->client && check->client->pers.connected == CON_CONNECTED && (check->client->iAmALoser || (check->client->ps.stats[STAT_HEALTH] <= 0 && check->client->sess.sessionTeam != TEAM_SPECTATOR)) && check->client->sess.duelTeam == team) { //found a living client on the specified team check->client->sess.losses += score; ClientUserinfoChanged(check->s.number); } i++; } } //[Asteroids] extern qboolean g_noPDuelCheck; void G_BroadcastObit( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int killer, int meansOfDeath, int wasInVehicle, qboolean wasJediMaster ) { // broadcast the death event to everyone if (self->s.eType != ET_NPC && !g_noPDuelCheck) { gentity_t *ent; ent = G_TempEntity( self->r.currentOrigin, EV_OBITUARY ); ent->s.eventParm = meansOfDeath; ent->s.otherEntityNum = self->s.number; if ( attacker ) { ent->s.otherEntityNum2 = attacker->s.number; } else {//??? ent->s.otherEntityNum2 = killer; } if ( inflictor && !Q_stricmp( "vehicle_proj", inflictor->classname ) ) {//a vehicle missile ent->s.eventParm = MOD_VEHICLE; //store index into g_vehWeaponInfo ent->s.weapon = inflictor->s.otherEntityNum2+1; //store generic rocket or blaster type of missile ent->s.generic1 = inflictor->s.weapon; } if ( wasInVehicle && self->s.number < MAX_CLIENTS ) {//target is in a vehicle, store the entnum ent->s.lookTarget = wasInVehicle; } if ( attacker ) { if ( attacker->s.m_iVehicleNum && attacker->s.number < MAX_CLIENTS ) {//target is in a vehicle, store the entnum ent->s.brokenLimbs = attacker->s.m_iVehicleNum; } else if ( ent->s.lookTarget && !Q_stricmp( "func_rotating", attacker->classname ) ) {//my vehicle was killed by a func_rotating, probably an asteroid, so... ent->s.saberInFlight = qtrue; } } ent->r.svFlags = SVF_BROADCAST; // send to everyone ent->s.isJediMaster = wasJediMaster; } } //[/Asteroids] /* ================== player_die ================== */ extern stringID_table_t animTable[MAX_ANIMATIONS+1]; extern void AI_DeleteSelfFromGroup( gentity_t *self ); extern void AI_GroupMemberKilled( gentity_t *self ); extern void Boba_FlyStop( gentity_t *self ); extern qboolean Jedi_WaitingAmbush( gentity_t *self ); void CheckExitRules( void ); extern void Rancor_DropVictim( gentity_t *self ); extern qboolean g_dontFrickinCheck; extern qboolean g_endPDuel; //[BugFix45] extern void saberReactivate(gentity_t *saberent, gentity_t *saberOwner); extern void saberBackToOwner(gentity_t *saberent); //[/BugFix45] //[Asteroids] //extern qboolean g_noPDuelCheck; //[/Asteroids] //[FullDismemberment] //intializing checkforblowingup - Wahoo void G_CheckForblowingup (gentity_t *ent, gentity_t *enemy, vec3_t point, int damage, int deathAnim, qboolean postDeath); //[/FullDismemberment] //[CoOp] extern void BubbleShield_TurnOff(gentity_t *self); //[/CoOp] //[SaberSys] void AddFatigueKillBonus( gentity_t *attacker, gentity_t *victim ); //[/SaberSys] void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath ) { int anim; int contents; int killer; int i; char *killerName, *obit; qboolean wasJediMaster = qfalse; int sPMType = 0; int MOD=meansOfDeath; //[Asteroids] int wasInVehicle = 0; gentity_t *tempInflictorEnt = inflictor; qboolean tempInflictor = qfalse; int actualMOD = meansOfDeath; //[/Asteroids] //Copy this position to POD VectorCopy(self->client->ps.origin, self->client->sess.placeOfDeath); if(MOD==MOD_THERMAL_SPLASH||MOD==MOD_THERMAL) { self->s.eFlags|=EF_DISINTEGRATION; if(self->client) self->client->ps.eFlags |= EF_DISINTEGRATION; } if(self->client->forceLifting != -1) { gentity_t*ent = &g_entities[self->client->forceLifting]; if(ent && ent->client) { ent->client->ps.forceGripMoveInterval = 0; ent->client->ps.forceGripChangeMovetype = PM_NORMAL; ent->client->ps.pm_type = PM_NORMAL; ent->client->underForceLift=qfalse; self->client->forceLifting = -1; } } //[SeekerItemNPC] if(attacker->NPC && attacker->client->NPC_class == CLASS_SEEKER && meansOfDeath == MOD_SEEKER) {//attacker was a player's seeker item if(attacker->client->leader //has leader && attacker->client->leader->client //leader is a client && attacker->client->leader->client->remote == attacker) //has us as their remote. {//item has valid parent, make them the true attacker attacker = attacker->client->leader; } } //[/SeekerItemNPC] //[ExpSys] if(!self->NPC && !(self->r.svFlags & SVF_BOT) ) {//NPCs and bots don't care about skill point updates if(self->client->sess.skillPoints >= 1 && self->client->ps.otherKiller == self->client->ps.clientNum) self->client->sess.skillPoints--; trap_SendServerCommand(self->s.number, va("nfr %i %i %i", (int) self->client->sess.skillPoints, 0, self->client->sess.sessionTeam)); } //[/ExpSys] if ( self->client->ps.pm_type == PM_DEAD ) { return; } if ( level.intermissiontime ) { return; } //check player stuff g_dontFrickinCheck = qfalse; //[LastManStanding] //[Coop] if (g_gametype.integer == GT_SINGLE_PLAYER && ojp_lms.integer == 1) { gentity_t *murderer = NULL; murderer = &g_entities[self->client->ps.otherKiller]; murderer->liveExp++; if (murderer->liveExp >= ojp_liveExp.integer) { murderer->lives++; murderer->liveExp = 0; #ifdef _DEBUG G_Printf("You now have %i lives.",murderer->lives); #endif } } //[Coop] //[LastManStanding] if (g_gametype.integer == GT_POWERDUEL) { //don't want to wait til later in the frame if this is the case CheckExitRules(); if ( level.intermissiontime ) { return; } } if (self->s.eType == ET_NPC && self->s.NPC_class == CLASS_VEHICLE && self->m_pVehicle && !self->m_pVehicle->m_pVehicleInfo->explosionDelay && (self->m_pVehicle->m_pPilot || self->m_pVehicle->m_iNumPassengers > 0 || self->m_pVehicle->m_pDroidUnit)) { //kill everyone on board in the name of the attacker... if the vehicle has no death delay gentity_t *murderer = NULL; gentity_t *killEnt; int i = 0; if (self->client->ps.otherKillerTime >= level.time) { //use the last attacker murderer = &g_entities[self->client->ps.otherKiller]; if (!murderer->inuse || !murderer->client) { murderer = NULL; } else { if (murderer->s.number >= MAX_CLIENTS && murderer->s.eType == ET_NPC && murderer->s.NPC_class == CLASS_VEHICLE && murderer->m_pVehicle && murderer->m_pVehicle->m_pPilot) { gentity_t *murderPilot = &g_entities[murderer->m_pVehicle->m_pPilot->s.number]; if (murderPilot->inuse && murderPilot->client) { //give the pilot of the offending vehicle credit for the kill murderer = murderPilot; //[Asteroids] actualMOD = self->client->otherKillerMOD; if ( self->client->otherKillerVehWeapon > 0 ) { tempInflictorEnt = G_Spawn(); if ( tempInflictorEnt ) {//fake up the inflictor tempInflictor = qtrue; tempInflictorEnt->classname = "vehicle_proj"; tempInflictorEnt->s.otherEntityNum2 = self->client->otherKillerVehWeapon-1; tempInflictorEnt->s.weapon = self->client->otherKillerWeaponType; } } //[/Asteroids] } } } } else if (attacker && attacker->inuse && attacker->client) { if (attacker->s.number >= MAX_CLIENTS && attacker->s.eType == ET_NPC && attacker->s.NPC_class == CLASS_VEHICLE && attacker->m_pVehicle && attacker->m_pVehicle->m_pPilot) { //set vehicles pilot's killer as murderer murderer = &g_entities[attacker->m_pVehicle->m_pPilot->s.number]; if (murderer->inuse && murderer->client &&murderer->client->ps.otherKillerTime >= level.time) { murderer = &g_entities[murderer->client->ps.otherKiller]; if (!murderer->inuse || !murderer->client) { murderer = NULL; } } else { murderer = NULL; } } else { murderer = &g_entities[attacker->s.number]; } } else if (self->m_pVehicle->m_pPilot) { murderer = (gentity_t *)self->m_pVehicle->m_pPilot; if (!murderer->inuse || !murderer->client) { murderer = NULL; } } //no valid murderer.. just use self I guess if (!murderer) { //[Asteroids] if ( !attacker ) { murderer = self; } else { murderer = attacker; } } if ( self->m_pVehicle->m_pVehicleInfo->hideRider ) {//pilot is *inside* me, so kill him, too killEnt = (gentity_t *)self->m_pVehicle->m_pPilot; if (killEnt && killEnt->inuse && killEnt->client) { G_Damage(killEnt, murderer, murderer, NULL, killEnt->client->ps.origin, 99999, DAMAGE_NO_PROTECTION, MOD_BLASTER); //G_Damage(killEnt, tempInflictorEnt, murderer, NULL, killEnt->client->ps.origin, 99999, DAMAGE_NO_PROTECTION, actualMOD); } if ( self->m_pVehicle->m_pVehicleInfo ) { int numPass = self->m_pVehicle->m_iNumPassengers; for ( i = 0; i < numPass && self->m_pVehicle->m_iNumPassengers; i++ ) {//go through and eject the last passenger killEnt = (gentity_t *)self->m_pVehicle->m_ppPassengers[self->m_pVehicle->m_iNumPassengers-1]; if ( killEnt ) { self->m_pVehicle->m_pVehicleInfo->Eject(self->m_pVehicle, (bgEntity_t *)killEnt, qtrue); if ( killEnt->inuse && killEnt->client ) { G_Damage(killEnt, murderer, murderer, NULL, killEnt->client->ps.origin, 99999, DAMAGE_NO_PROTECTION, MOD_BLASTER); //G_Damage(killEnt, tempInflictorEnt, murderer, NULL, killEnt->client->ps.origin, 99999, DAMAGE_NO_PROTECTION, actualMOD); } } } } } killEnt = (gentity_t *)self->m_pVehicle->m_pDroidUnit; if (killEnt && killEnt->inuse && killEnt->client) { killEnt->flags &= ~FL_UNDYING; G_Damage(killEnt, murderer, murderer, NULL, killEnt->client->ps.origin, 99999, DAMAGE_NO_PROTECTION, MOD_BLASTER); //G_Damage(killEnt, tempInflictorEnt, murderer, NULL, killEnt->client->ps.origin, 99999, DAMAGE_NO_PROTECTION, actualMOD); } if ( tempInflictor ) { G_FreeEntity( tempInflictorEnt ); } tempInflictorEnt = inflictor; tempInflictor = qfalse; actualMOD = meansOfDeath; //[/Asteroids] } self->client->ps.emplacedIndex = 0; G_BreakArm(self, 0); //unbreak anything we have broken self->client->ps.saberEntityNum = self->client->saberStoredIndex; //in case we died while our saber was knocked away. //[BugFix45] if (self->client->ps.weapon == WP_SABER && self->client->saberKnockedTime) { gentity_t *saberEnt = &g_entities[self->client->ps.saberEntityNum]; //G_Printf("DEBUG: Running saber cleanup for %s\n", self->client->pers.netname); self->client->saberKnockedTime = 0; saberReactivate(saberEnt, self); saberEnt->r.contents = CONTENTS_LIGHTSABER; saberEnt->think = saberBackToOwner; saberEnt->nextthink = level.time; G_RunObject(saberEnt); } //[/BugFix45] self->client->bodyGrabIndex = ENTITYNUM_NONE; self->client->bodyGrabTime = 0; if (self->client->holdingObjectiveItem > 0) { //carrying a siege objective item - make sure it updates and removes itself from us now in case this is an instant death-respawn situation gentity_t *objectiveItem = &g_entities[self->client->holdingObjectiveItem]; if (objectiveItem->inuse && objectiveItem->think) { objectiveItem->think(objectiveItem); } } if ( (self->client->inSpaceIndex && self->client->inSpaceIndex != ENTITYNUM_NONE) || (self->client->ps.eFlags2 & EF2_SHIP_DEATH) ) { self->client->noCorpse = qtrue; } if ( self->client->NPC_class != CLASS_VEHICLE && self->client->ps.m_iVehicleNum ) { //I'm riding a vehicle //tell it I'm getting off gentity_t *veh = &g_entities[self->client->ps.m_iVehicleNum]; if (veh->inuse && veh->client && veh->m_pVehicle) { //[Asteroids] //remember it for obit wasInVehicle = (veh->m_pVehicle->m_pVehicleInfo-&g_vehicleInfo[0]); //[/Asteroids] veh->m_pVehicle->m_pVehicleInfo->Eject(veh->m_pVehicle, (bgEntity_t *)self, qtrue); if (veh->m_pVehicle->m_pVehicleInfo->type == VH_FIGHTER) { //go into "die in ship" mode with flag self->client->ps.eFlags2 |= EF2_SHIP_DEATH; //put me over where my vehicle exploded G_SetOrigin(self, veh->client->ps.origin); VectorCopy(veh->client->ps.origin, self->client->ps.origin); } } //droids throw heads if they haven't yet switch(self->client->NPC_class) { case CLASS_R2D2: if ( !trap_G2API_GetSurfaceRenderStatus( self->ghoul2, 0, "head" ) ) { vec3_t up; AngleVectors( self->r.currentAngles, NULL, NULL, up ); G_PlayEffectID( G_EffectIndex("chunks/r2d2head_veh"), self->r.currentOrigin, up ); } break; case CLASS_R5D2: if ( !trap_G2API_GetSurfaceRenderStatus( self->ghoul2, 0, "head" ) ) { vec3_t up; AngleVectors( self->r.currentAngles, NULL, NULL, up ); G_PlayEffectID( G_EffectIndex("chunks/r5d2head_veh"), self->r.currentOrigin, up ); } break; } } if ( self->NPC ) { //[CoOp] //turn off shielding for the assassin droids if (self->client && self->client->NPC_class==CLASS_ASSASSIN_DROID) { BubbleShield_TurnOff(self); } //[/CoOp] if ( self->client && Jedi_WaitingAmbush( self ) ) {//ambushing trooper self->client->noclip = qfalse; } NPC_FreeCombatPoint( self->NPC->combatPoint, qfalse ); if ( self->NPC->group ) { //lastInGroup = (self->NPC->group->numGroup < 2); AI_GroupMemberKilled( self ); AI_DeleteSelfFromGroup( self ); } if ( self->NPC->tempGoal ) { G_FreeEntity( self->NPC->tempGoal ); self->NPC->tempGoal = NULL; } //[SeekerItemNPC] //if this is a player's seeker droid, remove the item from their inv if(self->client && self->client->NPC_class == CLASS_SEEKER) {//this could be a player's seeker item if(self->client->leader //has leader && self->client->leader->client //leader is a client && self->client->leader->client->remote == self) //has us as their remote. {//yep, this is a player's seeker, switch the attacker entity pointer self->client->leader->client->ps.stats[STAT_HOLDABLE_ITEMS] &= ~(1 << HI_SEEKER); } } //[/SeekerItemNPC] if (0) { Boba_FlyStop( self ); } //[NPCSandCreature] if ( self->s.NPC_class == CLASS_RANCOR || self->s.NPC_class == CLASS_WAMPA || self->s.NPC_class == CLASS_SAND_CREATURE) //[/NPCSandCreature] { Rancor_DropVictim( self ); } } if ( attacker && attacker->NPC && attacker->NPC->group && attacker->NPC->group->enemy == self ) { attacker->NPC->group->enemy = NULL; } //Cheap method until/if I decide to put fancier stuff in (e.g. sabers falling out of hand and slowly //holstering on death like sp) if (self->client->ps.weapon == WP_SABER && !self->client->ps.saberHolstered && self->client->ps.saberEntityNum) { if (!self->client->ps.saberInFlight && self->client->saber[0].soundOff) { G_Sound(self, CHAN_AUTO, self->client->saber[0].soundOff); } if (self->client->saber[1].soundOff && self->client->saber[1].model[0]) { G_Sound(self, CHAN_AUTO, self->client->saber[1].soundOff); } } //Use any target we had G_UseTargets( self, self ); if (g_slowmoDuelEnd.integer && (g_gametype.integer == GT_DUEL || g_gametype.integer == GT_POWERDUEL) && attacker && attacker->inuse && attacker->client) { if (!gDoSlowMoDuel) { gDoSlowMoDuel = qtrue; gSlowMoDuelTime = level.time; } } //Make sure the jetpack is turned off. Jetpack_Off(self); self->client->ps.heldByClient = 0; self->client->beingThrown = 0; self->client->doingThrow = 0; BG_ClearRocketLock( &self->client->ps ); self->client->isHacking = 0; self->client->ps.hackingTime = 0; if (inflictor && inflictor->activator && !inflictor->client && !attacker->client && inflictor->activator->client && inflictor->activator->inuse && inflictor->s.weapon == WP_TURRET) { attacker = inflictor->activator; } if (self->client && self->client->ps.isJediMaster) { wasJediMaster = qtrue; } //[Flamethrower] //turn off flamethrower self->client->flameTime = 0; self->client->ps.userInt3 &= ~(1 << FLAG_FLAMETHROWER); //[/Flamethrower] //[NOBODYQUE] //this is set earlier since some of the previous function calls depend on this being //set for the g_spawn emergency entity override stuff. if ( self->NPC ) { self->NPC->timeOfDeath = level.time;//this will change - used for debouncing post-death events } //[/NOBODYQUE] //if he was charging or anything else, kill the sound G_MuteSound(self->s.number, CHAN_WEAPON); BlowDetpacks(self); //blow detpacks if they're planted self->client->ps.fd.forceDeactivateAll = 1; if ((self == attacker || !attacker->client) && //[Asteroids] (meansOfDeath == MOD_CRUSH || meansOfDeath == MOD_FALLING || meansOfDeath == MOD_TRIGGER_HURT || meansOfDeath == MOD_UNKNOWN || meansOfDeath == MOD_SUICIDE) && //(meansOfDeath == MOD_CRUSH || meansOfDeath == MOD_FALLING || meansOfDeath == MOD_TRIGGER_HURT || meansOfDeath == MOD_UNKNOWN) && self->client->ps.otherKillerTime > level.time) {//remember who last attacked us attacker = &g_entities[self->client->ps.otherKiller]; if ( self->client->otherKillerMOD != MOD_UNKNOWN ) { actualMOD = self->client->otherKillerMOD; } if ( self->client->otherKillerVehWeapon > 0 ) { tempInflictorEnt = G_Spawn(); if ( tempInflictorEnt ) {//fake up the inflictor tempInflictor = qtrue; tempInflictorEnt->classname = "vehicle_proj"; tempInflictorEnt->s.otherEntityNum2 = self->client->otherKillerVehWeapon-1; tempInflictorEnt->s.weapon = self->client->otherKillerWeaponType; } } //[/Asteroids] } self->client->ps.pm_type = PM_DEAD; self->client->ps.pm_flags &= ~PMF_STUCK_TO_WALL; if ( attacker ) { killer = attacker->s.number; if ( attacker->client ) { killerName = attacker->client->pers.netname; } else { killerName = "<non-client>"; } } else { killer = ENTITYNUM_WORLD; killerName = "<world>"; } if ( killer < 0 || killer >= MAX_CLIENTS ) { killer = ENTITYNUM_WORLD; killerName = "<world>"; } if ( meansOfDeath < 0 || meansOfDeath >= sizeof( modNames ) / sizeof( modNames[0] ) ) { obit = "<bad obituary>"; } else { obit = modNames[ meansOfDeath ]; } G_LogPrintf("Kill: %i %i %i: %s killed %s by %s\n", killer, self->s.number, meansOfDeath, killerName, self->client->pers.netname, obit ); if ( g_austrian.integer && (g_gametype.integer == GT_DUEL) && level.numPlayingClients >= 2 ) { int spawnTime = (level.clients[level.sortedClients[0]].respawnTime > level.clients[level.sortedClients[1]].respawnTime) ? level.clients[level.sortedClients[0]].respawnTime : level.clients[level.sortedClients[1]].respawnTime; G_LogPrintf("Duel Kill Details:\n"); G_LogPrintf("Kill Time: %d\n", level.time-spawnTime ); G_LogPrintf("victim: %s, hits on enemy %d\n", self->client->pers.netname, self->client->ps.persistant[PERS_HITS] ); if ( attacker && attacker->client ) { G_LogPrintf("killer: %s, hits on enemy %d, health: %d\n", attacker->client->pers.netname, attacker->client->ps.persistant[PERS_HITS], attacker->health ); //also - if MOD_SABER, list the animation and saber style if ( meansOfDeath == MOD_SABER ) { G_LogPrintf("killer saber style: %d, killer saber anim %s\n", attacker->client->ps.fd.saberAnimLevel, animTable[(attacker->client->ps.torsoAnim)].name ); } } } G_LogWeaponKill(killer, meansOfDeath); G_LogWeaponDeath(self->s.number, self->s.weapon); if (attacker && attacker->client && attacker->inuse) { G_LogWeaponFrag(killer, self->s.number); } //[Asteroids] G_BroadcastObit( self, inflictor, attacker, killer, actualMOD, wasInVehicle, wasJediMaster ); if ( tempInflictor ) { G_FreeEntity( tempInflictorEnt ); } //[/Asteroids] self->enemy = attacker; self->client->ps.persistant[PERS_KILLED]++; if (self == attacker) { self->client->ps.fd.suicides++; } //[Asteroids] if (attacker && attacker->client) {//killed by a client of some kind (player, NPC or vehicle) if ( self->s.number < MAX_CLIENTS ) {//only remember real clients attacker->client->lastkilled_client = self->s.number; } G_CheckVictoryScript(attacker); if ( self->s.number >= MAX_CLIENTS//not a player client && self->client //an NPC client && self->client->NPC_class != CLASS_VEHICLE //not a vehicle && self->s.m_iVehicleNum )//a droid in a vehicle {//no credit for droid, you do get credit for the vehicle kill and the pilot (2 points) } else if ( meansOfDeath == MOD_COLLISION || meansOfDeath == MOD_VEH_EXPLOSION ) {//no credit for veh-veh collisions? } else if ( attacker == self || OnSameTeam (self, attacker ) ) {//killed self or teammate if ( meansOfDeath == MOD_FALLING && attacker != self && attacker->s.number < MAX_CLIENTS && attacker->s.m_iVehicleNum ) {//crushed by a teammate in a vehicle, no penalty } else if (g_gametype.integer == GT_DUEL) //[/Asteroids] { //in duel, if you kill yourself, the person you are dueling against gets a kill for it int otherClNum = -1; if (level.sortedClients[0] == self->s.number) { otherClNum = level.sortedClients[1]; } else if (level.sortedClients[1] == self->s.number) { otherClNum = level.sortedClients[0]; } if (otherClNum >= 0 && otherClNum < MAX_CLIENTS && g_entities[otherClNum].inuse && g_entities[otherClNum].client && otherClNum != attacker->s.number) { AddScore( &g_entities[otherClNum], self->r.currentOrigin, 1 ); } else { AddScore( attacker, self->r.currentOrigin, -1 ); } } else { AddScore( attacker, self->r.currentOrigin, -1 ); //[Asteroids] if ( attacker != self && attacker->s.number < MAX_CLIENTS && self->s.number < MAX_CLIENTS ) { G_CheckTKAutoKickBan( attacker ); } //[/Asteroids] } if (g_gametype.integer == GT_JEDIMASTER) { if (self->client && self->client->ps.isJediMaster) { //killed ourself so return the saber to the original position //(to avoid people jumping off ledges and making the saber //unreachable for 60 seconds) ThrowSaberToAttacker(self, NULL); self->client->ps.isJediMaster = qfalse; } } } else { if (g_gametype.integer == GT_JEDIMASTER) { if ((attacker->client && attacker->client->ps.isJediMaster) || (self->client && self->client->ps.isJediMaster)) {//racc - killed the JM or JM who killed someone AddScore( attacker, self->r.currentOrigin, 1 ); //[SaberSys] AddFatigueKillBonus( attacker, self ); //[SaberSys] if (self->client && self->client->ps.isJediMaster) { ThrowSaberToAttacker(self, attacker); self->client->ps.isJediMaster = qfalse; } } else { gentity_t *jmEnt = G_GetJediMaster(); if (jmEnt && jmEnt->client) { AddScore( jmEnt, self->r.currentOrigin, 1 ); } } } else { AddScore( attacker, self->r.currentOrigin, 1 ); //[SaberSys] AddFatigueKillBonus( attacker, self ); //[SaberSys] } if( meansOfDeath == MOD_STUN_BATON ) { // play humiliation on player attacker->client->ps.persistant[PERS_GAUNTLET_FRAG_COUNT]++; attacker->client->rewardTime = level.time + REWARD_SPRITE_TIME; // also play humiliation on target self->client->ps.persistant[PERS_PLAYEREVENTS] ^= PLAYEREVENT_GAUNTLETREWARD; } // check for two kills in a short amount of time // if this is close enough to the last kill, give a reward sound if ( level.time - attacker->client->lastKillTime < CARNAGE_REWARD_TIME ) { // play excellent on player attacker->client->ps.persistant[PERS_EXCELLENT_COUNT]++; attacker->client->rewardTime = level.time + REWARD_SPRITE_TIME; } attacker->client->lastKillTime = level.time; } //[Asteroids] } else if ( meansOfDeath == MOD_COLLISION || meansOfDeath == MOD_VEH_EXPLOSION ) {//no credit for veh-veh collisions? } else { //} else { //[/Asteroids] if (self->client && self->client->ps.isJediMaster) { //killed ourself so return the saber to the original position //(to avoid people jumping off ledges and making the saber //unreachable for 60 seconds) ThrowSaberToAttacker(self, NULL); self->client->ps.isJediMaster = qfalse; } if (g_gametype.integer == GT_DUEL) { //in duel, if you kill yourself, the person you are dueling against gets a kill for it int otherClNum = -1; if (level.sortedClients[0] == self->s.number) { otherClNum = level.sortedClients[1]; } else if (level.sortedClients[1] == self->s.number) { otherClNum = level.sortedClients[0]; } if (otherClNum >= 0 && otherClNum < MAX_CLIENTS && g_entities[otherClNum].inuse && g_entities[otherClNum].client && otherClNum != self->s.number) { AddScore( &g_entities[otherClNum], self->r.currentOrigin, 1 ); } else { AddScore( self, self->r.currentOrigin, -1 ); } } else { AddScore( self, self->r.currentOrigin, -1 ); } } // Add team bonuses Team_FragBonuses(self, inflictor, attacker); // if I committed suicide, the flag does not fall, it returns. if (meansOfDeath == MOD_SUICIDE) { if ( self->client->ps.powerups[PW_NEUTRALFLAG] ) { // only happens in One Flag CTF Team_ReturnFlag( TEAM_FREE ); self->client->ps.powerups[PW_NEUTRALFLAG] = 0; } else if ( self->client->ps.powerups[PW_REDFLAG] ) { // only happens in standard CTF Team_ReturnFlag( TEAM_RED ); self->client->ps.powerups[PW_REDFLAG] = 0; } else if ( self->client->ps.powerups[PW_BLUEFLAG] ) { // only happens in standard CTF Team_ReturnFlag( TEAM_BLUE ); self->client->ps.powerups[PW_BLUEFLAG] = 0; } } // if client is in a nodrop area, don't drop anything (but return CTF flags!) contents = trap_PointContents( self->r.currentOrigin, -1 ); if ( !( contents & CONTENTS_NODROP ) && !self->client->ps.fallingToDeath) { //[CoOp] //we want NPCs to drop weapons as well. //if (self->s.eType != ET_NPC) { TossClientItems( self ); } //[//CoOp] } else { if ( self->client->ps.powerups[PW_NEUTRALFLAG] ) { // only happens in One Flag CTF Team_ReturnFlag( TEAM_FREE ); } else if ( self->client->ps.powerups[PW_REDFLAG] ) { // only happens in standard CTF Team_ReturnFlag( TEAM_RED ); } else if ( self->client->ps.powerups[PW_BLUEFLAG] ) { // only happens in standard CTF Team_ReturnFlag( TEAM_BLUE ); } } if ( MOD_TEAM_CHANGE == meansOfDeath ) { // Give them back a point since they didn't really die. AddScore( self, self->r.currentOrigin, 1 ); } else { Cmd_Score_f( self ); // show scores } // send updated scores to any clients that are following this one, // or they would get stale scoreboards for ( i = 0 ; i < level.maxclients ; i++ ) { gclient_t *client; client = &level.clients[i]; if ( client->pers.connected != CON_CONNECTED ) { continue; } if ( client->sess.sessionTeam != TEAM_SPECTATOR ) { continue; } if ( client->sess.spectatorClient == self->s.number ) { Cmd_Score_f( g_entities + i ); } } self->takedamage = qtrue; // can still be gibbed self->s.weapon = WP_NONE; self->s.powerups = 0; if (self->s.eType != ET_NPC) { //handled differently for NPCs self->r.contents = CONTENTS_CORPSE; } self->client->ps.zoomMode = 0; // Turn off zooming when we die self->s.loopSound = 0; self->s.loopIsSoundset = qfalse; if (self->s.eType != ET_NPC) { //handled differently for NPCs self->r.maxs[2] = -8; //[DynamicMusic] //since a player died we need to play the death music if DMS is on SetDMSState(DM_DEATH); //[/DynamicMusic] } // don't allow respawn until the death anim is done // g_forcerespawn may force spawning at some later time self->client->respawnTime = level.time + 1700; // remove powerups memset( self->client->ps.powerups, 0, sizeof(self->client->ps.powerups) ); //[BugFix40] self->client->ps.stats[STAT_HOLDABLE_ITEMS] = 0; self->client->ps.stats[STAT_HOLDABLE_ITEM] = 0; //[/BugFix40] // normal death { static int i; anim = G_PickDeathAnim(self, self->pos1, damage, meansOfDeath, HL_NONE); if (anim >= 1) { //Some droids don't have death anims // for the no-blood option, we need to prevent the health // from going to gib level if ( self->health <= GIB_HEALTH ) { self->health = GIB_HEALTH+1; } self->client->respawnTime = level.time + 1000;//((self->client->animations[anim].numFrames*40)/(50.0f / self->client->animations[anim].frameLerp))+300; sPMType = self->client->ps.pm_type; self->client->ps.pm_type = PM_NORMAL; //don't want pm type interfering with our setanim calls. if (self->inuse) { //not disconnecting G_SetAnim(self, NULL, SETANIM_BOTH, anim, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD|SETANIM_FLAG_RESTART, 0); } self->client->ps.pm_type = sPMType; //[FullDismemberment] //weapon dismemberment so saber isn't the only one :) if (meansOfDeath == MOD_SABER || (meansOfDeath == MOD_TURBLAST) || (meansOfDeath == MOD_FLECHETTE) || (meansOfDeath == MOD_FLECHETTE_ALT_SPLASH) || (meansOfDeath == MOD_CONC_ALT) || (meansOfDeath == MOD_THERMAL_SPLASH) || (meansOfDeath == MOD_TRIP_MINE_SPLASH) || (meansOfDeath == MOD_TIMED_MINE_SPLASH) || (meansOfDeath == MOD_TELEFRAG) || (meansOfDeath == MOD_CRUSH) || (meansOfDeath == MOD_MELEE && G_HeavyMelee( attacker )) || meansOfDeath == MOD_REPEATER || meansOfDeath == MOD_BOWCASTER )//saber or heavy melee (claws) //if (meansOfDeath == MOD_SABER || (meansOfDeath == MOD_MELEE && G_HeavyMelee( attacker )) )//saber or heavy melee (claws) { //update the anim on the actual skeleton (so bolt point will reflect the correct position) and then check for dismem G_UpdateClientAnims(self, 1.0f); G_CheckForDismemberment(self, attacker, self->pos1, damage, anim, qfalse); } //GIBBING!!! making use of g_checkforblowing up - Wahoo if (meansOfDeath == MOD_ROCKET || (meansOfDeath == MOD_ROCKET_SPLASH) || (meansOfDeath == MOD_ROCKET_HOMING) || (meansOfDeath == MOD_ROCKET_HOMING_SPLASH) || (meansOfDeath == MOD_THERMAL) || (meansOfDeath == MOD_DET_PACK_SPLASH) || (meansOfDeath == MOD_TELEFRAG) || (meansOfDeath == MOD_TRIGGER_HURT) || (meansOfDeath == MOD_LAVA)) { G_UpdateClientAnims(self, 1.0f); G_CheckForblowingup(self, attacker, self->pos1, damage, anim, qfalse); } //[/FullDismemberment] } //[/CoOp] if (wasJediMaster) { G_AddEvent( self, EV_DEATH1 + i, 1 ); } else { G_AddEvent( self, EV_DEATH1 + i, 0 ); } if (self != attacker) { //don't make NPCs want to murder you on respawn for killing yourself! G_DeathAlert( self, attacker ); } // the body can still be gibbed if (!self->NPC) { //don't remove NPCs like this! self->die = body_die; } //It won't gib, it will disintegrate (because this is Star Wars). self->takedamage = qtrue; // globally cycle through the different death animations i = ( i + 1 ) % 3; } if ( self->NPC ) {//If an NPC, make sure we start running our scripts again- this gets set to infinite while we fall to our deaths self->NPC->nextBStateThink = level.time; } G_ActivateBehavior( self, BSET_DEATH ); if ( self->NPC && (self->NPC->scriptFlags&SCF_FFDEATH) ) { G_ActivateBehavior( self, BSET_FFDEATH ); G_UseTargets2( self, self, self->target4 ); } // Free up any timers we may have on us. TIMER_Clear2( self ); trap_LinkEntity (self); // Start any necessary death fx for this entity DeathFX( self ); if (g_gametype.integer == GT_POWERDUEL && !g_noPDuelCheck) { //powerduel checks if (self->client->sess.duelTeam == DUELTEAM_LONE) { //automatically means a win as there is only one G_AddPowerDuelScore(DUELTEAM_DOUBLE, 1); G_AddPowerDuelLoserScore(DUELTEAM_LONE, 1); g_endPDuel = qtrue; } else if (self->client->sess.duelTeam == DUELTEAM_DOUBLE) { int i = 0; gentity_t *check; qboolean heLives = qfalse; while (i < MAX_CLIENTS) { check = &g_entities[i]; if (check->inuse && check->client && check->s.number != self->s.number && check->client->pers.connected == CON_CONNECTED && !check->client->iAmALoser && check->client->ps.stats[STAT_HEALTH] > 0 && check->client->sess.sessionTeam != TEAM_SPECTATOR && check->client->sess.duelTeam == DUELTEAM_DOUBLE) { //still an active living paired duelist so it's not over yet. heLives = qtrue; break; } i++; } if (!heLives) { //they're all dead, give the lone duelist the win. G_AddPowerDuelScore(DUELTEAM_LONE, 1); G_AddPowerDuelLoserScore(DUELTEAM_DOUBLE, 1); g_endPDuel = qtrue; } } } } /* ================ CheckArmor ================ */ //[CoOp] //added mod for use by assassin droid shield management. int CheckArmor (gentity_t *ent, int damage, int dflags, int mod) //int CheckArmor (gentity_t *ent, int damage, int dflags) //[/CoOp] { gclient_t *client; int save; int count; if (!damage) return 0; client = ent->client; if (!client) return 0; if (dflags & DAMAGE_NO_ARMOR) return 0; //[CoOp] //armor acts as shielding for this class if (client->NPC_class==CLASS_ASSASSIN_DROID) { int previousArmor; // The Assassin Always Completely Ignores These Damage Types //----------------------------------------------------------- if ( mod==MOD_LAVA || mod==MOD_SLIME || mod==MOD_WATER || mod==MOD_MELEE || mod==MOD_BOWCASTER || mod==MOD_BRYAR_PISTOL || mod==MOD_BRYAR_PISTOL_ALT || mod==MOD_BLASTER || mod==MOD_DISRUPTOR_SNIPER || mod==MOD_BOWCASTER || mod==MOD_REPEATER || mod==MOD_REPEATER_ALT) { return damage; } // If The Shield Is Not On, No Additional Protection //--------------------------------------------------- if (!(ent->flags&FL_SHIELDED)) { // He Does Ignore Half Saber Damage, Even Shield Down //---------------------------------------------------- if (mod==MOD_SABER) { return (int)((float)(damage)*0.75f); } return 0; } // If The Shield Is Up, He Ignores These Damage Types //---------------------------------------------------- if (mod==MOD_SABER || mod==MOD_FLECHETTE || mod==MOD_FLECHETTE_ALT_SPLASH || mod==MOD_DISRUPTOR) { return damage; } // The Demp Completely Destroys The Shield //----------------------------------------- if (mod==MOD_DEMP2 || mod==MOD_DEMP2_ALT) { client->ps.stats[STAT_ARMOR] = 0; return 0; } // Otherwise, The Shield Absorbs As Much Damage As Possible //---------------------------------------------------------- previousArmor = client->ps.stats[STAT_ARMOR]; client->ps.stats[STAT_ARMOR] -= damage; if (client->ps.stats[STAT_ARMOR]<0) { client->ps.stats[STAT_ARMOR] = 0; } return (previousArmor - client->ps.stats[STAT_ARMOR]); } //[/CoOp] if ( client->NPC_class == CLASS_VEHICLE && ent->m_pVehicle && ent->client->ps.electrifyTime > level.time ) {//ion-cannon has disabled this ship's shields, take damage on hull! return 0; } // armor count = client->ps.stats[STAT_ARMOR]; if (dflags & DAMAGE_HALF_ABSORB) { // Half the damage gets absorbed by the shields, rather than 100% save = ceil( damage * ARMOR_PROTECTION ); } else { // All the damage gets absorbed by the shields. save = damage; } // save is the most damage that the armor is elibigle to protect, of course, but it's limited by the total armor. if (save >= count) save = count; if (!save) return 0; if (dflags & DAMAGE_HALF_ARMOR_REDUCTION) // Armor isn't whittled so easily by sniper shots. { client->ps.stats[STAT_ARMOR] -= (int)(save*ARMOR_REDUCTION_FACTOR); } else { client->ps.stats[STAT_ARMOR] -= save; } return save; } void G_ApplyKnockback( gentity_t *targ, vec3_t newDir, float knockback ) { vec3_t kvel; float mass; if ( targ->physicsBounce > 0 ) //overide the mass mass = targ->physicsBounce; else mass = 200; if ( g_gravity.value > 0 ) { VectorScale( newDir, g_knockback.value * (float)knockback / mass * 0.8, kvel ); kvel[2] = newDir[2] * g_knockback.value * (float)knockback / mass * 1.5; } else { VectorScale( newDir, g_knockback.value * (float)knockback / mass, kvel ); } if ( targ->client ) { VectorAdd( targ->client->ps.velocity, kvel, targ->client->ps.velocity ); } else if ( targ->s.pos.trType != TR_STATIONARY && targ->s.pos.trType != TR_LINEAR_STOP && targ->s.pos.trType != TR_NONLINEAR_STOP ) { VectorAdd( targ->s.pos.trDelta, kvel, targ->s.pos.trDelta ); VectorCopy( targ->r.currentOrigin, targ->s.pos.trBase ); targ->s.pos.trTime = level.time; } // set the timer so that the other client can't cancel // out the movement immediately if ( targ->client && !targ->client->ps.pm_time ) { int t; t = knockback * 2; if ( t < 50 ) { t = 50; } if ( t > 200 ) { t = 200; } targ->client->ps.pm_time = t; targ->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; } } //[KnockdownSys] static int G_CheckForLedge( gentity_t *self, vec3_t fallCheckDir, float checkDist ) {//racc - this function checks to see if there is a ledge/cliff/empty in fallCheckDir @ checkDist away from the player. //This also checks to see if there's a clear path between the player and the point from which the fall check is made. //Returns the length of the drop. vec3_t start, end; trace_t tr; VectorMA( self->r.currentOrigin, checkDist, fallCheckDir, end ); //Should have clip burshes masked out by now and have bbox resized to death size trap_Trace( &tr, self->r.currentOrigin, self->r.mins, self->r.maxs, end, self->s.number, self->clipmask ); if ( tr.allsolid || tr.startsolid ) { return 0; } VectorCopy( tr.endpos, start ); VectorCopy( start, end ); end[2] -= 256; trap_Trace( &tr, start, self->r.mins, self->r.maxs, end, self->s.number, self->clipmask ); if ( tr.allsolid || tr.startsolid ) { return 0; } if ( tr.fraction >= 1.0 ) { return (start[2]-tr.endpos[2]); } return 0; } //[/KnockdownSys] /* ================ RaySphereIntersections ================ */ int RaySphereIntersections( vec3_t origin, float radius, vec3_t point, vec3_t dir, vec3_t intersections[2] ) { float b, c, d, t; VectorNormalize(dir); b = 2 * (dir[0] * (point[0] - origin[0]) + dir[1] * (point[1] - origin[1]) + dir[2] * (point[2] - origin[2])); c = (point[0] - origin[0]) * (point[0] - origin[0]) + (point[1] - origin[1]) * (point[1] - origin[1]) + (point[2] - origin[2]) * (point[2] - origin[2]) - radius * radius; d = b * b - 4 * c; if (d > 0) { t = (- b + sqrt(d)) / 2; VectorMA(point, t, dir, intersections[0]); t = (- b - sqrt(d)) / 2; VectorMA(point, t, dir, intersections[1]); return 2; } else if (d == 0) { t = (- b ) / 2; VectorMA(point, t, dir, intersections[0]); return 1; } return 0; } /* =================================== rww - beginning of the majority of the dismemberment and location based damage code. =================================== */ char *hitLocName[HL_MAX] = { "none", //HL_NONE = 0, "right foot", //HL_FOOT_RT, "left foot", //HL_FOOT_LT, "right leg", //HL_LEG_RT, "left leg", //HL_LEG_LT, "waist", //HL_WAIST, "back right shoulder", //HL_BACK_RT, "back left shoulder", //HL_BACK_LT, "back", //HL_BACK, "front right shouler", //HL_CHEST_RT, "front left shoulder", //HL_CHEST_LT, "chest", //HL_CHEST, "right arm", //HL_ARM_RT, "left arm", //HL_ARM_LT, "right hand", //HL_HAND_RT, "left hand", //HL_HAND_LT, "head", //HL_HEAD "generic1", //HL_GENERIC1, "generic2", //HL_GENERIC2, "generic3", //HL_GENERIC3, "generic4", //HL_GENERIC4, "generic5", //HL_GENERIC5, "generic6" //HL_GENERIC6 }; void G_GetDismemberLoc(gentity_t *self, vec3_t boltPoint, int limbType) { //Just get the general area without using server-side ghoul2 vec3_t fwd, right, up; AngleVectors(self->r.currentAngles, fwd, right, up); VectorCopy(self->r.currentOrigin, boltPoint); switch (limbType) { case G2_MODELPART_HEAD: boltPoint[0] += up[0]*24; boltPoint[1] += up[1]*24; boltPoint[2] += up[2]*24; break; case G2_MODELPART_WAIST: boltPoint[0] += up[0]*4; boltPoint[1] += up[1]*4; boltPoint[2] += up[2]*4; break; case G2_MODELPART_LARM: boltPoint[0] += up[0]*18; boltPoint[1] += up[1]*18; boltPoint[2] += up[2]*18; boltPoint[0] -= right[0]*10; boltPoint[1] -= right[1]*10; boltPoint[2] -= right[2]*10; break; case G2_MODELPART_RARM: boltPoint[0] += up[0]*18; boltPoint[1] += up[1]*18; boltPoint[2] += up[2]*18; boltPoint[0] += right[0]*10; boltPoint[1] += right[1]*10; boltPoint[2] += right[2]*10; break; case G2_MODELPART_RHAND: boltPoint[0] += up[0]*8; boltPoint[1] += up[1]*8; boltPoint[2] += up[2]*8; boltPoint[0] += right[0]*10; boltPoint[1] += right[1]*10; boltPoint[2] += right[2]*10; break; case G2_MODELPART_LLEG: boltPoint[0] -= up[0]*4; boltPoint[1] -= up[1]*4; boltPoint[2] -= up[2]*4; boltPoint[0] -= right[0]*10; boltPoint[1] -= right[1]*10; boltPoint[2] -= right[2]*10; break; case G2_MODELPART_RLEG: boltPoint[0] -= up[0]*4; boltPoint[1] -= up[1]*4; boltPoint[2] -= up[2]*4; boltPoint[0] += right[0]*10; boltPoint[1] += right[1]*10; boltPoint[2] += right[2]*10; break; default: break; } return; } void G_GetDismemberBolt(gentity_t *self, vec3_t boltPoint, int limbType) { int useBolt = self->genericValue5; vec3_t properOrigin, properAngles, addVel; //vec3_t legAxis[3]; mdxaBone_t boltMatrix; float fVSpeed = 0; char *rotateBone = NULL; switch (limbType) { case G2_MODELPART_HEAD: rotateBone = "cranium"; break; case G2_MODELPART_WAIST: if (self->localAnimIndex <= 1) { //humanoid rotateBone = "thoracic"; } else { rotateBone = "pelvis"; } break; case G2_MODELPART_LARM: rotateBone = "lradius"; break; case G2_MODELPART_RARM: rotateBone = "rradius"; break; case G2_MODELPART_RHAND: rotateBone = "rhand"; break; case G2_MODELPART_LLEG: rotateBone = "ltibia"; break; case G2_MODELPART_RLEG: rotateBone = "rtibia"; break; default: rotateBone = "rtibia"; break; } useBolt = trap_G2API_AddBolt(self->ghoul2, 0, rotateBone); VectorCopy(self->client->ps.origin, properOrigin); VectorCopy(self->client->ps.viewangles, properAngles); //try to predict the origin based on velocity so it's more like what the client is seeing VectorCopy(self->client->ps.velocity, addVel); VectorNormalize(addVel); if (self->client->ps.velocity[0] < 0) { fVSpeed += (-self->client->ps.velocity[0]); } else { fVSpeed += self->client->ps.velocity[0]; } if (self->client->ps.velocity[1] < 0) { fVSpeed += (-self->client->ps.velocity[1]); } else { fVSpeed += self->client->ps.velocity[1]; } if (self->client->ps.velocity[2] < 0) { fVSpeed += (-self->client->ps.velocity[2]); } else { fVSpeed += self->client->ps.velocity[2]; } fVSpeed *= 0.08; properOrigin[0] += addVel[0]*fVSpeed; properOrigin[1] += addVel[1]*fVSpeed; properOrigin[2] += addVel[2]*fVSpeed; properAngles[0] = 0; properAngles[1] = self->client->ps.viewangles[YAW]; properAngles[2] = 0; trap_G2API_GetBoltMatrix(self->ghoul2, 0, useBolt, &boltMatrix, properAngles, properOrigin, level.time, NULL, self->modelScale); boltPoint[0] = boltMatrix.matrix[0][3]; boltPoint[1] = boltMatrix.matrix[1][3]; boltPoint[2] = boltMatrix.matrix[2][3]; trap_G2API_GetBoltMatrix(self->ghoul2, 1, 0, &boltMatrix, properAngles, properOrigin, level.time, NULL, self->modelScale); if (self->client && limbType == G2_MODELPART_RHAND) { //Make some saber hit sparks over the severed wrist area vec3_t boltAngles; gentity_t *te; boltAngles[0] = -boltMatrix.matrix[0][1]; boltAngles[1] = -boltMatrix.matrix[1][1]; boltAngles[2] = -boltMatrix.matrix[2][1]; te = G_TempEntity( boltPoint, EV_SABER_HIT ); te->s.otherEntityNum = self->s.number; te->s.otherEntityNum2 = ENTITYNUM_NONE; te->s.weapon = 0;//saberNum te->s.legsAnim = 0;//bladeNum VectorCopy(boltPoint, te->s.origin); VectorCopy(boltAngles, te->s.angles); if (!te->s.angles[0] && !te->s.angles[1] && !te->s.angles[2]) { //don't let it play with no direction te->s.angles[1] = 1; } te->s.eventParm = 16; //lots of sparks } } void LimbTouch( gentity_t *self, gentity_t *other, trace_t *trace ) { } void LimbThink( gentity_t *ent ) { float gravity = 3.0f; float mass = 0.09f; float bounce = 1.3f; switch (ent->s.modelGhoul2) { case G2_MODELPART_HEAD: mass = 0.08f; bounce = 1.4f; break; case G2_MODELPART_WAIST: mass = 0.1f; bounce = 1.2f; break; case G2_MODELPART_LARM: case G2_MODELPART_RARM: case G2_MODELPART_RHAND: case G2_MODELPART_LLEG: case G2_MODELPART_RLEG: default: break; } if (ent->speed < level.time) { ent->think = G_FreeEntity; ent->nextthink = level.time; return; } if (ent->genericValue5 <= level.time) { //this will be every frame by standard, but we want to compensate in case sv_fps is not 20. G_RunExPhys(ent, gravity, mass, bounce, qtrue, NULL, 0); ent->genericValue5 = level.time + 50; } ent->nextthink = level.time; } #include "../namespace_begin.h" extern qboolean BG_GetRootSurfNameWithVariant( void *ghoul2, const char *rootSurfName, char *returnSurfName, int returnSize ); #include "../namespace_end.h" void G_Dismember( gentity_t *ent, gentity_t *enemy, vec3_t point, int limbType, float limbRollBase, float limbPitchBase, int deathAnim, qboolean postDeath ) { vec3_t newPoint, dir, vel; gentity_t *limb; char limbName[MAX_QPATH]; char stubName[MAX_QPATH]; char stubCapName[MAX_QPATH]; if (limbType == G2_MODELPART_HEAD) { Q_strncpyz( limbName , "head", sizeof( limbName ) ); Q_strncpyz( stubCapName, "torso_cap_head", sizeof( stubCapName ) ); } else if (limbType == G2_MODELPART_WAIST) { Q_strncpyz( limbName, "torso", sizeof( limbName ) ); Q_strncpyz( stubCapName, "hips_cap_torso", sizeof( stubCapName ) ); } else if (limbType == G2_MODELPART_LARM) { BG_GetRootSurfNameWithVariant( ent->ghoul2, "l_arm", limbName, sizeof(limbName) ); BG_GetRootSurfNameWithVariant( ent->ghoul2, "torso", stubName, sizeof(stubName) ); Com_sprintf( stubCapName, sizeof( stubCapName), "%s_cap_l_arm", stubName ); } else if (limbType == G2_MODELPART_RARM) { BG_GetRootSurfNameWithVariant( ent->ghoul2, "r_arm", limbName, sizeof(limbName) ); BG_GetRootSurfNameWithVariant( ent->ghoul2, "torso", stubName, sizeof(stubName) ); Com_sprintf( stubCapName, sizeof( stubCapName), "%s_cap_r_arm", stubName ); } else if (limbType == G2_MODELPART_RHAND) { BG_GetRootSurfNameWithVariant( ent->ghoul2, "r_hand", limbName, sizeof(limbName) ); BG_GetRootSurfNameWithVariant( ent->ghoul2, "r_arm", stubName, sizeof(stubName) ); Com_sprintf( stubCapName, sizeof( stubCapName), "%s_cap_r_hand", stubName ); } else if (limbType == G2_MODELPART_LLEG) { BG_GetRootSurfNameWithVariant( ent->ghoul2, "l_leg", limbName, sizeof(limbName) ); BG_GetRootSurfNameWithVariant( ent->ghoul2, "hips", stubName, sizeof(stubName) ); Com_sprintf( stubCapName, sizeof( stubCapName), "%s_cap_l_leg", stubName ); } else if (limbType == G2_MODELPART_RLEG) { BG_GetRootSurfNameWithVariant( ent->ghoul2, "r_leg", limbName, sizeof(limbName) ); BG_GetRootSurfNameWithVariant( ent->ghoul2, "hips", stubName, sizeof(stubName) ); Com_sprintf( stubCapName, sizeof( stubCapName), "%s_cap_r_leg", stubName ); } else {//umm... just default to the right leg, I guess (same as on client) BG_GetRootSurfNameWithVariant( ent->ghoul2, "r_leg", limbName, sizeof(limbName) ); BG_GetRootSurfNameWithVariant( ent->ghoul2, "hips", stubName, sizeof(stubName) ); Com_sprintf( stubCapName, sizeof( stubCapName), "%s_cap_r_leg", stubName ); } if (ent->ghoul2 && limbName && trap_G2API_GetSurfaceRenderStatus(ent->ghoul2, 0, limbName)) { //is it already off? If so there's no reason to be doing it again, so get out of here. return; } VectorCopy( point, newPoint ); limb = G_Spawn(); limb->classname = "playerlimb"; /* if (limbType == G2_MODELPART_WAIST) { //slight hack newPoint[2] += 1; } */ G_SetOrigin( limb, newPoint ); VectorCopy( newPoint, limb->s.pos.trBase ); limb->think = LimbThink; limb->touch = LimbTouch; limb->speed = level.time + Q_irand(8000, 16000); limb->nextthink = level.time + FRAMETIME; limb->r.svFlags = SVF_USE_CURRENT_ORIGIN; limb->clipmask = MASK_SOLID; limb->r.contents = CONTENTS_TRIGGER; limb->physicsObject = qtrue; VectorSet( limb->r.mins, -6.0f, -6.0f, -3.0f ); VectorSet( limb->r.maxs, 6.0f, 6.0f, 6.0f ); limb->s.g2radius = 200; limb->s.eType = ET_GENERAL; limb->s.weapon = G2_MODEL_PART; limb->s.modelGhoul2 = limbType; limb->s.modelindex = ent->s.number; if (!ent->client) { limb->s.modelindex = -1; limb->s.otherEntityNum2 = ent->s.number; } VectorClear(limb->s.apos.trDelta); if (ent->client) { VectorCopy(ent->client->ps.viewangles, limb->r.currentAngles); VectorCopy(ent->client->ps.viewangles, limb->s.apos.trBase); } else { VectorCopy(ent->r.currentAngles, limb->r.currentAngles); VectorCopy(ent->r.currentAngles, limb->s.apos.trBase); } //Set up the ExPhys values for the entity. limb->epGravFactor = 0; VectorClear(limb->epVelocity); VectorSubtract( point, ent->r.currentOrigin, dir ); VectorNormalize( dir ); if (ent->client) { VectorCopy(ent->client->ps.velocity, vel); } else { VectorCopy(ent->s.pos.trDelta, vel); } VectorMA( vel, 80, dir, limb->epVelocity ); //add some vertical velocity if (limbType == G2_MODELPART_HEAD || limbType == G2_MODELPART_WAIST) { limb->epVelocity[2] += 10; } if (enemy && enemy->client && ent && ent != enemy && ent->s.number != enemy->s.number && enemy->client->ps.weapon == WP_SABER && enemy->client->olderIsValid && (level.time - enemy->client->lastSaberStorageTime) < 200) { //The enemy has valid saber positions between this and last frame. Use them to factor in direction of the limb. vec3_t dif; float totalDistance; const float distScale = 1.2f; //scale down the initial velocity first, which is based on the speed of the limb owner. //ExPhys object velocity operates on a slightly different scale than Q3-based physics velocity. VectorScale(limb->epVelocity, 0.4f, limb->epVelocity); VectorSubtract(enemy->client->lastSaberBase_Always, enemy->client->olderSaberBase, dif); totalDistance = VectorNormalize(dif); VectorScale(dif, totalDistance*distScale, dif); VectorAdd(limb->epVelocity, dif, limb->epVelocity); if (ent->client && (ent->client->ps.torsoTimer > 0 || !BG_InDeathAnim(ent->client->ps.torsoAnim))) { //if he's done with his death anim we don't actually want the limbs going far vec3_t preVel; VectorCopy(limb->epVelocity, preVel); preVel[2] = 0; totalDistance = VectorNormalize(preVel); if (totalDistance < 40.0f) { float mAmt = 40.0f;//60.0f/totalDistance; limb->epVelocity[0] = preVel[0]*mAmt; limb->epVelocity[1] = preVel[1]*mAmt; } } else if (ent->client) { VectorScale(limb->epVelocity, 0.3f, limb->epVelocity); } } if (ent->s.eType == ET_NPC && ent->ghoul2 && limbName && stubCapName) { //if it's an npc remove these surfs on the server too. For players we don't even care cause there's no further dismemberment after death. trap_G2API_SetSurfaceOnOff(ent->ghoul2, limbName, 0x00000100); trap_G2API_SetSurfaceOnOff(ent->ghoul2, stubCapName, 0); } limb->s.customRGBA[0] = ent->s.customRGBA[0]; limb->s.customRGBA[1] = ent->s.customRGBA[1]; limb->s.customRGBA[2] = ent->s.customRGBA[2]; limb->s.customRGBA[3] = ent->s.customRGBA[3]; trap_LinkEntity( limb ); } void DismembermentTest(gentity_t *self) { int sect = G2_MODELPART_HEAD; vec3_t boltPoint; while (sect <= G2_MODELPART_RLEG) { G_GetDismemberBolt(self, boltPoint, sect); G_Dismember( self, self, boltPoint, sect, 90, 0, BOTH_DEATH1, qfalse ); sect++; } } void DismembermentByNum(gentity_t *self, int num) { int sect = G2_MODELPART_HEAD; vec3_t boltPoint; switch (num) { case 0: sect = G2_MODELPART_HEAD; break; case 1: sect = G2_MODELPART_WAIST; break; case 2: sect = G2_MODELPART_LARM; break; case 3: sect = G2_MODELPART_RARM; break; case 4: sect = G2_MODELPART_RHAND; break; case 5: sect = G2_MODELPART_LLEG; break; case 6: sect = G2_MODELPART_RLEG; break; default: break; } G_GetDismemberBolt(self, boltPoint, sect); G_Dismember( self, self, boltPoint, sect, 90, 0, BOTH_DEATH1, qfalse ); } int G_GetHitQuad( gentity_t *self, vec3_t hitloc ) { vec3_t diff, fwdangles={0,0,0}, right; vec3_t clEye; float rightdot; float zdiff; int hitLoc = gPainHitLoc; if (self->client) { VectorCopy(self->client->ps.origin, clEye); clEye[2] += self->client->ps.viewheight; } else { VectorCopy(self->s.pos.trBase, clEye); clEye[2] += 16; } VectorSubtract( hitloc, clEye, diff ); diff[2] = 0; VectorNormalize( diff ); if (self->client) { fwdangles[1] = self->client->ps.viewangles[1]; } else { fwdangles[1] = self->s.apos.trBase[1]; } // Ultimately we might care if the shot was ahead or behind, but for now, just quadrant is fine. AngleVectors( fwdangles, NULL, right, NULL ); rightdot = DotProduct(right, diff); zdiff = hitloc[2] - clEye[2]; if ( zdiff > 0 ) { if ( rightdot > 0.3 ) { hitLoc = G2_MODELPART_RARM; } else if ( rightdot < -0.3 ) { hitLoc = G2_MODELPART_LARM; } else { hitLoc = G2_MODELPART_HEAD; } } else if ( zdiff > -20 ) { if ( rightdot > 0.1 ) { hitLoc = G2_MODELPART_RARM; } else if ( rightdot < -0.1 ) { hitLoc = G2_MODELPART_LARM; } else { hitLoc = G2_MODELPART_HEAD; } } else { if ( rightdot >= 0 ) { hitLoc = G2_MODELPART_RLEG; } else { hitLoc = G2_MODELPART_LLEG; } } return hitLoc; } int gGAvoidDismember = 0; void UpdateClientRenderBolts(gentity_t *self, vec3_t renderOrigin, vec3_t renderAngles); qboolean G_GetHitLocFromSurfName( gentity_t *ent, const char *surfName, int *hitLoc, vec3_t point, vec3_t dir, vec3_t bladeDir, int mod ) { qboolean dismember = qfalse; int actualTime; int kneeLBolt = -1; int kneeRBolt = -1; int handRBolt = -1; int handLBolt = -1; int footRBolt = -1; int footLBolt = -1; *hitLoc = HL_NONE; if ( !surfName || !surfName[0] ) { return qfalse; } if( !ent->client ) { return qfalse; } if (!point) { return qfalse; } if ( ent->client && ( ent->client->NPC_class == CLASS_R2D2 || ent->client->NPC_class == CLASS_R2D2 || ent->client->NPC_class == CLASS_GONK || ent->client->NPC_class == CLASS_MOUSE || ent->client->NPC_class == CLASS_SENTRY || ent->client->NPC_class == CLASS_INTERROGATOR || ent->client->NPC_class == CLASS_SENTRY || ent->client->NPC_class == CLASS_PROBE ) ) {//we don't care about per-surface hit-locations or dismemberment for these guys return qfalse; } if (ent->localAnimIndex <= 1) { //humanoid handLBolt = trap_G2API_AddBolt(ent->ghoul2, 0, "*l_hand"); handRBolt = trap_G2API_AddBolt(ent->ghoul2, 0, "*r_hand"); kneeLBolt = trap_G2API_AddBolt(ent->ghoul2, 0, "*hips_l_knee"); kneeRBolt = trap_G2API_AddBolt(ent->ghoul2, 0, "*hips_r_knee"); footLBolt = trap_G2API_AddBolt(ent->ghoul2, 0, "*l_leg_foot"); footRBolt = trap_G2API_AddBolt(ent->ghoul2, 0, "*r_leg_foot"); } if ( ent->client && (ent->client->NPC_class == CLASS_ATST) ) { //FIXME: almost impossible to hit these... perhaps we should // check for splashDamage and do radius damage to these parts? // Or, if we ever get bbox G2 traces, that may fix it, too if (!Q_stricmp("head_light_blaster_cann",surfName)) { *hitLoc = HL_ARM_LT; } else if (!Q_stricmp("head_concussion_charger",surfName)) { *hitLoc = HL_ARM_RT; } return(qfalse); } else if ( ent->client && (ent->client->NPC_class == CLASS_MARK1) ) { if (!Q_stricmp("l_arm",surfName)) { *hitLoc = HL_ARM_LT; } else if (!Q_stricmp("r_arm",surfName)) { *hitLoc = HL_ARM_RT; } else if (!Q_stricmp("torso_front",surfName)) { *hitLoc = HL_CHEST; } else if (!Q_stricmp("torso_tube1",surfName)) { *hitLoc = HL_GENERIC1; } else if (!Q_stricmp("torso_tube2",surfName)) { *hitLoc = HL_GENERIC2; } else if (!Q_stricmp("torso_tube3",surfName)) { *hitLoc = HL_GENERIC3; } else if (!Q_stricmp("torso_tube4",surfName)) { *hitLoc = HL_GENERIC4; } else if (!Q_stricmp("torso_tube5",surfName)) { *hitLoc = HL_GENERIC5; } else if (!Q_stricmp("torso_tube6",surfName)) { *hitLoc = HL_GENERIC6; } return(qfalse); } else if ( ent->client && (ent->client->NPC_class == CLASS_MARK2) ) { if (!Q_stricmp("torso_canister1",surfName)) { *hitLoc = HL_GENERIC1; } else if (!Q_stricmp("torso_canister2",surfName)) { *hitLoc = HL_GENERIC2; } else if (!Q_stricmp("torso_canister3",surfName)) { *hitLoc = HL_GENERIC3; } return(qfalse); } else if ( ent->client && (ent->client->NPC_class == CLASS_GALAKMECH) ) { if (!Q_stricmp("torso_antenna",surfName)||!Q_stricmp("torso_antenna_base",surfName)) { *hitLoc = HL_GENERIC1; } else if (!Q_stricmp("torso_shield",surfName)) { *hitLoc = HL_GENERIC2; } else { *hitLoc = HL_CHEST; } return(qfalse); } //FIXME: check the hitLoc and hitDir against the cap tag for the place //where the split will be- if the hit dir is roughly perpendicular to //the direction of the cap, then the split is allowed, otherwise we //hit it at the wrong angle and should not dismember... actualTime = level.time; if ( !Q_strncmp( "hips", surfName, 4 ) ) {//FIXME: test properly for legs *hitLoc = HL_WAIST; if ( ent->client != NULL && ent->ghoul2 ) { mdxaBone_t boltMatrix; vec3_t tagOrg, angles; VectorSet( angles, 0, ent->r.currentAngles[YAW], 0 ); if (kneeLBolt>=0) { trap_G2API_GetBoltMatrix( ent->ghoul2, 0, kneeLBolt, &boltMatrix, angles, ent->r.currentOrigin, actualTime, NULL, ent->modelScale ); BG_GiveMeVectorFromMatrix( &boltMatrix, ORIGIN, tagOrg ); if ( DistanceSquared( point, tagOrg ) < 100 ) {//actually hit the knee *hitLoc = HL_LEG_LT; } } if (*hitLoc == HL_WAIST) { if (kneeRBolt>=0) { trap_G2API_GetBoltMatrix( ent->ghoul2, 0, kneeRBolt, &boltMatrix, angles, ent->r.currentOrigin, actualTime, NULL, ent->modelScale ); BG_GiveMeVectorFromMatrix( &boltMatrix, ORIGIN, tagOrg ); if ( DistanceSquared( point, tagOrg ) < 100 ) {//actually hit the knee *hitLoc = HL_LEG_RT; } } } } } else if ( !Q_strncmp( "torso", surfName, 5 ) ) { if ( !ent->client ) { *hitLoc = HL_CHEST; } else { vec3_t t_fwd, t_rt, t_up, dirToImpact; float frontSide, rightSide, upSide; AngleVectors( ent->client->renderInfo.torsoAngles, t_fwd, t_rt, t_up ); if (ent->client->renderInfo.boltValidityTime != level.time) { vec3_t renderAng; renderAng[0] = 0; renderAng[1] = ent->client->ps.viewangles[YAW]; renderAng[2] = 0; UpdateClientRenderBolts(ent, ent->client->ps.origin, renderAng); } VectorSubtract( point, ent->client->renderInfo.torsoPoint, dirToImpact ); frontSide = DotProduct( t_fwd, dirToImpact ); rightSide = DotProduct( t_rt, dirToImpact ); upSide = DotProduct( t_up, dirToImpact ); if ( upSide < -10 ) {//hit at waist *hitLoc = HL_WAIST; } else {//hit on upper torso if ( rightSide > 4 ) { *hitLoc = HL_ARM_RT; } else if ( rightSide < -4 ) { *hitLoc = HL_ARM_LT; } else if ( rightSide > 2 ) { if ( frontSide > 0 ) { *hitLoc = HL_CHEST_RT; } else { *hitLoc = HL_BACK_RT; } } else if ( rightSide < -2 ) { if ( frontSide > 0 ) { *hitLoc = HL_CHEST_LT; } else { *hitLoc = HL_BACK_LT; } } else if ( upSide > -3 && mod == MOD_SABER ) { *hitLoc = HL_HEAD; } else if ( frontSide > 0 ) { *hitLoc = HL_CHEST; } else { *hitLoc = HL_BACK; } } } } else if ( !Q_strncmp( "head", surfName, 4 ) ) { *hitLoc = HL_HEAD; } else if ( !Q_strncmp( "r_arm", surfName, 5 ) ) { *hitLoc = HL_ARM_RT; if ( ent->client != NULL && ent->ghoul2 ) { mdxaBone_t boltMatrix; vec3_t tagOrg, angles; VectorSet( angles, 0, ent->r.currentAngles[YAW], 0 ); if (handRBolt>=0) { trap_G2API_GetBoltMatrix( ent->ghoul2, 0, handRBolt, &boltMatrix, angles, ent->r.currentOrigin, actualTime, NULL, ent->modelScale ); BG_GiveMeVectorFromMatrix( &boltMatrix, ORIGIN, tagOrg ); if ( DistanceSquared( point, tagOrg ) < 256 ) {//actually hit the hand *hitLoc = HL_HAND_RT; } } } } else if ( !Q_strncmp( "l_arm", surfName, 5 ) ) { *hitLoc = HL_ARM_LT; if ( ent->client != NULL && ent->ghoul2 ) { mdxaBone_t boltMatrix; vec3_t tagOrg, angles; VectorSet( angles, 0, ent->r.currentAngles[YAW], 0 ); if (handLBolt>=0) { trap_G2API_GetBoltMatrix( ent->ghoul2, 0, handLBolt, &boltMatrix, angles, ent->r.currentOrigin, actualTime, NULL, ent->modelScale ); BG_GiveMeVectorFromMatrix( &boltMatrix, ORIGIN, tagOrg ); if ( DistanceSquared( point, tagOrg ) < 256 ) {//actually hit the hand *hitLoc = HL_HAND_LT; } } } } else if ( !Q_strncmp( "r_leg", surfName, 5 ) ) { *hitLoc = HL_LEG_RT; if ( ent->client != NULL && ent->ghoul2 ) { mdxaBone_t boltMatrix; vec3_t tagOrg, angles; VectorSet( angles, 0, ent->r.currentAngles[YAW], 0 ); if (footRBolt>=0) { trap_G2API_GetBoltMatrix( ent->ghoul2, 0, footRBolt, &boltMatrix, angles, ent->r.currentOrigin, actualTime, NULL, ent->modelScale ); BG_GiveMeVectorFromMatrix( &boltMatrix, ORIGIN, tagOrg ); if ( DistanceSquared( point, tagOrg ) < 100 ) {//actually hit the foot *hitLoc = HL_FOOT_RT; } } } } else if ( !Q_strncmp( "l_leg", surfName, 5 ) ) { *hitLoc = HL_LEG_LT; if ( ent->client != NULL && ent->ghoul2 ) { mdxaBone_t boltMatrix; vec3_t tagOrg, angles; VectorSet( angles, 0, ent->r.currentAngles[YAW], 0 ); if (footLBolt>=0) { trap_G2API_GetBoltMatrix( ent->ghoul2, 0, footLBolt, &boltMatrix, angles, ent->r.currentOrigin, actualTime, NULL, ent->modelScale ); BG_GiveMeVectorFromMatrix( &boltMatrix, ORIGIN, tagOrg ); if ( DistanceSquared( point, tagOrg ) < 100 ) {//actually hit the foot *hitLoc = HL_FOOT_LT; } } } } else if ( !Q_strncmp( "r_hand", surfName, 6 ) || !Q_strncmp( "w_", surfName, 2 ) ) {//right hand or weapon *hitLoc = HL_HAND_RT; } else if ( !Q_strncmp( "l_hand", surfName, 6 ) ) { *hitLoc = HL_HAND_LT; } //[CoOp] //added force_shield as a hit area else if ( ent->flags&FL_SHIELDED && !Q_stricmp( "force_shield", surfName ) ) { *hitLoc = HL_GENERIC2; } //[/CoOp] /* #ifdef _DEBUG else { Com_Printf( "ERROR: surface %s does not belong to any hitLocation!!!\n", surfName ); } #endif //_DEBUG */ //if ( g_dismemberment->integer >= 11381138 || !ent->client->dismembered ) if (g_dismember.integer == 100) { //full probability... if ( ent->client && ent->client->NPC_class == CLASS_PROTOCOL ) { dismember = qtrue; } //[CoOp] //ported from SP. else if ( ent->client && ent->client->NPC_class == CLASS_ASSASSIN_DROID ) { dismember = qtrue; } else if ( ent->client && ent->client->NPC_class == CLASS_SABER_DROID ) { dismember = qtrue; } //[/CoOp] else if ( dir && (dir[0] || dir[1] || dir[2]) && bladeDir && (bladeDir[0] || bladeDir[1] || bladeDir[2]) ) {//we care about direction (presumably for dismemberment) //if ( g_dismemberProbabilities->value<=0.0f||G_Dismemberable( ent, *hitLoc ) ) if (1) //Fix me? {//either we don't care about probabilties or the probability let us continue char *tagName = NULL; float aoa = 0.5f; //dir must be roughly perpendicular to the hitLoc's cap bolt switch ( *hitLoc ) { case HL_LEG_RT: tagName = "*hips_cap_r_leg"; break; case HL_LEG_LT: tagName = "*hips_cap_l_leg"; break; case HL_WAIST: tagName = "*hips_cap_torso"; aoa = 0.25f; break; case HL_CHEST_RT: case HL_ARM_RT: case HL_BACK_LT: tagName = "*torso_cap_r_arm"; break; case HL_CHEST_LT: case HL_ARM_LT: case HL_BACK_RT: tagName = "*torso_cap_l_arm"; break; case HL_HAND_RT: tagName = "*r_arm_cap_r_hand"; break; case HL_HAND_LT: tagName = "*l_arm_cap_l_hand"; break; case HL_HEAD: tagName = "*torso_cap_head"; aoa = 0.25f; break; case HL_CHEST: case HL_BACK: case HL_FOOT_RT: case HL_FOOT_LT: default: //no dismemberment possible with these, so no checks needed break; } if ( tagName ) { int tagBolt = trap_G2API_AddBolt( ent->ghoul2, 0, tagName ); if ( tagBolt != -1 ) { mdxaBone_t boltMatrix; vec3_t tagOrg, tagDir, angles; VectorSet( angles, 0, ent->r.currentAngles[YAW], 0 ); trap_G2API_GetBoltMatrix( ent->ghoul2, 0, tagBolt, &boltMatrix, angles, ent->r.currentOrigin, actualTime, NULL, ent->modelScale ); BG_GiveMeVectorFromMatrix( &boltMatrix, ORIGIN, tagOrg ); BG_GiveMeVectorFromMatrix( &boltMatrix, NEGATIVE_Y, tagDir ); if ( DistanceSquared( point, tagOrg ) < 256 ) {//hit close float dot = DotProduct( dir, tagDir ); if ( dot < aoa && dot > -aoa ) {//hit roughly perpendicular dot = DotProduct( bladeDir, tagDir ); if ( dot < aoa && dot > -aoa ) {//blade was roughly perpendicular dismember = qtrue; } } } } } } } else { //hmm, no direction supplied. dismember = qtrue; } } return dismember; } void G_CheckForDismemberment(gentity_t *ent, gentity_t *enemy, vec3_t point, int damage, int deathAnim, qboolean postDeath) { int hitLoc = -1, hitLocUse = -1; vec3_t boltPoint; int dismember = g_dismember.integer; if (ent->localAnimIndex > 1) { if (!ent->NPC) { return; } if (ent->client->NPC_class != CLASS_PROTOCOL) { //this is the only non-humanoid allowed to do dismemberment. return; } } if (!dismember) { return; } if (gGAvoidDismember == 1) { return; } if (gGAvoidDismember != 2) { //this means do the dismemberment regardless of randomness and damage if (Q_irand(0, 100) > dismember) { return; } if (damage < 5) { return; } } if (gGAvoidDismember == 2) { hitLoc = HL_HAND_RT; } else { //[BUGFIX12] if (d_saberGhoul2Collision.integer && ent->client && ent->client->g2LastSurfaceTime == level.time && ent->client->g2LastSurfaceModel == G2MODEL_PLAYER) //if (d_saberGhoul2Collision.integer && ent->client && ent->client->g2LastSurfaceTime == level.time) //[/BUGFIX12] { char hitSurface[MAX_QPATH]; trap_G2API_GetSurfaceName(ent->ghoul2, ent->client->g2LastSurfaceHit, 0, hitSurface); if (hitSurface[0]) { G_GetHitLocFromSurfName(ent, hitSurface, &hitLoc, point, vec3_origin, vec3_origin, MOD_UNKNOWN); } } if (hitLoc == -1) { hitLoc = G_GetHitLocation( ent, point ); } } switch(hitLoc) { case HL_FOOT_RT: case HL_LEG_RT: hitLocUse = G2_MODELPART_RLEG; break; case HL_FOOT_LT: case HL_LEG_LT: hitLocUse = G2_MODELPART_LLEG; break; case HL_WAIST: hitLocUse = G2_MODELPART_WAIST; break; /* case HL_BACK_RT: case HL_BACK_LT: case HL_BACK: case HL_CHEST_RT: case HL_CHEST_LT: case HL_CHEST: break; */ case HL_ARM_RT: hitLocUse = G2_MODELPART_RARM; break; case HL_HAND_RT: hitLocUse = G2_MODELPART_RHAND; break; case HL_ARM_LT: case HL_HAND_LT: hitLocUse = G2_MODELPART_LARM; break; case HL_HEAD: hitLocUse = G2_MODELPART_HEAD; break; default: hitLocUse = G_GetHitQuad(ent, point); break; } if (hitLocUse == -1) { return; } if (ent->client) { G_GetDismemberBolt(ent, boltPoint, hitLocUse); if ( g_austrian.integer && (g_gametype.integer == GT_DUEL || g_gametype.integer == GT_POWERDUEL) ) { G_LogPrintf( "Duel Dismemberment: %s dismembered at %s\n", ent->client->pers.netname, hitLocName[hitLoc] ); } } else { G_GetDismemberLoc(ent, boltPoint, hitLocUse); } G_Dismember(ent, enemy, boltPoint, hitLocUse, 90, 0, deathAnim, postDeath); } //[FullDismemberment] //new function for blowing up dudes thanks to Wudan for his help :) - Wahoo void G_CheckForblowingup(gentity_t *ent, gentity_t *enemy, vec3_t point, int damage, int deathAnim, qboolean postDeath) { vec3_t boltPoint; int dismember = g_dismember.integer; if (ent->localAnimIndex > 1) { if (!ent->NPC) { return; } if (ent->client->NPC_class != CLASS_PROTOCOL) { //this is the only non-humanoid allowed to do dismemberment. return; } } if (!dismember) { return; } if (gGAvoidDismember == 1) { return; } if (gGAvoidDismember != 2) { //this means do the dismemberment regardless of randomness and damage if (Q_irand(0, 100) > dismember) { return; } if (damage < 5) { return; } } G_GetDismemberBolt(ent, boltPoint, G2_MODELPART_HEAD); G_Dismember(ent, enemy, boltPoint, G2_MODELPART_HEAD, 90, 0, deathAnim, postDeath); G_GetDismemberBolt(ent, boltPoint, G2_MODELPART_LARM); G_Dismember(ent, enemy, boltPoint, G2_MODELPART_LARM, 90, 0, deathAnim, postDeath); G_GetDismemberBolt(ent, boltPoint, G2_MODELPART_RARM); G_Dismember(ent, enemy, boltPoint, G2_MODELPART_RARM, 90, 0, deathAnim, postDeath); G_GetDismemberBolt(ent, boltPoint, G2_MODELPART_LLEG); G_Dismember(ent, enemy, boltPoint, G2_MODELPART_LLEG, 90, 0, deathAnim, postDeath); G_GetDismemberBolt(ent, boltPoint, G2_MODELPART_RLEG); G_Dismember(ent, enemy, boltPoint, G2_MODELPART_RLEG, 90, 0, deathAnim, postDeath); G_GetDismemberBolt(ent, boltPoint, G2_MODELPART_WAIST); G_Dismember(ent, enemy, boltPoint, G2_MODELPART_WAIST, 90, 0, deathAnim, postDeath); } //[/FullDismemberment] void G_LocationBasedDamageModifier(gentity_t *ent, vec3_t point, int mod, int dflags, int *damage) { int hitLoc = -1; if (!g_locationBasedDamage.integer) { //then leave it alone return; } if ( (dflags&DAMAGE_NO_HIT_LOC) ) { //then leave it alone return; } if (mod == MOD_SABER && *damage <= 1) { //don't bother for idle damage return; } if (!point) { return; } if ( ent->client && ent->client->NPC_class == CLASS_VEHICLE ) {//no location-based damage on vehicles return; } //[BugFix12] if ((d_saberGhoul2Collision.integer && ent->client && ent->client->g2LastSurfaceTime == level.time && ent->client->g2LastSurfaceModel == G2MODEL_PLAYER && mod == MOD_SABER) || //using ghoul2 collision? Then if the mod is a saber we should have surface data from the last hit (unless thrown). (d_projectileGhoul2Collision.integer && ent->client && ent->client->g2LastSurfaceModel == G2MODEL_PLAYER && ent->client->g2LastSurfaceTime == level.time)) //It's safe to assume we died from the projectile that just set our surface index. So, go ahead and use that as the surf I guess. //if ((d_saberGhoul2Collision.integer && ent->client && ent->client->g2LastSurfaceTime == level.time && mod == MOD_SABER) || //using ghoul2 collision? Then if the mod is a saber we should have surface data from the last hit (unless thrown). // (d_projectileGhoul2Collision.integer && ent->client && ent->client->g2LastSurfaceTime == level.time)) //It's safe to assume we died from the projectile that just set our surface index. So, go ahead and use that as the surf I guess. //[/BugFix12] { char hitSurface[MAX_QPATH]; trap_G2API_GetSurfaceName(ent->ghoul2, ent->client->g2LastSurfaceHit, 0, hitSurface); if (hitSurface[0]) { G_GetHitLocFromSurfName(ent, hitSurface, &hitLoc, point, vec3_origin, vec3_origin, MOD_UNKNOWN); } } if (hitLoc == -1) { hitLoc = G_GetHitLocation( ent, point ); } switch (hitLoc) { case HL_FOOT_RT: case HL_FOOT_LT: *damage *= 0.5; break; case HL_LEG_RT: case HL_LEG_LT: *damage *= 0.7; break; case HL_WAIST: case HL_BACK_RT: case HL_BACK_LT: case HL_BACK: case HL_CHEST_RT: case HL_CHEST_LT: case HL_CHEST: break; //normal damage case HL_ARM_RT: case HL_ARM_LT: *damage *= 0.85; break; case HL_HAND_RT: case HL_HAND_LT: *damage *= 0.6; break; case HL_HEAD: *damage *= 1.3; break; default: break; //do nothing then } } /* =================================== rww - end dismemberment/lbd =================================== */ qboolean G_ThereIsAMaster(void) { int i = 0; gentity_t *ent; while (i < MAX_CLIENTS) { ent = &g_entities[i]; if (ent && ent->client && ent->client->ps.isJediMaster) { return qtrue; } i++; } return qfalse; } //[CoOp] extern qboolean Jedi_StopKnockdown( gentity_t *self, gentity_t *pusher, const vec3_t pushDir ); extern qboolean Boba_StopKnockdown( gentity_t *self, gentity_t *pusher, const vec3_t pushDir, qboolean forceKnockdown ); extern qboolean Rosh_BeingHealed( gentity_t *self ); extern qboolean PM_LockedAnim( int anim ); extern qboolean BG_CrouchAnim( int anim ); extern void NPC_SetPainEvent( gentity_t *self ); extern qboolean PM_InKnockDown( playerState_t *ps ); extern qboolean PM_RollingAnim( int anim ); extern qboolean BG_KnockDownAnim( int anim ); //[/CoOp] //[SaberSys] extern void BG_ReduceMishapLevel(playerState_t *ps); //[/SaberSys] //[KnockdownSys] void G_Knockdown( gentity_t *self, gentity_t *attacker, const vec3_t pushDir, float strength, qboolean breakSaberLock ) { if ( !self || !self->client ) //removed the SP requirement for an attacker since I want G_Knockdown //to work without an attacker. //if ( !self || !self->client || !attacker || !attacker->client ) { return; } if ( self->client->NPC_class == CLASS_ROCKETTROOPER ) { return; } if ( Boba_StopKnockdown( self, attacker, pushDir, qfalse ) ) { return; } else if ( Jedi_StopKnockdown( self, attacker, pushDir ) ) {//They can sometimes backflip instead of be knocked down return; } else if ( PM_LockedAnim( self->client->ps.legsAnim ) ) {//stuck doing something else return; } else if ( Rosh_BeingHealed( self ) ) { return; } //[BoostKnockdown] strength *= 3; //[/BoostKnockdown] //break out of a saberLock? if ( self->client->ps.saberLockTime > level.time ) { if ( breakSaberLock ) { self->client->ps.saberLockTime = 0; self->client->ps.saberLockEnemy = ENTITYNUM_NONE; } else { return; } } if ( self->health > 0 ) { //racc - make a pain noise whenever you're knocked down. if ( self->s.number < MAX_CLIENTS ) { NPC_SetPainEvent( self ); } else {//npc NPC_Pain( self, attacker, 0 ); //GEntity_PainFunc( self, attacker, attacker, self->currentOrigin, 0, MOD_MELEE ); SP Version } //racc - check to see if an NPC should get conventently kicked off a nearby cliff. G_CheckLedgeDive( self, 72, pushDir, qfalse, qfalse ); if ( /*!BG_SpinningSaberAnim( self->client->ps.legsAnim ) //racc - I've removed this requirement since it's over used by staffs/duals. && !BG_FlippingAnim( self->client->ps.legsAnim ) &&*/ !PM_RollingAnim( self->client->ps.legsAnim ) && !PM_InKnockDown( &self->client->ps ) ) { int knockAnim = BOTH_KNOCKDOWN1;//default knockdown /* racc - I've removed this since I want the players to have all possible knockdowns if ( self->s.number < MAX_CLIENTS && ( strength < 300 ) )//!g_spskill->integer || {//player only knocked down if pushed *hard* return; } else */if ( BG_CrouchAnim( self->client->ps.legsAnim ) ) {//crouched knockdown knockAnim = BOTH_KNOCKDOWN4; } else {//plain old knockdown vec3_t pLFwd, pLAngles; VectorSet(pLAngles, 0, self->client->ps.viewangles[YAW], 0); AngleVectors( pLAngles, pLFwd, NULL, NULL ); if ( DotProduct( pLFwd, pushDir ) > 0.2f ) {//pushing him from behind knockAnim = BOTH_KNOCKDOWN3; } else {//pushing him from front knockAnim = BOTH_KNOCKDOWN1; } } if ( knockAnim == BOTH_KNOCKDOWN1 && strength > 150 ) {//push *hard* knockAnim = BOTH_KNOCKDOWN2; } if(self->client->pushEffectTime >= level.time) { int rand = Q_irand(1,3); switch(rand) { case 1: knockAnim=BOTH_DEATH8; break; case 2: knockAnim=BOTH_DEATH6; break; case 3: knockAnim=BOTH_DEATH5; break; } self->client->ps.legsTimer += 1000; self->client->ps.torsoTimer += 1000; } NPC_SetAnim( self, SETANIM_BOTH, knockAnim, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD ); if ( self->s.number >= MAX_CLIENTS ) {//randomize getup times int addTime = Q_irand( -200, 200 ); self->client->ps.legsTimer += addTime; self->client->ps.torsoTimer += addTime; } else {//player holds extra long so you have more time to decide to do the quick getup if ( BG_KnockDownAnim( self->client->ps.legsAnim ) ) { self->client->ps.legsTimer += PLAYER_KNOCKDOWN_HOLD_EXTRA_TIME; self->client->ps.torsoTimer += PLAYER_KNOCKDOWN_HOLD_EXTRA_TIME; } } //[SaberSys] //bump our MP level down. BG_ReduceMishapLevel(&self->client->ps); //[/SaberSys] } } } /* basejka version void G_Knockdown( gentity_t *victim ) { //[CoOp] //RAFIXME: This is a hack to get this to work. We really need to go back and //make knockdown directional again. for now, assume that the knockdown is always //trying to knock them backwards. vec3_t ang, fwd; VectorSet(ang, 0, victim->r.currentAngles[YAW], 0); AngleVectors( ang, fwd, NULL, NULL ); VectorScale(ang, -1, ang); if ( !victim || !victim->client ) { return; } if ( victim->client->NPC_class == CLASS_ROCKETTROOPER ) { return; } if ( Boba_StopKnockdown( victim, NULL, fwd, qfalse ) ) {//Boba Fett handles knockdown specially return; } else if ( Jedi_StopKnockdown( victim, NULL, fwd ) ) {//Jedi can sometimes backflip instead of be knocked down return; } else if ( PM_LockedAnim( victim->client->ps.legsAnim ) ) {//stuck doing something else return; } else if ( Rosh_BeingHealed( victim ) ) {//rosh in heal mode can't be knocked down. return; } //[/CoOp] if ( victim && victim->client && BG_KnockDownable(&victim->client->ps) ) { victim->client->ps.forceHandExtend = HANDEXTEND_KNOCKDOWN; victim->client->ps.forceDodgeAnim = 0; victim->client->ps.forceHandExtendTime = level.time + 1100; victim->client->ps.quickerGetup = qfalse; } } */ //[/KnockdownSys] //[Asteroids] void G_ApplyVehicleOtherKiller( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, int mod, qboolean vehicleDying ) { if ( targ && targ->client && attacker ) { if ( targ->client->ps.otherKillerDebounceTime > level.time ) {//wait a minute, I already have a last damager if ( targ->health < 0 || (targ->m_pVehicle && targ->m_pVehicle->m_iRemovedSurfaces) ) {//already dying? don't let credit transfer to anyone else return; } //otherwise, still alive, so, fine, use this damager... } targ->client->ps.otherKiller = attacker->s.number; targ->client->ps.otherKillerTime = level.time + 25000; targ->client->ps.otherKillerDebounceTime = level.time + 25000; targ->client->otherKillerMOD = mod; if ( inflictor && !Q_stricmp( "vehicle_proj", inflictor->classname ) ) { targ->client->otherKillerVehWeapon = inflictor->s.otherEntityNum2+1; targ->client->otherKillerWeaponType = inflictor->s.weapon; } else { targ->client->otherKillerVehWeapon = 0; targ->client->otherKillerWeaponType = WP_NONE; } if ( vehicleDying ) { //propogate otherkiller down to pilot and passengers so that proper credit is given if they suicide or eject... if ( targ->m_pVehicle ) { int passNum; if ( targ->m_pVehicle->m_pPilot ) { gentity_t *pilot = &g_entities[targ->m_pVehicle->m_pPilot->s.number]; if ( pilot->client ) { pilot->client->ps.otherKiller = targ->client->ps.otherKiller; pilot->client->ps.otherKillerTime = targ->client->ps.otherKillerTime; pilot->client->ps.otherKillerDebounceTime = targ->client->ps.otherKillerDebounceTime; pilot->client->otherKillerMOD = targ->client->otherKillerMOD; pilot->client->otherKillerVehWeapon = targ->client->otherKillerVehWeapon; pilot->client->otherKillerWeaponType = targ->client->otherKillerWeaponType; } } for ( passNum = 0; passNum < targ->m_pVehicle->m_iNumPassengers; passNum++ ) { gentity_t *pass = &g_entities[targ->m_pVehicle->m_ppPassengers[passNum]->s.number]; if ( pass->client ) { pass->client->ps.otherKiller = targ->client->ps.otherKiller; pass->client->ps.otherKillerTime = targ->client->ps.otherKillerTime; pass->client->ps.otherKillerDebounceTime = targ->client->ps.otherKillerDebounceTime; pass->client->otherKillerMOD = targ->client->otherKillerMOD; pass->client->otherKillerVehWeapon = targ->client->otherKillerVehWeapon; pass->client->otherKillerWeaponType = targ->client->otherKillerWeaponType; } } } } } } qboolean G_CheckVehicleNPCTeamDamage( gentity_t *ent ) { //NOTE: this covers both the vehicle and NPCs riding vehicles (droids) if ( !ent || ent->s.number < MAX_CLIENTS || ent->s.eType != ET_NPC ) {//not valid or a real client or not an NPC return qfalse; } if ( ent->s.NPC_class != CLASS_VEHICLE ) {//regualar NPC if ( ent->s.m_iVehicleNum ) {//an NPC in a vehicle, check for team damage return qtrue; } } return qfalse; } //[/Asteroids] /* ============ T_Damage targ entity that is being damaged inflictor entity that is causing the damage attacker entity that caused the inflictor to damage targ example: targ=monster, inflictor=rocket, attacker=player dir direction of the attack for knockback point point at which the damage is being inflicted, used for headshots damage amount of damage being inflicted knockback force to be applied against targ as a result of the damage inflictor, attacker, dir, and point can be NULL for environmental effects dflags these flags are used to control how T_Damage works DAMAGE_RADIUS damage was indirect (from a nearby explosion) DAMAGE_NO_ARMOR armor does not protect from this damage DAMAGE_NO_KNOCKBACK do not affect velocity, just view angles DAMAGE_NO_PROTECTION kills godmode, armor, everything DAMAGE_HALF_ABSORB half shields, half health DAMAGE_HALF_ARMOR_REDUCTION Any damage that shields incur is halved ============ */ extern qboolean gSiegeRoundBegun; int gPainMOD = 0; int gPainHitLoc = -1; vec3_t gPainPoint; //[CloakingVehicles] extern void G_ToggleVehicleCloak(playerState_t *ps); //[/CloakingVehicles] extern qboolean ButterFingers(gentity_t *saberent, gentity_t *saberOwner, gentity_t *other, trace_t *tr); void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, vec3_t dir, vec3_t point, int damage, int dflags, int mod ) { gclient_t *client; int take; int save; int asave; int knockback; int max; int subamt = 0; float famt = 0; float hamt = 0; float shieldAbsorbed = 0; if (targ && targ->client && (targ->client->ps.eFlags & EF_INVULNERABLE)) { return; } if((mod == MOD_REPEATER_ALT || mod == MOD_REPEATER_ALT_SPLASH) && targ && targ->client) {//Don't really like putting this here, move it later G_DodgeDrain(targ,attacker,Q_irand(2,5)); G_Throw(targ,dir,2); //targ->client->ps.velocity[2] += 5; return; } if (targ && targ->damageRedirect) { G_Damage(&g_entities[targ->damageRedirectTo], inflictor, attacker, dir, point, damage, dflags, mod); return; } if(mod != MOD_STUN_BATON && mod != MOD_UNKNOWN && mod != MOD_MELEE && mod != MOD_SABER && mod != MOD_VEHICLE && mod != MOD_WATER && mod != MOD_SLIME && mod != MOD_LAVA && mod != MOD_CRUSH && mod != MOD_TELEFRAG && mod != MOD_FALLING) { if(targ && attacker && attacker->client && targ->client && targ->client->ps.fd.forceGripEntityNum == attacker->client->ps.clientNum) WP_ForcePowerStop(targ,FP_GRIP); } if (mod == MOD_DEMP2 && targ && targ->inuse && targ->client) { if ( targ->client->ps.electrifyTime < level.time ) {//electrocution effect if (targ->s.eType == ET_NPC && targ->s.NPC_class == CLASS_VEHICLE && targ->m_pVehicle && (targ->m_pVehicle->m_pVehicleInfo->type == VH_SPEEDER || targ->m_pVehicle->m_pVehicleInfo->type == VH_WALKER)) { //do some extra stuff to speeders/walkers targ->client->ps.electrifyTime = level.time + Q_irand( 3000, 4000 ); } else if ( targ->s.NPC_class != CLASS_VEHICLE || (targ->m_pVehicle && targ->m_pVehicle->m_pVehicleInfo->type != VH_FIGHTER) ) {//don't do this to fighters targ->client->ps.electrifyTime = level.time + Q_irand( 300, 800 ); } } } if (g_gametype.integer == GT_SIEGE && !gSiegeRoundBegun) { //nothing can be damaged til the round starts. return; } //[BryarSecondary] if ( (mod == MOD_BRYAR_PISTOL_ALT || mod == MOD_SEEKER) && targ && targ->inuse && targ->client ) {//doesn't do actual damage to the target, instead it acts like a stun hit that increases MP/DP and tries to knock //the player over like a kick. //int mpDamage = (float) inflictor->s.generic1/BRYAR_MAX_CHARGE*MISHAPLEVEL_MAX; int mpDamage = (float) inflictor->s.generic1/BRYAR_MAX_CHARGE*7; //deal DP damage if(mod != MOD_SEEKER) { G_DodgeDrain(targ, attacker, damage); } G_Printf("%i: %i: Bryar MP Damage %i, Charge %i\n", level.time, targ->s.number, mpDamage, inflictor->s.generic1); targ->client->ps.saberAttackChainCount += mpDamage; if ((targ->client->ps.saberAttackChainCount >= MISHAPLEVEL_HEAVY || targ->client->ps.stats[STAT_DODGE] <= DODGE_CRITICALLEVEL)) {//knockdown vec3_t blowBackDir; VectorSubtract(targ->client->ps.origin,attacker->client->ps.origin, blowBackDir); G_Throw(targ,blowBackDir,4); if ( targ->client->ps.saberAttackChainCount >= MISHAPLEVEL_FULL ) { G_Knockdown( targ, attacker, dir, 300, qtrue ); } else { G_Knockdown( targ, attacker, dir, 100, qtrue ); } } else if(targ->client->ps.saberAttackChainCount >= MISHAPLEVEL_LIGHT) {//stumble vec3_t blowBackDir; VectorSubtract(targ->client->ps.origin,attacker->client->ps.origin, blowBackDir); G_Throw(targ,blowBackDir,2); AnimateStun(targ, attacker, point); BG_ReduceMishapLevel(&targ->client->ps); } targ->client->ps.electrifyTime = level.time + Q_irand( 300, 800 ); return; } //[/BryarSecondary] if (!targ->takedamage) { return; } //ROP VEHICLE_IMP START if ( ((targ->flags&FL_SHIELDED) || (targ->s.NPC_class == CLASS_VEHICLE && targ->m_pVehicle && !targ->m_pVehicle->m_pVehicleInfo->AllWeaponsDoDamageToShields && targ->client->ps.stats[STAT_ARMOR] > 0) ) && mod != MOD_SABER && !targ->client) //if ( (targ->flags&FL_SHIELDED) && mod != MOD_SABER && !targ->client) {//magnetically protected, this thing can only be damaged by lightsabers return; } //ROP VEHICLE_IMP END if ((targ->flags & FL_DMG_BY_SABER_ONLY) && mod != MOD_SABER) { //saber-only damage return; } if ( targ->client ) {//don't take damage when in a walker, or fighter //unless the walker/fighter is dead!!! -rww if ( targ->client->ps.clientNum < MAX_CLIENTS && targ->client->ps.m_iVehicleNum ) { gentity_t *veh = &g_entities[targ->client->ps.m_iVehicleNum]; if ( veh->m_pVehicle && veh->health > 0 ) { if ( veh->m_pVehicle->m_pVehicleInfo->type == VH_WALKER || veh->m_pVehicle->m_pVehicleInfo->type == VH_FIGHTER) { if (!(dflags & DAMAGE_NO_PROTECTION)) { return; } } } } } if ((targ->flags & FL_DMG_BY_HEAVY_WEAP_ONLY)) { //only take damage from explosives and such if (mod != MOD_REPEATER_ALT && mod != MOD_ROCKET && mod != MOD_FLECHETTE_ALT_SPLASH && mod != MOD_ROCKET_HOMING && mod != MOD_THERMAL && mod != MOD_THERMAL_SPLASH && mod != MOD_TRIP_MINE_SPLASH && mod != MOD_TIMED_MINE_SPLASH && mod != MOD_DET_PACK_SPLASH && mod != MOD_VEHICLE && mod != MOD_CONC && mod != MOD_CONC_ALT && mod != MOD_SABER && mod != MOD_TURBLAST && //[Asteroids] mod != MOD_TARGET_LASER && mod != MOD_SUICIDE && mod != MOD_FALLING && mod != MOD_CRUSH && mod != MOD_TELEFRAG && mod != MOD_COLLISION && mod != MOD_VEH_EXPLOSION && //[/Asteroids] mod != MOD_TRIGGER_HURT) { if ( mod != MOD_MELEE || !G_HeavyMelee( attacker ) ) { //let classes with heavy melee ability damage heavy wpn dmg doors with fists return; } } } if (targ->flags & FL_BBRUSH) { if (mod == MOD_DEMP2 || mod == MOD_DEMP2_ALT || mod == MOD_BRYAR_PISTOL || mod == MOD_BRYAR_PISTOL_ALT || mod == MOD_MELEE) { //these don't damage bbrushes.. ever if ( mod != MOD_MELEE || !G_HeavyMelee( attacker ) ) { //let classes with heavy melee ability damage breakable brushes with fists return; } } } if (targ && targ->client && targ->client->ps.duelInProgress) { if (attacker && attacker->client && attacker->s.number != targ->client->ps.duelIndex) { return; } else if (attacker && attacker->client && mod != MOD_SABER) { return; } } if (attacker && attacker->client && attacker->client->ps.duelInProgress) { if (targ && targ->client && targ->s.number != attacker->client->ps.duelIndex) { return; } else if (targ && targ->client && mod != MOD_SABER) { return; } } if ( !(dflags & DAMAGE_NO_PROTECTION) ) {//rage overridden by no_protection if (targ && targ->client && (targ->client->ps.fd.forcePowersActive & (1 << FP_RAGE))) { damage *= 0.5; } } // the intermission has allready been qualified for, so don't // allow any extra scoring if ( level.intermissionQueued ) { return; } if ( !inflictor ) { inflictor = &g_entities[ENTITYNUM_WORLD]; } if ( !attacker ) { attacker = &g_entities[ENTITYNUM_WORLD]; } // shootable doors / buttons don't actually have any health //if genericValue4 == 1 then it's glass or a breakable and those do have health if ( targ->s.eType == ET_MOVER && targ->genericValue4 != 1 ) { if ( targ->use && targ->moverState == MOVER_POS1 ) { GlobalUse( targ, inflictor, attacker ); } return; } // reduce damage by the attacker's handicap value // unless they are rocket jumping if ( attacker->client && attacker != targ && attacker->s.eType == ET_PLAYER && g_gametype.integer != GT_SIEGE ) { max = attacker->client->ps.stats[STAT_MAX_HEALTH]; damage = damage * max / 100; } if ( !(dflags&DAMAGE_NO_HIT_LOC) ) {//see if we should modify it by damage location if (targ->inuse && (targ->client || targ->s.eType == ET_NPC) && attacker->inuse && (attacker->client || attacker->s.eType == ET_NPC)) { //check for location based damage stuff. G_LocationBasedDamageModifier(targ, point, mod, dflags, &damage); } } if ( targ->client && targ->client->NPC_class == CLASS_RANCOR && (!attacker||!attacker->client||attacker->client->NPC_class!=CLASS_RANCOR) ) { // I guess always do 10 points of damage...feel free to tweak as needed if ( damage < 10 ) {//ignore piddly little damage damage = 0; } else if ( damage >= 10 ) { damage = 10; } } client = targ->client; if ( client ) { if ( client->noclip ) { return; } } if ( !dir ) { dflags |= DAMAGE_NO_KNOCKBACK; } else { VectorNormalize(dir); } knockback = damage; if ( knockback > 200 ) { knockback = 200; } if ( targ->flags & FL_NO_KNOCKBACK ) { knockback = 0; } if ( dflags & DAMAGE_NO_KNOCKBACK ) { knockback = 0; } if(targ->client && (targ->client->ps.stats[STAT_HEALTH]-damage) < 1) knockback *=2.5; // figure momentum add, even if the damage won't be taken if ( knockback && targ->client ) { vec3_t kvel; float mass; mass = 200; if (mod == MOD_SABER) { float saberKnockbackScale = g_saberDmgVelocityScale.value; if ( (dflags&DAMAGE_SABER_KNOCKBACK1) || (dflags&DAMAGE_SABER_KNOCKBACK2) ) {//saber does knockback, scale it by the right number if ( !saberKnockbackScale ) { saberKnockbackScale = 1.0f; } if ( attacker && attacker->client ) { if ( (dflags&DAMAGE_SABER_KNOCKBACK1) ) { if ( attacker && attacker->client ) { saberKnockbackScale *= attacker->client->saber[0].knockbackScale; } } if ( (dflags&DAMAGE_SABER_KNOCKBACK1_B2) ) { if ( attacker && attacker->client ) { saberKnockbackScale *= attacker->client->saber[0].knockbackScale2; } } if ( (dflags&DAMAGE_SABER_KNOCKBACK2) ) { if ( attacker && attacker->client ) { saberKnockbackScale *= attacker->client->saber[1].knockbackScale; } } if ( (dflags&DAMAGE_SABER_KNOCKBACK2_B2) ) { if ( attacker && attacker->client ) { saberKnockbackScale *= attacker->client->saber[1].knockbackScale2; } } } } VectorScale (dir, (g_knockback.value * (float)knockback / mass)*saberKnockbackScale, kvel); } else { VectorScale (dir, g_knockback.value * (float)knockback / mass, kvel); } VectorAdd (targ->client->ps.velocity, kvel, targ->client->ps.velocity); //[Asteroids] //moved this stuff down a bit. /* if (attacker && attacker->client && attacker != targ) { float dur = 5000; float dur2 = 100; if (targ->client && targ->s.eType == ET_NPC && targ->s.NPC_class == CLASS_VEHICLE) { dur = 25000; dur2 = 25000; } targ->client->ps.otherKiller = attacker->s.number; targ->client->ps.otherKillerTime = level.time + dur; targ->client->ps.otherKillerDebounceTime = level.time + dur2; } */ //[/Asteroids] // set the timer so that the other client can't cancel // out the movement immediately if ( !targ->client->ps.pm_time && (g_saberDmgVelocityScale.integer || mod != MOD_SABER || (dflags&DAMAGE_SABER_KNOCKBACK1) || (dflags&DAMAGE_SABER_KNOCKBACK2) || (dflags&DAMAGE_SABER_KNOCKBACK1_B2) || (dflags&DAMAGE_SABER_KNOCKBACK2_B2) ) ) { int t; t = knockback * 2; if ( t < 50 ) { t = 50; } if ( t > 200 ) { t = 200; } targ->client->ps.pm_time = t; targ->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; } } //[Asteroids] /* else if (targ->client && targ->s.eType == ET_NPC && targ->s.NPC_class == CLASS_VEHICLE && attacker != targ) { targ->client->ps.otherKiller = attacker->s.number; targ->client->ps.otherKillerTime = level.time + 25000; targ->client->ps.otherKillerDebounceTime = level.time + 25000; } */ //[/Asteroids] if ( (g_trueJedi.integer || g_gametype.integer == GT_SIEGE) && client ) {//less explosive damage for jedi, more saber damage for non-jedi if ( client->ps.trueJedi || (g_gametype.integer == GT_SIEGE&&client->ps.weapon == WP_SABER)) {//if the target is a trueJedi, reduce splash and explosive damage to 1/2 switch ( mod ) { case MOD_REPEATER_ALT: case MOD_REPEATER_ALT_SPLASH: case MOD_DEMP2_ALT: case MOD_FLECHETTE_ALT_SPLASH: case MOD_ROCKET: case MOD_ROCKET_SPLASH: case MOD_ROCKET_HOMING: case MOD_ROCKET_HOMING_SPLASH: case MOD_THERMAL: case MOD_THERMAL_SPLASH: case MOD_TRIP_MINE_SPLASH: case MOD_TIMED_MINE_SPLASH: case MOD_DET_PACK_SPLASH: damage *= 0.75; break; } } else if ( (client->ps.trueNonJedi || (g_gametype.integer == GT_SIEGE&&client->ps.weapon != WP_SABER)) && mod == MOD_SABER ) {//if the target is a trueNonJedi, take more saber damage... combined with the 1.5 in the w_saber stuff, this is 6 times damage! if ( damage < 100 ) { damage *= 4; if ( damage > 100 ) { damage = 100; } } } } if (attacker->client && targ->client && g_gametype.integer == GT_SIEGE && targ->client->siegeClass != -1 && (bgSiegeClasses[targ->client->siegeClass].classflags & (1<<CFL_STRONGAGAINSTPHYSICAL))) { //this class is flagged to take less damage from physical attacks. //For now I'm just decreasing against any client-based attack, this can be changed later I guess. damage *= 0.5; } // check for completely getting out of the damage if ( !(dflags & DAMAGE_NO_PROTECTION) ) { // if TF_NO_FRIENDLY_FIRE is set, don't do damage to the target // if the attacker was on the same team if ( targ != attacker) { if (OnSameTeam (targ, attacker)) { if ( !g_friendlyFire.integer ) { return; } } else if (attacker && attacker->inuse && !attacker->client && attacker->activator && targ != attacker->activator && attacker->activator->inuse && attacker->activator->client) { //emplaced guns don't hurt teammates of user if (OnSameTeam (targ, attacker->activator)) { if ( !g_friendlyFire.integer ) { return; } } } else if (targ->inuse && targ->client && g_gametype.integer >= GT_TEAM && attacker->s.number >= MAX_CLIENTS && attacker->alliedTeam && targ->client->sess.sessionTeam == attacker->alliedTeam && !g_friendlyFire.integer) { //things allied with my team should't hurt me.. I guess return; } } if (g_gametype.integer == GT_JEDIMASTER && !g_friendlyFire.integer && targ && targ->client && attacker && attacker->client && targ != attacker && !targ->client->ps.isJediMaster && !attacker->client->ps.isJediMaster && G_ThereIsAMaster()) { return; } if (targ->s.number >= MAX_CLIENTS && targ->client && targ->s.shouldtarget && targ->s.teamowner && attacker && attacker->inuse && attacker->client && targ->s.owner >= 0 && targ->s.owner < MAX_CLIENTS) { gentity_t *targown = &g_entities[targ->s.owner]; if (targown && targown->inuse && targown->client && OnSameTeam(targown, attacker)) { if (!g_friendlyFire.integer) { return; } } } // check for godmode if ( (targ->flags & FL_GODMODE) && targ->s.eType != ET_NPC ) { return; } } //check for teamnodmg //NOTE: non-client objects hitting clients (and clients hitting clients) purposely doesn't obey this teamnodmg (for emplaced guns) if ( attacker && !targ->client ) {//attacker hit a non-client if ( g_gametype.integer == GT_SIEGE && !g_ff_objectives.integer ) {//in siege mode (and...?) if ( targ->teamnodmg ) {//targ shouldn't take damage from a certain team if ( attacker->client ) {//a client hit a non-client object if ( targ->teamnodmg == attacker->client->sess.sessionTeam ) { return; } } else if ( attacker->teamnodmg ) {//a non-client hit a non-client object //FIXME: maybe check alliedTeam instead? if ( targ->teamnodmg == attacker->teamnodmg ) { if (attacker->activator && attacker->activator->inuse && attacker->activator->s.number < MAX_CLIENTS && attacker->activator->client && attacker->activator->client->sess.sessionTeam != targ->teamnodmg) { //uh, let them damage it I guess. } else { return; } } } } } } // battlesuit protects from all radius damage (but takes knockback) // and protects 50% against all damage if ( client && client->ps.powerups[PW_BATTLESUIT] ) { G_AddEvent( targ, EV_POWERUP_BATTLESUIT, 0 ); if ( ( dflags & DAMAGE_RADIUS ) || ( mod == MOD_FALLING ) ) { return; } damage *= 0.5; } // add to the attacker's hit counter (if the target isn't a general entity like a prox mine) if ( attacker->client && targ != attacker && targ->health > 0 && targ->s.eType != ET_MISSILE && targ->s.eType != ET_GENERAL && client) { if ( OnSameTeam( targ, attacker ) ) { attacker->client->ps.persistant[PERS_HITS]--; } else { attacker->client->ps.persistant[PERS_HITS]++; } attacker->client->ps.persistant[PERS_ATTACKEE_ARMOR] = (targ->health<<8)|(client->ps.stats[STAT_ARMOR]); } //[ExpSys] //don't do this since it allows players to rocket themselves to hurt you! /* basejka code // always give half damage if hurting self... but not in siege. Heavy weapons need a counter. // calculated after knockback, so rocket jumping works if ( targ == attacker && !(dflags & DAMAGE_NO_SELF_PROTECTION)) { if ( g_gametype.integer == GT_SIEGE ) { damage *= 1.5; } else { damage *= 0.5; } } */ //[/ExpSys] if ( damage < 1 ) { damage = 1; } //[Asteroids] //store the attacker as the potential killer in case we die by other means if ( targ->client && attacker && attacker != targ ) { if ( targ->s.eType == ET_NPC && targ->s.NPC_class == CLASS_VEHICLE) {//vehicle G_ApplyVehicleOtherKiller( targ, inflictor, attacker, mod, qfalse ); } else {//other client targ->client->ps.otherKiller = attacker->s.number; targ->client->ps.otherKillerTime = level.time + 5000; targ->client->ps.otherKillerDebounceTime = level.time + 100; targ->client->otherKillerMOD = mod; targ->client->otherKillerVehWeapon = 0; targ->client->otherKillerWeaponType = WP_NONE; } } //[/Asteroids] take = damage; save = 0; // save some from armor //[CoOp] //needed MOD for assassin droid shield handling asave = CheckArmor (targ, take, dflags, mod); //asave = CheckArmor (targ, take, dflags); //[/CoOp] //[NewShield] if(targ->client) { int previousArmor = targ->client->ps.stats[STAT_ARMOR]; targ->client->ps.stats[STAT_ARMOR] -= damage; if (targ->client->ps.stats[STAT_ARMOR]<0) { targ->client->ps.stats[STAT_ARMOR] = 0; } asave = (previousArmor - client->ps.stats[STAT_ARMOR]); } if(targ->client && targ->client->ps.stats[STAT_ARMOR] > 0) return; //[/NewShield] if (asave) { shieldAbsorbed = asave; } take -= asave; if ( targ->client ) {//update vehicle shields and armor, check for explode if ( targ->client->NPC_class == CLASS_VEHICLE && targ->m_pVehicle ) {//FIXME: should be in its own function in g_vehicles.c now, too big to be here int surface = -1; if ( attacker ) {//so we know the last guy who shot at us targ->enemy = attacker; } if ( ( targ->m_pVehicle->m_pVehicleInfo->type == VH_ANIMAL ) ) { //((CVehicleNPC *)targ->NPC)->m_ulFlags |= CVehicleNPC::VEH_BUCKING; } targ->m_pVehicle->m_iShields = targ->client->ps.stats[STAT_ARMOR]; G_VehUpdateShields( targ ); targ->m_pVehicle->m_iArmor -= take; if ( targ->m_pVehicle->m_iArmor <= 0 ) { targ->s.eFlags |= EF_DEAD; targ->client->ps.eFlags |= EF_DEAD; targ->m_pVehicle->m_iArmor = 0; } //[CloakingVehicles] else if(targ->m_pVehicle->m_pVehicleInfo->CloakingDevice && take > .2 * targ->m_pVehicle->m_pVehicleInfo->armor && targ->client->ps.powerups[PW_CLOAKED]) {//took more than %20 of our max health in damage, decloak G_ToggleVehicleCloak(&targ->client->ps); } //[/CloakingVehicles] if ( targ->m_pVehicle->m_pVehicleInfo->type == VH_FIGHTER ) {//get the last surf that was hit //[BugFix12] //racc - I'm still adding in the model index check incase there's another //model attached (like a pilot or something if ( targ->client && targ->client->g2LastSurfaceModel == G2MODEL_PLAYER && targ->client->g2LastSurfaceTime == level.time ) //if ( targ->client && targ->client->g2LastSurfaceTime == level.time) //[/BugFix12] { char hitSurface[MAX_QPATH]; trap_G2API_GetSurfaceName(targ->ghoul2, targ->client->g2LastSurfaceHit, 0, hitSurface); if (hitSurface[0]) { surface = G_ShipSurfaceForSurfName( &hitSurface[0] ); if ( take && surface > 0 ) {//hit a certain part of the ship int deathPoint = 0; targ->locationDamage[surface] += take; switch(surface) { case SHIPSURF_FRONT: deathPoint = targ->m_pVehicle->m_pVehicleInfo->health_front; break; case SHIPSURF_BACK: deathPoint = targ->m_pVehicle->m_pVehicleInfo->health_back; break; case SHIPSURF_RIGHT: deathPoint = targ->m_pVehicle->m_pVehicleInfo->health_right; break; case SHIPSURF_LEFT: deathPoint = targ->m_pVehicle->m_pVehicleInfo->health_left; break; default: break; } //presume 0 means it wasn't set and so it should never die. if ( deathPoint ) { if ( targ->locationDamage[surface] >= deathPoint) { //this area of the ship is now dead //[Asteroids] qboolean wasDying = (qboolean)(targ->m_pVehicle->m_iRemovedSurfaces!=0); if ( G_FlyVehicleDestroySurface( targ, surface ) ) {//actually took off a surface G_VehicleSetDamageLocFlags( targ, surface, deathPoint ); if ( !wasDying ) {//always take credit for kill if they were healthy before targ->client->ps.otherKillerDebounceTime = 0; } G_ApplyVehicleOtherKiller( targ, inflictor, attacker, mod, qtrue ); //[/Asteroids] } } else { G_VehicleSetDamageLocFlags( targ, surface, deathPoint ); } } } } } } if ( targ->m_pVehicle->m_pVehicleInfo->type != VH_ANIMAL ) { /* if ( targ->m_pVehicle->m_iArmor <= 0 ) {//vehicle all out of armor Vehicle_t *pVeh = targ->m_pVehicle; if ( pVeh->m_iDieTime == 0 ) {//just start the flaming effect and explosion delay, if it's not going already... pVeh->m_pVehicleInfo->StartDeathDelay( pVeh, 0 ); } } else*/ if ( attacker //&& attacker->client && targ != attacker && point && !VectorCompare( targ->client->ps.origin, point ) && targ->m_pVehicle->m_LandTrace.fraction >= 1.0f) {//just took a hit, knock us around vec3_t vUp, impactDir; float impactStrength = (damage/200.0f)*10.0f; float dot = 0.0f; if ( impactStrength > 10.0f ) { impactStrength = 10.0f; } //pitch or roll us based on where we were hit AngleVectors( targ->m_pVehicle->m_vOrientation, NULL, NULL, vUp ); VectorSubtract( point, targ->r.currentOrigin, impactDir ); VectorNormalize( impactDir ); if ( surface <= 0 ) {//no surf guess where we were hit, then vec3_t vFwd, vRight; AngleVectors( targ->m_pVehicle->m_vOrientation, vFwd, vRight, vUp ); dot = DotProduct( vRight, impactDir ); if ( dot > 0.4f ) { surface = SHIPSURF_RIGHT; } else if ( dot < -0.4f ) { surface = SHIPSURF_LEFT; } else { dot = DotProduct( vFwd, impactDir ); if ( dot > 0.0f ) { surface = SHIPSURF_FRONT; } else { surface = SHIPSURF_BACK; } } } switch ( surface ) { case SHIPSURF_FRONT: dot = DotProduct( vUp, impactDir ); if ( dot > 0 ) { targ->m_pVehicle->m_vOrientation[PITCH] += impactStrength; } else { targ->m_pVehicle->m_vOrientation[PITCH] -= impactStrength; } break; case SHIPSURF_BACK: dot = DotProduct( vUp, impactDir ); if ( dot > 0 ) { targ->m_pVehicle->m_vOrientation[PITCH] -= impactStrength; } else { targ->m_pVehicle->m_vOrientation[PITCH] += impactStrength; } break; case SHIPSURF_RIGHT: dot = DotProduct( vUp, impactDir ); if ( dot > 0 ) { targ->m_pVehicle->m_vOrientation[ROLL] -= impactStrength; } else { targ->m_pVehicle->m_vOrientation[ROLL] += impactStrength; } break; case SHIPSURF_LEFT: dot = DotProduct( vUp, impactDir ); if ( dot > 0 ) { targ->m_pVehicle->m_vOrientation[ROLL] += impactStrength; } else { targ->m_pVehicle->m_vOrientation[ROLL] -= impactStrength; } break; } } } } } //[CoOp] //ported from SP. if(targ->NPC && client && (mod == MOD_DEMP2 || mod == MOD_DEMP2_ALT)) {//NPCs get stunned by demps if( client->NPC_class == CLASS_SABER_DROID || client->NPC_class == CLASS_ASSASSIN_DROID || client->NPC_class == CLASS_GONK || client->NPC_class == CLASS_MOUSE || client->NPC_class == CLASS_PROBE || client->NPC_class == CLASS_PROTOCOL || client->NPC_class == CLASS_R2D2 || client->NPC_class == CLASS_R5D2 || client->NPC_class == CLASS_SEEKER || client->NPC_class == CLASS_INTERROGATOR) {//these NPC_types take way more damage from demps take *= 7; } TIMER_Set(targ, "DEMP2_StunTime", Q_irand(1000, 2000)); } //[/CoOp] if ( mod == MOD_DEMP2 || mod == MOD_DEMP2_ALT ) {//FIXME: screw with non-animal vehicles, too? if ( client ) { if ( client->NPC_class == CLASS_VEHICLE && targ->m_pVehicle && targ->m_pVehicle->m_pVehicleInfo && targ->m_pVehicle->m_pVehicleInfo->type == VH_FIGHTER ) {//all damage goes into the disruption of shields and systems take = 0; } else { if (client->jetPackOn) { //disable jetpack temporarily Jetpack_Off(targ); client->jetPackToggleTime = level.time + Q_irand(3000, 10000); } if ( client->NPC_class == CLASS_PROTOCOL || client->NPC_class == CLASS_SEEKER || client->NPC_class == CLASS_R2D2 || client->NPC_class == CLASS_R5D2 || client->NPC_class == CLASS_MOUSE || client->NPC_class == CLASS_GONK ) { // DEMP2 does more damage to these guys. take *= 2; } else if ( client->NPC_class == CLASS_PROBE || client->NPC_class == CLASS_INTERROGATOR || client->NPC_class == CLASS_MARK1 || client->NPC_class == CLASS_MARK2 || client->NPC_class == CLASS_SENTRY || client->NPC_class == CLASS_ATST ) { // DEMP2 does way more damage to these guys. take *= 5; } else { if (take > 0) { take /= 3; if (take < 1) { take = 1; } } } } } } #ifndef FINAL_BUILD if ( g_debugDamage.integer ) { G_Printf( "%i: client:%i health:%i damage:%i armor:%i\n", level.time, targ->s.number, targ->health, take, asave ); } #endif // add to the damage inflicted on a player this frame // the total will be turned into screen blends and view angle kicks // at the end of the frame if ( client ) { if ( attacker ) { client->ps.persistant[PERS_ATTACKER] = attacker->s.number; } else { client->ps.persistant[PERS_ATTACKER] = ENTITYNUM_WORLD; } client->damage_armor += asave; client->damage_blood += take; client->damage_knockback += knockback; if ( dir ) { VectorCopy ( dir, client->damage_from ); client->damage_fromWorld = qfalse; } else { VectorCopy ( targ->r.currentOrigin, client->damage_from ); client->damage_fromWorld = qtrue; } if (attacker && attacker->client) { BotDamageNotification(client, attacker); } else if (inflictor && inflictor->client) { BotDamageNotification(client, inflictor); } } // See if it's the player hurting the emeny flag carrier if( g_gametype.integer == GT_CTF || g_gametype.integer == GT_CTY) { Team_CheckHurtCarrier(targ, attacker); } if (targ->client) { // set the last client who damaged the target targ->client->lasthurt_client = attacker->s.number; targ->client->lasthurt_mod = mod; } if ( !(dflags & DAMAGE_NO_PROTECTION) ) {//protect overridden by no_protection if (take && targ->client && (targ->client->ps.fd.forcePowersActive & (1 << FP_MANIPULATE))) { if (targ->client->ps.fd.forcePower) { int maxtake = take; //G_Sound(targ, CHAN_AUTO, protectHitSound); if (targ->client->forcePowerSoundDebounce < level.time) { G_PreDefSound(targ->client->ps.origin, PDSOUND_PROTECTHIT); targ->client->forcePowerSoundDebounce = level.time + 400; } if (targ->client->ps.fd.forcePowerLevel[FP_MANIPULATE] == FORCE_LEVEL_1) { famt = 1; hamt = 0.40; if (maxtake > 100) { maxtake = 100; } } else if (targ->client->ps.fd.forcePowerLevel[FP_MANIPULATE] == FORCE_LEVEL_2) { famt = 0.5; hamt = 0.60; if (maxtake > 200) { maxtake = 200; } } else if (targ->client->ps.fd.forcePowerLevel[FP_MANIPULATE] == FORCE_LEVEL_3) { famt = 0.25; hamt = 0.80; if (maxtake > 400) { maxtake = 400; } } if (!targ->client->ps.powerups[PW_FORCE_BOON]) { targ->client->ps.fd.forcePower -= maxtake*famt; } else { targ->client->ps.fd.forcePower -= (maxtake*famt)/2; } subamt = (maxtake*hamt)+(take-maxtake); if (targ->client->ps.fd.forcePower < 0) { subamt += targ->client->ps.fd.forcePower; targ->client->ps.fd.forcePower = 0; } if (subamt) { take -= subamt; if (take < 0) { take = 0; } } } } } if (shieldAbsorbed) { /* if ( targ->client->NPC_class == CLASS_VEHICLE ) { targ->client->ps.electrifyTime = level.time + Q_irand( 500, 1000 ); } else */ { gentity_t *evEnt; // Send off an event to show a shield shell on the player, pointing in the right direction. //evEnt = G_TempEntity(vec3_origin, EV_SHIELD_HIT); //rww - er.. what the? This isn't broadcast, why is it being set on vec3_origin?! evEnt = G_TempEntity(targ->r.currentOrigin, EV_SHIELD_HIT); evEnt->s.otherEntityNum = targ->s.number; evEnt->s.eventParm = DirToByte(dir); evEnt->s.time2=shieldAbsorbed; /* shieldAbsorbed *= 20; if (shieldAbsorbed > 1500) { shieldAbsorbed = 1500; } if (shieldAbsorbed < 200) { shieldAbsorbed = 200; } if (targ->client->ps.powerups[PW_SHIELDHIT] < (level.time + shieldAbsorbed)) { targ->client->ps.powerups[PW_SHIELDHIT] = level.time + shieldAbsorbed; } //flicker for as many ms as damage was absorbed (*20) //therefore 10 damage causes 1/5 of a seond of flickering, whereas //a full 100 causes 2 seconds (but is reduced to 1.5 seconds due to the max) */ } } // do the damage if (take) { if (targ->client && targ->s.number < MAX_CLIENTS && (mod == MOD_DEMP2 || mod == MOD_DEMP2_ALT)) { //uh.. shock them or something. what the hell, I don't know. if (targ->client->ps.weaponTime <= 0) { //yeah, we were supposed to be beta a week ago, I don't feel like //breaking the game so I'm gonna be safe and only do this only //if your weapon is not busy targ->client->ps.weaponTime = 2000; targ->client->ps.electrifyTime = level.time + 2000; if (targ->client->ps.weaponstate == WEAPON_CHARGING || targ->client->ps.weaponstate == WEAPON_CHARGING_ALT) { targ->client->ps.weaponstate = WEAPON_READY; } } } if ( !(dflags & DAMAGE_NO_PROTECTION) ) {//rage overridden by no_protection if (targ->client && (targ->client->ps.fd.forcePowersActive & (1 << FP_RAGE)) && (inflictor->client || attacker->client)) { take /= (targ->client->ps.fd.forcePowerLevel[FP_RAGE]+1); } } //[ExpSys] //give experience for damaging players if(targ->client && targ->health > 0 && attacker && attacker->client) {//targ is creature and attacker is creature //[SkillChange] if(take > targ->health) {//damage is greated than target's health, only give experience for damage used to kill victim float skill = (float) targ->health / SKILL_HP_PER_SKILL * (targ->client->sess.skillPoints / attacker->client->sess.skillPoints); skill/=2; //if(skill != attacker->client->sess.skillPoints) //AddSkill(attacker,skill ); } else { float skill =(float) take / SKILL_HP_PER_SKILL * (targ->client->sess.skillPoints / attacker->client->sess.skillPoints); skill/=2; //if(skill != attacker->client->sess.skillPoints) //AddSkill(attacker, skill ); } //[/SkillChange] } //[/ExpSys] targ->health = targ->health - take; if ( (targ->flags&FL_UNDYING) ) {//take damage down to 1, but never die if ( targ->health < 1 ) { //[CoOp] //trigger death script (this flag is normally used for NPC bosses who you want to lose, but not die onscreen before the script is run. G_ActivateBehavior( targ, BSET_DEATH ); //[/CoOp] targ->health = 1; } } if ( targ->client ) { targ->client->ps.stats[STAT_HEALTH] = targ->health; } if ( !(dflags & DAMAGE_NO_PROTECTION) ) {//rage overridden by no_protection if (targ->client && (targ->client->ps.fd.forcePowersActive & (1 << FP_RAGE)) && (inflictor->client || attacker->client)) { if (targ->health <= 0) { targ->health = 1; } if (targ->client->ps.stats[STAT_HEALTH] <= 0) { targ->client->ps.stats[STAT_HEALTH] = 1; } } } //We want to go ahead and set gPainHitLoc regardless of if we have a pain func, //so we can adjust the location damage too. //[BugFix12] if (targ->client && targ->ghoul2 && targ->client->g2LastSurfaceModel == G2MODEL_PLAYER && targ->client->g2LastSurfaceTime == level.time) //if (targ->client && targ->ghoul2 && targ->client->g2LastSurfaceTime == level.time) //[/BugFix12] { //We updated the hit surface this frame, so it's valid. char hitSurface[MAX_QPATH]; trap_G2API_GetSurfaceName(targ->ghoul2, targ->client->g2LastSurfaceHit, 0, hitSurface); if (hitSurface[0]) { G_GetHitLocFromSurfName(targ, hitSurface, &gPainHitLoc, point, dir, vec3_origin, mod); } else { gPainHitLoc = -1; } if (gPainHitLoc < HL_MAX && gPainHitLoc >= 0 && targ->locationDamage[gPainHitLoc] < Q3_INFINITE && (targ->s.eType == ET_PLAYER || targ->s.NPC_class != CLASS_VEHICLE)) { targ->locationDamage[gPainHitLoc] += take; if (g_armBreakage.integer && !targ->client->ps.brokenLimbs && targ->client->ps.stats[STAT_HEALTH] > 0 && targ->health > 0 && !(targ->s.eFlags & EF_DEAD)) { //check for breakage if (targ->locationDamage[HL_ARM_RT]+targ->locationDamage[HL_HAND_RT] >= 80) { G_BreakArm(targ, BROKENLIMB_RARM); } else if (targ->locationDamage[HL_ARM_LT]+targ->locationDamage[HL_HAND_LT] >= 80) { G_BreakArm(targ, BROKENLIMB_LARM); } } } } else { gPainHitLoc = -1; } if (targ->maxHealth) { //if this is non-zero this guy should be updated his s.health to send to the client G_ScaleNetHealth(targ); } if ( targ->health <= 0 ) { if ( client ) { targ->flags |= FL_NO_KNOCKBACK; if (point) { VectorCopy( point, targ->pos1 ); } else { VectorCopy(targ->client->ps.origin, targ->pos1); } } else if (targ->s.eType == ET_NPC) { //g2animent VectorCopy(point, targ->pos1); } if (targ->health < -999) targ->health = -999; // If we are a breaking glass brush, store the damage point so we can do cool things with it. if ( targ->r.svFlags & SVF_GLASS_BRUSH ) { VectorCopy( point, targ->pos1 ); if (dir) { VectorCopy( dir, targ->pos2 ); } else { VectorClear(targ->pos2); } } if (targ->s.eType == ET_NPC && targ->client && (targ->s.eFlags & EF_DEAD)) { //an NPC that's already dead. Maybe we can cut some more limbs off! if ( (mod == MOD_SABER || (mod == MOD_MELEE && G_HeavyMelee( attacker )) )//saber or heavy melee (claws) && take > 2 && !(dflags&DAMAGE_NO_DISMEMBER) ) { G_CheckForDismemberment(targ, attacker, targ->pos1, take, targ->client->ps.torsoAnim, qtrue); } } targ->enemy = attacker; targ->die (targ, inflictor, attacker, take, mod); G_ActivateBehavior( targ, BSET_DEATH ); return; } else { if ( g_debugMelee.integer ) {//getting hurt makes you let go of the wall if ( targ->client && (targ->client->ps.pm_flags&PMF_STUCK_TO_WALL) ) { G_LetGoOfWall( targ ); } } if ( targ->pain ) { if (targ->s.eType != ET_NPC || mod != MOD_SABER || take > 1) { //don't even notify NPCs of pain if it's just idle saber damage gPainMOD = mod; if (point) { VectorCopy(point, gPainPoint); } else { VectorCopy(targ->r.currentOrigin, gPainPoint); } targ->pain (targ, attacker, take); } } } G_LogWeaponDamage(attacker->s.number, mod, take); } } //[Asteroids] void G_DamageFromKiller( gentity_t *pEnt, gentity_t *pVehEnt, gentity_t *attacker, vec3_t org, int damage, int dflags, int mod ) { gentity_t *killer = attacker, *inflictor = attacker; qboolean tempInflictor = qfalse; if ( !pEnt || !pVehEnt || !pVehEnt->client ) { return; } if (pVehEnt->client->ps.otherKiller < ENTITYNUM_WORLD && pVehEnt->client->ps.otherKillerTime > level.time) { gentity_t *potentialKiller = &g_entities[pVehEnt->client->ps.otherKiller]; if ( potentialKiller->inuse )//&& potentialKiller->client) { //he's valid I guess killer = potentialKiller; mod = pVehEnt->client->otherKillerMOD; inflictor = killer; if ( pVehEnt->client->otherKillerVehWeapon > 0 ) { inflictor = G_Spawn(); if ( inflictor ) {//fake up the inflictor tempInflictor = qtrue; inflictor->classname = "vehicle_proj"; inflictor->s.otherEntityNum2 = pVehEnt->client->otherKillerVehWeapon-1; inflictor->s.weapon = pVehEnt->client->otherKillerWeaponType; } } } } //FIXME: damage hitEnt, some, too? Our explosion should hurt them some, but... if ( killer && killer->s.eType == ET_NPC && killer->s.NPC_class == CLASS_VEHICLE && killer->m_pVehicle && killer->m_pVehicle->m_pPilot ) { killer = (gentity_t *)killer->m_pVehicle->m_pPilot; } G_Damage( pEnt, inflictor, killer, NULL, org, damage, dflags, mod ); if ( tempInflictor ) { G_FreeEntity( inflictor ); } } //[/Asteroids] /* ============ CanDamage Returns qtrue if the inflictor can directly damage the target. Used for explosions and melee attacks. ============ */ qboolean CanDamage (gentity_t *targ, vec3_t origin) { vec3_t dest; trace_t tr; vec3_t midpoint; // use the midpoint of the bounds instead of the origin, because // bmodels may have their origin is 0,0,0 VectorAdd (targ->r.absmin, targ->r.absmax, midpoint); VectorScale (midpoint, 0.5, midpoint); VectorCopy (midpoint, dest); trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID); if (tr.fraction == 1.0 || tr.entityNum == targ->s.number) return qtrue; // this should probably check in the plane of projection, // rather than in world coordinate, and also include Z VectorCopy (midpoint, dest); dest[0] += 15.0; dest[1] += 15.0; trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID); if (tr.fraction == 1.0) return qtrue; VectorCopy (midpoint, dest); dest[0] += 15.0; dest[1] -= 15.0; trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID); if (tr.fraction == 1.0) return qtrue; VectorCopy (midpoint, dest); dest[0] -= 15.0; dest[1] += 15.0; trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID); if (tr.fraction == 1.0) return qtrue; VectorCopy (midpoint, dest); dest[0] -= 15.0; dest[1] -= 15.0; trap_Trace ( &tr, origin, vec3_origin, vec3_origin, dest, ENTITYNUM_NONE, MASK_SOLID); if (tr.fraction == 1.0) return qtrue; return qfalse; } /* ============ G_RadiusDamage ============ */ //[DodgeSys] qboolean G_DoDodge( gentity_t *self, gentity_t *shooter, vec3_t impactPoint, int hitLoc, int * dmg, int mod ); //[/DodgeSys] qboolean G_RadiusDamage ( vec3_t origin, gentity_t *attacker, float damage, float radius, gentity_t *ignore, gentity_t *missile, int mod) { float points, dist; gentity_t *ent; int entityList[MAX_GENTITIES]; int numListedEntities; //[DodgeSys] int dodgeDmg; //damage value passed to and from the dodge code. //[/DodgeSys] vec3_t mins, maxs; vec3_t v; vec3_t dir; int i, e; qboolean hitClient = qfalse; qboolean roastPeople = qfalse; /* if (missile && !missile->client && missile->s.weapon > WP_NONE && missile->s.weapon < WP_NUM_WEAPONS && missile->r.ownerNum >= 0 && (missile->r.ownerNum < MAX_CLIENTS || g_entities[missile->r.ownerNum].s.eType == ET_NPC)) { //sounds like it's a valid weapon projectile.. is it a valid explosive to create marks from? switch(missile->s.weapon) { case WP_FLECHETTE: //flechette issuing this will be alt-fire case WP_ROCKET_LAUNCHER: case WP_THERMAL: case WP_GRENADE: case WP_DET_PACK: roastPeople = qtrue; //Then create explosive marks break; default: break; } } */ //oh well.. maybe sometime? I am trying to cut down on tempent use. if ( radius < 1 ) { radius = 1; } for ( i = 0 ; i < 3 ; i++ ) { mins[i] = origin[i] - radius; maxs[i] = origin[i] + radius; } numListedEntities = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); for ( e = 0 ; e < numListedEntities ; e++ ) { ent = &g_entities[entityList[ e ]]; if (ent == ignore) continue; if (!ent->takedamage) continue; // find the distance from the edge of the bounding box for ( i = 0 ; i < 3 ; i++ ) { if ( origin[i] < ent->r.absmin[i] ) { v[i] = ent->r.absmin[i] - origin[i]; } else if ( origin[i] > ent->r.absmax[i] ) { v[i] = origin[i] - ent->r.absmax[i]; } else { v[i] = 0; } } dist = VectorLength( v ); if ( dist >= radius ) { continue; } points = damage * ( 1.0 - dist / radius ); //[DodgeSys] //added dodge for splash damage. dodgeDmg = (int) points; if( CanDamage (ent, origin) && !G_DoDodge(ent, attacker, origin, -1, &dodgeDmg, mod) ) { //if( CanDamage (ent, origin) ) { //we might have reduced the damage by doing a partial dodge points = (float) dodgeDmg; //[/DodgeSys] if( LogAccuracyHit( ent, attacker ) ) { hitClient = qtrue; } VectorSubtract (ent->r.currentOrigin, origin, dir); // push the center of mass higher than the origin so players // get knocked into the air more dir[2] += 24; if (attacker && attacker->inuse && attacker->client && attacker->s.eType == ET_NPC && attacker->s.NPC_class == CLASS_VEHICLE && attacker->m_pVehicle && attacker->m_pVehicle->m_pPilot) { //say my pilot did it. //[Asteroids] G_Damage (ent, missile, (gentity_t *)attacker->m_pVehicle->m_pPilot, dir, origin, (int)points, DAMAGE_RADIUS, mod); //G_Damage (ent, NULL, (gentity_t *)attacker->m_pVehicle->m_pPilot, dir, origin, (int)points, DAMAGE_RADIUS, mod); } else { G_Damage (ent, missile, attacker, dir, origin, (int)points, DAMAGE_RADIUS, mod); //G_Damage (ent, NULL, attacker, dir, origin, (int)points, DAMAGE_RADIUS, mod); //[/Asteroids] } if(ent && missile && ent && Q_stricmp(ent->classname,"func_breakable")==0) { vec3_t blowBackDir; VectorSubtract(ent->s.pos.trBase,missile->s.pos.trBase, blowBackDir); G_Throw(ent,blowBackDir,200); } if (ent && ent->client && roastPeople && missile && !VectorCompare(ent->r.currentOrigin, missile->r.currentOrigin)) { //the thing calling this function can create burn marks on people, so create an event to do so gentity_t *evEnt = G_TempEntity(ent->r.currentOrigin, EV_GHOUL2_MARK); evEnt->s.otherEntityNum = ent->s.number; //the entity the mark should be placed on evEnt->s.weapon = WP_ROCKET_LAUNCHER; //always say it's rocket so we make the right mark //Try to place the decal by going from the missile location to the location of the person that was hit VectorCopy(missile->r.currentOrigin, evEnt->s.origin); VectorCopy(ent->r.currentOrigin, evEnt->s.origin2); //it's hacky, but we want to move it up so it's more likely to hit //the torso. if (missile->r.currentOrigin[2] < ent->r.currentOrigin[2]) { //move it up less so the decal is placed lower on the model then evEnt->s.origin2[2] += 8; } else { evEnt->s.origin2[2] += 24; } //Special col check evEnt->s.eventParm = 1; } } } return hitClient; } //[SaberSys] #define DODGE_KILLBONUS 20 //the DP bonus you get for killing another player #define FATIGUE_KILLBONUS 20 //the FP bonus you get for killing another player extern void WP_ForcePowerRegenerate( gentity_t *self, int overrideAmt ); void AddFatigueKillBonus( gentity_t *attacker, gentity_t *victim ) {//get a small bonus for killing an enemy if(!attacker || !attacker->client || !victim || !victim->client) { return; } if(victim->NPC) {//don't get kill bonus for axing NPCs return; } //add bonus WP_ForcePowerRegenerate(attacker, FATIGUE_KILLBONUS); attacker->client->ps.stats[STAT_DODGE] += DODGE_KILLBONUS; if(attacker->client->ps.stats[STAT_DODGE] > attacker->client->ps.stats[STAT_MAX_DODGE]) { attacker->client->ps.stats[STAT_DODGE] = attacker->client->ps.stats[STAT_MAX_DODGE]; } } //[/SaberSys] //[ExpSys] void AddSkill(gentity_t *self, float amount) {//add skill points to self if(amount < 0) { G_Printf("AddSkill: amount cannot be negative (%f)\n"); return; } if(amount == 0) return; self->client->sess.skillPoints += amount; self->client->skillUpdated = qtrue; //mark that we've updated our skill points so we can update the player's client. if(g_maxForceRank.integer < g_minForceRank.integer) {//can't have a max skill point level that's less than our starting skill points. //G_Printf("g_maxForceRank less than g_minForceRank. Defaulting to g_minForceRank.\n"); trap_Cvar_Set("g_maxForceRank", g_minForceRank.string); } if(self->client->sess.skillPoints > g_maxForceRank.value) { self->client->sess.skillPoints = g_maxForceRank.value; } } void G_DodgeDrain(gentity_t *victim, gentity_t *attacker, int amount) {//drains DP from victim. Also awards experience points to the attacker. if ( !g_friendlyFire.integer && OnSameTeam(victim, attacker)) {//don't drain DP if we're hit by a team member return; } if(victim->flags &FL_GODMODE) return; if(victim->client && victim->client->ps.fd.forcePowersActive & (1 << FP_MANIPULATE)) { amount /= 2; if(amount < 1) amount=1; } victim->client->ps.stats[STAT_DODGE] -= amount; if(attacker->client && (attacker->client->ps.torsoAnim == saberMoveData[16].animToUse || attacker->client->ps.torsoAnim == 1252) ) {//In DFA? victim->client->ps.saberAttackChainCount+=16; } if(victim->client->ps.stats[STAT_DODGE] < 0) { victim->client->ps.stats[STAT_DODGE] = 0; } if(attacker && attacker->client) {//attacker gets experience for causing damage. //don't want a divide by zero errors //Bug fix: double negitive here, was firing only if skillPoints is NOT equal to zero. assert(attacker->client->sess.skillPoints); //assert(!attacker->client->sess.skillPoints); //scale skill points based on the ratio between skills //AddSkill(attacker, // (float) amount / SKILL_DP_PER_SKILL * (victim->client->sess.skillPoints / attacker->client->sess.skillPoints)); } //G_Printf("%i: %i: %i Points of Dodge Drained\n", level.time, victim->s.number, amount); } //[/ExpSys]
[ "[email protected]@5776d9f2-9662-11de-ad41-3fcdc5e0e42d" ]
[ [ [ 1, 6706 ] ] ]
ccaf98cf2e671bcbb9aa2d8dbfef819b82af6a4d
463c3b62132d215e245a097a921859ecb498f723
/lib/dlib/hash_map.h
4d524c30e3cd7a892983d95334441fc42493dc43
[ "LicenseRef-scancode-unknown-license-reference", "BSL-1.0" ]
permissive
athulan/cppagent
58f078cee55b68c08297acdf04a5424c2308cfdc
9027ec4e32647e10c38276e12bcfed526a7e27dd
refs/heads/master
2021-01-18T23:34:34.691846
2009-05-05T00:19:54
2009-05-05T00:19:54
197,038
4
1
null
null
null
null
UTF-8
C++
false
false
1,831
h
// Copyright (C) 2003 Davis E. King ([email protected]) // License: Boost Software License See LICENSE.txt for the full license. #ifndef DLIB_HASH_MAp_ #define DLIB_HASH_MAp_ #include "hash_map/hash_map_kernel_1.h" #include "hash_map/hash_map_kernel_c.h" #include "hash_table.h" #include "algs.h" #include "memory_manager.h" #include <functional> namespace dlib { template < typename domain, typename range, unsigned long expnum, typename mem_manager = memory_manager<char>::kernel_1a, typename compare = std::less<domain> > class hash_map { hash_map() {} typedef typename hash_table<domain,range,mem_manager,compare>::kernel_1a hash_table_1; typedef typename hash_table<domain,range,mem_manager,compare>::kernel_2a hash_table_2; typedef typename hash_table<domain,range,mem_manager,compare>::kernel_2b hash_table_3; public: //----------- kernels --------------- // kernel_1a typedef hash_map_kernel_1<domain,range,expnum,hash_table_1,mem_manager> kernel_1a; typedef hash_map_kernel_c<kernel_1a> kernel_1a_c; // kernel_1b typedef hash_map_kernel_1<domain,range,expnum,hash_table_2,mem_manager> kernel_1b; typedef hash_map_kernel_c<kernel_1b> kernel_1b_c; // kernel_1c typedef hash_map_kernel_1<domain,range,expnum,hash_table_3,mem_manager> kernel_1c; typedef hash_map_kernel_c<kernel_1c> kernel_1c_c; }; } #endif // DLIB_HASH_MAp_
[ "jimmy@DGJ3X3B1.(none)" ]
[ [ [ 1, 63 ] ] ]
96429c2ddc6d85ba19b7cac628993b4889157451
cd38bbb67d915ac8f7ad5068fe8ed9bcae4ec0f9
/Card.h
2d45a5a7c84b7b1e13562b08dc60fbe1e7831065
[]
no_license
ceri-de-lloyd/pokergame
942027d33cdf1945b61f541b644089b3d0536ced
dbbfd86349125ba3caf0046838d517f42868ab4e
refs/heads/master
2019-01-22T00:01:31.194578
2011-09-21T12:14:03
2011-09-21T12:14:03
2,065,813
0
1
null
null
null
null
UTF-8
C++
false
false
1,588
h
#include <fstream> #include <iostream> #include <string> #include <cctype> #include <cstdlib> #include <cctype> #include <cmath> #include <stdio.h> #include "Suit.h" #include "CardRank.h" class Card { // A "card" as a pair of (card-)rank and suit. public: int num_cards = Suit.num_suites * CardRank.num_ranks; public: CardRank; rank; public: Suit; suit; public: Card(CardRank r, final Suit s) { rank = r; suit = s; } public: Card(int i) { assert i >= 0; assert i < num_cards; rank = new CardRank(i % CardRank.num_ranks); suit = new Suit(i / CardRank.num_ranks); } public: int index() { return suit.index * CardRank.num_ranks + rank.index; } string:: toString() { return rank.toString() + " of " + suit.toString(); } public: bool:: equals(Card c) { return c.rank.equals(rank) && c.suit.equals(suit); } // Demonstration of functionality: int main() { using std::cout; cout << new Card(0); cout << new Card(51); Card c1 = new Card(new CardRank("Jack"), new Suit("Spades")); cout << c1; // Demonstration that here references are harmless, since CardRank, Suit // and also Card behave similar to value-types (they are non-mutable): CardRank cr2 = new CardRank("5"); Suit s2 = new Suit("Hearts"); Card c2 = new Card(cr2, s2); cout << c2; cr2 = new CardRank("King"); s2 = new Suit("Clubs"); cout << c2; // still the same, since the old cr2- and s2-objects didn't change cout << new Card(cr2,s2); return 0; } }
[ [ [ 1, 63 ] ] ]
ce6e606a8787ae6783df9106b9d751d8dc512945
53f155c92599ccaa92be24c259893911bf03aff8
/trunk/source/outputaggregation.cpp
d3356470c6ed40ddfa7a89b52a5f0ea5bdc00ceb
[]
no_license
BackupTheBerlios/framework-svn
6813d63b9fab1eef7873d3e115be339c1f7a73a1
8bd8bedee4456d00fdb03b9a76cfe0b9e364ef73
refs/heads/master
2021-01-01T16:00:01.456584
2006-12-13T22:03:46
2006-12-13T22:03:46
40,671,138
0
0
null
null
null
null
ISO-8859-1
C++
false
false
10,168
cpp
#include "outputaggregation.h" OutputAggregation::OutputAggregation() { } void OutputAggregation::Initialize (vector <char *> *fieldNames, vector <FieldOperation> *fieldOperations, vector <char *> *fieldCriteria, vector <FieldFilter *> *fieldFilter) { _fieldOperations = fieldOperations; _fieldCriteria = fieldCriteria; _fieldNames = fieldNames; _fieldFilter = fieldFilter; _resolved = false; _count = new int[_fieldNames->size()]; startResults(); } OutputAggregation::~OutputAggregation() { if (_count != NULL) { delete _count; } } void OutputAggregation::copyvector(vector <varValue> &results, varValue *values) { results.clear(); for(vector <varValue>::size_type n = 0; n < this->_fieldNames->size(); n++) results.push_back(values[n]); } void OutputAggregation::ProcessValues(varValue *values) { if (_fieldOperations->size() == 0) { // No tiene que hacer ningún aggregate... copia valores _results.clear(); for(vector <varValue>::size_type n = 0; n < this->_fieldNames->size(); n++) if ((*_fieldFilter)[n] == NULL || EvaluateFilter((*_fieldFilter)[n], _fieldNames, values)) _results.push_back(values[n]); else _results.push_back(new varValue("")); return; } // Procesa para el aggregate... for(vector <double>::size_type n = 0; n < _fieldOperations->size(); n++) { if ((*_fieldFilter)[n] == NULL || EvaluateFilter((*_fieldFilter)[n], _fieldNames, values)) { switch((*_fieldOperations)[n]) { case Sum: case Average: _results[n] += values[n]; break; case Average_positive: if (values[n].GetNumericValue() >= 0) { _results[n] += values[n]; } else _count[n]--; // se asegura de que los demas no sean contabilizados break; case Min: if (values[n] < _results[n] || _count[n] == 0) _results[n] = values[n]; break; case Max: if (values[n] > _results[n] || _count[n] == 0) _results[n] = values[n]; break; case Count: if ((*_fieldCriteria)[n] == NULL) ++_results[n]; else { if (values[n].type == T_String) { varValue sv = values[n]; if (sv.GetStringValue() == string((*_fieldCriteria)[n])) { ++_results[n]; } } else { if (values[n].GetNumericValue() == atof((*_fieldCriteria)[n])) ++_results[n]; } } break; case Count_positive: if (values[n].GetNumericValue() >= 0) ++_results[n]; break; case Percentage: if (values[n].type == T_String) { varValue sv = values[n]; if (sv.GetStringValue() == string((*_fieldCriteria)[n])) { ++_results[n]; } else _count[n]--; } else if (values[n].GetNumericValue() == atof((*_fieldCriteria)[n])) ++_results[n]; else _count[n]--; break; /* Faltan implementar: Median, StdDev */ default: throw("Unsupported operation."); } _count[n]++; } } } bool OutputAggregation::EvaluateFilter(FieldFilter* _fieldFilter, vector <char *> *_fieldNames, varValue *values) { // Busca el field con ese valor for (int n=0; n<(int)_fieldNames->size(); n++) if (strcmp((*_fieldNames)[n], _fieldFilter->Field) == 0) { // Usa el comparador switch(_fieldFilter->Operator) { case Equal: if (values[n].type == T_String) { varValue sv = values[n]; return (sv.GetStringValue() == string(_fieldFilter->retValues)); } else return (values[n].GetNumericValue() == atof(_fieldFilter->retValues)); break; case NoEqual: if (values[n].type == T_String) { varValue sv = values[n]; return (sv.GetStringValue() != string(_fieldFilter->retValues)); } else return (values[n].GetNumericValue() != atof(_fieldFilter->retValues)); break; case GreaterThan: if (values[n].type == T_String) { varValue sv = values[n]; return (sv.GetStringValue() > string(_fieldFilter->retValues)); } else return (values[n].GetNumericValue() > atof(_fieldFilter->retValues)); break; case LowerThan: if (values[n].type == T_String) { varValue sv = values[n]; return (sv.GetStringValue() < string(_fieldFilter->retValues)); } else return (values[n].GetNumericValue() < atof(_fieldFilter->retValues)); break; case EqualOrGreaterThan: if (values[n].type == T_String) { varValue sv = values[n]; return (sv.GetStringValue() >= string(_fieldFilter->retValues)); } else return (values[n].GetNumericValue() >= atof(_fieldFilter->retValues)); break; case EqualOrLowerThan: if (values[n].type == T_String) { varValue sv = values[n]; return (sv.GetStringValue() <= string(_fieldFilter->retValues)); } else return (values[n].GetNumericValue() <= atof(_fieldFilter->retValues)); break; } } return false; } void OutputAggregation::BeginHeaders(FILE *file, bool isAggregate) { fprintf(file,"Loop\t"); if (isAggregate == false) fprintf(file,"AgentId\t"); } void OutputAggregation::ShowHeaders(FILE *file) { char buffer[40]; for(vector <char *>::size_type n = 0; n < _fieldNames->size(); n++) { fprintf(file,"%s", (*_fieldNames)[n]); if (_fieldOperations->size() > 0) // isAggregate { fprintf(file,"_%s", operationToText((*_fieldOperations)[n],buffer)); } fprintf(file,"\t"); } } char *OutputAggregation::operationToText(FieldOperation operation, char *buffer) { switch(operation) { case Average: strcpy(buffer, "mean"); break; case Average_positive: strcpy(buffer, "meanp"); break; case Sum: strcpy(buffer, "sum"); break; case Min: strcpy(buffer, "min"); break; case Max: strcpy(buffer, "max"); break; case Median: strcpy(buffer, "med"); break; case StdDev: strcpy(buffer, "stdv"); break; case Count: strcpy(buffer, "count"); break; case Count_positive: strcpy(buffer, "cntp"); break; case Percentage: strcpy(buffer, "pin"); break; default: throw("Operation missing in outputAggregation::OperationToText"); } return buffer; } void OutputAggregation::Resolve(void) { if (_fieldOperations->size() > 0) { // Procesa para el aggregate... for(vector <double>::size_type n = 0; n < _fieldOperations->size(); n++) { switch((*_fieldOperations)[n]) { case Sum: case Min: case Max: case Count: break; case Count_positive: break; case Average: case Average_positive: case Percentage: _results[n] /= _count[n]; break; /* Faltan implementar: Median, StdDev, */ default: throw("Unsupported operation."); } } } } void OutputAggregation::Clear(void) { startResults(); } void OutputAggregation::startResults() { // Initialize results... _results.clear(); for(vector <double>::size_type n = 0; n < _fieldNames->size(); n++) { _results.push_back(varValue(0.0)); _count[n]=0; } } void OutputAggregation::BeginLine(FILE *file, float loop) { BeginLine(file, loop, 0); } void OutputAggregation::BeginLine(FILE *file, float loop, unsigned int agentId) { fprintf(file,"%.2f\t", loop); if (agentId != 0) fprintf(file,"%#.8X\t", agentId); } void OutputAggregation::EndLine(FILE *file) { fprintf(file,"\n"); } void OutputAggregation::ShowValues(FILE *file) { if (_resolved == false) Resolve(); for(vector <char *>::size_type n = 0; n < _fieldNames->size(); n++) { variantToStringFile(file, _results[n]); } this->Clear(); } void OutputAggregation::variantToStringFile(FILE *file, varValue &value) { switch(value.type) { case T_Double: { double d = value.GetNumericValue(); if (d != (long) d) fprintf(file,"%.4f\t", d); else fprintf(file,"%ld\t", (long) d); break; } case T_Integer: fprintf(file,"%ld\t", value.GetNumericValue()); break; case T_String: { // tiene que haber una forma mejor!! string s = value.GetStringValue(); for(std::basic_string<char>::iterator it = s.begin(); it != s.end();++it) putc(*it, file); putc('\t', file); break; } default: throw "unsupported variantoToString type"; } };
[ "pablodegrande@8096f40a-0115-0410-8a2f-ff4c50103d81", "meguia@8096f40a-0115-0410-8a2f-ff4c50103d81" ]
[ [ [ 1, 4 ], [ 6, 27 ], [ 29, 57 ], [ 59, 222 ], [ 226, 243 ], [ 247, 268 ], [ 271, 271 ], [ 273, 296 ], [ 299, 301 ], [ 303, 305 ], [ 307, 307 ], [ 309, 320 ], [ 322, 347 ], [ 349, 357 ] ], [ [ 5, 5 ], [ 28, 28 ], [ 58, 58 ], [ 223, 225 ], [ 244, 246 ], [ 269, 270 ], [ 272, 272 ], [ 297, 298 ], [ 302, 302 ], [ 306, 306 ], [ 308, 308 ], [ 321, 321 ], [ 348, 348 ] ] ]
1ddb6c43c29a5e3590e2b7b80e12cb7ff1064a06
7f30cb109e574560873a5eb8bb398c027f85eeee
/src/pacsCommunicator.h
083282881ccabebb3215a62edae2ba6d894933d1
[]
no_license
svn2github/MITO
e8fd0e0b6eebf26f2382f62660c06726419a9043
71d1269d7666151df52d6b5a98765676d992349a
refs/heads/master
2021-01-10T03:13:55.083371
2011-10-14T15:40:14
2011-10-14T15:40:14
47,415,786
1
0
null
null
null
null
WINDOWS-1252
C++
false
false
6,065
h
/** * \file pacsCommunicator.h * \brief File per la comunicazione con i PACS * \author ICAR-CNR Napoli */ #ifndef _pacsCommunicator_h_ #define _pacsCommunicator_h_ #include "pacsDataTypes.h" #include "pacsPreferences.h" #include "pacsQuery.h" // For compilers that support precompilation, includes "wx/wx.h". #include <wx/wxprec.h> #include <wx/wx.h> #include <wx/notebook.h> //#include <ctn_os.h> //#include "wxPacsPreferencesGui.h" #include "wxPacsListBox.h" #ifdef WIN32 #include <windows.h> #else #include <unistd.h> #endif // location of settings.cfg #ifdef WIN32 #define PacsCFG "settings.cfg" #else #define PacsCFG "$HOME/.settingsrc" #endif // Eventi #define PVT_EVT_BASE 666 #define EVT_MITO_QUERY_TERMINATA (PVT_EVT_BASE) #define EVT_MITO_QUERY_ERROR (PVT_EVT_BASE) + 1 #define EVT_MITO_RECEIVED_IMAGE (PVT_EVT_BASE) + 2 #define EVT_MITO_RECEIVING_NEW_SERIES (PVT_EVT_BASE) + 3 #define EVT_MITO_RECEIVED_SERIES (PVT_EVT_BASE) + 4 #define EVT_MITO_RECEIVING_NEW_STUDY (PVT_EVT_BASE) + 5 #define EVT_MITO_RECEIVED_STUDY (PVT_EVT_BASE) + 6 #define EVT_MITO_RECEIVE_NOMORE (PVT_EVT_BASE) + 7 #define EVT_MITO_CLOSING_QUERYGUI (PVT_EVT_BASE) + 8 #define EVT_MITO_RECEIVE_START (PVT_EVT_BASE) + 9 // Forward declarations class pacsStoreSCP; class wxEvtHandler; /** \class pacsCommunicator * \brief Classe responsabile della comunicazione con i PACS */ class pacsCommunicator { public: /** Costruttore */ pacsCommunicator(); /** Distruttore */ virtual ~pacsCommunicator(); /** * \fn bool queryFollowUp (PacsData *pStart, const QueryLevel _qLev, PacsList ** lists) * \brief Realizza le query in base ai dataset * \param pStart Struttura relativa all'elemento selezionato nel TreeList * \param _qLev Livello query * \param PacsList * Lista nella quale salvare i risultati della query * \return Ritorna true in caso di successo, false in caso di problemi (probabilmente dovuti alla mancata risposta del PACS) */ bool queryFollowUp (PacsData *pStart, const QueryLevel _qLev, PacsList ** lists); /** * \fn bool query (const char *_name, const char *_patientBirthdate, const char *_studyDate) * \brief Realizza le query al server per date informazioni e memorizza i risultati in lists[0] * \param _name Nome del paziente * \param _patientBirthdate Data di nascita del paziente * \param _studyDate Data dello studio * \return Ritorna true in caso di successo, false in caso di problemi (probabilmente dovuti alla mancata risposta del PACS) */ bool query (const char*, const char*, const char*, PacsList **); /** * \fn bool query (StudyData *queryData, PacsList **lists) * \brief Realizza le query al server per date informazioni e memorizza i risultati in lists[0] * \param queryData Contiene le informazioni tramite le quali effettuare la query * \param lists Lista in cui salvare i risultati della query * \param bDeleteStudyData Dealloca queryData alla fine della query (valore predefinito false) * \return Ritorna true in caso di successo, false in caso di problemi (probabilmente dovuti alla mancata risposta del PACS) */ bool query (StudyData *, PacsList **, bool bDeleteStudyData = false); /** * \fn void query (const char*) * \brief Realizza le query alle directory * \param _dir Nome della directory * \return Ritorna true in caso di successo, false in caso di problemi (probabilmente dovuti alla mancata risposta del PACS) */ bool query (const char*, PacsList **); /** * \fn int send (const char* _server, , PacsData *pToMove) * \brief Scarica una immagine dal server * \param _server Server da cui scaricare le immagini * \param pToMove Riferimento dell'oggetto da scaricare (preso dalla lista) */ int send (const char*, PacsData *); /** * \fn void clearAll() * \brief Elimina tutti gli elementi dalla lista */ void clearAll(); /** * \fn void setOutput(wxTextCtrl* _output) * \brief Assegna il browser di output * \param _output Browser di output */ void setOutput(wxTextCtrl*); /** * \fn int store(const char *fileName) * \brief Invia immagini al PACS * \param fileName Nome del file o della directory da inviare * \return Vale 1 se l'operazione è andata a buon fine, 0 altrimenti */ int store(const char *fileName); /** * \fn pacsQuery* getPacsQuery() * \brief Restituisce il puntatore all'oggetto di tipo pacsQuery * \return Puntatore all'oggetto di tipo pacsQuery */ inline pacsQuery* getPacsQuery() { return qMod; } /** * \fn pacsStoreSCP *spawnStoreSCP(wxEvtHandler *pParent) * \brief Avvia il server per il download delle immagini * \return Ritorna una instanza della classe server SCP */ pacsStoreSCP *spawnStoreSCP(wxEvtHandler *); /** * \fn pacsPreferences *getPrefs() * \brief Restituisce il puntatore all'oggetto di tipo pacsPreferences * \return Puntatore all'oggetto di tipo pacsPreferences */ inline pacsPreferences *getPrefs() { return prefs; } void setPrefs(const pacsPreferences *pPrefs) { memcpy(prefs, pPrefs, sizeof(pacsPreferences)); } /** * \var PacsList* lists[2] * \brief Lista per i dati */ //PacsList* lists[2]; protected: /** * \var pacsPreferences *prefs * \brief Parametri per il PACS */ pacsPreferences *prefs; /** * \var pacsQuery *qMod * \brief Puntatore al gestore delle query per i PACS */ pacsQuery *qMod; /** * \var char prefsName[255] * \brief Nome del file contenente i parametri del PACS */ char prefsName[255]; /** * \var wxTextCtrl *output * \brief Browser di output */ wxTextCtrl *output; /** * \fn void writeOutput(const char* _msg) * \brief Scrive un messaggio nel browser di output * \param _msg Messaggio da visualizzare */ void writeOutput(const char*); }; #endif //_pacsCommunicator_h_
[ "kg_dexterp37@fde90bc1-0431-4138-8110-3f8199bc04de" ]
[ [ [ 1, 204 ] ] ]
5b3ce449d751fbc5dbd29a42dac78767aa7a658a
e7c45d18fa1e4285e5227e5984e07c47f8867d1d
/SMDK/Limn/LimnDW/Common/LimnModel_DiamondWizard_TrompCurve.cpp
2792c2bd032bebb88f91a54f9163e1c9eaea46aa
[]
no_license
abcweizhuo/Test3
0f3379e528a543c0d43aad09489b2444a2e0f86d
128a4edcf9a93d36a45e5585b70dee75e4502db4
refs/heads/master
2021-01-17T01:59:39.357645
2008-08-20T00:00:29
2008-08-20T00:00:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,636
cpp
//////////////////////////////////////////////////////////////////////////////////////////////////// ////// ////// #include <stdafx.h> #ifndef LIMNDW #include "globals.h" #endif #include "LimnModel_DiamondWizard_CommonFunctions.h" #include "LimnModel_DiamondWizard_TrompCurve.h" CLimn_ModelData_Common C_ModelParameters_DiamondWizard_TrompCurve::sm_Common; ////// // //---------------------------------------------------------------------------------------------- // // // Diamond Wizard - Tromp Curve model // // Parameters: // 0. A flag to identify the Floats product Stream (1 or 2) // 1. The water split fraction to Oversize // 2. The FeSi split fraction to Oversize // 3 to 2+nOreSizes. The tromp curve Ep values for Ore // 3+nOreSizes to 2+2*nOreSizes. The tromp curve Rho50 values for Ore // 3+2*nOreSizes to 2 + 2*nOreSizes + nDiamondSizes. The tromp curve Ep values for Diamond // 3 + 2*nOreSizes + nDiamondSizes to 2 + 2*nOreSizes + 2*nDiamondSizes. The tromp curve Rho50 values for Diamond // int _Model_DiamondWizard_TrompCurve (int nRows, int nColumns, int nParameters, int nReturns, double* ModelParams, double* ModelReturn, double* CombinedFeed, double* Product1, double* Product2, double* Product3, double* Product4, double* Product5, double* Product6 ) { int configID = CONFIGURATION.ID() ; CDiamondWizardConfiguration* thisConfig = CONFIGURATIONS.Configuration( configID ) ; // Find configuration worksheet if ( thisConfig != NULL ) { int nDSz = thisConfig->nDiamondSizes() ; // Limits int nOSz = thisConfig->nOreSizes() ; int nSG = thisConfig->nSGs() ; C_ModelParameters_DiamondWizard_TrompCurve p( ModelParams, nOSz, nDSz ) ; // model parameters - copied to class variables for clarity int iDSz ; // Counters int iOSz ; int iSG ; int idx = 0 ; // index into vector of stream data double partitionFraction ; double lockedSG ; if ( nParameters != (3 + 2*nOSz + 2*nDSz) ) { return 1 ; // 'Incorrect number of parameters' } /// /// Tromp Curve SG separator models /// /// Apply to Ore first /// for ( iOSz = 0 ; iOSz < nOSz ; iOSz++ ) { for ( iSG = 0 ; iSG < nSG ; iSG++ ) { idx = thisConfig->iODLimnStreamIndex ( iOSz, iSG ) ; partitionFraction = MeanTrompPartitionFraction( p.Ep(iOSz), p.Rho50(iOSz), thisConfig->SGsTop(iSG), thisConfig->SGsBottom(iSG) ) ; if (!p.Product1IsFloats()) partitionFraction = 1 - partitionFraction ; Product1[idx] = partitionFraction * CombinedFeed[idx] ; Product2[idx] = CombinedFeed[idx] - Product1[idx] ; } } /// /// Then apply to diamonds /// - handles locked diamond separation and /// separation of any liberated diamonds /// in the feed /// for ( iSG = 0 ; iSG < nSG ; iSG++ ) { for ( iDSz = 0 ; iDSz < nDSz ; iDSz++ ) { for ( iOSz = 0 ; iOSz < nOSz ; iOSz++ ) { idx = thisConfig->iDDLimnStreamIndex( iDSz, iOSz, iSG ) ; if ( thisConfig->IsLiberatedDiamond( iDSz, iOSz ) ) // check the diamond against all ore sizes { // to see if it is liberated lockedSG = thisConfig->DiamondSG() ; partitionFraction = 1 - 1 / (1 + exp(1.098 * (p.Rho50D(iDSz) - lockedSG) / p.EpD(iDSz))) ; } else { lockedSG = thisConfig->LockedParticleSG(iDSz, iOSz, iSG) ; partitionFraction = 1 - 1 / (1 + exp(1.098 * (p.Rho50(iOSz) - lockedSG) / p.Ep(iOSz))) ; } if ( !p.Product1IsFloats() ) partitionFraction = 1 - partitionFraction ; Product1[idx] = partitionFraction * CombinedFeed[idx] ; Product2[idx] = CombinedFeed[idx] - Product1[idx] ; } } } /// /// Then Water and FeSi splits /// idx = thisConfig->iWaterLimnStreamIndex() ; partitionFraction = p.WaterSplit() ; if ( !p.Product1IsFloats() ) partitionFraction = 1 - partitionFraction ; Product1[idx] = partitionFraction * CombinedFeed[idx] ; Product2[idx] = CombinedFeed[idx] - Product1[idx] ; idx = thisConfig->iFeSiLimnStreamIndex() ; partitionFraction = p.FeSiSplit(); if ( !p.Product1IsFloats() ) partitionFraction = 1 - partitionFraction ; Product1[idx] = partitionFraction * CombinedFeed[idx] ; Product2[idx] = CombinedFeed[idx] - Product1[idx] ; return 0 ; } else { return 3 ; // Error: "Could not access global configuration data" } } /// /// /*C_LINKAGE DLLMODEL */int _Error_DiamondWizard_TrompCurve( int errorIndex, LPSTR errorBuffer ) { return TRUE ; } /*C_LINKAGE DLLMODEL */int _Parameter_DiamondWizard_TrompCurve( int parameterIndex, LPSTR parameterInfoBuffer ) { return TRUE ; } // //
[ [ [ 1, 11 ], [ 17, 110 ], [ 112, 115 ], [ 117, 161 ] ], [ [ 12, 16 ], [ 111, 111 ], [ 116, 116 ] ] ]
a4ce114e5474afed107213efb6478549cd350cc4
ec5bf5236fa8219e2e872bd107e631f9167ad2a7
/include/guichan/irrlicht/irrlichtimageloader.hpp
13607178cffcc4c89ac321a0f46a0544c3abe81b
[ "BSD-3-Clause" ]
permissive
sanyaade-g2g-repos/guichan
3412d02644d0d2aeaa0ca7ed9c8f010f6b4ca516
aac6dda283bf77d4f7838c4a11ca8fa6325837c4
refs/heads/master
2020-06-05T22:22:43.864976
2009-04-13T10:29:58
2009-04-13T10:29:58
42,453,067
0
0
null
null
null
null
ISO-8859-2
C++
false
false
3,263
hpp
/* _______ __ __ __ ______ __ __ _______ __ __ * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ * * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson * * * Per Larsson a.k.a finalman * Olof Naessén a.k.a jansem/yakslem * * Visit: http://guichan.sourceforge.net * * License: (BSD) * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. Neither the name of Guichan nor the names of its contributors may * be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef GCN_IRRLICHTIMAGELOADER_HPP #define GCN_IRRLICHTIMAGELOADER_HPP #include "guichan/imageloader.hpp" #include "guichan/platform.hpp" #include "irrlicht.h" namespace gcn { class Image; /** * Irrlicht implementation of ImageLoader. * * @author Aaron Andersen * @since 0.9.0 */ class GCN_EXTENSION_DECLSPEC IrrlichtImageLoader : public ImageLoader { public: /** * Constructor. * * @param device The Irrlicht IVideoDriver device to use when loading images. */ IrrlichtImageLoader(irr::video::IVideoDriver* driver); /** * Destructor. */ ~IrrlichtImageLoader(); // Inherited from ImageLoader virtual Image* load(const std::string& filename, bool convertToDisplayFormat = true); protected: /** * Holds the Irrlicht IVideoDriver to use when loading images. */ irr::video::IVideoDriver* mDriver; }; } #endif // end GCN_IRRLICHTIMAGELOADER_HPP
[ "olof.naessen@9b4f5164-5a2d-0410-9de4-b3417c078dbe" ]
[ [ [ 1, 89 ] ] ]
e5ea27a3dd153b2c4fe19ecd4f19d2dfc12c517f
5e61787e7adba6ed1c2b5e40d38098ebdf9bdee8
/sans/models/c_smearer/smearer.cpp
80470e8a5f670f05eae8f6197b5f616e3bce0b97
[]
no_license
mcvine/sansmodels
4dcba43d18c930488b0e69e8afb04139e89e7b21
618928810ee7ae58ec35bbb839eba2a0117c4611
refs/heads/master
2021-01-22T13:12:22.721492
2011-09-30T14:01:06
2011-09-30T14:01:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,797
cpp
/** This software was developed by the University of Tennessee as part of the Distributed Data Analysis of Neutron Scattering Experiments (DANSE) project funded by the US National Science Foundation. If you use DANSE applications to do scientific research that leads to publication, we ask that you acknowledge the use of the software with the following sentence: "This work benefited from DANSE software developed under NSF award DMR-0520547." copyright 2009, University of Tennessee */ #include "smearer.hh" #include <stdio.h> #include <math.h> using namespace std; /** * Constructor for BaseSmearer * * @param qmin: minimum Q value * @param qmax: maximum Q value * @param nbins: number of Q bins */ BaseSmearer :: BaseSmearer(double qmin, double qmax, int nbins) { // Number of bins this->nbins = nbins; this->qmin = qmin; this->qmax = qmax; // Flag to keep track of whether we have a smearing matrix or // whether we need to compute one has_matrix = false; even_binning = true; }; /** * Constructor for BaseSmearer * * Used for uneven binning * @param q: array of Q values * @param nbins: number of Q bins */ BaseSmearer :: BaseSmearer(double* q, int nbins) { // Number of bins this->nbins = nbins; this->q_values = q; // Flag to keep track of whether we have a smearing matrix or // whether we need to compute one has_matrix = false; even_binning = false; }; /** * Constructor for SlitSmearer * * @param width: slit width in Q units * @param height: slit height in Q units * @param qmin: minimum Q value * @param qmax: maximum Q value * @param nbins: number of Q bins */ SlitSmearer :: SlitSmearer(double width, double height, double qmin, double qmax, int nbins) : BaseSmearer(qmin, qmax, nbins){ this->height = height; this->width = width; }; /** * Constructor for SlitSmearer * * @param width: slit width in Q units * @param height: slit height in Q units * @param q: array of Q values * @param nbins: number of Q bins */ SlitSmearer :: SlitSmearer(double width, double height, double* q, int nbins) : BaseSmearer(q, nbins){ this->height = height; this->width = width; }; /** * Constructor for QSmearer * * @param width: array slit widths for each Q point, in Q units * @param qmin: minimum Q value * @param qmax: maximum Q value * @param nbins: number of Q bins */ QSmearer :: QSmearer(double* width, double qmin, double qmax, int nbins) : BaseSmearer(qmin, qmax, nbins){ this->width = width; }; /** * Constructor for QSmearer * * @param width: array slit widths for each Q point, in Q units * @param q: array of Q values * @param nbins: number of Q bins */ QSmearer :: QSmearer(double* width, double* q, int nbins) : BaseSmearer(q, nbins){ this->width = width; }; /** * Compute the slit smearing matrix * * For even binning (q_min to q_max with nbins): * * step = (q_max-q_min)/(nbins-1) * first bin goes from q_min to q_min+step * last bin goes from q_max to q_max+step * * For binning according to q array: * * Each q point represents a bin going from half the distance between it * and the previous point to half the distance between it and the next point. * * Example: bin i goes from (q_values[i-1]+q_values[i])/2 to (q_values[i]+q_values[i+1])/2 * * The exceptions are the first and last bins, which are centered at the first and * last q-values, respectively. The width of the first and last bins is the distance between * their respective neighboring q-value. */ void SlitSmearer :: compute_matrix(){ weights = new vector<double>(nbins*nbins,0); // Check the length of the data if (nbins<2) return; int npts_h = height>0.0 ? npts : 1; int npts_w = width>0.0 ? npts : 1; // If both height and width are great than zero, // modify the number of points in each direction so // that the total number of points is still what // the user would expect (downgrade resolution) //if(npts_h>1 && npts_w>1){ // npts_h = (int)ceil(sqrt((double)npts)); // npts_w = npts_h; //} double shift_h, shift_w, hbin_size, wbin_size; // Make sure height and width are all positive (FWMH/2) // Assumption; height and width are all same for all q points if(npts_h == 1){ shift_h = 0.0; } else { shift_h = fabs(height); } if(npts_w == 1){ shift_w = 0.0; } else { shift_w = fabs(width); } // size of the h bin and w bin hbin_size = shift_h / nbins; wbin_size = shift_w / nbins; // Loop over all q-values for(int i=0; i<nbins; i++) { // Find Weights // Find q where the resolution smearing calculation of I(q) occurs double q, q_min, q_max, q_0; get_bin_range(i, &q, &q_min, &q_max); // Block q becomes <=0 if (q <= 0){ continue; } bool last_qpoint = true; // Find q[0] value to normalize the weight later, // otherwise, we will have a precision problem. if (i == 0){ q_0 = q; } // Loop over all qj-values bool first_w = true; for(int j=0; j<nbins; j++) { double q_j, q_high, q_low; // Calculate bin size of q_j get_bin_range(j, &q_j, &q_low, &q_high); // Block q_j becomes <=0 if (q_j <= 0){ continue; } // Check q_low that can not be negative. if (q_low < 0.0){ q_low = 0.0; } // default parameter values (*weights)[i*nbins+j] = 0.0; // protect for negative q if (q <= 0.0 || q_j <= 0.0){ continue; } double shift_w = 0.0; // Condition: zero slit smear. if (npts_w == 1 && npts_h == 1){ if(q_j == q) { (*weights)[i*nbins+j] = 1.0; } } //Condition:Smear weight integration for width >0 when the height (=0) does not present. //Or height << width. else if((npts_w!=1 && npts_h == 1)|| (npts_w!=1 && npts_h != 1 && width/height > 100.0)){ shift_w = width; //del_w = width/((double)npts_w-1.0); double q_shifted_low = q - shift_w; // High limit of the resolution range double q_shifted_high = q + shift_w; // Go through all the q_js for weighting those points if(q_j >= q_shifted_low && q_j <= q_shifted_high) { // The weighting factor comes, // Give some weight (delq_bin) for the q_j within the resolution range // Weight should be same for all qs except // for the q bin size at j. // Note that the division by q_0 is only due to the precision problem // where q_high - q_low gets to very small. // Later, it will be normalized again. (*weights)[i*nbins+j] += (q_high - q_low)/q_0 ; } } else{ // Loop for width (;Height is analytical.) // Condition: height >>> width, otherwise, below is not accurate enough. // Smear weight numerical iteration for width >0 when the height (>0) presents. // When width = 0, the numerical iteration will be skipped. // The resolution calculation for the height is done by direct integration, // assuming the I(q'=sqrt(q_j^2-(q+shift_w)^2)) is constant within a q' bin, [q_high, q_low]. // In general, this weight numerical iteration for width >0 might be a rough approximation, // but it must be good enough when height >>> width. for(int k=(-npts_w + 1); k<npts_w; k++){ if(npts_w!=1){ shift_w = width/((double)npts_w-1.0)*(double)k; } // For each q-value, compute the weight of each other q-bin // in the I(q) array // Low limit of the resolution range double q_shift = q + shift_w; if (q_shift < 0.0){ q_shift = 0.0; } double q_shifted_low = q_shift; // High limit of the resolution range double q_shifted_high = sqrt(q_shift * q_shift + shift_h * shift_h); // Go through all the q_js for weighting those points if(q_j >= q_shifted_low && q_j <= q_shifted_high) { // The weighting factor comes, // Give some weight (delq_bin) for the q_j within the resolution range // Weight should be same for all qs except // for the q bin size at j. // Note that the division by q_0 is only due to the precision problem // where q_high - q_low gets to very small. // Later, it will be normalized again. double q_shift_min = q - width; double u = (q_j * q_j - (q_shift) * (q_shift)); // The fabs below are not necessary but in case: the weight should never be imaginary. // At the edge of each sub_width. weight += u(at q_high bin) - u(0), where u(0) = 0, // and weighted by (2.0* npts_w -1.0)once for each q. //if (q == q_j) { if (q_low <= q_shift && q_high > q_shift) { //if (k==0) (*weights)[i*nbins+j] += (sqrt(fabs((q_high)*(q_high)-q_shift * q_shift)))/q_0;// * (2.0*double(npts_w)-1.0); } // For the rest of sub_width. weight += u(at q_high bin) - u(at q_low bin) else{// if (u > 0.0){ (*weights)[i*nbins+j] += (sqrt(fabs((q_high)*(q_high)- q_shift * q_shift))-sqrt(fabs((q_low)*(q_low)- q_shift * q_shift)))/q_0 ; } } } } } } }; /** * Compute the point smearing matrix */ void QSmearer :: compute_matrix(){ weights = new vector<double>(nbins*nbins,0); // Loop over all q-values double step = (qmax-qmin)/((double)nbins-1.0); double q, q_min, q_max; double q_j, q_jmax, q_jmin; for(int i=0; i<nbins; i++) { get_bin_range(i, &q, &q_min, &q_max); for(int j=0; j<nbins; j++) { get_bin_range(j, &q_j, &q_jmin, &q_jmax); // Compute the fraction of the Gaussian contributing // to the q_j bin between q_jmin and q_jmax long double value = erf( (q_jmax-q)/(sqrt(2.0)*width[i]) ); value -= erf( (q_jmin-q)/(sqrt(2.0)*width[i]) ); (*weights)[i*nbins+j] += value; } } } /** * Computes the Q range of a given bin of the Q distribution. * The range is computed according the the data distribution that * was given to the object at initialization. * * @param i: number of the bin in the distribution * @param q: q-value of bin i * @param q_min: lower bound of the bin * @param q_max: higher bound of the bin * */ int BaseSmearer :: get_bin_range(int i, double* q, double* q_min, double* q_max) { if (even_binning) { double step = (qmax-qmin)/((double)nbins-1.0); *q = qmin + (double)i*step; *q_min = *q - 0.5*step; *q_max = *q + 0.5*step; return 1; } else if (i>=0 && i<nbins) { *q = q_values[i]; if (i==0) { double step = (q_values[1]-q_values[0])/2.0; *q_min = *q - step; *q_max = *q + step; } else if (i==nbins-1) { double step = (q_values[i]-q_values[i-1])/2.0; *q_min = *q - step; *q_max = *q + step; } else { *q_min = *q - (q_values[i]-q_values[i-1])/2.0; *q_max = *q + (q_values[i+1]-q_values[i])/2.0; } return 1; } return -1; } /** * Perform smearing by applying the smearing matrix to the input Q array */ void BaseSmearer :: smear(double *iq_in, double *iq_out, int first_bin, int last_bin){ // If we haven't computed the smearing matrix, do it now if(!has_matrix) { compute_matrix(); has_matrix = true; } // Loop over q-values and multiply apply matrix for(int q_i=first_bin; q_i<=last_bin; q_i++){ double sum = 0.0; double counts = 0.0; for(int i=first_bin; i<=last_bin; i++){ // Skip if weight is less than 1e-03(this value is much smaller than // the weight at the 3*sigma distance // Will speed up a little bit... if ((*weights)[q_i*nbins+i] < 1.0e-003){ continue; } sum += iq_in[i] * (*weights)[q_i*nbins+i]; counts += (*weights)[q_i*nbins+i]; } // Normalize counts iq_out[q_i] = (counts>0.0) ? sum/counts : 0.0; } }
[ [ [ 1, 375 ] ] ]
9dd6c4bf497a91660957b7b1d29a2da7c592f6ac
94e2f239425cfafa921eb686bf7697d92c7a8d74
/jni/baby-engine/AndcopterRenderer.h
5462ad4dc59a638ee9a6a0b9ac79fdd01c1dad84
[]
no_license
parthmpandya/and-copter
f7814abf9942f0b0797b640fccfb2b183296a405
551be6c170f7a6562d0f2f093d431878078151bc
refs/heads/master
2020-05-31T13:27:38.418214
2011-07-20T18:50:07
2011-07-20T18:50:07
40,241,068
0
0
null
null
null
null
UTF-8
C++
false
false
463
h
#pragma once #include "Renderer.h" #include "Game.h" class AndcopterRenderer : public Renderer { protected: Game* game; public: AndcopterRenderer() : game(0) { fov_y = 45.0f; z_distance = -2; } virtual ~AndcopterRenderer() { if (game) { delete game; } } Game* getGame() { return game; } virtual void onCreate(); virtual void onSurfaceChange(int width, int height); virtual void onDraw(); };
[ [ [ 1, 34 ] ] ]
cdadf2732a99798ae2d947cf3bdc6465e53acf2f
3977ae61b891f7e8ae7d75b8e22bcb63dedc3c1c
/Base/Serializer.cpp
fc921267d37db4a4e0b9e067b19de2a207ff54c5
[]
no_license
jayrulez/ourprs
9734915b69207e7c3382412ca8647b051a787bb1
9d10f7a6edb06483015ed11dcfc9785f63b7204b
refs/heads/master
2020-05-17T11:40:55.001049
2010-03-25T05:20:04
2010-03-25T05:20:04
40,554,502
0
0
null
null
null
null
UTF-8
C++
false
false
393
cpp
/* @Group: BSC2D @Group Members: <ul> <li>Robert Campbell: 0701334</li> <li>Audley Gordon: 0802218</li> <li>Dale McFarlane: 0801042</li> <li>Dyonne Duberry: 0802189</li> </ul> @ */ #ifndef _SERIALIZER_H #include "./Serializer.h" #endif Serializer::Serializer() {} Serializer::~Serializer() {}
[ [ [ 1, 18 ] ] ]
2eb4a1bf396e9a11cbb18d09756c08ee239301d9
7dd2dbb15df45024e4c3f555da6d9ca6fc2c4d8b
/vacp/pluginmanager.h
e77762d502ba051406e0c84203c3fe4bb03dfabf
[]
no_license
wangscript/maelstrom-editor
c9f761e1f9e5f4e64d7e37834a7a63e04f57ae31
5bfab31bf444f44b9f8209f4deaed8715c305426
refs/heads/master
2021-01-10T01:37:00.619456
2011-11-21T23:17:08
2011-11-21T23:17:08
50,160,495
0
0
null
null
null
null
UTF-8
C++
false
false
728
h
#ifndef PLUGINMANAGER_H #define PLUGINMANAGER_H #include <QMap> #define NO_PLUGIN_HEADER #include <plugin_header/vacp_plugin_common.h> class QLibrary; class ContentExporter; class ContentExporterFactory; class PluginManager { private: QMap<QString, ContentExporterFactory*> exporters; QMap<QString, ContentCompilerFactory*> compilers; public: void register_plugins(); void register_exporter(char *exporter_name, void *token); void register_compiler(char *compiler_name, void *token); ContentExporter *create_texture_exporter(QString &exporter_name); ContentCompiler *create_texture_compiler(QString &compiler_name); PluginManager(); }; #endif // PLUGINMANAGER_H
[ [ [ 1, 28 ] ] ]
b467c88cbe76042adde43519584e6f7d50f00916
9c62af23e0a1faea5aaa8dd328ba1d82688823a5
/dependencies/OgreNewt/src/OgreNewt_MaterialPair.cpp
eb40a99df148caaa06f120d8090d15b1368040a0
[]
no_license
jacmoe/dsa-hl-svn
55b05b6f28b0b8b216eac7b0f9eedf650d116f85
97798e1f54df9d5785fb206c7165cd011c611560
refs/heads/master
2021-04-22T12:07:43.389214
2009-11-27T22:01:03
2009-11-27T22:01:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,763
cpp
#include "OgreNewt_MaterialPair.h" #include "OgreNewt_ContactJoint.h" namespace OgreNewt { MaterialPair::MaterialPair( const World* world, const MaterialID* mat1, const MaterialID* mat2 ) { m_world = world; id0 = mat1; id1 = mat2; m_contactcallback = NULL; } MaterialPair::~MaterialPair() { } void MaterialPair::setContactCallback( OgreNewt::ContactCallback* callback ) { m_contactcallback = callback; if( callback ) { NewtonMaterialSetCollisionCallback( m_world->getNewtonWorld(), id0->getID(), id1->getID(), this, collisionCallback_onAABBOverlap, collisionCallback_contactsProcess); } else { NewtonMaterialSetCollisionCallback( m_world->getNewtonWorld(), id0->getID(), id1->getID(), NULL, NULL, NULL); } } int _CDECL MaterialPair::collisionCallback_onAABBOverlap( const NewtonMaterial* material, const NewtonBody* newtonBody0, const NewtonBody* newtonBody1, int threadIndex ) { MaterialPair* me; me = (MaterialPair*)NewtonMaterialGetMaterialPairUserData( material ); Body* body0 = (OgreNewt::Body*)NewtonBodyGetUserData( newtonBody0 ); Body* body1 = (OgreNewt::Body*)NewtonBodyGetUserData( newtonBody1 ); return me->m_contactcallback->onAABBOverlap( body0, body1, threadIndex ); } void _CDECL MaterialPair::collisionCallback_contactsProcess(const NewtonJoint *newtonContactJoint, float timestep, int threadIndex ) { ContactJoint contactJoint(newtonContactJoint); MaterialPair* me = contactJoint.getMaterialPair(); if( me != NULL ) { ( me->m_contactcallback->contactsProcess )(contactJoint, timestep, threadIndex); } } }
[ "melven@4c79e8ff-cfd4-0310-af45-a38c79f83013" ]
[ [ [ 1, 64 ] ] ]
05f8136ee63d356624a45dd9e8b3ae4f6c7a80ac
5ac13fa1746046451f1989b5b8734f40d6445322
/minimangalore/Nebula2/code/nebula2/src/network/nusercontroller_main.cc
18877946378974b0e24148dfad11c1409f6b5c81
[]
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
2,825
cc
//------------------------------------------------------------------------------ // (C) 2006 RadonLabs GmbH //------------------------------------------------------------------------------ #include "kernel/nsystem.h" #include "kernel/nkernelserver.h" #include "network/nusercontroller.h" #include "util/nstring.h" #include "network/nbuddyserver.h" //nNebulaClass(nUserController, "nroot"); nUserController* nUserController::Singleton = 0; //------------------------------------------------------------------------------ /** */ nUserController::nUserController() { n_assert(0 == Singleton); Singleton = this; } //------------------------------------------------------------------------------ /** */ nUserController::~nUserController() { n_assert(Singleton); Singleton = 0; } void nUserController::Trigger() { nArray<int> lostConnections = nBuddyServer::Instance()->GetLostConnections(); for (int i=0;i< lostConnections.Size();i++) { this->DeleteUser(lostConnections[i]); } nBuddyServer::Instance()->ClearLostConnections(); } bool nUserController::AddUser(int ClientId,nString& name,nGuid& gameID) { nUserContext* context = n_new(nUserContext); context->SetIpcClientId(ClientId); context->SetUserName(name); context->SetGameGuid(gameID); this->UserContexts.PushBack(context); return true; } void nUserController::DeleteUser(int ClientId) { nArray<nUserContext*>::iterator it; for (it = this->UserContexts.Begin();it != this->UserContexts.End();it++) { if ((*it)->GetIpcClientId()==ClientId) { n_delete((*it)); this->UserContexts.EraseQuick(it); break; } } } bool nUserController::DeleteUser(nString& user) { nArray<nUserContext*>::iterator it; for (it = this->UserContexts.Begin();it != this->UserContexts.End();it++) { if ((*it)->GetUserName()==user) { n_delete((*it)); this->UserContexts.EraseQuick(it); return true; } } return false; } nUserContext* nUserController::GetUserContext(int ClientId) { nArray<nUserContext*>::iterator it; for (it = this->UserContexts.Begin();it != this->UserContexts.End();it++) { if ((*it)->GetIpcClientId()==ClientId) { return (*it); } } return NULL; } bool nUserController::GetClientID(nString& user,int& id) { nArray<nUserContext*>::iterator it; for (it = this->UserContexts.Begin();it != this->UserContexts.End();it++) { if ((*it)->GetUserName()==user) { id = (*it)->GetIpcClientId(); return true; } } return false; }
[ "BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c" ]
[ [ [ 1, 123 ] ] ]
81beac9ba255f792b6f04d9cf275d6f0c84780d6
00e841811d72cc6b6990b8c0bd38365a1290e976
/v1.1/source/system/inputdev/inputdev.h
167a44c5ff78a4877596e04ed7bdf1d1b1d134d8
[]
no_license
kurochan/OASIS
625aaa829fe32a95eaf7f44e82466b6698ddbfa8
17c0ecd6b00cbfc34d6e0217b28b81330c1cba21
refs/heads/master
2021-01-01T05:34:25.877020
2011-01-30T15:33:00
2011-01-30T15:33:00
1,313,246
0
0
null
null
null
null
UTF-8
C++
false
false
2,421
h
//========================================= // OASIS Kernel header code // Copyright (C) 2010 soS.A //========================================= #include "unsigned.h" //デバイスID //システム専用 static const UINT TIMER_ID_S = 1 ; static const UINT KEYBOARD_ID = 2 ; static const UINT MOUSE_ID_S = 3 ; static const UINT TIMER_ID = 4 ; static const UINT KEY_ID = 5 ; static const UINT MAX_ID = 6 ; //INPUTCTL上のFIFOでのデータの上位24bitがID識別子になっている //よって、使えるデバイスの数は最大16777215個。これだけのデバイスを接続する馬鹿はいないと思うので、問題なし。 //MAX_IDは登録するIDの最大値に1を足したもの //INPUTCTLのFIFOへアクセスするための窓口 class INPUTFIFO { UINT q; public: bool idFlag[MAX_ID]; // タスクが登録したIOデバイスのフラグを管理する配列(INPUTCTL以外からはアクセスしないべき) INPUTFIFO(void); UINT get(void); //INPUTCTLからデータ取得 void set_id(const unsigned dev_id); void remove_id(const unsigned dev_id); }; //外部デバイスからの入力データを管理するためのスーパーFIFO class INPUTCTL : private FIFO { public: INPUTCTL(void):FIFO(256){}; void i_put(const UINT data); //INPUTCTLFIFOにデータを追加 親クラスのputと全く同じ UINT i_get(UINT &i_q, const INPUTFIFO *Inputfifo); //INPUTCTLFIFOからデータの取得(INPUTFIFOからのみ呼び出される) void set_q(UINT &i_q); //INPUTCTLFIFOと同期(INPUTFIFOからのみ呼び出される) } extern *inputctl; inline void INPUTCTL::i_put(const UINT data){ put(data); return; } inline void INPUTCTL::set_q(UINT &i_q){ i_q=p; return ; } inline INPUTFIFO::INPUTFIFO(void){ inputctl->set_q(q); for(UINT cnt=0; cnt<MAX_ID; cnt++) idFlag[cnt]=0; } inline UINT INPUTFIFO::get(void){ return inputctl->i_get(q,this); } inline void INPUTFIFO::set_id(const unsigned dev_id){ idFlag[dev_id]=1; return; } inline void INPUTFIFO::remove_id(const unsigned dev_id){ idFlag[dev_id]=0; return; } struct MOUSE_DEC { UCHAR buf[3], phase, dat; int x, y, btn; } extern mdec; void enable_mouse(void); void init_keyboard(void); void wait_KBC_sendready(void) ; void kbc_reset(void);
[ [ [ 1, 84 ] ], [ [ 85, 85 ] ] ]
194c3f9f2f1e79b1d2ea2c51f144d31095d50059
0b66a94448cb545504692eafa3a32f435cdf92fa
/tags/0.3/cbear.berlios.de/range/reverse_sub_range.hpp
6022de75a33f490be7dbafb348361e8508e863f9
[ "MIT" ]
permissive
BackupTheBerlios/cbear-svn
e6629dfa5175776fbc41510e2f46ff4ff4280f08
0109296039b505d71dc215a0b256f73b1a60b3af
refs/heads/master
2021-03-12T22:51:43.491728
2007-09-28T01:13:48
2007-09-28T01:13:48
40,608,034
0
0
null
null
null
null
UTF-8
C++
false
false
1,951
hpp
/* The MIT License Copyright (c) 2005 C Bear (http://cbear.berlios.de) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef CBEAR_BERLIOS_DE_RANGE_REVERSE_SUB_RANGE_HPP_INCLUDED #define CBEAR_BERLIOS_DE_RANGE_REVERSE_SUB_RANGE_HPP_INCLUDED #include <cbear.berlios.de/range/reverse_iterator_range.hpp> #include <cbear.berlios.de/range/rbegin.hpp> #include <cbear.berlios.de/range/rend.hpp> namespace cbear_berlios_de { namespace range { template<class Range> struct reverse_sub_range: reverse_iterator_range<typename iterator<Range>::type> { }; template<class Range> typename reverse_sub_range<Range>::type make_reverse_sub_range( Range &X) { return reverse_sub_range<Range>::type(rbegin(X), rend(X)); } template<class Range> typename reverse_sub_range<const Range>::type make_reverse_sub_range( const Range &X) { return reverse_sub_range<const Range>::type(rbegin(X), rend(X)); } } } #endif
[ "sergey_shandar@e6e9985e-9100-0410-869a-e199dc1b6838" ]
[ [ [ 1, 57 ] ] ]
f3cdc66f04c0d54ffed19dadffae94bd0407ef20
0b66a94448cb545504692eafa3a32f435cdf92fa
/branches/kyr/cpp-object.sourceforge.net/src/cpp_object/arguments/in.hpp
65a99464fa447611181db0ddae6e59e877e25fcc
[]
no_license
BackupTheBerlios/cbear-svn
e6629dfa5175776fbc41510e2f46ff4ff4280f08
0109296039b505d71dc215a0b256f73b1a60b3af
refs/heads/master
2021-03-12T22:51:43.491728
2007-09-28T01:13:48
2007-09-28T01:13:48
40,608,034
0
0
null
null
null
null
UTF-8
C++
false
false
782
hpp
#ifndef CPP_OBJECT_ARGUMENTS_IN_HPP #define CPP_OBJECT_ARGUMENTS_IN_HPP #if defined(_MSC_VER) && _MSC_VER >= 1020 #pragma once #endif // _MSC_VER && _MSC_VER >= 1020 #include "cpp_object/arguments/declare_types.hpp" namespace cpp_object { namespace arguments { /// Input arguments passing /// Arguments are passed by reference to const for non-primitive types and /// by value for primitive types template<typename T> struct in : declare_types<in<T>, T> { in(reference t) : t_(t) { } operator param_type() { return t_; } private: this_reference operator=(this_const_reference); param_type t_; }; } // namespace arguments } // namespace cpp_object #endif // CPP_OBJECT_ARGUMENTS_IN_HPP
[ "sergey_shandar@e6e9985e-9100-0410-869a-e199dc1b6838" ]
[ [ [ 1, 40 ] ] ]
93e4c2688a70509012e4adaa30bd0ec3faf706f7
d258dd0ca5e8678c8eb81777e5fe360b8bbf7b7e
/Library/PhysXCPP/Nxap.cpp
65791ed74f7fffe0ed8b28f579e2270c2c975ec3
[]
no_license
ECToo/physxdotnet
1e7d7e9078796f1dad5c8582d28441a908e11a83
2b85d57bc877521cdbf1a9147bd6716af68a64b0
refs/heads/master
2021-01-22T07:17:58.918244
2008-04-13T11:15:26
2008-04-13T11:15:26
32,543,781
0
0
null
null
null
null
UTF-8
C++
false
false
40
cpp
#include "StdAfx.h" #include "Nxap.h"
[ "amiles@e8b6d1ee-b643-0410-9178-bfabf5f736f5" ]
[ [ [ 1, 2 ] ] ]
45c52ed67d374a78217d0c32198eaba73869e2f5
9b3df03cb7e134123cf6c4564590619662389d35
/FileInputStream.cpp
2a85606b04d1463691ee12c752b185af4d735ad4
[]
no_license
CauanCabral/Computacao_Grafica
a32aeff2745f40144a263c16483f53db7375c0ba
d8673aed304573415455d6a61ab31b68420b6766
refs/heads/master
2016-09-05T16:48:36.944139
2010-12-09T19:32:05
2010-12-09T19:32:05
null
0
0
null
null
null
null
ISO-8859-10
C++
false
false
2,601
cpp
//[]------------------------------------------------------------------------[] //| | //| GVSG Foundation Classes | //| Version 1.0 | //| | //| CopyrightŪ 2007, Paulo Aristarco Pagliosa | //| All Rights Reserved. | //| | //[]------------------------------------------------------------------------[] // // OVERVIEW: FileInputStream.cpp // ======== // Source code for file input stream. #ifndef __FileInputStream_h #include "FileInputStream.h" #endif using namespace System; ////////////////////////////////////////////////////////// // // FileInputStream implementation // =============== FileInputStream::FileInputStream(const char* fileName): file(fileName, File::readOnly | File::binary) //[]---------------------------------------------------[] //| Constructor | //[]---------------------------------------------------[] { // do nothing } FileInputStream::~FileInputStream() //[]---------------------------------------------------[] //| Destructor | //[]---------------------------------------------------[] { close(); } long FileInputStream::available() const //[]---------------------------------------------------[] //| Available | //[]---------------------------------------------------[] { return 0;//file.length() - file.position(); } void FileInputStream::close() //[]---------------------------------------------------[] //| Close | //[]---------------------------------------------------[] { file.close(); } long FileInputStream::read(void* buf, long len) //[]---------------------------------------------------[] //| Read | //[]---------------------------------------------------[] { return file.read(buf, len); } long FileInputStream::skip(long len) //[]---------------------------------------------------[] //| Skip | //[]---------------------------------------------------[] { return file.seek(len, File::cur); }
[ [ [ 1, 77 ] ] ]
d164cbab1ea9ba6baf03a331fd2c0f63c63affff
b7c505dcef43c0675fd89d428e45f3c2850b124f
/Src/SimulatorQt/Util/qt/Win32/include/Qt/q3sortedlist.h
113b9b770383faa1e20b10861f703e02633df03f
[ "BSD-2-Clause" ]
permissive
pranet/bhuman2009fork
14e473bd6e5d30af9f1745311d689723bfc5cfdb
82c1bd4485ae24043aa720a3aa7cb3e605b1a329
refs/heads/master
2021-01-15T17:55:37.058289
2010-02-28T13:52:56
2010-02-28T13:52:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,764
h
/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information ([email protected]) ** ** This file is part of the Qt3Support module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Commercial License Agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at [email protected]. ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef Q3SORTEDLIST_H #define Q3SORTEDLIST_H #include <Qt3Support/q3ptrlist.h> QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Qt3SupportLight) template<class type> class Q3SortedList : public Q3PtrList<type> { public: Q3SortedList() {} Q3SortedList( const Q3SortedList<type> &l ) : Q3PtrList<type>(l) {} ~Q3SortedList() { this->clear(); } Q3SortedList<type> &operator=(const Q3SortedList<type> &l) { return (Q3SortedList<type>&)Q3PtrList<type>::operator=(l); } virtual int compareItems( Q3PtrCollection::Item s1, Q3PtrCollection::Item s2 ) { if ( *((type*)s1) == *((type*)s2) ) return 0; return ( *((type*)s1) < *((type*)s2) ? -1 : 1 ); } }; QT_END_NAMESPACE QT_END_HEADER #endif // Q3SORTEDLIST_H
[ "alon@rogue.(none)" ]
[ [ [ 1, 71 ] ] ]
a49982e51be7a698497f1a41eed2cc814ae6cf81
4b0f51aeecddecf3f57a29ffa7a184ae48f1dc61
/CleanProject/MyGUI/include/MyGUI_Convert.h
865063d5c39609f1ad27459765090b4445c2fe9f
[]
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
UTF-8
C++
false
false
1,606
h
/*! @file @author Albert Semenov @date 10/2008 @module *//* This file is part of MyGUI. MyGUI 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. MyGUI 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 MyGUI. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __MYGUI_CONVERT_H__ #define __MYGUI_CONVERT_H__ #include "MyGUI_Prerequest.h" namespace MyGUI { namespace convert { std::wstring MYGUI_EXPORT ansi_to_wide(const std::string& _source); std::string MYGUI_EXPORT ansi_to_utf8(const std::string& _source); std::string MYGUI_EXPORT ansi_to_oem(const std::string& _source); std::wstring MYGUI_EXPORT utf8_to_wide(const std::string& _source); std::string MYGUI_EXPORT utf8_to_ansi(const std::string& _source); std::string MYGUI_EXPORT utf8_to_oem(const std::string& _source); std::string MYGUI_EXPORT wide_to_ansi(const std::wstring& _source); std::string MYGUI_EXPORT wide_to_utf8(const std::wstring& _source); std::string MYGUI_EXPORT wide_to_oem(const std::wstring& _source); } // namespace convert } // namespace MyGUI #endif // __MYGUI_CONVERT_H__
[ "pablosn@06488772-1f9a-11de-8b5c-13accb87f508" ]
[ [ [ 1, 49 ] ] ]
fca315ff29e1ecd32cda2567b8ab592618d7afa6
f11cba7f9546c9842e2e6feee6ab4420b96131ee
/src/bars/nprogressbar.h
fac91f28cafa71c2bf5fb3cf5a0d3a07ee04fcd2
[]
no_license
neuros/lib-widgets
3e6efb069e0eb0b4fe63263044fe54a859d55708
d38299b9d512343e7aacce95deae6d2cc52696f2
refs/heads/master
2016-09-03T07:14:08.509484
2008-09-11T08:32:09
2008-09-11T08:32:09
51,813
1
0
null
null
null
null
UTF-8
C++
false
false
1,639
h
#ifndef _NPROGRESSBAR_H_ #define _NPROGRESSBAR_H_ /* * Copyright(C) 2007 Neuros Technology International LLC. * <www.neurostechnology.com> * * * 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, version 2 of the License. * * * This program is distributed in the hope that, in addition to its * original purpose to support Neuros hardware, it will be useful * otherwise, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * **************************************************************************** * * NProgressBar implement header. * * REVISION: * * 1) Initial creation. ----------------------------------- 2008-07-21 WX * */ #include <QProgressBar> class NProgressBarPrivate; #if defined(DESIGNER) #include <QtDesigner/QDesignerExportWidget> class QDESIGNER_WIDGET_EXPORT NProgressBar : public QProgressBar #else class NProgressBar : public QProgressBar #endif { Q_OBJECT public: NProgressBar(QWidget *parent = NULL); virtual ~NProgressBar(); virtual QString text() const; private: NProgressBarPrivate *d; }; #endif // _NPROGRESSBAR_H_
[ [ [ 1, 56 ] ] ]
0fa19f331094d089af71b169deb61b02e9db1fe5
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/Dependencies/Xerces/include/xercesc/framework/psvi/XSObject.cpp
f5356eafce7b322e8268942100d5011161f8121e
[]
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
1,976
cpp
/* * Copyright 2003,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * $Id: XSObject.cpp 191054 2005-06-17 02:56:35Z jberry $ */ #include <xercesc/framework/psvi/XSObject.hpp> #include <xercesc/framework/psvi/XSModel.hpp> XERCES_CPP_NAMESPACE_BEGIN // --------------------------------------------------------------------------- // XSObject: Constructors and Destructor // --------------------------------------------------------------------------- XSObject::XSObject(XSConstants::COMPONENT_TYPE compType, XSModel* const xsModel, MemoryManager* const manager) : fComponentType(compType) , fXSModel(xsModel) , fMemoryManager(manager) , fId(0) { if (xsModel) { xsModel->addComponentToIdVector(this, compType-1); } } XSObject::~XSObject() { } // --------------------------------------------------------------------------- // XSObject: Virtual interface methods // --------------------------------------------------------------------------- const XMLCh *XSObject::getName() { return 0; } const XMLCh *XSObject::getNamespace() { return 0; } XSNamespaceItem *XSObject::getNamespaceItem() { return 0; } unsigned int XSObject::getId() const { return fId; } void XSObject::setId(unsigned int id) { fId = id; } XERCES_CPP_NAMESPACE_END
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 77 ] ] ]
6adbb7ef96f790e01ad149a96593302d230498a5
439d2881efebbcb3c06f8a5264bb83a9523ddc99
/src/samos.cpp
a9b9c6442145030a59f3e377c37d55f4ff390541
[]
no_license
hamidr/Samos
94ab4cb43ffa853c6c37cb951466f3a75fda4696
c734cea05fe0cef56ade21d9158841d6f0abcf74
refs/heads/master
2021-01-25T05:16:23.461976
2011-06-10T11:42:48
2011-06-10T11:42:48
1,471,399
0
0
null
null
null
null
UTF-8
C++
false
false
1,693
cpp
#include "samos.h" Samos::Samos() { ACC = new QString("0000000000"); MBR = new QString[10000]; id = new ID(MBR, ACC); this->isRunnable = false; qerr = new QTextStream(stderr); } void Samos::getFile(QString* addr) { SamosFile = addr; QFile infile(*SamosFile); if (!(this->isRunnable = infile.open(QIODevice::ReadOnly))) return; int count = 0; char endl = '\n'; // :D QString cmd; QTextStream file(&infile); while(!(cmd = file.readLine(0)).isEmpty()) { if ( cmd.mid(3,3) != "000" || cmd.size() < 10 ) { *qerr << "Oops! Error:\n" << "Line " <<count <<": " <<cmd << endl; *qerr << "Format should be like this: CMD000OPRD" << endl; this->isRunnable = false; infile.close(); return; } MBR[count] = cmd.mid(0,10); count++; } infile.close(); this->isRunnable = true; } void Samos::run() { if ( this->isRunnable ) { this->PC = 0; while( this->exec(&MBR[PC], &PC) ) PC++; } else { *qerr << "File is not runnable!" << '\n'; } } bool Samos::exec(QString *cmd, int *pc) { id->setCode(cmd, pc) ; return id->run(); } Samos::~Samos() { if ( this->isRunnable ) { *qerr << "\n\n*The END*\nREADING MEMORIES:\n"; for(int i=0; i<= 9999;i++) { if (! MBR[i].isEmpty()) *qerr <<i<<":\t"<< MBR[i] <<'\n'; } *qerr <<"ACC"<<":\t"<< *ACC <<'\n'; } delete[] MBR; delete qerr; delete id; delete ACC; }
[ [ [ 1, 75 ] ] ]
03d152436a5ee0a6b9265f0dc0cbc73f142bef74
c2a70374051ef8f96105d65c84023d97c90f4806
/bin/src/loadBmp/common/Filter/plhsvconvert.cpp
a59c02a0c67b2f2a0c8846a5c520b03264e303cd
[]
no_license
haselab-net/SpringheadOne
dcf6f10cb1144b17790a782f519ae25cbe522bb2
004335b64ec7bea748ae65a85463c0e85b98edbd
refs/heads/master
2023-08-04T20:27:17.158435
2006-04-15T16:49:35
2006-04-15T16:49:35
407,701,182
1
0
null
null
null
null
UTF-8
C++
false
false
3,379
cpp
/* /-------------------------------------------------------------------- | | $Id: plhsvconvert.cpp,v 1.2 2002/03/31 13:36:42 uzadow Exp $ | | Copyright (c) 1996-2002 Ulrich von Zadow | \-------------------------------------------------------------------- */ #include "plstdpch.h" #include "plhsvconvert.h" void fp_rgb_to_hsv (double *r, double *g, double *b) { int red, green, blue; double h=0, s, v; int min, max; int delta; red = (int)*r; green = (int)*g; blue = (int)*b; if (red > green) { if (red > blue) max = red; else max = blue; if (green < blue) min = green; else min = blue; } else { if (green > blue) max = green; else max = blue; if (red < blue) min = red; else min = blue; } v = max; if (max != 0) s = ((max - min) * 255) / (double) max; else s = 0; if (s == 0) h = 0; else { delta = max - min; if (red == max) h = (green - blue) / (double) delta; else if (green == max) h = 2 + (blue - red) / (double) delta; else if (blue == max) h = 4 + (red - green) / (double) delta; h *= 42.5; if (h < 0) h += 255; if (h > 255) h -= 255; } *r = h; *g = s; *b = v; } void fp_hsv_to_rgb (double *h, double *s, double *v) { double hue, saturation, value; double f, p, q, t; if (((int)*s) == 0) { *h = *v; *s = *v; *v = *v; } else { hue = *h * 6.0 / 255.0; saturation = *s / 255.0; value = *v / 255.0; f = hue - (int) hue; p = value * (1.0 - saturation); q = value * (1.0 - (saturation * f)); t = value * (1.0 - (saturation * (1.0 - f))); switch ((int) hue) { case 0: *h = value * 255.0; *s = t * 255.0; *v = p * 255.0; break; case 1: *h = q * 255.0; *s = value * 255.0; *v = p * 255.0; break; case 2: *h = p * 255.0; *s = value * 255.0; *v = t * 255.0; break; case 3: *h = p * 255.0; *s = q * 255.0; *v = value * 255.0; break; case 4: *h = t * 255.0; *s = p * 255.0; *v = value * 255.0; break; case 5: *h = value * 255.0; *s = p * 255.0; *v = q * 255.0; break; } } } /* /-------------------------------------------------------------------- | | $Log: /Project/Springhead/bin/src/loadBmp/common/Filter/plhsvconvert.cpp $ * * 1 04/07/12 13:34 Hase | Revision 1.2 2002/03/31 13:36:42 uzadow | Updated copyright. | | Revision 1.1 2001/09/16 19:03:23 uzadow | Added global name prefix PL, changed most filenames. | | Revision 1.1 2000/10/12 21:56:12 uzadow | Moved local functions from VideoInvertFilter.cpp to | hsvconvert.* | | | \-------------------------------------------------------------------- */
[ "jumius@05cee5c3-a2e9-0310-9523-9dfc2f93dbe1" ]
[ [ [ 1, 163 ] ] ]
a3df97d247ba7290cfb28a0ee74d8e324ca21815
08b064b3fb246f720b8d9727d690ca8c3b96d100
/Nordwind/gui/ViewWidget.hpp
8785be99c6322cdd1620bf271cd27dcef54c6a98
[]
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
661
hpp
#ifndef VIEW_HPP_ #define VIEW_HPP_ #include <qgraphicsview.h> namespace gui { class ViewWidget : public QGraphicsView { Q_OBJECT; public: ViewWidget( QGraphicsScene* scene = NULL, QWidget* parent = NULL ); // void setScene( QPointer<Scene> _scene ); // void setSceneRect( qreal _x, qreal _y, qreal _z, qreal _width, qreal _height ); virtual ~ViewWidget(); public Q_SLOTS: void moveView( QPoint _position, qint16 _z ); void toggleMap(bool enable); }; } #endif
[ "paulidstein@ae180d36-aaa7-11de-892d-7b2b76e7707e" ]
[ [ [ 1, 20 ] ] ]
828fcd65a85bce0a25c3f85969c3c75974257487
b1093f654e78210a00e6ca561c1a8f8f108f543e
/include/processor/UppercaseProcessor.h
0cbef7128e6180ea3f7a57b8e70f904058476556
[]
no_license
childhood/libAiml
bc82b7cd8859aa6fe0a7a3c42ffe4591438ae329
7954dc347463bcb4ab0070af87b9cbd421b08acc
refs/heads/master
2021-01-18T10:07:02.407246
2010-09-20T04:40:34
2010-09-20T04:40:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
537
h
/** * UppercaseProcessor - Transforms output to uppercase * * @author Jonathan Roewen */ #ifndef UPPERCASE_PROCESSOR_H #define UPPERCASE_PROCESSOR_H #include "AimlProcessor.h" #include "Kernel.h" #include "Utils.h" #include <string> using namespace std; class UppercaseProcessor : public AimlProcessor { public: ~UppercaseProcessor() { } string process(Match *m, PElement e, Responder *r, const string &id) { string result = Kernel::process(m, e, r, id); return toUpper(result); } }; #endif
[ [ [ 1, 28 ] ] ]
b7f32b71f26f7a3b95b7f1eb9e897b1f431f5caa
3d7fc34309dae695a17e693741a07cbf7ee26d6a
/shared/src/ionizer_utils.h
1e574000283a140c8a2db17c18f614e3553eddf4
[ "LicenseRef-scancode-public-domain" ]
permissive
nist-ionstorage/ionizer
f42706207c4fb962061796dbbc1afbff19026e09
70b52abfdee19e3fb7acdf6b4709deea29d25b15
refs/heads/master
2021-01-16T21:45:36.502297
2010-05-14T01:05:09
2010-05-14T01:05:09
20,006,050
5
0
null
null
null
null
UTF-8
C++
false
false
1,959
h
#pragma once #include <string> void creepy_speak(const std::string& s); #ifdef WIN32 //create an object of this class to create a directory and switch to it class working_dir { public: working_dir(const std::string& dir); const std::string dir; }; #endif //return current time in 100 ns units since 1900 unsigned long long CurrentTime_100ns(); //Returns current time in seconds since 1970 as a double. //This is standard UNIX time with additional digits. //Currently (Windows XP) the resolution seems to be 16 ms. double CurrentTime_s(); template<class T> inline int sign(const T& v) { return v > 0; } double factorial(int); template<class T> inline const T& bound(const T& val, const T& minimum, const T& maximum) { return std::min<T>(std::max<T>(val, minimum), maximum); } //append the file named by inputName to ofs void AppendFile(std::ofstream& ofs, const std::string& inputName); //return the date and time in "t" as YYYYMMDD_hhmmss //use the current time by default std::string GetDateTimeString(time_t t=0, int format=0); //return the time in "t" as hhmmss //use the current time by default std::string GetTimeString(time_t t=0); //return the time in "t" as hh:mm:ss //use the current time by default std::string GetNiceTimeString(time_t t=0); //return the date in "t" as YYYYMMDD (bShort=false) or YYMMDD (bShort=true) //use the current time by default std::string GetDateString(time_t t=0, bool bShort=false); #ifndef WIN32 struct RECT { int top, left, bottom, right; }; typedef struct RECT tagRECT; typedef RECT* LPRECT; #endif /* class Rect : public tagRECT { public: Rect() {}; Rect(const Point& p, const Point& sz) { left = p.x; top = p.y; right = p.x + sz.x; bottom = p.y + sz.y; }; Point Size() { return Point(right-left, bottom-top); } operator LPRECT () {return (LPRECT)this;} operator const RECT& () {return *this;} }; */
[ "trosen@814e38a0-0077-4020-8740-4f49b76d3b44" ]
[ [ [ 1, 81 ] ] ]
57d8ee6d6853c4aa17cb7658c277e01d6e9e81b5
6188f1aaaf5508e046cde6da16b56feb3d5914bc
/branches/CamFighter 1.0/App Framework/Input/InputMgr.cpp
61ff30bb23b7bbe92bf002c3849d9d7e9b7cb83a
[]
no_license
dogtwelve/fighter3d
7bb099f0dc396e8224c573743ee28c54cdd3d5a2
c073194989bc1589e4aa665714c5511f001e6400
refs/heads/master
2021-04-30T15:58:11.300681
2011-06-27T18:51:30
2011-06-27T18:51:30
33,675,635
1
0
null
null
null
null
UTF-8
C++
false
false
4,497
cpp
#include <fstream> #include "InputMgr.h" #ifdef WIN32 #pragma warning(disable : 4996) // deprecated #endif void InputMgr :: Key2InputCode_Set(byte kCode, int iCode) { int kIndex = KeyCode2Index(kCode); int iIndex = InputCode2Index(iCode); // replace existing key mapping if (kIndex) { if (iIndex == kIndex) return; InputMap->KeyCode2Index[kCode] = 0; // remove this kCode from search results byte kIndexOld = Index2FirstKeyCode(kIndex); // were there more mappings for this old Input Code? int iCodeOld = Index2InputCode(kIndex); // get old mapped Input Code assert (iCodeOld && iCode != iCodeOld); // it was the only keyCode->oldInputCode mapping if (!kIndexOld) { // so we may reuse its index if (!iIndex) { InputMap->KeyCode2Index[kCode] = kIndex; InputMap->InputCode2Index[iCode] = kIndex; FL_IndexState[kIndex] = 0; return; } // we already have our own index, we must free the unused one if (iIndex) { InputMap->KeyCode2Index[kCode] = iIndex; int lastIndex = InputMap->LastIndex; --InputMap->LastIndex; FL_IndexState[kIndex] = FL_IndexState[lastIndex]; InputMap->InputCode2Index[ Index2InputCode(lastIndex) ] = kIndex; for (int kCode = 0; kCode < NUM_KEYS; ++kCode) if (KeyCode2Index(kCode) == lastIndex) InputMap->KeyCode2Index[kCode] = kIndex; } } // the index is still occupied, we may zero kIndex and proceed normal path kIndex = 0; } if (!iIndex) { ++InputMap->LastIndex; InputMap->KeyCode2Index[kCode] = InputMap->LastIndex; InputMap->InputCode2Index[iCode] = InputMap->LastIndex; FL_IndexState[InputMap->LastIndex] = 0; return; } InputMap->KeyCode2Index[kCode] = iIndex; } void InputMgr :: LoadMap(const char *fileName) { assert(I_CodeCount); std::ifstream in; in.open(fileName); if (in.is_open()) { ClearMappings(); char buff[255]; while (in.good()) { in.getline(buff, 255); if (buff[0] == 0 || buff[0] == '#') continue; size_t len = strlen(buff); if (buff[len - 1] == '\r') buff[len - 1] = 0; if (buff[0] == '[') { InputMap = &ScenesMap[buff]; if (!InputMap->InputCode2Index) InputMap->Create(I_CodeCount); } else { if (InputMap) { const char *params = buff; int kCode = GetKeyCode(ReadSubstring(buff, params)); if (!kCode) continue; int iCode; sscanf(params, "%d", &iCode); Key2InputCode_Set(kCode, iCode); } } } in.close(); } } void InputMgr :: SaveMap(const char *fileName) { std::ofstream out; out.open(fileName); if (out.is_open()) { TScenesMap::iterator iter; for (iter = ScenesMap.begin(); iter != ScenesMap.end(); ++iter) { out << iter->first << '\n'; InputMap = &iter->second; for (int kCode = 0; kCode < NUM_KEYS; ++kCode) { int index = KeyCode2Index(kCode); if (index) { int iCode = Index2InputCode(index); out << GetKeyName(kCode) << '\t' << iCode << '\n'; } } } out.close(); } } void InputMgr :: LoadKeyCodeMap(const char *fileName) { std::ifstream in; in.open(fileName); if (in.is_open()) { KeyCodeNameMap.clear(); char buff[255]; int keyCode; char keyName[255]; while (in.good()) { in.getline(buff, 255); if (buff[0] == '\0' || buff[0] == '#') continue; sscanf(buff, "%d %s", &keyCode, keyName); KeyCodeNameMap[keyCode] = keyName; } in.close(); } }
[ "dmaciej1@f75eed02-8a0f-11dd-b20b-83d96e936561" ]
[ [ [ 1, 157 ] ] ]
a55083f636026e7fc5c179f4685702dfcebeb634
68cfffb549ab1cb32e02db4f80ed001a912e455b
/consnake-windows/main.cpp
fa80deeeb0f5ea72c7b4e62343a4695816c5a157
[]
no_license
xhbang/Console-snake
e462d6c206dc1dd071640f0ad203eb367460b2c8
a61cf9d91744f084741e2c29b930d9646256479b
refs/heads/master
2016-09-10T20:18:10.598179
2011-12-05T10:33:51
2011-12-05T10:33:51
2,902,986
0
0
null
null
null
null
UTF-8
C++
false
false
1,724
cpp
/**************************************************************************** * Copyright (C) 2008 Wurzer Roland * * * * Consnake 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. * * * * Consnake 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 Consnake. If not, see <http: www.gnu.org="" licenses="">. * * *************************************************************************/ #include "consnake.h" int main(int argc, char *argv[]) { draw_init(); srand(time(NULL)); Game *g = game_new(); draw_start_window(g); while(1) { game_main_loop(g); printw("Nochmal spielen? (j/N)"); refresh(); if(getchar() != 'j') break; game_reset(g); // } delete g; draw_deinit(); return 0; }
[ [ [ 1, 39 ] ] ]
fac0e15d0de316557b32650f2182e09f4c8b2e64
563e71cceb33a518f53326838a595c0f23d9b8f3
/v1/POC/Terrain.h
c34ce649c635cbf8158200d191127ef0b6c67d2c
[]
no_license
fabio-miranda/procedural
3d937037d63dd16cd6d9e68fe17efde0688b5a0a
e2f4b9d34baa1315e258613fb0ea66d1235a63f0
refs/heads/master
2021-05-28T18:13:57.833985
2009-10-07T21:09:13
2009-10-07T21:09:13
39,636,279
1
1
null
null
null
null
UTF-8
C++
false
false
1,021
h
#ifndef TERRAIN_H #define TERRAIN_H #include "node.h" #include "Heightmask.h" #include "Vector3.h" #include "Mesh.h" class Terrain : public Node{ protected: //void RenderQuad(int, int); //int GetArrayPosition(int, int); virtual void Render(bool,int); int m_height; int m_width; int m_renderStepSize; bool m_hasHeightmask; Heightmask m_heightmask; //Shaders cwc::glShader *m_shader; GLuint m_programObj; //Textures GLuint m_texture0; GLuint m_texture1; GLuint m_texture2; public: Terrain(int, Vector3<float>, Vector3<float>, int, int); ~ Terrain(); //VBO Mesh* m_mesh; virtual void FillHeightMap() = 0; void SetHeightMask(Heightmask); //int GetHeight(int, int); //Vector3<float> GetColor(int, int); void SetShader(); void LoadTexture(char*, GLuint&, GLuint); void Normalize(float, float); bool IsWithin(Vector3<float>); void InsertNode(Node*); Node* FindCurrentStandingNode(Vector3<float>); }; #endif
[ "fabiom@01b71de8-32d4-11de-96ab-f16d9912eac9" ]
[ [ [ 1, 64 ] ] ]
262e0b64d8f8659406956ace24639162980522c4
fcdddf0f27e52ece3f594c14fd47d1123f4ac863
/terralib/src/qwt/qwt_analog_clock.cpp
c6579868188a35f351474eb1370b5b9b2e8f49c3
[]
no_license
radtek/terra-printer
32a2568b1e92cb5a0495c651d7048db6b2bbc8e5
959241e52562128d196ccb806b51fda17d7342ae
refs/heads/master
2020-06-11T01:49:15.043478
2011-12-12T13:31:19
2011-12-12T13:31:19
null
0
0
null
null
null
null
ISO-8859-10
C++
false
false
5,245
cpp
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** * Qwt Widget Library * Copyright (C) 1997 Josef Wilgen * Copyright (C) 2002 Uwe Rathmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the Qwt License, Version 1.0 *****************************************************************************/ #include "qwt_analog_clock.h" /*! Constructor \param parent Parent widget */ QwtAnalogClock::QwtAnalogClock(QWidget *parent): QwtDial(parent) { setWrapping(true); setReadOnly(true); setOrigin(270.0); setRange(0.0, 60.0 * 60.0 * 12.0); // seconds setScale(-1, 5, 60.0 * 60.0); setScaleOptions(ScaleTicks | ScaleLabel); setScaleTicks(1, 0, 8); QColor knobColor = #if QT_VERSION < 0x040000 palette().color(QPalette::Active, QColorGroup::Text); #else palette().color(QPalette::Active, QPalette::Text); #endif knobColor = knobColor.dark(120); QColor handColor; int width; for ( int i = 0; i < NHands; i++ ) { if ( i == SecondHand ) { width = 2; handColor = knobColor.dark(120); } else { width = 8; handColor = knobColor; } QwtDialSimpleNeedle *hand = new QwtDialSimpleNeedle( QwtDialSimpleNeedle::Arrow, true, handColor, knobColor); hand->setWidth(width); d_hand[i] = NULL; setHand((Hand)i, hand); } } //! Destructor QwtAnalogClock::~QwtAnalogClock() { for ( int i = 0; i < NHands; i++ ) delete d_hand[i]; } /*! Nop method, use setHand instead \sa QwtAnalogClock::setHand */ void QwtAnalogClock::setNeedle(QwtDialNeedle *) { // no op return; } /*! Set a clockhand \param hand Specifies the type of hand \param needle Hand \sa QwtAnalogClock::hand() */ void QwtAnalogClock::setHand(Hand hand, QwtDialNeedle *needle) { if ( hand >= 0 || hand < NHands ) { delete d_hand[hand]; d_hand[hand] = needle; } } /*! \return Clock hand \param hd Specifies the type of hand \sa QwtAnalogClock::setHand */ QwtDialNeedle *QwtAnalogClock::hand(Hand hd) { if ( hd < 0 || hd >= NHands ) return NULL; return d_hand[hd]; } /*! \return Clock hand \param hd Specifies the type of hand \sa QwtAnalogClock::setHand */ const QwtDialNeedle *QwtAnalogClock::hand(Hand hd) const { return ((QwtAnalogClock *)this)->hand(hd); } /*! \brief Set the current time This is the same as QwtAnalogClock::setTime(), but Qt < 3.0 canīt handle default parameters for slots. */ void QwtAnalogClock::setCurrentTime() { setTime(QTime::currentTime()); } /*! Set a time \param time Time to display */ void QwtAnalogClock::setTime(const QTime &time) { if ( time.isValid() ) { setValue((time.hour() % 12) * 60.0 * 60.0 + time.minute() * 60.0 + time.second()); } else setValid(false); } /*! Find the scale label for a given value \param value Value \return Label */ QwtText QwtAnalogClock::scaleLabel(double value) const { if ( value == 0.0 ) value = 60.0 * 60.0 * 12.0; return QString::number(int(value / (60.0 * 60.0))); } /*! \brief Draw the needle A clock has no single needle but three hands instead. drawNeedle translates value() into directions for the hands and calls drawHand(). \param painter Painter \param center Center of the clock \param radius Maximum length for the hands \param direction Dummy, not used. \param cg ColorGroup \sa QwtAnalogClock::drawHand() */ void QwtAnalogClock::drawNeedle(QPainter *painter, const QPoint &center, int radius, double, QPalette::ColorGroup cg) const { if ( isValid() ) { const double hours = value() / (60.0 * 60.0); const double minutes = (value() - (int)hours * 60.0 * 60.0) / 60.0; const double seconds = value() - (int)hours * 60.0 * 60.0 - (int)minutes * 60.0; drawHand(painter, HourHand, center, radius, 360.0 - (origin() + 360.0 * hours / 12.0), cg); drawHand(painter, MinuteHand, center, radius, 360.0 - (origin() + 360.0 * minutes / 60.0), cg); drawHand(painter, SecondHand, center, radius, 360.0 - (origin() + 360.0 * seconds / 60.0), cg); } } /*! Draw a clock hand \param painter Painter \param hd Specify the type of hand \param center Center of the clock \param radius Maximum length for the hands \param direction Direction of the hand in degrees, counter clockwise \param cg ColorGroup */ void QwtAnalogClock::drawHand(QPainter *painter, Hand hd, const QPoint &center, int radius, double direction, QPalette::ColorGroup cg) const { const QwtDialNeedle *needle = hand(hd); if ( needle ) { if ( hd == HourHand ) radius = qRound(0.8 * radius); needle->draw(painter, center, radius, direction, cg); } }
[ "[email protected]@58180da6-ba8b-8960-36a5-00cc02a3ddec" ]
[ [ [ 1, 213 ] ] ]
e9818e6f62eb3ec324889fddd4e2fb60ed02526e
2b32433353652d705e5558e7c2d5de8b9fbf8fc3
/Dm_new_idz/Mlita/MatrixCtrl/MatrixCtrlPpg.h
5d9967a0ef8716ad664f34a423db6e83fb484600
[]
no_license
smarthaert/d-edit
70865143db2946dd29a4ff52cb36e85d18965be3
41d069236748c6e77a5a457280846a300d38e080
refs/heads/master
2020-04-23T12:21:51.180517
2011-01-30T00:37:18
2011-01-30T00:37:18
35,532,200
0
0
null
null
null
null
UTF-8
C++
false
false
1,464
h
#if !defined(AFX_MATRIXCTRLPPG_H__25CF4702_3A92_4FFD_A0D5_D6E6EA1482E0__INCLUDED_) #define AFX_MATRIXCTRLPPG_H__25CF4702_3A92_4FFD_A0D5_D6E6EA1482E0__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // MatrixCtrlPpg.h : Declaration of the CMatrixCtrlPropPage property page class. //////////////////////////////////////////////////////////////////////////// // CMatrixCtrlPropPage : See MatrixCtrlPpg.cpp.cpp for implementation. class CMatrixCtrlPropPage : public COlePropertyPage { DECLARE_DYNCREATE(CMatrixCtrlPropPage) DECLARE_OLECREATE_EX(CMatrixCtrlPropPage) // Constructor public: CMatrixCtrlPropPage(); // Dialog Data //{{AFX_DATA(CMatrixCtrlPropPage) enum { IDD = IDD_PROPPAGE_MATRIXCTRL }; // NOTE - ClassWizard will add data members here. // DO NOT EDIT what you see in these blocks of generated code ! //}}AFX_DATA // Implementation protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Message maps protected: //{{AFX_MSG(CMatrixCtrlPropPage) // NOTE - ClassWizard will add and remove member functions here. // DO NOT EDIT what you see in these blocks of generated code ! //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_MATRIXCTRLPPG_H__25CF4702_3A92_4FFD_A0D5_D6E6EA1482E0__INCLUDED)
[ [ [ 1, 46 ] ] ]
75cbc45cf59b7376d4b4a40df78bf67d2dffd3db
3d7fc34309dae695a17e693741a07cbf7ee26d6a
/aluminizerFPGA/dds_pulse.h
2fcb2056ab18d4ff60a087bfcb7f09bf63086019
[ "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
3,901
h
#ifndef DDS_PULSE_H_ #define DDS_PULSE_H_ #include "ttl_pulse.h" #include <float.h> #include <math.h> #include <algorithm> #include "shared/src/messaging.h" #include "host_interface.h" #include "common.h" #ifdef WIN32 #define scalb _scalb #define snprintf _snprintf #endif extern bool bDebugPulses; #define DDS_PRECOOL (0) #define DDS_RF (2) #define DDS_3P1x2 (1) #define DDS_DETECT (3) #define DDS_3P0_BR (4) #define DDS_HEAT (5) #define DDS_RAMAN (6) #define DDS_3P0 (7) #define DDS_NONE (100) #define PHASE_0 (0) #define PHASE_90 (1 << 12) #define PHASE_180 (1 << 13) #define PHASE_270 (PHASE_90 + PHASE_180) inline const char* DDS_name(unsigned iDDS) { switch (iDDS) { case DDS_PRECOOL: return " Precool"; // case DDS_RF: return " RF"; case DDS_3P1x2: return " 3P1 x 2"; case DDS_DETECT: return " Detect"; case DDS_HEAT: return " RF/Heat"; case DDS_RAMAN: return " Raman"; case DDS_3P0: return " 3P0 "; case DDS_3P0_BR: return " 3P0(BR)"; default: return " unknown"; } } unsigned FTW2Hz(unsigned ftw); double FTW2HzD(unsigned ftw); unsigned int Hz2FTW(double f); unsigned int MHz2FTW(double f); void print_pulse_info(unsigned iDDS, unsigned ftwOn, unsigned ftwOff, unsigned t, const char* info = 0); //make an RF pulse of specified frequency and duration inline void DDS_pulse(unsigned iDDS, unsigned ftwOn, unsigned ftwOff, unsigned t, unsigned ttl = 0) { if (t > 4) { PULSE_CONTROLLER_set_dds_freq(pulser, iDDS, ftwOn); PULSE_CONTROLLER_short_pulse(pulser, t, ttl); PULSE_CONTROLLER_set_dds_freq(pulser, iDDS, ftwOff); if (bDebugPulses) print_pulse_info(iDDS, ftwOn, ftwOff, t); } } inline void DDS_long_pulse(unsigned iDDS, unsigned ftwOn, unsigned ftwOff, unsigned t, unsigned flags, unsigned ttl = 0) { if (t > 4) { PULSE_CONTROLLER_set_dds_freq(pulser, iDDS, ftwOn); PULSE_CONTROLLER_pulse(pulser, t, flags, ttl); PULSE_CONTROLLER_set_dds_freq(pulser, iDDS, ftwOff); if (bDebugPulses) print_pulse_info(iDDS, ftwOn, ftwOff, t, "LONG"); } } /* inline void DDS_pulse(dds_pulse_params* pe) { DDS_pulse(p->iDDS, p->ftwOn, p->ftwOff, p->t); } */ inline void detection_pulse(unsigned ftwOn, unsigned ftwOff, unsigned t) { t = std::max<unsigned>(t, (unsigned)5); unsigned iDDS = DDS_DETECT; PULSE_CONTROLLER_short_pulse(pulser, 2000, 0); //padding (20 us seems like a lot?) PULSE_CONTROLLER_set_dds_freq(pulser, iDDS, ftwOn); PULSE_CONTROLLER_short_pulse(pulser, t | PULSE_CONTROLLER_COUNTING_PULSE_FLAG, TTL_DETECT_MON); PULSE_CONTROLLER_short_pulse(pulser, 5, 0); //padding PULSE_CONTROLLER_set_dds_freq(pulser, iDDS, ftwOff); if (bDebugPulses) print_pulse_info(iDDS, ftwOn, ftwOff, t, "DETECT"); } inline void DDS_off(unsigned iDDS) { PULSE_CONTROLLER_set_dds_freq(pulser, iDDS, 0); if (bDebugPulses) { sprintf(host->buffDebug, "%s DDS(%u) off %30s t = %8.2f us\n", DDS_name(iDDS), iDDS, "", (double)0.5); host->sendDebugMsg(host->buffDebug); } } inline void DDS_set_freq(unsigned iDDS, unsigned ftw) { PULSE_CONTROLLER_set_dds_freq(pulser, iDDS, ftw); if (bDebugPulses) { sprintf(host->buffDebug, "%s DDS(%u) f = %09u (ftw=%09X) t = %8.2f us\n", DDS_name(iDDS), iDDS, FTW2Hz(ftw), ftw, (double)0.5); host->sendDebugMsg(host->buffDebug); } } inline void DDS_set_phase(unsigned iDDS, unsigned phase) { PULSE_CONTROLLER_set_dds_phase(pulser, iDDS, phase); if (bDebugPulses) { sprintf(host->buffDebug, "%s DDS(%u) p = %9.3f degrees %9s t = %8.2f us\n", DDS_name(iDDS), iDDS, (phase * 360.0) / (1 << 14), "", (double)0.5); host->sendDebugMsg(host->buffDebug); } } #endif /*DDS_PULSE_H_*/
[ "trosen@814e38a0-0077-4020-8740-4f49b76d3b44" ]
[ [ [ 1, 144 ] ] ]
d5e8751770b3dbae4e2b8d2aeddeb2f9adfc6730
478570cde911b8e8e39046de62d3b5966b850384
/apicompatanamdw/bcdrivers/os/shortlinksrv/Bluetooth/T_BTSdpAPI/inc/T_DataSdpAttrValueBoolean.h
a8cb67bbbd6371fe3375f8ce9575c26b0fbf0289
[]
no_license
SymbianSource/oss.FCL.sftools.ana.compatanamdw
a6a8abf9ef7ad71021d43b7f2b2076b504d4445e
1169475bbf82ebb763de36686d144336fcf9d93b
refs/heads/master
2020-12-24T12:29:44.646072
2010-11-11T14:03:20
2010-11-11T14:03:20
72,994,432
0
0
null
null
null
null
UTF-8
C++
false
false
2,434
h
/* * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: * */ #if (!defined __T_DATA_SDP_ATTR_VALUE_BOOLEAN_H__) #define __T_DATA_SDP_ATTR_VALUE_BOOLEAN_H__ // User Includes #include "T_DataSdpAttrValue.h" /** * Test Active Notification class * */ class CT_DataSdpAttrValueBoolean : public CT_DataSdpAttrValue { public: /** * Two phase constructor */ static CT_DataSdpAttrValueBoolean* NewL(); /** * Public destructor */ ~CT_DataSdpAttrValueBoolean(); /** * Process a command read from the ini file * * @param aCommand The command to process * @param aSection The section in the ini containing data for the command * @param aAsyncErrorIndex Command index for async calls to return errors to * * @return ETrue if the command is processed * * @leave System wide error */ virtual TBool DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex); /** * Return a pointer to the object that the data wraps * * @return pointer to the object that the data wraps */ virtual TAny* GetObject() { return iAttrValBool; } /** * Set the object that the data wraps * * @param aObject object that the wrapper is testing * */ virtual void SetObjectL(TAny* aAny); /** * The object will no longer be owned by this * * @leave KErrNotSupported if the the function is not supported */ virtual void DisownObjectL(); inline virtual TCleanupOperation CleanupOperation(); protected: /** * Protected constructor. First phase construction */ CT_DataSdpAttrValueBoolean(); /** * Second phase construction */ void ConstructL(); virtual CSdpAttrValue* GetSdpAttrValue() const; private: static void CleanupOperation(TAny* aAny); /** * Helper methods */ void DestroyData(); inline void DoCmdNewBool(const TDesC& aSection); inline void DoCmdDestructor(); private: CSdpAttrValueBoolean* iAttrValBool; }; #endif /* __T_DATA_SDP_ATTR_VALUE_BOOLEAN_H__*/
[ "none@none" ]
[ [ [ 1, 106 ] ] ]
9c94e8bb5daa315547d34bc332414775b0655175
f2cbdee1dfdcad7b77c597e1af5f40ad83bad4aa
/MyJava/JRex/src/native/jni/dom/org_mozilla_jrex_dom_events_JRexEventImpl.cpp
d2adf673cf4cc4d9fa159347704b51d7f506693b
[]
no_license
jdouglas71/Examples
d03d9effc414965991ca5b46fbcf808a9dd6fe6d
b7829b131581ea3a62cebb2ae35571ec8263fd61
refs/heads/master
2021-01-18T14:23:56.900005
2011-04-07T19:34:04
2011-04-07T19:34:04
1,578,581
1
1
null
null
null
null
UTF-8
C++
false
false
21,290
cpp
/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * Contributor(s): * C.N Medappa <[email protected]><> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the NPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the NPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "org_mozilla_jrex_dom_events_JRexEventImpl.h" #include "nsIDOMNSEvent.h"//Don't change the order #include "JRexDOMGlobals.h" //event types for JRexDOMEvent enum JRexDOMEventEventTypes{JREX_GET_TARGET=0U, JREX_GET_CURR_TARGET, JREX_GET_ORIG_TARGET, JREX_GET_EXP_ORIG_TARGET}; static void* PR_CALLBACK HandleJRexDOMEventEvent(PLEvent* aEvent); static void PR_CALLBACK DestroyJRexDOMEventEvent(PLEvent* aEvent); inline JREX_JNI_UTIL::JRexCommonJRV* JRexEventImpl_GetTargetInternal(JNIEnv *env, nsIDOMEvent* domEvent){ JREX_JNI_UTIL::JRexCommonJRV *jrv=new JREX_JNI_UTIL::JRexCommonJRV; if(IS_NULL(jrv))return NULL; jobject jval=NULL; nsresult rv=NS_ERROR_FAILURE; if (domEvent){ nsCOMPtr<nsIDOMEventTarget> tmpTarget; rv = domEvent->GetTarget(getter_AddRefs(tmpTarget)); JREX_LOGLN("JRexEventImpl_GetTargetInternal()--> **** GetTarget rv<"<<rv<<"> ****") if(tmpTarget) jval=JRexDOMGlobals::CreateEventTarget(env, tmpTarget.get()); } jrv->jobj=jval; jrv->rv=rv; return jrv; } inline JREX_JNI_UTIL::JRexCommonJRV* JRexEventImpl_GetCurrentTargetInternal(JNIEnv *env, nsIDOMEvent* domEvent){ JREX_JNI_UTIL::JRexCommonJRV *jrv=new JREX_JNI_UTIL::JRexCommonJRV; if(IS_NULL(jrv))return NULL; jobject jval=NULL; nsresult rv=NS_ERROR_FAILURE; if (domEvent){ nsCOMPtr<nsIDOMEventTarget> tmpTarget; rv = domEvent->GetCurrentTarget(getter_AddRefs(tmpTarget)); JREX_LOGLN("JRexEventImpl_GetCurrentTargetInternal()--> **** GetCurrentTarget rv<"<<rv<<"> ****") if(tmpTarget) jval=JRexDOMGlobals::CreateEventTarget(env, tmpTarget.get()); } jrv->jobj=jval; jrv->rv=rv; return jrv; } inline JREX_JNI_UTIL::JRexCommonJRV* JRexEventImpl_GetOriginalTargetInternal(JNIEnv *env, nsIDOMEvent* domEvent){ JREX_JNI_UTIL::JRexCommonJRV *jrv=new JREX_JNI_UTIL::JRexCommonJRV; if(IS_NULL(jrv))return NULL; jobject jval=NULL; nsresult rv=NS_ERROR_FAILURE; nsCOMPtr<nsIDOMNSEvent> nsevent; if (domEvent && (nsevent=do_QueryInterface(domEvent))){ nsCOMPtr<nsIDOMEventTarget> tmpTarget; rv=nsevent->GetOriginalTarget(getter_AddRefs(tmpTarget)); JREX_LOGLN("JRexEventImpl_GetOriginalTargetInternal()--> **** GetOriginalTarget rv<"<<rv<<"> ****") if(tmpTarget) jval=JRexDOMGlobals::CreateEventTarget(env, tmpTarget.get()); } jrv->jobj=jval; jrv->rv=rv; return jrv; } inline JREX_JNI_UTIL::JRexCommonJRV* JRexEventImpl_GetExplicitOriginalTargetInternal(JNIEnv *env, nsIDOMEvent* domEvent){ JREX_JNI_UTIL::JRexCommonJRV *jrv=new JREX_JNI_UTIL::JRexCommonJRV; if(IS_NULL(jrv))return NULL; jobject jval=NULL; nsresult rv=NS_ERROR_FAILURE; nsCOMPtr<nsIDOMNSEvent> nsevent; if (domEvent && (nsevent=do_QueryInterface(domEvent))){ nsCOMPtr<nsIDOMEventTarget> tmpTarget; rv=nsevent->GetExplicitOriginalTarget(getter_AddRefs(tmpTarget)); JREX_LOGLN("JRexEventImpl_GetExplicitOriginalTargetInternal()--> **** GetExplicitOriginalTarget rv<"<<rv<<"> ****") if(tmpTarget) jval=JRexDOMGlobals::CreateEventTarget(env, tmpTarget.get()); } jrv->jobj=jval; jrv->rv=rv; return jrv; } /* * Class: org_mozilla_jrex_dom_events_JRexEventImpl * Method: GetType * Signature: ()Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_mozilla_jrex_dom_events_JRexEventImpl_GetType (JNIEnv *env, jobject jdomEvent){ if(!JRexDOMGlobals::sIntialized)return NULL; JREX_TRY nsIDOMEvent* thisEvent=(nsIDOMEvent*)NS_INT32_TO_PTR(env->GetIntField(jdomEvent, JRexDOMGlobals::domEventPeerID)); JREX_LOGLN("GetType()--> **** thisEvent <"<<thisEvent<<"> ****") if(IS_NULL(thisEvent)){ ThrowJRexException(env, "GetType()--> **** thisEvent DOES NOT EXIST!!! ****",0); return NULL; } nsEmbedString retString; nsresult rv = thisEvent->GetType(retString); JREX_LOGLN("GetType()--> **** GetType rv<"<<rv<<"> ****") if(NS_FAILED(rv)){ JREX_LOGLN("GetType()--> **** GetType NON-DOM ERROR OCCURED !!!****") ThrowJRexException(env, "**** GetType Failed ****",rv); return NULL; } NS_STR_TO_JSTR_RET(env,retString) JREX_CATCH(env) return NULL; } /* * Class: org_mozilla_jrex_dom_events_JRexEventImpl * Method: GetTarget * Signature: ()Lorg/w3c/dom/events/EventTarget; */ JNIEXPORT jobject JNICALL Java_org_mozilla_jrex_dom_events_JRexEventImpl_GetTarget (JNIEnv *env, jobject jdomEvent){ if(!JRexDOMGlobals::sIntialized)return NULL; JREX_TRY nsIDOMEvent* thisEvent=(nsIDOMEvent*)NS_INT32_TO_PTR(env->GetIntField(jdomEvent, JRexDOMGlobals::domEventPeerID)); JREX_LOGLN("GetTarget()--> **** thisEvent <"<<thisEvent<<"> ****") if(IS_NULL(thisEvent)){ ThrowJRexException(env, "GetTarget()--> **** thisEvent DOES NOT EXIST!!! ****",0); return NULL; } JREX_JNI_UTIL::JRexCommonJRV *jrv=NULL; if(IS_EQT){ JREX_LOGLN("GetTarget()--> **** IN EVT Q THREAD ****") jrv=JRexEventImpl_GetTargetInternal(env, thisEvent); }else{ nsresult rv=ExecInEventQDOM(thisEvent, JREX_GET_TARGET, nsnull, PR_TRUE, HandleJRexDOMEventEvent, DestroyJRexDOMEventEvent, (void**)&jrv); JREX_LOGLN("GetTarget()--> **** ExecInEventQDOM rv<"<<rv<<"> ****") } JREX_LOGLN("GetTarget()--> **** jrv<"<<jrv<<"> ****") if(NOT_NULL(jrv)){ nsresult rv=jrv->rv; jobject jobj=jrv->jobj; delete jrv; if(NS_FAILED(rv)){ JREX_LOGLN("GetTarget()--> **** GetTarget NON-DOM ERROR OCCURED !!!****") ThrowJRexException(env, "**** GetTarget Failed ****",rv); return NULL; } return jobj; } JREX_CATCH(env) return NULL; } /* * Class: org_mozilla_jrex_dom_events_JRexEventImpl * Method: GetCurrentTarget * Signature: ()Lorg/w3c/dom/events/EventTarget; */ JNIEXPORT jobject JNICALL Java_org_mozilla_jrex_dom_events_JRexEventImpl_GetCurrentTarget (JNIEnv *env, jobject jdomEvent){ if(!JRexDOMGlobals::sIntialized)return NULL; JREX_TRY nsIDOMEvent* thisEvent=(nsIDOMEvent*)NS_INT32_TO_PTR(env->GetIntField(jdomEvent, JRexDOMGlobals::domEventPeerID)); JREX_LOGLN("GetCurrentTarget()--> **** thisEvent <"<<thisEvent<<"> ****") if(IS_NULL(thisEvent)){ ThrowJRexException(env, "GetCurrentTarget()--> **** thisEvent DOES NOT EXIST!!! ****",0); return NULL; } JREX_JNI_UTIL::JRexCommonJRV *jrv=NULL; if(IS_EQT){ JREX_LOGLN("GetCurrentTarget()--> **** IN EVT Q THREAD ****") jrv=JRexEventImpl_GetCurrentTargetInternal(env, thisEvent); }else{ nsresult rv=ExecInEventQDOM(thisEvent, JREX_GET_CURR_TARGET, nsnull, PR_TRUE, HandleJRexDOMEventEvent, DestroyJRexDOMEventEvent, (void**)&jrv); JREX_LOGLN("GetCurrentTarget()--> **** ExecInEventQDOM rv<"<<rv<<"> ****") } JREX_LOGLN("GetCurrentTarget()--> **** jrv<"<<jrv<<"> ****") if(NOT_NULL(jrv)){ nsresult rv=jrv->rv; jobject jobj=jrv->jobj; delete jrv; if(NS_FAILED(rv)){ JREX_LOGLN("GetCurrentTarget()--> **** GetCurrentTarget NON-DOM ERROR OCCURED !!!****") ThrowJRexException(env, "**** GetCurrentTarget Failed ****",rv); return NULL; } return jobj; } JREX_CATCH(env) return NULL; } /* * Class: org_mozilla_jrex_dom_events_JRexEventImpl * Method: GetOriginalTarget * Signature: ()Lorg/w3c/dom/events/EventTarget; */ JNIEXPORT jobject JNICALL Java_org_mozilla_jrex_dom_events_JRexEventImpl_GetOriginalTarget (JNIEnv *env, jobject jdomEvent){ if(!JRexDOMGlobals::sIntialized)return NULL; JREX_TRY nsIDOMEvent* thisEvent=(nsIDOMEvent*)NS_INT32_TO_PTR(env->GetIntField(jdomEvent, JRexDOMGlobals::domEventPeerID)); JREX_LOGLN("GetOriginalTarget()--> **** thisEvent <"<<thisEvent<<"> ****") if(IS_NULL(thisEvent)){ ThrowJRexException(env, "GetOriginalTarget()--> **** thisEvent DOES NOT EXIST!!! ****",0); return NULL; } JREX_JNI_UTIL::JRexCommonJRV *jrv=NULL; if(IS_EQT){ JREX_LOGLN("GetOriginalTarget()--> **** IN EVT Q THREAD ****") jrv=JRexEventImpl_GetOriginalTargetInternal(env, thisEvent); }else{ nsresult rv=ExecInEventQDOM(thisEvent, JREX_GET_ORIG_TARGET, nsnull, PR_TRUE, HandleJRexDOMEventEvent, DestroyJRexDOMEventEvent, (void**)&jrv); JREX_LOGLN("GetOriginalTarget()--> **** ExecInEventQDOM rv<"<<rv<<"> ****") } JREX_LOGLN("GetOriginalTarget()--> **** jrv<"<<jrv<<"> ****") if(NOT_NULL(jrv)){ nsresult rv=jrv->rv; jobject jobj=jrv->jobj; delete jrv; if(NS_FAILED(rv)){ JREX_LOGLN("GetOriginalTarget()--> **** GetOriginalTarget NON-DOM ERROR OCCURED !!!****") ThrowJRexException(env, "**** GetOriginalTarget Failed ****",rv); return NULL; } return jobj; } JREX_CATCH(env) return NULL; } /* * Class: org_mozilla_jrex_dom_events_JRexEventImpl * Method: GetExplicitOriginalTarget * Signature: ()Lorg/w3c/dom/events/EventTarget; */ JNIEXPORT jobject JNICALL Java_org_mozilla_jrex_dom_events_JRexEventImpl_GetExplicitOriginalTarget (JNIEnv *env, jobject jdomEvent){ if(!JRexDOMGlobals::sIntialized)return NULL; JREX_TRY nsIDOMEvent* thisEvent=(nsIDOMEvent*)NS_INT32_TO_PTR(env->GetIntField(jdomEvent, JRexDOMGlobals::domEventPeerID)); JREX_LOGLN("GetExplicitOriginalTarget()--> **** thisEvent <"<<thisEvent<<"> ****") if(IS_NULL(thisEvent)){ ThrowJRexException(env, "GetExplicitOriginalTarget()--> **** thisEvent DOES NOT EXIST!!! ****",0); return NULL; } JREX_JNI_UTIL::JRexCommonJRV *jrv=NULL; if(IS_EQT){ JREX_LOGLN("GetExplicitOriginalTarget()--> **** IN EVT Q THREAD ****") jrv=JRexEventImpl_GetExplicitOriginalTargetInternal(env, thisEvent); }else{ nsresult rv=ExecInEventQDOM(thisEvent, JREX_GET_EXP_ORIG_TARGET, nsnull, PR_TRUE, HandleJRexDOMEventEvent, DestroyJRexDOMEventEvent, (void**)&jrv); JREX_LOGLN("GetExplicitOriginalTarget()--> **** ExecInEventQDOM rv<"<<rv<<"> ****") } JREX_LOGLN("GetExplicitOriginalTarget()--> **** jrv<"<<jrv<<"> ****") if(NOT_NULL(jrv)){ nsresult rv=jrv->rv; jobject jobj=jrv->jobj; delete jrv; if(NS_FAILED(rv)){ JREX_LOGLN("GetExplicitOriginalTarget()--> **** GetExplicitOriginalTarget NON-DOM ERROR OCCURED !!!****") ThrowJRexException(env, "**** GetExplicitOriginalTarget Failed ****",rv); return NULL; } return jobj; } JREX_CATCH(env) return NULL; } /* * Class: org_mozilla_jrex_dom_events_JRexEventImpl * Method: GetEventPhase * Signature: ()S */ JNIEXPORT jshort JNICALL Java_org_mozilla_jrex_dom_events_JRexEventImpl_GetEventPhase (JNIEnv *env, jobject jdomEvent){ if(!JRexDOMGlobals::sIntialized)return 0; JREX_TRY nsIDOMEvent* thisEvent=(nsIDOMEvent*)NS_INT32_TO_PTR(env->GetIntField(jdomEvent, JRexDOMGlobals::domEventPeerID)); JREX_LOGLN("GetEventPhase()--> **** thisEvent <"<<thisEvent<<"> ****") if(IS_NULL(thisEvent)){ ThrowJRexException(env, "GetEventPhase()--> **** thisEvent DOES NOT EXIST!!! ****",0); return 0; } PRUint16 retVal=0; nsresult rv = thisEvent->GetEventPhase(&retVal); JREX_LOGLN("GetEventPhase()--> **** GetEventPhase rv<"<<rv<<"> retVal<"<<retVal<<"> ****") if(NS_FAILED(rv)){ JREX_LOGLN("GetEventPhase()--> **** GetEventPhase NON-DOM ERROR OCCURED !!!****") ThrowJRexException(env, "**** GetEventPhase Failed ****",rv); return 0; } return (jshort)retVal; JREX_CATCH(env) return 0; } /* * Class: org_mozilla_jrex_dom_events_JRexEventImpl * Method: GetBubbles * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_org_mozilla_jrex_dom_events_JRexEventImpl_GetBubbles (JNIEnv *env, jobject jdomEvent){ if(!JRexDOMGlobals::sIntialized)return JNI_FALSE; JREX_TRY nsIDOMEvent* thisEvent=(nsIDOMEvent*)NS_INT32_TO_PTR(env->GetIntField(jdomEvent, JRexDOMGlobals::domEventPeerID)); JREX_LOGLN("GetBubbles()--> **** thisEvent <"<<thisEvent<<"> ****") if(IS_NULL(thisEvent)){ JREX_LOGLN("GetBubbles()--> **** thisEvent DOES NOT EXIST!!! ****"); return JNI_FALSE; } PRBool boolRet=PR_FALSE; nsresult rv =thisEvent->GetBubbles(&boolRet); JREX_LOGLN("GetBubbles()--> **** GetBubbles rv<"<<rv<<"> boolRet<"<<boolRet<<"> ****") if(NS_FAILED(rv)){ JREX_LOGLN("GetBubbles()--> **** GetBubbles NON-DOM ERROR OCCURED !!!****") ThrowJRexException(env, "**** GetBubbles Failed ****",rv); return JNI_FALSE; } return boolRet==PR_TRUE?JNI_TRUE:JNI_FALSE; JREX_CATCH(env) return JNI_FALSE; } /* * Class: org_mozilla_jrex_dom_events_JRexEventImpl * Method: GetCancelable * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_org_mozilla_jrex_dom_events_JRexEventImpl_GetCancelable (JNIEnv *env, jobject jdomEvent){ if(!JRexDOMGlobals::sIntialized)return JNI_FALSE; JREX_TRY nsIDOMEvent* thisEvent=(nsIDOMEvent*)NS_INT32_TO_PTR(env->GetIntField(jdomEvent, JRexDOMGlobals::domEventPeerID)); JREX_LOGLN("GetCancelable()--> **** thisEvent <"<<thisEvent<<"> ****") if(IS_NULL(thisEvent)){ JREX_LOGLN("GetCancelable()--> **** thisEvent DOES NOT EXIST!!! ****"); return JNI_FALSE; } PRBool boolRet=PR_FALSE; nsresult rv =thisEvent->GetCancelable(&boolRet); JREX_LOGLN("GetCancelable()--> **** GetCancelable rv<"<<rv<<"> boolRet<"<<boolRet<<"> ****") if(NS_FAILED(rv)){ JREX_LOGLN("GetCancelable()--> **** GetCancelable NON-DOM ERROR OCCURED !!!****") ThrowJRexException(env, "**** GetCancelable Failed ****",rv); return JNI_FALSE; } return boolRet==PR_TRUE?JNI_TRUE:JNI_FALSE; JREX_CATCH(env) return JNI_FALSE; } /* * Class: org_mozilla_jrex_dom_events_JRexEventImpl * Method: GetTimeStamp * Signature: ()J */ JNIEXPORT jlong JNICALL Java_org_mozilla_jrex_dom_events_JRexEventImpl_GetTimeStamp (JNIEnv *env, jobject jdomEvent){ if(!JRexDOMGlobals::sIntialized)return 0; JREX_TRY nsIDOMEvent* thisEvent=(nsIDOMEvent*)NS_INT32_TO_PTR(env->GetIntField(jdomEvent, JRexDOMGlobals::domEventPeerID)); JREX_LOGLN("GetTimeStamp()--> **** thisEvent <"<<thisEvent<<"> ****") if(IS_NULL(thisEvent)){ ThrowJRexException(env, "GetTimeStamp()--> **** thisEvent DOES NOT EXIST!!! ****",0); return 0; } DOMTimeStamp retVal=0; nsresult rv = thisEvent->GetTimeStamp(&retVal); JREX_LOGLN("GetTimeStamp()--> **** GetTimeStamp rv<"<<rv<<"> ****") if(NS_FAILED(rv)){ JREX_LOGLN("GetTimeStamp()--> **** GetTimeStamp NON-DOM ERROR OCCURED !!!****") ThrowJRexException(env, "**** GetTimeStamp Failed ****",rv); return 0; } return (jlong)retVal; JREX_CATCH(env) return 0; } /* * Class: org_mozilla_jrex_dom_events_JRexEventImpl * Method: StopPropagation * Signature: ()V */ JNIEXPORT void JNICALL Java_org_mozilla_jrex_dom_events_JRexEventImpl_StopPropagation (JNIEnv *env, jobject jdomEvent){ if(!JRexDOMGlobals::sIntialized)return; JREX_TRY nsIDOMEvent* thisEvent=(nsIDOMEvent*)NS_INT32_TO_PTR(env->GetIntField(jdomEvent, JRexDOMGlobals::domEventPeerID)); JREX_LOGLN("StopPropagation()--> **** thisEvent <"<<thisEvent<<"> ****") if(IS_NULL(thisEvent)){ ThrowJRexException(env, "StopPropagation()--> **** thisEvent DOES NOT EXIST!!! ****",0); return; } nsresult rv = thisEvent->StopPropagation(); JREX_LOGLN("StopPropagation()--> **** StopPropagation rv<"<<rv<<"> ****") if(NS_FAILED(rv)){ JREX_LOGLN("StopPropagation()--> **** StopPropagation NON-DOM ERROR OCCURED !!!****") ThrowJRexException(env, "**** StopPropagation Failed ****",rv); } JREX_CATCH(env) } /* * Class: org_mozilla_jrex_dom_events_JRexEventImpl * Method: PreventDefault * Signature: ()V */ JNIEXPORT void JNICALL Java_org_mozilla_jrex_dom_events_JRexEventImpl_PreventDefault (JNIEnv *env, jobject jdomEvent){ if(!JRexDOMGlobals::sIntialized)return; JREX_TRY nsIDOMEvent* thisEvent=(nsIDOMEvent*)NS_INT32_TO_PTR(env->GetIntField(jdomEvent, JRexDOMGlobals::domEventPeerID)); JREX_LOGLN("PreventDefault()--> **** thisEvent <"<<thisEvent<<"> ****") if(IS_NULL(thisEvent)){ ThrowJRexException(env, "PreventDefault()--> **** thisEvent DOES NOT EXIST!!! ****",0); return; } nsresult rv = thisEvent->PreventDefault(); JREX_LOGLN("PreventDefault()--> **** PreventDefault rv<"<<rv<<"> ****") if(NS_FAILED(rv)){ JREX_LOGLN("PreventDefault()--> **** PreventDefault NON-DOM ERROR OCCURED !!!****") ThrowJRexException(env, "**** PreventDefault Failed ****",rv); } JREX_CATCH(env) } /* * Class: org_mozilla_jrex_dom_events_JRexEventImpl * Method: InitEvent * Signature: (Ljava/lang/String;ZZ)V */ JNIEXPORT void JNICALL Java_org_mozilla_jrex_dom_events_JRexEventImpl_InitEvent (JNIEnv *env, jobject jdomEvent, jstring jtype, jboolean jcanBubble, jboolean jcanCancel){ if(!JRexDOMGlobals::sIntialized)return; JREX_TRY nsIDOMEvent* thisEvent=(nsIDOMEvent*)NS_INT32_TO_PTR(env->GetIntField(jdomEvent, JRexDOMGlobals::domEventPeerID)); JREX_LOGLN("InitEvent()--> **** thisEvent <"<<thisEvent<<"> ****") if(IS_NULL(thisEvent) || IS_NULL(jtype)){ ThrowJRexException(env, "InitEvent()--> **** thisEvent/jtype DOES NOT EXIST!!! ****",0); return; } PRUnichar* type=nsnull; JSTR_TO_NEW_PRUNI(env, jtype, type); nsEmbedString ttype(type); nsresult rv = thisEvent->InitEvent(ttype, (jcanBubble==JNI_TRUE?PR_TRUE:PR_FALSE), (jcanCancel==JNI_TRUE?PR_TRUE:PR_FALSE)); JREX_LOGLN("InitEvent()--> **** InitEvent rv<"<<rv<<"> ****") if(NS_FAILED(rv)){ JREX_LOGLN("InitEvent()--> **** InitEvent NON-DOM ERROR OCCURED !!!****") ThrowJRexException(env, "**** InitEvent Failed ****",rv); } JREX_CATCH(env) } /* * Class: org_mozilla_jrex_dom_events_JRexEventImpl * Method: Finalize * Signature: ()V */ JNIEXPORT void JNICALL Java_org_mozilla_jrex_dom_events_JRexEventImpl_Finalize (JNIEnv *env, jobject jdomEvent){ if(!JRexDOMGlobals::sIntialized)return; JREX_TRY nsIDOMEvent* thisEvent=(nsIDOMEvent*)NS_INT32_TO_PTR(env->GetIntField(jdomEvent, JRexDOMGlobals::domEventPeerID)); JREX_LOGLN("JRexEventImpl Finalize()--> **** thisEvent <"<<thisEvent<<"> ****") if(IS_NULL(thisEvent)){ ThrowJRexException(env, "JRexEventImpl Finalize()--> **** thisEvent DOES NOT EXIST!!! ****",0); return; } SAFE_RELEASE(thisEvent) JREX_CATCH(env) } void* PR_CALLBACK HandleJRexDOMEventEvent(PLEvent* aEvent){ if(!JRexDOMGlobals::sIntialized)return nsnull; JRexBasicEvent* event = NS_REINTERPRET_CAST(JRexBasicEvent*, aEvent); nsresult rv=NS_OK; JREX_LOGLN("HandleJRexDOMEventEvent()--> **** target <"<<event->target<<"> ****") nsCOMPtr<nsIDOMEvent> de(do_QueryInterface(NS_REINTERPRET_CAST(nsISupports*, event->target))); switch(event->eventType){ case JREX_GET_TARGET: { JREX_LOGLN("HandleJRexDOMEventEvent JREX_GET_TARGET EVENT!!!****") return (void*)JRexEventImpl_GetTargetInternal(nsnull, de.get()); } case JREX_GET_CURR_TARGET: { JREX_LOGLN("HandleJRexDOMEventEvent JREX_GET_CURR_TARGET EVENT!!!****") return (void*)JRexEventImpl_GetCurrentTargetInternal(nsnull, de.get()); } case JREX_GET_ORIG_TARGET: { JREX_LOGLN("HandleJRexDOMEventEvent JREX_GET_ORIG_TARGET EVENT!!!****") return (void*)JRexEventImpl_GetOriginalTargetInternal(nsnull, de.get()); } case JREX_GET_EXP_ORIG_TARGET: { JREX_LOGLN("HandleJRexDOMEventEvent JREX_GET_EXP_ORIG_TARGET EVENT!!!****") return (void*)JRexEventImpl_GetExplicitOriginalTargetInternal(nsnull, de.get()); } default: { JREX_LOGLN("HandleJRexDOMEventEvent()--> **** EVENT TYPE<"<<event->eventType<<"> not handled!!! ****") } } JREX_LOGLN("HandleJRexDOMEventEvent()--> **** returning rv<"<<rv<<"> ****") return (void*)rv; } void PR_CALLBACK DestroyJRexDOMEventEvent(PLEvent* aEvent){ JRexBasicEvent* event = NS_REINTERPRET_CAST( JRexBasicEvent*, aEvent); JREX_LOGLN("DestroyJRexDOMEventEvent()--> **** target <"<<event->target<<"> ****") delete event; }
[ [ [ 1, 572 ] ] ]
24cfb9ddf7f485db78e9a84ae003224aab54c209
f177993b13e97f9fecfc0e751602153824dfef7e
/ImProSln/ARTagApp/ImProClientMFCAppDlg.cpp
63b540d7d0cb80f6b1cd0748635e63770e9b3a94
[]
no_license
svn2github/imtophooksln
7bd7412947d6368ce394810f479ebab1557ef356
bacd7f29002135806d0f5047ae47cbad4c03f90e
refs/heads/master
2020-05-20T04:00:56.564124
2010-09-24T09:10:51
2010-09-24T09:10:51
11,787,598
1
0
null
null
null
null
UTF-8
C++
false
false
6,703
cpp
// ImProClientMFCAppDlg.cpp : implementation file // #include "stdafx.h" #include "ImProClientMFCApp.h" #include "ImProClientMFCAppDlg.h" #include <math.h> #ifdef _DEBUG #define new DEBUG_NEW #endif // CImProClientMFCAppDlg dialog CImProClientMFCAppDlg::CImProClientMFCAppDlg(CWnd* pParent /*=NULL*/) : CDialog(CImProClientMFCAppDlg::IDD, pParent) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_pDSCam = NULL; } void CImProClientMFCAppDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_BtnCaptureCam, m_btnCaptureCam); DDX_Control(pDX, IDC_BtnStopCapture, m_btnStopCapture); DDX_Control(pDX, IDC_picCapturePreview, m_picCapturePreview); DDX_Control(pDX, IDC_btnPlay, m_btnPlay); DDX_Control(pDX, IDC_btnPause, m_btnPause); DDX_Control(pDX, IDC_btnStop, m_btnStop); DDX_Control(pDX, IDC_SaveGraph, m_btnSaveGraph); DDX_Control(pDX, IDC_btnShowCamProp, m_btnCamProp); DDX_Control(pDX, IDC_btnCamPinProp, m_btnCamPinProp); DDX_Control(pDX, IDC_btnARProp, m_btnARProp); } BEGIN_MESSAGE_MAP(CImProClientMFCAppDlg, CDialog) ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP ON_BN_CLICKED(IDC_BtnCaptureCam, &CImProClientMFCAppDlg::OnBnClickedBtncapturecam) ON_BN_CLICKED(IDC_BtnStopCapture, &CImProClientMFCAppDlg::OnBnClickedBtnstopcapture) ON_BN_CLICKED(IDC_SaveGraph, &CImProClientMFCAppDlg::OnBnClickedSavegraph) ON_BN_CLICKED(IDC_btnPlay, &CImProClientMFCAppDlg::OnBnClickedbtnplay) ON_BN_CLICKED(IDC_btnPause, &CImProClientMFCAppDlg::OnBnClickedbtnpause) ON_BN_CLICKED(IDC_btnStop, &CImProClientMFCAppDlg::OnBnClickedbtnstop) ON_WM_DESTROY() ON_BN_CLICKED(IDC_btnShowCamProp, &CImProClientMFCAppDlg::OnBnClickedbtnshowcamprop) ON_BN_CLICKED(IDC_btnCamPinProp, &CImProClientMFCAppDlg::OnBnClickedbtncampinprop) ON_BN_CLICKED(IDC_btnARProp, &CImProClientMFCAppDlg::OnBnClickedbtnarprop) END_MESSAGE_MAP() // CImProClientMFCAppDlg message handlers BOOL CImProClientMFCAppDlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here m_btnCaptureCam.EnableWindow(TRUE); m_btnStopCapture.EnableWindow(FALSE); m_hWndCaptureWnd = 0; return TRUE; // return TRUE unless you set the focus to a control } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CImProClientMFCAppDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } // The system calls this function to obtain the cursor to display while the user drags // the minimized window. HCURSOR CImProClientMFCAppDlg::OnQueryDragIcon() { return static_cast<HCURSOR>(m_hIcon); } void CImProClientMFCAppDlg::OnBnClickedBtncapturecam() { if (m_pDSCam != NULL) { delete m_pDSCam; m_pDSCam = NULL; } bool ret; m_hWndCaptureWnd = m_picCapturePreview.GetSafeHwnd(); m_pDSCam = new ARTagCameraDS(); ret = m_pDSCam->OpenCamera(0, true); ret = m_pDSCam->SetVideoWindow(m_hWndCaptureWnd); void* argv[1] = {(void*)this}; m_pDSCam->SetARCallback(this->ARTagCallback, 1, argv); m_btnCaptureCam.EnableWindow(FALSE); m_btnStopCapture.EnableWindow(TRUE); m_btnPlay.EnableWindow(TRUE); m_btnPause.EnableWindow(FALSE); m_btnStop.EnableWindow(FALSE); m_btnSaveGraph.EnableWindow(TRUE); m_btnCamProp.EnableWindow(TRUE); m_btnCamPinProp.EnableWindow(TRUE); m_btnARProp.EnableWindow(TRUE); } void CImProClientMFCAppDlg::CaptureCallback(IplImage *frame) { OutputDebugStringW(L"@@@@@ CaptureCallBack!!!!!\n"); } void CImProClientMFCAppDlg::OnBnClickedBtnstopcapture() { if (m_pDSCam) { m_pDSCam->CloseCamera(); delete m_pDSCam; m_pDSCam = NULL; } m_btnCaptureCam.EnableWindow(TRUE); m_btnStopCapture.EnableWindow(FALSE); m_btnPlay.EnableWindow(FALSE); m_btnPause.EnableWindow(FALSE); m_btnStop.EnableWindow(FALSE); m_btnSaveGraph.EnableWindow(FALSE); m_btnCamProp.EnableWindow(FALSE); m_btnCamPinProp.EnableWindow(FALSE); m_btnARProp.EnableWindow(FALSE); } void CImProClientMFCAppDlg::OnBnClickedSavegraph() { if (m_pDSCam == NULL) { return; } m_pDSCam->SaveGraphFile(L"test.grf"); } void CImProClientMFCAppDlg::OnBnClickedbtnplay() { if (m_pDSCam == NULL) return; HRESULT hr; hr = m_pDSCam->Play(); if (FAILED(hr)) return; m_btnPlay.EnableWindow(FALSE); m_btnPause.EnableWindow(TRUE); m_btnStop.EnableWindow(TRUE); } void CImProClientMFCAppDlg::OnBnClickedbtnpause() { if (m_pDSCam == NULL) return; HRESULT hr; hr = m_pDSCam->Pause(); if (FAILED(hr)) return; m_btnPlay.EnableWindow(TRUE); m_btnPause.EnableWindow(FALSE); m_btnStop.EnableWindow(TRUE); } void CImProClientMFCAppDlg::OnBnClickedbtnstop() { if (m_pDSCam == NULL) return; HRESULT hr; hr = m_pDSCam->Stop(); if (FAILED(hr)) return; m_btnPlay.EnableWindow(TRUE); m_btnPause.EnableWindow(FALSE); m_btnStop.EnableWindow(FALSE); } BOOL CImProClientMFCAppDlg::ARTagCallback(int numDetected, const ARMarkerInfo* markinfos, const ARMultiMarkerInfoT* config, const double* matView, const double* matProj, int argc, void* argv[]) { WCHAR str[MAX_PATH]; swprintf_s(str, MAX_PATH, L"@@@@@ Got ARCallback!! numDetected = %d\n ", numDetected ); OutputDebugStringW(str); return TRUE; } void CImProClientMFCAppDlg::OnDestroy() { if (m_pDSCam != NULL) { m_pDSCam->Stop(); delete m_pDSCam; m_pDSCam = NULL; } CDialog::OnDestroy(); } void CImProClientMFCAppDlg::OnBnClickedbtnshowcamprop() { if (m_pDSCam == NULL) return; m_pDSCam->ShowCamProp(); } void CImProClientMFCAppDlg::OnBnClickedbtncampinprop() { if (m_pDSCam == NULL) return; m_pDSCam->ShowCamPinProp(); } void CImProClientMFCAppDlg::OnBnClickedbtnarprop() { if (m_pDSCam == NULL) return; m_pDSCam->ShowARProp(); }
[ "ndhumuscle@fa729b96-8d43-11de-b54f-137c5e29c83a" ]
[ [ [ 1, 262 ] ] ]
8e761bc6d2b82daddbe2ffd6a1627b0a768305f8
0b55a33f4df7593378f58b60faff6bac01ec27f3
/Konstruct/Client/Dimensions/ShoulderThrow.h
e99a3464a706c3ac3e376c4cd4f42b21071febcd
[]
no_license
RonOHara-GG/dimgame
8d149ffac1b1176432a3cae4643ba2d07011dd8e
bbde89435683244133dca9743d652dabb9edf1a4
refs/heads/master
2021-01-10T21:05:40.480392
2010-09-01T20:46:40
2010-09-01T20:46:40
32,113,739
1
0
null
null
null
null
UTF-8
C++
false
false
263
h
#pragma once #include "strike.h" class ShoulderThrow : public Strike { public: ShoulderThrow(void); ~ShoulderThrow(void); bool Update(PlayerCharacter* pSkillOwner, float fDeltaTime); protected: float m_fMinThrow; int m_iStrFactor; };
[ "bflassing@0c57dbdb-4d19-7b8c-568b-3fe73d88484e" ]
[ [ [ 1, 18 ] ] ]
e6cd710db28b33bf7729547bcacbd877ed634a13
822ab63b75d4d4e2925f97b9360a1b718b5321bc
/WeatherWidget2/inc/WeatherWidgetGraphicsView.h
16fcb75e15b58e9ba365bda79d83cbbc89f03736
[]
no_license
sriks/decii
71e4becff5c30e77da8f87a56383e02d48b78b28
02c58fbaea69c2448249710d13f2e774762da2c3
refs/heads/master
2020-05-17T23:03:27.822905
2011-12-16T07:29:38
2011-12-16T07:29:38
32,251,281
0
0
null
null
null
null
UTF-8
C++
false
false
461
h
#ifndef WEATHERWIDGETGRAPHICSVIEW_H_ #define WEATHERWIDGETGRAPHICSVIEW_H_ #include <QGraphicsView> class WeatherGraphicsWindow; class WeatherWidgetGraphicsView:public QGraphicsView { Q_OBJECT public: WeatherWidgetGraphicsView(); ~WeatherWidgetGraphicsView(); protected slots: void on_mainwindow_minimize(); private: WeatherGraphicsWindow* iMainWindow; QGraphicsScene* iScene; }; #endif /*WEATHERWIDGETGRAPHICSVIEW_H_*/
[ "srikanthsombhatla@016151e7-202e-141d-2e90-f2560e693586" ]
[ [ [ 1, 24 ] ] ]
1a472c2132cdbf79edfcff4357011f0e2ec1f51a
95a3e8914ddc6be5098ff5bc380305f3c5bcecb2
/src/FusionForever_lib/LineTrace.h
89c393319c067139751128397b879bc2dd9cc0b4
[]
no_license
danishcake/FusionForever
8fc3b1a33ac47177666e6ada9d9d19df9fc13784
186d1426fe6b3732a49dfc8b60eb946d62aa0e3b
refs/heads/master
2016-09-05T16:16:02.040635
2010-04-24T11:05:10
2010-04-24T11:05:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
592
h
#pragma once #include "Decoration.h" #define MAX_LINE_SECTIONS 100 #define LINE_SECTION_TIME 0.05f class LineTrace : public Decoration { protected: Vector3f line_trace_[MAX_LINE_SECTIONS+1]; int front_index_; virtual void InitialiseGraphics(){} BaseEntity* source_; bool first_run_; public: LineTrace(BaseEntity* _source, GLColor trail_color_); virtual ~LineTrace(void); virtual void Tick(float _timespan, Matrix4f _transform, std::vector<Decoration_ptr>& _decoration_spawn); virtual void DrawSelf(); virtual void EndSubscription(Subscriber* _source); };
[ "Edward Woolhouse@e6f1df29-e57c-d74d-9e6e-27e3b006b1a7", "[email protected]" ]
[ [ [ 1, 19 ], [ 21, 23 ] ], [ [ 20, 20 ] ] ]
8468c5476ed15d1f31ecd029db27727fd1f3d433
0b66a94448cb545504692eafa3a32f435cdf92fa
/tags/0.5/cbear.berlios.de/windows/com/enum.hpp
22ec6a86049a8b37e2769b4550ee8787b0203dcc
[ "MIT" ]
permissive
BackupTheBerlios/cbear-svn
e6629dfa5175776fbc41510e2f46ff4ff4280f08
0109296039b505d71dc215a0b256f73b1a60b3af
refs/heads/master
2021-03-12T22:51:43.491728
2007-09-28T01:13:48
2007-09-28T01:13:48
40,608,034
0
0
null
null
null
null
UTF-8
C++
false
false
2,082
hpp
/* The MIT License Copyright (c) 2005 C Bear (http://cbear.berlios.de) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef CBEAR_BERLIOS_DE_WINDOWS_COM_ENUM_HPP_INCLUDED #define CBEAR_BERLIOS_DE_WINDOWS_COM_ENUM_HPP_INCLUDED #include <cbear.berlios.de/windows/com/traits.hpp> namespace cbear_berlios_de { namespace windows { namespace com { template<class InternalType> class enum_policy: public policy::standard_policy<InternalType> { public: static void increment(InternalType &X) { X = InternalType(X + 1); } }; template<class Type, class ValueType> class enum_t: public policy::wrap<Type, ValueType, enum_policy<ValueType> > { public: typedef void *extra_result; typedef Type move_type; static const vartype_t vt = ::VT_INT; template<class ArchiveT> void serialize(ArchiveT &Archive, const unsigned int ) { Archive & boost::serialization::make_nvp("enum", this->internal()); } protected: enum_t() {} enum_t(ValueType X): policy::wrap<Type, ValueType, enum_policy<ValueType> >(X) { } }; } } } #endif
[ "sergey_shandar@e6e9985e-9100-0410-869a-e199dc1b6838" ]
[ [ [ 1, 65 ] ] ]
caa2bb69447af030d95c890fc801e1db982d00f4
00c36cc82b03bbf1af30606706891373d01b8dca
/Renderers/Ogre/DemoO/DemoAppFrameWork.cpp
9941a1ab1e84dec7858bec77b3a8dab244a505b6
[]
no_license
VB6Hobbyst7/opengui
8fb84206b419399153e03223e59625757180702f
640be732a25129a1709873bd528866787476fa1a
refs/heads/master
2021-12-24T01:29:10.296596
2007-01-22T08:00:22
2007-01-22T08:00:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,582
cpp
// OpenGUI (http://opengui.sourceforge.net) // This source code is released under the BSD License // See LICENSE.TXT for details #include "OgreRefApp.h" #include "DemoAppFrameWork.h" //#include "Renderer_OpenGL.h" #ifdef WIN32 int main( void ); int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { return main(); } #endif class OpenGUIInputReader : Ogre::FrameListener { public: OpenGUIInputReader(Ogre::RenderWindow* window) { Ogre::Root::getSingleton().addFrameListener(this); mInputDevice = Ogre::PlatformManager::getSingleton().createInputReader(); mInputDevice->initialise(window,true, true); //whatever the default scale is, it need to be double that! mInputDevice->setMouseScale( mInputDevice->getMouseScale() * 2.0f ); mButtonWasDown = false; mMousePos.x = window->getWidth() / 2; mMousePos.y = window->getHeight() / 2; mWindow = window; } virtual ~OpenGUIInputReader() { Ogre::Root::getSingleton().removeFrameListener(this); Ogre::PlatformManager::getSingleton().destroyInputReader( mInputDevice ); } virtual bool frameStarted (const FrameEvent &evt) { mInputDevice->capture(); if( mInputDevice->isKeyDown( KC_ESCAPE ) ){ return false; } long mx = mInputDevice->getMouseRelativeX(); long my = mInputDevice->getMouseRelativeY(); mMousePos.x += mx; mMousePos.y += my; if(mMousePos.x < 0) mMousePos.x = 0; if(mMousePos.y < 0) mMousePos.y = 0; if(mMousePos.x > (int)mWindow->getWidth()) mMousePos.x = mWindow->getWidth(); if(mMousePos.y > (int)mWindow->getHeight()) mMousePos.y = mWindow->getHeight(); DemoApp::getSingleton()._mousePositionCallback(mMousePos.x, mMousePos.y); bool curBtnState; curBtnState = mInputDevice->getMouseButton( 0 ); if( curBtnState != mButtonWasDown ){ mButtonWasDown = curBtnState; if(curBtnState){ DemoApp::getSingleton()._mouseButtonCallback(0,1); }else{ DemoApp::getSingleton()._mouseButtonCallback(0,0); } } DemoApp::getSingleton()._perframeRun(); return true; } protected: OpenGUI::IVector2 mMousePos; Ogre::InputReader* mInputDevice; bool mButtonWasDown; Ogre::RenderWindow* mWindow; }; OpenGUIInputReader* mptr_InputReader = 0; OgreRefApp* mptr_OgreRefApp = 0; DemoApp* DemoApp::mptr_Singleton = 0; DemoApp* DemoApp::getSingletonPtr() { assert( mptr_Singleton ); return mptr_Singleton; } DemoApp& DemoApp::getSingleton() { assert( mptr_Singleton ); return ( *mptr_Singleton ); } Ogre::RenderWindow* DemoApp::getWindow(){ return mptr_OgreRefApp->mWindow; } Ogre::Camera* DemoApp::getCamera(){ return mptr_OgreRefApp->mCamera; } void DemoApp::_perframeRun(){ perframeRun(); } void DemoApp::_mousePositionCallback( int x, int y ){ mousePositionCallback(x,y); } void DemoApp::_mouseButtonCallback( int button, int action ){ mouseButtonCallback(button,action); } DemoApp::DemoApp( std::string windowTitle ) { //singleton stuff assert( !mptr_Singleton ); mptr_Singleton = ( this ); mConfigured = false; mSystem = 0; mRenderer = 0; mptr_InputReader = 0; mptr_OgreRefApp = new OgreRefApp(); if(mptr_OgreRefApp->setup()){ mConfigured = true; mSystem = OpenGUI::System::getSingletonPtr(); mRenderer = OpenGUI::Renderer::getSingletonPtr(); mptr_InputReader = new OpenGUIInputReader(mptr_OgreRefApp->mWindow); } } DemoApp::~DemoApp() { assert( mptr_Singleton ); mptr_Singleton = 0; if(mptr_InputReader) delete mptr_InputReader; if(mptr_OgreRefApp) delete mptr_OgreRefApp; mptr_OgreRefApp = 0; mSystem = 0; mRenderer = 0; } void DemoApp::run() { preRun(); mptr_OgreRefApp->go(); postRun(); /* bool running = true; preRun(); while ( running ) { // OpenGL rendering goes here... glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); perframeRun(); mSystem->update(); postframeRun(); // Swap front and back rendering buffers glfwSwapBuffers(); // Check if ESC key was pressed or window was closed running = !glfwGetKey( GLFW_KEY_ESC ) && glfwGetWindowParam( GLFW_OPENED ); } postRun(); */ } void DemoApp::windowSizeChanged( int width, int height ) { OG_NYI; } void DemoApp::getWindowSize( int& width, int& height ){ if(mptr_OgreRefApp){ width = mptr_OgreRefApp->mWindow->getWidth(); height = mptr_OgreRefApp->mWindow->getHeight(); }else{ width = 0; height = 0; } }
[ "zeroskill@2828181b-9a0d-0410-a8fe-e25cbdd05f59" ]
[ [ [ 1, 189 ] ] ]
eb120a539baac5a2caa88e28fcbab5c9cb8df77b
2ca3ad74c1b5416b2748353d23710eed63539bb0
/Src/Lokapala/Operator/ExecutedProcessDTO.h
c19edeb5d5cf64e760c5f08fcf903f7c3768da5b
[]
no_license
sjp38/lokapala
5ced19e534bd7067aeace0b38ee80b87dfc7faed
dfa51d28845815cfccd39941c802faaec9233a6e
refs/heads/master
2021-01-15T16:10:23.884841
2009-06-03T14:56:50
2009-06-03T14:56:50
32,124,140
0
0
null
null
null
null
UTF-8
C++
false
false
748
h
/**@file ExecutedProcessDTO * @brief 실행된 프로세스 보고 관련 정보를 담는 CExecutedProcessDTO 클래스를 정의한다. * @author siva */ #ifndef EXECUTED_PROCESS_DTO_H #define EXECUTED_PROCESS_DTO_H /**@ingroup GroupDAM * @class CExecutedProcessDTO * @brief 실행된 프로세스의 보고에 관련된 정보를 담는 정보체. */ class CExecutedProcessDTO { public : CString m_executedProcessName; CString m_executedHostAddress; CExecutedProcessDTO(CString a_executedProcessName, CString a_executedHostAddress) { m_executedProcessName = a_executedProcessName; m_executedHostAddress = a_executedHostAddress; } CExecutedProcessDTO(){} ~CExecutedProcessDTO(){} }; #endif
[ "nilakantha38@b9e76448-5c52-0410-ae0e-a5aea8c5d16c" ]
[ [ [ 1, 30 ] ] ]
4902a48ba829c7b618d819ff5db7f2e9424a8dde
899e3440cda769c6a4b7649065dee47bc0516b6c
/topcoder/topcoder/TroytownKeeper.cpp
c6d290a7d071eb311f4dff8640fd991fd3de366d
[]
no_license
karanjude/snippets
6bf1492cb751a206e4b403ea7f03eda2a37c6892
a1c7e85b8999214f03b30469222cb64b5ad80146
refs/heads/master
2021-01-06T20:38:17.017406
2011-06-06T23:37:53
2011-06-06T23:37:53
32,311,843
0
0
null
null
null
null
ISO-8859-1
C++
false
false
5,526
cpp
/* Problem Statement      People enjoy mazes, but they also get them dirty. Arrows, graffiti, and chewing gum are just a few of the souvenirs people leave on the walls. You, the maze keeper, are assigned to whiten the maze walls. Each face of the wall requires one liter of paint, but you are only required to paint visible faces. You are given a map of the maze, and you must determine the amount of paint needed for the job. The maze is described by a vector <string> maze, where each character can be either '#' (a wall) or '.' (an empty space). All '.' characters on the perimeter of the map are considered entrances to the maze. Upon entering the maze, one can only move horizontally and vertically through empty spaces, and areas that are not reachable by these movements are not considered visible. Each '#' represents a square block with four wall faces (each side of the square is a face). A face is visible if it is not directly adjacent to another wall (and is in a reachable area of the maze). For example, two adjacent blocks can have at most six visible faces since two of their faces are directly adjacent to each other. All exterior faces on the perimeter are considered visible. For example, the following picture represents a trivial maze with just one (wide) entrance and only four empty reachable spaces: To whiten this maze you must paint the faces highlighted in yellow above: 16 for its perimeter, plus 8 interior faces. Note that there are faces that are not visible and thus need not be painted. Definition      Class: TroytownKeeper Method: limeLiters Parameters: vector <string> Returns: int Method signature: int limeLiters(vector <string> maze) (be sure your method is public)      Constraints - maze will contain between 1 and 50 elements, inclusive. - Each element of maze will contain between 1 and 50 characters, inclusive. - All elements of maze will have the same number of characters. - All characters in maze will be either '.' or '#'. Examples 0)      {"##..#" ,"#.#.#" ,"#.#.#" ,"#####"} Returns: 24 Example from the problem statement. 1)      {"##", "##"} Returns: 8 Only the perimeter of the maze (which has no interior!) has to be painted. 2)      {"######" ,"#....." ,"#.####" ,"#.#..#" ,"#.##.#" ,"#....#" ,"######"} Returns: 56 3)      {"######" ,"#....." ,"#..#.." ,"#....." ,"######"} Returns: 36 4)      {"#.#.#.#" ,".#.#.#." ,"#.#.#.#" ,".#.#.#."} Returns: 36 This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved. */ #include "stdafx.h" #include <map> #include <algorithm> #include <vector> #include <queue> #include <sstream> #include <string> #include <cctype> #include <utility.cpp> using namespace std; int dx[4] = {0 ,1,0,-1}; int dy[4] = {-1,0,1,0}; static int _maze[50][50][4]; struct Node{ Node(int x,int y){ this->x = x; this->y = y; } int x; int y; }; class TroytownKeeper{ private: queue<Node> q; int color_basic_walls_on_perimeter(vector<string> maze){ int walls = 0; for(int j = 0; j < maze[0].length(); j++) if(maze[0][j] == '#') walls++; else q.push(Node(j,0)); for(int j = 0;j < maze.size(); j++) if(maze[j][0] == '#') walls++; else q.push(Node(0,j)); for(int j = 0;j < maze.size();j++) if(maze[j][maze[0].length()-1] == '#') walls++; else q.push(Node(maze[0].length()-1,j)); for(int j = 0; j < maze[maze.size()-1].length(); j++) if(maze[maze.size()-1][j] == '#') walls++; else q.push(Node(j,maze.size()-1)); return walls; } void initialize(){ memset(_maze,0,sizeof(_maze)); } public: int limeLiters(vector <string> maze){ initialize(); int maxx = maze[0].length() -1; int maxy = maze.size() -1; int visited_walls = 0; int walls = color_basic_walls_on_perimeter(maze); while(!q.empty()){ Node top = q.front(); q.pop(); int x = top.x; int y = top.y; if(_maze[y][x][0]) continue; else { _maze[y][x][0] = _maze[y][x][1] = _maze[y][x][2] = _maze[y][x][3] = 1; } for(int i = 0;i < 4;i++){ int xx = x + dx[i]; int yy = y + dy[i]; if(xx < 0 || xx > maxx || yy < 0 || yy > maxy ) continue; if(maze[yy][xx] == '.') q.push(Node(xx,yy)); else{ if(!_maze[yy][xx][i]){ _maze[yy][xx][i] = 1; visited_walls++; } } } } return walls + visited_walls; } }; int _tmain(int argc, _TCHAR* argv[]){ TroytownKeeper t; string w[] = {"##", "##"}; are_equal_with_print<int>(8, t.limeLiters(to_vector<string,2>(w))); string w1[] = {"##..#" ,"#.#.#" ,"#.#.#" ,"#####"}; are_equal_with_print<int>(24,t.limeLiters(to_vector<string,4>(w1))); string w2[] = {"######" ,"#....." ,"#.####" ,"#.#..#" ,"#.##.#" ,"#....#" ,"######"}; are_equal_with_print<int>(56,t.limeLiters(to_vector<string,7>(w2))); string w3[] = {"######" ,"#....." ,"#..#.." ,"#....." ,"######"}; are_equal_with_print<int>(36,t.limeLiters(to_vector<string,5>(w3))); string w4[] = {"#.#.#.#" ,".#.#.#." ,"#.#.#.#" ,".#.#.#."}; are_equal_with_print<int>(36,t.limeLiters(to_vector<string,4>(w4))); int ii; cin >> ii; return 0; }
[ "karan.jude@737fc9ef-4d2d-0410-97ed-4d0c502f76d2" ]
[ [ [ 1, 219 ] ] ]
20b1873e403e9fa9af1879337e5975de8c5cb870
c70941413b8f7bf90173533115c148411c868bad
/plugins/SwfPlugin/src/vtxswfContourPoint.cpp
2096b85ac7ceee94677212e6664ebe6d6b0c1bb2
[]
no_license
cnsuhao/vektrix
ac6e028dca066aad4f942b8d9eb73665853fbbbe
9b8c5fa7119ff7f3dc80fb05b7cdba335cf02c1a
refs/heads/master
2021-06-23T11:28:34.907098
2011-03-27T17:39:37
2011-03-27T17:39:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,183
cpp
/* ----------------------------------------------------------------------------- This source file is part of "vektrix" (the rich media and vector graphics rendering library) For the latest info, see http://www.fuse-software.com/ Copyright (c) 2009-2010 Fuse-Software (tm) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------------- */ #include "vtxswfContourPoint.h" namespace vtx { namespace swf { //----------------------------------------------------------------------- ContourPoint::ContourPoint() : x(0), y(0) { } //----------------------------------------------------------------------- ContourPoint::~ContourPoint() { } //----------------------------------------------------------------------- bool ContourPoint::operator!=(const ContourPoint& a) { return (*this).x != a.x || (*this).y != a.y; } //----------------------------------------------------------------------- bool ContourPoint::operator==(const ContourPoint& a) { return (*this).x == a.x && (*this).y == a.y; } //----------------------------------------------------------------------- }}
[ "stonecold_@9773a11d-1121-4470-82d2-da89bd4a628a" ]
[ [ [ 1, 54 ] ] ]
8b938bb3ee6660317359487dad5ffd82c06b81b3
59f1959abb023c7e0a7ce2a347c250d799339fd8
/SceneStudio/SceneStudioDLL/UIEvent.h
74682123bbf4b57cd58445c48d3b9ed3e63c23d2
[]
no_license
ghsoftco/scenegallery
78580a8aaf02a0c7ccc2687bc4a40c1873da5715
965fabdb39cbdd7c9735aaa5daab9f617bf020cf
refs/heads/master
2021-01-10T11:18:30.032732
2011-10-14T20:56:27
2011-10-14T20:56:27
47,763,913
0
0
null
null
null
null
UTF-8
C++
false
false
1,228
h
enum UIEventType { UIEventSaveScene, UIEventUploadScene, UIEventClearSelection, UIEventRotate, UIEventResetRotation, UIEventScale, UIEventFlipFace, UIEventCopy, UIEventPaste, UIEventDelete, UIEventUndo, UIEventResetCamera, UIEventHelp, UIEventHomepage, UIEventTextSearch, UIEventShapeSearch, UIEventModelChosen, UIEventEnterInsertMode, UIEventEnterNormalMode, UIEventEnterSelectingMode, UIEventEnterLookingMode, UIEventDollyCamera, UIEventEnterMoveSurfacesMode, UIEventEnterMovePlaneMode, UIEventEnterMoveLevitateMode, UIEventMouseDown, UIEventMouseUp, UIEventMouseMove, UIEventKeywordSearchExemplar, UIEventKeywordSearchModel, UIEventClickModel, UIEventClickExemplar, UIEventNULL, }; class UIEvent { public: UIEvent() { _time = -1.0f; } UIEvent(float time, UIEventType type, String data); UIEvent(const String &s); static UIEventType tagToType(const String &tag); void print(std::ostream &os) const; private: static map<UIEventType, String> fillTagMap(); static map<UIEventType, String> tagMap; float _time; UIEventType _type; String _data; }; ostream& operator<<(ostream &os, const UIEvent &e);
[ [ [ 1, 35 ] ] ]
eb5a7aa3efaf3165e043fb84dddc7b19a472c918
12203ea9fe0801d613bbb2159d4f69cab3c84816
/Export/cpp/windows/obj/src/StringBuf.cpp
cfdaa1d6df88f5335cd3564e7db3888d7d469926
[]
no_license
alecmce/haxe_game_of_life
91b5557132043c6e9526254d17fdd9bcea9c5086
35ceb1565e06d12c89481451a7bedbbce20fa871
refs/heads/master
2016-09-16T00:47:24.032302
2011-10-10T12:38:14
2011-10-10T12:38:14
2,547,793
0
0
null
null
null
null
UTF-8
C++
false
false
3,641
cpp
#include <hxcpp.h> #ifndef INCLUDED_StringBuf #include <StringBuf.h> #endif Void StringBuf_obj::__construct() { { HX_SOURCE_POS("C:\\Motion-Twin\\haxe/std/StringBuf.hx",35) this->b = Dynamic( Array_obj<Dynamic>::__new() ); } ; return null(); } StringBuf_obj::~StringBuf_obj() { } Dynamic StringBuf_obj::__CreateEmpty() { return new StringBuf_obj; } hx::ObjectPtr< StringBuf_obj > StringBuf_obj::__new() { hx::ObjectPtr< StringBuf_obj > result = new StringBuf_obj(); result->__construct(); return result;} Dynamic StringBuf_obj::__Create(hx::DynamicArray inArgs) { hx::ObjectPtr< StringBuf_obj > result = new StringBuf_obj(); result->__construct(); return result;} Void StringBuf_obj::add( Dynamic x){ { HX_SOURCE_PUSH("StringBuf_obj::add") HX_SOURCE_POS("C:\\Motion-Twin\\haxe/std/StringBuf.hx",46) hx::IndexRef((this->b).mPtr,this->b->__Field(HX_CSTRING("length"))) = x; } return null(); } HX_DEFINE_DYNAMIC_FUNC1(StringBuf_obj,add,(void)) Void StringBuf_obj::addSub( ::String s,int pos,Dynamic len){ { HX_SOURCE_PUSH("StringBuf_obj::addSub") HX_SOURCE_POS("C:\\Motion-Twin\\haxe/std/StringBuf.hx",59) hx::IndexRef((this->b).mPtr,this->b->__Field(HX_CSTRING("length"))) = s.substr(pos,len); } return null(); } HX_DEFINE_DYNAMIC_FUNC3(StringBuf_obj,addSub,(void)) Void StringBuf_obj::addChar( int c){ { HX_SOURCE_PUSH("StringBuf_obj::addChar") HX_SOURCE_POS("C:\\Motion-Twin\\haxe/std/StringBuf.hx",75) hx::IndexRef((this->b).mPtr,this->b->__Field(HX_CSTRING("length"))) = ::String::fromCharCode(c); } return null(); } HX_DEFINE_DYNAMIC_FUNC1(StringBuf_obj,addChar,(void)) ::String StringBuf_obj::toString( ){ HX_SOURCE_PUSH("StringBuf_obj::toString") HX_SOURCE_POS("C:\\Motion-Twin\\haxe/std/StringBuf.hx",89) return this->b->__Field(HX_CSTRING("join"))(HX_CSTRING("")); } HX_DEFINE_DYNAMIC_FUNC0(StringBuf_obj,toString,return ) StringBuf_obj::StringBuf_obj() { } void StringBuf_obj::__Mark(HX_MARK_PARAMS) { HX_MARK_BEGIN_CLASS(StringBuf); HX_MARK_MEMBER_NAME(b,"b"); HX_MARK_END_CLASS(); } Dynamic StringBuf_obj::__Field(const ::String &inName) { switch(inName.length) { case 1: if (HX_FIELD_EQ(inName,"b") ) { return b; } break; case 3: if (HX_FIELD_EQ(inName,"add") ) { return add_dyn(); } break; case 6: if (HX_FIELD_EQ(inName,"addSub") ) { return addSub_dyn(); } break; case 7: if (HX_FIELD_EQ(inName,"addChar") ) { return addChar_dyn(); } break; case 8: if (HX_FIELD_EQ(inName,"toString") ) { return toString_dyn(); } } return super::__Field(inName); } Dynamic StringBuf_obj::__SetField(const ::String &inName,const Dynamic &inValue) { switch(inName.length) { case 1: if (HX_FIELD_EQ(inName,"b") ) { b=inValue.Cast< Dynamic >(); return inValue; } } return super::__SetField(inName,inValue); } void StringBuf_obj::__GetFields(Array< ::String> &outFields) { outFields->push(HX_CSTRING("b")); super::__GetFields(outFields); }; static ::String sStaticFields[] = { String(null()) }; static ::String sMemberFields[] = { HX_CSTRING("add"), HX_CSTRING("addSub"), HX_CSTRING("addChar"), HX_CSTRING("toString"), HX_CSTRING("b"), String(null()) }; static void sMarkStatics(HX_MARK_PARAMS) { }; Class StringBuf_obj::__mClass; void StringBuf_obj::__register() { Static(__mClass) = hx::RegisterClass(HX_CSTRING("StringBuf"), hx::TCanCast< StringBuf_obj> ,sStaticFields,sMemberFields, &__CreateEmpty, &__Create, &super::__SGetClass(), 0, sMarkStatics); } void StringBuf_obj::__boot() { }
[ [ [ 1, 149 ] ] ]
41a50bf689eb9e7180b085e3d0a47f0c2c900d3b
de98f880e307627d5ce93dcad1397bd4813751dd
/3libs/ut/include/OXPropertiesWnd.h
f68a1455993eb30e2c3da474662762ed17693d0b
[]
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
13,760
h
// ============================================================================ // Class Specification : COXPropertiesWnd // ============================================================================ // // 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. // /////////////////////////////////////////////////////////////////////////////// #if !defined(AFX_OXPROPERTIESWND_H__733A17FD_6455_4497_98A8_99A2E9457DFC__INCLUDED_) #define AFX_OXPROPERTIESWND_H__733A17FD_6455_4497_98A8_99A2E9457DFC__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // OXPropertiesWnd.h : header file // #define WM_USER_STARTEDITING (WM_USER + 94) #include "OXDllExt.h" #include "OXPropertyDescriptionPane.h" #include "OXCoolToolBar.h" #include "OXBrowseColorEdit.h" #include "OXPropertyTree.h" ///////////////////////////////////////////////////////////////////////////// // COXPropertiesWnd window #define _COMBO_ID 1000 #define _TREE_ID 1001 #define _DESCRIPTION_ID 1002 #define _EDITOR_ID 1003 #define HCATEGORY HTREEITEM #define HPROPERTY HTREEITEM /* /////////////////////////////////////////////////////////////////////////////// Description: The COXPropertiesWnd class implements a properties window similar to the one found in Visual Studio .NET. The SkinsDemo sample found in /samples/advanced demonstrates some of the capabilities of COXPropertiesWnd. The method CPropertiesBar::InitProperties() is of particular interest since it shows how easy it is to add different property types and editors to the properties window. The properties window is very flexible and is designed to support different property value editors derived from CEdit, COXEdit or COXMaskedEdit. All you have to do is pass a pointer to an editor when calling COXPropertiesWnd::InsertProperty(...). The following Ultimate ToolBox classes are ready to be used as property editors: COXEdit - text field COXListEdit - text field with a drop list. COXNumericEdit - numeric field COXMaskedEdit - masked field - can be used for phone numbers, serial numbers, etc. COXCurrencyEdit - currency field. COXIPEdit - IP address field. COXCalendarEdit - date field. The format of the date can be specified in the constructor. COXTimeEdit - time interval field. COXAngleEdit - angle field. (Degrees, radians and grades are supported). COXLengthEdit - physical length field. (empyreal and metric units are supported) COXTempEdit - temperature field. (Celsius, Fahrenheit and Kelvin) COXBrowseColorEdit- color picker field. COXCalculatorEdit - numeric field with a drop down calculator. COXBrowseDirEdit - directory field with a drop down browser. COXBrowseFileEdit - file name field with a drop down browser. Also you can derive from any of these classes in order to implement further validation or need more customization. Also you can implement your own drop editor if you derive your editor class from COXDropEdit<COXEdit> and override COXDropEdit::OnDropButton() virtual function. In order to make the property values flexible they are set and retrieved as strings by using the SetPropertyValue() and the GetPropertyValue() methods. In addition to the properties area the properties window also contains a combo box, a toolbar and a description area. The methods GetComboBoxEx() and GetToolBar() can be used to obtain a pointer to the controls. Also all there elements can be show or hidden using the ShowCombo(), ShowToolBar() and ShowDescription() methods. /////////////////////////////////////////////////////////////////////////////// */ class COXFrameSkin; class OX_CLASS_DECL COXPropertiesWnd : public CFrameWnd { friend class COXListEdit; friend class COXPropertyTree; friend class COXPropertyDescriptionPane; // Construction public: COXPropertiesWnd(); // Attributes public: // Operations public: // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(COXPropertiesWnd) public: virtual BOOL PreTranslateMessage(MSG* pMsg); protected: virtual void PostNcDestroy(); //}}AFX_VIRTUAL // Overrides // --- In : hProperty - A handle to the property that changed. // lpszOldValue - A string containing the previous value // lpszNewValue - A string containing the new value // --- Out : // --- Returns: TRUE if the new value is to be kept, otherwise FALSE // --- Effect: This function is called when the user changes a property value // using the UI. Override this function in order to detect a change // in a property value or to validate the new property value. virtual BOOL OnPropertyValueChanged(HPROPERTY hProperty, LPCTSTR lpszOldValue, LPCTSTR lpszNewValue); // --- In : hProperty - A handle to the property that changed. // lpszOldValue - A string containing the previous value // lpszNewValue - A string containing the new value // --- Out : // --- Returns: TRUE if it is okay to delete the property, false otherwise. // --- Effect: This function is called when a property is about to be deleted. // Override to perform any clean up and return FALSE if the property // should not be deleted. virtual BOOL OnDeleteProperty(HPROPERTY hProperty); // Implementation public: // --- In : // --- Out : // --- Returns: A handle to the currently selected property or NULL if no // is selected. // --- Effect: Call this function to obtain the currently selected property. HPROPERTY GetSelectedProperty(); // Selects the next property if any - Last Mod : Nish - June 14th, 2005 BOOL SelectNextProperty(); // --- In : bShow - If this parameter is true the combo will be visible, // otherwize it will not. // --- Out : // --- Returns: // --- Effect: Shows/hides the combo box. void ShowCombo(BOOL bShow = TRUE); // --- In : bShow - If this parameter is true the toolbar will be visible, // otherwize it will not. // --- Out : // --- Returns: // --- Effect: Shows/hides the toolbar. void ShowToolBar(BOOL bShow = TRUE); // --- In : bShow - If this parameter is true the description pane will // be visible, otherwize it will not. // --- Out : // --- Returns: // --- Effect: Shows/hides the description pane. void ShowDescription(BOOL bShow = TRUE); // --- In : // --- Out : // --- Returns: A reference to the properties window combo box // --- Effect: Obtains a reference to the properties window combo box. CComboBoxEx& GetComboBoxEx(); // --- In : // --- Out : // --- Returns: A reference to the properties window toolbar // --- Effect: Obtains a reference to the properties window toolbar. COXCoolToolBar& GetToolBar(); // --- In : bCategorized - if TRUE the properties window will display // the properties under their categopries. // --- Out : // --- Returns: // --- Effect: Causes the properties window to display the properties categories // Clicking on the Categorized button has the same effect. void SetCategorized(BOOL bCategorized = TRUE); // --- In : lpszName - The name of the property. // lpszCategory - The name of the category to which this property // belongs. If this parameter is NULL the // properties without a category will be searched. // --- Returns: A handle to the found property or NULL if not property was found. // --- Effect: Searches for a property under a category. HPROPERTY FindProperty(LPCTSTR lpszName, LPCTSTR lpszCategory = NULL); // --- In : hProperty - A handle to the property. Must not be NULL and // the property must exist. Use FindProperty(...) to // obtain the property handle. // --- Returns: A string containing the property's value // --- Effect: Retrienes the value of the given property. CString GetPropertyValue(HPROPERTY hProperty); // --- In : hProperty - A handle to the property. Must not be NULL and // the property must exist. Use FindProperty(...) to // obtain the property handle. // lpszValue - A string containing the value to be set. Pass an empty // string or NULL to clear the value. // --- Returns: TRUE if successfull, FALSE otherwise // --- Effect: Sets/clears the value of a property. BOOL SetPropertyValue(HPROPERTY hProperty, LPCTSTR lpszValue); // --- In : hProperty - A handle to the property. Must not be NULL and // the property must exist. Use FindProperty(...) to // obtain the property handle. // --- Returns: TRUE if the operation was successfull, FALSE otherwise // --- Effect: Deletes the given property. If this property was under a category which is // now empty the category will be removed as well. BOOL DeleteProperty(HPROPERTY hProperty); // --- In : lpszName - The name of the property. // lpszInitialValue- The initial value that this property will have. // lpszDescription - The description of the property which is shown // in the box below. // lpszCategory - The name of the category to which this property belongs // If this parameter is NULL the property will not belong to // any category. // pEditorClass - A pointer to a CEdit or derived editor class. If NULL // the property will be read only. // --- Out : // --- Returns: A handle to the inserted property or NULL if the operation failed. // --- Effect: Inserts a new property into the property window. HPROPERTY InsertProperty( LPCTSTR lpszName, LPCTSTR lpszInitialValue = NULL, LPCTSTR lpszDescription = NULL, LPCTSTR lpszCategory = NULL, CEdit* pEditorClass = NULL); // --- In : // --- Out : // --- Returns: TRUE if all the properties were deleted successfully, FALSE otherwise // --- Effect: Deletes all the properties in the properties window. BOOL DeleteAll(); // --- Effect : Sets a flag to indicate that categories are to be sorted void SetSortCategories(BOOL bSortCategories = TRUE); // Destructor virtual ~COXPropertiesWnd(); protected: //List of categories CList<CString,CString&> m_listCategories; // A pointer to the current active editor CEdit* m_pEditWnd; // Handle to the property that is currently being edited HPROPERTY m_hEditProp; // HPROPERTY to Category name map that holds the parent-child // relationship between properties and categories CMap<HPROPERTY, HPROPERTY, CString, CString> m_mapProp2Cat; // HPROPERTY to Description map that holds the one-to-one // relationship between properties and their description CMap<HPROPERTY, HPROPERTY, CString, CString> m_mapProp2Desc; // HPROPERTY to CEdit* map that binds each property to the // pointer of its editor CMap<HPROPERTY, HPROPERTY, CEdit*, CEdit*> m_mapProp2Editor; // A flag which is TRUE when the properties window in in categorized // mode and FALSE otherwise. BOOL m_bCategorized; // A flag set to TRUE to sort categories in categorized view. FALSE otherwise. // Default is TRUE. BOOL m_bSortCategories; // The toolbar which appears on top of the properties window. COXCoolToolBar m_wndToolBar; // The description pane window. COXPropertyDescriptionPane m_wndDescription; // The combo box which appears on top of the properties window. CComboBoxEx m_wndCombo; // The properties tree window which displays all the properties. COXPropertyTree m_wndTree; // Finds a category by name HCATEGORY FindCategory(LPCTSTR lpszCategory); // Inserts a new category HCATEGORY InsertCategory(LPCTSTR lpszCategoryName); // Start editing a property void StartEditing(HPROPERTY hSelectedProp); // Finish editing a property void FinishEditing(BOOL bSave = TRUE); // Handle to the currently selected property HPROPERTY m_hCurrentProp; // helper for detecting whether child descendant of parent // (works with owned popups as well) static BOOL IsDescendant(CWnd* pWndParent, CWnd* pWndChild); // Message handlers //{{AFX_MSG(COXPropertiesWnd) afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnCategorized(); afx_msg void OnAlphabetic(); afx_msg void OnPaint(); afx_msg void OnUpdateCategorized(CCmdUI* pCmdUI); afx_msg void OnUpdateAlphabetic(CCmdUI* pCmdUI); //}}AFX_MSG afx_msg void OnItemChanged(NMHDR* pNMHDR, LRESULT* pResult); LRESULT OnQueryPropertiesWnd(WPARAM wParam, LPARAM lParam); LRESULT OnStartEditing(WPARAM wParam, LPARAM lParam); LRESULT OnUserAdjustLastColumn(WPARAM wParam, LPARAM lParam); DECLARE_MESSAGE_MAP() private: COXFrameSkin* GetFrameSkin(); COXFrameSkin* m_pFrameSkin; }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_OXPROPERTIESWND_H__733A17FD_6455_4497_98A8_99A2E9457DFC__INCLUDED_)
[ [ [ 1, 365 ] ] ]
aea7e03e2cd632365dc3a52dd7df7a0353add81f
8b7714dce3292f7e9c8a05c15abfa1bf8ae99384
/excelreader.h
cf503555fd2fe100d795cbdf2d403344460d5c1c
[]
no_license
zhili/GeCellGenerator
ce3d33d620ababb60bf94d7ed35afb1e89544311
033e0bfba5b1f869f4b0a6dbfc07c839e1659cf7
refs/heads/master
2021-01-18T14:06:01.881720
2010-10-09T13:44:19
2010-10-09T13:44:19
948,380
1
0
null
null
null
null
UTF-8
C++
false
false
2,917
h
#pragma once // #include <standard library headers> #include <string> #include <list> // #include <other library headers> #include <ole2.h> // #include <other library headers> #include <comutil.h> #include <Shlwapi.h> #include <atlsafe.h> template<typename T> inline std::wstring towstr(const T &x){ std::wostringstream o; if (!(o << x)){ // Log Error Message here } return o.str(); } template<typename T> inline std::string tostr(const T &x){ std::ostringstream o; if (!(o << x)){ // Log Error Message here } return o.str(); } template<> inline std::wstring towstr<std::string>(const std::string &x){ std::wstring wstrReturn; wstrReturn.assign(x.begin(), x.end()); return wstrReturn; } template<> inline std::string tostr<std::wstring>(const std::wstring &x){ std::string strReturn; strReturn.assign(x.begin(), x.end()); return strReturn; } template<> inline std::wstring towstr<variant_t>(const variant_t &x){ return std::wstring((_bstr_t)(_variant_t)x); } template<> inline std::string tostr<variant_t>(const variant_t &x){ return std::string((_bstr_t)(_variant_t)x); } namespace msexcel { class excelreader { /** * description */ class ExcelException : public std::exception { public: ExcelException(const std::string& s = "") : msg(s) {} virtual ~ExcelException() throw() {} public: virtual const char* what() const throw() { return msg.c_str(); } virtual const std::string What() const throw() { return msg; } private: std::string msg; }; public: excelreader(const std::wstring& filename = L"", const std::wstring& sheet = L"", bool visible = false); virtual ~excelreader(); public: int rowCount(); int colCount(); void SetData(const std::wstring& cell, const std::wstring& data); // set a range void SetData(int nRow, int nBeg, const std::list<std::wstring>& data); // set a line void SetData(const std::wstring& colTag, int nBeg, const std::list<std::wstring>& data); // set a column void SaveAsFile(const std::wstring& filename); double excelreader::GetDataAsDouble(int row, int col); std::string excelreader::GetDataAsString(int row, int col); private: void CreateNewWorkbook(); void OpenWorkbook(const std::wstring& filename, const std::wstring& sheet); void GetActiveSheet(); void GetSheet(const std::wstring& sheetname); std::wstring GetColumnName(int nIndex); bool CheckFilename(const std::wstring& filename); void InstanceExcelWorkbook(int visible); static void excelreader::AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp, LPOLESTR ptName, int cArgs...); private: IDispatch* pXlApp; IDispatch* pXlBooks; IDispatch* pXlBook; IDispatch* pXlSheet; }; }
[ [ [ 1, 117 ] ] ]
2aad8c471c97be7815b45b5292c442ef096fe9f9
be7eb51cea272a091523a4f85fbd5a2dfa107c95
/Classes/FileOperations.cpp
a2939815df13ac81060b9a3490b75bd90167927b
[]
no_license
HousonCao/screendump
e517714a4fd357d6608384442a8ab2b1a35e7d75
483c400a5769cea568a2246aa8054006ad6a40ae
refs/heads/master
2021-01-18T17:55:14.002682
2010-10-12T19:01:02
2010-10-12T19:01:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,710
cpp
#include "stdafx.h" #include <direct.h> #include <io.h> #include "FileOperations.h" #include "GlobalSettings.h" // Returns a new filename using the timestamp: img_YYYYMMDD_HHMMSSuuu. // Verifies if a file already exists with the generated filename, if it does we increment the filename. CString GenerateAutoFileName() { GlobalSettings gs; CString timeStr; CString path; SYSTEMTIME tNow; CString ext; path = gs.bAutoName ? gs.getOutputDir() : _T("\\"); GetLocalTime(&tNow); timeStr.Format(_T("img_%u%02u%02u_%02u%02u%02u%03u"), tNow.wYear, tNow.wMonth, tNow.wDay, tNow.wHour, tNow.wMinute, tNow.wSecond, tNow.wMilliseconds); // We check which encoder is selected to know what extension to use switch (gs.sEnc) { case sEncBMP: ext = _T(".bmp"); break; case sEncJPEG: ext = _T(".jpg"); break; case sEncPNG: ext = _T(".png"); break; default: ext = _T(""); break; } // Check if the file already exists while( CheckFileExists(path + timeStr + ext) ) { if (tNow.wMilliseconds == 999) { break; } else { tNow.wMilliseconds += 1; timeStr.Format(_T("img_%u%02u%02u_%02u%02u%02u%03u"), tNow.wYear, tNow.wMonth, tNow.wDay, tNow.wHour, tNow.wMinute, tNow.wSecond, tNow.wMilliseconds); } } return timeStr + ext; } // Opens a File Open dialog for the user. Returns the full path and filename selected by the user, or // empty string if the user cancels out. CString OpenFileDialog() { CString fName; CString ext; CString Filter; GlobalSettings gs; switch (gs.sEnc) { case sEncBMP: ext = _T("bmp"); Filter = _T("Bitmap Files (*.bmp)|*.bmp||"); break; case sEncJPEG: ext = _T("jpg"); Filter = _T("JPEG Files (*.jpg)|*.jpg||"); break; case sEncPNG: ext = _T("png"); Filter = _T("PNG Files (*.png)|*.png||"); break; default: ext = _T(""); Filter = _T("All Files (*.*)|*.*||"); break; } CFileDialog cfSaveAs(FALSE, ext, _T(""), OFN_HIDEREADONLY|OFN_EXPLORER, Filter, NULL, 0, TRUE); if( cfSaveAs.DoModal() == IDOK ) { fName = cfSaveAs.GetPathName(); } else { fName = _T(""); } return fName; }
[ [ [ 1, 99 ] ] ]
52048de699679644b439bdeed2bd929f4ff13645
51e1cf5dc3b99e8eecffcf5790ada07b2f03f39c
/FileAssistant++/Source/CString.h
93a6784d65399aee581af97d03093f1ea1e2b1d0
[]
no_license
jdek/jim-pspware
c3e043b59a69cf5c28daf62dc9d8dca5daf87589
fd779e1148caac2da4c590844db7235357b47f7e
refs/heads/master
2021-05-31T06:45:03.953631
2007-06-25T22:45:26
2007-06-25T22:45:26
56,973,047
2
1
null
null
null
null
UTF-8
C++
false
false
8,037
h
/*********************************************************************************** Module : CString.h Description : Last Modified $Date: $ $Revision: $ Copyright (C) 07 August 2005 71M ***********************************************************************************/ #ifndef CSTRING_H_ #define CSTRING_H_ //********************************************************************************** // Include Files //********************************************************************************** #include "CTypes.h" #include "CAssert.h" //********************************************************************************** // Macros //********************************************************************************** //********************************************************************************** // Types //********************************************************************************** //********************************************************************************** // Constants //********************************************************************************** //********************************************************************************** // Class definitions //********************************************************************************** //********************************************************************************** // Externs //********************************************************************************** //********************************************************************************** // Prototypes //********************************************************************************** //************************************************************************************* // //************************************************************************************* inline s32 StringLen( const char * p_string ) { return strlen( p_string ); } inline char * StringCopy( char * dest, const char * source ) { return strcpy( dest, source ); } inline char * StringCopy( char * dest, const char * source, u32 len ) { return strncpy( dest, source, len ); } inline char * StringAppend( char * dest, const char * source ) { return strcat( dest, source ); } inline s32 StringCompare( const char * a, const char * b ) { return strcmp( a, b ); } inline s32 StringCompareI( const char * a, const char * b ) { return strcmpi( a, b ); } inline const char * StringFind( const char * source, char c ) { return strchr( source, c ); } inline char * StringFind( char * source, char c ) { return strchr( source, c ); } inline char* StringStr( const char* source, const char* search) { return strstr(source, search); } inline s32 StringPrint( char * string, u32 length, const char * format, va_list list ) { return vsnprintf( string, length, format, list ); } //************************************************************************************* // //************************************************************************************* template< s32 STRING_LEN, class CType = char > class CStaticString { public: CStaticString() { m_pString[ 0 ] = 0; } CStaticString( const CStaticString & string ) { Copy( string.m_pString ); } CStaticString( const CType * string ) { Copy( string ); } CStaticString( const CType * p_string1, const CType * p_string2 ) { Copy( p_string1 ); ASSERT( Length() + StringLen( p_string2 ) <= STRING_LEN, "String append will overflow array" ); StringAppend( m_pString, p_string2 ); } CStaticString( const CType * string, u32 len ) { SetLeft( string, len ); } CStaticString( s32 val ) { *this = val; } operator const CType * () const { return m_pString; } CStaticString & operator= ( const CStaticString & string ) { Copy( string.m_pString ); return *this; } CStaticString & operator = ( const CType * string ) { Copy( string ); return *this; } CStaticString & Reverse() { const u32 len( Length() ); for ( u32 i = 0; i < ( len / 2 ); ++i ) { const char tmp( m_pString[ i ] ); m_pString[ i ] = m_pString[ len - 1 - i ]; m_pString[ len - 1 - i ] = tmp; } return *this; } CStaticString & operator = ( s32 val ) { char * t; char * s( m_pString ); int mod; if ( val < 0 ) { *s++ = '-'; val = -val; } t = s; while ( val ) { mod = val % 10; *t++ = (char)mod + '0'; val /= 10; } if ( s == t ) { *t++ = '0'; } *t = '\0'; Reverse(); return *this; } CStaticString & operator += ( const CType * string ) { return Append( string ); } CStaticString & operator += ( const CStaticString & string ) { return Append( string ); } CStaticString operator + ( const CType * const p_string ) const { CStaticString< STRING_LEN, CType > temp( m_pString ); temp.Append( p_string ); return temp; } CStaticString operator + ( const CStaticString & string ) const { CStaticString< STRING_LEN, CType > temp( m_pString ); temp.Append( string ); return temp; } bool operator == ( const CType * string ) const { return Equals( string ); } bool operator != ( const CType * string ) const { return !Equals( string ); } bool operator > ( const CType * string ) const { return ( StringCompareI( m_pString, string ) > 0 ); } bool operator < ( const CType * string ) const { return ( StringCompareI( m_pString, string ) < 0 ); } const CType * GetPtr() const { return m_pString; } bool Equals( const CType * string ) const { return StringCompare( m_pString, string ) == 0; } bool IEquals( const CType * string ) const { return StringCompareI( m_pString, string ) == 0; } s32 Length() const { return StringLen( m_pString ); } bool IsEmpty() const { return ( m_pString[ 0 ] == '\0' ); } void ToUpper() { strupr( m_pString ); } void ToLower() { strlwr( m_pString ); } CType * Find( const CType * const p_string ) { return StringStr( m_pString, p_string ); } const CType * Find( const CType * const p_string ) const { return StringStr( m_pString, p_string ); } const CType * Find( CType c ) const { return StringFind( m_pString, c ); } CType * Find( CType c ) { return StringFind( m_pString, c ); } CStaticString & Append( const CType * string ) { ASSERT( Length() + StringLen( string ) <= STRING_LEN, "String append will overflow array" ); StringAppend( m_pString, string ); return *this; } void Clear() { m_pString[ 0 ] = '\0'; } CStaticString & Printf( const CType * format, ... ) { s32 chars_written; va_list marker; va_start( marker, format ); chars_written = StringPrint( m_pString, STRING_LEN, format, marker ); va_end( marker ); ASSERT( chars_written >= 0, "The formatted output is too long for the buffer" ); return *this; } protected: void Copy( const CType * string ) { if ( string == NULL ) { m_pString[ 0 ] = '\0'; } else { ASSERT( StringLen( string ) <= STRING_LEN, "Trying to copy a string that is too large" ); StringCopy( m_pString, string, STRING_LEN ); m_pString[ STRING_LEN ] = '\0'; } } protected: CType m_pString[ STRING_LEN + 1 ]; }; //********************************************************************************** // //********************************************************************************** typedef CStaticString< 256 > CString; typedef std::list< CString > CStringList; #endif /* CSTRING_H_ */
[ "71m@ff2c0c17-07fa-0310-a4bd-d48831021cb5" ]
[ [ [ 1, 373 ] ] ]
925f08fa26a4f52202bf5f4c3797528ad2aa9d46
f89e32cc183d64db5fc4eb17c47644a15c99e104
/pcsx2-rr/plugins/GSdx/GSTextureCache.cpp
818876186d3b58eb0ea1e9c3ba540eb0a553fa1a
[]
no_license
mauzus/progenitor
f99b882a48eb47a1cdbfacd2f38505e4c87480b4
7b4f30eb1f022b08e6da7eaafa5d2e77634d7bae
refs/heads/master
2021-01-10T07:24:00.383776
2011-04-28T11:03:43
2011-04-28T11:03:43
45,171,114
0
0
null
null
null
null
UTF-8
C++
false
false
27,041
cpp
/* * Copyright (C) 2007-2009 Gabest * http://www.gabest.org * * 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, 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 GNU Make; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * http://www.gnu.org/copyleft/gpl.html * */ #include "StdAfx.h" #include "GSTextureCache.h" GSTextureCache::GSTextureCache(GSRenderer* r) : m_renderer(r) { m_paltex = !!theApp.GetConfig("paltex", 0); UserHacks_HalfPixelOffset = !!theApp.GetConfig("UserHacks_HalfPixelOffset", 0); } GSTextureCache::~GSTextureCache() { RemoveAll(); } void GSTextureCache::RemoveAll() { m_src.RemoveAll(); for(int type = 0; type < 2; type++) { for_each(m_dst[type].begin(), m_dst[type].end(), delete_object()); m_dst[type].clear(); } } GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GSVector4i& r) { const GSLocalMemory::psm_t& psm = GSLocalMemory::m_psm[TEX0.PSM]; const uint32* clut = m_renderer->m_mem.m_clut; Source* src = NULL; list<Source*>& m = m_src.m_map[TEX0.TBP0 >> 5]; for(list<Source*>::iterator i = m.begin(); i != m.end(); i++) { Source* s = *i; if(((TEX0.u32[0] ^ s->m_TEX0.u32[0]) | ((TEX0.u32[1] ^ s->m_TEX0.u32[1]) & 3)) != 0) // TBP0 TBW PSM TW TH { continue; } if((psm.trbpp == 16 || psm.trbpp == 24) && TEX0.TCC && TEXA != s->m_TEXA) { continue; } if(s->m_palette == NULL && psm.pal > 0 && !GSVector4i::compare64(clut, s->m_clut, psm.pal * sizeof(clut[0]))) { continue; } m.splice(m.begin(), m, i); src = s; break; } Target* dst = NULL; if(src == NULL) { uint32 bp = TEX0.TBP0; uint32 psm = TEX0.PSM; for(int type = 0; type < 2 && dst == NULL; type++) { for(list<Target*>::iterator i = m_dst[type].begin(); i != m_dst[type].end(); i++) { Target* t = *i; if(t->m_used && t->m_dirty.empty() && GSUtil::HasSharedBits(bp, psm, t->m_TEX0.TBP0, t->m_TEX0.PSM)) { dst = t; break; } } } } if(src == NULL) { src = CreateSource(TEX0, TEXA, dst); if(src == NULL) { return NULL; } } if(psm.pal > 0) { int size = psm.pal * sizeof(clut[0]); if(src->m_palette) { if(src->m_initpalette || !GSVector4i::update(src->m_clut, clut, size)) { src->m_palette->Update(GSVector4i(0, 0, psm.pal, 1), src->m_clut, size); src->m_initpalette = false; } } } src->Update(TEX0, TEXA, r); m_src.m_used = true; return src; } GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int w, int h, int type, bool used) { uint32 bp = TEX0.TBP0; Target* dst = NULL; for(list<Target*>::iterator i = m_dst[type].begin(); i != m_dst[type].end(); i++) { Target* t = *i; if(bp == t->m_TEX0.TBP0) { m_dst[type].splice(m_dst[type].begin(), m_dst[type], i); dst = t; dst->m_TEX0 = TEX0; break; } } if(dst == NULL) { dst = CreateTarget(TEX0, w, h, type); if(dst == NULL) { return NULL; } } else { dst->Update(); } if(m_renderer->CanUpscale()) { int multiplier = m_renderer->upscale_Multiplier(); if (multiplier > 1) //it's limited to a maximum of 4 on reading the config { #if 0 //#ifdef USE_UPSCALE_HACKS //not happy with this yet.. float x = 1.0f; float y = 1.0f; switch(multiplier) { case 2: x = 1.9375; y = 2.0f; break; // x res get's rid of vertical lines in many games case 3: x = 2.9375f; y = 2.9375f; break; // not helping much case 4: x = 3.875f; y = 3.875f; break; // not helping much default: __assume(0); } dst->m_texture->SetScale( GSVector2(x, y) ); #else dst->m_texture->SetScale( GSVector2((float)multiplier, (float)multiplier) ); #endif } else { GSVector4i fr = m_renderer->GetFrameRect(); int ww = (int)(fr.left + m_renderer->GetDisplayRect().width()); int hh = (int)(fr.top + m_renderer->GetDisplayRect().height()); if(hh <= m_renderer->GetDeviceSize().y / 2) { hh *= 2; } //This vp2 fix doesn't work most of the time if(hh < 512 && m_renderer->m_context->SCISSOR.SCAY1 == 511) // vp2 { hh = 512; } if(ww > 0 && hh > 0) { dst->m_texture->SetScale(GSVector2((float)w / ww, (float)h / hh)); } } } if(used) { dst->m_used = true; } return dst; } GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int w, int h) { uint32 bp = TEX0.TBP0; Target* dst = NULL; for(list<Target*>::iterator i = m_dst[RenderTarget].begin(); i != m_dst[RenderTarget].end(); i++) { Target* t = *i; if(bp == t->m_TEX0.TBP0) { dst = t; break; } else { // HACK: try to find something close to the base pointer if(t->m_TEX0.TBP0 <= bp && bp < t->m_TEX0.TBP0 + 0x700 && (!dst || t->m_TEX0.TBP0 >= dst->m_TEX0.TBP0)) { dst = t; } } } if(dst == NULL) { dst = CreateTarget(TEX0, w, h, RenderTarget); if(dst == NULL) { return NULL; } } else { dst->Update(); } dst->m_used = true; return dst; } void GSTextureCache::InvalidateVideoMem(const GSOffset* o, const GSVector4i& rect, bool target) { // Fixme. Crashes Dual Hearts, maybe others as well. Was fine before r1549. if (!o) return; uint32 bp = o->bp; uint32 bw = o->bw; uint32 psm = o->psm; GSVector2i bs = (bp & 31) == 0 ? GSLocalMemory::m_psm[psm].pgs : GSLocalMemory::m_psm[psm].bs; GSVector4i r = rect.ralign<GSVector4i::Outside>(bs); if(!target) { const list<Source*>& m = m_src.m_map[bp >> 5]; for(list<Source*>::const_iterator i = m.begin(); i != m.end(); ) { list<Source*>::const_iterator j = i++; Source* s = *j; if(GSUtil::HasSharedBits(bp, psm, s->m_TEX0.TBP0, s->m_TEX0.PSM)) { m_src.RemoveAt(s); } } } bool found = false; for(int y = r.top; y < r.bottom; y += bs.y) { uint32 base = o->block.row[y >> 3]; for(int x = r.left; x < r.right; x += bs.x) { uint32 page = (base + o->block.col[x >> 3]) >> 5; if(page < MAX_PAGES) { const list<Source*>& m = m_src.m_map[page]; for(list<Source*>::const_iterator i = m.begin(); i != m.end(); ) { list<Source*>::const_iterator j = i++; Source* s = *j; if(GSUtil::HasSharedBits(psm, s->m_TEX0.PSM)) { bool b = bp == s->m_TEX0.TBP0; if(!s->m_target) { s->m_valid[page] = 0; s->m_complete = false; found = b; } else { // TODO if(b) { m_src.RemoveAt(s); } } } } } } } if(!target) return; for(int type = 0; type < 2; type++) { for(list<Target*>::iterator i = m_dst[type].begin(); i != m_dst[type].end(); ) { list<Target*>::iterator j = i++; Target* t = *j; if(GSUtil::HasSharedBits(bp, psm, t->m_TEX0.TBP0, t->m_TEX0.PSM)) { if(!found && GSUtil::HasCompatibleBits(psm, t->m_TEX0.PSM)) { t->m_dirty.push_back(GSDirtyRect(r, psm)); t->m_TEX0.TBW = bw; } else { m_dst[type].erase(j); delete t; continue; } } if(GSUtil::HasSharedBits(psm, t->m_TEX0.PSM) && bp < t->m_TEX0.TBP0) { uint32 rowsize = bw * 8192; uint32 offset = (uint32)((t->m_TEX0.TBP0 - bp) * 256); if(rowsize > 0 && offset % rowsize == 0) { int y = GSLocalMemory::m_psm[psm].pgs.y * offset / rowsize; if(r.bottom > y) { // TODO: do not add this rect above too t->m_dirty.push_back(GSDirtyRect(GSVector4i(r.left, r.top - y, r.right, r.bottom - y), psm)); t->m_TEX0.TBW = bw; continue; } } } } } } void GSTextureCache::InvalidateLocalMem(const GSOffset* o, const GSVector4i& r) { uint32 bp = o->bp; uint32 psm = o->psm; uint32 bw = o->bw; // No depth handling please. if (psm == PSM_PSMZ32 || psm == PSM_PSMZ24 || psm == PSM_PSMZ16 || psm == PSM_PSMZ16S) return; GSTextureCache::Target* rt2 = NULL; int ymin = INT_MAX; for(list<Target*>::iterator i = m_dst[RenderTarget].begin(); i != m_dst[RenderTarget].end(); ) { list<Target*>::iterator j = i++; Target* t = *j; if (t->m_TEX0.PSM != PSM_PSMZ32 && t->m_TEX0.PSM != PSM_PSMZ24 && t->m_TEX0.PSM != PSM_PSMZ16 && t->m_TEX0.PSM != PSM_PSMZ16S) { if(GSUtil::HasSharedBits(bp, psm, t->m_TEX0.TBP0, t->m_TEX0.PSM)) { if(GSUtil::HasCompatibleBits(psm, t->m_TEX0.PSM)) { Read(t, r.rintersect(t->m_valid)); return; } else if(psm == PSM_PSMCT32 && (t->m_TEX0.PSM == PSM_PSMCT16 || t->m_TEX0.PSM == PSM_PSMCT16S)) { // ffx-2 riku changing to her default (shoots some reflecting glass at the end), 16-bit rt read as 32-bit Read(t, GSVector4i(r.left, r.top, r.right, r.top + (r.bottom - r.top) * 2).rintersect(t->m_valid)); return; } else { if (psm == PSM_PSMT4HH && t->m_TEX0.PSM == PSM_PSMCT32) { // Silent Hill Origins shadows: Read 8 bit using only the HIGH bits (4 bit) texture as 32 bit. Read(t, r.rintersect(t->m_valid)); return; } else { //printf("Trashing render target. We have a %d type texture and we are trying to write into a %d type texture\n", t->m_TEX0.PSM, psm); m_dst[RenderTarget].erase(j); delete t; } } } // Grandia3, FFX, FFX-2 pause menus. t->m_TEX0.TBP0 magic number checks because otherwise kills xs2 videos if( (GSUtil::HasSharedBits(psm, t->m_TEX0.PSM) && (bp > t->m_TEX0.TBP0) ) && ((t->m_TEX0.TBP0 == 0) || (t->m_TEX0.TBP0==3328) || (t->m_TEX0.TBP0==3584) )) { //printf("first : %d-%d child : %d-%d\n", psm, bp, t->m_TEX0.PSM, t->m_TEX0.TBP0); uint32 rowsize = bw * 8192; uint32 offset = (uint32)((bp - t->m_TEX0.TBP0) * 256); if(rowsize > 0 && offset % rowsize == 0) { int y = GSLocalMemory::m_psm[psm].pgs.y * offset / rowsize; if(y < ymin && y < 512) { rt2 = t; ymin = y; } } } } } if(rt2) { Read(rt2, GSVector4i(r.left, r.top + ymin, r.right, r.bottom + ymin)); } // TODO: ds } void GSTextureCache::IncAge() { int maxage = m_src.m_used ? 3 : 30; for(hash_set<Source*>::iterator i = m_src.m_surfaces.begin(); i != m_src.m_surfaces.end(); ) { hash_set<Source*>::iterator j = i++; Source* s = *j; if(++s->m_age > maxage) { m_src.RemoveAt(s); } } m_src.m_used = false; // Clearing of Rendertargets causes flickering in many scene transitions. // Sigh, this seems to be used to invalidate surfaces. So set a huge maxage to avoid flicker, // but still invalidate surfaces. (Disgaea 2 fmv when booting the game through the BIOS) // Original maxage was 4 here, Xenosaga 2 needs at least 240, else it flickers on scene transitions. maxage = 400; // ffx intro scene changes leave the old image untouched for a couple of frames and only then start using it for(int type = 0; type < 2; type++) { for(list<Target*>::iterator i = m_dst[type].begin(); i != m_dst[type].end(); ) { list<Target*>::iterator j = i++; Target* t = *j; if(++t->m_age > maxage) { m_dst[type].erase(j); delete t; } } } } //Fixme: Several issues in here. Not handling depth stencil, pitch conversion doesnt work. GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, Target* dst) { Source* src = new Source(m_renderer); src->m_TEX0 = TEX0; src->m_TEXA = TEXA; int tw = 1 << TEX0.TW; int th = 1 << TEX0.TH; int tp = TEX0.TBW << 6; bool hack = false; if(dst == NULL) { if(m_paltex && GSLocalMemory::m_psm[TEX0.PSM].pal > 0) { src->m_fmt = FMT_8; src->m_texture = m_renderer->m_dev->CreateTexture(tw, th, Get8bitFormat()); src->m_palette = m_renderer->m_dev->CreateTexture(256, 1); } else { src->m_fmt = FMT_32; src->m_texture = m_renderer->m_dev->CreateTexture(tw, th); } } else { // TODO: clean up this mess src->m_target = true; if(dst->m_type != RenderTarget) { // TODO delete src; return NULL; } dst->Update(); GSTexture* tmp = NULL; if(dst->m_texture->IsMSAA()) { tmp = dst->m_texture; dst->m_texture = m_renderer->m_dev->Resolve(dst->m_texture); } // do not round here!!! if edge becomes a black pixel and addressing mode is clamp => everything outside the clamped area turns into black (kh2 shadows) int w = (int)(dst->m_texture->GetScale().x * tw); int h = (int)(dst->m_texture->GetScale().y * th); GSVector2i dstsize = dst->m_texture->GetSize(); // pitch conversion if(dst->m_TEX0.TBW != TEX0.TBW) // && dst->m_TEX0.PSM == TEX0.PSM { // This is so broken :p ////Better not do the code below, "fixes" like every game that ever gets here.. ////Edit: Ratchet and Clank needs this to show most of it's graphics at all. ////Someone else fix this please, I can't :p ////delete src; return NULL; //// sfex3 uses this trick (bw: 10 -> 5, wraps the right side below the left) //ASSERT(dst->m_TEX0.TBW > TEX0.TBW); // otherwise scale.x need to be reduced to make the larger texture fit (TODO) //src->m_texture = m_renderer->m_dev->CreateRenderTarget(dstsize.x, dstsize.y, false); //GSVector4 size = GSVector4(dstsize).xyxy(); //GSVector4 scale = GSVector4(dst->m_texture->GetScale()).xyxy(); //int blockWidth = 64; //int blockHeight = TEX0.PSM == PSM_PSMCT32 || TEX0.PSM == PSM_PSMCT24 ? 32 : 64; //GSVector4i br(0, 0, blockWidth, blockHeight); //int sw = (int)dst->m_TEX0.TBW << 6; //int dw = (int)TEX0.TBW << 6; //int dh = 1 << TEX0.TH; //if(sw != 0) //for(int dy = 0; dy < dh; dy += blockHeight) //{ // for(int dx = 0; dx < dw; dx += blockWidth) // { // int o = dy * dw / blockHeight + dx; // int sx = o % sw; // int sy = o / sw; // GSVector4 sr = GSVector4(GSVector4i(sx, sy).xyxy() + br) * scale / size; // GSVector4 dr = GSVector4(GSVector4i(dx, dy).xyxy() + br) * scale; // m_renderer->m_dev->StretchRect(dst->m_texture, sr, src->m_texture, dr); // // TODO: this is quite a lot of StretchRect, do it with one Draw // } //} } else if(tw < 1024) { // FIXME: timesplitters blurs the render target by blending itself over a couple of times hack = true; if(tw == 256 && th == 128 && (TEX0.TBP0 == 0 || TEX0.TBP0 == 0x00e00)) { delete src; return NULL; } } // width/height conversion GSVector2 scale = dst->m_texture->GetScale(); GSVector4 dr(0, 0, w, h); if(w > dstsize.x) { scale.x = (float)dstsize.x / tw; dr.z = (float)dstsize.x * scale.x / dst->m_texture->GetScale().x; w = dstsize.x; } if(h > dstsize.y) { scale.y = (float)dstsize.y / th; dr.w = (float)dstsize.y * scale.y / dst->m_texture->GetScale().y; h = dstsize.y; } GSVector4 sr(0, 0, w, h); GSTexture* st = src->m_texture ? src->m_texture : dst->m_texture; GSTexture* dt = m_renderer->m_dev->CreateRenderTarget(w, h, false); if(!src->m_texture) { src->m_texture = dt; } if((sr == dr).alltrue()) { m_renderer->m_dev->CopyRect(st, dt, GSVector4i(0, 0, w, h)); } else { sr.z /= st->GetWidth(); sr.w /= st->GetHeight(); m_renderer->m_dev->StretchRect(st, sr, dt, dr); } if(dt != src->m_texture) { m_renderer->m_dev->Recycle(src->m_texture); src->m_texture = dt; } src->m_texture->SetScale(scale); switch(TEX0.PSM) { default: // Note: this assertion triggers in Xenosaga2 after the first intro scenes, when // gameplay first begins (in the city). ASSERT(0); case PSM_PSMCT32: src->m_fmt = FMT_32; break; case PSM_PSMCT24: src->m_fmt = FMT_24; break; case PSM_PSMCT16: case PSM_PSMCT16S: src->m_fmt = FMT_16; break; case PSM_PSMT8H: src->m_fmt = FMT_8H; src->m_palette = m_renderer->m_dev->CreateTexture(256, 1); break; case PSM_PSMT8: //Not sure, this wasn't handled at all. //Xenosaga 2 and 3 use it, Tales of Legendia as well. //It's always used for fog like effects. src->m_fmt = FMT_8; src->m_palette = m_renderer->m_dev->CreateTexture(256, 1); break; case PSM_PSMT4HL: src->m_fmt = FMT_4HL; src->m_palette = m_renderer->m_dev->CreateTexture(256, 1); break; case PSM_PSMT4HH: src->m_fmt = FMT_4HH; src->m_palette = m_renderer->m_dev->CreateTexture(256, 1); break; } if(tmp != NULL) { m_renderer->m_dev->Recycle(dst->m_texture); dst->m_texture = tmp; } // Offset hack. Can be enabled via GSdx options. // The offset will be used in Draw(). float modx = 0.0f; float mody = 0.0f; if (UserHacks_HalfPixelOffset && hack) { int multiplier = m_renderer->upscale_Multiplier(); switch (multiplier) { case 2: modx = 2.2f; mody = 2.2f; dst->m_texture->LikelyOffset = true; break; case 3: modx = 3.1f; mody = 3.1f; dst->m_texture->LikelyOffset = true; break; case 4: modx = 4.2f; mody = 4.2f; dst->m_texture->LikelyOffset = true; break; case 5: modx = 5.3f; mody = 5.3f; dst->m_texture->LikelyOffset = true; break; case 6: modx = 6.2f; mody = 6.2f; dst->m_texture->LikelyOffset = true; break; default: modx = 0.0f; mody = 0.0f; dst->m_texture->LikelyOffset = false; break; } } dst->m_texture->OffsetHack_modx = modx; dst->m_texture->OffsetHack_mody = mody; } if(src->m_texture == NULL) { ASSERT(0); delete src; return NULL; } const GSLocalMemory::psm_t& psm = GSLocalMemory::m_psm[TEX0.PSM]; if(psm.pal > 0) { memcpy(src->m_clut, (const uint32*)m_renderer->m_mem.m_clut, psm.pal * sizeof(uint32)); } m_src.Add(src, TEX0, m_renderer->m_context->offset.tex); return src; } GSTextureCache::Target* GSTextureCache::CreateTarget(const GIFRegTEX0& TEX0, int w, int h, int type) { Target* t = new Target(m_renderer); t->m_TEX0 = TEX0; // FIXME: initial data should be unswizzled from local mem in Update() if dirty t->m_type = type; if(type == RenderTarget) { t->m_texture = m_renderer->m_dev->CreateRenderTarget(w, h, true); t->m_used = true; // FIXME } else if(type == DepthStencil) { t->m_texture = m_renderer->m_dev->CreateDepthStencil(w, h, true); } if(t->m_texture == NULL) { ASSERT(0); delete t; return NULL; } m_dst[type].push_front(t); return t; } // GSTextureCache::Surface GSTextureCache::Surface::Surface(GSRenderer* r) : m_renderer(r) , m_texture(NULL) , m_age(0) { m_TEX0.TBP0 = (uint32)~0; } GSTextureCache::Surface::~Surface() { m_renderer->m_dev->Recycle(m_texture); } void GSTextureCache::Surface::Update() { m_age = 0; } // GSTextureCache::Source GSTextureCache::Source::Source(GSRenderer* r) : Surface(r) , m_palette(NULL) , m_initpalette(true) , m_fmt(0) , m_target(false) , m_complete(false) { memset(m_valid, 0, sizeof(m_valid)); m_clut = (uint32*)_aligned_malloc(256 * sizeof(uint32), 16); memset(m_clut, 0, sizeof(m_clut)); m_write.rect = (GSVector4i*)_aligned_malloc(3 * sizeof(GSVector4i), 16); m_write.count = 0; } GSTextureCache::Source::~Source() { m_renderer->m_dev->Recycle(m_palette); _aligned_free(m_clut); _aligned_free(m_write.rect); } void GSTextureCache::Source::Update(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GSVector4i& rect) { __super::Update(); if(m_complete || m_target) { return; } m_TEX0 = TEX0; m_TEXA = TEXA; GSVector2i bs = GSLocalMemory::m_psm[m_TEX0.PSM].bs; int tw = std::max<int>(1 << m_TEX0.TW, bs.x); int th = std::max<int>(1 << m_TEX0.TH, bs.y); GSVector4i r = rect.ralign<GSVector4i::Outside>(bs); if(r.eq(GSVector4i(0, 0, tw, th))) { m_complete = true; // lame, but better than nothing } const GSOffset* o = m_renderer->m_context->offset.tex; bool repeating = m_TEX0.IsRepeating(); uint32 blocks = 0; for(int y = r.top; y < r.bottom; y += bs.y) { uint32 base = o->block.row[y >> 3]; for(int x = r.left; x < r.right; x += bs.x) { uint32 block = base + o->block.col[x >> 3]; if(block < MAX_BLOCKS) { uint32 row = block >> 5; uint32 col = 1 << (block & 31); if((m_valid[row] & col) == 0) { if(!repeating) { m_valid[row] |= col; } Write(GSVector4i(x, y, x + bs.x, y + bs.y)); blocks++; } } } } if(blocks > 0) { if(repeating) { for(int y = r.top; y < r.bottom; y += bs.y) { uint32 base = o->block.row[y >> 3]; for(int x = r.left; x < r.right; x += bs.x) { uint32 block = base + o->block.col[x >> 3]; if(block < MAX_BLOCKS) { uint32 row = block >> 5; uint32 col = 1 << (block & 31); m_valid[row] |= col; } } } } m_renderer->m_perfmon.Put(GSPerfMon::Unswizzle, bs.x * bs.y * blocks << (m_fmt == FMT_32 ? 2 : 0)); Flush(m_write.count); } } void GSTextureCache::Source::Write(const GSVector4i& r) { m_write.rect[m_write.count++] = r; while(m_write.count >= 2) { GSVector4i& a = m_write.rect[m_write.count - 2]; GSVector4i& b = m_write.rect[m_write.count - 1]; if((a == b.zyxw()).mask() == 0xfff0) { a.right = b.right; // extend right m_write.count--; } else if((a == b.xwzy()).mask() == 0xff0f) { a.bottom = b.bottom; // extend down m_write.count--; } else { break; } } if(m_write.count > 2) { Flush(1); } } void GSTextureCache::Source::Flush(uint32 count) { const GSLocalMemory::psm_t& psm = GSLocalMemory::m_psm[m_TEX0.PSM]; int tw = 1 << m_TEX0.TW; int th = 1 << m_TEX0.TH; GSVector4i tr(0, 0, tw, th); int pitch = max(tw, psm.bs.x) * sizeof(uint32); GSLocalMemory& mem = m_renderer->m_mem; const GSOffset* o = m_renderer->m_context->offset.tex; GSLocalMemory::readTexture rtx = psm.rtx; if(m_fmt == FMT_8) { pitch >>= 2; rtx = psm.rtxP; } uint8* buff = m_renderer->GetTextureBufferLock(); for(uint32 i = 0; i < count; i++) { GSVector4i r = m_write.rect[i]; if((r > tr).mask() & 0xff00) { (mem.*rtx)(o, r, buff, pitch, m_TEXA); m_texture->Update(r.rintersect(tr), buff, pitch); } else { GSTexture::GSMap m; if(m_texture->Map(m, &r)) { (mem.*rtx)(o, r, m.bits, m.pitch, m_TEXA); m_texture->Unmap(); } else { (mem.*rtx)(o, r, buff, pitch, m_TEXA); m_texture->Update(r, buff, pitch); } } } m_renderer->ReleaseTextureBufferLock(); if(count < m_write.count) { memcpy(m_write.rect[0], &m_write.rect[count], (m_write.count - count) * sizeof(m_write.rect[0])); } m_write.count -= count; } // GSTextureCache::Target GSTextureCache::Target::Target(GSRenderer* r) : Surface(r) , m_type(-1) , m_used(false) { m_valid = GSVector4i::zero(); } void GSTextureCache::Target::Update() { __super::Update(); // FIXME: the union of the rects may also update wrong parts of the render target (but a lot faster :) GSVector4i r = m_dirty.GetDirtyRectAndClear(m_TEX0, m_texture->GetSize()); if(r.rempty()) return; if(m_type == RenderTarget) { int w = r.width(); int h = r.height(); if(GSTexture* t = m_renderer->m_dev->CreateTexture(w, h)) { const GSOffset* o = m_renderer->m_mem.GetOffset(m_TEX0.TBP0, m_TEX0.TBW, m_TEX0.PSM); GIFRegTEXA TEXA; TEXA.AEM = 1; TEXA.TA0 = 0; TEXA.TA1 = 0x80; GSTexture::GSMap m; if(t->Map(m)) { m_renderer->m_mem.ReadTexture(o, r, m.bits, m.pitch, TEXA); t->Unmap(); } else { static uint8* buff = (uint8*)::_aligned_malloc(1024 * 1024 * 4, 16); int pitch = ((w + 3) & ~3) * 4; m_renderer->m_mem.ReadTexture(o, r, buff, pitch, TEXA); t->Update(r.rsize(), buff, pitch); } // m_renderer->m_perfmon.Put(GSPerfMon::Unswizzle, w * h * 4); m_renderer->m_dev->StretchRect(t, m_texture, GSVector4(r) * GSVector4(m_texture->GetScale()).xyxy()); m_renderer->m_dev->Recycle(t); } } else if(m_type == DepthStencil) { // do the most likely thing a direct write would do, clear it if((m_renderer->m_game.flags & CRC::ZWriteMustNotClear) == 0) { m_renderer->m_dev->ClearDepth(m_texture, 0); } } } // GSTextureCache::SourceMap void GSTextureCache::SourceMap::Add(Source* s, const GIFRegTEX0& TEX0, const GSOffset* o) { m_surfaces.insert(s); if(s->m_target) { // TODO m_map[TEX0.TBP0 >> 5].push_front(s); return; } const GSLocalMemory::psm_t& psm = GSLocalMemory::m_psm[TEX0.PSM]; GSVector2i bs = (TEX0.TBP0 & 31) == 0 ? psm.pgs : psm.bs; int tw = 1 << TEX0.TW; int th = 1 << TEX0.TH; for(int y = 0; y < th; y += bs.y) { uint32 base = o->block.row[y >> 3]; for(int x = 0; x < tw; x += bs.x) { uint32 page = (base + o->block.col[x >> 3]) >> 5; if(page < MAX_PAGES) { m_pages[page >> 5] |= 1 << (page & 31); } } } for(int i = 0; i < countof(m_pages); i++) { if(uint32 p = m_pages[i]) { m_pages[i] = 0; list<Source*>* m = &m_map[i << 5]; unsigned long j; while(_BitScanForward(&j, p)) { p ^= 1 << j; m[j].push_front(s); } } } } void GSTextureCache::SourceMap::RemoveAll() { for_each(m_surfaces.begin(), m_surfaces.end(), delete_object()); m_surfaces.clear(); for(uint32 i = 0; i < countof(m_map); i++) { m_map[i].clear(); } } void GSTextureCache::SourceMap::RemoveAt(Source* s) { m_surfaces.erase(s); for(uint32 start = s->m_TEX0.TBP0 >> 5, end = s->m_target ? start : countof(m_map) - 1; start <= end; start++) { list<Source*>& m = m_map[start]; for(list<Source*>::iterator i = m.begin(); i != m.end(); ) { list<Source*>::iterator j = i++; if(*j == s) {m.erase(j); break;} } } delete s; }
[ "koeiprogenitor@bfa1b011-20a7-a6e3-c617-88e5d26e11c5" ]
[ [ [ 1, 1198 ] ] ]
676c5849c08b9592bef8caef35bdf633de8ccb47
0f8559dad8e89d112362f9770a4551149d4e738f
/Wall_Destruction/Havok/Source/Physics/Utilities/VisualDebugger/Viewer/Dynamics/Constraint/Drawer/hkpConstraintDrawer.h
614c37649bb6d5a87a59966cc6c91641195fb942
[]
no_license
TheProjecter/olafurabertaymsc
9360ad4c988d921e55b8cef9b8dcf1959e92d814
456d4d87699342c5459534a7992f04669e75d2e1
refs/heads/master
2021-01-10T15:15:49.289873
2010-09-20T12:58:48
2010-09-20T12:58:48
45,933,002
0
0
null
null
null
null
UTF-8
C++
false
false
3,366
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-2009 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_CONSTRAINTDRAWER_H #define HK_CONSTRAINTDRAWER_H #include <Physics/Utilities/VisualDebugger/Viewer/Dynamics/Constraint/Drawer/hkpPrimitiveDrawer.h> /// Base class for constraint drawers class hkpConstraintInstance; class hkpConstraintDrawer { public: HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_VDB, hkpConstraintDrawer ); hkpConstraintDrawer(); /// Sets the size of lines drawn. void setLineLength(hkReal lineLength); /// Sets the radius of arcs drawn. void setArcRadius(hkReal arcRadius); /// Allows the user to up the number of segments used when displaying curved geometry. void setNumArcSegments(int numSegments); /// Set the size of the pivots drawn. void setPivotSize(hkReal size); /// Sets the size of arrows drawn. void setArrowSize(hkReal arrrowSize); /// Sets the scale of all drawing void setScale(hkReal scale); protected: void drawPivots(int id, int tag); void drawBodyFrames(int id, int tag); void updateCommonParameters(const hkpConstraintInstance* constraint, hkTransform& refLocalToWorld, hkTransform& attLocalToWorld); private: hkReal m_lineLength; hkReal m_arcRadius; hkReal m_pivotSize; hkReal m_arrowSize; hkReal m_coneSize; hkReal m_planeSize; int m_numArcSegments; hkReal m_scale; protected: hkReal getLineLengthForDraw() { return m_scale * m_lineLength; } hkReal getArrowSizeForDraw() { return m_scale * m_arrowSize; } hkReal getConeSizeForDraw() { return m_scale * m_coneSize; } hkReal getPlaneSizeForDraw() { return m_scale * m_planeSize; } hkReal getPivotSizeForDraw() { return m_scale * m_pivotSize; } hkReal getArcRadiusForDraw() { return m_scale * m_arcRadius; } int getNumArcSegmentsForDraw() { return m_numArcSegments; } protected: // world positions hkVector4 m_bodyAWPos; hkVector4 m_bodyBWPos; // world positions of pivots hkVector4 m_bodyAWPivot; hkVector4 m_bodyBWPivot; hkRotation m_RA; hkRotation m_RB; hkpPrimitiveDrawer m_primitiveDrawer; }; #endif /* * Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20091222) * * Confidential Information of Havok. (C) Copyright 1999-2009 * 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. * */
[ [ [ 1, 128 ] ] ]
7fd54f0a1f5e779fb78b257dfd22036f148d9d17
c2153dcfa8bcf5b6d7f187e5a337b904ad9f91ac
/src/Engine/Core/InputAsciiMap.h
558cc052fc0df04f8237aa58f94120250ea54e89
[]
no_license
ptrefall/smn6200fluidmechanics
841541a26023f72aa53d214fe4787ed7f5db88e1
77e5f919982116a6cdee59f58ca929313dfbb3f7
refs/heads/master
2020-08-09T17:03:59.726027
2011-01-13T22:39:03
2011-01-13T22:39:03
32,448,422
1
0
null
null
null
null
UTF-8
C++
false
false
2,444
h
namespace Engine { namespace InputAsciiMap { char ascii_map[4][51] = { // shift off and capslock off { 0, ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ';', '=', ',', '-', '.', '/', '`', '[', '\\', ']', '\'', 0, 0 }, // shift on and capslock off { 0, ' ', ')', '!', '@', '#', '$', '%', '^', '&', '*', '(', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ':', '+', '<', '_', '>', '?', '~', '{', '|', '}', '"', 0, 0 }, // shift on and capslock on { 0, ' ', ')', '!', '@', '#', '$', '%', '^', '&', '*', '(', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ':', '+', '<', '_', '>', '?', '~', '{', '|', '}', '"', 0, 0 }, // shift off and capslock on { 0, ' ', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ';', '=', ',', '-', '.', '/', '`', '[', '\\', ']', '\'', 0, 0 } }; char keypad_map[2][18] = { { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '\n', '*', '+', 0, '-', '.', '/', '=' }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\n', '*', '+', 0, '-', 0, '/', '=' } }; } }
[ "[email protected]@c628178a-a759-096a-d0f3-7c7507b30227" ]
[ [ [ 1, 273 ] ] ]
85ee3ec3a673b0dbf905f79b7644d7aef50bf2f6
478570cde911b8e8e39046de62d3b5966b850384
/apicompatanamdw/bcdrivers/mw/locationsrv/landmarks_database_management_api/src/testdbmanagementapi.cpp
8dda7d491b68e5343b14c1effe7176c297f27d90
[]
no_license
SymbianSource/oss.FCL.sftools.ana.compatanamdw
a6a8abf9ef7ad71021d43b7f2b2076b504d4445e
1169475bbf82ebb763de36686d144336fcf9d93b
refs/heads/master
2020-12-24T12:29:44.646072
2010-11-11T14:03:20
2010-11-11T14:03:20
72,994,432
0
0
null
null
null
null
UTF-8
C++
false
false
3,758
cpp
/* * Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: Ctestdbmanagementapi class * */ // INCLUDE FILES #include <Stiftestinterface.h> #include "testdbmanagementapi.h" // ============================ MEMBER FUNCTIONS =============================== // ----------------------------------------------------------------------------- // Ctestdbmanagementapi::Ctestdbmanagementapi // C++ default constructor can NOT contain any code, that // might leave. // ----------------------------------------------------------------------------- // Ctestdbmanagementapi::Ctestdbmanagementapi( CTestModuleIf& aTestModuleIf ): CScriptBase( aTestModuleIf ) { } // ----------------------------------------------------------------------------- // Ctestdbmanagementapi::ConstructL // Symbian 2nd phase constructor can leave. // ----------------------------------------------------------------------------- // void Ctestdbmanagementapi::ConstructL() { iLog = CStifLogger::NewL( KtestdbmanagementapiLogPath, KtestdbmanagementapiLogFile, CStifLogger::ETxt, CStifLogger::EFile, EFalse ); SendTestModuleVersion(); } //----------------------------------------------------------------------------- // Ctestdbmanagementapi::SendTestClassVersion // Method used to send version of test class //----------------------------------------------------------------------------- // void Ctestdbmanagementapi::SendTestModuleVersion() { TVersion moduleVersion; moduleVersion.iMajor = TEST_MODULE_VERSION_MAJOR; moduleVersion.iMinor = TEST_MODULE_VERSION_MINOR; moduleVersion.iBuild = TEST_MODULE_VERSION_BUILD; TFileName moduleName; moduleName = _L("testdbmanagementapi.dll"); TBool newVersionOfMethod = ETrue; CTestModuleIf &test=TestModuleIf(); test.SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod); test.SetBehavior(CTestModuleIf::ETestLeaksHandles); } // ----------------------------------------------------------------------------- // Ctestdbmanagementapi::NewL // Two-phased constructor. // ----------------------------------------------------------------------------- // Ctestdbmanagementapi* Ctestdbmanagementapi::NewL( CTestModuleIf& aTestModuleIf ) { Ctestdbmanagementapi* self = new (ELeave) Ctestdbmanagementapi( aTestModuleIf ); CleanupStack::PushL( self ); self->ConstructL(); CleanupStack::Pop(); return self; } // Destructor Ctestdbmanagementapi::~Ctestdbmanagementapi() { // Delete resources allocated from test methods Delete(); // Delete logger delete iLog; } // ========================== OTHER EXPORTED FUNCTIONS ========================= // ----------------------------------------------------------------------------- // LibEntryL is a polymorphic Dll entry point. // Returns: CScriptBase: New CScriptBase derived object // ----------------------------------------------------------------------------- // EXPORT_C CScriptBase* LibEntryL( CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework { return ( CScriptBase* ) Ctestdbmanagementapi::NewL( aTestModuleIf ); } // End of File
[ "none@none" ]
[ [ [ 1, 121 ] ] ]
6c292a6877db8479001b541fccf32e0d0c372606
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/__ffl_dump/include/ffl_text_file.h
bcd023e61c75b91bc756af6134beabac8d41170d
[]
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
818
h
#ifndef __FFL_TEXT_FILE_H__ #define __FFL_TEXT_FILE_H__ #include "ffl_common.h" #include "ffl_file.h" class ffl_text_file { public: ffl_text_file(); ~ffl_text_file(); bool create( const ffl_tchar_t * name, unsigned int access_mode = GENERIC_READ | GENERIC_WRITE, unsigned int share_mode = FILE_SHARE_READ ); bool open( const ffl_tchar_t * name, unsigned int access_mode = GENERIC_READ | GENERIC_WRITE, unsigned int share_mode = FILE_SHARE_READ ); void close(); bool opened(); size_t write_text( const ffl_tchar_t * text, size_t count ); size_t read_text( ffl_tchar_t * text, size_t count ); size_t read_line( ffl_tchar_t * text, size_t count ); bool flush(); ffl_uint64_t size(); private: ffl_file file_; }; #endif //__FFL_TEXT_FILE_H__
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 34 ] ] ]
e9349c3a00d6501a5cff30fe0ab3c3c097e660b7
252e638cde99ab2aa84922a2e230511f8f0c84be
/tripformlib/src/TripStepViewForm.cpp
7383758484c762701926d2ace17f38ce13869541
[]
no_license
openlab-vn-ua/tour
abbd8be4f3f2fe4d787e9054385dea2f926f2287
d467a300bb31a0e82c54004e26e47f7139bd728d
refs/heads/master
2022-10-02T20:03:43.778821
2011-11-10T12:58:15
2011-11-10T12:58:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,063
cpp
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrTripStep #include "FieldDef.h" #include "StdTool.h" #include "TourTool.h" #include "TripStepViewForm.h" //#include "TripStepAddForm.h" //#include "TripStepEditForm.h" #include "TripStepWizardForm.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "Placemnt" #pragma link "RXDBCtrl" #pragma link "TableGridViewForm" #pragma link "VADODataSourceOrdering" #pragma link "VCustomDataSourceOrdering" #pragma link "VDBGridFilterDialog" #pragma link "VDBSortGrid" #pragma link "VStringStorage" #pragma link "VCustomDBGridFilterDialog" #pragma resource "*.dfm" TTourTripStepViewForm *TourTripStepViewForm; enum TourTripStepStringTypes { TourTripStepNoSelectItemStr = TourRefBookViewStringTypesEnumCount, TourTripStepStepByTripStepIdCaptionStr, TourTripStepRecordTripStepWizardHintStr }; #define GetTranslatedStr(Index) VStringStorage->Lines->Strings[Index] //--------------------------------------------------------------------------- __fastcall TTourTripStepViewForm::TTourTripStepViewForm(TComponent* Owner) : TTourRefBookTableGridViewForm(Owner) { } //--------------------------------------------------------------------------- /* void __fastcall TTourTripStepViewForm::NewActionExecute( TObject *Sender) { TTourTripStepAddForm *TourTripStepAddFormPtr; FunctionArgUsedSkip(Sender); TourTripStepAddFormPtr = NULL; if (!EditLocked) { try { Application->CreateForm(__classid(TTourTripStepAddForm), &TourTripStepAddFormPtr); if (TourTripStepAddFormPtr != NULL) { TourTripStepAddFormPtr->MainQueryDataSet = MainQuery; TourTripStepAddFormPtr ->BusDataSource->DataSet = BusQuery; TourTripStepAddFormPtr ->TripStepOwnerDataSource->DataSet = TripStepOwnerQuery; ShowProcessAdd(TourTripStepAddFormPtr); delete (TourTripStepAddFormPtr); TourTripStepAddFormPtr = NULL; } else { throw Exception(GetTranslatedStr(TourRefBookCreateObjectErrorMessageStr) + "TTourTripStepAddForm"); } } catch (Exception &exception) { TourShowDialogException(NULL,&exception); } } } //--------------------------------------------------------------------------- void __fastcall TTourTripStepViewForm::EditActionExecute( TObject *Sender) { TTourTripStepEditForm *TourTripStepEditFormPtr; FunctionArgUsedSkip(Sender); TourTripStepEditFormPtr = NULL; if (!EditLocked) { try { Application->CreateForm(__classid(TTourTripStepEditForm), &TourTripStepEditFormPtr); if (TourTripStepEditFormPtr != NULL) { TourTripStepEditFormPtr->MainQueryDataSet = MainQuery; TourTripStepEditFormPtr ->BusDataSource->DataSet = BusQuery; TourTripStepEditFormPtr ->TripStepOwnerDataSource->DataSet = TripStepOwnerQuery; ShowProcessEdit(TourTripStepEditFormPtr); delete (TourTripStepEditFormPtr); TourTripStepEditFormPtr = NULL; } else { throw Exception(GetTranslatedStr(TourRefBookCreateObjectErrorMessageStr) + "TTourTripStepEditForm"); } } catch (Exception &exception) { TourShowDialogException(NULL,&exception); } } } */ //--------------------------------------------------------------------------- void __fastcall TTourTripStepViewForm::FormClose(TObject *Sender, TCloseAction &Action) { try { TripQuery->Close(); StopQuery->Close(); } catch (Exception &exception) { TourShowDialogException(NULL,&exception); } TTourRefBookTableGridViewForm::FormClose(Sender,Action); TourTripStepViewForm = NULL; } //--------------------------------------------------------------------------- void __fastcall TTourTripStepViewForm::FormCreate(TObject *Sender) { CursorWaitOpen(); try { TripQuery->Open(); StopQuery->Open(); } catch (Exception &exception) { TourShowDialogException(NULL,&exception); } CursorWaitClose(); TTourRefBookTableGridViewForm::FormCreate(Sender); EditLocked = true; AfterMainTableOpenStatusBarHintStr += GetTranslatedStr(TourTripStepRecordTripStepWizardHintStr); MainStatusBar->Panels->Items[0]->Text = AfterMainTableOpenStatusBarHintStr; } //--------------------------------------------------------------------------- void __fastcall TTourTripStepViewForm::RefreshActionExecute( TObject *Sender) { CursorWaitOpen(); try { if (TripQuery->Active) { TripQuery->Close(); } if (!TripQuery->Active) { TripQuery->Open(); } if (StopQuery->Active) { StopQuery->Close(); } if (!StopQuery->Active) { StopQuery->Open(); } } catch (Exception &exception) { TourShowDialogException(NULL,&exception); } CursorWaitClose(); TTourRefBookTableGridViewForm::RefreshActionExecute(Sender); } //--------------------------------------------------------------------------- void __fastcall TTourTripStepViewForm::TripStepStepActionExecute(TObject *Sender) { TTourTripStepWizardForm *TripStepWizardFormPtr; AnsiString TripIdStr; FunctionArgUsedSkip(Sender); TripStepWizardFormPtr = NULL; TripIdStr = ""; try { Application->CreateForm(__classid(TTourTripStepWizardForm), &TripStepWizardFormPtr); if (TripStepWizardFormPtr != NULL) { TripIdStr = MainQuery->FieldByName(TripIdFieldNameStr)->AsString; if (!TripIdStr.IsEmpty()) { TripStepWizardFormPtr->Caption = GetTranslatedStr(TourTripStepStepByTripStepIdCaptionStr) + TripIdStr + " [" + MainQuery->FieldByName(TripNameFieldNameStr)->AsString + "]"; TripStepWizardFormPtr->CurrentTripId/*Str*/ = TripIdStr; // TripStepWizardFormPtr->FillChainStrStoreByTrip(TripIdStr); if (TripStepWizardFormPtr->ShowModal() == mrOk) { TripStepWizardFormPtr->UpdateTripStepTable(TripIdStr); RefreshActionExecute(Sender); } } else { TourShowDialogError ((GetTranslatedStr(TourTripStepNoSelectItemStr)).c_str()); } delete (TripStepWizardFormPtr); TripStepWizardFormPtr = NULL; } } catch (Exception &exception) { TourShowDialogException(NULL,&exception); } } //--------------------------------------------------------------------------- #undef GetTranslatedStr(Index)
[ [ [ 1, 260 ] ] ]
ef8e78c6c67c6fffd7a19eb5fbb961e00daf5285
c7120eeec717341240624c7b8a731553494ef439
/src/cplusplus/freezone-samp/src/core/serialization/configuradable.hpp
34324154df43d1039eb12336e31f37221d254eb1
[]
no_license
neverm1ndo/gta-paradise-sa
d564c1ed661090336621af1dfd04879a9c7db62d
730a89eaa6e8e4afc3395744227527748048c46d
refs/heads/master
2020-04-27T22:00:22.221323
2010-09-04T19:02:28
2010-09-04T19:02:28
174,719,907
1
0
null
2019-03-09T16:44:43
2019-03-09T16:44:43
null
WINDOWS-1251
C++
false
false
581
hpp
#ifndef CONFIGURADABLE_HPP #define CONFIGURADABLE_HPP #include "serialization.hpp" #include <memory> // Интерфейс объекта, который может быть сконфигурирован class configuradable: public serialization::auto_name { public: typedef std::tr1::shared_ptr<configuradable> ptr; typedef serialization::def_t<configuradable> def_t; virtual void configure_pre() = 0; virtual void configure(buffer::ptr const& buff, def_t const& def) = 0; virtual void configure_post() = 0; }; #endif // CONFIGURADABLE_HPP
[ "dimonml@19848965-7475-ded4-60a4-26152d85fbc5" ]
[ [ [ 1, 16 ] ] ]
3f33bf12ea64fa1558ac9e461ced45a511327fb2
b240ccb537657eb72a3ac7634c99e3b8733e454c
/code/api/api_v001rc/networkcommunication/tcpSocket/src/smtpclient.cpp
5512b735f0829d6b134ac952d57ea9bbaec2c458
[]
no_license
Jmos/ftofsharing
96c2c77deab4c15da0ec42b14e0c17f5adfeb485
8969c3b33a2173c36f3a282b946b92656d77ad81
refs/heads/master
2021-01-22T23:16:04.198478
2011-06-04T18:46:00
2011-06-04T18:46:00
34,392,347
0
0
null
null
null
null
UTF-8
C++
false
false
7,538
cpp
#include "smtpclient.h" //----------------------------------------------------------------- /** * Constructor of CSmtpClient-Class\n * and Parent-Constructor of CMailClient-Class* * * @param iConnectionType Sets the connection type (unencrypted/SSL) * * @see CMailClient * ********************************************************************************/ CSmtpClient::CSmtpClient(CTcpSocket::EConnectionType iConnectionType): CMailClient(ProtocolSMTP, iConnectionType) { } /** * Constructor of CSmtpClient-Class\n * and Parent-Constructor of CMailClient-Class* * * @param iHostName Defines the Host to connect to. * @param iConnectionType Sets the connection type (unencrypted/SSL). * * @see CMailClient * ********************************************************************************/ CSmtpClient::CSmtpClient(QString iHostName, CTcpSocket::EConnectionType iConnectionType): CMailClient(ProtocolSMTP, iConnectionType, iHostName) { } /** * Constructor of CSmtpClient-Class\n * and Parent-Constructor of CMailClient-Class* * * @param iHostName Defines the host to connect to. * @param iUserName Defines the username for authentication. * @param iPassWord Defines the password for authentication. * @param iConnectionType Sets the connection type (unencrypted/SSL). * * @see CMailClient * ********************************************************************************/ CSmtpClient::CSmtpClient(QString iHostName, QString iUserName, QString iPassWord, CTcpSocket::EConnectionType iConnectionType): CMailClient(ProtocolSMTP, iConnectionType, iHostName, iUserName, iPassWord) { } /** * Function to send an e-mail. * * @param iMail A Pointer to an instance of \c REMail. * @return Returns \c true when sending was successfully, else \c false. * ********************************************************************************/ bool CSmtpClient::SendMail(REMail *iMail) { return SendMail(iMail, cHostName, cUserName, cPassWord); } /** * Function to send an e-mail. * * @param iMail A Pointer to an instance of \c REMail. * @param iUserName Defines the username for authentication. * @param iPassWord Defines the password for authentication. * @return Returns \c true when sending was successfully, else \c false. * ********************************************************************************/ bool CSmtpClient::SendMail(REMail *iMail, QString iUserName, QString iPassWord) { return SendMail(iMail, cHostName, iUserName, iPassWord); } /** * Function to send an e-mail. * * @param iMail A Pointer to an instance of \c REMail. * @param iHostName Defines the host to connect to. * @param iUserName Defines the username for authentication. * @param iPassWord Defines the password for authentication. * @return Returns \c true when sending was successfully, else \c false. * ********************************************************************************/ bool CSmtpClient::SendMail(REMail *iMail, QString iHostName, QString iUserName, QString iPassWord) { QList<QString> MailData; if (!CheckParams(iHostName, iUserName, iPassWord)) return false; if (iMail != NULL) { if (iMail->To.isEmpty() || !iMail->To.contains("@")) { cLastError= INVALIDTOADDRESS; return false; } if (iMail->From.isEmpty() || !iMail->From.contains("@")) { cLastError= INVALIDFROMADDRESS; return false; } } else { cLastError= INVALIDMAIL; return false; } MailData.append("From: <" + iMail->From + ">"); MailData.append("To: <" + iMail->To + ">"); MailData.append("Subject: " + iMail->Subject + "\n"); MailData.append(iMail->Body); MailData.append("\r\n.\r\n"); if (cTcpSocket != NULL) delete cTcpSocket; cTcpSocket = new CTcpSocket(cConnectionType); if (!ServerLogIn(iHostName, iUserName, iPassWord)) return false; if (!cTcpSocket->SendText("MAIL FROM: <" + iMail->From + ">\r\n")) { cLastError= SENDINGERROR; return false; } if (cTcpSocket->ReceiveText().left(3) != "250") { cLastError= INVALIDFROMADDRESS; return false; } if (!cTcpSocket->SendText("RCPT TO: <" + iMail->To + ">\r\n")) { cLastError= SENDINGERROR; return false; } if (cTcpSocket->ReceiveText().left(3) != "250") { cLastError= INVALIDTOADDRESS; return false; } if (!cTcpSocket->SendText("DATA\r\n")) { cLastError= SENDINGERROR; return false; } if (cTcpSocket->ReceiveText().left(3) != "354") { cLastError= UNKNOWNSERVERERROR; return false; } if (!cTcpSocket->SendText(MailData)) { cLastError= SENDINGERROR; return false; } if (cTcpSocket->ReceiveText().left(3) != "250") { cLastError= UNKNOWNSERVERERROR; return false; } cTcpSocket->Disconnect(); return true; } /** * Implementation of abstract class CMailClient.\n * Private function to login at the current host. * * @param iHostName Defines the host to connect to. * @param iUserName Defines the username for authentication. * @param iPassWord Defines the password for authentication. * @return Returns \c true when login was successfully, else \c false. * * @see CMailClient, CPop3Client * ********************************************************************************/ bool CSmtpClient::ServerLogIn(QString iHostName, QString iUserName, QString iPassWord) { QString PCName= getenv("COMPUTERNAME"); QByteArray UserName; QByteArray PassWord; UserName.append(iUserName); PassWord.append(iPassWord); if (cTcpSocket->ConnectTo(iHostName, cServerPort, cMaxServerTimeOut)) { if (cTcpSocket->ReceiveText().left(3) != "220") { cLastError= UNKNOWNSERVERERROR; return false; } if (!cTcpSocket->SendText("EHLO " + PCName + "\r\n")) { cLastError= SENDINGERROR; return false; } if (cTcpSocket->ReceiveText().left(3) != "250") { if (!cTcpSocket->SendText("HELO " + PCName + "\r\n")) { cLastError= SENDINGERROR; return false; } if (cTcpSocket->ReceiveText().left(3) != "250") { cLastError= UNKNOWNSERVERERROR; return false; } } if (!cTcpSocket->SendText("AUTH LOGIN\r\n")) { cLastError= SENDINGERROR; return false; } if (cTcpSocket->ReceiveText().left(3) != "334") { cLastError= AUTHENTICATIONERROR; return false; } if (!cTcpSocket->SendText((QString)UserName.toBase64() + "\r\n")) { cLastError= SENDINGERROR; return false; } if (cTcpSocket->ReceiveText().left(3) != "334") { cLastError= AUTHENTICATIONERROR; return false; } if (!cTcpSocket->SendText((QString)PassWord.toBase64() + "\r\n")) { cLastError= SENDINGERROR; return false; } if (cTcpSocket->ReceiveText().left(3) != "235") { cLastError= AUTHENTICATIONERROR; return false; } return true; } else { cLastError= UNAVAILABLEHOST; } return false; }
[ "georgsaxl@ed7a1941-e62f-a9da-ef21-68f2f9546975" ]
[ [ [ 1, 259 ] ] ]
63b4f94a1067e025e5e84e5cc535ae7d3a97c73f
27d5670a7739a866c3ad97a71c0fc9334f6875f2
/CPP/Targets/MapLib/Shared/src/TileMapUtil.cpp
dc741e5b73823d61dbec64b799597b70683b69f2
[ "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
1,756
cpp
/* 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. */ #include "TileMapUtil.h" char* TileMapUtil::newStrDup(const char* orig) { int memlen = strlen(orig) + 1; char* copyStr = new char[memlen]; memcpy(copyStr, orig, memlen); return copyStr; }
[ [ [ 1, 23 ] ] ]
178db395836ada3330da91f1c61fa0d56f4df6a4
23df069203762da415d03da6f61cdf340e84307b
/2009-2010/winter10/csci245/archive/eval/symbol.h
6a167022516d99c286e87b3f11412ec77cd587fe
[]
no_license
grablisting/ray
9356e80e638f3a20c5280b8dba4b6577044d4c6e
967f8aebe2107c8052c18200872f9389e87d19c1
refs/heads/master
2016-09-10T19:51:35.133301
2010-09-29T13:37:26
2010-09-29T13:37:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
450
h
#ifndef SYMBOL_H #define SYMBOL_H #include "sexpr.h" #include <iostream> class Symbol : public Sexpr { public: Symbol(){}; /** Returns the symbol. @param return is a string. */ string get_string(); /** Reads Symbols. @param in is the source. */ void read(istream& in); /** Prints Symbols. @param out is the destination. */ void print(ostream& out); private: string name; }; #endif
[ "Bobbbbommmbb@Bobbbbommmbb-PC.(none)" ]
[ [ [ 1, 33 ] ] ]
bc1d62c6730b96dd199efd49fc39604f41747639
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/_Multimedia/WaveStream/sndtimer.cpp
ac7cb823154aa3a0b17a9870408478b0b5441419
[]
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
UHC
C++
false
false
1,691
cpp
// Timer.cpp //#define VC_EXTRALEAN //#define STRICT #include "stdafx.h" // MFC에서는 항상 "stdafx.h"를 먼저 써줘야 한다(-_-;) #include "assert.h" #include "debug.h" #include <mmsystem.h> #include "sndTimer.h" int g_nTimer; // constructor Timer::Timer (void) { DOUT ("Timer::Timer\n\r"); m_nIDTimer = NULL; } // Destructor Timer::~Timer (void) { DOUT ("Timer::~Timer\n\r"); if (m_nIDTimer) { if(timeKillEvent (m_nIDTimer) != TIMERR_NOERROR ) { ASSERT(0); } g_nTimer--; } } // Create BOOL Timer::Create (UINT nPeriod, UINT nRes, DWORD dwUser, TIMERCALLBACK pfnCallback) { BOOL bRtn = SUCCESS; // assume success DOUT ("Timer::Create\n\r"); ASSERT (pfnCallback); ASSERT (nPeriod > 10); ASSERT (nPeriod >= nRes); m_nPeriod = nPeriod; m_nRes = nRes; m_dwUser = dwUser; m_pfnCallback = pfnCallback; g_nTimer++; if ((m_nIDTimer = timeSetEvent (m_nPeriod, m_nRes, TimeProc, (DWORD) this, TIME_PERIODIC)) == NULL) { bRtn = FALSE; } return (bRtn); } // Timer proc for multimedia timer callback set with timeSetTime(). // // Calls procedure specified when Timer object was created. The // dwUser parameter contains "this" pointer for associated Timer object. // void CALLBACK Timer::TimeProc(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2) { if(!g_nTimer) return; // dwUser contains ptr to Timer object Timer * ptimer = (Timer *) dwUser; // Call user-specified callback and pass back user specified data (ptimer->m_pfnCallback) (ptimer->m_dwUser); }
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 76 ] ] ]
e83a73ccd7f9809cb62aee563e6a0b162139d6e7
a7985fd90271731c73cab45029ee9a9903c8e1a2
/server/westley.hennigh_server/westley.hennigh_server/Defines.hpp
8cc17a7daaeff94160c0400ce1a41b51b20ffd1a
[]
no_license
WestleyArgentum/cs260-networking
129039f7ad2a89b9350ddcac0cc50a17c6f74bf7
36d2d34400ad93906e2b4839278e4b33de28ae8b
refs/heads/master
2021-01-01T05:47:12.910324
2010-04-07T07:01:40
2010-04-07T07:01:40
32,187,121
0
0
null
null
null
null
UTF-8
C++
false
false
202
hpp
// Westley Hennigh // Defines.hpp : Common defines for buffer size etc // CS260 Assignment 3 // Mar 19th 2010 #ifndef MYDEFINES #define MYDEFINES const unsigned STD_BUFF_SIZE = 9001; #endif
[ "[email protected]@1f2afcba-5144-80f4-e828-afee2f9acc6f", "knuxjr@1f2afcba-5144-80f4-e828-afee2f9acc6f" ]
[ [ [ 1, 5 ] ], [ [ 6, 11 ] ] ]
c97e0e8db2f8b09420b574a044706f2e9caa8f7a
0b66a94448cb545504692eafa3a32f435cdf92fa
/tags/0.5/cbear.berlios.de/range/back.hpp
3e9793a4241482d1303a2f0158db43b86327c916
[ "MIT" ]
permissive
BackupTheBerlios/cbear-svn
e6629dfa5175776fbc41510e2f46ff4ff4280f08
0109296039b505d71dc215a0b256f73b1a60b3af
refs/heads/master
2021-03-12T22:51:43.491728
2007-09-28T01:13:48
2007-09-28T01:13:48
40,608,034
0
0
null
null
null
null
UTF-8
C++
false
false
1,631
hpp
/* The MIT License Copyright (c) 2005 C Bear (http://cbear.berlios.de) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef CBEAR_BERLIOS_DE_RANGE_BACK_HPP_INCLUDED #define CBEAR_BERLIOS_DE_RANGE_BACK_HPP_INCLUDED #include <cbear.berlios.de/range/reference.hpp> namespace cbear_berlios_de { namespace range { template<class Container> typename reference<Container>::type back(Container &X) { return traits<Container>::back(X); } template<class Container> typename reference<const Container>::type back(const Container &X) { return traits<const Container>::back(X); } } } #endif
[ "sergey_shandar@e6e9985e-9100-0410-869a-e199dc1b6838" ]
[ [ [ 1, 48 ] ] ]
abaee46328605d95cf903eb812dfc7dd7fd6efac
fcf03ead74f6dc103ec3b07ffe3bce81c820660d
/Base/IPC/Async/Fibonacci3/Fibonacci3.cpp
f48fb16332c03e0f7834cd6dfe2d74ff3678c8d3
[]
no_license
huellif/symbian-example
72097c9aec6d45d555a79a30d576dddc04a65a16
56f6c5e67a3d37961408fc51188d46d49bddcfdc
refs/heads/master
2016-09-06T12:49:32.021854
2010-10-14T06:31:20
2010-10-14T06:31:20
38,062,421
2
0
null
null
null
null
UTF-8
C++
false
false
15,855
cpp
// Fibonacci3.CPP // // Copyright (C) Symbian Software Ltd 1997-2005. All rights reserved. // // Example wraps a console in an active object and performs the // Fibonacci calculation as a background active object. // // The technique used is similar to, but not identical, to that used by CIdle, where // the background active object is repeatedly called provided the other (higher priority) // active objects are not ready to run. // // // Fibonacci Active Objects example // #include <e32cons.h> #include <e32base.h> #include <e32std.h> ////testing only - can remove this & ModifyLedMask calls //nclude <e32hal.h> LOCAL_D CConsoleBase* console; _LIT(KTxtMainInstructions,"\n\nPress 'F' to start\n 'ESC' to exit\n 'C' to cancel, anytime\n"); ////////////////////////////////////////////////////////////////////////////// // // -----> CActiveConsole (definition) // // An abstract class which provides the facility to issue key requests. // ////////////////////////////////////////////////////////////////////////////// class CActiveConsole : public CActive { public: // Construction CActiveConsole(CConsoleBase* aConsole); void ConstructL(); // Destruction ~CActiveConsole(); // Issue request void RequestCharacter(); // Cancel request. // Defined as pure virtual by CActive; // implementation provided by this class. void DoCancel(); // Service completed request. // Defined as pure virtual by CActive; // implementation provided by this class, void RunL(); // Called from RunL() - an implementation must be provided // by derived classes to handle the completed request virtual void ProcessKeyPress(TChar aChar) = 0; protected: // Data members defined by this class CConsoleBase* iConsole; // A console for reading from }; ////////////////////////////////////////////////////////////////////////////// // // -----> CExampleScheduler (definition) // ////////////////////////////////////////////////////////////////////////////// class CActiveConsole; class CExampleScheduler : public CActiveScheduler { public: void Error (TInt aError) const; void WaitForAnyRequest(); void SetActiveObject(CActiveConsole* aActiveConsole); private: // data members defined for this class CActiveConsole* iActiveConsole; }; ////////////////////////////////////////////////////////////////////////////// // // -----> CFibonacciEngine (definition) // // This class provides the fibonacci calculation engine // ////////////////////////////////////////////////////////////////////////////// class CFibonacciEngine : public CBase { public: CFibonacciEngine() ; void StartCalculate (TInt aTerms) ; void StepCalculate () ; TUint iResult ; enum TEngineState {eInactive, eCalculating, eCompleted} ; TEngineState iState ; private: TUint iCurrentTotal ; TUint iPreviousTotal ; TInt iTermsLeftToDo ; } ; ////////////////////////////////////////////////////////////////////////////// // // -----> CFibonacciApplication (definition) // // This class encapsulates the fibonacci thread that runs the fibonacci engine // ////////////////////////////////////////////////////////////////////////////// class CFibonacciApplication : public CActive { public: CFibonacciApplication(CConsoleBase* aConsole, CFibonacciEngine* aFibonacciEngine) ; ~CFibonacciApplication() ; void CalculateFibonacci(TInt aIterations) ; private: void DoCancel() ; void RunL() ; private: CConsoleBase* iConsole ; CFibonacciEngine* iFibonacciEngine ; } ; ////////////////////////////////////////////////////////////////////////////// // // -----> CFibonacciKeyHandler (definition) // // This class encapsulates the fibonacci keyboard handler // ////////////////////////////////////////////////////////////////////////////// class CFibonacciKeyHandler : public CActiveConsole { public: CFibonacciKeyHandler( CConsoleBase* aConsole, CFibonacciApplication* aApplication) ; void ConstructL(); // Static construction static CFibonacciKeyHandler* NewLC(CConsoleBase* aConsole, CFibonacciApplication* aHandler) ; // service request void ProcessKeyPress(TChar aChar) ; private: CConsoleBase* iConsole ; CFibonacciApplication* iApplication ; }; ////////////////////////////////////////////////////////////////////////////// // // -----> CActiveConsole (implementation) // ////////////////////////////////////////////////////////////////////////////// CActiveConsole::CActiveConsole( CConsoleBase* aConsole) : CActive(CActive::EPriorityUserInput) // Construct high-priority active object { iConsole = aConsole; __DECLARE_NAME(_S("CActiveConsole")); } void CActiveConsole::ConstructL() { // Add to active scheduler CActiveScheduler::Add(this); } CActiveConsole::~CActiveConsole() { // Make sure we're cancelled Cancel(); } void CActiveConsole::DoCancel() { iConsole->ReadCancel(); } void CActiveConsole::RunL() { // Handle completed request ProcessKeyPress(TChar(iConsole->KeyCode())); } void CActiveConsole::RequestCharacter() { // A request is issued to the CConsoleBase to accept a // character from the keyboard. iConsole->Read(iStatus); SetActive(); } ////////////////////////////////////////////////////////////////////////////// // // -----> CExampleScheduler (implementation) // ////////////////////////////////////////////////////////////////////////////// void CExampleScheduler::Error(TInt aError) const { _LIT(KTxtSchedulerError,"CExampleScheduler - error"); User::Panic(KTxtSchedulerError,aError); } void CExampleScheduler::WaitForAnyRequest() { if (!(iActiveConsole->IsActive())) iActiveConsole->RequestCharacter(); CActiveScheduler::WaitForAnyRequest(); } void CExampleScheduler::SetActiveObject(CActiveConsole* aActiveConsole) { iActiveConsole = aActiveConsole; } ///////////////////////////////////////////////////////////////////////////////// // CFibonacciKeyHandler support routine // uses up arrow & down arrow to change number, Enter to select ///////////////////////////////////////////////////////////////////////////////// TInt GetValueFromKeyboard (TInt aInitial, TInt aStep, TInt lowerLimit, TInt upperLimit, const TDesC& aPrompt, CConsoleBase* aConsole) { TChar input ; TInt value = aInitial ; aConsole->Printf(aPrompt) ; do { aConsole->SetPos(0); _LIT(KFormat1,"%d "); aConsole->Printf(KFormat1, value); input = aConsole->Getch() ; if (input == EKeyUpArrow && value < upperLimit) value = value + aStep ; if (input == EKeyDownArrow && value > lowerLimit) value = value - aStep ; } while (input != EKeyEnter) ; return value ; } ////////////////////////////////////////////////////////////////////////////// // // -----> CFibonacciKeyHandler (implementation) // ////////////////////////////////////////////////////////////////////////////// CFibonacciKeyHandler::CFibonacciKeyHandler(CConsoleBase* aConsole, CFibonacciApplication* aApplication) : CActiveConsole(aConsole) // construct zero-priority active object { iConsole = aConsole ; iApplication = aApplication ; __DECLARE_NAME(_S("CFibonacciApplication")); // Add to active scheduler CActiveScheduler::Add(this); // Make this the active object ((CExampleScheduler*)(CActiveScheduler::Current()))->SetActiveObject(this); } void CFibonacciKeyHandler::ProcessKeyPress(TChar aChar) { // if key is ESC, cancel any outstanding request & stop the scheduler if (aChar == EKeyEscape) { CActiveScheduler::Stop(); return; } // If key is "f" or "F", issue a Fibonacci request if none is in progress if (aChar == 'f' || aChar == 'F') { if (!(iApplication->IsActive())) { _LIT(KTxtReturnTermNumber,"\nENTER selects num\nUP arrow increases num\nDOWN arrow decreases num\n\n"); TInt iterations = GetValueFromKeyboard(5,1,2,46, KTxtReturnTermNumber, iConsole) ; iApplication->CalculateFibonacci(iterations); } else { _LIT(KTxtAlreadyInProgress,"[Already in progress]"); iConsole->Printf(KTxtAlreadyInProgress); } return; } // If key is "c" or "C", cancel any outstanding request if (aChar == 'c' || aChar == 'C') { _LIT(KTxtCancelFibonacci,"\nCancelling Fibonacci.... \n"); iConsole->Printf(KTxtCancelFibonacci); iApplication->Cancel(); iConsole->Printf(KTxtMainInstructions); return; } _LIT(KTxtNotRecognised,"\nUnwanted key pressed"); iConsole->Printf(KTxtNotRecognised); iConsole->Printf(KTxtMainInstructions); } ////////////////////////////////////////////////////////////////////////////// // // -----> CFibonacciApplication (implementation) // ////////////////////////////////////////////////////////////////////////////// CFibonacciApplication::CFibonacciApplication(CConsoleBase* aConsole, CFibonacciEngine* aFibonacciEngine) // // Constructor // : CActive(EPriorityStandard) { iConsole = aConsole ; iFibonacciEngine = aFibonacciEngine ; CActiveScheduler::Add(this); __DECLARE_NAME(_S("CFibonacciApplication")); }; // destructor CFibonacciApplication::~CFibonacciApplication() { // cancel any requests and tell server Cancel() ; } void CFibonacciApplication::DoCancel() { // cancel the active object request iFibonacciEngine->iState = CFibonacciEngine::eInactive ; } // initiate a request void CFibonacciApplication::CalculateFibonacci(TInt aIterations) { // initialize engine // no neeed to set iStatus to KRequestPending, as request completes below iFibonacciEngine->StartCalculate(aIterations) ; // schedule the request SetActive() ; // send signal that this request has completed TRequestStatus* status = &iStatus ; User::RequestComplete(status, KErrNone) ; } void CFibonacciApplication::RunL() // implements a simple state engine: {eInactive, eCalculating, eCompleted} { if (iFibonacciEngine->iState == CFibonacciEngine::eInactive ) { _LIT(KTxtEngineNotInitialized,"Engine not initialized"); User::Panic(KTxtEngineNotInitialized, KErrNotReady) ; } else if (iFibonacciEngine->iState == CFibonacciEngine::eCalculating ) { // unnecessary - just provides feedback on progression of the calculation _LIT(KTxtDot,"."); iConsole->Printf(KTxtDot) ; // no neeed to set iStatus to KRequestPending, as request completes below // request next step iFibonacciEngine->StepCalculate() ; // schedule request SetActive() ; // send signal that this request has completed TRequestStatus* status = &iStatus ; User::RequestComplete(status, KErrNone) ; } else if (iFibonacciEngine->iState == CFibonacciEngine::eCompleted ) { // finished calculation: print result and reset state engine _LIT(KFormat2,"\n Result : %u \n"); //not used iConsole->Printf(KFormat2, iFibonacciEngine->iResult) ; iConsole->Printf(KTxtMainInstructions) ; iFibonacciEngine->iState = CFibonacciEngine::eInactive ; } } ////////////////////////////////////////////////////////////////////////////// // // -----> CFibonacciEngine (implementation) // ////////////////////////////////////////////////////////////////////////////// CFibonacciEngine::CFibonacciEngine() { iState = eInactive ; } void CFibonacciEngine::StartCalculate (TInt aTerms) { // initialise all internal variables to initial state iCurrentTotal = 1 ; iPreviousTotal = 0 ; iResult = 0 ; iTermsLeftToDo = aTerms - 1 ; // first step completed in variable initialization iState = eCalculating ; } void CFibonacciEngine::StepCalculate () { // if full calculation not yet complete, but in progress (i.e. not cancelled) if (--iTermsLeftToDo > 0 && iState == eCalculating) { // calculate next number in series TInt newTotal = iCurrentTotal + iPreviousTotal ; // update internal variables iPreviousTotal = iCurrentTotal ; iCurrentTotal = newTotal ; // introduce a delay to make us a long-running service User::After(1000000) ; // not necessary, but allows running total to be used during the calculation // (say for putting values into a chart or graph) iResult = iCurrentTotal ; } else if (iTermsLeftToDo <= 0) { // flag that calculation has finished and ensure final result is available iState = eCompleted ; iResult = iCurrentTotal ; } } ///////////////////////////////////////////////////////////////////////////////// // This section deals with initialisation and ensuring we have a console active ///////////////////////////////////////////////////////////////////////////////// void doExampleL () ; void SetupConsoleL(); GLDEF_C TInt E32Main() // main function called by E32 { CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack TRAPD(error,SetupConsoleL()); // more initialization, then do example _LIT(KTxtFibonacciExampleError,"Fibonacci example error"); __ASSERT_ALWAYS(!error,User::Panic(KTxtFibonacciExampleError,error)); delete cleanup; // destroy clean-up stack return 0; // and return } void SetupConsoleL() // initialize and call example code under cleanup stack { _LIT(KTxtFibActObjBackground,"Background Active Object"); console=Console::NewL(KTxtFibActObjBackground, TSize(KConsFullScreen,KConsFullScreen)); CleanupStack::PushL(console); console->Printf(KTxtMainInstructions) ; TRAPD(error, doExampleL()); // perform example function if (error) { _LIT(KFormat3,"failed: leave code=%d"); console->Printf(KFormat3, error); } _LIT(KTxtPressAnyKey,"[Press any key to exit]"); console->Printf(KTxtPressAnyKey); console->Getch(); // get and ignore character CleanupStack::PopAndDestroy(); // close console } ////////////////////////////////////////////////////////////////////////////// // // Do the example // ////////////////////////////////////////////////////////////////////////////// void doExampleL() { // Construct and install the active scheduler; push onto the cleanup stack CExampleScheduler* exampleScheduler = new (ELeave) CExampleScheduler; CleanupStack::PushL(exampleScheduler); // Install as the active scheduler CActiveScheduler::Install(exampleScheduler); // Create CFibonacciEngine active object; push onto the cleanup stack CFibonacciEngine* fibEngine = new (ELeave) CFibonacciEngine ; CleanupStack::PushL(fibEngine); // Create CFibonacciApplication handler active object; push onto the cleanup stack CFibonacciApplication* fibApplication = new CFibonacciApplication(console, fibEngine); CleanupStack::PushL(fibApplication); // Create CFibonacciKeyHandler active object; push onto the cleanup stack CFibonacciKeyHandler* fibKeyHandler = new CFibonacciKeyHandler(console, fibApplication); CleanupStack::PushL(fibKeyHandler); // issue initial request fibKeyHandler->RequestCharacter() ; // Main part of the program: // wait loop that cycles until ActiveScheduler::Stop called CActiveScheduler::Start(); // Remove items from the cleanup stack and destroy them CleanupStack::PopAndDestroy(4); }
[ "liuxk99@bdc341c6-17c0-11de-ac9f-1d9250355bca" ]
[ [ [ 1, 547 ] ] ]