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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
34286f17a6f60b7329488eb6e0ae570bc09774a2 | 9566086d262936000a914c5dc31cb4e8aa8c461c | /EnigmaAudio/OpenALAudioDevice.hpp | b8910afae66090636046d7c943ff87e5a2a999bf | []
| no_license | pazuzu156/Enigma | 9a0aaf0cd426607bb981eb46f5baa7f05b66c21f | b8a4dfbd0df206e48072259dbbfcc85845caad76 | refs/heads/master | 2020-06-06T07:33:46.385396 | 2011-12-19T03:14:15 | 2011-12-19T03:14:15 | 3,023,618 | 1 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 3,220 | hpp | #ifndef OPENALAUDIODEVICE_HPP_INCLUDED
#define OPENALAUDIODEVICE_HPP_INCLUDED
/*
Copyright © 2009 Christopher Joseph Dean Schaefer (disks86)
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "OpenAL.hpp"
#include "IAudioDevice.hpp"
#include "SoundSource.hpp"
#include "SoundSourceCompare.hpp"
#include <list>
#include <boost/shared_ptr.hpp>
#include "std_queue.hpp"
#include "std_map.hpp"
#include <boost/chrono.hpp>
namespace Enigma
{
class DllExport OpenALAudioDevice : public IAudioDevice
{
private:
bool mIsLoaded;
std::priority_queue<SoundSource> mSoundSources;
std::priority_queue<SoundSource> mVoiceChatSources;
std::map<boost::uuids::uuid,SoundSource> mAllocatedSources;
ALCdevice* mDevice;
ALCcontext* mContext;
//recording
ALCdevice* mCaptureDevice;
ALCbyte* mDefaultCaptureDevice;
ALint mAvailableSamples;
ALint mBitsPerSample;
ALint mChannels;
ALint mBlockAlign;
ClientTransmissionManager& mClientTransmissionManager;
protected:
void GenerateSources();
void CheckForOpenALError(bool nothrow,const Enigma::c8* functionName);
public:
OpenALAudioDevice(ClientTransmissionManager& clientTransmissionManager);
~OpenALAudioDevice();
virtual void Preinit();
virtual void Init(int argc, Enigma::c8** argv);
virtual void Load();
virtual void Unload();
virtual void Poll();
virtual void Capture();
//playback
virtual void StreamAtLocation(const Enigma::Entity& entity, Enigma::u8* buffer,int priority,size_t encodedSize);
virtual void StreamVoiceAtLocation(const Enigma::Entity& entity, Enigma::u8* buffer,size_t encodedSize);
virtual void PlayAtLocation(const Enigma::Entity& entity,const std::string& filename,int priority);
virtual void PlayAtLocation(const Enigma::Entity& entity,Enigma::c8* filename,int priority);
virtual void PlayAtLocation(const Enigma::Entity& entity,const Enigma::c8* filename,int priority);
virtual void UpdateListenerValues(const Enigma::Entity& entity);
//recording
virtual void StartRecording();
virtual void StopRecording();
bool CaptureAudio();
};
};
#endif // OPENALAUDIODEVICE_HPP_INCLUDED
| [
"[email protected]"
]
| [
[
[
1,
94
]
]
]
|
460e029be3fd10b925dd36788c939ed239b5dd8f | b83c990328347a0a2130716fd99788c49c29621e | /include/boost/random/uniform_int.hpp | add52e1914ede1a62900d2515eb2de259e195a76 | []
| no_license | SpliFF/mingwlibs | c6249fbb13abd74ee9c16e0a049c88b27bd357cf | 12d1369c9c1c2cc342f66c51d045b95c811ff90c | refs/heads/master | 2021-01-18T03:51:51.198506 | 2010-06-13T15:13:20 | 2010-06-13T15:13:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,100 | hpp | /* boost random/uniform_int.hpp header file
*
* Copyright Jens Maurer 2000-2001
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
* $Id: uniform_int.hpp 52492 2009-04-19 14:55:57Z steven_watanabe $
*
* Revision history
* 2001-04-08 added min<max assertion (N. Becker)
* 2001-02-18 moved to individual header files
*/
#ifndef BOOST_RANDOM_UNIFORM_INT_HPP
#define BOOST_RANDOM_UNIFORM_INT_HPP
#include <cassert>
#include <iostream>
#include <boost/config.hpp>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/random/uniform_smallint.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/detail/signed_unsigned_tools.hpp>
#include <boost/type_traits/make_unsigned.hpp>
#ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
#include <boost/type_traits/is_float.hpp>
#endif
namespace boost {
// uniform integer distribution on [min, max]
template<class IntType = int>
class uniform_int
{
public:
typedef IntType input_type;
typedef IntType result_type;
typedef typename make_unsigned<result_type>::type range_type;
explicit uniform_int(IntType min_arg = 0, IntType max_arg = 9)
: _min(min_arg), _max(max_arg)
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
// MSVC fails BOOST_STATIC_ASSERT with std::numeric_limits at class scope
BOOST_STATIC_ASSERT(std::numeric_limits<IntType>::is_integer);
#endif
assert(min_arg <= max_arg);
init();
}
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _min; }
result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _max; }
void reset() { }
// can't have member function templates out-of-line due to MSVC bugs
template<class Engine>
result_type operator()(Engine& eng)
{
return generate(eng, _min, _max, _range);
}
template<class Engine>
result_type operator()(Engine& eng, result_type n)
{
assert(n > 0);
if (n == 1)
{
return 0;
}
return generate(eng, 0, n - 1, n - 1);
}
#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
template<class CharT, class Traits>
friend std::basic_ostream<CharT,Traits>&
operator<<(std::basic_ostream<CharT,Traits>& os, const uniform_int& ud)
{
os << ud._min << " " << ud._max;
return os;
}
template<class CharT, class Traits>
friend std::basic_istream<CharT,Traits>&
operator>>(std::basic_istream<CharT,Traits>& is, uniform_int& ud)
{
is >> std::ws >> ud._min >> std::ws >> ud._max;
ud.init();
return is;
}
#endif
private:
template<class Engine>
static result_type generate(Engine& eng, result_type min_value, result_type max_value, range_type range)
{
typedef typename Engine::result_type base_result;
// ranges are always unsigned
typedef typename make_unsigned<base_result>::type base_unsigned;
const base_result bmin = (eng.min)();
const base_unsigned brange =
random::detail::subtract<base_result>()((eng.max)(), (eng.min)());
if(range == 0) {
return min_value;
} else if(brange == range) {
// this will probably never happen in real life
// basically nothing to do; just take care we don't overflow / underflow
base_unsigned v = random::detail::subtract<base_result>()(eng(), bmin);
return random::detail::add<base_unsigned, result_type>()(v, min_value);
} else if(brange < range) {
// use rejection method to handle things like 0..3 --> 0..4
for(;;) {
// concatenate several invocations of the base RNG
// take extra care to avoid overflows
range_type limit;
if(range == (std::numeric_limits<range_type>::max)()) {
limit = range/(range_type(brange)+1);
if(range % range_type(brange)+1 == range_type(brange))
++limit;
} else {
limit = (range+1)/(range_type(brange)+1);
}
// We consider "result" as expressed to base (brange+1):
// For every power of (brange+1), we determine a random factor
range_type result = range_type(0);
range_type mult = range_type(1);
while(mult <= limit) {
result += random::detail::subtract<base_result>()(eng(), bmin) * mult;
mult *= range_type(brange)+range_type(1);
}
if(mult == limit)
// range+1 is an integer power of brange+1: no rejections required
return result;
// range/mult < brange+1 -> no endless loop
result += uniform_int<range_type>(0, range/mult)(eng) * mult;
if(result <= range)
return random::detail::add<range_type, result_type>()(result, min_value);
}
} else { // brange > range
if(brange / range > 4 /* quantization_cutoff */ ) {
// the new range is vastly smaller than the source range,
// so quantization effects are not relevant
return boost::uniform_smallint<result_type>(min_value, max_value)(eng);
} else {
// use rejection method to handle cases like 0..5 -> 0..4
for(;;) {
base_unsigned result =
random::detail::subtract<base_result>()(eng(), bmin);
// result and range are non-negative, and result is possibly larger
// than range, so the cast is safe
if(result <= static_cast<base_unsigned>(range))
return random::detail::add<base_unsigned, result_type>()(result, min_value);
}
}
}
}
void init()
{
_range = random::detail::subtract<result_type>()(_max, _min);
}
// The result_type may be signed or unsigned, but the _range is always
// unsigned.
result_type _min, _max;
range_type _range;
};
} // namespace boost
#endif // BOOST_RANDOM_UNIFORM_INT_HPP
| [
"[email protected]"
]
| [
[
[
1,
178
]
]
]
|
faf8a1b85c51adbee705212460b3a6f9b30ff1b6 | df5277b77ad258cc5d3da348b5986294b055a2be | /Spaceships/Game.cpp | 3a2f53b93c6bb74c2dc24091ee8b60f217074794 | []
| no_license | beentaken/cs260-last2 | 147eaeb1ab15d03c57ad7fdc5db2d4e0824c0c22 | 61b2f84d565cc94a0283cc14c40fb52189ec1ba5 | refs/heads/master | 2021-03-20T16:27:10.552333 | 2010-04-26T00:47:13 | 2010-04-26T00:47:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,387 | cpp | #include "precompiled.h"
#include "Game.h"
using namespace std;
extern MessageHandler* G_globalMessageHandler;
Game::Game(Screen* screen, DXFactory* factory)
{
//default to main menu
internalState = GameState::MainMenu;
_screen = screen;
for(int i = 0; i < GameStateCount; i++){
this->_controllers[i] = NULL;
this->_handlers[i] = NULL;
}
this->_factory = factory;
}
Game::~Game(void)
{
}
void Game::AddController(Controller* c, GameState g){
_controllers[g] = c;
}
bool Game::changeState(GameState newState){
internalState = newState;
return true;
}
GameState Game::getState(){
return internalState;
}
void Game::AddView(View* v){
this->_currentView = v;
}
int Game::InitGameLoop(){
DWORD lastTickCount;
DWORD currentTickCount;
lastTickCount = GetTickCount();
list<Message*> temp;
while(1){
//TODO: you'll need to route messages that the user created to the network somehow
Message* msg = _handlers[internalState]->GetNextMessage();
//TODO: you'll need to get the messages from the network somehow so that they can be
//passed to the controller for handling.
//get every message and pass it into our temporary list for processing.
//this will free up our list to receive more input if it needs to. not
//terribly important for directinput but the wndproc is event driven so this
//is critical
while(msg != NULL)
{
if(msg->GetMessageType() == MessageType::USER_INPUT){
if(msg->GetMessageContent() == (GameAction)GameAction::QUIT)
{
delete msg;
return 0;
}
else
{
_controllers[internalState]->PassMessage(msg);
}
}
msg = _handlers[internalState]->GetNextMessage();
}
//tell the controller to process all the messages you just aggregated for it
// this->_controllers[internalState]->HandleMessages(&temp);
//initialize drawing the screen
_screen->GetBackBuffer();
//tell the game to update its state and draw
//imagine if this were a switch statement on internalState. If we added a new state,
//would this code have to change (hint: no)
GameState gs = this->_controllers[internalState]->Update();
//tell the screen to flip the back buffer
_screen->UpdateScreen();
//change state if needed
if(internalState != gs)
{
internalState = gs;
}
if(gs == GameState::Quit)
return 0;
//lock timing
currentTickCount = GetTickCount();
int diff = currentTickCount - lastTickCount;
int singelframetime = 1000 / FRAMERATE;
if(diff < singelframetime){
Sleep(singelframetime - diff);
}
lastTickCount = currentTickCount;
}
}
//no way to get the handler except with a static call. This is like a singleton.
//probably the global used to store the handler could be removed
MessageHandler* Game::GetWindProcHandler(void){
if(G_globalMessageHandler == NULL)
G_globalMessageHandler = new KeyboardHandler();
return G_globalMessageHandler;
}
//add a handler for a particular game state. If you add a new game state,
//you'll need to ensure that a handler is registered for it. You may need to
//mess with these so that handlers know about the network somehow
void Game::RegisterMessageHandler(GameState g, MessageHandler* handler){
this->_handlers[g] = handler;
}
| [
"ProstheticMind43@af704e40-745a-32bd-e5ce-d8b418a3b9ef"
]
| [
[
[
1,
136
]
]
]
|
18549afb0819e54f64894e863fd6c4b9bfddb0c9 | 36bf908bb8423598bda91bd63c4bcbc02db67a9d | /Include/CAudioVolume.h | 15b123991d45b5d2f2d0e4e6665e9de48e2aa4f0 | []
| no_license | code4bones/crawlpaper | edbae18a8b099814a1eed5453607a2d66142b496 | f218be1947a9791b2438b438362bc66c0a505f99 | refs/heads/master | 2021-01-10T13:11:23.176481 | 2011-04-14T11:04:17 | 2011-04-14T11:04:17 | 44,686,513 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,169 | h | /*
CAudioVolume.h
Classe per l'impostazione del volume.
Luca Piergentili, 22/08/03
[email protected]
*/
#ifndef _CAUDIOVOLUME_H
#define _CAUDIOVOLUME_H 1
#include "window.h"
/*
CAudioVolume
*/
class CAudioVolume : public CWnd
{
public:
CAudioVolume();
virtual ~CAudioVolume();
inline void SetStep (long lValue) {if(lValue >= m_lMinLevel && lValue <= m_lMaxLevel) m_lStepValue = lValue;}
inline long GetStep (void) const {return(m_lStepValue);}
BOOL Increase (long lValue = -1L);
BOOL Decrease (long lValue = -1L);
protected:
void OnDestroy (void);
LRESULT OnMixerControlChange (WPARAM wParam,LPARAM lParam);
private:
BOOL mixerInitialize (void);
BOOL mixerUninitialize (void);
BOOL mixerGetMasterVolumeControl (void);
BOOL mixerGetMasterVolumeValue (long &lValue);
BOOL mixerSetMasterVolumeValue (long lValue);
UINT m_nMixersCount;
HMIXER m_hMixer;
MIXERCAPS m_stMixerCaps;
long m_lLevel;
long m_lMinLevel;
long m_lMaxLevel;
long m_lStepValue;
DWORD m_dwVolumeControlID;
DECLARE_MESSAGE_MAP()
};
#endif // _CAUDIOVOLUME_H
| [
"[email protected]"
]
| [
[
[
1,
50
]
]
]
|
568c6ae1c89c357888439db8eae5915a9243e188 | 3d7fc34309dae695a17e693741a07cbf7ee26d6a | /aluminizerFPGA/shared/src/HFS.cpp | ee4d232f4cef592b008ad073a0c44c79a3cc7ba5 | [
"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 | 6,833 | cpp | #ifndef NO_HFS
#include "fractions.h"
#include "physics.h"
#include "HFS.h"
#include "string_func.h"
#include <iomanip>
#include <tnt.h>
#include <jama_eig.h>
using namespace std;
using namespace TNT;
using namespace JAMA;
using namespace physics;
using namespace numerics;
const double HFS::m_nuc = 1.66053886e-27; // nuclear mass (1 u)
const double HFS::BohrMagneton = 1.39962458e6; // Hz per Gauss
const double HFS::NuclearMagneton = 7.62259371e2; // Hz per Gauss
HFS::HFS(const string& element_name, double mass, double F, double I, double J,
int L, double S, double gJ, double gF, double muI) :
gF(gF), gJ(gJ), gI(0), mass(mass), F(F), I(I), J(J), S(S), L(L), Bfield(0),
TwoF(static_cast<int>(2*F)),
TwoI(static_cast<int>(2*I)),
TwoJ(static_cast<int>(2*J)),
TwoS(static_cast<int>(2*S))
{
//all spins need to be integer or half-integer
assert(TwoF == floor(2*F));
assert(TwoI == floor(2*I));
assert(TwoJ == floor(2*J));
assert(TwoS == floor(2*S));
//electronic g-factor
double gL = 1 - m_e/mass;
//calculate gJ unless gJ is provided
if(J != 0 && gJ == 0)
this->gJ = gL * ( J*(J + 1) + L*(L + 1) - S*(S + 1) ) / ( 2*J*(J + 1) ) +
gS * ( J*(J + 1) - L*(L + 1) + S*(S + 1) ) / ( 2*J*(J + 1) );
//nuclear g-factor
if(I != 0)
this->gI = muI;
//calculate gF unless gF is provided
if ( F != 0 && gF == 0)
{
double g1 = this->gJ * ( ( F*(F+1) + J*(J + 1) - I*(I+1) ) / ( 2*F*(F + 1) ) );
double g2 = ( ( F*(F+1) + I*(I + 1) - J*(J+1) ) / ( 2*F*(F + 1) ) );
this->gF = g1 + this->gI * (NuclearMagneton / BohrMagneton) * g2;
}
ostringstream oss;
oss << element_name << " " << (TwoS + 1) << this->L.symbol() << fraction_txt(J) << "(F=" << fraction_txt(F) << ")";
name = oss.str();
}
// returns linear Magnetic field shift of specified level in Hz/G
double HFS::sublevel(double mF, double B)
{
return mF * BohrMagneton * gF * B;
}
void HFS::PrintSublevels(ostream& o, double B)
{
for(double mF = -F; mF <= F; ++mF)
{
o << GetName() << " mF = " << setw(3) << mF << " : ";
o << setw(14) << to_string<double>(sublevel(mF, B), 3) << " Hz" << endl;
}
}
HFS_BreitRabi::HFS_BreitRabi(const HFS& hfs, double Ahfs, double Bhfs) :
HFS(hfs),
Ahfs(Ahfs),
Bhfs(Bhfs),
EVhfs0(new Array1D<double>((TwoJ+1)*(TwoI+1), 0.)),
EVhfs(new Array1D<double>((TwoJ+1)*(TwoI+1), 0.)),
HFSHamiltonian(new Array2D<double>((TwoJ+1)*(TwoI+1), (TwoJ+1)*(TwoI+1), 0.))
{
//zero field eigenvalues
GenerateHFSHamiltonian(0.0);
Eigenvalue<double> eig0(*HFSHamiltonian);
eig0.getRealEigenvalues(*EVhfs0);
SortEigenValues(EVhfs0, 0);
*EVhfs = *EVhfs0;
}
HFS_BreitRabi::~HFS_BreitRabi()
{
delete HFSHamiltonian;
delete EVhfs0;
delete EVhfs;
}
// generate HFS Hamiltonian in Hz
// Bz: Mag. field in G
// I use |I J m_I m_J> basis
void HFS_BreitRabi::GenerateHFSHamiltonian(double Bz)
{
// electronic coupling constant
double ecc=gJ*Bz*BohrMagneton;
// nuclear coupling constant
double ncc=gI*Bz*NuclearMagneton;
// HFS coupling constant
double IJshort=J*(J+1)+I*(I+1);
double AHFScc=Ahfs/2;
double AHFSdiagterm = AHFScc*IJshort;
// QP HFS coupling constant
double BHFScc = 0;
if ( I>1/2. && J>1/2. ) // term vanishes for I<=1/2 or J<=1/2
BHFScc=3/8.*Bhfs /( I*(2*I-1)*J*(2*J-1) );
double BHFSdiagterm = -4/3.*BHFScc*( I*(I+1)*J*(J+1) );
int nJ=TwoJ+1; // # of J components
int nI=TwoI+1; // # of I components
//zero out HFSHamiltonian
for(int i = 0; i < HFSHamiltonian->dim1(); i++)
for(int j = 0; j < HFSHamiltonian->dim2(); j++)
(*HFSHamiltonian)[i][j] = 0;
// setup diagonal (I_z, J_z, I^2, J^2) part
// matrix index: ii+nI*jj
for ( int mi=0; mi<nI; ++mi )
{
for ( int mj=0; mj<nJ; ++mj )
{
(*HFSHamiltonian)[mi+nI*mj][mi+nI*mj]=ecc*(mj-J)+ncc*(mi-I) - AHFSdiagterm - BHFSdiagterm;
}
}
// setup off-diagonal (F^2) matrix elements
double CGKtrans = 0;
double K = 0;
for ( int mi1=0; mi1<nI; ++mi1 )
{
for ( int mj1=0; mj1<nJ; ++mj1 )
{
for ( int mi2=0; mi2<nI; ++mi2 )
{
//speed up by only evaluating non-zero terms
//CGKtrans is only non-zero if mi1 + mj1 == mi2 + mj2
int mj2 = mi1 + mj1 - mi2;
if( (mj2 >= 0) && (mj2 < nJ) )
{
//CGKtrans is only non-zero if mf == mi1 + mj1 - I - J
double mf = mj1 + mi1 - I - J;
for ( double F=std::max( abs(I-J), abs(mf) ); F<=I+J; ++F )
{
CGKtrans = CGK(J, mj1-J, I, mi1-I, F, mf)*CGK(J, mj2-J, I, mi2-I, F, mf);
K = F*(F+1) - IJshort;
(*HFSHamiltonian)[mi1+nI*mj1][mi2+nI*mj2] += AHFScc*(F*(F+1))*CGKtrans + BHFScc * K*(K+1) * CGKtrans;
}
}
}
}
}
}
//order eigenvalues (does only sorting now; could be more sophisticated)
void HFS_BreitRabi::SortEigenValues(Array1D<double>* ev, double /*B*/) const
{
for ( int i = 0; i < ev->dim(); ++i )
for ( int j = i; j < ev->dim(); ++j )
{
// if(B >= 0)
{
if ( (*ev)[j] > (*ev)[i] )
{
swap((*ev)[i], (*ev)[j]);
}
}
/* else
{
if ( (*ev)[j] < (*ev)[i] )
{
swap((*ev)[i], (*ev)[j]);
}
}
*/
}
}
// calculate level shift [Hz] in magnetic field [G]
// problem: eigenvalues are sorted by size, so if there is a level crossing
// the state-labelling algorithm fails!
double HFS_BreitRabi::sublevel(double mF, double B)
{
if(J == 0)
return HFS::sublevel(mF, B);
//only recalculate if the magnetic field has changed
if(B != Bfield)
{
Bfield = B;
// get Bz=Magneticfield level energy
GenerateHFSHamiltonian(B);
Eigenvalue<double> eig(*HFSHamiltonian);
eig.getRealEigenvalues(*EVhfs);
SortEigenValues(EVhfs, B);
}
// find our F manifold
int Findex = 0;
// count all mF sublevels in the lower F manifolds
for ( double iF=abs(I-J); iF<F; ++iF )
Findex += static_cast<int>(2*iF+1);
// now count inside the current F manfold
int mFindex=(gF<0)?static_cast<int>(F+mF):static_cast<int>(F-mF);
// A<0: F states are ordered with decreasing energy
if ( Ahfs>0 )
Findex = HFSHamiltonian->dim1() - (Findex+TwoF+1);
int index = Findex + mFindex;
return (*EVhfs)[index] - (*EVhfs0)[index];
}
#endif //NO_HFS
| [
"trosen@814e38a0-0077-4020-8740-4f49b76d3b44"
]
| [
[
[
1,
237
]
]
]
|
62e402d76e554118a96b7fc6155f55fc11301c17 | 5dc6c87a7e6459ef8e832774faa4b5ae4363da99 | /vis_avs/r_water.cpp | 91080c9f6b3a76b4f657c8f605997d0948565705 | []
| no_license | aidinabedi/avs4unity | 407603d2fc44bc8b075b54cd0a808250582ee077 | 9b6327db1d092218e96d8907bd14d68b741dcc4d | refs/heads/master | 2021-01-20T15:27:32.449282 | 2010-12-24T03:28:09 | 2010-12-24T03:28:09 | 90,773,183 | 5 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 13,159 | cpp | /*
LICENSE
-------
Copyright 2005 Nullsoft, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Nullsoft nor the names of its contributors may be used to
endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h"
// alphachannel safe 11/21/99
#include <windows.h>
#include <commctrl.h>
#include "r_defs.h"
#include "resource.h"
#include "timing.h"
#ifndef LASER
#define C_THISCLASS C_WaterClass
#define MOD_NAME "Trans / Water"
class C_THISCLASS : public C_RBASE2 {
protected:
public:
C_THISCLASS();
virtual ~C_THISCLASS();
virtual int render(char visdata[2][2][SAMPLES], int isBeat, int *framebuffer, int *fbout, int w, int h);
virtual char *get_desc() { return MOD_NAME; }
virtual HWND conf(HINSTANCE hInstance, HWND hwndParent);
virtual void load_config(unsigned char *data, int len);
virtual int save_config(unsigned char *data);
virtual int smp_getflags() { return 1; }
virtual int smp_begin(int max_threads, char visdata[2][2][SAMPLES], int isBeat, int *framebuffer, int *fbout, int w, int h);
virtual void smp_render(int this_thread, int max_threads, char visdata[2][2][SAMPLES], int isBeat, int *framebuffer, int *fbout, int w, int h);
virtual int smp_finish(char visdata[2][2][SAMPLES], int isBeat, int *framebuffer, int *fbout, int w, int h); // return value is that of render() for fbstuff etc
unsigned int *lastframe;
int lastframe_len;
int enabled;
};
#define PUT_INT(y) data[pos]=(y)&255; data[pos+1]=(y>>8)&255; data[pos+2]=(y>>16)&255; data[pos+3]=(y>>24)&255
#define GET_INT() (data[pos]|(data[pos+1]<<8)|(data[pos+2]<<16)|(data[pos+3]<<24))
void C_THISCLASS::load_config(unsigned char *data, int len)
{
int pos=0;
if (len-pos >= 4) { enabled=GET_INT(); pos+=4; }
}
int C_THISCLASS::save_config(unsigned char *data)
{
int pos=0;
PUT_INT(enabled); pos+=4;
return pos;
}
C_THISCLASS::C_THISCLASS()
{
enabled=1;
lastframe_len=0;
lastframe=NULL;
}
C_THISCLASS::~C_THISCLASS()
{
if (lastframe) GlobalFree(lastframe);
}
#define _R(x) (( x ) & 0xff)
#define _G(x) ((( x )) & 0xff00)
#define _B(x) ((( x )) & 0xff0000)
#define _RGB(r,g,b) (( r ) | (( g ) & 0xff00) | (( b ) & 0xff0000))
static const int zero=0;
int C_THISCLASS::render(char visdata[2][2][SAMPLES], int isBeat, int *framebuffer, int *fbout, int w, int h)
{
smp_begin(1,visdata,isBeat,framebuffer,fbout,w,h);
if (isBeat & 0x80000000) return 0;
smp_render(0,1,visdata,isBeat,framebuffer,fbout,w,h);
return smp_finish(visdata,isBeat,framebuffer,fbout,w,h);
}
int C_THISCLASS::smp_begin(int max_threads, char visdata[2][2][SAMPLES], int isBeat, int *framebuffer, int *fbout, int w, int h)
{
if (!enabled) return 0;
if (!lastframe || w*h != lastframe_len)
{
if (lastframe) GlobalFree(lastframe);
lastframe_len=w*h;
lastframe=(unsigned int *)GlobalAlloc(GPTR,w*h*sizeof(int));
}
return max_threads;
}
int C_THISCLASS::smp_finish(char visdata[2][2][SAMPLES], int isBeat, int *framebuffer, int *fbout, int w, int h) // return value is that of render() for fbstuff etc
{
return !!enabled;
}
void C_THISCLASS::smp_render(int this_thread, int max_threads, char visdata[2][2][SAMPLES], int isBeat, int *framebuffer, int *fbout, int w, int h)
{
if (!enabled) return;
unsigned int *f = (unsigned int *) framebuffer;
unsigned int *of = (unsigned int *) fbout;
unsigned int *lfo = (unsigned int *) lastframe;
int start_l = ( this_thread * h ) / max_threads;
int end_l;
if (this_thread >= max_threads - 1) end_l = h;
else end_l = ( (this_thread+1) * h ) / max_threads;
int outh=end_l-start_l;
if (outh<1) return;
int skip_pix=start_l*w;
f += skip_pix;
of+= skip_pix;
lfo += skip_pix;
int at_top=0, at_bottom=0;
if (!this_thread) at_top=1;
if (this_thread >= max_threads - 1) at_bottom=1;
timingEnter(0);
{
if (at_top)
// top line
{
int x;
// left edge
{
int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]);
r += _R(f[w]); g += _G(f[w]); b += _B(f[w]);
f++;
r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
lfo++;
if (r < 0) r=0;
else if (r > 255) r=255;
if (g < 0) g=0;
else if (g > 255*256) g=255*256;
if (b < 0) b=0;
else if (b > 255*65536) b=255*65536;
*of++=_RGB(r,g,b);
}
// middle of line
x=(w-2);
while (x--)
{
int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]);
r += _R(f[-1]); g += _G(f[-1]); b += _B(f[-1]);
r += _R(f[w]); g += _G(f[w]); b += _B(f[w]);
f++;
r/=2; g/=2; b/=2;
r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
lfo++;
if (r < 0) r=0;
else if (r > 255) r=255;
if (g < 0) g=0;
else if (g > 255*256) g=255*256;
if (b < 0) b=0;
else if (b > 255*65536) b=255*65536;
*of++=_RGB(r,g,b);
}
// right block
{
int r=_R(f[-1]); int g=_G(f[-1]); int b=_B(f[-1]);
r += _R(f[w]); g += _G(f[w]); b += _B(f[w]);
f++;
r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
lfo++;
if (r < 0) r=0;
else if (r > 255) r=255;
if (g < 0) g=0;
else if (g > 255*256) g=255*256;
if (b < 0) b=0;
else if (b > 255*65536) b=255*65536;
*of++=_RGB(r,g,b);
}
}
// middle block
{
int y=outh-at_top-at_bottom;
while (y--)
{
int x;
// left edge
{
int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]);
r += _R(f[w]); g += _G(f[w]); b += _B(f[w]);
r += _R(f[-w]); g += _G(f[-w]); b += _B(f[-w]);
f++;
r/=2; g/=2; b/=2;
r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
lfo++;
if (r < 0) r=0;
else if (r > 255) r=255;
if (g < 0) g=0;
else if (g > 255*256) g=255*256;
if (b < 0) b=0;
else if (b > 255*65536) b=255*65536;
*of++=_RGB(r,g,b);
}
// middle of line
x=(w-2);
#ifdef NO_MMX
while (x--)
{
int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]);
r += _R(f[-1]); g += _G(f[-1]); b += _B(f[-1]);
r += _R(f[w]); g += _G(f[w]); b += _B(f[w]);
r += _R(f[-w]); g += _G(f[-w]); b += _B(f[-w]);
f++;
r/=2; g/=2; b/=2;
r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
lfo++;
if (r < 0) r=0;
else if (r > 255) r=255;
if (g < 0) g=0;
else if (g > 255*256) g=255*256;
if (b < 0) b=0;
else if (b > 255*65536) b=255*65536;
*of++=_RGB(r,g,b);
}
#else
__asm
{
mov esi, f
mov edi, of
mov edx, lfo
mov ecx, x
mov ebx, w
shl ebx, 2
shr ecx, 1
sub esi, ebx
align 16
mmx_water_loop1:
movd mm0, [esi+ebx+4]
movd mm1, [esi+ebx-4]
punpcklbw mm0, [zero]
movd mm2, [esi+ebx*2]
punpcklbw mm1, [zero]
movd mm3, [esi]
punpcklbw mm2, [zero]
movd mm4, [edx]
paddw mm0, mm1
punpcklbw mm3, [zero]
movd mm7, [esi+ebx+8]
punpcklbw mm4, [zero]
paddw mm2, mm3
movd mm6, [esi+ebx]
paddw mm0, mm2
psrlw mm0, 1
punpcklbw mm7, [zero]
movd mm2, [esi+ebx*2+4]
psubw mm0, mm4
movd mm3, [esi+4]
packuswb mm0, mm0
movd [edi], mm0
punpcklbw mm6, [zero]
movd mm4, [edx+4]
punpcklbw mm2, [zero]
paddw mm7, mm6
punpcklbw mm3, [zero]
punpcklbw mm4, [zero]
paddw mm2, mm3
paddw mm7, mm2
add edx, 8
psrlw mm7, 1
add esi, 8
psubw mm7, mm4
packuswb mm7, mm7
movd [edi+4], mm7
add edi, 8
dec ecx
jnz mmx_water_loop1
add esi, ebx
mov f, esi
mov of, edi
mov lfo, edx
};
#endif
// right block
{
int r=_R(f[-1]); int g=_G(f[-1]); int b=_B(f[-1]);
r += _R(f[w]); g += _G(f[w]); b += _B(f[w]);
r += _R(f[-w]); g += _G(f[-w]); b += _B(f[-w]);
f++;
r/=2; g/=2; b/=2;
r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
lfo++;
if (r < 0) r=0;
else if (r > 255) r=255;
if (g < 0) g=0;
else if (g > 255*256) g=255*256;
if (b < 0) b=0;
else if (b > 255*65536) b=255*65536;
*of++=_RGB(r,g,b);
}
}
}
// bottom line
if (at_bottom)
{
int x;
// left edge
{
int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]);
r += _R(f[-w]); g += _G(f[-w]); b += _B(f[-w]);
f++;
r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
lfo++;
if (r < 0) r=0;
else if (r > 255) r=255;
if (g < 0) g=0;
else if (g > 255*256) g=255*256;
if (b < 0) b=0;
else if (b > 255*65536) b=255*65536;
*of++=_RGB(r,g,b);
}
// middle of line
x=(w-2);
while (x--)
{
int r=_R(f[1]); int g=_G(f[1]); int b=_B(f[1]);
r += _R(f[-1]); g += _G(f[-1]); b += _B(f[-1]);
r += _R(f[-w]); g += _G(f[-w]); b += _B(f[-w]);
f++;
r/=2; g/=2; b/=2;
r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
lfo++;
if (r < 0) r=0;
else if (r > 255) r=255;
if (g < 0) g=0;
else if (g > 255*256) g=255*256;
if (b < 0) b=0;
else if (b > 255*65536) b=255*65536;
*of++=_RGB(r,g,b);
}
// right block
{
int r=_R(f[-1]); int g=_G(f[-1]); int b=_B(f[-1]);
r += _R(f[-w]); g += _G(f[-w]); b += _B(f[-w]);
f++;
r-=_R(lfo[0]); g-=_G(lfo[0]); b-=_B(lfo[0]);
lfo++;
if (r < 0) r=0;
else if (r > 255) r=255;
if (g < 0) g=0;
else if (g > 255*256) g=255*256;
if (b < 0) b=0;
else if (b > 255*65536) b=255*65536;
*of++=_RGB(r,g,b);
}
}
}
memcpy(lastframe+skip_pix,framebuffer+skip_pix,w*outh*sizeof(int));
#ifndef NO_MMX
__asm emms;
#endif
timingLeave(0);
}
C_RBASE *R_Water(char *desc)
{
if (desc) { strcpy(desc,MOD_NAME); return NULL; }
return (C_RBASE *) new C_THISCLASS();
}
static C_THISCLASS *g_this;
static BOOL CALLBACK g_DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
if (g_this->enabled) CheckDlgButton(hwndDlg,IDC_CHECK1,BST_CHECKED);
return 1;
case WM_COMMAND:
if (LOWORD(wParam) == IDC_CHECK1)
{
if (IsDlgButtonChecked(hwndDlg,IDC_CHECK1))
g_this->enabled=1;
else
g_this->enabled=0;
}
return 0;
}
return 0;
}
HWND C_THISCLASS::conf(HINSTANCE hInstance, HWND hwndParent)
{
g_this = this;
return CreateDialog(hInstance,MAKEINTRESOURCE(IDD_CFG_WATER),hwndParent,g_DlgProc);
}
#else
C_RBASE *R_Water(char *desc) { return NULL; }
#endif | [
"[email protected]"
]
| [
[
[
1,
499
]
]
]
|
9b7b25189a90e28dce93b8ad4c31e326704e2430 | 7ec5d0bfb47aec6748ab8d2f69126e406aa4bed0 | /gv_Main.h | fda3916fec5799a8649c4550b606aba256ea6d3c | []
| no_license | john-smith-git/gpsview | 693f4bc2b1a6bef7cb29a1bcfde9b52d241b7680 | a356460bc5a0a21a2a372fc09e94e32740734ff9 | refs/heads/master | 2020-04-17T03:40:33.220608 | 2008-02-13T21:06:22 | 2008-02-13T21:06:22 | 34,434,306 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,001 | h | #ifndef __MAIN_FORM
#define __MAIN_FORM
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "HCFGStorage.h"
#include "HExcept.h"
#include "HLog.h"
#include "HMenus.h"
#include "XPMenu.hpp"
#include <Dialogs.hpp>
#include <Menus.hpp>
#include "HWindow.h"
#include "TB97Ctls.hpp"
class TMainForm : public TForm {
__published:
HMainMenu *MainMenu;
TMenuItem *F1;
TMenuItem *mnuLoad;
TMenuItem *mnuClear;
TMenuItem *mnuConfig;
TMenuItem *N5;
TMenuItem *mnuSaveCfg;
TMenuItem *mnuExit;
HExceptionDialog *HExceptionDialog1;
HCfgStorage *cfg;
HLogComboBox *cbLog;
TMenuItem *N1;
TXPMenu *XPMenu1;
TOpenDialog *open;
TSaveDialog *save;
TMenuItem *Window1;
TMenuItem *mnuNewWindow;
TMenuItem *Hide1;
TMenuItem *N8;
TMenuItem *ArrangeAll1;
TMenuItem *Cascade1;
TMenuItem *Tile1;
TMenuItem *N2;
TMenuItem *T1;
TMenuItem *G1;
TMenuItem *N3;
TMenuItem *Previous1;
HWindow *wndFilter;
TLabel *Label2;
TLabel *Label3;
TToolbarButton97 *btnRefilter;
TLabel *Label4;
TLabel *Label5;
TLabel *Label6;
TLabel *Label7;
TLabel *Label8;
TEdit *edtDOPMin;
TCheckBox *chMove;
TEdit *edtMoveDiff;
TCheckBox *chMaxSpeedInc;
TEdit *edtMaxSpeedInc;
TCheckBox *chMaxPrevDiff;
TEdit *edtMovePrevDiff;
TMenuItem *P1;
void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose);
void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
void __fastcall mnuExitClick(TObject *Sender);
void __fastcall mnuSaveCfgClick(TObject *Sender);
void __fastcall mnuConfigClick(TObject *Sender);
void __fastcall mnuLoadClick(TObject *Sender);
void __fastcall T1Click(TObject *Sender);
void __fastcall Tile1Click(TObject *Sender);
void __fastcall Cascade1Click(TObject *Sender);
void __fastcall N3Click(TObject *Sender);
void __fastcall Previous1Click(TObject *Sender);
void __fastcall ArrangeAll1Click(TObject *Sender);
void __fastcall Hide1Click(TObject *Sender);
void __fastcall mnuClearClick(TObject *Sender);
void __fastcall G1Click(TObject *Sender);
void __fastcall btnRefilterClick(TObject *Sender);
void __fastcall P1Click(TObject *Sender);
private:
bool idOnUnknownCommand( CONSTSTR s );
bool idOnCommandParceError( CONSTSTR s );
bool idOnNoCRC( CONSTSTR s );
bool idOnCRCError( CONSTSTR s );
public:
__fastcall TMainForm(TComponent* Owner);
bool LoadNMEAFile( CONSTSTR fnm );
void LoadCfg( void );
void SaveCfg( TObject *Sender /*=NULL*/ );
};
#endif
| [
"[email protected]@9808890e-0f46-0410-a4b9-f53f42733e87"
]
| [
[
[
1,
95
]
]
]
|
d433abaeffee54c528fecc978e01c46e0936ddfa | fbe2cbeb947664ba278ba30ce713810676a2c412 | /iptv_root/iptv_media3/VideoDecoder.h | f422e5e6ed663b386cfa444bbdbded2de1b4abdf | []
| no_license | abhipr1/multitv | 0b3b863bfb61b83c30053b15688b070d4149ca0b | 6a93bf9122ddbcc1971dead3ab3be8faea5e53d8 | refs/heads/master | 2020-12-24T15:13:44.511555 | 2009-06-04T17:11:02 | 2009-06-04T17:11:02 | 41,107,043 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,979 | h | #ifndef VIDEO_DECODER_H
#define VIDEO_DECODER_H
#include "Codec.h"
#include "DemuxedMediaType.h"
#include "global_error.h"
class VideoDecoder : public Decoder, public IMediaVideo
{
protected:
bool m_keyFrameFound;
unsigned m_uDecodedFrameLen,
m_uOutputFrameLen;
PixelFormat m_outputPixFmt;
unsigned char * m_pDecodedFrameBuf;
AVFrame * m_pDecodedFrame,
* m_pOutputFrame;
unsigned InitBuffers();
virtual unsigned ConvertToOutputFmt(AVPicture *_pDecodedFrame, unsigned char *_pDstBuf, unsigned &_uDstBufLen);
public:
VideoDecoder(unsigned char _type) : Decoder(_type)
{
m_outputPixFmt = PIX_FMT_RGB24;
m_uDecodedFrameLen = 0;
m_uOutputFrameLen = 0;
m_pDecodedFrameBuf = NULL;
m_pDecodedFrame = NULL;
m_pOutputFrame = NULL;
m_keyFrameFound = false;
}
virtual ~VideoDecoder()
{
if (m_pDecodedFrameBuf)
delete m_pDecodedFrameBuf;
if (m_pDecodedFrame)
av_free(m_pDecodedFrame);
if (m_pOutputFrame)
av_free(m_pOutputFrame);
}
virtual unsigned Init();
virtual unsigned Decode(unsigned char *_pBufIn,
unsigned _bufInLen,
unsigned char *_pBufOut,
unsigned & _bufOutLen,
void *_pHeaderData);
// IMediaVideo implementation
virtual unsigned GetWidth();
virtual unsigned GetHeight();
virtual unsigned GetFrameSize();
virtual double GetFramerate();
};
class ASFVideoDecoder : public VideoDecoder
{
public:
ASFVideoDecoder(AVCodecContext *_pCodecCtx) : VideoDecoder(ASF_DEMUXED_VIDEO)
{
m_pCodecCtx = _pCodecCtx;
}
~ASFVideoDecoder() {}
virtual unsigned Init();
// virtual unsigned Decode();
};
#endif
| [
"heineck@c016ff2c-3db2-11de-a81c-fde7d73ceb89"
]
| [
[
[
1,
89
]
]
]
|
35f1e0e7a5d52246c27fa4515eac783a0e62e4be | 9a48be80edc7692df4918c0222a1640545384dbb | /Libraries/Boost1.40/libs/wave/samples/waveidl/idllexer/idl_lex_iterator.hpp | a57f6c152a993c94e304afc8c30fb0453de2f2a8 | [
"BSL-1.0"
]
| permissive | fcrick/RepSnapper | 05e4fb1157f634acad575fffa2029f7f655b7940 | a5809843f37b7162f19765e852b968648b33b694 | refs/heads/master | 2021-01-17T21:42:29.537504 | 2010-06-07T05:38:05 | 2010-06-07T05:38:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,723 | hpp | /*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Sample: Re2C based IDL lexer
Definition of the lexer iterator
http://www.boost.org/
Copyright (c) 2001-2009 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(IDL_LEX_ITERATOR_HPP_7926F865_E02F_4950_9EB5_5F453C9FF953_INCLUDED)
#define IDL_LEX_ITERATOR_HPP_7926F865_E02F_4950_9EB5_5F453C9FF953_INCLUDED
#include <string>
#include <iostream>
#include <boost/assert.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/spirit/include/classic_multi_pass.hpp>
#include <boost/wave/language_support.hpp>
#include <boost/wave/util/file_position.hpp>
#include <boost/wave/util/functor_input.hpp>
#include "idl_lex_interface.hpp"
#if 0 != __COMO_VERSION__
#define BOOST_WAVE_EOF_PREFIX static
#else
#define BOOST_WAVE_EOF_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace idllexer {
namespace impl {
///////////////////////////////////////////////////////////////////////////////
//
// lex_iterator_functor_shim
//
///////////////////////////////////////////////////////////////////////////////
template <typename TokenT>
class lex_iterator_functor_shim
{
typedef lex_input_interface_generator<TokenT> lex_input_interface_type;
public:
template <typename IteratorT>
lex_iterator_functor_shim(IteratorT const &first, IteratorT const &last,
typename TokenT::position_type const &pos,
boost::wave::language_support language)
: functor_ptr(lex_input_interface_type::new_lexer(first, last, pos, language))
{}
// interface to the boost::spirit::classic::multi_pass_policies::functor_input
// policy
typedef TokenT result_type;
BOOST_WAVE_EOF_PREFIX result_type const eof;
result_type operator()()
{
BOOST_ASSERT(0 != functor_ptr.get());
return functor_ptr->get();
}
void set_position(typename TokenT::position_type const &pos)
{
BOOST_ASSERT(0 != functor_ptr.get());
functor_ptr->set_position(pos);
}
private:
boost::shared_ptr<cpplexer::lex_input_interface<TokenT> > functor_ptr;
};
#if 0 != __COMO_VERSION__
///////////////////////////////////////////////////////////////////////////////
// eof token
template <typename LexT>
typename lex_iterator_functor_shim<LexT>::result_type const
lex_iterator_functor_shim<LexT>::eof;
#endif // 0 != __COMO_VERSION__
///////////////////////////////////////////////////////////////////////////////
} // namespace impl
///////////////////////////////////////////////////////////////////////////////
//
// lex_iterator
//
// A generic C++ lexer interface class, which allows to plug in different
// lexer implementations (template parameter LexT). The following
// requirement apply:
//
// - the lexer type should have a function implemented, which returnes
// the next lexed token from the input stream:
// typename LexT::token_type get();
// - at the end of the input stream this function should return the
// eof token equivalent
// - the lexer should implement a constructor taking two iterators
// pointing to the beginning and the end of the input stream and
// a third parameter containing the name of the parsed input file
//
///////////////////////////////////////////////////////////////////////////////
template <typename TokenT>
class lex_iterator
: public boost::spirit::classic::multi_pass<
impl::lex_iterator_functor_shim<TokenT>,
boost::wave::util::functor_input
>
{
typedef impl::lex_iterator_functor_shim<TokenT> input_policy_type;
typedef
boost::spirit::classic::multi_pass<input_policy_type,
boost::wave::util::functor_input>
base_type;
typedef lex_iterator<TokenT> self_type;
public:
typedef TokenT token_type;
lex_iterator()
{}
template <typename IteratorT>
lex_iterator(IteratorT const &first, IteratorT const &last,
typename TokenT::position_type const &pos,
boost::wave::language_support language)
: base_type(input_policy_type(first, last, pos, language))
{}
void set_position(typename TokenT::position_type const &pos)
{
typedef typename TokenT::position_type position_type;
// set the new position in the current token
position_type currpos = base_type::get_input().get_position();
currpos.set_file(pos.get_file());
currpos.set_line(pos.get_line());
base_type::get_input().set_position(currpos);
// set the new position for future tokens as well
base_type::get_functor().set_position(pos);
}
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
// this sample does no include guard detection
bool has_include_guards(std::string&) const { return false; }
#endif
};
///////////////////////////////////////////////////////////////////////////////
} // namespace idllexer
} // namespace wave
} // namespace boost
#endif // !defined(IDL_LEX_ITERATOR_HPP_7926F865_E02F_4950_9EB5_5F453C9FF953_INCLUDED)
| [
"metrix@Blended.(none)"
]
| [
[
[
1,
164
]
]
]
|
1f671ab33c37be7d1cef8e9f9d9a569525019d1c | e74686db481febc3e0e1d21b42cae5975ddb0c6a | /src/jservice/javaService.cpp | 558766191b4d4a25135ef94573eb209f40ea001c | []
| no_license | sorcersoft/startnow | f8642969009abda75911b49c9bff3e7772234306 | 3d5d7258c4f0acaa5aa39a226ff37d2dd3005278 | refs/heads/master | 2021-01-21T12:23:09.994860 | 2008-07-30T17:18:28 | 2008-07-30T17:18:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,709 | cpp | //////////////////////////////////////////////////////////////////////////////
//// javaService.cpp
//////////////////////////////////////////////////////////////////////////////
#include <windows.h>
#include <stdio.h>
#include "jservice.h"
#include "JvmServices.h"
#include "JvmAppArgs.h"
JvmServices* jvmProvider;
static HANDLE jThreadHandle;
extern "C" {
extern char *PROPERTIES;
};
char *CLASSNAME;
VOID serviceStart( char *jvmdllpath, char *classname, DWORD dwArgc, LPTSTR *lpszArgv, char **jvmargs, int jvmargcnt, int minvm, int maxvm ) {
JvmAppArgs* svc_args;
static char *args[2];
reportNewStatus (SERVICE_START_PENDING,0,0);
CLASSNAME = strdup( classname );
jvmProvider = new JvmServices();
if( jvmProvider->startJvm(jvmdllpath, minvm, maxvm,jvmargs, jvmargcnt ) == 0 ) {
long err = GetLastError();
AddToMessageLog( 2, TEXT("JVM startup failed") );
reportNewStatus( SERVICE_STOPPED, ERROR_SERVICE_SPECIFIC_ERROR, err );
return;
}
//printf("getting jvmappargs\n");
svc_args = new JvmAppArgs();
//printf("we'll be running %s\n", CLASSNAME );
svc_args->setClass(CLASSNAME);
svc_args->setJvmService(jvmProvider);
// if( dwArgc == 0 ) {
// dwArgc = 1;
// lpszArgv = args;
// args[0] = PROPERTIES;
// args[1] = NULL;
// }
// (*(char*)0) = 0;
svc_args->setArgList( dwArgc, lpszArgv );
reportNewStatus(SERVICE_RUNNING,0,0);
//printf( "starting application\n");
jThreadHandle = (HANDLE)jvmProvider->startApp(svc_args);
//printf( "Waiting for service to stop: HANDLE=%08lx\n", jThreadHandle );
// Wait for thread to exit
DWORD status;
while( GetExitCodeThread( jThreadHandle, &status ) && status == STILL_ACTIVE )
WaitForSingleObject(jThreadHandle, INFINITE);
printf( "returned status was: (STILL_ACTIVE=%d) %d\n", STILL_ACTIVE, status );
//printf( "Service stopped\n" );
reportNewStatus(SERVICE_STOPPED,ERROR_SERVICE_SPECIFIC_ERROR,11);
}
//// If a stopService procedure is going to take longer than
//// 3 seconds to execute, it should spawn a thread to
//// execute the stop code, and return. Otherwise, the
//// ServiceControlManager will believe that the service has
//// stopped responding
VOID serviceStop(){
reportNewStatus (SERVICE_STOP_PENDING,0,0);
JNIEnv* env;
JDK1_1AttachArgs* t_args;
JavaVM* jvm = jvmProvider->getJvm();
jvm->AttachCurrentThread((void**)&env, &t_args);
jclass jserviceClz = env->FindClass(CLASSNAME);
jmethodID mid = env->GetStaticMethodID(jserviceClz,
"cleanup", "()V");
if (mid != 0)
env->CallStaticVoidMethod(jserviceClz, mid, NULL);
jvm->DetachCurrentThread();
CloseHandle(jThreadHandle);
reportNewStatus(SERVICE_STOPPED,0,0);
}
| [
"greggwon@a6ea22c0-cb08-eb36-ae63-d3d4202a734f"
]
| [
[
[
1,
93
]
]
]
|
fe6f20ebc8a0c8e0a2a889ab1837ad33a7ad4b8f | db26d73e7b3cb449ced2d7516f6dc47497640c78 | /MenuExtFirst/IGMenuEx.cpp | 13dc0814cdc65d455de4f2ff84661d4051bbcdde | []
| no_license | camark/protouch | 64f48e7b17185bcdd6734690f68f1191430d9f53 | 72b4c7b5ec588f3dfa496c819513bd669bb2c3d9 | refs/heads/master | 2021-01-01T06:44:51.757274 | 2008-04-07T01:45:38 | 2008-04-07T01:45:38 | 32,129,231 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 113 | cpp | // IGMenuEx.cpp : Implementation of CIGMenuEx
#include "stdafx.h"
#include "IGMenuEx.h"
// CIGMenuEx
| [
"gm8pleasure@846b6f15-f049-0410-af6c-15f16ab86fe9"
]
| [
[
[
1,
8
]
]
]
|
ed5478cbb3b8bdb851b01f86004f64786d701fd9 | 07f0b2dcc8370ab0adfe9bf2abebcaffdd1d618c | /suffix/Edge.cpp | f32a20aad5e2ca2b0122468593fe47c427ce0fa8 | []
| no_license | piotrjan01/pwaalproject | e01f7956e2e2acb3722215695b05371bc328b809 | dd81bd128c6073c3eb29efbf902edde74c4d8138 | refs/heads/master | 2020-04-17T06:07:51.173243 | 2010-01-12T18:20:20 | 2010-01-12T18:20:20 | 33,796,679 | 0 | 0 | null | null | null | null | WINDOWS-1250 | C++ | false | false | 2,734 | cpp | /*
* Edge.cpp
*
* Implementacja klasy opisanej w pliku nagłówkowym
*
* Created on: 2010-01-07
* Author: Piotr Gwizdała
*/
#include "Edge.h"
#include <sstream>
Edge::Edge(int startIndex, int endIndex, Node *startNode) {
this->startInd = startIndex;
this->endInd = endIndex;
this->startN = startNode;
this->endN = new Node(startNode->tree, NULL, this);
this->insertToParentEdgeList();
}
Edge::~Edge() {
}
Node* Edge::split(Suffix *s) {
//usunięcie tej krawędzi z węzła-ojca
this->removeFromParentEdgeList();
//utworzenie nowej krawędzi zgodnie z dodawanym sufiksem (niejawnie powstaje nowy węzeł - liść)
Edge* ne = new Edge(this->startInd, this->startInd + s->getPhraseLength(), s->originNode);
//ustawienie wskaźnika na następny mniejszy sufiks w drzewie
ne->endN->suffixNode = s->originNode;
//wycięcie starego początku tekstu (teraz jest on na nowej krawędzi) i dodanie nowego znaku
this->startInd += s->getPhraseLength() + 1;
//podpięcie tej krawędzi na koniec nowopowstałej krawędzi
this->startN = ne->endN;
this->insertToParentEdgeList();
//Zwracany jest nowy węzeł
return ne->endN;
}
void Edge::insertToParentEdgeList() {
this->startN->addEdge(this->startInd, this);
}
void Edge::removeFromParentEdgeList() {
this->startN->removeEdge(this->startInd);
}
int Edge::getPhraseLength() {
return this->endInd - this->startInd;
}
int Edge::getFullSuffixLength() {
int mtl = startN->tree->text.length();
int realEnd = (this->endInd < 0 ? mtl : this->endInd);
if (realEnd > mtl) realEnd = mtl-1;
int tt = realEnd - startInd+1;
int pt = 0;
if (startN->parentEdge != NULL) pt = startN->parentEdge->getFullSuffixLength();
return pt+tt;
}
string Edge::getEdgeText() {
string text = startN->tree->text;
int realEnd = (this->endInd < 0 ? text.length() : this->endInd);
if (realEnd > (int)text.length()) realEnd = text.length()-1;
text = text.substr(this->startInd, realEnd - this->startInd +1);
return text;
}
string Edge::getEdgeFullText() {
string tt = getEdgeText();
string pt;
if (startN->parentEdge != NULL) pt = startN->parentEdge->getEdgeFullText();
return pt+tt;
}
string Edge::toString() {
stringstream ss;
string text = startN->tree->text;
int realEnd = (this->endInd < 0 ? text.length() : this->endInd);
if (realEnd > (int)text.length()) realEnd = text.length()-1;
text = text.substr(this->startInd, realEnd - this->startInd +1);
ss<<startInd<<"\t"<<realEnd<<"\t";
ss<<this->startN->toString()<<"\t"<<this->endN->toString()<<"\t"<<text;
return ss.str();
}
| [
"gwizdek@ff063b32-fc41-11de-b5bc-ffd2847a4b57"
]
| [
[
[
1,
98
]
]
]
|
753ee04abee30554118a716e29c8ce60e638ff36 | 6a925ad6f969afc636a340b1820feb8983fc049b | /librtsp/librtsp/src/util.cpp | 39025d62105efcacedd5f37a0f0505582fa3d75e | []
| no_license | dulton/librtsp | c1ac298daecd8f8008f7ab1c2ffa915bdbb710ad | 8ab300dc678dc05085f6926f016b32746c28aec3 | refs/heads/master | 2021-05-29T14:59:37.037583 | 2010-05-30T04:07:28 | 2010-05-30T04:07:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 522 | cpp |
#ifdef _DEBUG
#include "util.h"
#include <cstring>
#include <cstdarg>
void Utility::realdprintf( char const * file, int lineno, char const *fmt, ... )
{
char buf[256];
::memset(buf, 0, sizeof(char) * 256);
va_list vl;
va_start(vl, fmt);
vsnprintf(buf, 256, fmt, vl);
va_end(vl);
std::string filepath(file);
std::string filename = filepath.substr(filepath.rfind('/')+1,filepath.length());
fprintf(stdout, "%s (%s,%d)\n", buf, filename.c_str(), lineno);
}
#endif
| [
"TangWentaoHust@95ff1050-1aa1-11de-b6aa-3535bc3264a2"
]
| [
[
[
1,
21
]
]
]
|
93e5f9f8e2e17ff8cf3129211a93d2823c54b4a5 | 89d2197ed4531892f005d7ee3804774202b1cb8d | /GWEN/include/Gwen/Controls/VerticalSlider.h | f82a8cc67b6f466dc162855c55f0532c02f58132 | [
"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 | 674 | h | /*
GWEN
Copyright (c) 2010 Facepunch Studios
See license in Gwen.h
*/
#pragma once
#include "Gwen/Controls/Base.h"
#include "Gwen/Controls/Button.h"
#include "Gwen/Controls/Dragger.h"
#include "Gwen/Gwen.h"
#include "Gwen/Skin.h"
#include "Gwen/Controls/Slider.h"
namespace Gwen
{
namespace Controls
{
class GWEN_EXPORT VerticalSlider : public Slider
{
GWEN_CONTROL( VerticalSlider, Slider );
virtual void Layout(Skin::Base* skin);
virtual void Render(Skin::Base* skin);
virtual float CalculateValue();
virtual void UpdateBarFromValue();
virtual void OnMouseClickLeft( int x, int y, bool bDown );
};
}
} | [
"haza55@5bf3a77f-ad06-ad18-b9fb-7d0f6dabd793"
]
| [
[
[
1,
34
]
]
]
|
c310fa9d2b831e7719a20e432d2e500b93dce886 | 969a039a5499a68272539ace39a441844a1b5554 | /VirtualKeyboard/TraceObj.cpp | 0dd93e56c7cdaccdcb0effc5547ac35c3d024aca | []
| no_license | coolboy/qvirtual-keyboard | 5c2533be66ac02425600e119062c09901a6b9e63 | 4057056ab7952e21fa206cceb434b454be56d0ec | refs/heads/master | 2021-01-18T14:38:36.362242 | 2011-02-01T00:14:24 | 2011-02-01T00:14:24 | 32,131,754 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 42 | cpp | #include "StdAfx.h"
#include "TraceObj.h" | [
"[email protected]@30274b60-42cb-7143-5b13-851e6f7d0551"
]
| [
[
[
1,
2
]
]
]
|
1fbecc4dd8d8e5e68a97092811cd5f172b4f0c0e | 90e6fe719db2668fe7d11ec2cfb8425a48bb4d79 | /main.cpp | 0044fbb7349b78306306a9d9d84bac7f225ef513 | []
| no_license | Aquajet/yuv_noise | 5fcfa64e218d1c9c41c524872498ffd2205712e1 | 2e99ee575d741ec64a71182e8463654189775b43 | refs/heads/master | 2021-01-18T21:29:52.641358 | 2011-07-26T15:54:37 | 2011-07-26T15:54:37 | 2,106,436 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 278 | cpp | #include <QtGui/QApplication>
#include "mainwindow.h"
#include "Console.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MessageOutput::setMessageOutputToGlobalConsole();
MainWindow w;
w.showMaximized();
return a.exec();
} | [
"[email protected]"
]
| [
[
[
1,
16
]
]
]
|
c8f624666b08ca3385bdf68be9e3ffa7ca1ef85e | 1c9f99b2b2e3835038aba7ec0abc3a228e24a558 | /Projects/elastix/elastix_sources_v4/src/Components/Transforms/DeformationFieldTransform/itkDeformationFieldInterpolatingTransform.h | 26d72890499b3c2d6b8145e1388ea6e4598bda44 | []
| no_license | mijc/Diploma | 95fa1b04801ba9afb6493b24b53383d0fbd00b33 | bae131ed74f1b344b219c0ffe0fffcd90306aeb8 | refs/heads/master | 2021-01-18T13:57:42.223466 | 2011-02-15T14:19:49 | 2011-02-15T14:19:49 | 1,369,569 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,911 | h | /*======================================================================
This file is part of the elastix software.
Copyright (c) University Medical Center Utrecht. All rights reserved.
See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
======================================================================*/
#ifndef __itkDeformationFieldInterpolatingTransform_h
#define __itkDeformationFieldInterpolatingTransform_h
#include <iostream>
#include "itkAdvancedTransform.h"
#include "itkExceptionObject.h"
#include "itkImage.h"
#include "itkVectorInterpolateImageFunction.h"
#include "itkVectorNearestNeighborInterpolateImageFunction.h"
namespace itk
{
/** \brief Transform that interpolates a given deformation field
*
* A simple transform that allows the user to set a deformation field.
* TransformPoint adds the displacement to the input point.
* This transform does not support optimizers. Its Set/GetParameters
* is not implemented.
* You may set your own interpolator!
*
* \ingroup Transforms
*/
template <
class TScalarType=double, // Data type for scalars (float or double)
unsigned int NDimensions=3, // Number of input dimensions
class TComponentType=double> // ComponentType of the deformation field
class DeformationFieldInterpolatingTransform :
public AdvancedTransform< TScalarType, NDimensions, NDimensions >
{
public:
/** Standard class typedefs. */
typedef DeformationFieldInterpolatingTransform Self;
typedef AdvancedTransform< TScalarType, NDimensions, NDimensions > Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
/** New macro for creation of through the object factory.*/
itkNewMacro( Self );
/** Run-time type information (and related methods). */
itkTypeMacro( DeformationFieldInterpolatingTransform, AdvancedTransform );
/** Dimension of the domain spaces. */
itkStaticConstMacro(InputSpaceDimension, unsigned int, Superclass::InputSpaceDimension);
itkStaticConstMacro(OutputSpaceDimension, unsigned int, Superclass::OutputSpaceDimension);
/** Superclass typedefs */
typedef typename Superclass::ScalarType ScalarType;
typedef typename Superclass::ParametersType ParametersType;
typedef typename Superclass::JacobianType JacobianType;
typedef typename Superclass::InputVectorType InputVectorType;
typedef typename Superclass::OutputVectorType OutputVectorType;
typedef typename Superclass::InputCovariantVectorType InputCovariantVectorType;
typedef typename Superclass::OutputCovariantVectorType OutputCovariantVectorType;
typedef typename Superclass::InputVnlVectorType InputVnlVectorType;
typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType;
typedef typename Superclass::InputPointType InputPointType;
typedef typename Superclass::OutputPointType OutputPointType;
typedef TComponentType DeformationFieldComponentType;
typedef Vector<DeformationFieldComponentType,
itkGetStaticConstMacro(OutputSpaceDimension) > DeformationFieldVectorType;
typedef Image< DeformationFieldVectorType,
itkGetStaticConstMacro(InputSpaceDimension) > DeformationFieldType;
typedef VectorInterpolateImageFunction<
DeformationFieldType, ScalarType >
DeformationFieldInterpolatorType;
typedef VectorNearestNeighborInterpolateImageFunction<
DeformationFieldType, ScalarType >
DefaultDeformationFieldInterpolatorType;
/** Transform a point
* This method adds a displacement to a given point,
* returning the transformed point */
OutputPointType TransformPoint(const InputPointType &point ) const;
/** Make this an identity transform ( the deformation field is replaced
* by a zero deformation field */
void SetIdentity(void);
/** Set/Get the deformation field that defines the displacements */
virtual void SetDeformationField( DeformationFieldType * _arg );
itkGetObjectMacro(DeformationField, DeformationFieldType);
/** Set/Get the deformation field interpolator */
virtual void SetDeformationFieldInterpolator( DeformationFieldInterpolatorType * _arg );
itkGetObjectMacro(DeformationFieldInterpolator, DeformationFieldInterpolatorType);
virtual bool IsLinear( void ) const { return false; };
protected:
DeformationFieldInterpolatingTransform();
~DeformationFieldInterpolatingTransform();
/** Typedef which is used internally */
typedef typename DeformationFieldInterpolatorType::ContinuousIndexType
InputContinuousIndexType;
typedef typename DeformationFieldInterpolatorType::OutputType InterpolatorOutputType;
/** Print contents of an DeformationFieldInterpolatingTransform. */
void PrintSelf(std::ostream &os, Indent indent) const;
typename DeformationFieldType::Pointer m_DeformationField;
typename DeformationFieldType::Pointer m_ZeroDeformationField;
typename DeformationFieldInterpolatorType::Pointer m_DeformationFieldInterpolator;
private:
DeformationFieldInterpolatingTransform(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
}; //class DeformationFieldInterpolatingTransform
} // namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkDeformationFieldInterpolatingTransform.txx"
#endif
#endif /* __itkDeformationFieldInterpolatingTransform_h */
| [
"[email protected]"
]
| [
[
[
1,
141
]
]
]
|
4bbd4600fb1762d7dba5799d3e00b176f501fd39 | 79636d9a11c4ac53811d55ef0f432f68ab62944f | /smart-darkgdk/include/CommonBSPCollider.cpp | 2b4744929cc3116f9f56f8890d9529854d72f72a | [
"MIT"
]
| permissive | endel/smart-darkgdk | 44d90a1afcd71deebef65f47dc54586df4ae4736 | 6235288b8aab505577223f9544a6e5a7eb6bf6cd | refs/heads/master | 2021-01-19T10:58:29.387767 | 2009-06-26T16:44:15 | 2009-06-26T16:44:15 | 32,123,434 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 157 | cpp | #include "CommonBSPCollider.h"
CommonBSPCollider::CommonBSPCollider(void)
:collisionIndex(0)
{
}
CommonBSPCollider::~CommonBSPCollider(void)
{
}
| [
"endel.dreyer@0995f060-2c81-11de-ae9b-2be1a451ffb1"
]
| [
[
[
1,
10
]
]
]
|
c07e87cee2b91547df70dd0e45ad1e75af629175 | 0f40e36dc65b58cc3c04022cf215c77ae31965a8 | /src/apps/vis/elements/vis_drawable_edge_estimated.cpp | d6c8fafa8ac2360ef0d2239c3c1f8d23d4b3ab08 | [
"MIT",
"BSD-3-Clause"
]
| permissive | venkatarajasekhar/shawn-1 | 08e6cd4cf9f39a8962c1514aa17b294565e849f8 | d36c90dd88f8460e89731c873bb71fb97da85e82 | refs/heads/master | 2020-06-26T18:19:01.247491 | 2010-10-26T17:40:48 | 2010-10-26T17:40:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,711 | cpp | /************************************************************************
** This file is part of the network simulator Shawn. **
** Copyright (C) 2004,2005 by SwarmNet (www.swarmnet.de) **
** and SWARMS (www.swarms.de) **
** Shawn is free software; you can redistribute it and/or modify it **
** under the terms of the GNU General Public License, version 2. **
************************************************************************/
#include "../buildfiles/_apps_enable_cmake.h"
#ifdef ENABLE_VIS
#include "apps/vis/elements/vis_drawable_edge_estimated.h"
namespace vis
{
const std::string DrawableEdgeEstimated::PREFIX("estimated");
// ----------------------------------------------------------------------
DrawableEdgeEstimated::
DrawableEdgeEstimated( const shawn::Node& v1,
const DrawableNode& dv1,
const std::string& p )
: DrawableEdge( std::string("edge.") + p, v1, v1 ),
props_ ( NULL ),
src_drawable_ ( &dv1 )
{}
// ----------------------------------------------------------------------
DrawableEdgeEstimated::
~DrawableEdgeEstimated()
{}
// ----------------------------------------------------------------------
void
DrawableEdgeEstimated::
init( void )
throw()
{
props_ = new EdgePropertySet;
props_->init(*this);
DrawableEdge::init();
}
// ----------------------------------------------------------------------
void
DrawableEdgeEstimated::
draw( cairo_t* cr, double t, const Context& C )
const throw(std::runtime_error)
{
Drawable::draw(cr,t,C);
if( visible() )
{
shawn::Vec pos1 = src_drawable_->position(t);
const shawn::Vec pos2 = src_drawable_->node().est_position();
double lw = edge_properties().line_width(t);
shawn::Vec col = edge_properties().color(t);
double blend = edge_properties().blend(t);
cairo_save(cr);
cairo_set_line_width( cr, lw );
cairo_set_source_rgba(cr,col.x(),col.y(),col.z(),1.0-blend);
//blend_set_color(cr,col);
cairo_move_to(cr,pos1.x(),pos1.y());
cairo_line_to(cr,pos2.x(),pos2.y());
cairo_stroke(cr);
cairo_restore(cr);
}
}
// ----------------------------------------------------------------------
const PropertySet&
DrawableEdgeEstimated::
properties( void )
const throw()
{
assert( props_.is_not_null() );
return *props_;
}
// ----------------------------------------------------------------------
PropertySet&
DrawableEdgeEstimated::
properties_w( void )
throw()
{
assert( props_.is_not_null() );
return *props_;
}
}
#endif
/*-----------------------------------------------------------------------
* Source $Source: /cvs/shawn/shawn/tubsapps/vis/elements/vis_drawable_edge_default.cpp,v $
* Version $Revision: 1.4 $
* Date $Date: 2006/02/19 21:34:29 $
*-----------------------------------------------------------------------
* $Log: vis_drawable_edge_default.cpp,v $
* Revision 1.4 2006/02/19 21:34:29 ali
* *** empty log message ***
*
* Revision 1.3 2006/02/14 21:53:10 ali
* *** empty log message ***
*
* Revision 1.2 2006/02/05 20:22:35 ali
* more vis
*
* Revision 1.1 2006/02/04 20:19:46 ali
* *** empty log message ***
*
*-----------------------------------------------------------------------*/
| [
"[email protected]"
]
| [
[
[
1,
108
]
]
]
|
72eda3ad634d069b7922e0cbecb5e40bb6b70f33 | 63951c6e55d656454d9ad07cc5abf1b4a8ff1707 | /Rotozoomer3.h | cbc7583b0935f828c83e6434c47ef68c3a2046bb | [
"CC-BY-4.0",
"CC-BY-3.0"
]
| permissive | reaper2012/Rotozoomer | 07b8103141afc763410061428481e474dd7bb454 | cc19ef8bf94bd1a6a3a11a77f59482b32ba40e0d | refs/heads/master | 2021-01-22T23:53:56.747759 | 2011-06-13T02:37:08 | 2011-06-13T02:37:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 794 | h | #pragma once
#ifndef __AFXWIN_H__
#error "include 'stdafx.h' before including this file for PCH"
#endif
#include "resource.h"
#include "FPoint.h"
#include <vector>
#define PI (3.14159265)
// Idle time handler interface
class IIdleHandler {
public:
virtual BOOL OnIdle(LONG lCount) = 0;
};
class CRotozoomer3App : public CWinAppEx {
protected:
int ExitInstance();
public:
CRotozoomer3App();
UINT m_nAppLook;
BOOL m_bHiColorIcons;
std::vector<IIdleHandler *> IdleHandlers;
virtual BOOL InitInstance();
virtual void PreLoadState();
virtual void LoadCustomState();
virtual void SaveCustomState();
BOOL OnIdle(LONG lCount);
afx_msg void OnAppAbout();
DECLARE_MESSAGE_MAP()
};
extern CRotozoomer3App theApp;
| [
"[email protected]"
]
| [
[
[
1,
40
]
]
]
|
759e9726be59d6849513a7073ec103c03669a4ad | a51ac532423cf58c35682415c81aee8e8ae706ce | /MachineAPI/MachineRotateAbsoluteCommand.h | 0e389ac3db3bf5ec3e29d67387ae4d4aa9da6f51 | []
| no_license | anderslindmark/PickNPlace | b9a89fb2a6df839b2b010b35a0c873af436a1ab9 | 00ca4f6ce2ecfeddfea7db5cb7ae8e9d0023a5e1 | refs/heads/master | 2020-12-24T16:59:20.515351 | 2008-05-25T01:32:31 | 2008-05-25T01:32:31 | 34,914,321 | 1 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 900 | h | /**
\file MachineRotateAbsoluteCommand.h
\brief
Header file for the MachineInitCommand class
\author Henrik Mäkitaavola & Anders Lindmark
**/
#ifndef __MACHINEROTATEABSOLUTECOMMAND_H__
#define __MACHINEROTATEABSOLUTECOMMAND_H__
#include "machinecommand.h"
/// \class MachineRotateAbsoluteCommand
/// \brief Rotate the head on the Pick N Place machine to a specific angle
class MachineRotateAbsoluteCommand : public MachineCommand
{
MACHINE_COMMAND_FRIENDS;
public:
MachineRotateAbsoluteCommand(float angle);
~MachineRotateAbsoluteCommand(void);
MachineState GetAfterState(MachineState &oldms);
string ToString();
bool IsValid()
{
return true;
}
private:
MachineRotateAbsoluteCommand* Copy();
bool DoCommand(SerialPort &sp);
float m_angle; ///< The angle the head should be rotated to
};
#endif //__MACHINEROTATEABSOLUTECOMMAND_H__
| [
"henmak-4@f672c3ff-8b41-4f22-a4ab-2adcb4f732c7",
"anders@f672c3ff-8b41-4f22-a4ab-2adcb4f732c7"
]
| [
[
[
1,
13
],
[
16,
17
],
[
37,
37
]
],
[
[
14,
15
],
[
18,
36
],
[
38,
38
]
]
]
|
8df03914aa2da94b4e1f48848000348869b085a3 | 3bfc30f7a07ce0f6eabcd526e39ba1030d84c1f3 | /BlobbyWarriors/Source/BlobbyWarriors/UI/Sound/SoundManager.cpp | 584acd25b6e88b94e2256a207d44fbeccfa0cc5b | []
| no_license | visusnet/Blobby-Warriors | b0b70a0b4769b60d96424b55ad7c47b256e60061 | adec63056786e4e8dfcb1ed7f7fe8b09ce05399d | refs/heads/master | 2021-01-19T14:09:32.522480 | 2011-11-29T21:53:25 | 2011-11-29T21:53:25 | 2,850,563 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 528 | cpp | #include "SoundManager.h"
SoundManager* SoundManager::getInstance()
{
static Guard guard;
if(SoundManager::instance == 0) {
SoundManager::instance = new SoundManager();
}
return SoundManager::instance;
}
ISoundEngine* SoundManager::getEngine()
{
return this->engine;
}
SoundManager::SoundManager()
{
this->engine = createIrrKlangDevice();
if (!this->engine) {
debug("Could not start sound engine.");
}
}
SoundManager::~SoundManager()
{
}
SoundManager* SoundManager::instance = 0;
| [
"[email protected]"
]
| [
[
[
1,
30
]
]
]
|
2308fa852ebd091e78ee01a74e1476fbed3b70fa | 06a812828178249355ae08dd9ad5dc01ffdf7e23 | /prog3/longint.h | f3c97dff55f50fce51e93b6764084af1d7b370ec | []
| no_license | johntalton/cs220 | 6fbc5f8cb177475e3696e3d17eda2eb6d3a05a75 | 32ded5643cc6969d173fdaa7f50b2ee1a4abf929 | refs/heads/master | 2021-06-22T18:18:45.216713 | 1997-11-12T22:59:00 | 2017-08-15T23:09:30 | 100,425,946 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 667 | h | #ifndef LONGINT_H
#define LONGINT_H
#include <iostream.h>
#include "list.h"
#include "LIterator.h"
#define MAXLEN 1000
#define maxslice 10000
struct longintnode
{
int value;
longintnode(){};
void Init(int val) {value = val;};
};
class longint
{
friend longint operator*(const longint&, const longint&);
friend longint operator+(const longint&, const longint&);
friend ostream& operator <<(ostream& , const longint&);
friend istream& operator >>(istream& , longint&);
friend void printLongInt(ListIterator<longintnode> &Aiter);
public:
longint(){};
~longint(){};
private:
List <longintnode> lngint;
};
#endif | [
"[email protected]"
]
| [
[
[
1,
32
]
]
]
|
44f42a228f9e60c756363104e09c9c319532a7ea | 4891542ea31c89c0ab2377428e92cc72bd1d078f | /GameEditor/GameEditor.h | cc1af4303e8bd7740b35671524a6ad46fdf09b07 | []
| no_license | koutsop/arcanoid | aa32c46c407955a06c6d4efe34748e50c472eea8 | 5bfef14317e35751fa386d841f0f5fa2b8757fb4 | refs/heads/master | 2021-01-18T14:11:00.321215 | 2008-07-17T21:50:36 | 2008-07-17T21:50:36 | 33,115,792 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,459 | h | /*
*author: koutsop
*/
//TODO na dw na mporw na ala3w to static buffer pou exw edw kai pou ton
//xrisimopiw gia thn SwitchIn
#ifndef GAMEEDITOR_H
#define GAMEEDITOR_H
#include <map>
#include <string>
#include "Terrain.h"
#include "OkCancel.h"
#include "LoadData.h"
#include "StoreData.h"
#include "BricksFilm.h"
#include "InputManager.h"
using namespace std;
typedef map<string, BITMAP *>Map;
class GameEditor {
private:
Map bitmaps;
LoadData data;
BricksFilm bricks;
Terrain terrain;
InputManager inputManager;
OkCancel choice;
static bool areLoadData; //Elegxoume an exoun fwrto8ei ta dedomena
static BITMAP* terrainBackground;
////////////////////////////////// private functions
static void SwitchIn();
/* @target: Kanei init thn allegro kai to Map bitmaps
*/
void Init(void);
/* @target: Kanei load ta data apoto configure file
*/
void LoadData(void);
/* @target: Kanei load ta dedomena gia thn dimiourgeia tou terrain
*/
void LoadTerrainInfo(void);
/* @target: Kanei load ta blitmaps
*/
void LoadBitmaps(void);
/* @target: Kanei blit ta bitmaps
*/
void BlitBitmaps(void);
/* @target: Diagrafei ola ta bitmaps pou exoun dimiourgi8ei
*/
void Deinit(void);
public:
GameEditor(void);
~GameEditor(void);
/* @target: Na dimiourgei thn arxh enos neou game editor
*/
void StartEditor(void);
};
#endif GAMEEDITOR_H | [
"koutsop@5c4dd20e-9542-0410-abe3-ad2d610f3ba4"
]
| [
[
[
1,
73
]
]
]
|
3b724fb4d1ad8d5d6a2987bac061739edb5defc8 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/boost/typeof/msvc/typeof_impl.hpp | 4eb392013aea13f563211a9804dc467213bc6b80 | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,291 | hpp |
// Copyright (C) 2005 Igor Chesnokov, mailto:[email protected]
// Copyright (C) 2005 Peder Holt
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_TYPEOF_MSVC_TYPEOF_IMPL_HPP_INCLUDED
# define BOOST_TYPEOF_MSVC_TYPEOF_IMPL_HPP_INCLUDED
# include <boost/config.hpp>
# include <boost/detail/workaround.hpp>
# include <boost/mpl/int.hpp>
# include <boost/type_traits/is_function.hpp>
# include <boost/utility/enable_if.hpp>
namespace boost
{
namespace type_of
{
//Compile time constant code
# if BOOST_WORKAROUND(BOOST_MSVC,>=1300) && defined(_MSC_EXTENSIONS)
template<int N> struct the_counter;
template<typename T,int N = 5/*for similarity*/>
struct encode_counter
{
__if_exists(the_counter<N + 256>)
{
BOOST_STATIC_CONSTANT(unsigned,count=(encode_counter<T,N + 257>::count));
}
__if_not_exists(the_counter<N + 256>)
{
__if_exists(the_counter<N + 64>)
{
BOOST_STATIC_CONSTANT(unsigned,count=(encode_counter<T,N + 65>::count));
}
__if_not_exists(the_counter<N + 64>)
{
__if_exists(the_counter<N + 16>)
{
BOOST_STATIC_CONSTANT(unsigned,count=(encode_counter<T,N + 17>::count));
}
__if_not_exists(the_counter<N + 16>)
{
__if_exists(the_counter<N + 4>)
{
BOOST_STATIC_CONSTANT(unsigned,count=(encode_counter<T,N + 5>::count));
}
__if_not_exists(the_counter<N + 4>)
{
__if_exists(the_counter<N>)
{
BOOST_STATIC_CONSTANT(unsigned,count=(encode_counter<T,N + 1>::count));
}
__if_not_exists(the_counter<N>)
{
BOOST_STATIC_CONSTANT(unsigned,count=N);
typedef the_counter<N> type;
}
}
}
}
}
};
# define BOOST_TYPEOF_INDEX(T) (encode_counter<T>::count)
# define BOOST_TYPEOF_NEXT_INDEX(next)
# else
template<int N> struct encode_counter : encode_counter<N - 1> {};
template<> struct encode_counter<0> {};
//Need to default to a larger value than 4, as due to MSVC's ETI errors. (sizeof(int)==4)
char (*encode_index(...))[5];
# define BOOST_TYPEOF_INDEX(T) (sizeof(*boost::type_of::encode_index((boost::type_of::encode_counter<1005>*)0)))
# define BOOST_TYPEOF_NEXT_INDEX(next) friend char (*encode_index(encode_counter<next>*))[next];
# endif
//Typeof code
# if BOOST_WORKAROUND(BOOST_MSVC,==1300)
template<typename ID>
struct msvc_extract_type
{
template<bool>
struct id2type_impl;
typedef id2type_impl<true> id2type;
};
template<typename T, typename ID>
struct msvc_register_type : msvc_extract_type<ID>
{
template<>
struct id2type_impl<true> //VC7.0 specific bugfeature
{
typedef T type;
};
};
# else
template<typename ID>
struct msvc_extract_type
{
struct id2type;
};
template<typename T, typename ID>
struct msvc_register_type : msvc_extract_type<ID>
{
typedef msvc_extract_type<ID> base_type;
struct base_type::id2type // This uses nice VC6.5 and VC7.1 bugfeature
{
typedef T type;
};
};
# endif
template<int ID>
struct msvc_typeid_wrapper {
typedef typename msvc_extract_type<mpl::int_<ID> >::id2type id2type;
typedef typename id2type::type type;
};
//Workaround for ETI-bug for VC6 and VC7
template<>
struct msvc_typeid_wrapper<1> {
typedef msvc_typeid_wrapper<1> type;
};
//Workaround for ETI-bug for VC7.1
template<>
struct msvc_typeid_wrapper<4> {
typedef msvc_typeid_wrapper<4> type;
};
//Tie it all together
template<typename T>
struct encode_type
{
//Get the next available compile time constants index
BOOST_STATIC_CONSTANT(unsigned,value=BOOST_TYPEOF_INDEX(T));
//Instantiate the template
typedef typename msvc_register_type<T,mpl::int_<value> >::id2type type;
//Set the next compile time constants index
BOOST_STATIC_CONSTANT(unsigned,next=value+1);
//Increment the compile time constant (only needed when extensions are not active
BOOST_TYPEOF_NEXT_INDEX(next);
};
template<class T>
struct sizer
{
typedef char(*type)[encode_type<T>::value];
};
# ifdef BOOST_NO_SFINAE
template<typename T>
typename sizer<T>::type encode_start(T const&);
# else
template<typename T> typename disable_if<
typename is_function<T>::type,
typename sizer<T>::type>::type encode_start(T const&);
template<typename T> typename enable_if<
typename is_function<T>::type,
typename sizer<T>::type>::type encode_start(T&);
# endif
}
}
# define BOOST_TYPEOF(expr) \
boost::type_of::msvc_typeid_wrapper<sizeof(*boost::type_of::encode_start(expr))>::type
# define BOOST_TYPEOF_TPL(expr) typename BOOST_TYPEOF(expr)
# define BOOST_TYPEOF_NESTED_TYPEDEF_TPL(name,expr) \
struct name {\
template<typename T>\
static boost::type_of::msvc_register_type<T,name> _typeof_register_function(const T&);\
BOOST_STATIC_CONSTANT(int,_typeof_register_value=sizeof(_typeof_register_function(expr)));\
typedef typename boost::type_of::msvc_extract_type<name>::id2type id2type;\
typedef typename id2type::type type;\
};
# define BOOST_TYPEOF_NESTED_TYPEDEF(name,expr) \
struct name {\
template<typename T>\
static boost::type_of::msvc_register_type<T,name> _typeof_register_function(const T&);\
BOOST_STATIC_CONSTANT(int,_typeof_register_value=sizeof(_typeof_register_function(expr)));\
typedef boost::type_of::msvc_extract_type<name>::id2type id2type;\
typedef id2type::type type;\
};
#endif//BOOST_TYPEOF_MSVC_TYPEOF_IMPL_HPP_INCLUDED
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
198
]
]
]
|
276a909a3aebb483a74a66a9f6099db4a7735e1c | ce262ae496ab3eeebfcbb337da86d34eb689c07b | /SEFoundation/SEShaders/SEGeometryProgram.cpp | f12ec04635c3f4c2866d7b3592691f8deb23dc93 | []
| 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 | UTF-8 | C++ | false | false | 2,366 | 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 "SEFoundationPCH.h"
#include "SEGeometryProgram.h"
#include "SEGeometryProgramCatalog.h"
using namespace Swing;
SE_IMPLEMENT_RTTI(Swing, SEGeometryProgram, SEProgram);
SE_IMPLEMENT_STREAM(SEGeometryProgram);
SE_IMPLEMENT_DEFAULT_STREAM(SEGeometryProgram, SEProgram);
SE_IMPLEMENT_DEFAULT_NAME_ID(SEGeometryProgram, SEProgram);
//SE_REGISTER_STREAM(SEGeometryProgram);
//----------------------------------------------------------------------------
SEGeometryProgram* SEGeometryProgram::Load(SERenderer* pRenderer,
const std::string& rProgramName, const std::string& rKey,
SEInterfaceDescriptor* pInterfaceDesc)
{
SEGeometryProgram* pProgram = SE_NEW SEGeometryProgram;
bool bLoaded = SEProgram::Load(pRenderer, rProgramName, pProgram,
SEProgram::PT_GEOMETRY, pInterfaceDesc);
if( !bLoaded )
{
SE_DELETE pProgram;
return 0;
}
pProgram->SetName(rKey);
SEGeometryProgramCatalog::GetActive()->Insert(pProgram);
return pProgram;
}
//----------------------------------------------------------------------------
SEGeometryProgram::SEGeometryProgram()
{
}
//----------------------------------------------------------------------------
SEGeometryProgram::~SEGeometryProgram()
{
SEGeometryProgramCatalog::GetActive()->Remove(this);
}
//----------------------------------------------------------------------------
| [
"[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac"
]
| [
[
[
1,
63
]
]
]
|
9a24ac31b6da9dcf6ca842c36a12c7fb7f3bbbb2 | 34a68e61a469b94063bc98465557072897a9aa88 | /libraries/gameswf/gameswf_fontlib.h | 201966b2ad80c19ff491ba733696d229b0f32770 | []
| no_license | CneoC/shinzui | f83bfc9cbd9a05480d5323a21339d83e4d403dd9 | 5a2b79b430b207500766849bd58538e6a4aff2f8 | refs/heads/master | 2020-05-03T11:00:52.671613 | 2010-01-25T00:05:55 | 2010-01-25T00:05:55 | 377,430 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 990 | h | // gameswf_fontlib.h -- Thatcher Ulrich <[email protected]> 2003
// This source code has been donated to the Public Domain. Do
// whatever you want with it.
// Internal interfaces to fontlib.
#ifndef GAMESWF_FONTLIB_H
#define GAMESWF_FONTLIB_H
#include "gameswf/base/tu_config.h"
#include "base/container.h"
#include "gameswf/gameswf_types.h"
namespace gameswf
{
typedef hash<int, glyph_entity> glyph_array;
struct glyph_provider_tu : public glyph_provider
{
glyph_provider_tu();
~glyph_provider_tu();
virtual bitmap_info* get_char_image(character_def* shape_glyph, Uint16 code,
const tu_string& fontname, bool is_bold, bool is_italic, int fontsize,
rect* bounds, float* advance);
private:
stringi_hash< glyph_array* > m_glyph; // fontame-glyphs-glyph
};
} // end namespace gameswf
#endif // GAMESWF_FONTLIB_H
// Local Variables:
// mode: C++
// c-basic-offset: 8
// tab-width: 8
// indent-tabs-mode: t
// End:
| [
"[email protected]"
]
| [
[
[
1,
44
]
]
]
|
1ef3ac9c2e4ab56720727f23722f0f4f9998f118 | 6188f1aaaf5508e046cde6da16b56feb3d5914bc | /CamFighter/Graphics/D3D/d3d.h | 3ee387cf995b4a2ced653d06fa0a928a67c18ab1 | []
| 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 | 349 | h | #ifndef __incl_Graphics_D3D_d3d_h
#define __incl_Graphics_D3D_d3d_h
#ifdef USE_D3D
#include <d3d9.h>
#include <d3dx9.h>
// include the Direct3D Library file
#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")
namespace Graphics { namespace D3D {
extern LPDIRECT3DDEVICE9 d3ddev; // current d3d device
}}
#endif
#endif
| [
"darekmac@f75eed02-8a0f-11dd-b20b-83d96e936561"
]
| [
[
[
1,
20
]
]
]
|
1f1a169c3f521bd878c4fde19327e675a201def8 | d01196cdfc4451c4e1c88343bdb1eb4db9c5ac18 | /source/server/game/teamplay_gamerules.h | 529e22bd102618102750ce562d38651606a374e5 | []
| no_license | ferhan66h/Xash3D_ancient | 7491cd4ff1c7d0b48300029db24d7e08ba96e88a | 075e0a6dae12a0952065eb9b2954be4a8827c72f | refs/heads/master | 2021-12-10T07:55:29.592432 | 2010-05-09T00:00:00 | 2016-07-30T17:37:36 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,348 | h | /***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
//
// teamplay_gamerules.h
//
#define MAX_TEAMNAME_LENGTH 16
#define MAX_TEAMS 32
#define TEAMPLAY_TEAMLISTLENGTH MAX_TEAMS*MAX_TEAMNAME_LENGTH
class CHalfLifeTeamplay : public CHalfLifeMultiplay
{
public:
CHalfLifeTeamplay();
virtual BOOL ClientCommand( CBasePlayer *pPlayer, const char *pcmd );
virtual void ClientUserInfoChanged( CBasePlayer *pPlayer, char *infobuffer );
virtual BOOL IsTeamplay( void );
virtual BOOL FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker );
virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget );
virtual const char *GetTeamID( CBaseEntity *pEntity );
virtual BOOL ShouldAutoAim( CBasePlayer *pPlayer, edict_t *target );
virtual int IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled );
virtual void InitHUD( CBasePlayer *pl );
virtual void DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor );
virtual void UpdateGameMode( CBasePlayer *pPlayer ); // the client needs to be informed of the current game mode
virtual void PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor );
virtual void Think ( void );
virtual int GetTeamIndex( const char *pTeamName );
virtual const char *GetIndexedTeamName( int teamIndex );
virtual BOOL IsValidTeam( const char *pTeamName );
const char *SetDefaultPlayerTeam( CBasePlayer *pPlayer );
virtual void ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib );
private:
void RecountTeams( bool bResendInfo = FALSE );
const char *TeamWithFewestPlayers( void );
BOOL m_DisableDeathMessages;
BOOL m_DisableDeathPenalty;
BOOL m_teamLimit; // This means the server set only some teams as valid
char m_szTeamList[TEAMPLAY_TEAMLISTLENGTH];
};
| [
"[email protected]"
]
| [
[
[
1,
56
]
]
]
|
842b0d2f2ec98cbe5b784426e57f747081279fd1 | 31a5e7570148149f0f7d8626274c22e15454a71f | /Simcraft/Simcraft/sc_mmo_champion.cpp | ff298920481c9f33cc623a13919762d78ec66f91 | []
| no_license | imclab/SimcraftGearOptimizer | b54575e9fc330c97070168ade5bbd46a2de0627a | b5c1f82b2bf7579389d23b769e520a6b0968fc98 | refs/heads/master | 2021-01-22T13:37:15.010740 | 2010-05-04T00:46:44 | 2010-05-04T00:46:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,843 | cpp | // ==========================================================================
// Dedmonwakeen's Raid DPS/TPS Simulator.
// Send questions to [email protected]
// ==========================================================================
#include "simulationcraft.h"
#define RANGE_BITS 24
#define RANGE_HIGH ((1<<RANGE_BITS)-1)
#define RANGE_HIGH_MASK (0x3f<<(RANGE_BITS-6))
#define RANGE_LOW_MASK ((1<<(RANGE_BITS-6))-1)
static const char* base64 = "f-qR3eOHQ9dSIMwk8pabYt6yrJUFNXLTh4n2KWEoz0uC5j7xmAgDlZiPcs_BGV1v"; // sufficiently randomized 10+26+26+2 = 64
namespace // ANONYMOUS NAMESPACE ==========================================
{
// download_id ==============================================================
static xml_node_t* download_id( sim_t* sim,
const std::string& id_str,
int cache_only=0 )
{
if ( id_str.empty() || id_str == "" || id_str == "0" ) return 0;
std::string url = "http://db.mmo-champion.com/i/" + id_str + "/";
xml_node_t* node;
if ( cache_only )
node = xml_t::download_cache( sim, url );
else
node = xml_t::download( sim, url, "<h4>Item #", 0 );
if ( sim -> debug ) xml_t::print( node );
return node;
}
// get_tti_node =============================================================
static xml_node_t* get_tti_node( xml_node_t* root,
const std::string& name )
{
std::string class_str;
if ( xml_t::get_value( class_str, root, "class" ) )
{
if ( ! strncmp( class_str.c_str(), name.c_str(), name.size() ) )
{
return root;
}
}
std::vector<xml_node_t*> children;
int num_children = xml_t::get_children( children, root );
for ( int i=0; i < num_children; i++ )
{
xml_node_t* node = get_tti_node( children[ i ], name );
if ( node ) return node;
}
return 0;
}
// get_tti_nodes ============================================================
static int get_tti_nodes( std::vector<xml_node_t*>& nodes,
xml_node_t* root,
const std::string& name )
{
std::string class_str;
if ( xml_t::get_value( class_str, root, "class" ) )
{
if ( ! strncmp( class_str.c_str(), name.c_str(), name.size() ) )
{
nodes.push_back( root );
}
}
std::vector<xml_node_t*> children;
int num_children = xml_t::get_children( children, root );
for ( int i=0; i < num_children; i++ )
{
get_tti_nodes( nodes, children[ i ], name );
}
return ( int ) nodes.size();
}
// get_tti_value ===========================================================
static bool get_tti_value( std::string& value,
xml_node_t* root,
const std::string& name )
{
xml_node_t* node = get_tti_node( root, name );
if ( node )
{
if( xml_t::get_value( value, node, "." ) )
{
return true;
}
else if( xml_t::get_value( value, node, "a/." ) )
{
return true;
}
}
return false;
}
// get_tti_value ============================================================
static int get_tti_value( std::vector<std::string>& values,
xml_node_t* root,
const std::string& name )
{
std::string class_str;
if ( xml_t::get_value( class_str, root, "class" ) )
{
if ( ! strncmp( class_str.c_str(), name.c_str(), name.size() ) )
{
std::string value;
if ( xml_t::get_value( value, root, "." ) )
{
values.push_back( value );
}
else if ( xml_t::get_value( value, root, "a/." ) )
{
values.push_back( value );
}
}
}
std::vector<xml_node_t*> children;
int num_children = xml_t::get_children( children, root );
for ( int i=0; i < num_children; i++ )
{
get_tti_value( values, children[ i ], name );
}
return ( int ) values.size();
}
// parse_gems ===============================================================
static bool parse_gems( item_t& item,
xml_node_t* node,
const std::string gem_ids[ 3 ] )
{
item.armory_gems_str.clear();
int sockets[ 3 ] = { GEM_NONE, GEM_NONE, GEM_NONE };
std::vector<std::string> socket_colors;
int num_sockets = get_tti_value( socket_colors, node, "tti-socket" );
for ( int i=0; i < num_sockets && i < 3; i++ )
{
std::string& s = socket_colors[ i ];
std::string::size_type pos = s.find( " " );
if ( pos != std::string::npos ) s.erase( pos );
armory_t::format( s );
sockets[ i ] = util_t::parse_gem_type( s );
}
bool match = true;
for ( int i=0; i < 3; i++ )
{
int gem = item_t::parse_gem( item, gem_ids[ i ] );
if ( ! util_t::socket_gem_match( sockets[ i ], gem ) )
match = false;
}
if ( match )
{
xml_node_t* socket_bonus_node = get_tti_node( node, "tti-socketbonus" );
if ( socket_bonus_node )
{
std::string socket_bonus_str;
if ( xml_t::get_value( socket_bonus_str, socket_bonus_node, "a/." ) )
{
armory_t::fuzzy_stats( item.armory_gems_str, socket_bonus_str );
}
}
}
armory_t::format( item.armory_gems_str );
return true;
}
// parse_weapon =============================================================
static bool parse_weapon( item_t& item,
xml_node_t* node )
{
std::string tti_speed, tti_dps, tti_dmg;
if ( ! get_tti_value( tti_speed, node, "tti-speed" ) ||
! get_tti_value( tti_dps, node, "tti-dps" ) )
return true;
if ( ! get_tti_value( tti_dmg, node, "tti-dmg" ) )
if ( ! get_tti_value( tti_dmg, node, "tti-damage" ) )
return true;
std::string speed_str, dps_str, dmg_min_str, dmg_max_str;
std::vector<std::string> tokens;
int num_tokens = util_t::string_split( tokens, tti_speed, " " );
if ( num_tokens == 2 ) speed_str = tokens[ 1 ];
tokens.clear();
num_tokens = util_t::string_split( tokens, tti_dmg, " " );
if ( num_tokens == 4 )
{
dmg_min_str = tokens[ 0 ];
dmg_max_str = tokens[ 2 ];
}
tokens.clear();
num_tokens = util_t::string_split( tokens, tti_dps, " ()" );
if ( num_tokens == 4 ) dps_str = tokens[ 0 ];
if ( speed_str.empty() || dps_str.empty() || dmg_min_str.empty() || dmg_max_str.empty() ) return false;
std::string subclass_str, slot_str;
if ( ! get_tti_value( subclass_str, node, "tti-subclass" ) ||
! get_tti_value( slot_str, node, "tti-slot" ) )
return false;
if( slot_str == "Main Hand" ) slot_str = "One-Hand";
int weapon_type = WEAPON_NONE;
if ( subclass_str == "Axe" && slot_str == "One-Hand" ) weapon_type = WEAPON_AXE;
else if ( subclass_str == "Axe" && slot_str == "Two-Hand" ) weapon_type = WEAPON_AXE_2H;
else if ( subclass_str == "Dagger" ) weapon_type = WEAPON_DAGGER;
else if ( subclass_str == "Fist Weapon" ) weapon_type = WEAPON_FIST;
else if ( subclass_str == "Mace" && slot_str == "One-Hand" ) weapon_type = WEAPON_MACE;
else if ( subclass_str == "Mace" && slot_str == "Two-Hand" ) weapon_type = WEAPON_MACE_2H;
else if ( subclass_str == "Polearm" ) weapon_type = WEAPON_POLEARM;
else if ( subclass_str == "Staff" ) weapon_type = WEAPON_STAFF;
else if ( subclass_str == "Sword" && slot_str == "One-Hand" ) weapon_type = WEAPON_SWORD;
else if ( subclass_str == "Sword" && slot_str == "Two-Hand" ) weapon_type = WEAPON_SWORD_2H;
else if ( subclass_str == "Bow" ) weapon_type = WEAPON_BOW;
else if ( subclass_str == "Crossbow" ) weapon_type = WEAPON_CROSSBOW;
else if ( subclass_str == "Gun" ) weapon_type = WEAPON_GUN;
else if ( subclass_str == "Thrown" ) weapon_type = WEAPON_THROWN;
else if ( subclass_str == "Wand" ) weapon_type = WEAPON_WAND;
else if ( subclass_str == "Fishing Pole" ) weapon_type = WEAPON_POLEARM;
else if ( subclass_str == "Miscellaneous" ) weapon_type = WEAPON_POLEARM;
if ( weapon_type == WEAPON_NONE ) return false;
if ( weapon_type == WEAPON_WAND ) return true;
item.armory_weapon_str = util_t::weapon_type_string( weapon_type );
item.armory_weapon_str += "_" + speed_str + "speed" + "_" + dmg_min_str + "min" + "_" + dmg_max_str + "max";
return true;
}
// parse_item_stats =========================================================
static bool parse_item_stats( item_t& item,
xml_node_t* node )
{
item.armory_stats_str.clear();
std::vector<std::string> descriptions;
get_tti_value( descriptions, node, "tti-stat" );
get_tti_value( descriptions, node, "tti-stats" );
int num_descriptions = descriptions.size();
for ( int i=0; i < num_descriptions; i++ )
{
armory_t::fuzzy_stats( item.armory_stats_str, descriptions[ i ] );
}
std::vector<xml_node_t*> spells;
int num_spells = get_tti_nodes( spells, node, "tti-spells" );
for ( int i=0; i < num_spells; i++ )
{
std::string description;
if ( xml_t::get_value( description, spells[ i ], "a/." ) )
{
armory_t::fuzzy_stats( item.armory_stats_str, description );
}
}
std::string armor_str;;
if ( get_tti_value( armor_str, node, "tti-armor" ) )
{
std::string::size_type pos = armor_str.find( " " );
if ( pos != std::string::npos ) armor_str.erase( pos );
item.armory_stats_str += "_";
item.armory_stats_str += armor_str + "armor";
}
std::string block_str;;
if ( get_tti_value( armor_str, node, "tti-block" ) )
{
std::string::size_type pos = block_str.find( " " );
if ( pos != std::string::npos ) block_str.erase( pos );
item.armory_stats_str += "_";
item.armory_stats_str += block_str + "blockv";
}
armory_t::format( item.armory_stats_str );
return true;
}
// parse_item_name ==========================================================
static bool parse_item_name( item_t& item,
xml_node_t* node,
const std::string& item_id )
{
std::string& s = item.armory_name_str;
if ( ! xml_t::get_value( s, node, "title/." ) )
return false;
std::string::size_type pos = s.find( " - " );
if ( pos != std::string::npos ) s.erase( pos );
// The MMO-Champion names often have numbers embedded in the name.....
for ( int i=0; s[ i ]; i++ )
{
if ( isdigit( s[ i ] ) )
{
s.erase( i, 1 );
i--;
}
}
armory_t::format( s );
item.armory_id_str = item_id;
return true;
}
// parse_item_heroic =========================================================
static bool parse_item_heroic( item_t& item,
xml_node_t* node )
{
std::string heroic_str;
item.armory_heroic_str = "";
if ( xml_t::get_value( heroic_str, node, "tti-heroic" ) )
{
item.armory_heroic_str = "1";
}
armory_t::format( item.armory_heroic_str );
return true;
}
} // ANONYMOUS NAMESPACE ====================================================
// mmo_champion_t::parse_gem ================================================================
int mmo_champion_t::parse_gem( item_t& item,
const std::string& gem_id,
int cache_only )
{
if ( gem_id.empty() || gem_id == "" || gem_id == "0" )
return GEM_NONE;
xml_node_t* node = download_id( item.sim, gem_id, cache_only );
if ( ! node )
{
if ( ! cache_only )
item.sim -> errorf( "Player %s unable to download gem id %s from mmo-champion.\n",
item.player -> name(), gem_id.c_str() );
return GEM_NONE;
}
if ( node )
{
std::string color_str;
if ( get_tti_value( color_str, node, "tti-subclass" ) )
{
armory_t::format( color_str );
int gem_type = util_t::parse_gem_type( color_str );
std::string property_str;
xml_node_t* property_node = get_tti_node( node, "tti-gemproperties" );
if ( property_node ) xml_t::get_value( property_str, property_node, "a/." );
if ( gem_type == GEM_NONE || property_str.empty() )
return GEM_NONE;
std::string& s = item.armory_gems_str;
if ( gem_type == GEM_META )
{
int meta_gem_type = armory_t::parse_meta_gem( property_str );
if ( meta_gem_type != META_GEM_NONE )
{
s += "_";
s += util_t::meta_gem_type_string( meta_gem_type );
}
else
{
armory_t::fuzzy_stats( s, property_str );
}
}
else
{
armory_t::fuzzy_stats( s, property_str );
}
return gem_type;
}
}
return GEM_NONE;
}
// mmo_champion_t::download_glyph ===========================================
bool mmo_champion_t::download_glyph( sim_t* sim,
std::string& glyph_name,
const std::string& glyph_id,
int cache_only )
{
xml_node_t* node = download_id( sim, glyph_id, cache_only );
if ( ! node || ! xml_t::get_value( glyph_name, node, "title/." ) )
{
if ( ! cache_only )
sim -> errorf( "Unable to download glyph id %s from mmo-champion\n", glyph_id.c_str() );
return false;
}
glyph_name.erase( 0, 9 ); // remove "Glyph of "
std::string::size_type pos = glyph_name.find( " - " );
if ( pos != std::string::npos ) glyph_name.erase( pos );
armory_t::format( glyph_name );
return true;
}
// mmo_champion_t::download_item ============================================
bool mmo_champion_t::download_item( item_t& item,
const std::string& item_id,
int cache_only )
{
player_t* p = item.player;
xml_node_t* node = download_id( item.sim, item_id, cache_only );
if ( ! node )
{
if ( ! cache_only )
item.sim -> errorf( "Player %s nable to download item id '%s' from mmo-champion at slot %s.\n", p -> name(), item_id.c_str(), item.slot_name() );
return false;
}
if ( ! parse_item_name( item, node, item_id ) )
{
item.sim -> errorf( "Player %s unable to determine item name for id '%s' at slot %s.\n", p -> name(), item_id.c_str(), item.slot_name() );
return false;
}
if ( ! parse_item_heroic( item, node ) )
{
item.sim -> errorf( "Player %s unable to determine heroic flag for id '%s' at slot %s.\n", p -> name(), item_id.c_str(), item.slot_name() );
return false;
}
if ( ! parse_item_stats( item, node ) )
{
item.sim -> errorf( "Player %s unable to determine stats for item '%s' at slot %s.\n", p -> name(), item.name(), item.slot_name() );
return false;
}
if ( ! parse_weapon( item, node ) )
{
item.sim -> errorf( "Player %s unable to determine weapon info for item '%s' at slot %s.\n", p -> name(), item.name(), item.slot_name() );
return false;
}
return true;
}
// mmo_champion_t::download_slot ============================================
bool mmo_champion_t::download_slot( item_t& item,
const std::string& item_id,
const std::string& enchant_id,
const std::string gem_ids[ 3 ],
int cache_only )
{
player_t* p = item.player;
xml_node_t* node = download_id( item.sim, item_id, cache_only );
if ( ! node )
{
if ( ! cache_only )
item.sim -> errorf( "Player %s nable to download item id '%s' from mmo-champion at slot %s.\n", p -> name(), item_id.c_str(), item.slot_name() );
return false;
}
if ( ! parse_item_name( item, node, item_id ) )
{
item.sim -> errorf( "Player %s unable to determine item name for id '%s' at slot %s.\n", p -> name(), item_id.c_str(), item.slot_name() );
return false;
}
if ( ! parse_item_heroic( item, node ) )
{
item.sim -> errorf( "Player %s unable to determine heroic flag for item '%s' at slot %s.\n", p -> name(), item.name(), item.slot_name() );
return false;
}
if ( ! parse_item_stats( item, node ) )
{
item.sim -> errorf( "Player %s unable to determine stats for item '%s' at slot %s.\n", p -> name(), item.name(), item.slot_name() );
return false;
}
if ( ! parse_weapon( item, node ) )
{
item.sim -> errorf( "Player %s unable to determine weapon info for item '%s' at slot %s.\n", p -> name(), item.name(), item.slot_name() );
return false;
}
if ( ! parse_gems( item, node, gem_ids ) )
{
item.sim -> errorf( "Player %s unable to determine gems for item '%s' at slot %s.\n", p -> name(), item.name(), item.slot_name() );
return false;
}
if ( ! enchant_t::download( item, enchant_id ) )
{
item.sim -> errorf( "Player %s unable to parse enchant id %s for item \"%s\" at slot %s.\n", p -> name(), enchant_id.c_str(), item.name(), item.slot_name() );
//return false;
}
return true;
}
bool mmo_champion_t::parse_talents( player_t* player, const std::string& talent_string)
{
unsigned int i;
unsigned int visible[MAX_TALENT_SLOTS] = {0};
int trees[3] = {0};
int numleft = MAX_TALENT_POINTS;
int thismax;
unsigned int rangelow = 0;
unsigned int rangehigh = RANGE_HIGH;
unsigned int rangeval = 0;
unsigned int div1;
int mul1;
int mul2;
unsigned int len;
char c;
int newvisible = 1;
int talents[MAX_TALENT_SLOTS] = {0};
std::vector<talent_translation_t> translations = player->get_talent_list();
// need to have empty talent in the front of vector
std::vector<talent_translation_t> talent_list;
talent_translation_t empty_talent = {0,0,0,0,0,0,0};
talent_list.push_back(empty_talent);
for(i=0;i<translations.size();i++)
talent_list.push_back(translations[i]);
char* src = (char*)talent_string.c_str();
for(i=0;i<RANGE_BITS/6;i++) get_next_range_byte(&rangeval, &src); // get 24 bits
// 0 = disabled
// 1 = enabled this pass
// 2 = already scanned over, not considering again
visible[0] = 2;
while(newvisible) {
newvisible = 0;
// step 1: enable (consider) next row, if requirements met
for(i=1; i < talent_list.size();i++) {
if(visible[i] == 0 && trees[talent_list[i].tree] >= 5*talent_list[i].row && visible[talent_list[i].req] == 2 && talents[talent_list[i].req] == talent_list[talent_list[i].req].max) visible[i] = 1;
}
// step 2: step through each enabled node, convert
for(i=1; i < talent_list.size();i++) {
if(!numleft) break;
if(visible[i] == 1)
{
newvisible = 1;
visible[i] = 2;
thismax = numleft;
if(talent_list[i].max < thismax) thismax = talent_list[i].max;
div1 = thismax+1; // # choices
mul2 = 1; // prob of just this one
len = rangehigh - rangelow;
for(mul1=0;mul1<thismax+1;mul1++) {
if(rangeval >= rangelow + len * mul1 / div1 && rangeval < rangelow + len * (mul1 + mul2) / div1) break;
}
talents[i] = mul1;
if(talents[i] > talent_list[i].max) { // probably corrupt string or wrong version, we can't really continue decode
return 1;
}
rangehigh = rangelow + len * (mul1 + mul2) / div1;// - 1;
rangelow += len * mul1 / div1;
while( (rangelow & RANGE_HIGH_MASK) == (rangehigh & RANGE_HIGH_MASK) ) {
c = (rangelow >> (RANGE_BITS-6)) & 0x3f;
len = rangehigh - rangelow;
rangelow = ((rangelow & RANGE_LOW_MASK) << 6);
rangehigh = rangelow + len*0x40 - 1;
get_next_range_byte(&rangeval, &src); // get 6 bits
}
// update
trees[talent_list[i].tree] += talents[i];
numleft -= talents[i];
}
}
}
for(i=0;i<translations.size();i++)
talents[i] = talents[i+1];
return player->parse_talent_trees(talents);
}
void mmo_champion_t::get_next_range_byte(unsigned int* rangeval, char** src) {
*rangeval = ((*rangeval)&(RANGE_HIGH>>6))<<6;
if(**src && strchr(base64, **src)) {
*rangeval |= (strchr(base64, **src)-base64);
*src = (*src) + 1;
}
}
| [
"[email protected]"
]
| [
[
[
1,
648
]
]
]
|
2610e7c1aff6e7e2e9a0586a91223d9d6876d840 | d2fc16640fb0156afb6528e744867e2be4eec02c | /src/ShortCut.cpp | f46e661cf6259bab9995eaa5dbbd2732bfaca2de | []
| no_license | wlschmidt/lcdmiscellany | 8cd93b5403f9c62a127ddd00c8c5dd577cf72e2f | 6623ca05cd978d91580673e6d183f2242bb8eb24 | refs/heads/master | 2021-01-19T02:30:05.104179 | 2011-11-02T21:52:07 | 2011-11-02T21:52:07 | 48,021,331 | 1 | 1 | null | 2016-07-23T09:08:48 | 2015-12-15T05:20:15 | C++ | UTF-8 | C++ | false | false | 7,975 | cpp | #include "ShortCut.h"
#include "Config.h"
#include "unicode.h"
#include "stringUtil.h"
#include <shellapi.h>
#include "malloc.h"
#include "vm.h"
ShortcutManager shortcutManager;
void ShortcutManager::ClearShortcuts() {
for (int i=0; i<numShortcuts; i++) {
// If already closed the window, no need to unregister.
if (ghWnd)
UnregisterHotKey(ghWnd, i);
free(shortcuts[i].command);
}
free(shortcuts);
shortcuts = 0;
numShortcuts = 0;
}
void ShortcutManager::HotkeyPressed(WPARAM id) {
if ((int)id < 0 || (int)id >= numShortcuts) return;
int l = strlen (shortcuts[id].command);
if (l && shortcuts[id].command[l-1] == ')') {
int w = l;
while (w && shortcuts[id].command[w] != '(') w--;
if (w) {
int w2 = w;
w2--;
while (w2 && shortcuts[id].command[w] == ' ' || shortcuts[id].command[w] == '\t') w2--;
if (w2) {
char t = shortcuts[id].command[w2+1];
shortcuts[id].command[w2+1] = 0;
int f = FindFunction(shortcuts[id].command);
shortcuts[id].command[w2+1] = t;
if (f >= 0) {
RunFunction(f);
}
}
}
}
//Resolve path == bad. \\?\<path> doesn't launch explorer window properly.
wchar_t *path = UTF8toUTF16Alloc(shortcuts[id].command);
if (path) {
wchar_t * rPath = path;
wchar_t * args = 0;
if (path[0] == '\"') {
rPath = path + 1;
args = wcschr(rPath, '\"');
}
else {
args = wcschr(rPath, ' ');
}
if (args) {
args[0] = 0;
args ++;
}
if (args)
LeftJustify(args);
//ShellExecuteW(ghWnd, 0, rPath, args, 0, SW_SHOWNORMAL);
STARTUPINFO si;
//PROCESS_INFORMATION pi;
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
ShellExecuteW(ghWnd, 0, rPath, args, 0, SW_SHOW);
//CreateProcessW(rPath, args, 0, 0, 0, CREATE_DEFAULT_ERROR_MODE, 0, 0, &si, &pi);
//CloseHandle(pi.hProcess);
//CloseHandle(pi.hThread);
free(path);
}
}
void ShortcutManager::Load() {
unsigned char *key;
unsigned char *command;
ClearShortcuts();
int count = 0;
while (command = config.GetConfigStringAndKey((unsigned char *)"Shortcuts", key, count)) {
count++;
if (command || key) {
if (key && command && srealloc(shortcuts, sizeof(Shortcut) * (numShortcuts+1))) {
unsigned int modifiers = 0;
unsigned int vkey = 0;
int i = 0;
while (1) {
if (key[i] == '@') modifiers |= MOD_WIN;
else if (key[i] == '!') modifiers |= MOD_ALT;
else if (key[i] == '^') modifiers |= MOD_CONTROL;
else if (key[i] == '+') modifiers |= MOD_SHIFT;
else break;
i++;
}
if (key[i+1] == 0) {
short code = VkKeyScan(key[i]);
if (code != 0xFFFF) {
vkey = code & 0xFF;
}
/*if ((UCASE(key[i] >= 'A') && UCASE(key[i] <= 'Z')) || (key[i] >= '0' && key[i] <= '9'))
vkey = UCASE(key[i]);
if ((UCASE(key[i] >= 'A') && UCASE(key[i] <= 'Z')) || (key[i] >= '0' && key[i] <= '9'))
//*/
}
else if (CompareSubstringNoCase(key+i, (unsigned char*)"num") == 0) {
if (CompareSubstringNoCase(key+i, (unsigned char*)"pad") == 0)
i+=3;
if (key[i+1] == 0 && '0' <= key[i] && key[i] <= '9') {
vkey = VK_NUMPAD0 + key[i] - '0';
}
else if (stricmp(key+i, (unsigned char*) "*") == 0 || stricmp(key+i, (unsigned char*) "multiply") == 0 || stricmp(key+i, (unsigned char*) "mul") == 0 || stricmp(key+i, (unsigned char*) "times") == 0 || stricmp(key+i, (unsigned char*) "star") == 0)
vkey = VK_ADD;
else if (stricmp(key+i, (unsigned char*) "+") == 0 || stricmp(key+i, (unsigned char*) "plus") == 0 || stricmp(key+i, (unsigned char*) "add") == 0)
vkey = VK_ADD;
else if (stricmp(key+i, (unsigned char*) "-") == 0 || stricmp(key+i, (unsigned char*) "minus") == 0 || stricmp(key+i, (unsigned char*) "sub") == 0 || stricmp(key+i, (unsigned char*) "subtract") == 0)
vkey = VK_SUBTRACT;
else if (stricmp(key+i, (unsigned char*) "/") == 0 || stricmp(key+i, (unsigned char*) "divide") == 0 || stricmp(key+i, (unsigned char*) "div") == 0 || stricmp(key+i, (unsigned char*) "slash") == 0)
vkey = VK_DIVIDE;
else if (stricmp(key+i, (unsigned char*) ".") == 0 || stricmp(key+i, (unsigned char*) "dec") == 0 || stricmp(key+i, (unsigned char*) "decimal") == 0)
vkey = VK_DECIMAL;
else if (stricmp(key+i, (unsigned char*) ".") == 0 || stricmp(key+i, (unsigned char*) "dec") == 0 || stricmp(key+i, (unsigned char*) "decimal") == 0)
vkey = VK_DECIMAL;
else if (stricmp(key+i, (unsigned char*) "lock") == 0 || key[i] == 0)
vkey = VK_NUMLOCK;
}
else if (key[i] == 'f' || key[i] == 'F') {
i++;
if ('0' <= key[i] && key[i] <= '9' && (key[i+1] == 0 || (key[i+2] == 0 && '0' <= key[i+1] && key[i+1] <= '9'))) {
int w = (int) strtoi64((char*)key+i, 0, 0);
if (w > 0 && w <=24) {
// 24 f keys? There are key codes for them...apparently.
vkey = VK_F1 + w;
}
}
}
else if (stricmp(key+i, (unsigned char*) "space") == 0)
vkey = VK_SPACE;
else if (stricmp(key+i, (unsigned char*) "esc") == 0 || stricmp(key+i, (unsigned char*) "escape") == 0)
vkey = VK_ESCAPE;
else if (stricmp(key+i, (unsigned char*) "pgup") == 0 || stricmp(key+i, (unsigned char*) "pageup") == 0)
vkey = VK_PRIOR;
else if (stricmp(key+i, (unsigned char*) "pgdn") == 0 || stricmp(key+i, (unsigned char*) "pagedn") == 0 || stricmp(key+i, (unsigned char*) "pagedown") == 0)
vkey = VK_NEXT;
else if (stricmp(key+i, (unsigned char*) "end") == 0)
vkey = VK_END;
else if (stricmp(key+i, (unsigned char*) "home") == 0)
vkey = VK_HOME;
else if (stricmp(key+i, (unsigned char*) "left") == 0)
vkey = VK_LEFT;
else if (stricmp(key+i, (unsigned char*) "right") == 0)
vkey = VK_RIGHT;
else if (stricmp(key+i, (unsigned char*) "down") == 0)
vkey = VK_DOWN;
else if (stricmp(key+i, (unsigned char*) "up") == 0)
vkey = VK_UP;
else if (stricmp(key+i, (unsigned char*) "print") == 0 || stricmp(key+i, (unsigned char*) "printscreen") == 0)
vkey = VK_SNAPSHOT;
else if (stricmp(key+i, (unsigned char*) "ins") == 0 || stricmp(key+i, (unsigned char*) "insert") == 0)
vkey = VK_INSERT;
else if (stricmp(key+i, (unsigned char*) "del") == 0 || stricmp(key+i, (unsigned char*) "delete") == 0)
vkey = VK_DELETE;
else if (stricmp(key+i, (unsigned char*) "help") == 0)
vkey = VK_HELP;
else if (stricmp(key+i, (unsigned char*) "pause") == 0)
vkey = VK_PAUSE;
else if (stricmp(key+i, (unsigned char*) "caps") == 0 || stricmp(key+i, (unsigned char*) "capslock") == 0)
vkey = VK_CAPITAL;
else if (stricmp(key+i, (unsigned char*) "tab") == 0)
vkey = VK_TAB;
else if (stricmp(key+i, (unsigned char*) "scroll") == 0 || stricmp(key+i, (unsigned char*) "scrolllock") == 0)
vkey = VK_SCROLL;
else if (stricmp(key+i, (unsigned char*) "back") == 0 || stricmp(key+i, (unsigned char*) "backspace") == 0)
vkey = VK_BACK;
else if (stricmp(key+i, (unsigned char*) "clear") == 0 || stricmp(key+i, (unsigned char*) "cls") == 0 || stricmp(key+i, (unsigned char*) "clearscreen") == 0)
vkey = VK_CLEAR;
else if (stricmp(key+i, (unsigned char*) "enter") == 0 || stricmp(key+i, (unsigned char*) "resturn") == 0)
vkey = VK_RETURN;
else if (stricmp(key+i, (unsigned char*) "shift") == 0)
vkey = VK_SHIFT;
else if (stricmp(key+i, (unsigned char*) "control") == 0 || stricmp(key+i, (unsigned char*) "ctrl") == 0)
vkey = VK_MENU;
if (vkey) {
if (RegisterHotKey(ghWnd, numShortcuts, modifiers, vkey)) {
shortcuts[numShortcuts].flags = modifiers;
shortcuts[numShortcuts].vkey = vkey;
shortcuts[numShortcuts++].command = command;
LeftJustify(command);
continue;
}
}
}
if (command)
free(command);
continue;
}
break;
}
}
| [
"mattmenke@88352c64-7129-11de-90d8-1fdda9445408"
]
| [
[
[
1,
198
]
]
]
|
7c29992851788599dea365da9dde5fbadf53fc9d | 33f59b1ba6b12c2dd3080b24830331c37bba9fe2 | /Depend/Foundation/Mathematics/Wm4Tetrahedron3.h | 8244fa5e8420b7ca77a0de556ecf0cf54bd07699 | []
| no_license | daleaddink/flagship3d | 4835c223fe1b6429c12e325770c14679c42ae3c6 | 6cce5b1ff7e7a2d5d0df7aa0594a70d795c7979a | refs/heads/master | 2021-01-15T16:29:12.196094 | 2009-11-01T10:18:11 | 2009-11-01T10:18:11 | 37,734,654 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,725 | h | // Geometric Tools, Inc.
// http://www.geometrictools.com
// Copyright (c) 1998-2006. All Rights Reserved
//
// The Wild Magic Version 4 Foundation Library source code is supplied
// under the terms of the license agreement
// http://www.geometrictools.com/License/Wm4FoundationLicense.pdf
// and may not be copied or disclosed except in accordance with the terms
// of that agreement.
#ifndef WM4TETRAHEDRON3_H
#define WM4TETRAHEDRON3_H
#include "Wm4FoundationLIB.h"
#include "Wm4Plane3.h"
namespace Wm4
{
template <class Real>
class Tetrahedron3
{
public:
// The vertices are ordered so that the triangular faces are
// counterclockwise when viewed by an observer outside the tetrahedron:
// face 0 = <V[0],V[2],V[1]>
// face 1 = <V[0],V[1],V[3]>
// face 2 = <V[0],V[3],V[2]>
// face 3 = <V[1],V[2],V[3]>
// Construction.
Tetrahedron3 (); // uninitialized
Tetrahedron3 (const Vector3<Real>& rkV0, const Vector3<Real>& rkV1,
const Vector3<Real>& rkV2, const Vector3<Real>& rkV3);
Tetrahedron3 (const Vector3<Real> akV[4]);
// Get the vertex indices for the specified face.
void GetFaceIndices (int iFace, int aiIndex[3]) const;
// Construct the planes of the faces. The planes have outer pointing
// normal vectors. The normals may be specified to be unit length. The
// plane indexing is the same as the face indexing mentioned previously.
void GetPlanes (Plane3<Real> akPlane[4], bool bUnitLengthNormals) const;
Vector3<Real> V[4];
};
#include "Wm4Tetrahedron3.inl"
typedef Tetrahedron3<float> Tetrahedron3f;
typedef Tetrahedron3<double> Tetrahedron3d;
}
#endif
| [
"yf.flagship@e79fdf7c-a9d8-11de-b950-3d5b5f4ea0aa"
]
| [
[
[
1,
55
]
]
]
|
4f6b31d08669d5ffdc667cfda4dc4a0259732c23 | 9590b067bcd6087a7ae97a77788818562649bd02 | /Sources/Internal/Sound/SoundChannel.h | 260e605a810e457d710fd9c268d29a6e1e70ec52 | []
| no_license | vaad2/dava.framework | b2ce2ad737c374a28e9d13112db1951a965870e5 | bc0589048287a9b303b794854b75c98eb61baa8e | refs/heads/master | 2020-11-27T05:12:12.268778 | 2011-12-01T13:09:34 | 2011-12-01T13:09:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,799 | h | /*==================================================================================
Copyright (c) 2008, DAVA Consulting, LLC
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 DAVA Consulting, LLC 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 DAVA CONSULTING, LLC 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 DAVA CONSULTING, LLC 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.
Revision History:
* Created by Ivan Petrochenko
=====================================================================================*/
#ifndef __DAVAENGINE_SOUND_CHANNEL_H__
#define __DAVAENGINE_SOUND_CHANNEL_H__
#include "Base/BaseTypes.h"
#include "Sound/ALUtils.h"
namespace DAVA
{
class Sound;
class SoundChannel
{
public:
enum eState
{
STATE_FREE = 0,
STATE_PLAYING,
STATE_PAUSED
};
SoundChannel();
~SoundChannel();
void SetPriority(int32 newPriority);
int32 GetProirity();
void SetState(eState newState);
eState GetState();
void Play(Sound * sound, bool looping); //move to private-friend
void Pause(bool pause);
void Stop();
void SetVolume(float32 volume); // [0..1]
float32 GetVolume();
void Update();
Sound * GetBuddySound();
private:
#ifdef __DAVASOUND_AL__
ALuint source;
#endif
eState state;
int32 priority;
Sound * buddySound;
float32 volume;
bool looping;
void PlayStatic();
void PlayStreamed();
void UpdateStatic();
void UpdateStreamed();
};
};
#endif //__DAVAENGINE_SOUND_CHANNEL_H__
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
46
],
[
49,
89
]
],
[
[
47,
48
]
]
]
|
2682d3cd884117ea3c7d611f2e7a2ada20768715 | 57c3ef7177f9bf80874fbd357fceb8625e746060 | /Personal_modle_file/Dean_Zhang/server/BServer/debug/moc_cimserver.cpp | 048d6c7fa780bbe45693bb07ae2f320d28d5f356 | []
| no_license | kref/mobileim | 0c33cc01b312704d71e74db04c4ba9b624b4ff73 | 15894fa006095428727b0530e9337137262818ac | refs/heads/master | 2016-08-10T08:33:27.761030 | 2011-08-13T13:15:37 | 2011-08-13T13:15:37 | 45,781,075 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,608 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'cimserver.h'
**
** Created: Sun Jun 27 23:00:22 2010
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../cimserver.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'cimserver.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 62
#error "This file was generated using the moc from 4.6.2. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_CIMServer[] = {
// content:
4, // revision
0, // classname
0, 0, // classinfo
2, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
// slots: signature, parameters, type, tag, flags
11, 10, 10, 10, 0x08,
49, 37, 10, 10, 0x08,
0 // eod
};
static const char qt_meta_stringdata_CIMServer[] = {
"CIMServer\0\0processPendingDatagrams()\0"
"socketError\0DisplayError(QAbstractSocket::SocketError)\0"
};
const QMetaObject CIMServer::staticMetaObject = {
{ &QObject::staticMetaObject, qt_meta_stringdata_CIMServer,
qt_meta_data_CIMServer, 0 }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &CIMServer::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *CIMServer::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *CIMServer::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_CIMServer))
return static_cast<void*>(const_cast< CIMServer*>(this));
return QObject::qt_metacast(_clname);
}
int CIMServer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QObject::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: processPendingDatagrams(); break;
case 1: DisplayError((*reinterpret_cast< QAbstractSocket::SocketError(*)>(_a[1]))); break;
default: ;
}
_id -= 2;
}
return _id;
}
QT_END_MOC_NAMESPACE
| [
"[email protected]"
]
| [
[
[
1,
82
]
]
]
|
523e2b8028aabdd4ee7cca217f595070c3ec546b | 0fedf4a90b9ccabe4956ba3dc14289bcae050b28 | /arm9/include/map.h | c7255831a1882a2bc44a696bf8453e71bbf84d62 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | Jell/tower_game | 8bf784c583f8cc7208081d2748756de38173b2d5 | c65546ba89643dfdc23482b76aa5cd23bb577249 | refs/heads/main | 2021-06-16T19:31:17.276147 | 2011-04-17T19:12:09 | 2011-04-17T19:12:09 | 1,627,379 | 1 | 0 | null | null | null | null | ISO-8859-2 | C++ | false | false | 929 | h | /*
* map.h
*
* Created on: 1 déc. 2009
* Author: Jean-Louis
*/
#ifndef MAP_H_
#define MAP_H_
extern "C" {
#include <nds.h>
#include <stdio.h>
#include "constants.h"
}
#include "mapengine.h"
#include "display.h"
#define IS_OBJ_NULL(i,j) (objectMap[(i)][(j)] == TILE_NULL)
#define IS_OBJ_GRND(i,j) (objectMap[(i)][(j)] == TILE_GROUND)
#define IS_OBJ_NOT_NULL(i,j) (objectMap[(i)][(j)] != TILE_NULL)
#define IS_OBJ_WALL(i,j) (objectMap[(i)][(j)] == TILE_WALL)
class Map {
private:
void drawBorders();
void smoothBorders();
void smoothPath();
void wallsAround();
void generateCave();
void generateDungeon();
void generateOutside();
public:
Map();
virtual ~Map();
s32 scroll_x, scroll_y;
u8 objectMap[OBJ_MAP_WIDTH][OBJ_MAP_HEIGHT];
u8 testDoors();
u8 testWalls();
void move(s32 x, s32 y);
void renderMap();
void newLevel();
};
#endif /* MAP_H_ */
| [
"[email protected]"
]
| [
[
[
1,
46
]
]
]
|
7febabac56ff4f788ccf37c115fd22d01cf72294 | b6d87736b619bd299d337637900c6025fe056a84 | /src/Pipe.h | 4c087179e45dcb0c6051edb10bc029c8878a17d3 | []
| no_license | rogergranada/pipe-flow-simulator | 00d6ef7ab7d22a0c6e8512399e26b940a11bcbcf | 8b81b1ca6152aa8ac96a3a728896675e8aaea7de | refs/heads/master | 2021-01-17T12:10:39.727622 | 2011-04-11T16:19:30 | 2011-04-11T16:19:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 314 | h | #include "UnitsManager.h"
class Pipe{
public:
// Calculate the pipe's area
double getArea();
// x - Pipe length [m]
double length;
// θ - Pipe angle [deg]
double angle;
// D - Pipe diameter [m]
double diameter;
// ε - Roughness height [m]
double roughnessHeight;
}; | [
"[email protected]"
]
| [
[
[
1,
19
]
]
]
|
3d8b3163f531084c2251de1b51d0578ba0f09773 | 8d1d891c3a1f9b4c09d6edf8cad30fcf03a214ed | /source/world/World.cpp | 8e92dfcf6f4c15cbea6d83ba07e840260440323e | []
| no_license | mightymouse2016/shootmii | 7a53a70d027ec8bc8e957c7113144de57ecfa1a5 | 6a44637da4db44ba05d5d14c9a742f5d053041fa | refs/heads/master | 2021-01-10T06:36:38.009975 | 2010-07-20T19:43:23 | 2010-07-20T19:43:23 | 54,534,472 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,361 | cpp | #include "../tools/ImageBank.h"
#include "../App.h"
#include "Sun.h"
#include "Wind.h"
#include "Cloud.h"
#include "Terrain.h"
#include "World.h"
namespace shootmii {
World::World() :
Polygon(SKY_LAYER),
wind(new Wind),
terrain(new Terrain(N_ROWS, N_COLS, TERRAIN_CELL_WIDTH, TERRAIN_CELL_HEIGHT)),
sun(new Sun),
clouds(new std::list<Cloud*>)
{
vertices.reserve(4);
vertices.push_back(Coordinates(1,1));
vertices.push_back(Coordinates(TERRAIN_CELL_WIDTH*N_COLS-1,1));
vertices.push_back(Coordinates(TERRAIN_CELL_WIDTH*N_COLS-1,TERRAIN_CELL_HEIGHT*N_ROWS-1));
vertices.push_back(Coordinates(1,TERRAIN_CELL_HEIGHT*N_ROWS-1));
for (int i = 0; i < N_BACKGROUND_CLOUDS; i++) {
clouds->push_back(
new Cloud(
BACK_CLOUD_LAYER,
wind,
App::imageBank->get(TXT_BG_CLOUD),
BACK_CLOUD_WIDTH,
BACK_CLOUD_HEIGHT));
}
for (int i = 0; i < N_FOREGROUND_CLOUDS; i++) {
clouds->push_back(
new Cloud(
FRONT_CLOUD_LAYER,
wind,
App::imageBank->get(TXT_FG_CLOUD),
FRONT_CLOUD_WIDTH,
FRONT_CLOUD_HEIGHT));
}
}
World::~World() {
clouds->clear();
delete clouds;
delete terrain;
}
Wind* World::getWind() {
return wind;
}
Terrain* World::getTerrain() {
return terrain;
}
void World::init() {
terrain->generate();
wind->init();
sun->init();
for (std::list<Cloud*>::iterator i=clouds->begin();i!=clouds->end();i++) (*i)->init();
}
void World::compute() {
computeClouds();
wind->compute();
sun->compute();
}
void World::computeClouds() {
for (std::list<Cloud*>::iterator i=clouds->begin();i!=clouds->end();i++) {
(*i)->compute();
}
}
void World::addToDrawManager(){
Polygon::addToDrawManager();
sun->addToDrawManager();
terrain->addToDrawManager();
for (std::list<Cloud*>::iterator i=clouds->begin();i!=clouds->end();i++) (*i)->addToDrawManager();
}
void World::draw() const{
// Ciel
float ratio = (1-SUN_LIGHT_INFLUENCE) - sin(sun->getAbsoluteAngle())*SUN_LIGHT_INFLUENCE;
Color colorSky1 = Color(Color::BLUE_SKY_1, Color::BLUE_SKY_1 & Color::TRANSPARENT, ratio);
Color colorSky2 = Color(Color::BLUE_SKY_2, Color::BLUE_SKY_2 & Color::TRANSPARENT, ratio);
u32 colors[] = {colorSky1, colorSky1, colorSky2, colorSky2};
drawRectangle(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, colors);
Polygon::draw();
}
}
| [
"Altarfinch@c8eafc54-4d23-11de-9e51-a92ed582648b",
"altarfinch@c8eafc54-4d23-11de-9e51-a92ed582648b"
]
| [
[
[
1,
7
],
[
16,
16
],
[
62,
62
],
[
67,
67
],
[
72,
72
],
[
81,
81
],
[
84,
84
],
[
87,
88
]
],
[
[
8,
15
],
[
17,
61
],
[
63,
66
],
[
68,
71
],
[
73,
80
],
[
82,
83
],
[
85,
86
],
[
89,
94
]
]
]
|
372f4bbb7ada98f102050cb66b273a296b8b19ce | c95a83e1a741b8c0eb810dd018d91060e5872dd8 | /libs/STLPort-4.0/stlport/ostream.h | 5592ab6e98dcd84097c97f9dbb59b23c8fd655ca | [
"LicenseRef-scancode-stlport-4.5"
]
| permissive | rickyharis39/nolf2 | ba0b56e2abb076e60d97fc7a2a8ee7be4394266c | 0da0603dc961e73ac734ff365bfbfb8abb9b9b04 | refs/heads/master | 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,361 | h | /*
* Copyright (c) 1999
* Boris Fomitchev
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
#ifndef __STLPORT_OSTREAM_H
# define __STLPORT_OSTREAM_H
# ifndef __STL_OUTERMOST_HEADER_ID
# define __STL_OUTERMOST_HEADER_ID 0x2051
# include <stl/_prolog.h>
# endif
# if defined (__SGI_STL_OWN_IOSTREAMS)
# include <ostream>
# ifdef __STL_USE_NAMESPACES
# include <using/ostream>
# endif
# elif !defined (__STL_USE_NO_IOSTREAMS)
# include __STL_NATIVE_OLD_STREAMS_HEADER(ostream.h)
# if defined (__STL_USE_NAMESPACES) && !defined (__STL_BROKEN_USING_DIRECTIVE)
__STL_BEGIN_NAMESPACE
# include <using/h/ostream.h>
__STL_END_NAMESPACE
# endif /* __STL_USE_NAMESPACES */
# endif /* __STL_USE_NO_IOSTREAMS */
# if (__STL_OUTERMOST_HEADER_ID == 0x2051)
# include <stl/_epilog.h>
# undef __STL_OUTERMOST_HEADER_ID
# endif
#endif /* __STLPORT_OSTREAM_H */
| [
"[email protected]"
]
| [
[
[
1,
49
]
]
]
|
c27b10d070664b357b11b0be9f52a2571ae6b0ef | d115cf7a1b374d857f6b094d4b4ccd8e9b1ac189 | /pyplusplus_dev/unittests/data/operators_bug_to_be_exported.hpp | 37a5f0403db41c95f3aa82385d0a3a8b19605af9 | [
"BSL-1.0"
]
| permissive | gatoatigrado/pyplusplusclone | 30af9065fb6ac3dcce527c79ed5151aade6a742f | a64dc9aeeb718b2f30bd6a5ff8dcd8bfb1cd2ede | refs/heads/master | 2016-09-05T23:32:08.595261 | 2010-05-16T10:53:45 | 2010-05-16T10:53:45 | 700,369 | 4 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,756 | hpp | // Copyright 2004-2008 Roman Yakovenko.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef __operators_bug_to_be_exported_hpp__
#define __operators_bug_to_be_exported_hpp__
#include <string>
namespace operators_bug{
template< typename derived_type, typename value_type >
struct number{
value_type value;
friend derived_type operator+( const derived_type& y, const derived_type& x ){
derived_type tmp;
tmp.value = y.value + x.value;
return tmp;
}
protected:
bool operator==( const derived_type& other ){ return value == other.value; }
};
struct integral : public number< integral, int >{
integral operator+( int x ){
integral tmp;
tmp.value = value + x;
return tmp;
}
integral operator++( ){
integral tmp;
tmp.value = value + 1;
return tmp;
}
};
struct integral2 : public number< integral, int >{
//in this case no operator should be redefined
};
struct vector
{
double x;
static const vector one;
vector(double ax) : x(ax) {}
vector operator+(const vector& other) const { return vector(x+other.x); }
virtual void trigger_wrapper() {}
};
struct call_copy_constructor_t{
explicit call_copy_constructor_t( const std::string& x )
{}
call_copy_constructor_t( const call_copy_constructor_t& x ){};
call_copy_constructor_t& operator=( const call_copy_constructor_t& x ){
return *this;
}
virtual void do_nothing(){}
};
}
#endif//__operators_bug_to_be_exported_hpp__
| [
"roman_yakovenko@dc5859f9-2512-0410-ae5c-dd123cda1f76"
]
| [
[
[
1,
72
]
]
]
|
aa58455f38331d8888531c9f4a40760dec19c890 | a352572bc22d863f72020118d8f5b94c69521f3f | /pa2/src/Rectangle.h | a435a1952e7f730400385d89423ad5f3694f357c | []
| no_license | mjs513/cs4620-1 | 63345a9a7774279d8d6ab63b1af64d65b14b0ae3 | 419da5df73c5a9c34387b3cd2f7f3c542e0a3c3e | refs/heads/master | 2021-01-10T06:45:47.809907 | 2010-12-10T20:59:46 | 2010-12-10T20:59:46 | 46,994,144 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 844 | h | /*
* Rectangle.h
*
* Created on: Sep 24, 2010
* Author: Roberto
*/
#ifndef RECTANGLE_H_
#define RECTANGLE_H_
#include "Vector.h"
#include "Point.h"
namespace Geo {
class Rectangle
{
public:
Rectangle();
Rectangle(const Point &origin, const Vector &size);
const Point origin() const;
Rectangle& setOrigin(const Point &origin);
const Vector size() const;
Rectangle& setSize(const Vector &size);
double area() const;
std::pair<Rectangle,Rectangle> splitX(double x) const;
std::pair<Rectangle,Rectangle> splitY(double y) const;
const Rectangle inset(double border) const;
void draw() const;
private:
Point _origin;
Vector _size;
};
} // namespace Geo
std::ostream& operator<<(std::ostream &out, const Geo::Rectangle &rect);
#endif /* RECTANGLE_H_ */
| [
"robertorfischer@ebbd4279-5267-bd07-7df5-4dafc36418f6"
]
| [
[
[
1,
52
]
]
]
|
90348a7ca0dce40cb6bf43f3f64ecb4ed044d878 | fdfaf8e8449c5e80d93999ea665db48feaecccbe | /trunk/cg ex3/ParticleSystem.cpp | 257ddc2653e6940acf160ddd9604b7b061955749 | []
| no_license | BackupTheBerlios/glhuji2005-svn | 879e60533f820d1bdcfa436fd27894774c27a0b7 | 3afe113b265704e385c94fabaf99a7d1ad1fdb02 | refs/heads/master | 2016-09-01T17:25:30.876585 | 2006-09-03T18:04:19 | 2006-09-03T18:04:19 | 40,673,356 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,046 | cpp | #include "StdAfx.h"
#include "ParticleSystem.h"
#include "constants.h"
#include "SimulationsParams.h"
extern CSimulationsParams g_simulationParams;
CParticleSystem::CParticleSystem(void):
m_nCurFrame(0),
mMaxParticleVelocity(100),
m_pParticleSize(1,1,1),
m_pParticleColor(0,0,1),
m_pParticleColor2(0,0,1)
{
m_dt = 0.033;
m_bUsingA = true;
m_nParticlesPerFrame = 10;
m_pCurSystem = &m_ParticlesA;
m_pNewSystem = &m_ParticlesB;
m_dDefaultMass = 0.1; //[Kg]
m_dDefaultRadius = 1; //[m]
m_dDefaultSpan = 20; //[m]
m_dDefaultLifespan = 7; //[sec]
m_dDefaultPersistance = 1;
ParticleShapeType m_particleShape = C_PARTICLESHAPE_DOT;
m_dParticleAlpha = 1;
m_dColorRandomness = 0;
m_dParticleSizeRand = 0;
}
CParticleSystem::~CParticleSystem(void)
{
}
bool CParticleSystem::calcNextFrame()
{
m_nCurFrame++;
if (m_bUsingA)
{
m_pCurSystem = &m_ParticlesA;
m_pNewSystem = &m_ParticlesB;
}
else
{
m_pCurSystem = &m_ParticlesB;
m_pNewSystem = &m_ParticlesA;
}
m_bUsingA = !m_bUsingA;
return true;
}
bool CParticleSystem::isParticleDead (int i)
{
//Check dying of old age
(*m_pNewSystem)[i].age += m_dt;
if ((*m_pNewSystem)[i].lifepan >= 0 &&
(*m_pNewSystem)[i].age > (*m_pNewSystem)[i].lifepan)
return true;
//Check dying by chance
if (frand() > (*m_pNewSystem)[i].persistance)
return true;
//Check dying by distance from birthplace
if ((*m_pNewSystem)[i].span > 0 &&
((*m_pNewSystem)[i].X-(*m_pNewSystem)[i].birthplace).length() > (*m_pNewSystem)[i].span)
return true;
return false;
}
bool CParticleSystem::prevFrame()
{
return false;
}
bool CParticleSystem::display(int nFrameNum, int nShading)
{
Point3d a;
unsigned int numParticles = (unsigned int)m_pNewSystem->size();
//for faster drawing of teapot
static GLuint teapotDisplayList;
static bool teapotCreated = false;
static bool drawnLines = false;
bool drawLines = (nShading%2==1);
if (drawLines != drawnLines){
teapotCreated = false;
drawnLines = drawLines;
}
for (unsigned int i=0; i<numParticles; i++)
{
glPushMatrix();
CParticle &particle = (*m_pNewSystem)[i];
Point3d color = particle.getColor();
Point3d size = particle.size;
float alpha = (float)particle.alpha;
// calculate rotation angle
GLdouble lengthV = particle.V.norm();
Vector3d v1(particle.V);
Vector3d v2(0,0,1);
//special case for particles with zero velocity...
if (lengthV > 0){
v1.normalize();
}
else{
v1 = Point3d(0,1,0);
}
Vector3d norm = v1%v2;
double angle1 = dot(v1,v2);
double angle = acos(angle1)*RAD2DEG;
// draw
glColor4f(color[0], color[1], color[2], alpha);
GLfloat ambient[] = { color[0], color[1], color[2], alpha };
GLfloat diffuse[] = { color[0], color[1], color[2], alpha };
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse);
glTranslatef(particle.X[0],particle.X[1],particle.X[2]);
glRotated(-angle, norm[0], norm[1] ,norm[2]);
glScaled(size[0], size[1], size[2]);
switch (particle.shape){
case C_PARTICLESHAPE_DOT:
glPointSize(size[0]);
glBegin(GL_POINTS);
glVertex3f(0,0,0);
glEnd();
break;
case C_PARTICLESHAPE_SPHERE:
if (drawLines)
glutWireSphere(1, 10, 10);
else
glutSolidSphere(1, 10, 10);
break;
case C_PARTICLESHAPE_BALOON:
if (drawLines)
glutWireSphere(1,10,10);
else
glutSolidSphere(1, 10, 10);
glBegin(GL_LINES);
glVertex3f(0,0,0);
glVertex3f(0,0,-5);
glEnd();
break;
case C_PARTICLESHAPE_CONE:
if (drawLines)
glutWireCone(1,1,10,10);
else
glutSolidCone(1,1,10,10);
break;
case C_PARTICLESHAPE_LEAF:
glRotated(45,0,1,0);
if (drawLines)
{
glTranslated(-0.5,0,0);
glutWireSphere(0.6,10,10);
glTranslated(0,0,0.5);
glutWireCube(1);
glTranslated(0.5,0,0);
glutWireSphere(0.6,10,10);
}
else
{
glTranslated(-0.5,0,0);
glutSolidSphere(0.6,10,10);
glTranslated(0,0,0.5);
glutSolidCube(1);
glTranslated(0.5,0,0);
glutSolidSphere(0.6,10,10);
}
break;
case C_PARTICLESHAPE_TEAPOT:
//Create Display list on first time through, then just render display list...
if( !teapotCreated )
{
teapotCreated = true;
teapotDisplayList = glGenLists(1);
glNewList(teapotDisplayList,GL_COMPILE);
//scale teapot to be about same size as other particle types
glRotated(-90,0,1,0);
if (drawLines)
glutWireTeapot( size[0]*0.3 );
else
glutSolidTeapot( size[0]*0.3 );
glEndList();
}
glCallList(teapotDisplayList);
break;
case C_PARTICLESHAPE_ANT:
drawAnt();
break;
default:
break;
}
glPopMatrix();
}
return true;
}
bool CParticleSystem::init()
{
return true;
}
bool CParticleSystem::gotoFrame(int nFrame)
{
if (nFrame == 0)
{
//ToDo: Restart simulation
}
else if (nFrame == m_nCurFrame)
{
return true;
}
else if (nFrame == m_nCurFrame+1)
{
return calcNextFrame();
}
else if (nFrame == m_nCurFrame-1)
{
return prevFrame();
}
else
{
//ToDo: Jump (if allowed)
}
return false;
}
Point3d CParticleSystem::getLookAtPoint()
{
unsigned int numParticles = (int)m_pCurSystem->size();
Point3d centerOfMass(0,0,0);
for( unsigned int j = 0; j < numParticles; j++ )
{
centerOfMass += (*m_pCurSystem)[j].X;
}
centerOfMass /= numParticles;
return centerOfMass;
// return g_simulationParams.m_cameraDir;
}
#define RAND_POINT Point3d(frand()-0.5, frand()-0.5, frand()-0.5)*0.2
void CParticleSystem::drawAnt()
{
Point3d p;
glScaled(1,1,1.2);
glutSolidSphere(0.5, 10, 10);
glTranslated(0,0,0.65);
glutSolidSphere(0.2, 10, 10);
glBegin(GL_LINES);
glVertex3f(0,0,0);
p = Point3d(0.5,-0.5,0.5);
p += RAND_POINT;
glVertex3f(p[0],p[1],p[2]);
glVertex3f(0,0,0);
p = Point3d(0.5,-0.5,0);
p += RAND_POINT;
glVertex3f(p[0],p[1],p[2]);
glVertex3f(0,0,0);
p = Point3d(0.5,-0.5,-0.5);
p += RAND_POINT;
glVertex3f(p[0],p[1],p[2]);
glVertex3f(0,0,0);
p = Point3d(-0.5,-0.5,0.5);
p += RAND_POINT;
glVertex3f(p[0],p[1],p[2]);
glVertex3f(0,0,0);
p = Point3d(-0.5,-0.5,0);
p += RAND_POINT;
glVertex3f(p[0],p[1],p[2]);
glVertex3f(0,0,0);
p = Point3d(-0.5,-0.5,-0.5);
p += RAND_POINT;
glVertex3f(p[0],p[1],p[2]);
glEnd();
glTranslated(0,0,0.4);
glutSolidSphere(0.3, 10, 10);
glBegin(GL_LINES);
glVertex3f(0,0,0);
glVertex3f(0.2,0.6,0.3);
glVertex3f(0,0,0);
glVertex3f(-0.2,0.6,0.3);
glEnd();
} | [
"itai@c8a6d0be-e207-0410-856a-d97b7f264bab",
"playmobil@c8a6d0be-e207-0410-856a-d97b7f264bab",
"dagan@c8a6d0be-e207-0410-856a-d97b7f264bab"
]
| [
[
[
1,
1
],
[
13,
15
],
[
17,
18
],
[
29,
75
],
[
90,
90
],
[
92,
93
],
[
114,
115
],
[
210,
241
],
[
244,
252
]
],
[
[
2,
3
],
[
8,
10
],
[
78,
81
],
[
89,
89
],
[
102,
109
],
[
179,
187
],
[
193,
198
]
],
[
[
4,
7
],
[
11,
12
],
[
16,
16
],
[
19,
28
],
[
76,
77
],
[
82,
88
],
[
91,
91
],
[
94,
101
],
[
110,
113
],
[
116,
178
],
[
188,
192
],
[
199,
209
],
[
242,
243
],
[
253,
299
]
]
]
|
4d709cd6e1b3d816719476a9ba6ab95e4a6859cb | adac3837d0242936ee697daa7dc2a8ffdf4da08b | /performance/throughput/OpenSplice/C/waitset/qos_file_format.h | 6e96f016e572fad74e63655a4f46b11be0b43da6 | []
| no_license | DOCGroup/DDS_Test | 7fb89d13df0b3fc775f794212b58aa3550620eec | 1f82d597f35ea74d46784e27c8b9bae78370c9fc | refs/heads/master | 2023-07-22T20:43:17.811097 | 2008-10-23T17:37:34 | 2008-10-23T17:37:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,138 | h | // Author: Hieu Nguyen
// June 19th, 2006
#ifndef __QOS_FILE_FORMAT_H
#define __QOS_FILE_FORMAT_H
#include <string>
using std::string;
// Define classes that manage the Qos file's keys naming format.
// To change the format, edit qos_file_format.cpp
namespace QosFormat {
class DomainParticipantQosKeys {
public:
static string get_user_data_key () { return user_data; }
static string get_entity_factory_key () { return entity_factory; }
private:
static const string user_data;
static const string entity_factory;
};
class TopicQosKeys {
public:
static string get_topic_data_key () { return topic_data; }
static string get_durability_kind_key () { return durability_kind; }
static string get_durability_service_cleanup_delay_key () { return durability_service_cleanup_delay; }
static string get_deadline_key () { return deadline; }
static string get_latency_budget_key () { return latency_budget; }
static string get_liveliness_kind_key () { return liveliness_kind; }
static string get_liveliness_lease_duration_key () { return liveliness_lease_duration; }
static string get_reliability_kind_key () { return reliability_kind; }
static string get_reliability_max_blocking_time_key () { return reliability_max_blocking_time; }
static string get_destination_order_key () { return destination_order; }
static string get_history_kind_key () { return history_kind; }
static string get_history_depth_key () { return history_depth; }
static string get_resource_limits_max_samples_key () { return resource_limits_max_samples; }
static string get_resource_limits_max_instances_key () { return resource_limits_max_instances; }
static string get_resource_limits_max_samples_per_instance_key () { return resource_limits_max_samples_per_instance; }
static string get_transport_priority_key () { return transport_priority; }
static string get_lifespan_key () { return lifespan; }
static string get_ownership_key () { return ownership; }
private:
static const string topic_data;
static const string durability_kind;
static const string durability_service_cleanup_delay;
static const string deadline;
static const string latency_budget;
static const string liveliness_kind;
static const string liveliness_lease_duration;
static const string reliability_kind;
static const string reliability_max_blocking_time;
static const string destination_order;
static const string history_kind;
static const string history_depth;
static const string resource_limits_max_samples;
static const string resource_limits_max_instances;
static const string resource_limits_max_samples_per_instance;
static const string transport_priority;
static const string lifespan;
static const string ownership;
};
class PublisherQosKeys {
public:
static string get_presentation_access_scope_key () { return presentation_access_scope; }
static string get_presentation_coherent_access_key () { return presentation_coherent_access; }
static string get_presentation_ordered_access_key () { return presentation_ordered_access; }
static string get_partition_key () { return partition; }
static string get_group_data_key () { return group_data; }
static string get_entity_factory_key () { return entity_factory; }
private:
static const string presentation_access_scope;
static const string presentation_coherent_access;
static const string presentation_ordered_access;
static const string partition;
static const string group_data;
static const string entity_factory;
};
class SubscriberQosKeys {
public:
static string get_presentation_access_scope_key () { return presentation_access_scope; }
static string get_presentation_coherent_access_key () { return presentation_coherent_access; }
static string get_presentation_ordered_access_key () { return presentation_ordered_access; }
static string get_partition_key () { return partition; }
static string get_group_data_key () { return group_data; }
static string get_entity_factory_key () { return entity_factory; }
private:
static const string presentation_access_scope;
static const string presentation_coherent_access;
static const string presentation_ordered_access;
static const string partition;
static const string group_data;
static const string entity_factory;
};
class DataWriterQosKeys {
public:
static string get_durability_kind_key () { return durability_kind; }
static string get_durability_service_cleanup_delay_key () { return durability_service_cleanup_delay; }
static string get_deadline_key () { return deadline; }
static string get_latency_budget_key () { return latency_budget; }
static string get_liveliness_kind_key () { return liveliness_kind; }
static string get_liveliness_lease_duration_key () { return liveliness_lease_duration; }
static string get_reliability_kind_key () { return reliability_kind; }
static string get_reliability_max_blocking_time_key () { return reliability_max_blocking_time; }
static string get_destination_order_key () { return destination_order; }
static string get_history_kind_key () { return history_kind; }
static string get_history_depth_key () { return history_depth; }
static string get_resource_limits_max_samples_key () { return resource_limits_max_samples; }
static string get_resource_limits_max_instances_key () { return resource_limits_max_instances; }
static string get_resource_limits_max_samples_per_instance_key () { return resource_limits_max_samples_per_instance; }
static string get_transport_priority_key () { return transport_priority; }
static string get_lifespan_key () { return lifespan; }
static string get_user_data_key () { return user_data; }
static string get_ownership_strength_key () { return ownership_strength; }
static string get_writer_data_lifecycle_key () { return writer_data_lifecycle; }
private:
static const string durability_kind;
static const string durability_service_cleanup_delay;
static const string deadline;
static const string latency_budget;
static const string liveliness_kind;
static const string liveliness_lease_duration;
static const string reliability_kind;
static const string reliability_max_blocking_time;
static const string destination_order;
static const string history_kind;
static const string history_depth;
static const string resource_limits_max_samples;
static const string resource_limits_max_instances;
static const string resource_limits_max_samples_per_instance;
static const string transport_priority;
static const string lifespan;
static const string user_data;
static const string ownership_strength;
static const string writer_data_lifecycle;
};
class DataReaderQosKeys {
public:
static string get_durability_kind_key () { return durability_kind; }
static string get_durability_service_cleanup_delay_key () { return durability_service_cleanup_delay; }
static string get_deadline_key () { return deadline; }
static string get_latency_budget_key () { return latency_budget; }
static string get_liveliness_kind_key () { return liveliness_kind; }
static string get_liveliness_lease_duration_key () { return liveliness_lease_duration; }
static string get_reliability_kind_key () { return reliability_kind; }
static string get_reliability_max_blocking_time_key () { return reliability_max_blocking_time; }
static string get_destination_order_key () { return destination_order; }
static string get_history_kind_key () { return history_kind; }
static string get_history_depth_key () { return history_depth; }
static string get_resource_limits_max_samples_key () { return resource_limits_max_samples; }
static string get_resource_limits_max_instances_key () { return resource_limits_max_instances; }
static string get_resource_limits_max_samples_per_instance_key () { return resource_limits_max_samples_per_instance; }
static string get_user_data_key () { return user_data; }
static string get_time_based_filter_key () { return time_based_filter; }
static string get_reader_data_lifecycle_key () { return reader_data_lifecycle; }
private:
static const string durability_kind;
static const string durability_service_cleanup_delay;
static const string deadline;
static const string latency_budget;
static const string liveliness_kind;
static const string liveliness_lease_duration;
static const string reliability_kind;
static const string reliability_max_blocking_time;
static const string destination_order;
static const string history_kind;
static const string history_depth;
static const string resource_limits_max_samples;
static const string resource_limits_max_instances;
static const string resource_limits_max_samples_per_instance;
static const string user_data;
static const string time_based_filter;
static const string reader_data_lifecycle;
};
} // end of namespace QosFormat
#endif /* __QOS_FILE_FORMAT_H */
| [
"hnguyen@b83e41e9-5108-4780-9bb0-1723f710b6d8"
]
| [
[
[
1,
200
]
]
]
|
0e2c5c5a4cffd73854021bae2251f5da12af723a | 5c4e36054f0752a610ad149dfd81e6f35ccb37a1 | /libs/src2.75/BulletCollision/CollisionDispatch/btCollisionObject.cpp | 17b31459aafd5df502fc9a5e2e48377601c7823d | []
| no_license | Akira-Hayasaka/ofxBulletPhysics | 4141dc7b6dff7e46b85317b0fe7d2e1f8896b2e4 | 5e45da80bce2ed8b1f12de9a220e0c1eafeb7951 | refs/heads/master | 2016-09-15T23:11:01.354626 | 2011-09-22T04:11:35 | 2011-09-22T04:11:35 | 1,152,090 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,304 | cpp | /*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "btCollisionObject.h"
btCollisionObject::btCollisionObject()
: m_anisotropicFriction(1.f,1.f,1.f),
m_hasAnisotropicFriction(false),
m_contactProcessingThreshold(BT_LARGE_FLOAT),
m_broadphaseHandle(0),
m_collisionShape(0),
m_rootCollisionShape(0),
m_collisionFlags(btCollisionObject::CF_STATIC_OBJECT),
m_islandTag1(-1),
m_companionId(-1),
m_activationState1(1),
m_deactivationTime(btScalar(0.)),
m_friction(btScalar(0.5)),
m_restitution(btScalar(0.)),
m_userObjectPointer(0),
m_internalType(CO_COLLISION_OBJECT),
m_hitFraction(btScalar(1.)),
m_ccdSweptSphereRadius(btScalar(0.)),
m_ccdMotionThreshold(btScalar(0.)),
m_checkCollideWith(false)
{
m_worldTransform.setIdentity();
}
btCollisionObject::~btCollisionObject()
{
}
void btCollisionObject::setActivationState(int newState)
{
if ( (m_activationState1 != DISABLE_DEACTIVATION) && (m_activationState1 != DISABLE_SIMULATION))
m_activationState1 = newState;
}
void btCollisionObject::forceActivationState(int newState)
{
m_activationState1 = newState;
}
void btCollisionObject::activate(bool forceActivation)
{
if (forceActivation || !(m_collisionFlags & (CF_STATIC_OBJECT|CF_KINEMATIC_OBJECT)))
{
setActivationState(ACTIVE_TAG);
m_deactivationTime = btScalar(0.);
}
}
| [
"[email protected]"
]
| [
[
[
1,
68
]
]
]
|
05bebfe02a3675a5a9eca4d6a8b78fb12cce9e54 | 0813282678cb6bb52cd0001a760cfbc24663cfca | /NumberFormat.cpp | af89f7a1608ec85b2880e3e14e2fc72c0b61bf22 | []
| no_license | mannyzhou5/scbuildorder | e3850a86baaa33d1c549c7b89ddab7738b79b3c0 | 2396293ee483e40495590782b652320db8adf530 | refs/heads/master | 2020-04-29T01:01:04.504099 | 2011-04-12T10:00:54 | 2011-04-12T10:00:54 | 33,047,073 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,329 | cpp | #include "stdafx.h"
#include "NumberFormat.h"
CNumberFormat::CNumberFormat()
{
m_format.NumDigits = 0;
m_format.LeadingZero = 0;
m_format.lpDecimalSep = NULL;
m_format.lpThousandSep = NULL;
m_format.NegativeOrder = 0;
m_format.Grouping = 0;
}
CNumberFormat::~CNumberFormat()
{
delete m_format.lpDecimalSep;
delete m_format.lpThousandSep;
}
bool CNumberFormat::LoadDefault(LCID locale /* = LOCALE_USER_DEFAULT */)
{
CString strBuffer;
bool result = true;
int bufferSize;
bufferSize = GetLocaleInfo(locale, LOCALE_IDIGITS, NULL, 0);
if(0 != bufferSize)
{
if(GetLocaleInfo(locale, LOCALE_IDIGITS, strBuffer.GetBuffer(bufferSize), bufferSize))
m_format.NumDigits = wcstoul(strBuffer, NULL, 0);
else
result = false;
strBuffer.ReleaseBuffer();
}
bufferSize = GetLocaleInfo(locale, LOCALE_ILZERO, NULL, 0);
if(0 != bufferSize)
{
if(GetLocaleInfo(locale, LOCALE_ILZERO, strBuffer.GetBuffer(bufferSize), bufferSize))
m_format.LeadingZero = wcstoul(strBuffer, NULL, 0);
else
result = false;
strBuffer.ReleaseBuffer();
}
bufferSize = GetLocaleInfo(locale, LOCALE_SDECIMAL, NULL, 0);
if(0 != bufferSize)
{
delete m_format.lpDecimalSep;
m_format.lpDecimalSep = new WCHAR[bufferSize];
if(!GetLocaleInfo(locale, LOCALE_SDECIMAL, m_format.lpDecimalSep, bufferSize))
{
result = false;
delete m_format.lpDecimalSep;
m_format.lpDecimalSep = 0;
}
}
bufferSize = GetLocaleInfo(locale, LOCALE_STHOUSAND, NULL, 0);
if(0 != bufferSize)
{
delete m_format.lpThousandSep;
m_format.lpThousandSep = new WCHAR[bufferSize];
if(!GetLocaleInfo(locale, LOCALE_STHOUSAND, m_format.lpThousandSep, bufferSize))
{
result = false;
delete m_format.lpThousandSep;
m_format.lpDecimalSep = 0;
}
}
bufferSize = GetLocaleInfo(locale, LOCALE_INEGNUMBER, NULL, 0);
if(0 != bufferSize)
{
if(GetLocaleInfo(locale, LOCALE_INEGNUMBER, strBuffer.GetBuffer(bufferSize), bufferSize))
m_format.NegativeOrder = wcstoul(strBuffer, NULL, 0);
else
result = false;
strBuffer.ReleaseBuffer();
}
bufferSize = GetLocaleInfo(locale, LOCALE_SGROUPING, NULL, 0);
if(0 != bufferSize)
{
if(GetLocaleInfo(locale, LOCALE_SGROUPING, strBuffer.GetBuffer(bufferSize), bufferSize))
{
m_format.Grouping = 0;
for(const WCHAR *c = strBuffer; *c; c++)
{
if(*c >= L'1' && *c <= L'9')
m_format.Grouping = m_format.Grouping * 10 + (*c - L'0');
if(*c != L'0' && !c[1])
m_format.Grouping *= 10;
}
}
else
result = false;
strBuffer.ReleaseBuffer();
}
return result;
}
int CNumberFormat::FormatNumberByLocale(LPCTSTR pszNumber, CString &strFormatted, LCID locale /* = LOCALE_USER_DEFAULT */)
{
int nSize = ::GetNumberFormat(locale, 0, pszNumber, &m_format, NULL, 0);
nSize = ::GetNumberFormat(locale, 0, pszNumber, &m_format, strFormatted.GetBuffer(nSize), nSize);
strFormatted.ReleaseBuffer();
return nSize;
}
int CNumberFormat::FormatNumberByLocale(double dNumber, CString &strFormatted, LCID locale /* = LOCALE_USER_DEFAULT */)
{
CString strNumber;
strNumber.Format(_T("%.2f"), dNumber);
return FormatNumberByLocale(strNumber, strFormatted, locale);
}
| [
"CarbonTwelve.Developer@a0245358-5b9e-171e-63e1-2316ddff5996"
]
| [
[
[
1,
117
]
]
]
|
83b5e30812ee7ef1080dc1bf6ff14c15f04951f8 | 25f79693b806edb9041e3786fa3cf331d6fd4b97 | /src/core/cal/PinnedBuffer.cpp | 7a82e233853404f68176458cabb2c80debb0e27d | []
| no_license | ouj/amd-spl | ff3c9faf89d20b5d6267b7f862c277d16aae9eee | 54b38e80088855f5e118f0992558ab88a7dea5b9 | refs/heads/master | 2016-09-06T03:13:23.993426 | 2009-08-29T08:55:02 | 2009-08-29T08:55:02 | 32,124,284 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,728 | cpp | //////////////////////////////////////////////////////////////////////////
//!
//! \file PinnedBuffer.cpp
//! \date 5:5:2009 15:15
//! \author Shawn Zhou
//!
//! \brief Contains definition of RemoteBuffer class.
//!
//////////////////////////////////////////////////////////////////////////
#include "RuntimeDefs.h"
#include "PinnedBuffer.h"
namespace amdspl
{
namespace core
{
namespace cal
{
//////////////////////////////////////////////////////////////////////////
//!
//! \param format The CAL format of the remote buffer.
//! \param width The width of 1D/2D remote buffer.
//! \param height The height of 2D remote buffer. For 1D remote buffer,
//! this value should be set to zero.
//! \return Constructor
//!
//! \brief Construct the RemoteBuffer object. The object will not be
//! available until RemoteBuffer::initialize() is called.
//!
//////////////////////////////////////////////////////////////////////////
PinnedBuffer::PinnedBuffer(Device *device, CALformat format, unsigned int width, unsigned int height, void *userMem)
: Buffer(format, width, height), _device(device), _mem(userMem)
{
}
//////////////////////////////////////////////////////////////////////////
//!
//! \return Destructor
//!
//! \brief Destroy the RemoteBuffer object.
//!
//////////////////////////////////////////////////////////////////////////
PinnedBuffer::~PinnedBuffer()
{
}
//////////////////////////////////////////////////////////////////////////
//!
//! \return bool True if the remote buffer is initialized successful.
//! False if there is an error during initialization.
//!
//! \brief Initialize the RemoteBuffer object.
//!
//////////////////////////////////////////////////////////////////////////
bool PinnedBuffer::initialize()
{
#ifdef ATI_OS_VISTA
if(((uintptr_t)_mem) & (0xfff)) {
LOG_COMMON_ERROR("memory should be aligned!");
return false;
}
#else
if(((uintptr_t)_mem) & (0xff)) {
LOG_COMMON_ERROR("memory should be aligned!");
return false;
}
#endif
if(!calResCreate2D) {
if( calExtGetProc((CALextproc*)&calResCreate2D, CAL_EXT_RES_CREATE, "calResCreate2D") != CAL_RESULT_OK )
{
LOG_COMMON_ERROR("calGetProc failed\n");
return false;
}
if( calResCreate2D == 0 )
{
LOG_COMMON_ERROR("NULL function pointer. calResCreate2D\n");
return false;
}
}
//TODO: now use float1 as default
unsigned int size = sizeof(float) * _width * _height * 4;
CALresult result = calResCreate2D(&_res, _device->getHandle(), (CALvoid*)_mem,
_width, _height, _dataFormat, CALuint(size), 0);
/*CALresult result = calResCreate2D(&_res, _device->getHandle(), (CALvoid*)_mem,
1024, 1024, CAL_FORMAT_FLOAT_1, CALuint(1024), 0);*/
if(result!= CAL_RESULT_OK)
{
LOG_COMMON_ERROR("calResCreate2D failed. \n");
return false;
}
return true;
}
bool PinnedBuffer::readData(void *ptr, unsigned long size) { return false; }
bool PinnedBuffer::writeData(void *ptr, unsigned long size) { return false; }
}
}
}
| [
"probing@1960d7c4-c739-11dd-8829-37334faa441c"
]
| [
[
[
1,
107
]
]
]
|
9b80587b6c30f1ff3726983e343e79da3d521f6a | cf579692f2e289563160b6a218fa5f1b6335d813 | /XBtool/ColorDlg/MultiMonitor.h | 2f3e256affc2134cc1179ae5ab1d988ad581a09a | []
| no_license | opcow/XBtool | a7451971de3296e1ce5632b0c9d95430f6d3b223 | 718a7fbf87e08c12c0c829dd2e2c0d6cee967cbe | refs/heads/master | 2021-01-16T21:02:17.759102 | 2011-03-09T23:36:54 | 2011-03-09T23:36:54 | 1,461,420 | 8 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 2,268 | h | #pragma once
//////////////////////////////////////////////////
// CMonitor - wrapper to Win32 multi-monitor API
//
// Author: Donald Kackman
// Email: [email protected]
// Copyright 2002, Donald Kackman
//
// You may freely use or modify this code provided this
// Copyright is included in all derived versions.
//
///////////////////////////////////////////////////
//
//David Campbell's article
//How to Exploit Multiple Monitor Support in Memphis and Windows NT 5.0
//is very helpful for multimonitor api calls
//http://www.microsoft.com/msj/defaultframe.asp?page=/msj/0697/monitor/monitor.htm&nav=/msj/0697/newnav.htm
//
//include multimon.h here to get the types
//multimon.cpp includes this with the COMPILESTUBS define to get the implementations
//this is only necessary if the app is supporting win95
#if WINVER < 0x0500
#include "multimon.h"
#endif // WINVER < 0x0500
// CMonitor
class CMonitor : public CObject
{
public:
//construction destruction
CMonitor();
CMonitor( const CMonitor& monitor );
virtual ~CMonitor();
//operations
void Attach( const HMONITOR hMonitor );
HMONITOR Detach();
void ClipRectToMonitor( LPRECT lprc, const BOOL UseWorkAreaRect = FALSE ) const;
void CenterRectToMonitor( LPRECT lprc, const BOOL UseWorkAreaRect = FALSE ) const;
void CenterWindowToMonitor( CWnd* const pWnd, const BOOL UseWorkAreaRect = FALSE ) const;
HDC CreateDC() const;
//properties
void GetMonitorRect( LPRECT lprc ) const;
void GetWorkAreaRect( LPRECT lprc ) const;
void GetName( CString& string ) const;
int GetBitsPerPixel() const;
BOOL IsOnMonitor( const POINT pt ) const;
BOOL IsOnMonitor( const CWnd* pWnd ) const;
BOOL IsOnMonitor( const LPRECT lprc ) const;
BOOL IsPrimaryMonitor() const;
BOOL IsMonitor() const;
//operators
operator HMONITOR() const
{
return this == NULL ? NULL : m_hMonitor;
}
BOOL operator ==( const CMonitor& monitor ) const
{
return m_hMonitor == (HMONITOR)monitor;
}
BOOL operator !=( const CMonitor& monitor ) const
{
return !( *this == monitor );
}
void operator =( const CMonitor& monitor )
{
m_hMonitor = (HMONITOR)monitor;
}
private:
HMONITOR m_hMonitor;
};
| [
"[email protected]"
]
| [
[
[
1,
94
]
]
]
|
15d1a0a5826970ab52b2d6e07def2e824f00b26c | ff5c060273aeafed9f0e5aa7018f371b8b11cdfd | /Codigo/C/Opciones_Armonizacion.h | e5e5c0daa881554c776c97825072b2caabd2455d | []
| no_license | BackupTheBerlios/genaro | bb14efcdb54394e12e56159313151930d8f26d6b | 03e618a4f259cfb991929ee48004b601486d610f | refs/heads/master | 2020-04-20T19:37:21.138816 | 2008-03-25T16:15:16 | 2008-03-25T16:15:16 | 40,075,683 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,180 | h | //---------------------------------------------------------------------------
#ifndef Opciones_ArmonizacionH
#define Opciones_ArmonizacionH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TFormOpcionesArmonizacion : public TForm
{
__published: // IDE-managed Components
TComboBox *ComboBox1;
TLabel *Label1;
TEdit *Edit2;
TEdit *Edit1;
TLabel *Label2;
TLabel *Label3;
TComboBox *ComboBox2;
TLabel *Label4;
TLabel *Label5;
TComboBox *ComboBox3;
TEdit *Edit3;
TEdit *Edit4;
TLabel *Label6;
TLabel *Label7;
void __fastcall ComboBox3Change(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TFormOpcionesArmonizacion(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TFormOpcionesArmonizacion *FormOpcionesArmonizacion;
//---------------------------------------------------------------------------
#endif
| [
"gatchan"
]
| [
[
[
1,
36
]
]
]
|
421681e95e8da5725a6b271e2ea9bf70ede28ed1 | 27d5670a7739a866c3ad97a71c0fc9334f6875f2 | /CPP/Targets/MapLib/Shared/include/MLConfigurator.h | dc49e26558c37c07989b5ec03a3a064fc7880385 | [
"BSD-3-Clause"
]
| permissive | ravustaja/Wayfinder-S60-Navigator | ef506c418b8c2e6498ece6dcae67e583fb8a4a95 | 14d1b729b2cea52f726874687e78f17492949585 | refs/heads/master | 2021-01-16T20:53:37.630909 | 2010-06-28T09:51:10 | 2010-06-28T09:51:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,158 | h | /*
Copyright (c) 1999 - 2010, Vodafone Group Services Ltd
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the Vodafone Group Services Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ML_CONVIGURATOR_H
#define ML_CONVIGURATOR_H
#include "config.h"
/**
* Configuration interface for MapLib functionality.
* All strings are in utf-8.
*/
class MLConfigurator {
public:
/**
* Set the language using the specified iso639 string.
* The string can consist of two or three letters and must be
* NULL terminated.
* @param isoStr The string, containing two or three letters.
* @return The language as iso639 that was set to MapLib.
*/
virtual const char* setLanguageAsISO639( const char* isoStr ) = 0;
/**
* Set the DPI correction factor. The factor 1 corresponds
* a value suitable for phone model with 128 DPI screen.
* For newer devices with displays with higher
* DPI, the factor should be correspond with how many times
* greater the DPI is compared to 128 DPI.
*/
virtual void setDPICorrectionFactor( uint32 factor ) = 0;
// -- Cache handling
/**
* Creates the read/write cache with the supplied max size.
* @param path The path to the cache in utf-8.
* @param maxSize The maximum size of the cache.
*/
virtual int addDiskCache( const char* path,
uint32 maxSize ) = 0;
/**
* Sets the max size of the disk cache if it exists.
* @param nbrBytes The maximum size of the R/W cache in bytes.
*/
virtual int setDiskCacheSize( uint32 nbrBytes ) = 0;
/**
* Clears the R/W disk cache.
*/
virtual int clearDiskCache() = 0;
};
#endif
| [
"[email protected]"
]
| [
[
[
1,
65
]
]
]
|
c4d44a42ebd2c8fd5fd5075d31e482ae9a48f3db | 113b284df51a798c943e36aaa21273e7379391a9 | /VolumeGadget/VolumeControlDLL/VolumeControlDLL.h | 95368d90616468e62e3a2d05473e7cb67833afed | []
| no_license | ccMatrix/desktopgadgets | bf171b75b446faf16443202c06e98c0a4b5eef7c | f5fa36e042ce274910f62e5d3510072ae07acf5e | refs/heads/master | 2020-12-25T19:26:10.514144 | 2010-03-01T23:24:15 | 2010-03-01T23:24:15 | 32,254,664 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 9,301 | h |
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 6.00.0366 */
/* at Mon Nov 19 01:26:25 2007
*/
/* Compiler settings for .\VolumeControlDLL.idl:
Oicf, W1, Zp8, env=Win32 (32b run)
protocol : dce , ms_ext, c_ext, robust
error checks: allocation ref bounds_check enum stub_data
VC __declspec() decoration level:
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
DECLSPEC_UUID(), MIDL_INTERFACE()
*/
//@@MIDL_FILE_HEADING( )
#pragma warning( disable: 4049 ) /* more than 64k source lines */
/* verify that the <rpcndr.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 475
#endif
#include "rpc.h"
#include "rpcndr.h"
#ifndef __RPCNDR_H_VERSION__
#error this stub requires an updated version of <rpcndr.h>
#endif // __RPCNDR_H_VERSION__
#ifndef COM_NO_WINDOWS_H
#include "windows.h"
#include "ole2.h"
#endif /*COM_NO_WINDOWS_H*/
#ifndef __VolumeControlDLL_h__
#define __VolumeControlDLL_h__
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
/* Forward Declarations */
#ifndef __IVolumeControl_FWD_DEFINED__
#define __IVolumeControl_FWD_DEFINED__
typedef interface IVolumeControl IVolumeControl;
#endif /* __IVolumeControl_FWD_DEFINED__ */
#ifndef __VolumeControl_FWD_DEFINED__
#define __VolumeControl_FWD_DEFINED__
#ifdef __cplusplus
typedef class VolumeControl VolumeControl;
#else
typedef struct VolumeControl VolumeControl;
#endif /* __cplusplus */
#endif /* __VolumeControl_FWD_DEFINED__ */
/* header files for imported files */
#include "oaidl.h"
#include "ocidl.h"
#ifdef __cplusplus
extern "C"{
#endif
void * __RPC_USER MIDL_user_allocate(size_t);
void __RPC_USER MIDL_user_free( void * );
#ifndef __IVolumeControl_INTERFACE_DEFINED__
#define __IVolumeControl_INTERFACE_DEFINED__
/* interface IVolumeControl */
/* [unique][helpstring][nonextensible][dual][uuid][object] */
EXTERN_C const IID IID_IVolumeControl;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("C28FF508-8AC3-4580-BD8A-9A3C3344CF1A")
IVolumeControl : public IDispatch
{
public:
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getVolume(
/* [retval][out] */ DWORD *volume) = 0;
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setVolume(
/* [in] */ SHORT *volume) = 0;
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE toggleMute( void) = 0;
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE isMute(
/* [retval][out] */ SHORT *ismute) = 0;
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE isWinVista(
/* [retval][out] */ BYTE *vista) = 0;
};
#else /* C style interface */
typedef struct IVolumeControlVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
IVolumeControl * This,
/* [in] */ REFIID riid,
/* [iid_is][out] */ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
IVolumeControl * This);
ULONG ( STDMETHODCALLTYPE *Release )(
IVolumeControl * This);
HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )(
IVolumeControl * This,
/* [out] */ UINT *pctinfo);
HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )(
IVolumeControl * This,
/* [in] */ UINT iTInfo,
/* [in] */ LCID lcid,
/* [out] */ ITypeInfo **ppTInfo);
HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )(
IVolumeControl * This,
/* [in] */ REFIID riid,
/* [size_is][in] */ LPOLESTR *rgszNames,
/* [in] */ UINT cNames,
/* [in] */ LCID lcid,
/* [size_is][out] */ DISPID *rgDispId);
/* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )(
IVolumeControl * This,
/* [in] */ DISPID dispIdMember,
/* [in] */ REFIID riid,
/* [in] */ LCID lcid,
/* [in] */ WORD wFlags,
/* [out][in] */ DISPPARAMS *pDispParams,
/* [out] */ VARIANT *pVarResult,
/* [out] */ EXCEPINFO *pExcepInfo,
/* [out] */ UINT *puArgErr);
/* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *getVolume )(
IVolumeControl * This,
/* [retval][out] */ DWORD *volume);
/* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *setVolume )(
IVolumeControl * This,
/* [in] */ SHORT *volume);
/* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *toggleMute )(
IVolumeControl * This);
/* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *isMute )(
IVolumeControl * This,
/* [retval][out] */ SHORT *ismute);
/* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *isWinVista )(
IVolumeControl * This,
/* [retval][out] */ BYTE *vista);
END_INTERFACE
} IVolumeControlVtbl;
interface IVolumeControl
{
CONST_VTBL struct IVolumeControlVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define IVolumeControl_QueryInterface(This,riid,ppvObject) \
(This)->lpVtbl -> QueryInterface(This,riid,ppvObject)
#define IVolumeControl_AddRef(This) \
(This)->lpVtbl -> AddRef(This)
#define IVolumeControl_Release(This) \
(This)->lpVtbl -> Release(This)
#define IVolumeControl_GetTypeInfoCount(This,pctinfo) \
(This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)
#define IVolumeControl_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \
(This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)
#define IVolumeControl_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \
(This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)
#define IVolumeControl_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \
(This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
#define IVolumeControl_getVolume(This,volume) \
(This)->lpVtbl -> getVolume(This,volume)
#define IVolumeControl_setVolume(This,volume) \
(This)->lpVtbl -> setVolume(This,volume)
#define IVolumeControl_toggleMute(This) \
(This)->lpVtbl -> toggleMute(This)
#define IVolumeControl_isMute(This,ismute) \
(This)->lpVtbl -> isMute(This,ismute)
#define IVolumeControl_isWinVista(This,vista) \
(This)->lpVtbl -> isWinVista(This,vista)
#endif /* COBJMACROS */
#endif /* C style interface */
/* [helpstring][id] */ HRESULT STDMETHODCALLTYPE IVolumeControl_getVolume_Proxy(
IVolumeControl * This,
/* [retval][out] */ DWORD *volume);
void __RPC_STUB IVolumeControl_getVolume_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring][id] */ HRESULT STDMETHODCALLTYPE IVolumeControl_setVolume_Proxy(
IVolumeControl * This,
/* [in] */ SHORT *volume);
void __RPC_STUB IVolumeControl_setVolume_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring][id] */ HRESULT STDMETHODCALLTYPE IVolumeControl_toggleMute_Proxy(
IVolumeControl * This);
void __RPC_STUB IVolumeControl_toggleMute_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring][id] */ HRESULT STDMETHODCALLTYPE IVolumeControl_isMute_Proxy(
IVolumeControl * This,
/* [retval][out] */ SHORT *ismute);
void __RPC_STUB IVolumeControl_isMute_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring][id] */ HRESULT STDMETHODCALLTYPE IVolumeControl_isWinVista_Proxy(
IVolumeControl * This,
/* [retval][out] */ BYTE *vista);
void __RPC_STUB IVolumeControl_isWinVista_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
#endif /* __IVolumeControl_INTERFACE_DEFINED__ */
#ifndef __VolumeControlDLLLib_LIBRARY_DEFINED__
#define __VolumeControlDLLLib_LIBRARY_DEFINED__
/* library VolumeControlDLLLib */
/* [helpstring][version][uuid] */
EXTERN_C const IID LIBID_VolumeControlDLLLib;
EXTERN_C const CLSID CLSID_VolumeControl;
#ifdef __cplusplus
class DECLSPEC_UUID("5A409F51-AFFA-4096-95CB-FC4839C96B88")
VolumeControl;
#endif
#endif /* __VolumeControlDLLLib_LIBRARY_DEFINED__ */
/* Additional Prototypes for ALL interfaces */
/* end of Additional Prototypes */
#ifdef __cplusplus
}
#endif
#endif
| [
"codename.matrix@e00a1d1f-563d-0410-a555-bbce3309907e"
]
| [
[
[
1,
323
]
]
]
|
019b5362f953b7732f38463969b3a9b27ffd49c2 | 5c4e36054f0752a610ad149dfd81e6f35ccb37a1 | /libs/src2.75/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h | f7ad0964d53abb02e9ecbe5e1b0b81bb6d6b5ffe | []
| no_license | Akira-Hayasaka/ofxBulletPhysics | 4141dc7b6dff7e46b85317b0fe7d2e1f8896b2e4 | 5e45da80bce2ed8b1f12de9a220e0c1eafeb7951 | refs/heads/master | 2016-09-15T23:11:01.354626 | 2011-09-22T04:11:35 | 2011-09-22T04:11:35 | 1,152,090 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,966 | h | /*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
#define SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
#include "btConstraintSolver.h"
class btIDebugDraw;
#include "btContactConstraint.h"
#include "btSolverBody.h"
#include "btSolverConstraint.h"
#include "btTypedConstraint.h"
#include "BulletCollision/NarrowPhaseCollision/btManifoldPoint.h"
///The btSequentialImpulseConstraintSolver is a fast SIMD implementation of the Projected Gauss Seidel (iterative LCP) method.
class btSequentialImpulseConstraintSolver : public btConstraintSolver
{
protected:
btAlignedObjectArray<btSolverBody> m_tmpSolverBodyPool;
btConstraintArray m_tmpSolverContactConstraintPool;
btConstraintArray m_tmpSolverNonContactConstraintPool;
btConstraintArray m_tmpSolverContactFrictionConstraintPool;
btAlignedObjectArray<int> m_orderTmpConstraintPool;
btAlignedObjectArray<int> m_orderFrictionConstraintPool;
btAlignedObjectArray<btTypedConstraint::btConstraintInfo1> m_tmpConstraintSizesPool;
btSolverConstraint& addFrictionConstraint(const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation);
///m_btSeed2 is used for re-arranging the constraint rows. improves convergence/quality of friction
unsigned long m_btSeed2;
void initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject);
btScalar restitutionCurve(btScalar rel_vel, btScalar restitution);
void convertContact(btPersistentManifold* manifold,const btContactSolverInfo& infoGlobal);
void resolveSplitPenetrationSIMD(
btSolverBody& body1,
btSolverBody& body2,
const btSolverConstraint& contactConstraint);
void resolveSplitPenetrationImpulseCacheFriendly(
btSolverBody& body1,
btSolverBody& body2,
const btSolverConstraint& contactConstraint);
//internal method
int getOrInitSolverBody(btCollisionObject& body);
void resolveSingleConstraintRowGeneric(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& contactConstraint);
void resolveSingleConstraintRowGenericSIMD(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& contactConstraint);
void resolveSingleConstraintRowLowerLimit(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& contactConstraint);
void resolveSingleConstraintRowLowerLimitSIMD(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& contactConstraint);
public:
btSequentialImpulseConstraintSolver();
virtual ~btSequentialImpulseConstraintSolver();
virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher);
btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
///clear internal cached data and reset random seed
virtual void reset();
unsigned long btRand2();
int btRandInt2 (int n);
void setRandSeed(unsigned long seed)
{
m_btSeed2 = seed;
}
unsigned long getRandSeed() const
{
return m_btSeed2;
}
};
#ifndef BT_PREFER_SIMD
typedef btSequentialImpulseConstraintSolver btSequentialImpulseConstraintSolverPrefered;
#endif
#endif //SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
| [
"[email protected]"
]
| [
[
[
1,
107
]
]
]
|
917d13c6946df7a7b13e6f2852aaf5bb51fe5b88 | 80716d408715377e88de1fc736c9204b87a12376 | /OnSipInstall/OnSipInstallDLL/stdafx.cpp | 321e78223b7a81d3b6c9789371bb56cb2b85ea86 | []
| no_license | junction/jn-tapi | b5cf4b1bb010d696473cabcc3d5950b756ef37e9 | a2ef6c91c9ffa60739ecee75d6d58928f4a5ffd4 | refs/heads/master | 2021-03-12T23:38:01.037779 | 2011-03-10T01:08:40 | 2011-03-10T01:08:40 | 199,317 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 299 | cpp | // stdafx.cpp : source file that includes just the standard includes
// OnSipInstall.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
| [
"Ron@.(none)"
]
| [
[
[
1,
8
]
]
]
|
4bb71cf1c76d66b3afdbd1bede591f37bfdcbb3b | ccc9aade4c4f509043e41106028060007c20588b | /CppSQLite3.h | a53632a111802f4e540c5b742bd4452104a638ab | []
| no_license | bygreencn/CppSQLite | 7c3a119def25902a8993dbfaf4b5618e2d83a54f | 37884db62dec9cbe6bcf44dd41be74203ee323a1 | refs/heads/master | 2021-01-16T17:42:24.588456 | 2011-02-13T22:12:38 | 2011-02-13T22:12:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,907 | h | /*
* CppSQLite
* Developed by Rob Groves <[email protected]>
* Maintained by NeoSmart Technologies <http://neosmart.net/>
* See LICENSE file for copyright and license info
*/
#ifndef _CppSQLite3_H_
#define _CppSQLite3_H_
#include "sqlite3.h"
#include <cstdio>
#include <cstring>
#define CPPSQLITE_ERROR 1000
class CppSQLite3Exception
{
public:
CppSQLite3Exception(const int nErrCode,
char* szErrMess,
bool bDeleteMsg=true);
CppSQLite3Exception(const CppSQLite3Exception& e);
virtual ~CppSQLite3Exception();
const int errorCode() { return mnErrCode; }
const char* errorMessage() { return mpszErrMess; }
static const char* errorCodeAsString(int nErrCode);
private:
int mnErrCode;
char* mpszErrMess;
};
class CppSQLite3Buffer
{
public:
CppSQLite3Buffer();
~CppSQLite3Buffer();
const char* format(const char* szFormat, ...);
operator const char*() { return mpBuf; }
void clear();
private:
char* mpBuf;
};
class CppSQLite3Binary
{
public:
CppSQLite3Binary();
~CppSQLite3Binary();
void setBinary(const unsigned char* pBuf, int nLen);
void setEncoded(const unsigned char* pBuf);
const unsigned char* getEncoded();
const unsigned char* getBinary();
int getBinaryLength();
unsigned char* allocBuffer(int nLen);
void clear();
private:
unsigned char* mpBuf;
int mnBinaryLen;
int mnBufferLen;
int mnEncodedLen;
bool mbEncoded;
};
class CppSQLite3Query
{
public:
CppSQLite3Query();
CppSQLite3Query(const CppSQLite3Query& rQuery);
CppSQLite3Query(sqlite3* pDB,
sqlite3_stmt* pVM,
bool bEof,
bool bOwnVM=true);
CppSQLite3Query& operator=(const CppSQLite3Query& rQuery);
virtual ~CppSQLite3Query();
int numFields();
int fieldIndex(const char* szField);
const char* fieldName(int nCol);
const char* fieldDeclType(int nCol);
int fieldDataType(int nCol);
const char* fieldValue(int nField);
const char* fieldValue(const char* szField);
int getIntField(int nField, int nNullValue=0);
int getIntField(const char* szField, int nNullValue=0);
double getFloatField(int nField, double fNullValue=0.0);
double getFloatField(const char* szField, double fNullValue=0.0);
const char* getStringField(int nField, const char* szNullValue="");
const char* getStringField(const char* szField, const char* szNullValue="");
const unsigned char* getBlobField(int nField, int& nLen);
const unsigned char* getBlobField(const char* szField, int& nLen);
bool fieldIsNull(int nField);
bool fieldIsNull(const char* szField);
bool eof();
void nextRow();
void finalize();
private:
void checkVM();
sqlite3* mpDB;
sqlite3_stmt* mpVM;
bool mbEof;
int mnCols;
bool mbOwnVM;
};
class CppSQLite3Table
{
public:
CppSQLite3Table();
CppSQLite3Table(const CppSQLite3Table& rTable);
CppSQLite3Table(char** paszResults, int nRows, int nCols);
virtual ~CppSQLite3Table();
CppSQLite3Table& operator=(const CppSQLite3Table& rTable);
int numFields();
int numRows();
const char* fieldName(int nCol);
const char* fieldValue(int nField);
const char* fieldValue(const char* szField);
int getIntField(int nField, int nNullValue=0);
int getIntField(const char* szField, int nNullValue=0);
double getFloatField(int nField, double fNullValue=0.0);
double getFloatField(const char* szField, double fNullValue=0.0);
const char* getStringField(int nField, const char* szNullValue="");
const char* getStringField(const char* szField, const char* szNullValue="");
bool fieldIsNull(int nField);
bool fieldIsNull(const char* szField);
void setRow(int nRow);
void finalize();
private:
void checkResults();
int mnCols;
int mnRows;
int mnCurrentRow;
char** mpaszResults;
};
class CppSQLite3Statement
{
public:
CppSQLite3Statement();
CppSQLite3Statement(const CppSQLite3Statement& rStatement);
CppSQLite3Statement(sqlite3* pDB, sqlite3_stmt* pVM);
virtual ~CppSQLite3Statement();
CppSQLite3Statement& operator=(const CppSQLite3Statement& rStatement);
int execDML();
CppSQLite3Query execQuery();
void bind(int nParam, const char* szValue);
void bind(int nParam, const int nValue);
void bind(int nParam, const long long nValue);
void bind(int nParam, const double dwValue);
void bind(int nParam, const unsigned char* blobValue, int nLen);
void bindNull(int nParam);
void reset();
void finalize();
private:
void checkDB();
void checkVM();
sqlite3* mpDB;
sqlite3_stmt* mpVM;
};
class CppSQLite3DB
{
public:
CppSQLite3DB();
virtual ~CppSQLite3DB();
void open(const char* szFile);
void close();
bool tableExists(const char* szTable);
int execDML(const char* szSQL);
CppSQLite3Query execQuery(const char* szSQL);
int execScalar(const char* szSQL);
CppSQLite3Table getTable(const char* szSQL);
CppSQLite3Statement compileStatement(const char* szSQL);
sqlite_int64 lastRowId();
void interrupt() { sqlite3_interrupt(mpDB); }
void setBusyTimeout(int nMillisecs);
static const char* SQLiteVersion() { return SQLITE_VERSION; }
private:
CppSQLite3DB(const CppSQLite3DB& db);
CppSQLite3DB& operator=(const CppSQLite3DB& db);
sqlite3_stmt* compile(const char* szSQL);
void checkDB();
sqlite3* mpDB;
int mnBusyTimeoutMs;
};
#endif
| [
"[email protected]"
]
| [
[
[
1,
287
]
]
]
|
f94d8236fcaae3a1a218e77b4def33833cd2400e | bfdfb7c406c318c877b7cbc43bc2dfd925185e50 | /engine/hayat.cpp | 39110bc26f66c654481d692046703bfd1eac0028 | [
"MIT"
]
| permissive | ysei/Hayat | 74cc1e281ae6772b2a05bbeccfcf430215cb435b | b32ed82a1c6222ef7f4bf0fc9dedfad81280c2c0 | refs/heads/master | 2020-12-11T09:07:35.606061 | 2011-08-01T12:38:39 | 2011-08-01T12:38:39 | null | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 3,379 | cpp | /* -*- coding: sjis-dos; -*- */
/*
* copyright 2010 FUKUZAWA Tadashi. All rights reserved.
*/
#include "hayat.h"
using namespace Hayat;
using namespace Hayat::Engine;
// stdlibのffiテーブル
EXTERN_BYTECODE_FFI(stdlib);
// メモリ、GC等初期化
void
Engine::initMemory(void* pMemory, size_t memorySize)
{
Common::MemPool::initGMemPool(pMemory, memorySize);
gCodeManager.initialize();
gGlobalVar.initialize();
GC::initialize();
ThreadManager::firstOfAll();
gThreadManager.initialize();
HClass::initializeRootFfiTable();
}
// stdlib初期化
// バイトコードは内部で管理されるので、最後のfinalizeも内部で行なわれる
void
Engine::initStdlib(const char* stdlibPath)
{
LINK_BYTECODE_FFI(stdlib);
Bytecode* stdlibBytecode = gCodeManager.readBytecode(stdlibPath);
HMD_ASSERT(stdlibBytecode != NULL);
Value::initStdlib(*stdlibBytecode); // 標準値初期化
Context* saveContext = VM::getContext();
Context* context = gCodeManager.createContext();
stdlibBytecode->initLinkBytecode(context, true); // 初期化実行
gCodeManager.releaseContext(context);
VM::setContext(saveContext);
delete context; // stdlibの初期化ではContextが他から参照される事はない
}
// ライブラリ類バイトコード読み込み、初期化
// バイトコードは内部で管理されるので、最後のfinalizeも内部で行なわれる
SymbolID_t
Engine::readLibrary(const char* filename)
{
Bytecode* pBytecode = gCodeManager.readBytecode(filename);
Context* saveContext = VM::getContext();
Context* context = gCodeManager.createContext();
pBytecode->initLinkBytecode(context, true); // 初期化
VM::setContext(saveContext);
gCodeManager.releaseContext(context);
return pBytecode->bytecodeSymbol();
}
// バイトコードの先頭から、スレッドで開始
ThreadID_t
Engine::startThread(Bytecode* pBytecode)
{
ThreadID_t tid = gThreadManager.createThread();
Thread* pThread = gThreadManager.id2thread(tid);
Context* context = gCodeManager.createContext();
pBytecode->initLinkBytecode(context, false);
context->canSubstConst = true;
context->callBytecodeTop(pBytecode);
pThread->initialize(context);
pThread->start();
gCodeManager.releaseContext(context);
return tid;
}
// スレッド強制終了
void
Engine::terminateThread(ThreadID_t tid)
{
Thread* pThread = gThreadManager.id2thread(tid);
if (pThread) pThread->terminate();
}
// 後始末
void
Engine::finalizeAll(void)
{
GC::finalize();
gThreadManager.finalize();
gCodeManager.finalize();
HClass::finalizeRootFfiTable();
// gSymbolTable.finalize();
Value::destroyStdlib();
}
void
Engine::initializeDebug(void* debugMemory, size_t debugMemorySize)
{
if (debugMemory == NULL || debugMemorySize == 0)
return;
Debug::setDebugMemPool(MemPool::manage(debugMemory, debugMemorySize));
// バイトコードのデバッグ情報(*.hdb)読み込み設定をデフォルトでtrueに
Hayat::Engine::Bytecode::setFlagReadDebugInfo(true);
MMes::initialize();
}
void
Engine::finalizeDebug(void)
{
MMes::finalize();
gSymbolTable.finalize();
}
| [
"[email protected]"
]
| [
[
[
1,
121
]
]
]
|
142ad6f523e1876120776c7a5219af212883474d | 8bbbcc2bd210d5608613c5c591a4c0025ac1f06b | /nes/mapper/097.cpp | 56da98854c7d327ca6a4b784a479a93d1196de85 | []
| no_license | PSP-Archive/NesterJ-takka | 140786083b1676aaf91d608882e5f3aaa4d2c53d | 41c90388a777c63c731beb185e924820ffd05f93 | refs/heads/master | 2023-04-16T11:36:56.127438 | 2008-12-07T01:39:17 | 2008-12-07T01:39:17 | 357,617,280 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 981 | cpp | #ifdef _NES_MAPPER_CPP_
/////////////////////////////////////////////////////////////////////
// Mapper 97
void NES_mapper97_Init()
{
g_NESmapper.Reset = NES_mapper97_Reset;
g_NESmapper.MemoryWrite = NES_mapper97_MemoryWrite;
}
void NES_mapper97_Reset()
{
// set CPU bank pointers
g_NESmapper.set_CPU_banks4(g_NESmapper.num_8k_ROM_banks-2,g_NESmapper.num_8k_ROM_banks-1,0,1);
// set PPU bank pointers ?
if(g_NESmapper.num_1k_VROM_banks)
{
g_NESmapper.set_PPU_banks8(0,1,2,3,4,5,6,7);
}
}
void NES_mapper97_MemoryWrite(uint32 addr, uint8 data)
{
if(addr < 0xC000)
{
uint8 prg_bank = data & 0x0F;
g_NESmapper.set_CPU_bank6(prg_bank*2+0);
g_NESmapper.set_CPU_bank7(prg_bank*2+1);
if((data & 0x80) == 0)
{
g_NESmapper.set_mirroring2(NES_PPU_MIRROR_HORIZ);
}
else
{
g_NESmapper.set_mirroring2(NES_PPU_MIRROR_VERT);
}
}
}
/////////////////////////////////////////////////////////////////////
#endif
| [
"takka@e750ed6d-7236-0410-a570-cc313d6b6496"
]
| [
[
[
1,
44
]
]
]
|
644f7ce901c79270e345f303f1011bd72e313693 | fcf03ead74f6dc103ec3b07ffe3bce81c820660d | /AppServices/timezonelocalization/TZLocExample.cpp | e07b6fef1d85ff02f3e1fb07fb825801f28c4cf9 | []
| 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 | 5,836 | cpp | // TZLocExample.cpp
//
// Copyright (c) 2005 Symbian Software Ltd. All rights reserved.
// This examples demonstrates using the TimeZone Localization API
// (CTzLocalizer and associated classes) to retrieve a list of time zones
// and to get information about a particular time zone. It adds a city
// to a time zone/city group.
#include <e32base.h>
#include <e32cons.h>
#include <TzLocalizer.h>
#include <TzLocalizationDataTypes.h>
// local definitions
static CConsoleBase* console;
static CTzLocalizer* localizer;
static TInt timeZoneId;
static TInt cityGroupId;
// length of buffer to hold city name
const TInt KMaxCityBufLength = 26;
// strings for display
_LIT(KConsoleNewLine,"\n");
_LIT(KMsgPressAnyKey,"\n\nPress any key to continue\n");
// Sort and print out all time zones
static void GetAllTimeZonesL()
{
// Use standard names in alphabetical order
CTzLocalizedTimeZoneArray* timeZones = localizer->GetAllTimeZonesL(CTzLocalizer::ETzAlphaStandardNameAscending);
TInt count= timeZones->Count();
_LIT(KConsoleMessage,"\nAll timezones:");
console->Printf(KConsoleMessage);
for(TInt i=0; i<count; ++i)
{
TPtrC temp(timeZones->At(i).StandardName());
// if the time zone has a standard name, print it and the short name
if ((&temp)->Length()!=0)
{
console->Printf(KConsoleNewLine);
console->Printf(temp);
_LIT(KConsoleTab,"\t");
console->Printf(KConsoleTab);
console->Printf(timeZones->At(i).ShortStandardName());
}
}
delete timeZones;
console->Printf(KMsgPressAnyKey);
console->Getch();
}
// Add a city to a specific time zone and city group
static void AddCityL()
{
// Add the new city to the same time zone and city group as London
_LIT(KCityName,"London");
TBufC<KMaxCityBufLength> cityBuf(KCityName);
TPtrC cityName(cityBuf);
// First, find the time zone and city group that London is in
CTzLocalizedCity* city=localizer->FindCityByNameL(cityName);
if (!city)
// city doesn't exist
User::Leave(KErrNotFound);
// Get the city's time zone ID and city group ID
timeZoneId = city->TimeZoneId();
cityGroupId = city->GroupId();
delete city;
// Now add the new city to that time zone/city group.
// First check it is not already present
CTzLocalizedCityArray* cities=localizer->GetCitiesL(timeZoneId);
CleanupStack::PushL(cities);
_LIT(KNewCityName,"Cambridge");
TBufC<KMaxCityBufLength> newCityBuf(KNewCityName);
TPtrC newCityName(newCityBuf);
TBool present=EFalse;
CTzLocalizedCity* temp;
// (AddCityL() leaves if the city has already been added, so trap the leave)
TRAPD(err,temp=localizer->AddCityL(timeZoneId,newCityName,cityGroupId));
// Ignore return value
if (err==KErrNone)
delete temp;
CleanupStack::PopAndDestroy(cities);
}
// print out all the cities in the time zone
static void GetCitiesInTimeZoneL()
{
CTzLocalizedCityArray* tzCities=localizer->GetCitiesL(timeZoneId);
CleanupStack::PushL(tzCities);
// get the standard name of the time zone and print it
CTzLocalizedTimeZone* tz = localizer->GetLocalizedTimeZoneL(timeZoneId);
_LIT(KConsoleMessage,"\nThe cities in the %S time zone are :");
TPtrC tzName = tz->StandardName();
console->Printf(KConsoleMessage,&tzName);
delete tz;
TInt tzCount=tzCities->Count();
for(TInt i=0; i<tzCount; ++i)
{
console->Printf(KConsoleNewLine);
console->Printf(tzCities->At(i).Name());
}
CleanupStack::PopAndDestroy(tzCities);
console->Printf(KMsgPressAnyKey);
console->Getch();
}
// print out all the cities in the city group
static void GetCitiesInGroupL()
{
CTzLocalizedCityArray* groupCities = localizer->GetCitiesInGroupL(cityGroupId);
CleanupStack::PushL(groupCities);
// get the city group name
CTzLocalizedCityGroup* cityGroup=localizer->GetCityGroupL(cityGroupId);
_LIT(KConsoleMessage,"\nThe cities in the %S city group are :");
TPtrC groupName = cityGroup->Name();
console->Printf(KConsoleMessage,&groupName);
delete cityGroup;
TInt groupCount=groupCities->Count();
for(TInt i=0; i<groupCount; ++i)
{
console->Printf(KConsoleNewLine);
console->Printf(groupCities->At(i).Name());
}
CleanupStack::PopAndDestroy(groupCities);
}
static void LocalizeTimeZonesL()
{
// Create an instance of CTzLocalizer
localizer = CTzLocalizer::NewL();
CleanupStack::PushL(localizer);
GetAllTimeZonesL();
AddCityL();
GetCitiesInTimeZoneL();
GetCitiesInGroupL();
CleanupStack::PopAndDestroy(localizer);
}
static void DoExampleL()
{
// Create the console to print the messages to.
_LIT(KConsoleMessageDisplay, "Time zone localisation example");
_LIT(KConsoleStars,"\n*************************\n");
console = Console::NewL(KConsoleMessageDisplay,TSize(KConsFullScreen,KConsFullScreen));
CleanupStack::PushL(console);
console->Printf(KConsoleMessageDisplay);
console->Printf(KConsoleStars);
TRAPD(err,LocalizeTimeZonesL());
if (err)
{
_LIT(KFailed,"\n\nExample failed: leave code=%d");
console->Printf(KFailed, err);
}
// wait for user to press a key before destroying console
console->Printf(KMsgPressAnyKey);
console->Getch();
CleanupStack::PopAndDestroy(console);
}
// Standard entry point function
TInt E32Main()
{
__UHEAP_MARK;
// Active scheduler required as this is a console app
CActiveScheduler* scheduler=new CActiveScheduler;
// If active scheduler has been created, install it.
if (scheduler)
{
CActiveScheduler::Install(scheduler);
// Cleanup stack needed
CTrapCleanup* cleanup=CTrapCleanup::New();
if (cleanup)
{
TRAP_IGNORE(DoExampleL());
delete cleanup;
}
delete scheduler;
}
__UHEAP_MARKEND;
return KErrNone;
}
| [
"liuxk99@bdc341c6-17c0-11de-ac9f-1d9250355bca"
]
| [
[
[
1,
197
]
]
]
|
37adc5756b3286643b9631ece4c7795a91a1290b | e7c45d18fa1e4285e5227e5984e07c47f8867d1d | /SMDK/Alcan/AlcanUsr/HyprodClassif.cpp | eae62ac1ce776d4cf267d79c0809695fffb50352 | []
| 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 | WINDOWS-1250 | C++ | false | false | 28,097 | cpp | //===========================================================================
//=== SysCAD SMDK - Hyprod Precipitator Model 2003 : Alcan, Kenwalt ===
//===========================================================================
#include "stdafx.h"
#define __HYPRODCLASSIF_CPP
#include "hyprodclassif.h"
#include "math.h"
#if ForceOptimizeOff
#pragma optimize("", off)
#endif
//====================================================================================
const int idFeed=0;
const int idOverflow=1;
const int idUnderflow=2;
static MInOutDefStruct s_IODefs[]=
{
// Desc; Name; Id; Rqd; Max; CnId, FracHgt; Options;
{ "Feed", "Feed", idFeed, 1, 10, 0, 1.0f, MIO_In |MIO_Material},
{ "Overflow", "Overflow", idOverflow, 1, 1, 0, 1.0f, MIO_Out|MIO_Material},
{ "Underflow", "Underflow", idUnderflow, 1, 1, 0, 0.0f, MIO_Out|MIO_Material},
{ NULL },
};
static double ClassifierDraw[] = { MDrw_Poly, -6,6, -6,2, 0,-8, 6,2, 6,6, -6,6,
MDrw_End};
//---------------------------------------------------------------------------
DEFINE_SURGE_UNIT(Classifier, "Classif", DLL_GroupName)
void Classifier_UnitDef::GetOptions()
{
SetDefaultTag("CL", true);
SetDrawing("SizeSeparation", ClassifierDraw);
SetTreeDescription("Process:Unit:Alcan Classifier");
SetDescription("Alcan Classifier based on Hyprod model");
SetModelSolveMode(MSolveMode_Probal);
SetModelGroup(MGroup_Alumina);
SetModelLicense(MLicense_HeatExchange|MLicense_Alumina|MLicense_Alcan);
};
//---------------------------------------------------------------------------
Classifier::Classifier(MUnitDefBase * pUnitDef, TaggedObject * pNd) : MBaseMethod(pUnitDef, pNd)
{
//default values...
m_bOn = 1;
m_bPrecipOn = 1;
m_bBrentSolverSelected =1;
m_eModel = eMdl_Gravity;
m_eInputMethod = eIM_CutSize,
m_eSharpEqn = eSE_Lynch;
m_dD50 = 0.00005;
m_dSharpness = 4.0;
m_dRqdUFSolidsConc = 700.0;
m_dRqdRecoveryFrac = 0.5;
m_dRqdUFVolFlow = 2.77777777777e-4;// 100 m3/h
m_dRqdOFSolidsTons = 10.0/3.6; //kg/s
m_dDiameter = 10.0;
m_dHindSettlFac = 1.0;
m_dRf = 0.25;
m_dUFSolidsConc = 0.0;
m_dUFVolFlow = 0.0;
m_dOFSolidsConc = 0.0;
m_dOFVolFlow = 0.0;
m_dOFSolidsTons = 0.0;
m_dCalcRecoveryFrac = m_dRqdRecoveryFrac;
m_dRqdRecoveryFracUsed = m_dRqdRecoveryFrac;
m_dD50Used = m_dD50;
}
//---------------------------------------------------------------------------
void Classifier::Init()
{
SetIODefinition(s_IODefs);
}
const int idDX_Version = 1;
//---------------------------------------------------------------------------
void Classifier::BuildDataFields()
{
static MDDValueLst DDModels[]=
{
{eMdl_Gravity, "Gravity Classifier"},
{eMdl_Cyclone, "Cyclone"},
{0}
};
static MDDValueLst DDInputMethods[]=
{
{eIM_CutSize, "Cut Size"},
{eIM_Recovery, "Recovery"},
{eIM_Underflow,"Underflow"},
{eIM_Overflow, "Overflow"},
{eIM_Model, "Model"},
{0}
};
static MDDValueLst DDSharpEqn[]=
{
{eSE_Lynch, "Lynch"},
{eSE_Plitt, "Plitt"},
{0}
};
static MDDValueLst DDHeatBalance[]=
{
{eHBal_Normal, "Normal"},
{eHBal_ImposedTemp, "Imposed Temperature"},
// {eHBal_OptimumTemp, "Optimum Temperature"},
{0}
};
DD.Text ("");
DD.String("Version", "", idDX_Version, MF_RESULT);
DD.CheckBox ("On", "", &m_bOn, MF_PARAMETER);
DD.Long ("Model", "", (long*)&m_eModel, MF_PARAMETER|MF_SET_ON_CHANGE, DDModels);
DD.Show(m_eModel==eMdl_Gravity);
DD.Text ("");
DD.Text ("Precipitation...");
DD.CheckBox ("Precip", "", &m_bPrecipOn, MF_PARAMETER|MF_SET_ON_CHANGE);
DD.Show(m_eModel==eMdl_Gravity && m_bPrecipOn);
DD.Double ("NoOperating", "", &m_dNumberInService, MF_PARAMETER, MC_);
DD.Double ("Volume", "", &m_dVolume, MF_PARAMETER, MC_Vol("m^3"));
DD.Text ("");
DD.Long ("ThermalBalance", "", (long*)&m_eHeatBalance, MF_PARAMETER|MF_SET_ON_CHANGE, DDHeatBalance);
DD.Show(m_eModel==eMdl_Gravity && m_eHeatBalance == eHBal_Normal && m_bPrecipOn);
DD.Double ("Surface", "", &m_dSurface, MF_PARAMETER, MC_Area("m^2"));
DD.Show( m_eHeatBalance == eHBal_ImposedTemp && m_bPrecipOn);
DD.Double ("TempImposed", "", &m_dTempImpos, MF_PARAMETER, MC_T("C"));
DD.Show(true);
DD.Text ("");
DD.Text ("Separation...");
DD.Long ("InputMethod", "", (long*)&m_eInputMethod, MF_PARAMETER|MF_SET_ON_CHANGE, DDInputMethods);
DD.Long ("SharpEqn", "", (long*)&m_eSharpEqn, MF_PARAMETER, DDSharpEqn);
DD.Show(m_eInputMethod==eIM_CutSize);
DD.Double ("CutSize", "", &m_dD50, MF_PARAMETER, MC_L("um"));
DD.Show(true);
DD.Double ("Sharpness", "", &m_dSharpness, MF_PARAMETER ,MC_);
DD.Show(m_eInputMethod!=eIM_Model );
DD.Double ("RqdUF_SolidsConc", "", &m_dRqdUFSolidsConc, MF_PARAMETER, MC_Conc("g/L"));
DD.Show(m_eInputMethod==eIM_Recovery);
DD.Double ("RqdRecovery", "", &m_dRqdRecoveryFrac, MF_PARAMETER, MC_Frac("%"));
//DD.Show(m_eInputMethod==eIM_Model || m_eInputMethod==eIM_Underflow);
//DD.Show(m_eInputMethod!=eIM_CutSize && m_eInputMethod!=eIM_Recovery);
DD.Show(true);
DD.CheckBox ("Use Brent Solver method", "", &m_bBrentSolverSelected, MF_PARAMETER|MF_SET_ON_CHANGE);
DD.Double ("RqdUF_VolFlow", "", &m_dRqdUFVolFlow, (m_eInputMethod==eIM_Model || m_eInputMethod==eIM_Underflow) ? MF_PARAMETER : MF_RESULT, MC_Qv("m^3/h"));
DD.Show(m_eInputMethod==eIM_Overflow);
DD.Double ("RqdOF_SolidsFlow", "", &m_dRqdOFSolidsTons, MF_PARAMETER, MC_Qm("t/h"));
DD.Show(m_eInputMethod==eIM_Model);
DD.Double ("TankDiameter", "", &m_dDiameter, MF_PARAMETER, MC_L("m"));
DD.Double ("HinderSettlingFactor", "", &m_dHindSettlFac, MF_PARAMETER, MC_);
DD.Show(true);
DD.Text ("");
DD.Text ("Results");
DD.Show(m_eModel==eMdl_Gravity && m_bPrecipOn);
DD.Double("Yield", "", &m_dYield, MF_RESULT, MC_Conc("g/L"));
DD.Show(true);
DD.Double("Ti", "", &m_dTempIn, MF_RESULT, MC_T("C"));
DD.Double("To", "", &m_dTempOut, MF_RESULT, MC_T("C"));
DD.Double("ACin", "", &m_dACIn, MF_RESULT, MC_);
if (m_eModel==eMdl_Gravity && m_bPrecipOn)
DD.Double("ACout", "", &m_dACOut, MF_RESULT, MC_);
DD.Double("SolidConcIn", "", &m_dSolidConcIn, MF_RESULT, MC_Conc("g/L"));
//DD.Double("SolidConcOut", "", &m_dSolidConcOut, MF_RESULT, MC_Conc("g/L"));
DD.Double ("Rf", "", &m_dRf, MF_RESULT, MC_Frac );
DD.Double ("Recovery", "", &m_dCalcRecoveryFrac, MF_RESULT, MC_Frac("%"));
DD.Double ("CutSizeUsed", "", &m_dD50Used, MF_RESULT, MC_L("um"));
DD.Double ("UF_SolidsConc", "", &m_dUFSolidsConc, MF_RESULT, MC_Conc("g/L"));
DD.Double ("UF_VolFlow", "", &m_dUFVolFlow, MF_RESULT, MC_Qv("m^3/h"));
DD.Double ("OF_SolidsConc", "", &m_dOFSolidsConc, MF_RESULT, MC_Conc("g/L"));
DD.Double ("OF_VolFlow", "", &m_dOFVolFlow, MF_RESULT, MC_Qv("m^3/h"));
DD.Double ("OF_SolidsFlow", "", &m_dOFSolidsTons, MF_RESULT, MC_Qm("t/h"));
DD.Object(m_QProd, MDD_RqdPage);
}
//---------------------------------------------------------------------------
bool Classifier::ExchangeDataFields()
{
switch (DX.Handle)
{
case idDX_Version:
DX.String = VersionDescription;
return true;
}
return false;
}
//---------------------------------------------------------------------------
bool Classifier::ValidateDataFields()
{//ensure parameters are within expected ranges
if (m_eModel==eMdl_Cyclone && m_eInputMethod==eIM_Model)
m_eInputMethod = eIM_Recovery;
m_dD50 = DV.ValidateRange("CutSize", 0.000001, m_dD50 , 0.0005);
//m_dD50Used = DV.ValidateRange("", 0.000001, m_dD50 , 0.0005);
m_dD50Used = Range(0.000001, m_dD50 , 0.0005); //is this needed???
m_dRqdRecoveryFrac = DV.ValidateRange("RqdRecovery", 0.01, m_dRqdRecoveryFrac , 0.995);
//!!!! NEED TO PUT A LOT OF SAFETY CHECKS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
return true;
}
//---------------------------------------------------------------------------
bool Classifier::CalcPrecipition(MVector & Feed, MVector & Prod)
{
try
{
int ErrCode = PrecipSS(Feed, Prod, m_QProd);
switch (ErrCode)
{
case 0:
HeatBalance(Feed, Prod, Prod.T);
break;
case -1: Log.SetCondition(6, MMsg_Error, "PrecipSS Failed - No Solids"); return false;
case -2: Log.SetCondition(6, MMsg_Error, "PrecipSS Failed - No Caustic"); return false;
case -3: Log.Message(MMsg_Note, "Pas Precipitation"); return false;
case -4: Log.SetCondition(6, MMsg_Error, "PrecipSS Failed - Infinite solve loop"); return false;
}
}
catch(MMdlException & e)
{
Log.SetCondition(5, MMsg_Error, "Exception Occurred in CalcPrecipition %s", e.Description);
SetIdleRequired("Phone Denis");
return false;
}
catch(...)
{
Log.SetCondition(5, MMsg_Error, "Exception Occurred in CalcPrecipition");
SetIdleRequired("Phone Denis");
return false;
}
return true;
}
//---------------------------------------------------------------------------
bool Classifier::CalcSeparationNoPSD(MVector & Feed, MVector & OF, MVector & UF)
{
double FeedSolMass = Feed.Mass(MP_Sol);
double FeedLiqVolFlow = Feed.Volume(MP_Liq);
double TtlUFSolids;
double UFVolFlow;
if (m_eInputMethod==eIM_Recovery)
{
TtlUFSolids = m_dRqdRecoveryFrac * FeedSolMass;
UFVolFlow = TtlUFSolids/m_dRqdUFSolidsConc; // m^3/s
}
else
{
TtlUFSolids = m_dRqdRecoveryFrac * FeedSolMass;//todo
UFVolFlow = m_dRqdUFVolFlow;
}
double UFSolVolFlow = TtlUFSolids/UF.Density(MP_Sol);
double UFLiqVolFlow = UFVolFlow - UFSolVolFlow;
double LiquidToOF_Frac = GEZ(1.0 - (UFLiqVolFlow/GTZ(FeedLiqVolFlow)));
double SolidsToOF_Frac = GEZ(1.0 - (TtlUFSolids/GTZ(FeedSolMass)));
for (int i=0; i<gs_MVDefn.Count(); i++)
{
if (gs_MVDefn[i].IsSolid())
{
OF.M[i] = Feed.M[i]*SolidsToOF_Frac;
}
else if (gs_MVDefn[i].IsLiquid())
{
OF.M[i] = Feed.M[i]*LiquidToOF_Frac;
}
else if (gs_MVDefn[i].IsGas())
{
OF.M[i] = Feed.M[i];
}
UF.M[i] = Feed.M[i]-OF.M[i];
}
m_dCalcRecoveryFrac = UF.Mass(MP_Sol)/FeedSolMass;
return true;
}
//---------------------------------------------------------------------------
bool Classifier::ComputeEfficiency(MVector & Feed, MVector & OF, MVector & UF, double Beta)
{
MIPSD &FdPSD = *Feed.GetIF<MIPSD>(); //actual PSD data
MIPSD &OFPSD = *OF.GetIF<MIPSD>(); //actual PSD data
MIPSD &UFPSD = *UF.GetIF<MIPSD>(); //actual PSD data
MPSDDefn &SD = FdPSD.getDefn(); //sieve series definition
const int NumComps = SD.getPSDVectorCount(); // Number of components in the stream usisng size data
Eu.SetSize(NIntervals);
double SolidsToOF_Frac = 0.0;
//todo what if NumComps>1 !!!!!!!
//if (sm_bCompletePopulation)
for (int c=0; c<NumComps; c++)
{
const int SpId = SD.SpecieIndex[c];
OF.M[SpId] = 0.0;
UF.M[SpId] = 0.0;
double FdMassFlow = Feed.M[SpId];
double* pDataFd = FdPSD.getFracVector(c);
double* pDataOF = OFPSD.getFracVector(c);
double* pDataUF = UFPSD.getFracVector(c);
for (int mm=0; mm<NIntervals; mm++)
{
const double d = SizeClass[mm]/(m_dD50Used*1.0e6);
if (m_eSharpEqn == eSE_Lynch)
{
const double tmp1 = exp(m_dSharpness);
const double tmp2 = exp(m_dSharpness*SizeClass[mm]/(m_dD50Used*1.0e6));
const double tmp = (tmp1 - 1.0)/(tmp1 + tmp2 - 2.0);
Eu[mm] = 1.0 + (1.0 - tmp)*Beta - Beta ;
}
else
{
Eu[mm] = 1.0 - Beta * exp(-0.693147*pow(d, m_dSharpness));
}
pDataUF[mm] = (pDataFd[mm] * FdMassFlow) * Eu[mm];
UF.M[SpId] += pDataUF[mm];
pDataOF[mm] = Max(0.0, (pDataFd[mm] * FdMassFlow) - pDataUF[mm]);
OF.M[SpId] += pDataOF[mm];
}
for (mm=0; mm<NIntervals; mm++)
{
pDataOF[mm] /= GTZ(OF.M[SpId]);
pDataUF[mm] /= GTZ(UF.M[SpId]);
}
}
double FdMassFlow = 0;
for (int c=0; c<NumComps; c++)
{
const int SpId = SD.SpecieIndex[c];
SolidsToOF_Frac += OF.M[SpId];
FdMassFlow += Feed.M[SpId];
}
SolidsToOF_Frac /= GTZ(FdMassFlow);
SolidsToOF_Frac = Max(0.0, SolidsToOF_Frac);
//solids split first
double TtlUFSolids = 0.0; // kg/s
for (int i=0; i<gs_MVDefn.Count(); i++)
{
if (gs_MVDefn[i].IsSolid())
{
OF.M[i] = Feed.M[i]*SolidsToOF_Frac;
UF.M[i] = Feed.M[i]-OF.M[i];
TtlUFSolids += UF.M[i];
}
}
//now calculate liquid split...
double UFVolFlow;
if (m_eInputMethod==eIM_CutSize || m_eInputMethod==eIM_Recovery)
{
UFVolFlow = TtlUFSolids/m_dRqdUFSolidsConc; // m^3/s
}
else
{
UFVolFlow = m_dRqdUFVolFlow;
}
double UFSolVolFlow = TtlUFSolids/UF.Density(MP_Sol);
double UFLiqVolFlow = UFVolFlow - UFSolVolFlow;
double FeedLiqVolFlow = Feed.Volume(MP_Liq);
double LiquidToOF_Frac = 1.0 - (UFLiqVolFlow/GTZ(FeedLiqVolFlow));
LiquidToOF_Frac = Max(0.0, LiquidToOF_Frac);
for (i=0; i<gs_MVDefn.Count(); i++)
{
if (gs_MVDefn[i].IsLiquid())
{
OF.M[i] = Feed.M[i]*LiquidToOF_Frac;
UF.M[i] = Feed.M[i]-OF.M[i];
}
else if (gs_MVDefn[i].IsGas())
{
OF.M[i] = Feed.M[i];
UF.M[i] = 0.0;
}
}
return true;
}
//---------------------------------------------------------------------------
class CRecoveryFn: public MRootFinder
{
public:
static MToleranceBlock s_Tol;
private:
Classifier & TheClassifier;
MVector & Feed;
MVector & OF;
MVector & UF;
double TtlVolFlow;
double FdSolMass;
public:
CRecoveryFn(Classifier & Classifier_, MVector & Feed_, MVector & OF_, MVector & UF_) : MRootFinder("ClassifierRecoveryFn", s_Tol),
Feed(Feed_), OF(OF_), UF(UF_), TheClassifier(Classifier_)
{
TtlVolFlow = Feed.Volume();
FdSolMass = Feed.Mass(MP_Sol);
}
double Function(double x)
{
TheClassifier.m_dD50Used = x;
//const int MaxLoop = ((TheClassifier.m_eInputMethod!=eIM_Underflow) ? 5 : 2);
const int MaxLoop = 50;
double UFvol = UF.Volume();
if (TheClassifier.m_eInputMethod!=eIM_Underflow)
TheClassifier.m_dRf = UFvol/TtlVolFlow;//using previous UF.Volume can be a problem!?!
double beta = 1.0 - TheClassifier.m_dRf;
double PrevRf = TheClassifier.m_dRf;
//require a second internal convergence because change in UF.Volume changes Rf (ie beta)
for (int i=0; i<MaxLoop; i++)
{
TheClassifier.ComputeEfficiency(Feed, OF, UF, beta);
UFvol = UF.Volume();
if (TheClassifier.m_eInputMethod!=eIM_Underflow)
TheClassifier.m_dRf = UFvol/TtlVolFlow;
beta = 1.0 - TheClassifier.m_dRf;
if (fabs(TheClassifier.m_dRf-PrevRf)<1.0e-5)
break;
PrevRf = TheClassifier.m_dRf;
}
if (i==MaxLoop)
{//Report error when this doesn't converge!!??
int xxx=0;
}
const double UFmass = UF.Mass(MP_Sol);
const double recovery = UFmass/FdSolMass;
int xxx=0;
return recovery;
}
};
MToleranceBlock CRecoveryFn::s_Tol(TBF_Both, "AlcanClassifier:RecoveryFn", 1.0-6, 0.0, 100);
//---------------------------------------------------------------------------
bool Classifier::CalcSeparation(MVector & Feed, MVector & OF, MVector & UF)
{
const double FdSolMass = Feed.Mass(MP_Sol);
Log.SetCondition(FdSolMass<1.0e-9, 12, MMsg_Warning, "No solids in the feed - liquids report to UF");
Log.ClearCondition(4);
if (FdSolMass<1.0e-9)
{
UF = Feed;
OF.ZeroMass();
m_dCalcRecoveryFrac = 0.0;
return true;
}
const double Min_d50 = 1.0e-8;
InitSizeData(Feed);
//MIBayer & UFB = *UF.GetIF<MIBayer>();
MIBayer & FeedB = *Feed.GetIF<MIBayer>();
const double T = Feed.T;
const double TtlVolFlow = Feed.Volume();
m_dD50 = Valid(m_dD50) ? Max(Min_d50, m_dD50) : Min_d50*10.0;
switch (m_eInputMethod)
{
case eIM_CutSize:
case eIM_Model:
{
const bool UseBrentSolver = false;
if (UseBrentSolver)
{
//TODO: Rather use Brent solver!?!
}
else
{
//double Rf = 0.25; // Assumed starting value
double beta = 1.0 - m_dRf;
//const double Visc = Feed.DynamicViscosity(MP_Liq);
const double Visc = 0.002; //fixed value for Bayer typical liquor in kg /m.s (perhaps make this a parameter that the user can change?)
const double Densliq = Feed.Density(MP_Liq);
const double gpl = FeedB.SolidsConc(T);
m_dD50Used = m_dD50;
ComputeEfficiency(Feed, OF, UF, beta);
int reply=0;
double prev_Rf = m_dRf;
m_dRf = UF.Volume() / TtlVolFlow;
while ((fabs(prev_Rf - m_dRf ) > 0.0001) && (reply <= 100))
{
m_dRf = UF.Volume() / TtlVolFlow;
beta = 1.0 - m_dRf; // This line SHOULD NOT be commented .. Except to simulate HYPROD results
if (m_eInputMethod == eIM_Model)
{
double speed = ( TtlVolFlow - UF.Volume() ) / ( PI * Sqr( m_dDiameter)/4); // OVERFLOW FLOW in m/s
double K1 = Pow( (1.0 - gpl/THADens), 4.65); //effect of solids concentration Ref. Perry
m_dD50Used = Sqrt(speed * Visc/(1.08888* K1* m_dHindSettlFac * (THADens-Densliq)));// in microns
if (m_dD50Used<0.0)
{//Potential error!!!???
m_dD50Used = Min_d50;
}
}
ComputeEfficiency(Feed, OF, UF, beta);
prev_Rf = m_dRf;
reply++;
}
//m_dRqdUFVolFlow = UF.Volume();// do not want to override this!!!?!
//m_dRqdRecoveryFrac = UF.Mass(MP_Sol)/FdSolMass; do not want to override this!!!?!
Log.SetCondition(reply>99, 4, MMsg_Error, "Probleme de convergence de densité");
}
break;
}
case eIM_Overflow:
case eIM_Underflow:
case eIM_Recovery:
{
if (m_eInputMethod==eIM_Overflow)
{
double UFmass = Max(0.0, FdSolMass - m_dRqdOFSolidsTons);
m_dRqdUFVolFlow = UFmass/m_dRqdUFSolidsConc;
m_dRqdRecoveryFracUsed = UFmass/FdSolMass;
m_dRf = (TtlVolFlow - m_dRqdUFVolFlow) / TtlVolFlow;
}
if (m_eInputMethod==eIM_Underflow)
{
//m_dRqdRecoveryFrac = m_dRqdUFVolFlow * m_dRqdUFSolidsConc / FdSolMass; do not want to override this!!!?!
m_dRqdRecoveryFracUsed = m_dRqdUFVolFlow * m_dRqdUFSolidsConc / FdSolMass;
m_dRf = m_dRqdUFVolFlow/TtlVolFlow;
}
if (m_eInputMethod==eIM_Recovery)
{
m_dRqdRecoveryFracUsed = m_dRqdRecoveryFrac;
double UFmass = Max(0.0, FdSolMass * m_dRqdRecoveryFracUsed);
m_dRqdUFVolFlow = UFmass/m_dRqdUFSolidsConc;
m_dRf = (TtlVolFlow - m_dRqdUFVolFlow) / TtlVolFlow;
}
if ( (m_dRqdRecoveryFracUsed >= 1) || ( (m_dRf < 0) && (m_dRf > 1)) )
{
SetStopRequired("Insufficient Feed : revise flowsheet!");
Log.SetCondition( true , 12, MMsg_Error, "Insufficient Feed to Classifier!use Recovery Mode");
break;
}
const bool UseBrentSolver = m_bBrentSolverSelected;
if (UseBrentSolver)
{
//Solve to determine new d50 to achieve required recovery...
const double Target = m_dRqdRecoveryFracUsed;
double d50_Est;
if (m_dD50 > 0 )
d50_Est = m_dD50;
else
d50_Est = 80;
CRecoveryFn Fn(*this, Feed, OF, UF);
if (Fn.FindRoot(Target, d50_Est/2.0, d50_Est*2, m_dD50Used)!=RF_OK)
{//try again with less strict range...
//switch (Fn.FindRoot(Target, Min_d50, SizeClass[NIntervals-1]*1.0e-3, m_dD50Used)) //todo: improve min/max range
switch (Fn.FindRoot(Target, d50_Est/10.0, d50_Est*10.0, m_dD50Used))
{
case RF_OK:
break;
case RF_LoLimit:
Log.SetCondition(true, 4, MMsg_Error, "Recovery cutSize RootFinder at LOW limit");
break;
case RF_HiLimit:
Log.SetCondition(true, 4, MMsg_Error, "Recovery cutSize RootFinder at HIGH limit");
break;
default:
Log.SetCondition(true, 4, MMsg_Error, "Recovery cutSize RootFinder:%s", Fn.ResultString(Fn.Error()));
break;
}
}
//m_dRqdUFVolFlow = UF.Volume();// DO WE WANT THIS???
}
else
{ // --------- SECANT Root Finding Method -----------------
double beta = 1.0 - m_dRf;
m_dD50Used = m_dD50;
ComputeEfficiency(Feed, OF, UF, beta);
m_dRf = UF.Volume() / TtlVolFlow;
beta = 1.0 - m_dRf;
ComputeEfficiency(Feed, OF, UF, beta);
double NewFdSolMass = Feed.Mass(MP_Sol);
double y0 = FdSolMass * m_dRqdRecoveryFracUsed - UF.Mass(MP_Sol);
double Cut0 = m_dD50Used *1.0e6 ;
m_dD50Used = m_dD50Used *1.1;
ComputeEfficiency(Feed, OF, UF, beta);
double y1 = FdSolMass * m_dRqdRecoveryFracUsed - UF.Mass(MP_Sol);
double Cut1 = m_dD50Used *1.0e6 ;
int reply=0;
while ((fabs(y1) > 0.00001) && (reply <= 100))
{
if ( (y0 >0.0)&& (y1 > y0)) // the secant goes the wrong way so we have to invert the pair of points
{
double y_temp = y1;
double Cut_temp = Cut1;
y1 = y0;
Cut1 = Cut0;
y0 = y_temp;
Cut0 = Cut_temp;
}
m_dRf = UF.Volume() / TtlVolFlow;
beta = 1.0 - m_dRf; // This line SHOULD NOT be commented .. Except to simulate HYPROD results
m_dD50Used = ( Cut0 - y0* (Cut1-Cut0)/(y1 - y0) ) / 1.0e6;
if (m_dD50Used<0.0)
{//Trouble!!!???
int xx=0;
m_dD50Used = Min_d50;
}
y0 = y1;
Cut0 = Cut1 ;
ComputeEfficiency(Feed, OF, UF, beta);
y1 = FdSolMass * m_dRqdRecoveryFracUsed - UF.Mass(MP_Sol);
Cut1 = m_dD50Used *1.0e6;
reply++;
}
m_dRqdUFVolFlow = UF.Volume();
Log.SetCondition(reply>99, 4, MMsg_Error, "Probleme de convergence de densité");
}
break;
}
}
m_dCalcRecoveryFrac = UF.Mass(MP_Sol)/FdSolMass;
return true;
}
//---------------------------------------------------------------------------
void Classifier::EvalProducts()
{
if (!IsSolveDirect)//(!IsProbal)
return;
MStreamI Prod;
bool SplitErr = false;
try
{
MStreamI Feed;
FlwIOs.AddMixtureIn_Id(Feed, idFeed);
MStream & OF = FlwIOs[FlwIOs.First[idOverflow]].Stream;
MStream & UF = FlwIOs[FlwIOs.First[idUnderflow]].Stream;
Prod = Feed;
m_dThermalLoss = 0.0;
m_dYield = 0.0;
m_dTempIn = Feed.T;
MIBayer & FeedB=*Feed.FindIF<MIBayer>();
if (!IsNothing(FeedB))
{
m_dACIn = FeedB.AtoC();
m_dSolidConcIn = FeedB.SolidsConc(C2K(25.0));
}
else
{
m_dACIn = 0.0;
m_dSolidConcIn = 0.0;
}
if (m_bOn && Feed.Mass()>UsableMass)
{
//first precipitation...
if (m_bPrecipOn && m_eModel==eMdl_Gravity)
{
MIBayer & ProdB=*Prod.FindIF<MIBayer>();
MISSA & FeedSSA=*Feed.FindIF<MISSA>();
Log.SetCondition(IsNothing(FeedB), 1, MMsg_Warning, "Bad Feed Stream - Not Bayer Model"); //expect stream to have bayer properties
Log.SetCondition(IsNothing(FeedSSA), 2, MMsg_Warning, "Bad Feed Stream - SSA must be present"); //expect stream to have bayer properties
if (!IsNothing(FeedB) && !IsNothing(FeedSSA))
{
if (!CalcPrecipition(Feed, Prod))
{//error occured
if (fabs(Feed.Mass()-Prod.Mass())>10.e-6)
{//serious problem, set prod = feed
Prod = Feed;
}
m_dACOut = ProdB.AtoC();
}
else
{
double H0 = Feed.totHf(MP_All, Feed.T, Feed.P);
m_dThermalLoss = H0-Prod.totHf(MP_All, Prod.T, Prod.P);
m_dACOut = ProdB.AtoC();
double Cout = ProdB.CausticConc(Prod.T);
m_dYield = Cout*(m_dACIn-m_dACOut);
//if (sm_bUsePrevPSD)
// {
// SetPSDfromPrev(Prod);
// }
}
}
}
m_QProd = Prod; //the stream after precipitation but before separation
//now split...
SplitErr = true;
OF = Prod;
UF = Prod;
if (!sm_bCompletePopulation)
{
CalcSeparationNoPSD(Prod, OF, UF);
}
else
{
MIPSD & ProdSz = *Prod.FindIF<MIPSD>();
Log.SetCondition(IsNothing(ProdSz), 3, MMsg_Warning, "Bad Feed Stream - No PSD present");
if (!IsNothing(ProdSz))
{
CalcSeparation(Prod, OF, UF);
}
else
{
OF = Prod;
UF = Prod;
UF.ZeroMass();
}
}
SplitErr = false;
}
else
{
OF = Prod;
UF = Prod;
UF.ZeroMass();
}
//results...
m_dTempOut = Prod.T;
MIBayer & UFB=*UF.FindIF<MIBayer>();
MIBayer & OFB=*OF.FindIF<MIBayer>();
if (!IsNothing(UFB) && !IsNothing(OFB))
{
m_dUFSolidsConc = UFB.SolidsConc(m_dTempOut);
m_dOFSolidsConc = OFB.SolidsConc(m_dTempOut);
}
else
{
m_dUFSolidsConc = 0.0;
m_dOFSolidsConc = 0.0;
}
m_dUFVolFlow = UF.Volume();
m_dOFVolFlow = OF.Volume();
m_dOFSolidsTons = OF.Mass(MP_Sol);
}
catch (MMdlException &e)
{
Log.Message(MMsg_Error, e.Description);
}
catch (MFPPException &e)
{
e.ClearFPP();
Log.Message(MMsg_Error, e.Description);
}
catch (MSysException &e)
{
Log.Message(MMsg_Error, e.Description);
}
catch (...)
{
Log.Message(MMsg_Error, "Some Unknown Exception occured");
}
if (SplitErr)
{//Something is wrong!!! Bug needs fixing!!!
//So lets set OF=feed and UF=0....
MStream & OF = FlwIOs[FlwIOs.First[idOverflow]].Stream;
MStream & UF = FlwIOs[FlwIOs.First[idUnderflow]].Stream;
OF = Prod;
UF = Prod;
UF.ZeroMass();
SetStopRequired("Phone Denis");
}
Log.SetCondition(SplitErr, 11, MMsg_Error, "CalcSeparation Error needs fixing!!!");
}
//--------------------------------------------------------------------------
void Classifier::ClosureInfo(MClosureInfo & CI)
{
if (CI.DoFlows())
{
CI.AddPowerIn(0, -m_dThermalLoss);
}
}
//--------------------------------------------------------------------------
bool Classifier::PreStartCheck()
{
if (!sm_bCompletePopulation )
{
m_eInputMethod = eIM_Recovery; // force the method to be recovery
if ( m_dCalcRecoveryFrac<= 0)
{
m_sErrorMsg = "Invalid Method";
return false;
}
else
{
//m_dRqdRecoveryFrac = m_dCalcRecoveryFrac; //24/9/2007: What is this for? This code overrides user specified RqdRecovery at startup!!!
}
}
return true;
}
//====================================================================================
| [
"[email protected]",
"[email protected]",
"[email protected]"
]
| [
[
[
1,
52
],
[
54,
83
],
[
86,
118
],
[
120,
150
],
[
152,
181
],
[
195,
199
],
[
208,
264
],
[
267,
291
],
[
295,
347
],
[
349,
375
],
[
377,
466
],
[
469,
470
],
[
473,
526
],
[
533,
538
],
[
540,
541
],
[
545,
545
],
[
556,
586
],
[
590,
591
],
[
605,
605
],
[
615,
616
],
[
618,
620
],
[
622,
622
],
[
625,
625
],
[
628,
630
],
[
632,
643
],
[
645,
645
],
[
647,
649
],
[
651,
658
],
[
660,
675
],
[
678,
700
],
[
702,
715
],
[
717,
739
],
[
742,
754
],
[
756,
800
],
[
814,
817
]
],
[
[
53,
53
],
[
84,
85
],
[
119,
119
],
[
151,
151
],
[
182,
194
],
[
200,
207
],
[
265,
266
],
[
348,
348
],
[
376,
376
],
[
471,
472
],
[
527,
532
],
[
539,
539
],
[
542,
544
],
[
546,
555
],
[
587,
589
],
[
592,
604
],
[
606,
614
],
[
617,
617
],
[
621,
621
],
[
623,
624
],
[
626,
627
],
[
631,
631
],
[
644,
644
],
[
701,
701
],
[
801,
813
]
],
[
[
292,
294
],
[
467,
468
],
[
646,
646
],
[
650,
650
],
[
659,
659
],
[
676,
677
],
[
716,
716
],
[
740,
741
],
[
755,
755
]
]
]
|
a446cd7a4339f96d2dce39a1d3ca46a61787e9e8 | c1c3866586c56ec921cd8c9a690e88ac471adfc8 | /Practise_2005/dshow.test.texture3d9/ClientApplication.cpp | 5442ea3b2699e3056d37b7310abbbf2e037496fd | []
| no_license | rtmpnewbie/lai3d | 0802dbb5ebe67be2b28d9e8a4d1cc83b4f36b14f | b44c9edfb81fde2b40e180a651793fec7d0e617d | refs/heads/master | 2021-01-10T04:29:07.463289 | 2011-03-22T17:51:24 | 2011-03-22T17:51:24 | 36,842,700 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,125 | cpp | //=============================================================================
// Desc: 纹理影射基础
//=============================================================================
#include "stdafx.h"
#include "ClientApplication.h"
#include "dshow.texture3d9.h"
#include "DShowTextures.h"
#include "DShowManager.h"
#include "Render3D9.h"
CDShowManager* g_pApp = NULL;
//-----------------------------------------------------------------------------
// Desc: 消息处理
//-----------------------------------------------------------------------------
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_DESTROY:
Cleanup();
PostQuitMessage( 0 );
return 0;
}
return DefWindowProc( hWnd, msg, wParam, lParam );
}
//-----------------------------------------------------------------------------
// Desc: 入口函数
//-----------------------------------------------------------------------------
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
// Initialize COM
CoInitialize (NULL);
//注册窗口类
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
L"ClassName", NULL };
RegisterClassEx( &wc );
//创建窗口
g_hWnd = CreateWindow( L"ClassName", L"纹理影射基础",
WS_OVERLAPPEDWINDOW, 200, 100, 600, 500,
GetDesktopWindow(), NULL, wc.hInstance, NULL );
//初始化Direct3D
if( SUCCEEDED( InitD3D( g_hWnd ) ) )
{
//创建场景图形
if( SUCCEEDED( InitGriphics() ) )
{
//显示窗口
ShowWindow( g_hWnd, SW_SHOWDEFAULT );
UpdateWindow( g_hWnd );
//进入消息循环
MSG msg;
ZeroMemory( &msg, sizeof(msg) );
while( msg.message!=WM_QUIT )
{
if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
{
Render(); //渲染图形
}
}
}
}
UnregisterClass( L"ClassName", wc.hInstance );
CoUninitialize();
return 0;
}
| [
"laiyanlin@27d9c402-1b7e-11de-9433-ad2e3fad96c5"
]
| [
[
[
1,
82
]
]
]
|
3b0e7ffb803940966a90e665554cf72e07e2f10d | 2e86c8ff6c58b8d307fed7441dfbc2ce8e5e1160 | /src/gdx-cpp/utils/JsonWriter.cpp | 73b8a5a9adee9366a197908416a185f3d95c8d59 | [
"Apache-2.0"
]
| permissive | NoiSek/libgdx-cpp | dbe9448983ff84090e62e5b59b4cb48076d6aac3 | d7f5fd5e690659f381d3945a128eaf93dab35d79 | refs/heads/master | 2021-01-16T21:02:59.297514 | 2011-11-02T01:39:24 | 2011-11-02T01:39:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,072 | cpp |
/*
Copyright 2011 Aevum Software aevum @ aevumlab.com
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.
@author Victor Vicente de Carvalho [email protected]
@author Ozires Bortolon de Faria [email protected]
*/
#include "JsonWriter.hpp"
using namespace gdx_cpp::utils;
JsonWriter& JsonWriter::object () throws IOException {
if (current != null) {
if (!current.array) throw new RuntimeException("Current item must be an array.");
if (!current.needsComma)
current.needsComma = true;
else
writer.write(",");
}
stack.push(current = new JsonObject(false));
return this;
}
JsonWriter& JsonWriter::array () throws IOException {
if (current != null) {
if (!current.array) throw new RuntimeException("Current item must be an array.");
if (!current.needsComma)
current.needsComma = true;
else
writer.write(",");
}
stack.push(current = new JsonObject(true));
return this;
}
JsonWriter& JsonWriter::add (const Object& value) throws IOException {
if (!current.array) throw new RuntimeException("Current item must be an array.");
if (!current.needsComma)
current.needsComma = true;
else
writer.write(",");
if (value == null || value instanceof Number || value instanceof Boolean)
writer.write(String.valueOf(value));
else {
writer.write("\"");
writer.write(value.toString());
writer.write("\"");
}
return this;
}
JsonWriter& JsonWriter::object (const std::string& name) throws IOException {
if (current == null || current.array) throw new RuntimeException("Current item must be an object.");
if (!current.needsComma)
current.needsComma = true;
else
writer.write(",");
writer.write("\"");
writer.write(name);
writer.write("\":");
stack.push(current = new JsonObject(false));
return this;
}
JsonWriter& JsonWriter::array (const std::string& name) throws IOException {
if (current == null || current.array) throw new RuntimeException("Current item must be an object.");
if (!current.needsComma)
current.needsComma = true;
else
writer.write(",");
writer.write("\"");
writer.write(name);
writer.write("\":");
stack.push(current = new JsonObject(true));
return this;
}
JsonWriter& JsonWriter::set (const std::string& name,const Object& value) throws IOException {
if (current == null || current.array) throw new RuntimeException("Current item must be an object.");
if (!current.needsComma)
current.needsComma = true;
else
writer.write(",");
writer.write("\"");
writer.write(name);
if (value == null || value instanceof Number || value instanceof Boolean) {
writer.write("\":");
writer.write(String.valueOf(value));
} else {
writer.write("\":\"");
writer.write(value.toString());
writer.write("\"");
}
return this;
}
JsonWriter& JsonWriter::pop () throws IOException {
stack.pop().close();
current = stack.peek();
return this;
}
void JsonWriter::write (int off,int len) throws IOException {
writer.write(cbuf, off, len);
}
void JsonWriter::flush () throws IOException {
writer.flush();
}
void JsonWriter::close () throws IOException {
while (!stack.isEmpty())
pop();
writer.close();
}
| [
"[email protected]"
]
| [
[
[
1,
129
]
]
]
|
f12b12fa71a55ad606d7180c485177babcdaedd8 | 3182b05c41f13237825f1ee59d7a0eba09632cd5 | /T3D/aiPlayer.h | 2887b49404a6fc22f33ceee420f768699c49cf6f | []
| no_license | adhistac/ee-client-2-0 | 856e8e6ce84bfba32ddd8b790115956a763eec96 | d225fc835fa13cb51c3e0655cb025eba24a8cdac | refs/heads/master | 2021-01-17T17:13:48.618988 | 2010-01-04T17:35:12 | 2010-01-04T17:35:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,362 | h | //-----------------------------------------------------------------------------
// Torque 3D
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
#ifndef _AIPLAYER_H_
#define _AIPLAYER_H_
#ifndef _PLAYER_H_
#include "T3D/player.h"
#endif
class AIPlayer : public Player {
typedef Player Parent;
public:
enum MoveState {
ModeStop,
ModeMove,
ModeStuck,
};
private:
MoveState mMoveState;
F32 mMoveSpeed;
F32 mMoveTolerance; // Distance from destination before we stop
Point3F mMoveDestination; // Destination for movement
Point3F mLastLocation; // For stuck check
bool mMoveSlowdown; // Slowdown as we near the destination
SimObjectPtr<GameBase> mAimObject; // Object to point at, overrides location
bool mAimLocationSet; // Has an aim location been set?
Point3F mAimLocation; // Point to look at
bool mTargetInLOS; // Is target object visible?
Point3F mAimOffset;
// Utility Methods
void throwCallback( const char *name );
public:
DECLARE_CONOBJECT( AIPlayer );
AIPlayer();
~AIPlayer();
virtual bool getAIMove( Move *move );
// Targeting and aiming sets/gets
void setAimObject( GameBase *targetObject );
void setAimObject( GameBase *targetObject, Point3F offset );
GameBase* getAimObject() const { return mAimObject; }
void setAimLocation( const Point3F &location );
Point3F getAimLocation() const { return mAimLocation; }
void clearAim();
// Movement sets/gets
void setMoveSpeed( const F32 speed );
F32 getMoveSpeed() const { return mMoveSpeed; }
void setMoveTolerance( const F32 tolerance );
F32 getMoveTolerance() const { return mMoveTolerance; }
void setMoveDestination( const Point3F &location, bool slowdown );
Point3F getMoveDestination() const { return mMoveDestination; }
void stopMove();
void preprocessMove(Move * mv);
void getCameraTransform(F32* pos,MatrixF* mat);
void setControlByKey(bool val);
void faceToCamera(bool faceto = true);
void backToCamera();
protected:
Point3F m_ptCamRot;
F32 m_fCamDistance;
F32 m_fCamDistanceToReach;
bool m_bControlByKey;
};
#endif
| [
"[email protected]"
]
| [
[
[
1,
79
]
]
]
|
ae8d98ae1e1f4a153e1a807bb76263bed18de0df | 789bfae90cbb728db537b24eb9ab21c88bda2786 | /source/ShutDownStateClass.cpp | 5cc49ce17722157216ee7debeafd8d8aa832862d | [
"MIT"
]
| permissive | Izhido/bitsweeper | b89db2c2050cbc82ea60d31d2f31b041a1e913a3 | a37902c5b9ae9c25ee30694c2ba0974fd235090e | refs/heads/master | 2021-01-23T11:49:21.723909 | 2011-12-24T22:43:30 | 2011-12-24T22:43:30 | 34,614,275 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 364 | cpp | #include "ShutDownStateClass.h"
#include "CommonDataClass.h"
ShutDownStateClass::ShutDownStateClass()
: StateClass()
{
}
void ShutDownStateClass::Start(CommonDataClass* CommonData)
{
CommonData->Finished = true;
}
void ShutDownStateClass::Run(CommonDataClass* CommonData)
{
}
void ShutDownStateClass::Draw(CommonDataClass* CommonData)
{
}
| [
"[email protected]@66f87ebb-1a6f-337b-3a26-6cadc16acdcf"
]
| [
[
[
1,
20
]
]
]
|
10fdfa7bf937d3d63bbcfbdfdfa3635aed943daf | fd47272bb959679789cf1c65afa778569886232f | /Utility/ShadeRecord.h | 35a29030cf45d8312f5c4ca00708fec03bed955d | []
| no_license | dicta/ray | 5aeed98fe0cc76b7a5dea2c4b93c38caf0485b6c | 5e6290077a92b8468877a8b6751f1ed13da81a43 | refs/heads/master | 2021-01-17T16:16:21.768537 | 2011-09-26T06:03:12 | 2011-09-28T04:36:22 | 2,471,865 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 708 | h | /*
* ShadeRecord.h
* RayTracer
*
* Created by Eric Saari on 12/15/10.
* Copyright 2010 __MyCompanyName__. All rights reserved.
*
*/
#ifndef _SHADE_RECORD_H_
#define _SHADE_RECORD_H_
#include "Math/Vector3D.h"
#include "Math/Point3D.h"
#include <boost/shared_ptr.hpp>
using namespace boost;
class Material;
class Tracer;
class ShadeRecord {
public:
ShadeRecord();
~ShadeRecord();
Vector3D normal;
Point3D hitPoint;
Point3D localHitPoint;
shared_ptr<Material> material;
int depth;
// The following are used by area lights
Point3D samplePoint;
Vector3D lightNormal;
Vector3D wi;
Tracer* tracer;
double tu, tv;
Vector3D dpdu, dpdv;
};
#endif
| [
"esaari1@13d0956a-e706-368b-88ec-5b7e5bac2ff7"
]
| [
[
[
1,
45
]
]
]
|
044693f9ec5e2b7790facdc16c0e48c032815d66 | 5d3c1be292f6153480f3a372befea4172c683180 | /trunk/Event Heap/c++/Windows/include/idk_th_TMTQueue.h | a7915339a3b936d3742b4f26d6f399d02cd989ac | [
"Artistic-2.0"
]
| permissive | BackupTheBerlios/istuff-svn | 5f47aa73dd74ecf5c55f83765a5c50daa28fa508 | d0bb9963b899259695553ccd2b01b35be5fb83db | refs/heads/master | 2016-09-06T04:54:24.129060 | 2008-05-02T22:33:26 | 2008-05-02T22:33:26 | 40,820,013 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,879 | h | /* Copyright (c) 2003 The Board of Trustees of The Leland Stanford Junior
* University. All Rights Reserved.
*
* See the file LICENSE.txt for information on redistributing this software.
*/
/* $Id: idk_th_TMTQueue.h,v 1.5 2003/06/02 08:03:40 tomoto Exp $ */
#ifndef _IDK_TH_TMTQUEUE_H_
#define _IDK_TH_TMTQUEUE_H_
#include <idk_th_Types.h>
#include <idk_ut_TQueue.h>
#include <idk_th_Monitor.h>
#include <idk_th_Locker.h>
/** @file
Definition of idk_th_TMTQueue, idk_th_MTQueueBase class.
*/
/**
Parameter-independent part of idk_th_TMTQueue class.
Usually users do not have to care of this class.
*/
class IDK_DECL idk_th_MTQueueBase {
protected:
idk_th_MonitorPtr m_monitorPtr;
int m_isClosed;
public:
~idk_th_MTQueueBase();
idk_th_MTQueueBase(int maxSize = 0);
void closeQueueBase();
protected:
void putPre(int timeout);
void putPost(int stateChanged);
void getPre(int timeout);
void getPost(int stateChanged);
virtual int isFull() = 0;
virtual int isEmpty() = 0;
};
/**
Queue for interthread communication.
This class provides a queue through which multiple threads can
send and receive data items.
*/
template <class T>
class IDK_DECL idk_th_TMTQueue
: public idk_ut_RealObject, protected idk_th_MTQueueBase
{
public:
typedef idk_ut_TSharedPtr<idk_th_TMTQueue<T> > Ptr;
private:
idk_ut_TQueue<T> m_queue;
protected:
virtual int isFull() { return m_queue.isFull(); }
virtual int isEmpty() { return m_queue.isEmpty(); }
public:
~idk_th_TMTQueue() { closeQueue(); }
/**
Creates an object.
@param maxSize The maximum size of the queue. Zero means infinite.
*/
idk_th_TMTQueue(int maxSize = 0)
: idk_th_MTQueueBase(maxSize), m_queue(maxSize) {}
/**
Tries to put an item into the queue.
If the queue is full, wait for one slot to become available.
@param value Value to put.
@param timeout The maximum time to wait in milliseconds.
@throws idk_th_InterruptedException
closeQueue was called or the thread was interrupted while waiting.
<i>The latter is not implemented yet.</i>
@throws idk_th_MonitorTimedoutException Reached to timeout.
*/
void put(const T& value, int timeout = 0) {
idk_th_Locker locker(m_monitorPtr); // sync this block
putPre(timeout);
int stateChanged = m_queue.isEmpty();
m_queue.put(value);
putPost(stateChanged);
}
/**
Tries to get an item from the queue.
If no item exists, wait for one to become available.
@param timeout The maximum time to wait in milliseconds.
@throws idk_th_InterruptedException
closeQueue was called or the thread was interrupted while waiting.
<i>The latter is not implemented yet.</i>
@throws idk_th_MonitorTimedoutException Reached to timeout.
*/
T get(int timeout = 0) {
idk_th_Locker locker(m_monitorPtr); // sync this block
getPre(timeout);
int stateChanged = m_queue.isFull();
T result = m_queue.get();
getPost(stateChanged);
return result;
}
/**
Clears the queue.
*/
void clear() {
idk_th_Locker locker(m_monitorPtr); // sync this block
m_queue.clear();
}
/**
Gets the lockable for the queue.
You may share this lockable to lock related resources to the queue.
*/
idk_th_ILockable* getLockable() { return m_monitorPtr; }
/**
Closes the queue.
Once the queue was closed, the queue operations (i.e. put() and get())
currently being blocked raise idk_th_InterruptedException
immediately, and any subsequent queue operations results
the same exceptions also.
Note that get() operation works normally as far as there are
items in the queue left even after the queue was closed.
*/
void closeQueue() { closeQueueBase(); }
/**
Returns the size of the queue
*/
int size() { return m_queue.size(); }
};
#endif
| [
"ballagas@2a53cb5c-8ff1-0310-8b75-b3ec22923d26"
]
| [
[
[
1,
149
]
]
]
|
f71400fdb58508dad279c26fe2f0daba88ee0868 | 0b66a94448cb545504692eafa3a32f435cdf92fa | /tags/0.7/cbear.berlios.de/range/equal.hpp | f02f229b0ee93e6ffee0697b0018ded0511dde12 | [
"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 | 791 | hpp | #ifndef CBEAR_BERLIOS_DE_RANGE_EQUAL_HPP_INCLUDED
#define CBEAR_BERLIOS_DE_RANGE_EQUAL_HPP_INCLUDED
// std::equal
#include <algorithm>
#include <cbear.berlios.de/range/begin.hpp>
#include <cbear.berlios.de/range/end.hpp>
#include <cbear.berlios.de/range/size.hpp>
namespace cbear_berlios_de
{
namespace range
{
template<class Range1, class Range2>
bool equal(const Range1 &A, const Range2 &B)
{
return
range::size(A)==range::size(B) &&
::std::equal(
range::begin(A), range::end(A), range::begin(B));
}
template<class Range1, class Range2, class Pred>
bool equal(const Range1 &A, const Range2 &B, Pred P)
{
return
range::size(A)==range::size(B) &&
::std::equal(
range::begin(A), range::end(A), range::begin(B), P);
}
}
}
#endif
| [
"sergey_shandar@e6e9985e-9100-0410-869a-e199dc1b6838"
]
| [
[
[
1,
37
]
]
]
|
15a151a78d1ece1ff4173f4bc15e037dd8c27a0c | f12a33df3711392891e10b97ae18f687041e846b | /canon_noir/ModeleCpp/Case.h | 97cb2ac1c011e3c6399dd0c1255e7e5bdbe00eaa | []
| no_license | MilenaKasaka/poocanonnoir | 63e9cc68f0e560dece36f01f28df88a1bd46cbc6 | 04750469ac30fd9f59730c7b93154c3261a74f93 | refs/heads/master | 2020-05-18T06:34:07.996980 | 2011-01-26T18:39:29 | 2011-01-26T18:39:29 | 32,133,754 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,803 | h | /**
* \file Case.h
* \brief Fichier d'en-tete decrivant la classe Case
* \author Sophie Le Corre
* \author Gregoire Lecourt
* \version 1.0
* \date 26/01/2011
*/
#ifndef CASE_H
#define CASE_H
/// <remarks>
/// si type = TRESOR alors nbTresor>=0,
/// sinon nbTresor = 0
/// </remarks>
#include <utility>
#include "enumerations.h"
using namespace std;
/**
* \class Case
* \brief Representation d'une case
* Une case est définie par une position, une altitude, un type et peut contenir un tresor
*/
class Case
{
private :
int nbTresor; /*!< nombre de trésors restants sur la case, initialisé à 0 pour les cases qui ne sont pas de type trésor */
TypeCase type; /*!< type de la case (eau, ile, canon ou tresor) */
int altitude; /*!< altitude de la case, pas prise en compte dans cette version du jeu */
pair<int,int> coordonnees; /*!< coordonnées de la case sur le plateau */
public :
/**
* \fn Case()
* \brief Construit une case avec comme type par défaut le type eau et aucun trésor
*/
Case();
/**
* \fn Case(TypeCase t, int n)
* \brief Construit un case en lui passant son type et son nombre de trésors
* \param[in] t type de la case (eau, ile, canon ou tresor)
* \param[in] n nombre de trésors contenu par la case
*/
Case(TypeCase t, int n);
/**
* \fn TypeCase getType()
* \brief Permet d'obtenir le type de la case (eau, ile, canon ou tresor)
* \return type de la case
*/
TypeCase getType();
/**
* \fn void setType(TypeCase t)
* \brief Permet de changer le type de la case
* \param[in] t nouveau type de la case (eau, ile, canon ou tresor)
*/
void setType(TypeCase t);
/**
* \fn int getNbTresor()
* \brief Permet d'obtenir le nombre de trésors restant sur la case
* \return nombre de trésors restant sur la case
*/
int getNbTresor();
/**
* \fn void setNbTresor(int n)
* \brief Permet de changer le nombre de trésors contenu par la case
* \param[in] n nouveau nombre de trésors
*/
void setNbTresor(int n);
/**
* \fn bool prendreTresor()
* \brief Permet de prendre un trésor sur la case
* \return vrai si la case contenait un trésor, faux sinon
*/
bool prendreTresor();
/**
* \fn pair<int,int> getCoordonnees() const
* \brief Permet d'obtenir les coordonnées de la case
* \return coordonnées de la case sur le plateau
*/
pair<int,int> getCoordonnees() const;
/**
* \fn void setCoordonnees(pair<int,int> c)
* \brief Permet de changer les coordonnées de la case
* \param[in] c nouvelles coordonnées de la case sur le plateau
*/
void setCoordonnees(pair<int,int> c);
};
inline pair<int,int> Case::getCoordonnees() const { return coordonnees; }
#endif
| [
"[email protected]@c2238186-79af-eb75-5ca7-4ae61b27dd8b"
]
| [
[
[
1,
101
]
]
]
|
857bc9c805d90a038d8cb0137d38c99a17832c2c | b5ad65ebe6a1148716115e1faab31b5f0de1b493 | /src/Aran/Animation.h | 4d641de4216f55bd7c28852e804c96b6790d1f65 | []
| no_license | gasbank/aran | 4360e3536185dcc0b364d8de84b34ae3a5f0855c | 01908cd36612379ade220cc09783bc7366c80961 | refs/heads/master | 2021-05-01T01:16:19.815088 | 2011-03-01T05:21:38 | 2011-03-01T05:21:38 | 1,051,010 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,344 | h | #pragma once
class ArnSkinInfo;
class Animation
{
public:
Animation(unsigned int totalCurveCount);
~Animation(void);
unsigned int registerCurve(CurveName curveName, unsigned int pointCount, CurveType curveType);
bool setCurvePoint(CurveName curveName, POINT2FLOAT* point2Array);
// originally written by Blender;
// file: blendersvn/blender/source/blender/blenkernel/intern/ipo.c
// function: float eval_icu(IpoCurve *icu, float ipotime)
static float EvalCurveInterp(const CurveData* icu, float ipotime);
private:
struct AnimCurve
{
CurveName curveName;
unsigned int pointCount;
CurveType curveType;
POINT2FLOAT* point2Array;
};
AnimCurve* findCurve(CurveName curveName);
unsigned int m_totalCurveCount;
unsigned int m_curveCount;
AnimCurve* m_curves;
bool m_curveFlags[CN_SIZE];
};
//////////////////////////////////////////////////////////////////////////
// Creates a skin info object based on the number of vertices, number of bones, and a FVF describing the vertex layout of the target vertices
// The bone names and initial bone transforms are not filled in the skin info object by this method.
HRESULT ARAN_API ArnCreateSkinInfoFVF( DWORD NumVertices, DWORD FVF, DWORD NumBones, ArnSkinInfo** ppSkinInfo);
| [
"[email protected]"
]
| [
[
[
1,
37
]
]
]
|
30660303aa84190cad00fe44a96f62e2b62d16a3 | b44229db8ac87529bc5b2734d0212d6c23da00a3 | /src/trayicon.cpp | 1ea5bb964e5be07367c69ba91a01a16cc6aed879 | []
| no_license | Sanane22/taekwindow | d16203ab2bc5a792c0fcf7cfe6f64825bbba7581 | 2879b662dc1fd2a0cd6ea48006b858f3faa2935b | refs/heads/master | 2020-04-26T13:41:53.912838 | 2011-03-13T13:21:33 | 2011-03-13T13:21:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,341 | cpp | #include <windows.h>
#include <windowsx.h>
#include <tchar.h>
#include <strsafe.h>
#include "trayicon.hpp"
#include "messages.hpp"
#include "version.h"
#include "graphics.h"
#include "errors.hpp"
#include "main.hpp"
#include "globals.hpp"
const UINT ICON_ID = 42;
const UINT_PTR IDM_ENABLE = 1;
const UINT_PTR IDM_CONFIGURE = 2;
const UINT_PTR IDM_EXIT = 3;
TrayIcon::TrayIcon()
:
d_showing(false)
{
HINSTANCE instance = GetModuleHandle(NULL);
d_enabledIcon = (HICON)LoadImage(instance, MAKEINTRESOURCE(IDI_TRAY_COLOUR), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
d_disabledIcon = (HICON)LoadImage(instance, MAKEINTRESOURCE(IDI_TRAY_GRAY), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
// Create the notify icon itself.
// We use Version 5.0, that is, Windows 2000/XP semantics.
d_data.cbSize = sizeof(d_data);
d_data.hWnd = d_window.handle();
d_data.uID = ICON_ID;
d_data.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
d_data.uCallbackMessage = TRAYICON_MESSAGE;
d_data.hIcon = currentIcon();
StringCchCopy(d_data.szTip, sizeof(d_data.szTip), _T(APPLICATION_TITLE));
d_data.dwState = 0;
d_data.dwStateMask = 0;
d_data.szInfo[0] = _T('\0');
d_data.uVersion = NOTIFYICON_VERSION;
d_data.szInfoTitle[0] = _T('\0');
d_data.dwInfoFlags = 0;
if (!Shell_NotifyIcon(NIM_ADD, &d_data)) {
showLastError(NULL, _T("Error creating notify icon"));
return;
}
d_window.setWindowProc(WindowProcFwd<TrayIcon>(*this, &TrayIcon::windowProc));
d_showing = true;
}
TrayIcon::~TrayIcon() {
if (d_showing)
Shell_NotifyIcon(NIM_DELETE, &d_data);
if (d_enabledIcon)
DestroyIcon(d_enabledIcon);
if (d_disabledIcon)
DestroyIcon(d_disabledIcon);
}
void TrayIcon::update() {
if (!d_showing)
return;
d_data.hIcon = currentIcon();
Shell_NotifyIcon(NIM_MODIFY, &d_data);
}
void TrayIcon::showMenu(POINT pos) {
// Create the pop-up menu for the icon.
HMENU menu = CreatePopupMenu();
if (!menu) {
return;
}
// Populate the pop-up menu.
AppendMenu(menu, (isEnabled() ? MF_CHECKED : 0) | MF_ENABLED | MF_STRING, IDM_ENABLE, _T("En&able Taekwindow"));
AppendMenu(menu, MF_ENABLED | MF_STRING, IDM_CONFIGURE, _T("&Preferences..."));
AppendMenu(menu, MF_SEPARATOR, 0, NULL);
AppendMenu(menu, MF_ENABLED | MF_STRING, IDM_EXIT, _T("&Exit"));
// Show the pop-up menu.
// Set the foreground window, so that the menu will be closed when the user clicks elsewhere.
// Post a dummy message to get it to show up the next time (I don't see this problem myself, but the KB says it).
// See Microsoft KB article 135788: "PRB: Menus for Notification Icons Do Not Work Correctly".
SetForegroundWindow(d_window.handle());
TrackPopupMenuEx(menu,
TPM_RIGHTBUTTON | (GetSystemMetrics(SM_MENUDROPALIGNMENT) ? TPM_RIGHTALIGN : TPM_LEFTALIGN),
pos.x, pos.y, d_window.handle(), NULL);
PostMessage(d_window.handle(), WM_NULL, 0, 0);
DestroyMenu(menu);
}
HICON TrayIcon::currentIcon() {
return isEnabled() ? d_enabledIcon : d_disabledIcon;
}
void TrayIcon::toggleEnabled() {
if (isEnabled()) {
disable();
} else {
enable();
}
}
void TrayIcon::showConfigDlg() {
globals->configDlg().show();
}
void TrayIcon::exitProgram() {
PostQuitMessage(0);
}
LRESULT TrayIcon::windowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch (msg) {
case TRAYICON_MESSAGE:
switch (lParam) { // that contains the "real" message
case WM_RBUTTONUP:
case WM_CONTEXTMENU:
{
// Using GetMessagePos() would be way better, but it gives me 0.
POINT mousePos;
GetCursorPos(&mousePos);
showMenu(mousePos);
return 0;
}
case WM_LBUTTONDOWN:
case NIN_SELECT:
case NIN_KEYSELECT:
toggleEnabled();
return 0;
case WM_LBUTTONDBLCLK:
toggleEnabled(); // second click does not register as WM_LBUTTONDOWN
showConfigDlg();
return 0;
}
break;
case WM_COMMAND:
switch (LOWORD(wParam)) { // contains the menu item identifier
case IDM_ENABLE:
toggleEnabled();
return 0;
case IDM_CONFIGURE:
showConfigDlg();
return 0;
case IDM_EXIT:
exitProgram();
return 0;
}
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
| [
"[email protected]"
]
| [
[
[
1,
155
]
]
]
|
4afc172db640eac27e1dbd201779d18877fedda7 | 0320357a767318b78b18fa90137ee70edd0e57fe | /Calourada/principal.cpp | e6c1f8c4391a81e475e786a27a3787d1c3079401 | []
| no_license | diogenesleonel/CalouradaLivre2011 | 6b448fa46713a02bb943e8a32e41547a075b56f3 | 216f237587970231dca03532b26a873532df9f7b | refs/heads/master | 2016-09-10T15:43:37.196166 | 2011-08-24T02:02:17 | 2011-08-24T02:02:17 | 2,201,855 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,299 | cpp | #include "principal.h"
#include <QString>
#define _TTY_WIN_
#include "C:\qextserialport\qextserialbase.h"
#include "C:\qextserialport\qextserialport.h"
Principal::Principal(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Principal)
{
ui->setupUi(this);
time = new QTimer(this);
led1Status = false;
led2Status = false;
motorStatus = false;
serial=new QextSerialPort(QString("COM4"));
serial->setBaudRate(BAUD9600);
serial->setDataBits(DATA_8);
serial->setParity(PAR_NONE);
serial->setStopBits(STOP_1 );
serial->setFlowControl(FLOW_OFF );
serial->setTimeout(0,10);
if(serial->open(QIODevice::ReadWrite))
{
qDebug()<< "conectado";
}
connect(time,SIGNAL(timeout()),this,SLOT(showData()));
// connect(serial,SIGNAL(readyRead()),this,SLOT(showData()));
time->start(1000);
// showData();
}
int Principal::receive(int count, char *bytes)
{
return serial->readData(bytes, count);
}
Principal::~Principal()
{
delete ui;
}
void Principal::showData()
{
char buffer[256];
int rec=receive(255,buffer);
buffer[rec]='\0';
qDebug()<< QString::fromLocal8Bit(buffer,rec) <<rec;
}
void Principal::send(int count, char *bytes)
{
serial->writeData(bytes, count);
serial->flush();
}
void Principal::on_pushButton_clicked(bool checked)
{
led1Status=!led1Status;
char *u = new char[3];
u[0]=0x01;
if(led1Status)
ui->pushButton->setIcon(QIcon(QString::fromUtf8(":/img/on")));
else
ui->pushButton->setIcon(QIcon(QString::fromUtf8(":/img/off")));
ui->pushButton->setIconSize(QSize(30, 30));
send(1,u);
}
void Principal::on_pushButton_2_clicked()
{
led2Status=!led2Status;
char *u = new char[3];
u[0]=0x10;
if(led2Status)
ui->pushButton_2->setIcon(QIcon(QString::fromUtf8(":/img/on")));
else
ui->pushButton_2->setIcon(QIcon(QString::fromUtf8(":/img/off")));
ui->pushButton_2->setIconSize(QSize(30, 30));
send(1,u);
}
void Principal::on_pushButton_3_clicked()
{
motorStatus=!motorStatus;
char *u = new char[3];
u[0]=0x04;
send(1,u);
}
| [
"[email protected]"
]
| [
[
[
1,
117
]
]
]
|
681a3123cd0fc45858aa2e1ba4b9b7a5aeb3e58c | 252e638cde99ab2aa84922a2e230511f8f0c84be | /reflib/src/RegionAddForm.h | ac05a9ef2a0694f0821b06ba432d9ca37ac55206 | []
| 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 | 1,000 | h | //---------------------------------------------------------------------------
#ifndef RegionAddFormH
#define RegionAddFormH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "RegionProcessForm.h"
#include "VStringStorage.h"
#include <Db.hpp>
#include <DBCtrls.hpp>
#include <Mask.hpp>
//---------------------------------------------------------------------------
class TTourRefBookRegionAddForm : public TTourRefBookRegionProcessForm
{
__published: // IDE-managed Components
private: // User declarations
public: // User declarations
__fastcall TTourRefBookRegionAddForm(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TTourRefBookRegionAddForm *TourRefBookRegionAddForm;
//---------------------------------------------------------------------------
#endif
| [
"[email protected]"
]
| [
[
[
1,
26
]
]
]
|
e1b0016395e18a338a6d05a517ea08fa2008701d | 4aadb120c23f44519fbd5254e56fc91c0eb3772c | /Source/src/EduNetConnect/ClientVehicleUpdate.h | 6aa20fb8dc02211885b7cd194a065e994dfd32c6 | []
| no_license | janfietz/edunetgames | d06cfb021d8f24cdcf3848a59cab694fbfd9c0ba | 04d787b0afca7c99b0f4c0692002b4abb8eea410 | refs/heads/master | 2016-09-10T19:24:04.051842 | 2011-04-17T11:00:09 | 2011-04-17T11:00:09 | 33,568,741 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,672 | h | #ifndef __CLIENTVEHICLEUPDATE_H__
#define __CLIENTVEHICLEUPDATE_H__
//-----------------------------------------------------------------------------
// Copyright (c) 2009, Jan Fietz, Cyrus Preuss
// 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 EduNetGames 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 "EduNetConnect/NetworkVehicle.h"
//-----------------------------------------------------------------------------
namespace OpenSteer {
//-------------------------------------------------------------------------
class ClientVehicleUpdate : public NetworkVehicleUpdate {
OS_DECLARE_BASE(NetworkVehicleUpdate)
public:
ClientVehicleUpdate( AbstractVehicle* pkVehicle ):
BaseClass( pkVehicle )
{
}
virtual ~ClientVehicleUpdate(){}
//-------------------------------------------------------------------
// interface AbstractUpdated
virtual void updateCustom( AbstractUpdated* pkParent, const osScalar currentTime, const osScalar elapsedTime );
virtual void update( const osScalar currentTime, const osScalar elapsedTime );
private:
EVehicleUpdateMode determineUpdateMode( const class SimpleNetworkVehicle& kVehicle ) const;
void updatePosition( class SimpleNetworkVehicle& kVehicle, const osScalar currentTime, const osScalar elapsedTime );
void updatePositionOrientation( class SimpleNetworkVehicle& kVehicle, const osScalar currentTime, const osScalar elapsedTime );
void updateBruteForce( class SimpleNetworkVehicle& kVehicle, const osScalar currentTime, const osScalar elapsedTime );
void updatePhysicsMotion( class SimpleNetworkVehicle& kVehicle, const osScalar currentTime, const osScalar elapsedTime );
void updateForwardSpeed( class SimpleNetworkVehicle& kVehicle, const osScalar currentTime, const osScalar elapsedTime );
void updateSteer( class SimpleNetworkVehicle& kVehicle, const osScalar currentTime, const osScalar elapsedTime );
void updateUnknown( class SimpleNetworkVehicle& kVehicle, const osScalar currentTime, const osScalar elapsedTime );
};
} // namespace OpenSteer
#endif // __SIMPLENETWORKVEHICLEUPDATE_H__ | [
"janfietz@localhost"
]
| [
[
[
1,
73
]
]
]
|
6f5d09fdb368500b7f6b174d85caeca865484d8f | 29c00095e9aa05f7100561e490c65f71150fa93b | /langs/java.cpp | c0d495cacbbb887d005bc7fe0fe4f1d5d73b7f90 | [
"Apache-2.0"
]
| permissive | krfkeith/toupl | 1c78fe90a6516946a7f504d6c77ec746807e7ec8 | c80b5206750dc2de222e79c860cb229fb150a1fb | refs/heads/master | 2020-12-24T17:36:26.259097 | 2009-06-13T14:53:44 | 2009-06-13T14:53:44 | 37,639,837 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,782 | cpp | /*
This file is part of Toupl.
http://code.google.com/p/toupl/
Autor: Bga
Email: [email protected]
X.509 & GnuPG Email certifaces here: http://code.google.com/p/jbasis/downloads/list
Copyright 2009 Bga <[email protected]>
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#include "java.hpp"
Lang javaLang=
{
&(::_createLangClass<TouplParser::Java>),
"java",
{".java",null}
};
namespace TouplParser
{
String Java::__addText(Const String& text)
{
return String("fpStringBuilder.append(\"") & _quote(text) & "\");\n";
}
String Java::__addValue(Const String& value)
{
return String("fpStringBuilder.append(") & value & ");\n";
}
String Java::__declareVar(Const String& varName,Const String& varType)
{
String type;
if(varType=="String")
type="String";
if(varType=="Bool")
type="boolean";
return String("") & type & " " & varName & ";\n";
}
String Java::__condBegin(Const String& varName)
{
return String("if(") & varName & ")\n{\n";
}
String Java::__condEnd(Const String& varName)
{
return String("}\n");
}
// simple. only AND operations
String Java::__condComp(Const Vector<ParseRes_*>& prs)
{
if(prs.size()==0)
return null;
String ret="";
Vector<ParseRes_*>::size_type i;
for(i=0;i<prs.size()-1;++i)
{
ret & "(" & prs[i]->varName_ & "=" & prs[i]->value_ & "," & prs[i]->testCode_ & ") && ";
}
ret & "(" & prs[i]->varName_ & "=" & prs[i]->value_ & "," & prs[i]->testCode_ & ")";
return ret;
}
String Java::__condCompFinal(ParseRes_* pr)
{
if(!_t(pr))
return null;
return String ("") & pr->varName_ & "=" & pr->value_ & ";\n";
}
String Java::__createVar(Int pos)
{
return String("fpVar") & pos;
}
String Java::__boolVarTestCode(Const String& varName)
{
return varName;
}
String Java::__varTestCode(Const String& varName)
{
return String("_fpT(") & varName & ")";
}
Void Java::_setup(ArgParser * argp)
{
Base::_setup(argp);
}
} // namespace TouplParser
| [
"bga.email@31f10f56-5826-11de-b31f-81d54249e7d9"
]
| [
[
[
1,
114
]
]
]
|
b2f846df1211bbd11108534ef7d460af762e8adb | 5e755d27b668f647bb29218987a03c9eaa6a6d0b | /CADBiS_docs/PashikUs/content/DefaultFinder.h | 72acf696e953f1c7239c1931908c92f95db1e50c | []
| no_license | xtps1987225/cadbis | 0672ae5b00fd04fa7ce0722190110ab1466a04ac | ffd2f41d87df438d6276b748129dca4dc49d2055 | refs/heads/master | 2021-01-20T02:17:18.865466 | 2008-07-23T09:32:21 | 2008-07-23T09:32:21 | 33,819,572 | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 768 | h | //============================================================================
// Name : DefaultFinder.h
// Author : Sakoltsev PV
// Version :
// Copyright : Your copyright notice
// Description : дополнительный модуль с классом содержащим метод поиска подстроки в строке
//============================================================================
#ifndef DEFAULTFINDER_H_
#define DEFAULTFINDER_H_
#include <string>
#include <iostream>
using namespace std;
#include "AnalyzeFinderAbstract.h"
class DefaultFinder : public AnalyzeFinderAbstract
{
public:
virtual int operator () (const char *fword,const char *opentext);
};
#endif /*DEFAULTFINDER_H_*/
| [
"pashikus@254517df-764a-0410-b743-7361b4a10c92"
]
| [
[
[
1,
24
]
]
]
|
b1bf6a393d65c567f678d5bc3e3326beb9377f57 | a699a508742a0fd3c07901ab690cdeba2544a5d1 | /RailwayDetection/RWDSClient/RecordStaff.h | 77e5b2ff6e16055899a6db404e2c272afa7469a9 | []
| no_license | xiaomailong/railway-detection | 2bf92126bceaa9aebd193b570ca6cd5556faef5b | 62e998f5de86ee2b6282ea71b592bc55ee25fe14 | refs/heads/master | 2021-01-17T06:04:48.782266 | 2011-09-27T15:13:55 | 2011-09-27T15:13:55 | 42,157,845 | 0 | 1 | null | 2015-09-09T05:24:10 | 2015-09-09T05:24:09 | null | GB18030 | C++ | false | false | 1,077 | h | #pragma once
#include "afxwin.h"
#include "afxdtctl.h"
#include "RWDSClientDoc.h"
#include "RWDSClientView.h"
// CRecordStaff 对话框
class CRecordStaff : public CDialogEx
{
DECLARE_DYNAMIC(CRecordStaff)
public:
CRecordStaff(CWnd* pParent = NULL); // 标准构造函数
virtual ~CRecordStaff();
// 对话框数据
enum { IDD = IDD_RECORDSTAFF };
public:
int GetSelect();
time_t GetPickDateTime();
StaffInfo* GetSelectedStaff();
void SetDateVisible(BOOL aVisible);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
private:
CRWDSClientView* m_CRWDSClientView;
CComboBox m_ComboRecord;
CDateTimeCtrl m_DateTimeRecord;
CButton m_RadioCurrentTrack;
int m_Select;
CTime m_PickDateTime;
StaffInfo* m_Staff;
public:
afx_msg void OnBnClickedOk();
afx_msg void OnBnClickedCancel();
virtual BOOL OnInitDialog();
afx_msg void OnBnClickedRadioCurrenttrack();
afx_msg void OnBnClickedRadioRecord();
};
| [
"[email protected]@4d6b9eea-9d24-033f-dd66-d003eccfd9d3"
]
| [
[
[
1,
45
]
]
]
|
223e5b710b7e6d20ff57e7eefa2e4a6ec9ac6eef | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.2/bctestuniteditor/src/bctestuniteditorapp.cpp | bc958e268d7e0aeee7954dca8046481b1620453e | []
| no_license | SymbianSource/oss.FCL.sftools.ana.compatanamdw | a6a8abf9ef7ad71021d43b7f2b2076b504d4445e | 1169475bbf82ebb763de36686d144336fcf9d93b | refs/heads/master | 2020-12-24T12:29:44.646072 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,999 | cpp | /*
* 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: Avkon UnitEditor test app
*
*/
// INCLUDE FILES
#include "BCTestUnitEditorApp.h"
#include "BCTestUnitEditorDocument.h"
#include <eikstart.h>
// ================= MEMBER FUNCTIONS =========================================
// ----------------------------------------------------------------------------
// TUid CBCTestUnitEditorApp::AppDllUid()
// Returns application UID.
// ----------------------------------------------------------------------------
//
TUid CBCTestUnitEditorApp::AppDllUid() const
{
return KUidBCTestUnitEditor;
}
// ----------------------------------------------------------------------------
// CApaDocument* CBCTestUnitEditorApp::CreateDocumentL()
// Creates CBCTestUnitEditorDocument object.
// ----------------------------------------------------------------------------
//
CApaDocument* CBCTestUnitEditorApp::CreateDocumentL()
{
return CBCTestUnitEditorDocument::NewL( *this );
}
// ================= OTHER EXPORTED FUNCTIONS =================================
//
// ----------------------------------------------------------------------------
// CApaApplication* NewApplication()
// Constructs CBCTestUnitEditorApp.
// Returns: CApaDocument*: created application object
// ----------------------------------------------------------------------------
//
LOCAL_C CApaApplication* NewApplication()
{
return new CBCTestUnitEditorApp;
}
GLDEF_C TInt E32Main()
{
return EikStart::RunApplication(NewApplication);
}
// End of File
| [
"none@none"
]
| [
[
[
1,
64
]
]
]
|
82d28b2861f645df2aa325b3b06be5471ccb1736 | 26706a661c23f5c2c1f97847ba09f44b7b425cf6 | /TaskManager/DlgProcessModule.h | 3ad5760b4b06d42a85f377cd9b8f074377b126a9 | []
| no_license | 124327288/nativetaskmanager | 96a54dbe150f855422d7fd813d3631eaac76fadd | e75b3d9d27c902baddbb1bef975c746451b1b8bb | refs/heads/master | 2021-05-29T05:18:26.779900 | 2009-02-10T13:23:28 | 2009-02-10T13:23:28 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,786 | h | #pragma once
#include "afxcmn.h"
#include "SortListCtrl.h"
#include "EnumModule.h"
#include <vector>
using namespace std;
using enumModule::TvecModuleInfo;
// CDlgProcessModule 对话框
typedef struct tagModuleColInfo
{
CString strColName; // Colnum名称
UINT uWidth; // Colnum宽度
}ModuleColInfo;
class CDlgProcessModule : public CDialog
{
DECLARE_DYNAMIC(CDlgProcessModule)
public:
CDlgProcessModule(CWnd* pParent = NULL); // 标准构造函数
virtual ~CDlgProcessModule();
// 对话框数据
enum { IDD = IDD_FORMVIEW_PROCESS_TAB_MODULE };
private:
CSortListCtrl m_wndListProcessTabModule;
CImageList m_iImageSmall;
CFont m_font;
int m_nProcessID; // 当前选中进程ID
CWinThread *m_pModuleThread; // 获取模块信息线程
TvecModuleInfo m_vecModuleInfo; // 模块信息
static const ModuleColInfo m_ModuleColInfo[];// 模块List显示信息
private:
void InitList(); // 初始化ListCtrl
void InsertItem(); // 插入数据
static DWORD WINAPI ModuleInfoThread(LPVOID pVoid);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
virtual BOOL OnInitDialog();
public:
DECLARE_EASYSIZE
DECLARE_MESSAGE_MAP()
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnDestroy();
afx_msg void OnInitMenuPopup(CMenu *pPopupMenu, UINT nIndex,BOOL bSysMenu);
afx_msg LRESULT OnLoadModuleInfo(WPARAM wParam,LPARAM lParam);
afx_msg LRESULT OnFlushModuleInfo(WPARAM wParam,LPARAM lParam);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnNMRclickListProcessTabModule(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnNMDblclkListProcessTabModule(NMHDR *pNMHDR, LRESULT *pResult);
};
| [
"[email protected]@97a26042-f463-11dd-a7be-4b3ef3b0700c"
]
| [
[
[
1,
66
]
]
]
|
b41c7387dff23a26b4c991f2283e2af922e0174e | 076413cfd054131591ae7b4ef0b769c48b6d967b | /tetris/TetrominoL.cpp | 35fbb3a577c93f560e75a3796e099ce9546c9c20 | [
"MIT"
]
| permissive | oliverzheng/tetris | 9ef134266ea528303f9fb6b8c28095575ef7b882 | 8a0c629e7378fd90c6b6f40a904b58e7110c4040 | refs/heads/master | 2020-06-03T15:08:26.444621 | 2010-02-02T03:54:40 | 2010-02-02T03:54:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,965 | cpp | /******************************************************************************
TetrominoL.cpp
Created for: Tetris
Copyright (C) 2006-2007 Oliver Zheng.
All rights reserved. No part of this software may be used or reproduced in
any form by any means without prior written permission.
|
|
|
--
Inherited from Tetromino
******************************************************************************/
#include "TetrominoL.h"
#include "Tetris.h"
// Absolute positions in the Tetris screen that the blocks should be setup.
int TetrominoL::setup_positions_x[] = {Tetris::getWidth() / 2,
Tetris::getWidth() / 2 - 1,
Tetris::getWidth() / 2 - 2,
Tetris::getWidth() / 2 - 2};
int TetrominoL::setup_positions_y[] = {2, 2, 2, 3};
// Relative positions that should be displayed in the Tetris NEXT box
int TetrominoL::next_positions_x[] = {2, 1, 0, 0};
int TetrominoL::next_positions_y[] = {0, 0, 0, 1};
// Relative positions that each block should move to
int TetrominoL::rotation_positions_x[][block_count] = {{-1, 0, 1, 0},
{-1, 0, 1, 2},
{1, 0, -1, 0},
{1, 0, -1, -2}};
int TetrominoL::rotation_positions_y[][block_count] = {{1, 0, -1, -2},
{-1, 0, 1, 0},
{-1, 0, 1, 2},
{1, 0, -1, 0}};
/******************************************************************************
TetrominoL
Constructor - allocates the blocks and buffer blocks & sets the designated color.
Input Parameters:
none
Output:
None
******************************************************************************/
TetrominoL::TetrominoL() : rotation_state(0) {
blocks = new Block[block_count];
blocks_buffer = new Block[block_count];
for(int i = 0; i < block_count; i++) {
blocks[i].setColor(block_color);
}
restore_buffer();
}
/******************************************************************************
TetrominoJ
Delete the allocated blocks & buffer blocks
Input Parameters:
none
Output:
none
******************************************************************************/
TetrominoL::~TetrominoL() {
delete []blocks;
delete []blocks_buffer;
}
/******************************************************************************
setup()
Sets up each block at its origin locations. The setup may not be successful
due to the existing blocks on the Tetris screen. (This would be game over).
Input Parameters:
none
Output:
True - if setup was successful
False - if unsuccessful
******************************************************************************/
bool TetrominoL::setup() {
for(int i = 0; i < block_count; i++) {
blocks[i].setX(setup_positions_x[i]);
blocks[i].setY(setup_positions_y[i]);
restore_buffer();
}
if(check()) {
return true;
} else {
return false;
}
}
/******************************************************************************
rotate_map
Rotates each block in the Tetromino blocks buffer. Does not actually change
anything in the real blocks.
Input Parameters:
none
Output:
none
******************************************************************************/
void TetrominoL::rotate_map() {
for(int i = 0; i < block_count; i++) {
blocks_buffer[i].setX(blocks_buffer[i].getX() + rotation_positions_x[rotation_state][i]);
blocks_buffer[i].setY(blocks_buffer[i].getY() + rotation_positions_y[rotation_state][i]);
}
}
/******************************************************************************
nextSetup
Sets up the positions of the real (non-buffer) blocks for display on NEXT.
Input Parameters:
none
Output:
none
******************************************************************************/
void TetrominoL::nextSetup(void) {
for(int i = 0; i < block_count; i++) {
blocks[i].setX(next_positions_x[i]);
blocks[i].setY(next_positions_y[i]);
}
}
| [
"[email protected]"
]
| [
[
[
1,
136
]
]
]
|
fad4477e43b6f3377f0cbfa11f58249c04486079 | 723202e673511cf9f243177d964dfeba51cb06a3 | /09/oot/epa_labs/l2/src/ChildFrm.h | bbe9dd2c6f03bcb2e8312a8d0d7f01e2c902734d | []
| no_license | aeremenok/a-team-777 | c2ffe04b408a266f62c523fb8d68c87689f2a2e9 | 0945efbe00c3695c9cc3dbcdb9177ff6f1e9f50b | refs/heads/master | 2020-12-24T16:50:12.178873 | 2009-06-16T14:55:41 | 2009-06-16T14:55:41 | 32,388,114 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,303 | h | // ChildFrm.h : interface of the CChildFrame class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_CHILDFRM_H__623441A9_57EA_11D0_9257_00201834E2A3__INCLUDED_)
#define AFX_CHILDFRM_H__623441A9_57EA_11D0_9257_00201834E2A3__INCLUDED_
class CChildFrame : public CMDIChildWnd
{
DECLARE_DYNCREATE(CChildFrame)
public:
CChildFrame();
// Attributes
public:
CStatusBar m_StatusBar; // Status bar object
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CChildFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CChildFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
protected:
//{{AFX_MSG(CChildFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CHILDFRM_H__623441A9_57EA_11D0_9257_00201834E2A3__INCLUDED_)
| [
"emmanpavel@9273621a-9230-0410-b1c6-9ffd80c20a0c"
]
| [
[
[
1,
48
]
]
]
|
b464a452ccde9acdd9e5df40813b36c0ee1dc403 | 9c62af23e0a1faea5aaa8dd328ba1d82688823a5 | /rl/branches/persistence2/engine/script/include/SoundNodeProcessor.h | 6e3ed97fd6930a2b00c2f993b8a7c514c579a996 | [
"ClArtistic",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
]
| permissive | jacmoe/dsa-hl-svn | 55b05b6f28b0b8b216eac7b0f9eedf650d116f85 | 97798e1f54df9d5785fb206c7165cd011c611560 | refs/heads/master | 2021-04-22T12:07:43.389214 | 2009-11-27T22:01:03 | 2009-11-27T22:01:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,138 | h | /* This source file is part of Rastullahs Lockenpracht.
* Copyright (C) 2003-2008 Team Pantheon. http://www.team-pantheon.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Clarified Artistic License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Clarified Artistic License for more details.
*
* You should have received a copy of the Clarified Artistic License
* along with this program; if not you can get it here
* http://www.jpaulmorrison.com/fbp/artistic2.htm.
*/
#ifndef __SoundNodeProcessor_H__
#define __SoundNodeProcessor_H__
#include <xercesc/dom/DOMElement.hpp>
#include "ScriptPrerequisites.h"
#include "AbstractMapNodeProcessor.h"
namespace rl
{
class SoundNodeProcessor : public AbstractMapNodeProcessor
{
public:
virtual bool processNode(XERCES_CPP_NAMESPACE::DOMElement* nodeElem, bool loadGameObjects);
};
}
#endif // __SoundNodeProcessor_H__
| [
"timm@4c79e8ff-cfd4-0310-af45-a38c79f83013"
]
| [
[
[
1,
34
]
]
]
|
25368ff81693e9954c4ae2b0cc2bb46f2fa87649 | 8a3fce9fb893696b8e408703b62fa452feec65c5 | /GServerEngine/GServerEngine/stdafx.cpp | d54308f5d49c1d7601220ca1de09cd2c01f114ee | []
| no_license | win18216001/tpgame | bb4e8b1a2f19b92ecce14a7477ce30a470faecda | d877dd51a924f1d628959c5ab638c34a671b39b2 | refs/heads/master | 2021-04-12T04:51:47.882699 | 2011-03-08T10:04:55 | 2011-03-08T10:04:55 | 42,728,291 | 0 | 2 | null | null | null | null | GB18030 | C++ | false | false | 273 | cpp | // stdafx.cpp : 只包括标准包含文件的源文件
// GServerEngine.pch 将作为预编译头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"
// TODO: 在 STDAFX.H 中
// 引用任何所需的附加头文件,而不是在此文件中引用
| [
"[email protected]"
]
| [
[
[
1,
8
]
]
]
|
dd7f5907508ef89646a0b3c5947d9f4db3dc5152 | 353bd39ba7ae46ed521936753176ed17ea8546b5 | /src/layer1_system/primitives_2d/src/axp2_circle.cpp | e0c61199339bd14c857f8a4e0ab629a0eb082a76 | []
| no_license | d0n3val/axe-engine | 1a13e8eee0da667ac40ac4d92b6a084ab8a910e8 | 320b08df3a1a5254b776c81775b28fa7004861dc | refs/heads/master | 2021-01-01T19:46:39.641648 | 2007-12-10T18:26:22 | 2007-12-10T18:26:22 | 32,251,179 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,824 | cpp | /**
* @file
* 2D circle code
* @author Ricard Pillosu <d0n3val\@gmail.com>
* @date 29 Aug 2004
*/
#include "axp2_stdafx.h"
/*$1- Info about this primitive ----------------------------------------------*/
float axe_circle::get_area() const
{
return( PI * (radius * radius) );
}
/*$1- Create this primitive from another one ---------------------------------*/
axe_circle &axe_circle::create( const axe_vector2& center, const float& radius )
{
this->center = center;
this->radius = radius;
return( *this );
}
axe_circle &axe_circle::create( const axe_circle& circle )
{
center = circle.center;
radius = circle.radius;
return( *this );
}
/*$1- Intersection test with another primitives ------------------------------*/
int axe_circle::intersect( const axe_vector2& point ) const
{
if( point.distance_pow2_to(center) > (radius * radius) )
{
return( AXE_FALSE );
}
return( AXE_TRUE );
}
int axe_circle::intersect( const axe_circle& circle ) const
{
if( circle.center.distance_pow2_to(center) > (radius * radius) + (circle.radius * circle.radius) )
{
return( AXE_FALSE );
}
return( AXE_TRUE );
}
int axe_circle::intersect( const axe_aa_rectangle& rectangle ) const
{
return( rectangle.intersect(*this) );
}
/*$1- Distance test to another primitives ------------------------------------*/
float axe_circle::get_distance( const axe_circle& circle, const axp2_dist_type distance_type ) const
{
AXE_ASSERT( 0 && "not implemented" );
return( -1.0f );
}
/*$1- Transformation methods -------------------------------------------------*/
void axe_circle::transform( const axe_matrix_3x3& matrix )
{
AXE_ASSERT( 0 && "not implemented" );
}
/* $Id: axp2_circle.cpp,v 1.1 2004/08/29 18:28:45 doneval Exp $ */
| [
"d0n3val@2cff7946-3f3c-0410-b79f-f9b517ddbf54"
]
| [
[
[
1,
69
]
]
]
|
9704ce6247fab6345e95bffdcebc3df3e6f91dee | 4b51d32f40ef5a36c98a53d2a1eab7e6f362cb00 | /CapaIndices/Indices/IndiceHash.h | 027a79b223c7fff30d1e1d75d75e1d4d99a0ea74 | []
| no_license | damian-pisaturo/datos7506 | bcff7f1e9e69af8051ebf464107b92f91be560e4 | a67aac89eccd619cdc02a7e6940980f346981895 | refs/heads/master | 2016-09-06T16:48:18.612868 | 2007-12-10T22:12:28 | 2007-12-10T22:12:28 | 32,679,551 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,266 | h | ///////////////////////////////////////////////////////////////////////////
// Archivo : IndiceHash.h
// Namespace : CapaIndice
////////////////////////////////////////////////////////////////////////////
// 75.06 Organizacion de Datos
// Trabajo practico: Framework de Persistencia
////////////////////////////////////////////////////////////////////////////
// Descripcion
// Cabeceras e interfaz de las clase IndiceHash.
///////////////////////////////////////////////////////////////////////////
// Integrantes
// - Alvarez Fantone, Nicolas;
// - Caravatti, Estefania;
// - Garcia Cabrera, Manuel;
// - Grisolia, Nahuel;
// - Pisaturo, Damian;
// - Rodriguez, Maria Laura.
///////////////////////////////////////////////////////////////////////////
#ifndef INDICEHASH_H_
#define INDICEHASH_H_
#include "../Hash/Hash.h"
#include "Indice.h"
#include <set>
using namespace std;
///////////////////////////////////////////////////////////////////////////
// Clase
//------------------------------------------------------------------------
// Nombre: IndiceHash (Interfaz comun entre los distintos tipos de indices
// y el hash extensible)
//////////////////////////////////////////////////////////////////////////
class IndiceHash :public Indice
{
private:
//////////////////////////////////////////////////////////////////////
// Atributos
//////////////////////////////////////////////////////////////////////
Hash* hash;
ListaTipos* listaTiposClave;
ListaInfoRegistro* listaNodosClave;
public:
///////////////////////////////////////////////////////////////////////
// Constructor/Destructor
///////////////////////////////////////////////////////////////////////
IndiceHash(unsigned char tipoIndice, ListaTipos *listaTiposClave,
ListaInfoRegistro* listaInfoReg, unsigned int tamBloqueLista,
unsigned int tamBucket, const string& nombreArchivo);
virtual ~IndiceHash();
///////////////////////////////////////////////////////////////////////
// Metodos publicos
///////////////////////////////////////////////////////////////////////
/*
* Este metodo inserta un elemento en un indice y guarda el bloque de datos.
**/
virtual int insertar(Clave *clave, char* ®istro, unsigned short tamanioRegistro);
/*
* Este método hace una inserción en un indice secundario; si la clave secundaria
* ya está insertada, agrega la clave primaria a su lista invertida; sino,
* agrega la clave secundaria al indice, y crea su lista invertida correspondiente
* con clave primaria como su unico elemento.
**/
virtual int insertar(Clave *claveSecundaria, Clave* clavePrimaria);
/*
* Este metodo elimina un elemento del indice.
* Si es un índice primario también se elimina el registro de datos.
**/
virtual int eliminar(Clave *clave);
/*
* Este método elimina una clave primaria de la lista de claves primarias
* correspondiente a la clave secundaria.
* Si la lista queda vacía, también se elimina la clave secundaria.
*/
virtual int eliminar(Clave* claveSecundaria, Clave *clavePrimaria);
/*
* Este metodo busca un elemento dentro del indice.
* y devuelve el bloque que contiene el registro de clave "clave"
* dentro de "registro".
**/
virtual int buscar(Clave *clave, char* ®istro, unsigned short &tamanioBucket) const;
/*
* Busca una clave en un indice secundario, y si la encuntra retorna su lista invertida,
* que contiene las claves primarias en listaClaves.
**/
virtual int buscar(Clave *clave, SetClaves* &setClavesPrimarias) const ;
/*
* Método utilizado para saber si una clave ya se encuentra insertada en el índice
*/
virtual int buscar(Clave *clave) const;
/*
* Devuelve ResultadosIndices::ERROR_MODIFICACION si claveVieja no se encuentra en el indice.
* En caso contrario devuelve ResultadosIndices::OK, reemplaza claveVieja
* por claveNueva y reemplaza el viejo registro correspondiente
* a "claveVieja" por "registroNuevo".
**/
virtual int modificar(Clave *claveVieja, Clave *claveNueva,
char* ®istroNuevo, unsigned short tamanioRegistroNuevo);
/*
* Método que llama a la capa física para pedirle un bloque que contenga espacio suficiente
* para insertar un nuevo registro de tamaño 'tamRegistro'
*/
virtual int buscarBloqueDestino(unsigned short tamRegistro, char* bloqueDatos);
SetEnteros getConjuntoBloques();
Bloque* leerBloque(unsigned int nroBloque);
/*
* Método que devuelve el siguiente bloque de disco que contiene
* registros de datos.
*/
virtual int siguienteBloque(Bloque* &bloque);
unsigned int getOffsetToList(char *registro, unsigned short tamanioRegistro) const;
void setOffsetToList(unsigned int offset, char *registro, unsigned short tamanioRegistro);
virtual void primero() {}
virtual void mayorOIgual(Clave* clave) {}
virtual void mayor(Clave* clave) {}
virtual Clave* siguiente() { return NULL; }
private:
ListaInfoRegistro* getListaNodosClave() const;
};
#endif /*INDICEHASH_H_*/
| [
"nfantone@4ef8b2a0-b237-0410-b753-5dc98fa25004",
"manugarciacab@4ef8b2a0-b237-0410-b753-5dc98fa25004",
"ecaravatti@4ef8b2a0-b237-0410-b753-5dc98fa25004",
"dpisaturo@4ef8b2a0-b237-0410-b753-5dc98fa25004",
"rdz.maria.laura@4ef8b2a0-b237-0410-b753-5dc98fa25004"
]
| [
[
[
1,
19
],
[
29,
40
],
[
46,
48
],
[
54,
59
],
[
61,
61
],
[
72,
72
],
[
75,
75
],
[
85,
85
],
[
88,
89
],
[
103,
103
],
[
108,
108
]
],
[
[
20,
23
],
[
28,
28
],
[
44,
45
],
[
53,
53
],
[
71,
71
],
[
77,
77
],
[
97,
97
],
[
117,
118
],
[
139,
142
]
],
[
[
24,
27
],
[
60,
60
],
[
62,
69
],
[
73,
74
],
[
76,
76
],
[
83,
83
],
[
86,
87
],
[
90,
95
],
[
98,
102
],
[
104,
107
],
[
109,
110
],
[
112,
115
],
[
119,
121
],
[
128,
128
],
[
131,
131
]
],
[
[
41,
42
],
[
49,
49
],
[
51,
52
],
[
78,
82
],
[
84,
84
],
[
96,
96
],
[
111,
111
],
[
116,
116
],
[
122,
127
],
[
137,
137
]
],
[
[
43,
43
],
[
50,
50
],
[
70,
70
],
[
129,
130
],
[
132,
136
],
[
138,
138
]
]
]
|
165bd1d93eb19a37ecab667ebb326115f651f90a | 1e01b697191a910a872e95ddfce27a91cebc57dd | /CppParsingTree.cpp | 83bb1aac02f52b25ca6aa4bd47ad30be9964d16c | []
| no_license | canercandan/codeworker | 7c9871076af481e98be42bf487a9ec1256040d08 | a68851958b1beef3d40114fd1ceb655f587c49ad | refs/heads/master | 2020-05-31T22:53:56.492569 | 2011-01-29T19:12:59 | 2011-01-29T19:12:59 | 1,306,254 | 7 | 5 | null | null | null | null | IBM852 | C++ | false | false | 17,098 | cpp | /* "CodeWorker": a scripting language for parsing and generating text.
Copyright (C) 1996-1997, 1999-2002 CÚdric Lemaire
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
To contact the author: [email protected]
*/
#ifdef WIN32
#pragma warning(disable : 4786)
#endif
#ifndef WIN32
# include <cstdio> // for Debian/gcc 2.95.4
#endif
#include "ScpStream.h"
#include "UtlException.h"
#include "ExprScriptVariable.h"
#include "DtaScriptVariable.h"
#include "DtaProject.h"
#include "DtaScript.h"
#include "CppParsingTree.h"
namespace CodeWorker {
CppParsingTree_expr::CppParsingTree_expr(const std::string& sExpression) {
DtaScript theEmptyScript(NULL);
GrfBlock* pBlock = NULL;
GrfBlock& myNullBlock = *pBlock;
ScpStream myStream(sExpression);
_pExpression = theEmptyScript.parseExpression(myNullBlock, myStream);
}
CppParsingTree_expr::~CppParsingTree_expr() {
delete _pExpression;
}
CppParsingTree_varexpr::CppParsingTree_varexpr(const std::string& sVariableExpression) {
DtaScript theEmptyScript(NULL);
GrfBlock* pBlock = NULL;
GrfBlock& myNullBlock = *pBlock;
ScpStream myStream(sVariableExpression);
_pExpression = theEmptyScript.parseVariableExpression(myNullBlock, myStream);
}
ExprScriptVariable& CppParsingTree_varexpr::getVariableExpression() const {
return *dynamic_cast<ExprScriptVariable*>(_pExpression);
}
CppParsingTree_var::CppParsingTree_var() : _pInternalNode(NULL) {
}
CppParsingTree_var::CppParsingTree_var(const CppParsingTree_var& tree) {
_pInternalNode = tree._pInternalNode;
}
CppParsingTree_var::CppParsingTree_var(DtaScriptVariable* pVariable) : _pInternalNode(pVariable) {
}
CppParsingTree_var::CppParsingTree_var(DtaScriptVariable& variable) : _pInternalNode(&variable) {
}
bool CppParsingTree_var::isLocal() const {
if (_pInternalNode == NULL) return false;
return _pInternalNode->isLocal();
}
ExternalValueNode* CppParsingTree_var::getExternalValueNode() const {
if (_pInternalNode == NULL) return NULL;
return _pInternalNode->getExternalValueNode();
}
const char* CppParsingTree_var::getName() const {
if (_pInternalNode == NULL) return NULL;
return _pInternalNode->getName();
}
const char* CppParsingTree_var::getValue() const {
if (_pInternalNode == NULL) return NULL;
return _pInternalNode->getValue();
}
size_t CppParsingTree_var::getValueLength() const {
if (_pInternalNode == NULL) return 0;
return _pInternalNode->getValueLength();
}
bool CppParsingTree_var::getBooleanValue() const {
if (_pInternalNode == NULL) return 0;
const char* tcValue = _pInternalNode->getValue();
return (tcValue != NULL) && (*tcValue != '\0');
}
int CppParsingTree_var::getIntValue() const {
if (_pInternalNode == NULL) return 0;
const char* tcValue = _pInternalNode->getValue();
if (tcValue == NULL) return 0;
return atoi(tcValue);
}
double CppParsingTree_var::getDoubleValue() const {
if (_pInternalNode == NULL) return 0.0;
const char* tcValue = _pInternalNode->getValue();
if (tcValue == NULL) return 0.0;
return atof(tcValue);
}
std::string CppParsingTree_var::getStringValue() const {
const char* tcValue = getValue();
return ((tcValue == NULL) ? "" : tcValue);
}
DtaScriptVariable* CppParsingTree_var::getReference() const {
if (_pInternalNode == NULL) return 0;
return _pInternalNode->getReferencedVariable();
}
void CppParsingTree_var::clearValue() const {
if (_pInternalNode != NULL) _pInternalNode->clearValue();
}
void CppParsingTree_var::setValue(const char* tcValue) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to set value \"" + std::string(tcValue) + "\" to an empty node");
_pInternalNode->setValue(tcValue);
}
void CppParsingTree_var::setValue(const std::string& sValue) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to set value \"" + sValue + "\" to an empty node");
_pInternalNode->setValue(sValue.c_str());
}
void CppParsingTree_var::setValue(double dValue) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to set a numeric to an empty node");
_pInternalNode->setValue(dValue);
}
void CppParsingTree_var::setValue(bool bValue) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to set a boolean to an empty node");
_pInternalNode->setValue((bValue ? "true" : ""));
}
void CppParsingTree_var::setValue(int iValue) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to set an integer to an empty node");
_pInternalNode->setValue(iValue);
}
void CppParsingTree_var::setValue(const CppParsingTree_var& pValue) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to set a value to an empty node");
if (pValue._pInternalNode == NULL) _pInternalNode->setValue((const char*) NULL);
_pInternalNode->setValue(pValue.getValue());
}
void CppParsingTree_var::setValue(ExternalValueNode* pExternal) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to set a value to an empty node");
_pInternalNode->setValue(pExternal);
}
void CppParsingTree_var::setValue(const std::list<std::string>& listOfValues) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to set an array of strings to an empty node");
_pInternalNode->setValue(listOfValues);
}
void CppParsingTree_var::concatenateValue(const std::string& sValue) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to concatenate value \"" + sValue + "\" to an empty node");
const char* tcLeft = _pInternalNode->getValue();
if (tcLeft != NULL) {
std::string sConcatenation(tcLeft);
sConcatenation += sValue;
_pInternalNode->setValue(sConcatenation.c_str());
} else {
_pInternalNode->setValue(sValue.c_str());
}
}
void CppParsingTree_var::concatenateValue(const CppParsingTree_var& pValue) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to concatenate a value to an empty node");
const char* tcLeft = _pInternalNode->getValue();
const char* tcValue = pValue.getValue();
if (tcLeft != NULL) {
std::string sConcatenation(tcLeft);
if (tcValue != 0) sConcatenation += tcValue;
_pInternalNode->setValue(sConcatenation.c_str());
} else {
_pInternalNode->setValue(tcValue);
}
}
void CppParsingTree_var::setReference(const CppParsingTree_var& reference) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to assign a reference to an empty node");
if (reference._pInternalNode == NULL) throw UtlException("internal error: trying to assign an empty node as reference");
_pInternalNode->setValue(reference._pInternalNode);
}
void CppParsingTree_var::setAll(const CppParsingTree_var& tree) const {
if (tree._pInternalNode == NULL) throw UtlException("internal error: trying to assign an empty subtree to a node");
_pInternalNode->copyAll(*tree._pInternalNode);
}
void CppParsingTree_var::merge(const CppParsingTree_var& tree) const {
if (tree._pInternalNode == NULL) throw UtlException("internal error: trying to assign an empty subtree to a node");
_pInternalNode->copyAll(*tree._pInternalNode, true);
}
CppParsingTree_var CppParsingTree_var::pushItem() const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to push a value to the array of an empty node");
return _pInternalNode->pushItem("");
}
void CppParsingTree_var::pushItem(const std::string& sValue) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to push a value to the array of an empty node");
_pInternalNode->pushItem(sValue);
}
void CppParsingTree_var::pushItem(const CppParsingTree_var& theValue) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to push a value to the array of an empty node");
_pInternalNode->pushItem(theValue.getStringValue());
}
void CppParsingTree_var::addElements(const CppParsingTree_var& theValue) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to add elements to the array of an empty node");
if (theValue._pInternalNode != NULL) _pInternalNode->addArrayElements(*(theValue._pInternalNode));
}
const std::list<DtaScriptVariable*>* CppParsingTree_var::getArray() const {
if (_pInternalNode == NULL) return NULL;
return _pInternalNode->getArray();
}
const std::map<std::string, DtaScriptVariable*>* CppParsingTree_var::getSortedArray() const {
if (_pInternalNode == NULL) return NULL;
return _pInternalNode->getSortedArray();
}
std::auto_ptr<std::vector<DtaScriptVariable*> > CppParsingTree_var::getSortedNoCaseArray() const {
if (_pInternalNode == NULL) return std::auto_ptr<std::vector<DtaScriptVariable*> >(new std::vector<DtaScriptVariable*>());
return _pInternalNode->getSortedNoCaseArray();
}
std::auto_ptr<std::vector<DtaScriptVariable*> > CppParsingTree_var::getSortedArrayOnValue() const {
if (_pInternalNode == NULL) return std::auto_ptr<std::vector<DtaScriptVariable*> >(new std::vector<DtaScriptVariable*>());
return _pInternalNode->getSortedArrayOnValue();
}
std::auto_ptr<std::vector<DtaScriptVariable*> > CppParsingTree_var::getSortedNoCaseArrayOnValue() const {
if (_pInternalNode == NULL) return std::auto_ptr<std::vector<DtaScriptVariable*> >(new std::vector<DtaScriptVariable*>());
return _pInternalNode->getSortedNoCaseArrayOnValue();
}
std::list<std::string> CppParsingTree_var::getAttributeNames() const {
std::list<std::string> attributes;
if (_pInternalNode != NULL) {
DtaScriptVariableList* pAttributes = _pInternalNode->getAttributes();
while (pAttributes != NULL) {
DtaScriptVariable* pNode = pAttributes->getNode();
attributes.push_back(pNode->getName());
pAttributes = pAttributes->getNext();
}
}
return attributes;
}
void CppParsingTree_var::clearNode() const {
if (_pInternalNode != NULL) _pInternalNode->clearContent();
}
CppParsingTree_var CppParsingTree_var::getNode(const std::string& sBranch) const {
if (_pInternalNode == NULL) return CppParsingTree_var();
DtaScriptVariable* pVariable = _pInternalNode->getNode(sBranch.c_str());
return CppParsingTree_var(pVariable);
}
CppParsingTree_var CppParsingTree_var::getEvaluatedNode(const std::string& sDynamicVariable) const {
if (_pInternalNode == NULL) return CppParsingTree_var();
DtaScriptVariable* pVariable = _pInternalNode->getEvaluatedNode(sDynamicVariable);
return CppParsingTree_var(pVariable);
}
CppParsingTree_var CppParsingTree_var::getOrCreateLocalEvaluatedNode(const std::string& sDynamicVariable) const {
if (_pInternalNode == NULL) return CppParsingTree_var();
DtaScriptVariable* pVariable = _pInternalNode->getOrCreateLocalEvaluatedNode(sDynamicVariable);
return CppParsingTree_var(pVariable);
}
CppParsingTree_var CppParsingTree_var::getParentNode() const {
if (_pInternalNode == NULL) return CppParsingTree_var();
DtaScriptVariable* pVariable = _pInternalNode->getParent();
return CppParsingTree_var(pVariable);
}
CppParsingTree_var CppParsingTree_var::getRootNode() const {
if (_pInternalNode == NULL) return CppParsingTree_var();
DtaScriptVariable* pVariable = _pInternalNode->getRoot();
return CppParsingTree_var(pVariable);
}
CppParsingTree_var CppParsingTree_var::getArrayNodeFromKey(const std::string& sKey) const {
if (_pInternalNode == NULL) return CppParsingTree_var();
DtaScriptVariable* pVariable = _pInternalNode->getArrayElement(sKey);
return CppParsingTree_var(pVariable);
}
CppParsingTree_var CppParsingTree_var::getArrayNodeFromPosition(int iPosition) const {
if (_pInternalNode == NULL) return CppParsingTree_var();
DtaScriptVariable* pVariable = _pInternalNode->getArrayElement(iPosition);
return CppParsingTree_var(pVariable);
}
CppParsingTree_var CppParsingTree_var::getFirstArrayNode() const {
if (_pInternalNode == NULL) return CppParsingTree_var();
DtaScriptVariable* pVariable = _pInternalNode->getArrayElement((int) 0);
return CppParsingTree_var(pVariable);
}
CppParsingTree_var CppParsingTree_var::getLastArrayNode() const {
if (_pInternalNode == NULL) return CppParsingTree_var();
DtaScriptVariable* pVariable = _pInternalNode->getArrayElement(_pInternalNode->getArraySize() - 1);
return CppParsingTree_var(pVariable);
}
CppParsingTree_var CppParsingTree_var::insertNode(const std::string& sBranch) const {
if (_pInternalNode == NULL) {
throw UtlException("internal error: trying to insert the node '" + sBranch + "' into an empty tree");
}
DtaScriptVariable* pVariable = _pInternalNode->insertNode(sBranch.c_str());
return CppParsingTree_var(pVariable);
}
CppParsingTree_var CppParsingTree_var::insertEvaluatedNode(const std::string& sDynamicVariable) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to insert an evaluated node '" + sDynamicVariable + "' into an empty tree");
DtaScriptVariable* pVariable = _pInternalNode->insertEvaluatedNode(sDynamicVariable);
return CppParsingTree_var(pVariable);
}
CppParsingTree_var CppParsingTree_var::insertClassicalEvaluatedNode(const std::string& sDynamicVariable) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to insert an evaluated node '" + sDynamicVariable + "' into an empty tree");
DtaScriptVariable* pVariable = _pInternalNode->insertClassicalEvaluatedNode(sDynamicVariable);
return CppParsingTree_var(pVariable);
}
CppParsingTree_var CppParsingTree_var::insertArrayNodeFromKey(const std::string& sKey) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to insert '" + sKey + "' key node into an empty array");
DtaScriptVariable* pVariable = _pInternalNode->addElement(sKey);
return CppParsingTree_var(pVariable);
}
CppParsingTree_var CppParsingTree_var::insertArrayNodeFromKey(int iKey) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to insert key node into an empty array");
char tcNumber[16];
sprintf(tcNumber, "%d", iKey);
DtaScriptVariable* pVariable = _pInternalNode->addElement(tcNumber);
return CppParsingTree_var(pVariable);
}
CppParsingTree_var CppParsingTree_var::insertArrayNodeFromKey(const CppParsingTree_var& pKey) const {
if (_pInternalNode == NULL) throw UtlException("internal error: trying to insert key node into an empty tree");
DtaScriptVariable* pVariable = _pInternalNode->addElement(pKey.getValue());
return CppParsingTree_var(pVariable);
}
CppParsingTree_value::CppParsingTree_value() {
_pInternalNode = new DtaScriptVariable;
}
CppParsingTree_value::CppParsingTree_value(const char* tcValue) {
_pInternalNode = new DtaScriptVariable;
_pInternalNode->setValue(tcValue);
}
CppParsingTree_value::CppParsingTree_value(const CppParsingTree_var& tree) {
_pInternalNode = new DtaScriptVariable;
setValue(tree);
}
CppParsingTree_value::CppParsingTree_value(const CppParsingTree_value& tree) {
_pInternalNode = new DtaScriptVariable;
setValue(tree);
}
CppParsingTree_value::CppParsingTree_value(bool bValue) {
_pInternalNode = new DtaScriptVariable;
_pInternalNode->setValue(bValue);
}
CppParsingTree_value::CppParsingTree_value(int iValue) {
_pInternalNode = new DtaScriptVariable;
_pInternalNode->setValue(iValue);
}
CppParsingTree_value::CppParsingTree_value(double dValue) {
_pInternalNode = new DtaScriptVariable;
_pInternalNode->setValue(dValue);
}
CppParsingTree_value::CppParsingTree_value(const std::string& sValue) {
_pInternalNode = new DtaScriptVariable;
_pInternalNode->setValue(sValue.c_str());
}
CppParsingTree_value::~CppParsingTree_value() {
delete _pInternalNode;
}
void CppParsingTree_global::initialize(const std::string& sName) {
_pInternalNode = DtaProject::getInstance().getGlobalVariable(sName);
if (_pInternalNode == NULL) {
_pInternalNode = DtaProject::getInstance().setGlobalVariable(sName);
}
}
}
| [
"cedric.p.r.lemaire@28b3f5f3-d42e-7560-b87f-5f53cf622bc4"
]
| [
[
[
1,
425
]
]
]
|
98d4046dc251716e3e9f9371e197041d8a9f049f | 9c62af23e0a1faea5aaa8dd328ba1d82688823a5 | /rl/branches/newton20/engine/rules/src/QuestBook.cpp | c37e1a747c38c67654c3b0aba9408e1b2dd60b00 | [
"ClArtistic",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
]
| permissive | jacmoe/dsa-hl-svn | 55b05b6f28b0b8b216eac7b0f9eedf650d116f85 | 97798e1f54df9d5785fb206c7165cd011c611560 | refs/heads/master | 2021-04-22T12:07:43.389214 | 2009-11-27T22:01:03 | 2009-11-27T22:01:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,224 | cpp | /* This source file is part of Rastullahs Lockenpracht.
* Copyright (C) 2003-2008 Team Pantheon. http://www.team-pantheon.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Clarified Artistic License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Clarified Artistic License for more details.
*
* You should have received a copy of the Clarified Artistic License
* along with this program; if not you can get it here
* http://www.jpaulmorrison.com/fbp/artistic2.htm.
*/
#include "stdinc.h" //precompiled header
#include "QuestBook.h"
#include "Quest.h"
#include "Exception.h"
#include "ScriptWrapper.h"
#include "SaveGameManager.h"
using namespace std;
using namespace XERCES_CPP_NAMESPACE;
namespace rl {
const Ogre::String QuestBook::PROPERTY_QUESTS = "quests";
const Ogre::String QuestBook::PROPERTY_JOURNAL = "journal";
QuestBook::QuestBook()
: mJournalEntries(),
mQuestEventCaster(),
mJournalEventCaster(),
ScriptLoader()
{
mScriptPatterns.push_back("*.quests");
createRoot();
SaveGameManager::getSingleton().registerSaveGameData(this);
}
QuestBook::~QuestBook()
{
SaveGameManager::getSingleton().unregisterSaveGameData(this);
delete mRootQuest;
for( vector<JournalEntry*>::iterator it = mJournalEntries.begin();
it != mJournalEntries.end(); it++ )
{
delete *it;
}
mJournalEntries.clear();
}
void QuestBook::createRoot()
{
mRootQuest = new Quest("<root>", "<root>", "<root>");
mRootQuest->setQuestBook(this);
mRootQuest->setState(Quest::OPEN);
}
Quest* QuestBook::getQuest(const CeGuiString id) const
{
return getQuest(mRootQuest, id);
}
Quest* QuestBook::getQuest(Quest* parent, const CeGuiString id) const
{
if (parent->getId().compare(id) == 0)
return parent;
QuestVector children = parent->getSubquests();
for(QuestVector::iterator it = children.begin(); it != children.end(); it++)
{
Quest* subquest = getQuest(*it, id);
if (subquest)
{
return subquest;
}
}
return NULL;
}
void QuestBook::addQuest(Quest* quest)
{
mRootQuest->addSubquest(quest);
}
void QuestBook::_fireQuestBookChanged(Quest *quest, int reason)
{
QuestEvent* evt = new QuestEvent(this, reason);
evt->setQuest(quest);
mQuestEventCaster.dispatchEvent(evt);
delete evt;
}
void QuestBook::fireJournalChanged(JournalEntry* entry, int reason)
{
JournalEvent evt = JournalEvent(this, reason, entry);
mJournalEventCaster.dispatchEvent(&evt);
}
void QuestBook::addQuestListener(QuestListener* listener)
{
if (mQuestEventCaster.containsListener(listener) !=
mJournalEventCaster.containsListener(listener))
{
Throw(AssertionFailedError, "listener registration inconsistent");
}
else if (!mJournalEventCaster.containsListener(listener))
{
mJournalEventCaster.addEventListener(listener);
mQuestEventCaster.addEventListener(listener);
ScriptWrapper::getSingleton().owned( listener );
}
}
void QuestBook::removeQuestListener(QuestListener* listener)
{
if (mQuestEventCaster.containsListener(listener) !=
mJournalEventCaster.containsListener(listener))
{
Throw(AssertionFailedError, "listener registration inconsistent");
}
else if (mJournalEventCaster.containsListener( listener ))
{
mJournalEventCaster.removeEventListener(listener);
mQuestEventCaster.removeEventListener(listener);
ScriptWrapper::getSingleton().disowned( listener );
}
}
QuestVector QuestBook::getTopLevelQuests() const
{
return mRootQuest->getSubquests();
}
void QuestBook::addJournalEntry(JournalEntry* entry)
{
mJournalEntries.push_back(entry);
LOG_MESSAGE(
Logger::RULES,
Ogre::String("Journal entry added: ") + entry->getCaption());
fireJournalChanged(entry, JournalEvent::JOURNAL_ENTRY_ADDED);
}
void QuestBook::addJournalEntry(CeGuiString caption, CeGuiString text)
{
addJournalEntry(new JournalEntry(caption, text));
}
unsigned int QuestBook::getNumJournalEntries() const
{
return mJournalEntries.size();
}
JournalEntry* QuestBook::getJournalEntry(unsigned int index) const
{
if (mJournalEntries.size() <= index)
{
Throw(IllegalArgumentException, "No such JournalEntry.");
}
return mJournalEntries[index];
}
const Property QuestBook::getProperty(const CeGuiString& key) const
{
if (key == PROPERTY_QUESTS)
{
//PropertyArray quests;
//QuestVector allQuests = getAllQuests();
//for (QuestVector::const_iterator it = allQuests.begin();
// it != allQuests.end(); ++it)
//{
// PropertyRecord* questProps = (*it)->getAllProperties();
// quests.push_back(Property(questProps->toPropertyMap()));
// delete questProps;
//}
//return Property(quests);
return getQuestsProperty(mRootQuest);
}
else if (key == PROPERTY_JOURNAL)
{
PropertyArray journals;
for(std::vector<JournalEntry*>::const_iterator iter = mJournalEntries.begin(); iter != mJournalEntries.end(); iter++)
{
PropertyRecord journal;
journal.setProperty(JournalEntry::PROPERTY_CAPTION, Property((*iter)->getCaption()));
journal.setProperty(JournalEntry::PROPERTY_TEXT, Property((*iter)->getText()));
journals.push_back(journal.toPropertyMap());
}
return Property(journals);
}
else
{
Throw(IllegalArgumentException, key + " is not a property of QuestBook");
}
}
PropertyArray QuestBook::getQuestsProperty(const Quest* rootQuest) const
{
PropertyArray parray;
if(rootQuest->hasSubquests())
{
QuestVector quests = rootQuest->getSubquests();
for(unsigned int i = 0; i < quests.size(); i++)
{
PropertyMap map = quests[i]->getAllProperties()->toPropertyMap();
if(quests[i]->hasSubquests())
map.insert(std::pair<CeGuiString, Property>("quests", getQuestsProperty(quests[i])));
parray.push_back(map);
}
}
return parray;
}
void QuestBook::setProperty(const CeGuiString& key, const Property& value)
{
if (key == PROPERTY_QUESTS)
{
setQuestsProperty(value.toArray(), mRootQuest);
/*PropertyArray quests = value.toArray();
for (PropertyArray::const_iterator it = quests.begin();
it != quests.end(); ++it)
{
PropertyMap curVal = it->toMap();
CeGuiString id = curVal[Quest::PROPERTY_ID];
Quest* quest = getQuest(id);
if (!quest)
{
quest = new Quest(id);
addQuest(quest);
}
quest->setProperties(curVal);
}*/
///@todo implement
}
else if (key == PROPERTY_JOURNAL)
{
PropertyArray journals = value.toArray();
for(PropertyArray::const_iterator it = journals.begin(); it != journals.end(); it++)
{
PropertyMap curVal = it->toMap();
Property caption = curVal[JournalEntry::PROPERTY_CAPTION];
Property text = curVal[JournalEntry::PROPERTY_TEXT];
addJournalEntry(caption.toString(), text.toString());
}
}
else
{
Throw(IllegalArgumentException, key + " is not a property of QuestBook");
}
}
void QuestBook::setQuestsProperty(PropertyArray array, Quest* rootQuest)
{
for (PropertyArray::const_iterator it = array.begin(); it != array.end(); ++it)
{
PropertyMap curVal = it->toMap();
CeGuiString id = curVal[Quest::PROPERTY_ID];
Quest* quest = getQuest(id);
if (!quest)
{
quest = new Quest(id);
rootQuest->addSubquest(quest);
}
quest->setProperties(curVal);
if(curVal.find("quests") != curVal.end())
{
setQuestsProperty(curVal["quests"], quest);
}
}
///@todo implement
}
PropertyKeys QuestBook::getAllPropertyKeys() const
{
PropertyKeys keys;
keys.insert(PROPERTY_QUESTS);
keys.insert(PROPERTY_JOURNAL);
return keys;
}
QuestVector QuestBook::getAllQuests() const
{
QuestVector quests = getTopLevelQuests();
unsigned int lastPos = 0;
while (lastPos < quests.size())
{
QuestVector sub = quests[lastPos]->getSubquests();
for (QuestVector::const_iterator it = sub.begin(); it != sub.end(); ++it)
{
quests.push_back(*it);
}
++lastPos;
}
return quests;
}
CeGuiString QuestBook::getXmlNodeIdentifier() const
{
return "questbook";
}
void QuestBook::writeData(SaveGameFileWriter *writer)
{
LOG_MESSAGE(Logger::RULES, "Saving questbook");
PropertyRecordPtr set = getAllProperties();
writer->writeEachProperty(this, set->toPropertyMap());
}
void QuestBook::readData(SaveGameFileReader* reader)
{
LOG_MESSAGE(Logger::RULES, "Loading questbook");
clear();
PropertyRecordPtr properties = reader->getAllPropertiesAsRecord(this);
setProperties(properties);
}
void QuestBook::clear()
{
delete mRootQuest;
for( vector<JournalEntry*>::iterator it = mJournalEntries.begin();
it != mJournalEntries.end(); )
{
JournalEntry* entry = *it;
it = mJournalEntries.erase(it);
fireJournalChanged(entry, JournalEvent::JOURNAL_ENTRY_DELETED);
delete entry;
}
createRoot();
}
int QuestBook::getPriority() const
{
return 101;
}
const Ogre::StringVector &QuestBook::getScriptPatterns(void) const
{
return mScriptPatterns;
}
void QuestBook::parseScript(Ogre::DataStreamPtr& stream,const Ogre::String& groupname)
{
initializeXml();
DOMDocument* doc = loadDocument(stream);
if (doc)
{
for (DOMNode* cur = doc->getDocumentElement()->getFirstChild(); cur != NULL; cur = cur->getNextSibling())
{
if(hasNodeName(cur, "quest"))
{
processQuest(static_cast<DOMElement*>(cur), mRootQuest);
}
}
}
else
LOG_ERROR(Logger::RULES,"Quests XML is not valid!");
shutdownXml();
}
Ogre::Real QuestBook::getLoadingOrder(void) const
{
return 1000;
}
Quest* QuestBook::processQuest(XERCES_CPP_NAMESPACE::DOMElement* questXml, Quest* parent)
{
Quest* quest = new Quest(getAttributeValueAsString(questXml, "id"));
parent->addSubquest(quest);
quest->setKnown(false);
quest->setState(Quest::OPEN);
for (DOMNode* cur = questXml->getFirstChild(); cur != NULL; cur = cur->getNextSibling())
{
if(hasNodeName(cur, "name"))
quest->setProperty(Quest::PROPERTY_NAME, Property(getValueAsString(static_cast<DOMElement*>(cur))));
if(hasNodeName(cur, "description"))
quest->setProperty(Quest::PROPERTY_DESCRIPTION, Property(getValueAsString(static_cast<DOMElement*>(cur))));
if(hasNodeName(cur, "known"))
quest->setKnown(getValueAsBool(static_cast<DOMElement*>(cur)));
if(hasNodeName(cur, "state"))
quest->setState(Quest::getStateFromName(getValueAsString(static_cast<DOMElement*>(cur))));
if(hasNodeName(cur, "quest"))
processQuest(static_cast<DOMElement*>(cur), quest);
}
return quest;
}
}
| [
"melven@4c79e8ff-cfd4-0310-af45-a38c79f83013"
]
| [
[
[
1,
407
]
]
]
|
14299feb368be6035d99c646ee659136707bdd98 | e02fa80eef98834bf8a042a09d7cb7fe6bf768ba | /MyGUIEngine/include/MyGUI_Prerequest.h | 356882b4b54551b01270e33902b3f8dec205197d | []
| no_license | MyGUI/mygui-historical | fcd3edede9f6cb694c544b402149abb68c538673 | 4886073fd4813de80c22eded0b2033a5ba7f425f | refs/heads/master | 2021-01-23T16:40:19.477150 | 2008-03-06T22:19:12 | 2008-03-06T22:19:12 | 22,805,225 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,406 | h | /*!
@file
@author Denis Koronchik
@author Georgiy Evmenov
@date 09/2007
*/
#ifndef __MYGUI_PREREQUEST_H__
#define __MYGUI_PREREQUEST_H__
#include "MyGUI_Platform.h"
#include <string>
#include <list>
#include <set>
#include <map>
#include <vector>
#include <deque>
#include "MyGUI_Utility.h"
#include "MyGUI_Delegate.h"
namespace MyGUI
{
class Gui;
class DynLib;
class Plugin;
using MyGUI::delegates::newDelegate;
class WidgetSkinInfo;
class MaskPeekInfo;
// managers
class InputManager;
class SubWidgetManager;
class ClipboardManager;
class LayerManager;
class SkinManager;
class WidgetManager;
class LayoutManager;
class FontManager;
class PointerManager;
class DynLibManager;
class PluginManager;
class ControllerManager;
// widgets
class Button;
class ComboBox;
class Edit;
class HScroll;
class List;
class Sheet;
class StaticImage;
class StaticText;
class Tab;
class VScroll;
class Window;
class Message;
class Progress;
class RenderBox;
class ItemBox;
class MultiList;
class PopupMenu;
class FoorBar;
// widget pointers
typedef Button* ButtonPtr;
typedef ComboBox* ComboBoxPtr;
typedef Edit * EditPtr;
typedef HScroll * HScrollPtr;
typedef List * ListPtr;
typedef Sheet * SheetPtr;
typedef StaticImage * StaticImagePtr;
typedef StaticText* StaticTextPtr;
typedef Tab* TabPtr;
typedef VScroll* VScrollPtr;
typedef Window * WindowPtr;
typedef Message * MessagePtr;
typedef Progress * ProgressPtr;
typedef RenderBox * RenderBoxPtr;
typedef ItemBox * ItemBoxPtr;
typedef MultiList * MultiListPtr;
typedef PopupMenu * PopupMenuPtr;
//typedef FooBar* FooBarPtr;
class WidgetFactoryInterface;
namespace factory{
class WidgetFactory;
class ButtonFactory;
class ComboBoxFactory;
class EditFactory;
class HScrollFactory;
class ListFactory;
class SheetFactory;
class StaticImageFactory;
class StaticTextFactory;
class TabFactory;
class VScrollFactory;
class WidgetFactory;
class WindowFactory;
class MessageFactory;
class ProgressFactory;
class RenderBoxFactory;
class ItemBoxFactory;
class MultiListFactory;
class PopupMenuFactory;
class FooBarFactory;
}
// Define version
#define MYGUI_VERSION_MAJOR 2
#define MYGUI_VERSION_MINOR 0
#define MYGUI_VERSION_PATCH 1
#define MYGUI_VERSION ((MYGUI_VERSION_MAJOR << 16) | (MYGUI_VERSION_MINOR << 8) | MYGUI_VERSION_PATCH)
// Disable warnings for MSVC compiler
#if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
// Turn off warnings generated by long std templates
// This warns about truncation to 255 characters in debug/browse info
# pragma warning (disable : 4786)
// Turn off warnings generated by long std templates
// This warns about truncation to 255 characters in debug/browse info
# pragma warning (disable : 4503)
// disable: "conversion from 'double' to 'float', possible loss of data
# pragma warning (disable : 4244)
// disable: "truncation from 'double' to 'float'
# pragma warning (disable : 4305)
// disable: "<type> needs to have dll-interface to be used by clients'
// Happens on STL member variables which are not public therefore is ok
# pragma warning (disable : 4251)
// disable: "non dll-interface class used as base for dll-interface class"
// Happens when deriving from Singleton because bug in compiler ignores
// template export
# pragma warning (disable : 4275)
// disable: "C++ Exception Specification ignored"
// This is because MSVC 6 did not implement all the C++ exception
// specifications in the ANSI C++ draft.
# pragma warning( disable : 4290 )
// disable: "no suitable definition provided for explicit template
// instantiation request" Occurs in VC7 for no justifiable reason on all
// #includes of Singleton
# pragma warning( disable: 4661)
// disable: deprecation warnings when using CRT calls in VC8
// These show up on all C runtime lib code in VC8, disable since they clutter
// the warnings with things we may not be able to do anything about (e.g.
// generated code from nvparse etc). I doubt very much that these calls
// will ever be actually removed from VC anyway, it would break too much code.
# pragma warning( disable: 4996)
#endif
} // namespace MyGUI
#endif // __MYGUI_PREREQUEST_H__
| [
"[email protected]",
"[email protected]",
"[email protected]"
]
| [
[
[
1,
2
],
[
4,
4
],
[
27,
27
],
[
31,
36
],
[
38,
45
],
[
47,
58
],
[
61,
61
],
[
63,
63
],
[
66,
78
],
[
81,
81
],
[
83,
83
],
[
86,
101
],
[
104,
104
],
[
106,
106
],
[
109,
109
]
],
[
[
3,
3
],
[
5,
7
],
[
13,
14
],
[
16,
17
],
[
21,
21
],
[
23,
23
],
[
25,
26
],
[
30,
30
],
[
37,
37
],
[
46,
46
],
[
65,
65
],
[
85,
85
],
[
108,
108
],
[
110,
110
],
[
118,
162
]
],
[
[
8,
12
],
[
15,
15
],
[
18,
20
],
[
22,
22
],
[
24,
24
],
[
28,
29
],
[
59,
60
],
[
62,
62
],
[
64,
64
],
[
79,
80
],
[
82,
82
],
[
84,
84
],
[
102,
103
],
[
105,
105
],
[
107,
107
],
[
111,
117
],
[
163,
166
]
]
]
|
376e5614a4a88431b7bcc713eb9ba95141e1b0e9 | 2e5fd1fc05c0d3b28f64abc99f358145c3ddd658 | /deps/quickfix/src/.NET/CPPLog.h | 4c7aa8c70440ccf91e6ffdc14b45cc019f5d6080 | [
"BSD-2-Clause"
]
| permissive | indraj/fixfeed | 9365c51e2b622eaff4ce5fac5b86bea86415c1e4 | 5ea71aab502c459da61862eaea2b78859b0c3ab3 | refs/heads/master | 2020-12-25T10:41:39.427032 | 2011-02-15T13:38:34 | 2011-02-15T20:50:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,393 | h | /* -*- C++ -*- */
/****************************************************************************
** Copyright (c) quickfixengine.org All rights reserved.
**
** This file is part of the QuickFIX FIX Engine
**
** This file may be distributed under the terms of the quickfixengine.org
** license as defined by quickfixengine.org and appearing in the file
** LICENSE included in the packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.quickfixengine.org/LICENSE for licensing information.
**
** Contact [email protected] if any conditions of this licensing are
** not clear to you.
**
****************************************************************************/
#pragma once
using namespace System;
using namespace System::Threading;
#include "quickfix_net.h"
#include "Log.h"
#include "LogFactory.h"
#include "SessionSettings.h"
#include "quickfix/FileLog.h"
#include "quickfix/CallStack.h"
#include "vcclr.h"
namespace QuickFix
{
public __gc class CPPLog : public Log, public IDisposable
{
public:
CPPLog() {}
CPPLog( FIX::Log* pUnmanaged )
{ QF_STACK_TRY
m_pUnmanaged = pUnmanaged;
System::GC::SuppressFinalize( this );
QF_STACK_CATCH
}
void Dispose( bool dispose )
{
if( m_pUnmanaged )
{
delete m_pUnmanaged;
m_pUnmanaged = 0;
}
}
void Dispose()
{ Dispose( true ); }
~CPPLog()
{ Dispose( false ); }
void clear()
{ QF_STACK_TRY
m_pUnmanaged->clear();
QF_STACK_CATCH
}
void backup()
{ QF_STACK_TRY
m_pUnmanaged->backup();
QF_STACK_POP
}
void onIncoming( String* s )
{ QF_STACK_TRY
char* us = createUnmanagedString( s );
m_pUnmanaged->onIncoming( us );
destroyUnmanagedString( us );
QF_STACK_CATCH
}
void onOutgoing( String* s )
{ QF_STACK_TRY
char* us = createUnmanagedString( s );
m_pUnmanaged->onOutgoing( us );
destroyUnmanagedString( us );
QF_STACK_CATCH
}
void onEvent( String* s )
{ QF_STACK_TRY
char* us = createUnmanagedString( s );
m_pUnmanaged->onEvent( us );
destroyUnmanagedString( us );
QF_STACK_CATCH
}
protected:
FIX::Log* m_pUnmanaged;
};
}
| [
"[email protected]"
]
| [
[
[
1,
109
]
]
]
|
9deb0df8f4a9cf25c9dd40301ebb47caa4d464d1 | 9c2a6fd19d8d1fede218b99749fc48d5123b248a | /3rdParty/Htmlayout/api/behaviors/behavior_actions.cpp | 28517e8b3a7ac4d176931b073efdaa189fe79f3d | []
| no_license | ans-ashkan/expemerent | 0f6bed7e630301f63e71992e3fbad70a0075082a | 054c33f55408d1274c50a2d6eb4cbc5295c92739 | refs/heads/master | 2021-01-15T22:15:18.929759 | 2008-12-21T00:40:52 | 2008-12-21T00:40:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,882 | cpp | #include "behavior_aux.h"
namespace htmlayout
{
/*
BEHAVIOR: actions
Simplistic action interpretter.
on button clicks exectues actions described by 'action' attribute.
TYPICAL USE CASE:
< div style="behavior:actions" >
....
<button action="alert: Hello world!" >
....
</div>
*/
static bool parse_args( aux::wchars a, aux::wchars& arg );
static bool parse_args( aux::wchars a, aux::wchars& arg1, aux::wchars& arg2 );
static bool parse_args( aux::wchars a, aux::wchars& arg1, aux::wchars& arg2, aux::wchars& arg3, aux::wchars& arg4 );
// parse dtring "checked" or "!checked" to int STATE_CHECKED, etc.
static int parse_state( aux::wchars sst );
struct actions: public behavior
{
// ctor
actions(): behavior(HANDLE_BEHAVIOR_EVENT, "actions") {}
virtual BOOL on_event (HELEMENT he, HELEMENT target, BEHAVIOR_EVENTS type, UINT_PTR reason )
{
if( type != BUTTON_CLICK )
return FALSE;
dom::element btn = target;
const wchar_t* action = btn.get_attribute("action");
if( !action )
return FALSE; // it is not a button we know about
if(interpret_action( btn.root(), action) )
return TRUE;
return FALSE;
}
// Just an idea: here should go some simple interpretter.
// If you know one - let me know.
// For a while it is just dumb thing like this:
bool interpret_action( dom::element root, const wchar_t* action )
{
aux::wchars a = aux::chars_of(action);
if( a.like(L"alert:*"))
{
aux::wchars msg;
if(parse_args(a,msg))
::MessageBoxW(NULL,msg.start,L"alert!",MB_OK);
return true;
}
else if( a.like(L"copy-value:*")) // copy-value: dst selector , src selector
{
aux::wchars src_sel, dst_sel;
if(!parse_args(a,dst_sel,src_sel))
return true;
dom::element src = root.find_first(aux::w2a(src_sel));
dom::element dst = root.find_first(aux::w2a(dst_sel));
if(!src.is_valid() || !dst.is_valid())
{
assert(0); // not found!
return false;
}
json::value v = src.get_value();
dst.set_value(v);
dst.set_state(STATE_FOCUS);
return true;
}
else if( a.like(L"copy-state:*"))
return action_copy_state( root, a);
return false;
}
// copy-state: dst-state, dst-selector, src-state, src-selector
bool action_copy_state( dom::element root, aux::wchars cmd)
{
aux::wchars src_state, src_sel, dst_state, dst_sel;
if(!parse_args(cmd,dst_state, dst_sel, src_state, src_sel))
return true;
dom::element src = root.find_first(aux::w2a(src_sel));
if(!src.is_valid())
return true;
struct : dom::callback
{
int state_to_set;
int state_to_clear;
bool on_element(HELEMENT he) { htmlayout::dom::element el = he; el.set_state(state_to_set,state_to_clear);
return false; /*continue enumeration*/ }
} actor;
bool v = src.get_state( parse_state(src_state) );
if(src_state[0] == '!') v = !v;
actor.state_to_set = 0; actor.state_to_clear = 0;
if(v) { actor.state_to_set = parse_state( dst_state ); actor.state_to_clear = 0; }
else { actor.state_to_set = 0; actor.state_to_clear = parse_state( dst_state ); }
// walk through all dst_sel elements.
root.find_all(&actor, aux::w2a(dst_sel));
return true;
}
};
// instantiating and attaching it to the global list
actions actions_instance;
bool parse_args( aux::wchars a, aux::wchars& arg )
{
aux::wtokens wt( a, L":" );
aux::wchars t;
for(int n = 0; n < 2; ++n)
if(!wt.next(t))
{
assert(0); // wrong format!
return false;
}
else if( n == 1)
arg = t;
return true;
}
bool parse_args( aux::wchars a, aux::wchars& arg1, aux::wchars& arg2 )
{
aux::wtokens wt( a, L":," );
aux::wchars t;
for(int n = 0; n < 3; ++n)
if(!wt.next(t))
{
assert(0); // wrong format!
return false;
}
else switch( n )
{
case 1: arg1 = aux::trim(t); break;
case 2: arg2 = aux::trim(t); break;
}
return true;
}
bool parse_args( aux::wchars a, aux::wchars& arg1, aux::wchars& arg2, aux::wchars& arg3, aux::wchars& arg4 )
{
aux::wtokens wt( a, L":," );
aux::wchars t;
for(int n = 0; n < 5; ++n)
if(!wt.next(t))
{
assert(0); // wrong format!
return false;
}
else switch( n )
{
case 1: arg1 = aux::trim(t); break;
case 2: arg2 = aux::trim(t); break;
case 3: arg3 = aux::trim(t); break;
case 4: arg4 = aux::trim(t); break;
}
return true;
}
int parse_state( aux::wchars sst )
{
if( sst[0] == '!' )
{
++sst.start;
--sst.length;
}
if( sst == const_wchars("checked") ) return STATE_CHECKED;
if( sst == const_wchars("active") ) return STATE_ACTIVE;
if( sst == const_wchars("focus") ) return STATE_FOCUS;
if( sst == const_wchars("current") ) return STATE_CURRENT;
if( sst == const_wchars("checked") ) return STATE_CHECKED;
if( sst == const_wchars("disabled") ) return STATE_DISABLED;
if( sst == const_wchars("readonly") ) return STATE_READONLY;
if( sst == const_wchars("expanded") ) return STATE_EXPANDED;
if( sst == const_wchars("collapsed") ) return STATE_COLLAPSED;
if( sst == const_wchars("anchor") ) return STATE_ANCHOR;
if( sst == const_wchars("tabfocus") ) return STATE_TABFOCUS;
if( sst == const_wchars("busy") ) return STATE_BUSY;
assert(0); // sst is not recognized
return 0;
}
} // htmlayout namespace
| [
"userstvo@9d5f44c3-c14b-0410-8269-bdf5c58671da"
]
| [
[
[
1,
202
]
]
]
|
4f10402917384a49e68ef7d3bb0216df17adcfb7 | 8523123cacd378d808dbd3f02bbe0b66e2c69290 | /SC2 Multi Lossbot/SC2 Multi Lossbot/clsGame.h | 39b809dd51fbeebe0b104537eb5936d2990b1fd0 | []
| no_license | shneezyn/sc2-multi-lossbot | 568194a12cba168b0bbac9ed046a2fb717cd6bb3 | 47ed28853067689679d7e189344599b716ae4c5f | refs/heads/master | 2016-08-09T07:33:50.243624 | 2010-11-30T20:32:22 | 2010-11-30T20:32:22 | 44,065,340 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 862 | h | #include <iostream>
#include <tlhelp32.h>
#include <time.h>
using namespace std;
class clsGame
{
public:
static int EnemyPlayerNumber;
static int MyPlayerNumber;
static string SearchHotkey;
static string QuitHotkey;
static bool GameFound[8];
static time_t Timer[8];
static bool TimerLeave[8];
static bool Timer1stChat[8];
static bool Timer2ndChat[8];
static bool TimesUp[8];
static HWND Handle[8];
static HANDLE Process[8];
static DWORD PID[8];
static void Setup(void);
static void EnableDebugPriv(void);
static DWORD GetModuleBase(DWORD hProcId, TCHAR* lpModName);
static void StartQuickSearch(int instance);
static void QuitGame(int instance);
static void CleanUp(int instance, HWND hWnd);
static void DetectPlayerNumber(int instance);
private:
static int ResolutionWidth;
static int ResolutionHeight;
}; | [
"[email protected]"
]
| [
[
[
1,
33
]
]
]
|
e42349151c04bfd83aa0c633f9332773f738c2b7 | 25607f4024cbc227d18ec6ecb4bb3fb2352ae8d9 | /gl/glnode.cpp | 7c12499c14ea22cf63a4f0b57c49bb2ea673ce8e | [
"LicenseRef-scancode-warranty-disclaimer",
"BSD-2-Clause"
]
| permissive | mikeshutlar/nifskope | 36d74908aa3718d178eec6bc9598f0bf3b9c7572 | 5cd0ed19caedb35d3cdc6af3466da77e635d6b48 | refs/heads/master | 2021-05-27T14:28:17.765803 | 2011-09-25T07:59:02 | 2011-09-25T07:59:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 53,745 | cpp | /***** BEGIN LICENSE BLOCK *****
BSD License
Copyright (c) 2005-2010, NIF File Format Library and Tools
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the NIF File Format Library and Tools project may not be
used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***** END LICENCE BLOCK *****/
#include "glscene.h"
#include "glmarker.h"
#include "glnode.h"
int Node::SELECTING = 0;
#include "glcontroller.h"
#include "../options.h"
#include "../NvTriStrip/qtwrapper.h"
#include "marker/furniture.h"
#include "marker/constraints.h"
#ifndef M_PI
#define M_PI 3.1415926535897932385
#endif
class TransformController : public Controller
{
public:
TransformController( Node * node, const QModelIndex & index )
: Controller( index ), target( node ){}
void update( float time )
{
if ( ! ( active && target ) )
return;
time = ctrlTime( time );
if ( interpolator )
{
interpolator->updateTransform(target->local, time);
}
}
void setInterpolator( const QModelIndex & iBlock )
{
const NifModel * nif = static_cast<const NifModel *>( iBlock.model() );
if ( nif && iBlock.isValid() )
{
if ( interpolator )
{
delete interpolator;
interpolator = 0;
}
if ( nif->isNiBlock( iBlock, "NiBSplineCompTransformInterpolator" ) )
{
iInterpolator = iBlock;
interpolator = new BSplineTransformInterpolator(this);
}
else if ( nif->isNiBlock( iBlock, "NiTransformInterpolator" ) )
{
iInterpolator = iBlock;
interpolator = new TransformInterpolator(this);
}
if ( interpolator )
{
interpolator->update( nif, iInterpolator );
}
}
}
protected:
QPointer<Node> target;
QPointer<TransformInterpolator> interpolator;
};
class MultiTargetTransformController : public Controller
{
typedef QPair< QPointer<Node>, QPointer<TransformInterpolator> > TransformTarget;
public:
MultiTargetTransformController( Node * node, const QModelIndex & index )
: Controller( index ), target( node ) {}
void update( float time )
{
if ( ! ( active && target ) )
return;
time = ctrlTime( time );
foreach ( TransformTarget tt, extraTargets )
{
if ( tt.first && tt.second )
{
tt.second->updateTransform( tt.first->local, time );
}
}
}
bool update( const NifModel * nif, const QModelIndex & index )
{
if ( Controller::update( nif, index ) )
{
if ( target )
{
Scene * scene = target->scene;
extraTargets.clear();
QVector<qint32> lTargets = nif->getLinkArray( index, "Extra Targets" );
foreach ( qint32 l, lTargets )
{
Node * node = scene->getNode( nif, nif->getBlock( l ) );
if ( node )
{
extraTargets.append( TransformTarget( node, 0 ) );
}
}
}
return true;
}
foreach ( TransformTarget tt, extraTargets )
{
// TODO: update the interpolators
}
return false;
}
bool setInterpolator( Node * node, const QModelIndex & iInterpolator )
{
const NifModel * nif = static_cast<const NifModel *>( iInterpolator.model() );
if ( ! nif || ! iInterpolator.isValid() )
return false;
QMutableListIterator<TransformTarget> it( extraTargets );
while ( it.hasNext() )
{
it.next();
if ( it.value().first == node )
{
if ( it.value().second )
{
delete it.value().second;
it.value().second = 0;
}
if ( nif->isNiBlock( iInterpolator, "NiBSplineCompTransformInterpolator" ) )
{
it.value().second = new BSplineTransformInterpolator( this );
}
else if ( nif->isNiBlock( iInterpolator, "NiTransformInterpolator" ) )
{
it.value().second = new TransformInterpolator( this );
}
if ( it.value().second )
{
it.value().second->update( nif, iInterpolator );
}
return true;
}
}
return false;
}
protected:
QPointer<Node> target;
QList< TransformTarget > extraTargets;
};
class ControllerManager : public Controller
{
public:
ControllerManager( Node * node, const QModelIndex & index )
: Controller( index ), target( node ) {}
void update( float ) {}
bool update( const NifModel * nif, const QModelIndex & index )
{
if ( Controller::update( nif, index ) )
{
if ( target )
{
Scene * scene = target->scene;
QVector<qint32> lSequences = nif->getLinkArray( index, "Controller Sequences" );
foreach ( qint32 l, lSequences )
{
QModelIndex iSeq = nif->getBlock( l, "NiControllerSequence" );
if ( iSeq.isValid() )
{
QString name = nif->get<QString>( iSeq, "Name" );
if ( ! scene->animGroups.contains( name ) )
{
scene->animGroups.append( name );
QMap<QString,float> tags = scene->animTags[ name ];
QModelIndex iKeys = nif->getBlock( nif->getLink( iSeq, "Text Keys" ), "NiTextKeyExtraData" );
QModelIndex iTags = nif->getIndex( iKeys, "Text Keys" );
for ( int r = 0; r < nif->rowCount( iTags ); r++ )
{
tags.insert( nif->get<QString>( iTags.child( r, 0 ), "Value" ), nif->get<float>( iTags.child( r, 0 ), "Time" ) );
}
scene->animTags[ name ] = tags;
}
}
}
}
return true;
}
return false;
}
void setSequence( const QString & seqname )
{
const NifModel * nif = static_cast<const NifModel *>( iBlock.model() );
if ( target && iBlock.isValid() && nif )
{
MultiTargetTransformController * multiTargetTransformer = 0;
foreach ( Controller * c, target->controllers )
{
if ( c->typeId() == "NiMultiTargetTransformController" )
{
multiTargetTransformer = static_cast<MultiTargetTransformController*>( c );
break;
}
}
QVector<qint32> lSequences = nif->getLinkArray( iBlock, "Controller Sequences" );
foreach ( qint32 l, lSequences )
{
QModelIndex iSeq = nif->getBlock( l, "NiControllerSequence" );
if ( iSeq.isValid() && nif->get<QString>( iSeq, "Name" ) == seqname )
{
start = nif->get<float>( iSeq, "Start Time" );
stop = nif->get<float>( iSeq, "Stop Time" );
phase = nif->get<float>( iSeq, "Phase" );
frequency = nif->get<float>( iSeq, "Frequency" );
QModelIndex iCtrlBlcks = nif->getIndex( iSeq, "Controlled Blocks" );
for ( int r = 0; r < nif->rowCount( iCtrlBlcks ); r++ )
{
QModelIndex iCB = iCtrlBlcks.child( r, 0 );
QModelIndex iInterpolator = nif->getBlock( nif->getLink( iCB, "Interpolator" ), "NiInterpolator" );
QString nodename = nif->get<QString>( iCB, "Node Name" );
if ( nodename.isEmpty() ) {
QModelIndex idx = nif->getIndex( iCB, "Node Name Offset" );
nodename = idx.sibling( idx.row(), NifModel::ValueCol ).data( Qt::DisplayRole ).toString();
}
QString proptype = nif->get<QString>( iCB, "Property Type" );
if ( proptype.isEmpty() ) {
QModelIndex idx = nif->getIndex( iCB, "Property Type Offset" );
proptype = idx.sibling( idx.row(), NifModel::ValueCol ).data( Qt::DisplayRole ).toString();
}
QString ctrltype = nif->get<QString>( iCB, "Controller Type" );
if ( ctrltype.isEmpty() ) {
QModelIndex idx = nif->getIndex( iCB, "Controller Type Offset" );
ctrltype = idx.sibling( idx.row(), NifModel::ValueCol ).data( Qt::DisplayRole ).toString();
}
QString var1 = nif->get<QString>( iCB, "Variable 1" );
if ( var1.isEmpty() ) {
QModelIndex idx = nif->getIndex( iCB, "Variable 1 Offset" );
var1 = idx.sibling( idx.row(), NifModel::ValueCol ).data( Qt::DisplayRole ).toString();
}
QString var2 = nif->get<QString>( iCB, "Variable 2" );
if ( var2.isEmpty() ) {
QModelIndex idx = nif->getIndex( iCB, "Variable 2 Offset" );
var2 = idx.sibling( idx.row(), NifModel::ValueCol ).data( Qt::DisplayRole ).toString();
}
Node * node = target->findChild( nodename );
if ( ! node )
continue;
if ( ctrltype == "NiTransformController" && multiTargetTransformer )
{
if ( multiTargetTransformer->setInterpolator( node, iInterpolator ) )
{
multiTargetTransformer->start = start;
multiTargetTransformer->stop = stop;
multiTargetTransformer->phase = phase;
multiTargetTransformer->frequency = frequency;
continue;
}
}
Controller * ctrl = node->findController( proptype, ctrltype, var1, var2 );
if ( ctrl )
{
ctrl->start = start;
ctrl->stop = stop;
ctrl->phase = phase;
ctrl->frequency = frequency;
ctrl->setInterpolator( iInterpolator );
}
}
}
}
}
}
protected:
QPointer<Node> target;
};
class KeyframeController : public Controller
{
public:
KeyframeController( Node * node, const QModelIndex & index )
: Controller( index ), target( node ), lTrans( 0 ), lRotate( 0 ), lScale( 0 ) {}
void update( float time )
{
if ( ! ( active && target ) )
return;
time = ctrlTime( time );
interpolate( target->local.rotation, iRotations, time, lRotate );
interpolate( target->local.translation, iTranslations, time, lTrans );
interpolate( target->local.scale, iScales, time, lScale );
}
bool update( const NifModel * nif, const QModelIndex & index )
{
if ( Controller::update( nif, index ) )
{
iTranslations = nif->getIndex( iData, "Translations" );
iRotations = nif->getIndex( iData, "Rotations" );
if ( ! iRotations.isValid() )
iRotations = iData;
iScales = nif->getIndex( iData, "Scales" );
return true;
}
return false;
}
protected:
QPointer<Node> target;
QPersistentModelIndex iTranslations, iRotations, iScales;
int lTrans, lRotate, lScale;
};
class VisibilityController : public Controller
{
public:
VisibilityController( Node * node, const QModelIndex & index )
: Controller( index ), target( node ), visLast( 0 ) {}
void update( float time )
{
if ( ! ( active && target ) )
return;
time = ctrlTime( time );
bool isVisible;
if ( interpolate( isVisible, iData, time, visLast ) )
{
target->flags.node.hidden = ! isVisible;
}
}
bool update( const NifModel * nif, const QModelIndex & index )
{
if ( Controller::update( nif, index ) )
{
// iData already points to the NiVisData
// note that nif.xml needs to have "Keys" not "Vis Keys" for interpolate() to work
//iKeys = nif->getIndex( iData, "Data" );
return true;
}
return false;
}
protected:
QPointer<Node> target;
//QPersistentModelIndex iKeys;
int visLast;
};
/*
* Node list
*/
NodeList::NodeList()
{
}
NodeList::NodeList( const NodeList & other )
{
operator=( other );
}
NodeList::~NodeList()
{
clear();
}
void NodeList::clear()
{
foreach( Node * n, nodes )
del( n );
}
NodeList & NodeList::operator=( const NodeList & other )
{
clear();
foreach ( Node * n, other.list() )
add( n );
return *this;
}
void NodeList::add( Node * n )
{
if ( n && ! nodes.contains( n ) )
{
++ n->ref;
nodes.append( n );
}
}
void NodeList::del( Node * n )
{
if ( nodes.contains( n ) )
{
int cnt = nodes.removeAll( n );
if ( n->ref <= cnt )
{
delete n;
}
else
n->ref -= cnt;
}
}
Node * NodeList::get( const QModelIndex & index ) const
{
foreach ( Node * n, nodes )
{
if ( n->index().isValid() && n->index() == index )
return n;
}
return 0;
}
void NodeList::validate()
{
QList<Node *> rem;
foreach ( Node * n, nodes )
{
if ( ! n->isValid() )
rem.append( n );
}
foreach ( Node * n, rem )
{
del( n );
}
}
bool compareNodes( const Node * node1, const Node * node2 )
{
// opaque meshes first (sorted from front to rear)
// then alpha enabled meshes (sorted from rear to front)
bool a1 = node1->findProperty<AlphaProperty>();
bool a2 = node2->findProperty<AlphaProperty>();
if ( a1 == a2 )
if ( a1 )
return ( node1->center()[2] < node2->center()[2] );
else
return ( node1->center()[2] > node2->center()[2] );
else
return a2;
}
void NodeList::sort()
{
qStableSort( nodes.begin(), nodes.end(), compareNodes );
}
/*
* Node
*/
Node::Node( Scene * s, const QModelIndex & index ) : Controllable( s, index ), parent( 0 ), ref( 0 )
{
nodeId = 0;
flags.bits = 0;
}
void Node::clear()
{
Controllable::clear();
nodeId = 0;
flags.bits = 0;
local = Transform();
children.clear();
properties.clear();
}
Controller * Node::findController( const QString & proptype, const QString & ctrltype, const QString & var1, const QString & var2 )
{
if ( proptype != "<empty>" && ! proptype.isEmpty() )
{
foreach ( Property * prp, properties.list() )
{
if ( prp->typeId() == proptype )
{
return prp->findController( ctrltype, var1, var2 );
}
}
return 0;
}
return Controllable::findController( ctrltype, var1, var2 );
}
void Node::update( const NifModel * nif, const QModelIndex & index )
{
Controllable::update( nif, index );
if ( ! iBlock.isValid() )
{
clear();
return;
}
nodeId = nif->getBlockNumber( iBlock );
if ( iBlock == index )
{
flags.bits = nif->get<int>( iBlock, "Flags" );
local = Transform( nif, iBlock );
}
if ( iBlock == index || ! index.isValid() )
{
PropertyList newProps;
foreach ( qint32 l, nif->getLinkArray( iBlock, "Properties" ) )
if ( Property * p = scene->getProperty( nif, nif->getBlock( l ) ) )
newProps.add( p );
properties = newProps;
children.clear();
QModelIndex iChildren = nif->getIndex( iBlock, "Children" );
QList<qint32> lChildren = nif->getChildLinks( nif->getBlockNumber( iBlock ) );
if ( iChildren.isValid() )
{
for ( int c = 0; c < nif->rowCount( iChildren ); c++ )
{
qint32 link = nif->getLink( iChildren.child( c, 0 ) );
if ( lChildren.contains( link ) )
{
QModelIndex iChild = nif->getBlock( link );
Node * node = scene->getNode( nif, iChild );
if ( node )
{
node->makeParent( this );
}
}
}
}
}
}
void Node::makeParent( Node * newParent )
{
if ( parent )
parent->children.del( this );
parent = newParent;
if ( parent )
parent->children.add( this );
}
void Node::setController( const NifModel * nif, const QModelIndex & iController )
{
QString cname = nif->itemName( iController );
if ( cname == "NiTransformController" )
{
Controller * ctrl = new TransformController( this, iController );
ctrl->update( nif, iController );
controllers.append( ctrl );
}
else if ( cname == "NiMultiTargetTransformController" )
{
Controller * ctrl = new MultiTargetTransformController( this, iController );
ctrl->update( nif, iController );
controllers.append( ctrl );
}
else if ( cname == "NiControllerManager" )
{
Controller * ctrl = new ControllerManager( this, iController );
ctrl->update( nif, iController );
controllers.append( ctrl );
}
else if ( cname == "NiKeyframeController" )
{
Controller * ctrl = new KeyframeController( this, iController );
ctrl->update( nif, iController );
controllers.append( ctrl );
}
else if ( cname == "NiVisController" )
{
Controller * ctrl = new VisibilityController( this, iController );
ctrl->update( nif, iController );
controllers.append( ctrl );
}
}
void Node::activeProperties( PropertyList & list ) const
{
list.merge( properties );
if ( parent )
parent->activeProperties( list );
}
const Transform & Node::viewTrans() const
{
if ( scene->viewTrans.contains( nodeId ) )
return scene->viewTrans[ nodeId ];
Transform t;
if ( parent )
t = parent->viewTrans() * local;
else
t = scene->view * worldTrans();
scene->viewTrans.insert( nodeId, t );
return scene->viewTrans[ nodeId ];
}
const Transform & Node::worldTrans() const
{
if ( scene->worldTrans.contains( nodeId ) )
return scene->worldTrans[ nodeId ];
Transform t = local;
if ( parent )
t = parent->worldTrans() * t;
scene->worldTrans.insert( nodeId, t );
return scene->worldTrans[ nodeId ];
}
Transform Node::localTransFrom( int root ) const
{
Transform trans;
const Node * node = this;
while ( node && node->nodeId != root )
{
trans = node->local * trans;
node = node->parent;
}
return trans;
}
Vector3 Node::center() const
{
return worldTrans().translation;
}
Node * Node::findParent( int id ) const
{
Node * node = parent;
while ( node && node->nodeId != id )
node = node->parent;
return node;
}
Node * Node::findChild( int id ) const
{
foreach ( Node * child, children.list() )
{
if ( child->nodeId == id )
return child;
child = child->findChild( id );
if ( child )
return child;
}
return 0;
}
Node * Node::findChild( const QString & name ) const
{
if ( this->name == name )
return const_cast<Node*>( this );
foreach ( Node * child, children.list() )
{
Node * n = child->findChild( name );
if ( n )
return n;
}
return 0;
}
bool Node::isHidden() const
{
if ( Options::drawHidden() )
return false;
if ( flags.node.hidden || ( parent && parent->isHidden() ) )
return true;
return ! Options::cullExpression().isEmpty() && name.contains( Options::cullExpression() );
}
void Node::transform()
{
Controllable::transform();
// if there's a rigid body attached, then calculate and cache the body's transform
// (need this later in the drawing stage for the constraints)
const NifModel * nif = static_cast<const NifModel *>( iBlock.model() );
if ( iBlock.isValid() && nif )
{
QModelIndex iObject = nif->getBlock( nif->getLink( iBlock, "Collision Data" ) );
if ( ! iObject.isValid() )
iObject = nif->getBlock( nif->getLink( iBlock, "Collision Object" ) );
if ( iObject.isValid() )
{
QModelIndex iBody = nif->getBlock( nif->getLink( iObject, "Body" ) );
if ( iBody.isValid() )
{
Transform t;
t.scale = 7;
if ( nif->isNiBlock( iBody, "bhkRigidBodyT" ) )
{
t.rotation.fromQuat( nif->get<Quat>( iBody, "Rotation" ) );
t.translation = Vector3( nif->get<Vector4>( iBody, "Translation" ) * 7 );
}
scene->bhkBodyTrans.insert( nif->getBlockNumber( iBody ), worldTrans() * t );
}
}
}
foreach ( Node * node, children.list() )
node->transform();
}
void Node::transformShapes()
{
foreach ( Node * node, children.list() )
node->transformShapes();
}
void Node::draw()
{
if ( isHidden() )
return;
//glLoadName( nodeId ); - disabled glRenderMode( GL_SELECT );
if (Node::SELECTING) {
int s_nodeId = ID2COLORKEY( nodeId );
glColor4ubv( (GLubyte *)&s_nodeId );
glLineWidth( 5 ); // make hitting a line a litlle bit more easy
}
else {
glEnable( GL_DEPTH_TEST );
glDepthFunc( GL_LEQUAL );
glDepthMask( GL_TRUE );
glDisable( GL_TEXTURE_2D );
glDisable( GL_NORMALIZE );
glDisable( GL_LIGHTING );
glDisable( GL_COLOR_MATERIAL );
glEnable( GL_BLEND );
glDisable( GL_ALPHA_TEST );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glNormalColor();
glLineWidth( 2.5 );
}
glPointSize( 8.5 );
Vector3 a = viewTrans().translation;
Vector3 b = a;
if ( parent )
b = parent->viewTrans().translation;
glBegin( GL_POINTS );
glVertex( a );
glEnd();
glBegin( GL_LINES );
glVertex( a );
glVertex( b );
glEnd();
foreach ( Node * node, children.list() )
node->draw();
}
void Node::drawSelection() const
{
if ( scene->currentBlock != iBlock || ! Options::drawNodes() )
return;
//glLoadName( nodeId ); - disabled glRenderMode( GL_SELECT );
if (Node::SELECTING) {
int s_nodeId = ID2COLORKEY( nodeId );
glColor4ubv( (GLubyte *)&s_nodeId );
glLineWidth( 5 );
}
else {
glEnable( GL_DEPTH_TEST );
glDepthFunc( GL_ALWAYS );
glDepthMask( GL_TRUE );
glDisable( GL_TEXTURE_2D );
glDisable( GL_NORMALIZE );
glDisable( GL_LIGHTING );
glDisable( GL_COLOR_MATERIAL );
glEnable( GL_BLEND );
glDisable( GL_ALPHA_TEST );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glHighlightColor();
glLineWidth( 2.5 );
}
glPointSize( 8.5 );
Vector3 a = viewTrans().translation;
Vector3 b = a;
if ( parent )
b = parent->viewTrans().translation;
glBegin( GL_POINTS );
glVertex( a );
glEnd();
glBegin( GL_LINES );
glVertex( a );
glVertex( b );
glEnd();
}
void DrawVertexSelection( QVector<Vector3> &verts, int i )
{
glPointSize( 3.5 );
glDepthFunc( GL_LEQUAL );
glNormalColor();
glBegin( GL_POINTS );
for ( int j = 0; j < verts.count(); j++ )
glVertex( verts.value( j ) );
glEnd();
if ( i >= 0 )
{
glDepthFunc( GL_ALWAYS );
glHighlightColor();
glBegin( GL_POINTS );
glVertex( verts.value( i ) );
glEnd();
}
}
void DrawTriangleSelection( QVector<Vector3> const &verts, Triangle const &tri )
{
glLineWidth( 1.5f );
glDepthFunc( GL_ALWAYS );
glHighlightColor();
glBegin( GL_LINE_STRIP );
glVertex( verts.value( tri.v1() ) );
glVertex( verts.value( tri.v2() ) );
glVertex( verts.value( tri.v3() ) );
glVertex( verts.value( tri.v1() ) );
glEnd();
}
void DrawTriangleIndex( QVector<Vector3> const &verts, Triangle const &tri, int index)
{
Vector3 c = ( verts.value( tri.v1() ) + verts.value( tri.v2() ) + verts.value( tri.v3() ) ) / 3.0;
renderText(c, QString("%1").arg(index));
}
void drawHvkShape( const NifModel * nif, const QModelIndex & iShape, QStack<QModelIndex> & stack, const Scene * scene, const float origin_color3fv[3] )
{
if ( ! nif || ! iShape.isValid() || stack.contains( iShape ) )
return;
stack.push( iShape );
//qWarning() << "draw shape" << nif->getBlockNumber( iShape ) << nif->itemName( iShape );
QString name = nif->itemName( iShape );
if ( name == "bhkListShape" )
{
QModelIndex iShapes = nif->getIndex( iShape, "Sub Shapes" );
if ( iShapes.isValid() )
{
for ( int r = 0; r < nif->rowCount( iShapes ); r++ )
{
if ( !Node::SELECTING ) {
if ( scene->currentBlock == nif->getBlock( nif->getLink( iShapes.child( r, 0 ) ) ) ) {// fix: add selected visual to havok meshes
glHighlightColor();
glLineWidth( 2.5 );
}
else {
if ( scene->currentBlock != iShape) {// allow group highlighting
glLineWidth( 1.0 );
glColor3fv( origin_color3fv );
}
}
}
drawHvkShape( nif, nif->getBlock( nif->getLink( iShapes.child( r, 0 ) ) ), stack, scene, origin_color3fv );
}
}
}
else if ( name == "bhkTransformShape" || name == "bhkConvexTransformShape" )
{
glPushMatrix();
Matrix4 tm = nif->get<Matrix4>( iShape, "Transform" );
glMultMatrix( tm );
drawHvkShape( nif, nif->getBlock( nif->getLink( iShape, "Shape" ) ), stack, scene, origin_color3fv );
glPopMatrix();
}
else if ( name == "bhkSphereShape" )
{
//glLoadName( nif->getBlockNumber( iShape ) );
if (Node::SELECTING) {
int s_nodeId = ID2COLORKEY( nif->getBlockNumber( iShape ) );
glColor4ubv( (GLubyte *)&s_nodeId );
}
drawSphere( Vector3(), nif->get<float>( iShape, "Radius" ) );
}
else if ( name == "bhkMultiSphereShape" )
{
//glLoadName( nif->getBlockNumber( iShape ) );
if (Node::SELECTING) {
int s_nodeId = ID2COLORKEY( nif->getBlockNumber( iShape ) );
glColor4ubv( (GLubyte *)&s_nodeId );
}
QModelIndex iSpheres = nif->getIndex( iShape, "Spheres" );
for ( int r = 0; r < nif->rowCount( iSpheres ); r++ )
{
drawSphere( nif->get<Vector3>( iSpheres.child( r, 0 ), "Center" ), nif->get<float>( iSpheres.child( r, 0 ), "Radius" ) );
}
}
else if ( name == "bhkBoxShape" )
{
//glLoadName( nif->getBlockNumber( iShape ) );
if (Node::SELECTING) {
int s_nodeId = ID2COLORKEY( nif->getBlockNumber( iShape ) );
glColor4ubv( (GLubyte *)&s_nodeId );
}
Vector3 v = nif->get<Vector3>( iShape, "Dimensions" );
drawBox( v, - v );
}
else if ( name == "bhkCapsuleShape" )
{
//glLoadName( nif->getBlockNumber( iShape ) );
if (Node::SELECTING) {
int s_nodeId = ID2COLORKEY( nif->getBlockNumber( iShape ) );
glColor4ubv( (GLubyte *)&s_nodeId );
}
drawCapsule( nif->get<Vector3>( iShape, "First Point" ), nif->get<Vector3>( iShape, "Second Point" ), nif->get<float>( iShape, "Radius" ) );
}
else if ( name == "bhkNiTriStripsShape" )
{
glPushMatrix();
float s = 1.0f / 7.0f;
glScalef( s, s, s );
//glLoadName( nif->getBlockNumber( iShape ) );
if (Node::SELECTING) {
int s_nodeId = ID2COLORKEY( nif->getBlockNumber( iShape ) );
glColor4ubv( (GLubyte *)&s_nodeId );
}
QModelIndex iStrips = nif->getIndex( iShape, "Strips Data" );
for ( int r = 0; r < nif->rowCount( iStrips ); r++ )
{
QModelIndex iStripData = nif->getBlock( nif->getLink( iStrips.child( r, 0 ) ), "NiTriStripsData" );
if ( iStripData.isValid() )
{
QVector<Vector3> verts = nif->getArray<Vector3>( iStripData, "Vertices" );
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
glBegin( GL_TRIANGLES );
QModelIndex iPoints = nif->getIndex( iStripData, "Points" );
for ( int r = 0; r < nif->rowCount( iPoints ); r++ )
{ // draw the strips like they appear in the tescs
// (use the unstich strips spell to avoid the spider web effect)
QVector<quint16> strip = nif->getArray<quint16>( iPoints.child( r, 0 ) );
if ( strip.count() >= 3 )
{
quint16 a = strip[0];
quint16 b = strip[1];
for ( int x = 2; x < strip.size(); x++ )
{
quint16 c = strip[x];
glVertex( verts.value( a ) );
glVertex( verts.value( b ) );
glVertex( verts.value( c ) );
a = b;
b = c;
}
}
}
glEnd();
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
}
}
glPopMatrix();
}
else if ( name == "bhkConvexVerticesShape" )
{
//glLoadName( nif->getBlockNumber( iShape ) );
if (Node::SELECTING) {
int s_nodeId = ID2COLORKEY( nif->getBlockNumber( iShape ) );
glColor4ubv( (GLubyte *)&s_nodeId );
}
drawConvexHull( nif->getArray<Vector4>( iShape, "Vertices" ), nif->getArray<Vector4>( iShape, "Normals" ) );
}
else if ( name == "bhkMoppBvTreeShape" )
{
if ( !Node::SELECTING ) {
if ( scene->currentBlock == nif->getBlock( nif->getLink( iShape, "Shape" ) ) ) {// fix: add selected visual to havok meshes
glHighlightColor();
glLineWidth( 1.5f );// taken from "DrawTriangleSelection"
}
else {
glLineWidth( 1.0 );
glColor3fv( origin_color3fv );
}
}
drawHvkShape( nif, nif->getBlock( nif->getLink( iShape, "Shape" ) ), stack, scene, origin_color3fv );
}
else if ( name == "bhkPackedNiTriStripsShape" )
{
//glLoadName( nif->getBlockNumber( iShape ) );
if (Node::SELECTING) {
int s_nodeId = ID2COLORKEY( nif->getBlockNumber( iShape ) );
glColor4ubv( (GLubyte *)&s_nodeId );
}
QModelIndex iData = nif->getBlock( nif->getLink( iShape, "Data" ) );
if ( iData.isValid() )
{
QVector<Vector3> verts = nif->getArray<Vector3>( iData, "Vertices" );
QModelIndex iTris = nif->getIndex( iData, "Triangles" );
for ( int t = 0; t < nif->rowCount( iTris ); t++ )
{
Triangle tri = nif->get<Triangle>( iTris.child( t, 0 ), "Triangle" );
if ( tri[0] != tri[1] || tri[1] != tri[2] || tri[2] != tri[0] )
{
glBegin( GL_LINE_STRIP );
glVertex( verts.value( tri[0] ) );
glVertex( verts.value( tri[1] ) );
glVertex( verts.value( tri[2] ) );
glVertex( verts.value( tri[0] ) );
glEnd();
}
}
// Handle Selection of hkPackedNiTriStripsData
if (scene->currentBlock == iData )
{
int i = -1;
QString n = scene->currentIndex.data( Qt::DisplayRole ).toString();
QModelIndex iParent = scene->currentIndex.parent();
if ( iParent.isValid() && iParent != iData )
{
n = iParent.data( Qt::DisplayRole ).toString();
i = scene->currentIndex.row();
}
if ( n == "Vertices" || n == "Normals" || n == "Vertex Colors" || n == "UV Sets" )
DrawVertexSelection(verts, i);
else if ( ( n == "Faces" || n == "Triangles" ) )
{
if ( i == -1 )
{
glDepthFunc( GL_ALWAYS );
glHighlightColor();
for ( int t = 0; t < nif->rowCount( iTris ); t++ )
DrawTriangleIndex(verts, nif->get<Triangle>( iTris.child( t, 0 ), "Triangle" ), t);
}
else if ( nif->isCompound( nif->getBlockType( scene->currentIndex ) ) )
{
Triangle tri = nif->get<Triangle>( iTris.child( i, 0 ), "Triangle" );
DrawTriangleSelection(verts, tri );
DrawTriangleIndex(verts, tri, i);
}
else if ( nif->getBlockName( scene->currentIndex ) == "Normal" )
{
Triangle tri = nif->get<Triangle>( scene->currentIndex.parent(), "Triangle" );
Vector3 triCentre = ( verts.value( tri.v1() ) + verts.value( tri.v2() ) + verts.value( tri.v3() ) ) / 3.0;
glLineWidth( 1.5f );
glDepthFunc( GL_ALWAYS );
glHighlightColor();
glBegin( GL_LINES );
glVertex( triCentre );
glVertex( triCentre + nif->get<Vector3>( scene->currentIndex ) );
glEnd();
}
}
}
// Handle Selection of bhkPackedNiTriStripsShape
else if ( scene->currentBlock == iShape )
{
int i = -1;
QString n = scene->currentIndex.data( Qt::DisplayRole ).toString();
QModelIndex iParent = scene->currentIndex.parent();
if ( iParent.isValid() && iParent != iShape )
{
n = iParent.data( Qt::DisplayRole ).toString();
i = scene->currentIndex.row();
}
//qDebug() << n;
// n == "Sub Shapes" if the array is selected and if an element of the array is selected
// iParent != iShape only for the elements of the array
if (( n == "Sub Shapes" ) && ( iParent != iShape )) {
// get subshape vertex indices
QModelIndex iSubShapes = iParent;
QModelIndex iSubShape = scene->currentIndex;
int start_vertex = 0;
int end_vertex = 0;
for (int subshape = 0; subshape < nif->rowCount(iSubShapes); subshape++) {
QModelIndex iCurrentSubShape = iSubShapes.child(subshape, 0);
int num_vertices = nif->get<int>( iCurrentSubShape, "Num Vertices" );
//qDebug() << num_vertices;
end_vertex += num_vertices;
if ( iCurrentSubShape == iSubShape ) {
break;
} else {
start_vertex += num_vertices;
}
}
// highlight the triangles of the subshape
for ( int t = 0; t < nif->rowCount( iTris ); t++ ) {
Triangle tri = nif->get<Triangle>( iTris.child( t, 0 ), "Triangle" );
if ((start_vertex <= tri[0]) && (tri[0] < end_vertex)) {
if ((start_vertex <= tri[1]) && (tri[1] < end_vertex) && (start_vertex <= tri[2]) && (tri[2] < end_vertex)) {
DrawTriangleSelection(verts, tri );
DrawTriangleIndex(verts, tri, t);
} else {
qWarning() << "triangle with multiple materials?" << t;
}
}
}
}
}
}
}
stack.pop();
}
void drawHvkConstraint( const NifModel * nif, const QModelIndex & iConstraint, const Scene * scene )
{
if ( ! ( nif && iConstraint.isValid() && scene && Options::drawConstraints() ) )
return;
QList<Transform> tBodies;
QModelIndex iBodies = nif->getIndex( iConstraint, "Entities" );
if( !iBodies.isValid() ) {
return;
}
for ( int r = 0; r < nif->rowCount( iBodies ); r++ )
{
qint32 l = nif->getLink( iBodies.child( r, 0 ) );
if ( ! scene->bhkBodyTrans.contains( l ) )
return;
else
tBodies.append( scene->bhkBodyTrans.value( l ) );
}
if ( tBodies.count() != 2 )
return;
Color3 color_a( 0.8f, 0.6f, 0.0f );
Color3 color_b( 0.6f, 0.8f, 0.0f );
//glLoadName( nif->getBlockNumber( iConstraint ) );
if (Node::SELECTING) {
int s_nodeId = ID2COLORKEY( nif->getBlockNumber( iConstraint ) );
glColor4ubv( (GLubyte *)&s_nodeId );
glLineWidth( 5 ); // make hitting a line a litlle bit more easy
}
else {
if ( scene->currentBlock == nif->getBlock( iConstraint ) ) {// fix: add selected visual to havok meshes
glHighlightColor();
color_a.fromQColor( Options::hlColor() );
color_b.setRGB( Options::hlColor().blueF(), Options::hlColor().redF(), Options::hlColor().greenF());
}
}
glPushMatrix();
glLoadMatrix( scene->view );
glPushAttrib( GL_ENABLE_BIT );
glEnable( GL_DEPTH_TEST );
QString name = nif->itemName( iConstraint );
if ( name == "bhkMalleableConstraint" )
{
if ( nif->getIndex( iConstraint, "Ragdoll" ).isValid() )
{
name = "bhkRagdollConstraint";
}
else if ( nif->getIndex( iConstraint, "Limited Hinge" ).isValid() )
{
name = "bhkLimitedHingeConstraint";
}
}
if ( name == "bhkLimitedHingeConstraint" )
{
QModelIndex iHinge = nif->getIndex( iConstraint, "Limited Hinge" );
const Vector3 pivotA( nif->get<Vector4>( iHinge, "Pivot A" ) );
const Vector3 pivotB( nif->get<Vector4>( iHinge, "Pivot B" ) );
const Vector3 axleA( nif->get<Vector4>( iHinge, "Axle A" ) );
const Vector3 axleA1( nif->get<Vector4>( iHinge, "Perp2 Axle In A1" ) );
const Vector3 axleA2( nif->get<Vector4>( iHinge, "Perp2 Axle In A2" ) );
const Vector3 axleB( nif->get<Vector4>( iHinge, "Axle B" ) );
const Vector3 axleB2( nif->get<Vector4>( iHinge, "Perp2 Axle In B2" ) );
const float minAngle = nif->get<float>( iHinge, "Min Angle" );
const float maxAngle = nif->get<float>( iHinge, "Max Angle" );
glPushMatrix();
glMultMatrix( tBodies.value( 0 ) );
if (!Node::SELECTING)
glColor( color_a );
glBegin( GL_POINTS ); glVertex( pivotA ); glEnd();
glBegin( GL_LINES ); glVertex( pivotA ); glVertex( pivotA + axleA ); glEnd();
drawDashLine( pivotA, pivotA + axleA1, 14 );
drawDashLine( pivotA, pivotA + axleA2, 14 );
drawCircle( pivotA, axleA, 1.0f );
drawSolidArc( pivotA, axleA / 5, axleA2, axleA1, minAngle, maxAngle, 1.0f );
glPopMatrix();
glPushMatrix();
glMultMatrix( tBodies.value( 1 ) );
if (!Node::SELECTING)
glColor( color_b );
glBegin( GL_POINTS ); glVertex( pivotB ); glEnd();
glBegin( GL_LINES ); glVertex( pivotB ); glVertex( pivotB + axleB ); glEnd();
drawDashLine( pivotB + axleB2, pivotB, 14 );
drawDashLine( pivotB + Vector3::crossproduct( axleB2, axleB ), pivotB, 14 );
drawCircle( pivotB, axleB, 1.01f );
drawSolidArc( pivotB, axleB / 7, axleB2, Vector3::crossproduct( axleB2, axleB ), minAngle, maxAngle, 1.01f );
glPopMatrix();
glMultMatrix( tBodies.value( 0 ) );
float angle = Vector3::angle( tBodies.value( 0 ).rotation * axleA2, tBodies.value( 1 ).rotation * axleB2 );
if (!Node::SELECTING)
glColor( color_a );
glBegin( GL_LINES );
glVertex( pivotA );
glVertex( pivotA + axleA1 * cosf( angle ) + axleA2 * sinf( angle ) );
glEnd();
}
else if ( name == "bhkHingeConstraint" )
{
QModelIndex iHinge = nif->getIndex( iConstraint, "Hinge" );
const Vector3 pivotA( nif->get<Vector4>( iHinge, "Pivot A" ) );
const Vector3 pivotB( nif->get<Vector4>( iHinge, "Pivot B" ) );
const Vector3 axleA1( nif->get<Vector4>( iHinge, "Perp2 Axle In A1" ) );
const Vector3 axleA2( nif->get<Vector4>( iHinge, "Perp2 Axle In A2" ) );
const Vector3 axleA( Vector3::crossproduct( axleA1, axleA2 ) );
const Vector3 axleB( nif->get<Vector4>( iHinge, "Axle B" ) );
const Vector3 axleB1( axleB[1], axleB[2], axleB[0] );
const Vector3 axleB2( Vector3::crossproduct( axleB, axleB1 ) );
/*
* This should be correct but is visually strange...
*
Vector3 axleB1temp;
Vector3 axleB2temp;
if ( nif->checkVersion( 0, 0x14000002 ) )
{
Vector3 axleB1temp( axleB[1], axleB[2], axleB[0] );
Vector3 axleB2temp( Vector3::crossproduct( axleB, axleB1temp ) );
}
else if ( nif->checkVersion( 0x14020007, 0 ) )
{
Vector3 axleB1temp( nif->get<Vector4>( iHinge, "Perp2 Axle In B1" ) );
Vector3 axleB2temp( nif->get<Vector4>( iHinge, "Perp2 Axle In B2" ) );
}
const Vector3 axleB1( axleB1temp );
const Vector3 axleB2( axleB2temp );
*/
const float minAngle = - PI;
const float maxAngle = + PI;
glPushMatrix();
glMultMatrix( tBodies.value( 0 ) );
if (!Node::SELECTING)
glColor( color_a );
glBegin( GL_POINTS ); glVertex( pivotA ); glEnd();
drawDashLine( pivotA, pivotA + axleA1 );
drawDashLine( pivotA, pivotA + axleA2 );
drawSolidArc( pivotA, axleA / 5, axleA2, axleA1, minAngle, maxAngle, 1.0f, 16 );
glPopMatrix();
glMultMatrix( tBodies.value( 1 ) );
if (!Node::SELECTING)
glColor( color_b );
glBegin( GL_POINTS ); glVertex( pivotB ); glEnd();
glBegin( GL_LINES ); glVertex( pivotB ); glVertex( pivotB + axleB ); glEnd();
drawSolidArc( pivotB, axleB / 7, axleB2, axleB1, minAngle, maxAngle, 1.01f, 16 );
}
else if ( name == "bhkStiffSpringConstraint" )
{
const Vector3 pivotA = tBodies.value( 0 ) * Vector3( nif->get<Vector4>( iConstraint, "Pivot A" ) );
const Vector3 pivotB = tBodies.value( 1 ) * Vector3( nif->get<Vector4>( iConstraint, "Pivot B" ) );
const float length = nif->get<float>( iConstraint, "Length" );
if (!Node::SELECTING)
glColor( color_b );
drawSpring( pivotA, pivotB, length );
}
else if ( name == "bhkRagdollConstraint" )
{
QModelIndex iRagdoll = nif->getIndex( iConstraint, "Ragdoll" );
const Vector3 pivotA( nif->get<Vector4>( iRagdoll, "Pivot A" ) );
const Vector3 pivotB( nif->get<Vector4>( iRagdoll, "Pivot B" ) );
const Vector3 planeA( nif->get<Vector4>( iRagdoll, "Plane A" ) );
const Vector3 planeB( nif->get<Vector4>( iRagdoll, "Plane B" ) );
const Vector3 twistA( nif->get<Vector4>( iRagdoll, "Twist A" ) );
const Vector3 twistB( nif->get<Vector4>( iRagdoll, "Twist B" ) );
const float coneAngle( nif->get<float>( iRagdoll, "Cone Max Angle" ) );
const float minPlaneAngle( nif->get<float>( iRagdoll, "Plane Min Angle" ) );
const float maxPlaneAngle( nif->get<float>( iRagdoll, "Plane Max Angle" ) );
// Unused? GCC complains
/*
const float minTwistAngle( nif->get<float>( iRagdoll, "Twist Min Angle" ) );
const float maxTwistAngle( nif->get<float>( iRagdoll, "Twist Max Angle" ) );
*/
glPushMatrix();
glMultMatrix( tBodies.value( 0 ) );
if (!Node::SELECTING)
glColor( color_a );
glPopMatrix();
glPushMatrix();
glMultMatrix( tBodies.value( 0 ) );
if (!Node::SELECTING)
glColor( color_a );
glBegin( GL_POINTS ); glVertex( pivotA ); glEnd();
glBegin( GL_LINES ); glVertex( pivotA ); glVertex( pivotA + twistA ); glEnd();
drawDashLine( pivotA, pivotA + planeA, 14 );
drawRagdollCone( pivotA, twistA, planeA, coneAngle, minPlaneAngle, maxPlaneAngle );
glPopMatrix();
glPushMatrix();
glMultMatrix( tBodies.value( 1 ) );
if (!Node::SELECTING)
glColor( color_b );
glBegin( GL_POINTS ); glVertex( pivotB ); glEnd();
glBegin( GL_LINES ); glVertex( pivotB ); glVertex( pivotB + twistB ); glEnd();
drawDashLine( pivotB + planeB, pivotB, 14 );
drawRagdollCone( pivotB, twistB, planeB, coneAngle, minPlaneAngle, maxPlaneAngle );
glPopMatrix();
}
else if ( name == "bhkPrismaticConstraint" )
{
const Vector3 pivotA( nif->get<Vector4>( iConstraint, "Pivot A" ) );
const Vector3 pivotB( nif->get<Vector4>( iConstraint, "Pivot B" ) );
const Vector3 planeNormal( nif->get<Vector4>( iConstraint, "Plane" ) );
const Vector3 slidingAxis( nif->get<Vector4>( iConstraint, "Sliding Axis" ) );
const float minDistance = nif->get<float>( iConstraint, "Min Distance" );
const float maxDistance = nif->get<float>( iConstraint, "Max Distance" );
const Vector3 d1 = pivotA + slidingAxis * minDistance;
const Vector3 d2 = pivotA + slidingAxis * maxDistance;
/* draw Pivot A and Plane */
glPushMatrix();
glMultMatrix( tBodies.value( 0 ) );
if (!Node::SELECTING)
glColor( color_a );
glBegin( GL_POINTS ); glVertex( pivotA ); glEnd();
glBegin( GL_LINES ); glVertex( pivotA ); glVertex( pivotA + planeNormal ); glEnd();
drawDashLine( pivotA, d1, 14 );
/* draw rail */
if ( minDistance < maxDistance ) {
drawRail( d1, d2 );
}
/*draw first marker*/
Transform t;
float angle = atan2f( slidingAxis[1], slidingAxis[0] );
if ( slidingAxis[0] < 0.0001f && slidingAxis[1] < 0.0001f ) {
angle = PI / 2;
}
t.translation = d1;
t.rotation.fromEuler( 0.0f, 0.0f, angle );
glMultMatrix( t );
angle = - asinf( slidingAxis[2] / slidingAxis.length() );
t.translation = Vector3( 0.0f, 0.0f, 0.0f );
t.rotation.fromEuler( 0.0f, angle, 0.0f );
glMultMatrix( t );
drawMarker( &BumperMarker01 );
/*draw second marker*/
t.translation = Vector3( minDistance < maxDistance ? ( d2 - d1 ).length() : 0.0f, 0.0f, 0.0f );
t.rotation.fromEuler( 0.0f, 0.0f, PI );
glMultMatrix( t );
drawMarker( &BumperMarker01 );
glPopMatrix();
/* draw Pivot B */
glPushMatrix();
glMultMatrix( tBodies.value( 1 ) );
if (!Node::SELECTING)
glColor( color_b );
glBegin( GL_POINTS ); glVertex( pivotB ); glEnd();
glPopMatrix();
}
glPopAttrib();
glPopMatrix();
}
void Node::drawHavok()
{// TODO: Why are all these here - "drawNodes", "drawFurn", "drawHavok"?
// Proposal: Make them go to their own classes in different cpp files
foreach ( Node * node, children.list() )
node->drawHavok();
const NifModel * nif = static_cast<const NifModel *>( iBlock.model() );
if ( ! ( iBlock.isValid() && nif ) )
return;
//Check if there's any old style collision bounding box set
if ( nif->get<bool>( iBlock, "Has Bounding Box" ) == true )
{
QModelIndex iBox = nif->getIndex( iBlock, "Bounding Box" );
Transform bt;
bt.translation = nif->get<Vector3>( iBox, "Translation" );
bt.rotation = nif->get<Matrix>( iBox, "Rotation" );
bt.scale = 1.0f;
Vector3 rad = nif->get<Vector3>( iBox, "Radius" );
glPushMatrix();
glLoadMatrix( scene->view );
// The Morrowind construction set seems to completely ignore the node transform
//glMultMatrix( worldTrans() );
glMultMatrix( bt );
//glLoadName( nodeId );
if (Node::SELECTING) {
int s_nodeId = ID2COLORKEY( nodeId );
glColor4ubv( (GLubyte *)&s_nodeId );
}
else {
glColor( Color3( 1.0f, 0.0f, 0.0f ) );
glDisable( GL_LIGHTING );
}
glLineWidth( 1.0f );
drawBox( rad, -rad );
glPopMatrix();
}
// Draw BSBound dimensions
QModelIndex iExtraDataList = nif->getIndex( iBlock, "Extra Data List" );
if ( iExtraDataList.isValid() )
{
for ( int d = 0; d < nif->rowCount( iExtraDataList ); d++ )
{
QModelIndex iBound = nif->getBlock( nif->getLink( iExtraDataList.child( d, 0 ) ), "BSBound" );
if ( ! iBound.isValid() )
continue;
Vector3 center = nif->get<Vector3>( iBound, "Center" );
Vector3 dim = nif->get<Vector3>( iBound, "Dimensions" );
glPushMatrix();
glLoadMatrix( scene->view );
// Not sure if world transform is taken into account
glMultMatrix( worldTrans() );
//glLoadName( nif->getBlockNumber( iBound ) );
if (Node::SELECTING) {
int s_nodeId = ID2COLORKEY( nif->getBlockNumber( iBound ) );
glColor4ubv( (GLubyte *)&s_nodeId );
}
else {
glColor( Color3( 1.0f, 0.0f, 0.0f ) );
glDisable( GL_LIGHTING );
}
glLineWidth( 1.0f );
drawBox( dim + center, -dim + center );
glPopMatrix();
}
}
QModelIndex iObject = nif->getBlock( nif->getLink( iBlock, "Collision Data" ) );
if ( ! iObject.isValid() )
iObject = nif->getBlock( nif->getLink( iBlock, "Collision Object" ) );
if ( ! iObject.isValid() )
return;
QModelIndex iBody = nif->getBlock( nif->getLink( iObject, "Body" ) );
glPushMatrix();
glLoadMatrix( scene->view );
glMultMatrix( scene->bhkBodyTrans.value( nif->getBlockNumber( iBody ) ) );
//qWarning() << "draw obj" << nif->getBlockNumber( iObject ) << nif->itemName( iObject );
if (!Node::SELECTING) {
glEnable( GL_DEPTH_TEST );
glDepthMask( GL_TRUE );
glDepthFunc( GL_LEQUAL );
glDisable( GL_TEXTURE_2D );
glDisable( GL_NORMALIZE );
glDisable( GL_LIGHTING );
glDisable( GL_COLOR_MATERIAL );
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glDisable( GL_ALPHA_TEST );
}
glPointSize( 4.5 );
glLineWidth( 1.0 );
static const float colors[8][3] = {
{ 0.0f, 1.0f, 0.0f },
{ 1.0f, 0.0f, 0.0f },
{ 1.0f, 0.0f, 1.0f },
{ 1.0f, 1.0f, 1.0f },
{ 0.5f, 0.5f, 1.0f },
{ 1.0f, 0.8f, 0.0f },
{ 1.0f, 0.8f, 0.4f },
{ 0.0f, 1.0f, 1.0f }
};
int color_index = nif->get<int>( iBody, "Layer" ) & 7;
glColor3fv( colors[ color_index ] );
if ( !Node::SELECTING )
if ( scene->currentBlock == nif->getBlock( nif->getLink( iBody, "Shape" ) ) ) {// fix: add selected visual to havok meshes
glHighlightColor(); // TODO: proposal: I do not recommend mimicking the Open GL API
// It confuses the one who reads the code. And the Open GL API is
// in constant development.
glLineWidth( 2.5 );
//glPointSize( 8.5 );
}
QStack<QModelIndex> shapeStack;
if (Node::SELECTING)
glLineWidth( 5 );// make selection click a little more easy
drawHvkShape( nif, nif->getBlock( nif->getLink( iBody, "Shape" ) ), shapeStack, scene, colors[ color_index ] );
//glLoadName( nif->getBlockNumber( iBody ) );
if (Node::SELECTING) {
int s_nodeId = ID2COLORKEY (nif->getBlockNumber( iBody ) );
glColor4ubv( (GLubyte *)&s_nodeId );
}
else {
glDepthFunc( GL_ALWAYS );
drawAxes( Vector3( nif->get<Vector4>( iBody, "Center" ) ), 0.2f );
glDepthFunc( GL_LEQUAL );
}
glPopMatrix();
foreach ( qint32 l, nif->getLinkArray( iBody, "Constraints" ) )
{
QModelIndex iConstraint = nif->getBlock( l );
if ( nif->inherits( iConstraint, "bhkConstraint" ) )
drawHvkConstraint( nif, iConstraint, scene );
}
}
void drawFurnitureMarker( const NifModel *nif, const QModelIndex &iPosition )
{
QString name = nif->itemName( iPosition );
Vector3 offs = nif->get<Vector3>( iPosition, "Offset" );
quint16 orient = nif->get<quint16>( iPosition, "Orientation" );
quint8 ref1 = nif->get<quint8>( iPosition, "Position Ref 1" );
quint8 ref2 = nif->get<quint8>( iPosition, "Position Ref 2" );
if ( ref1 != ref2 )
{
qDebug() << "Position Ref 1 and 2 are not equal!";
return;
}
Vector3 flip(1, 1, 1);
const GLMarker *mark;
switch ( ref1 )
{
case 1:
mark = &FurnitureMarker01;
break;
case 2:
flip[0] = -1;
mark = &FurnitureMarker01;
break;
case 3:
mark = &FurnitureMarker03;
break;
case 4:
mark = &FurnitureMarker04;
break;
case 11:
mark = &FurnitureMarker11;
break;
case 12:
flip[0] = -1;
mark = &FurnitureMarker11;
break;
case 13:
mark = &FurnitureMarker13;
break;
case 14:
mark = &FurnitureMarker14;
break;
default:
qDebug() << "Unknown furniture marker " << ref1 << "!";
return;
}
float roll = float( orient ) / 6284.0 * 2.0 * (-M_PI);
//glLoadName( ( nif->getBlockNumber( iPosition ) & 0xffff ) | ( ( iPosition.row() & 0xffff ) << 16 ) ); - disabled glRenderMode( GL_SELECT );
if (Node::SELECTING) {// TODO: not tested! need nif files what contain that
GLint id = ( nif->getBlockNumber( iPosition ) & 0xffff ) | ( ( iPosition.row() & 0xffff ) << 16 );
int s_nodeId = ID2COLORKEY( id );
glColor4ubv ( (GLubyte *)&s_nodeId);
}
glPushMatrix();
Transform t;
t.rotation.fromEuler( 0, 0, roll );
t.translation = offs;
glMultMatrix( t );
glScale(flip);
drawMarker( mark );
glPopMatrix();
}
void Node::drawFurn()
{
foreach ( Node * node, children.list() )
node->drawFurn();
const NifModel * nif = static_cast<const NifModel *>( iBlock.model() );
if ( ! ( iBlock.isValid() && nif ) )
return;
QModelIndex iExtraDataList = nif->getIndex( iBlock, "Extra Data List" );
if ( !iExtraDataList.isValid() )
return;
if (!Node::SELECTING) {
glEnable( GL_DEPTH_TEST );
glDepthMask( GL_FALSE );
glDepthFunc( GL_LEQUAL );
glDisable( GL_TEXTURE_2D );
glDisable( GL_NORMALIZE );
glDisable( GL_LIGHTING );
glDisable( GL_COLOR_MATERIAL );
glDisable( GL_CULL_FACE );
glDisable( GL_BLEND );
glDisable( GL_ALPHA_TEST );
glColor4f( 1, 1, 1, 1 );
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
}
glLineWidth( 1.0 );
glPushMatrix();
glMultMatrix( viewTrans() );
for ( int p = 0; p < nif->rowCount( iExtraDataList ); p++ )
{// DONE: never seen Furn in nifs, so there may be a need of a fix here later - saw one, fixed a bug
QModelIndex iFurnMark = nif->getBlock( nif->getLink( iExtraDataList.child( p, 0 ) ), "BSFurnitureMarker" );
if ( ! iFurnMark.isValid() )
continue;
QModelIndex iPositions = nif->getIndex( iFurnMark, "Positions" );
if ( !iPositions.isValid() )
break;
for ( int j = 0; j < nif->rowCount( iPositions ); j++ )
{
QModelIndex iPosition = iPositions.child( j, 0 );
if ( scene->currentIndex == iPosition )
glHighlightColor();
else
glNormalColor();
drawFurnitureMarker( nif, iPosition );
}
}
glPopMatrix();
}
void Node::drawShapes( NodeList * draw2nd )
{
if ( isHidden() )
return;
foreach ( Node * node, children.list() )
{
node->drawShapes( draw2nd );
}
}
#define Farg( X ) arg( X, 0, 'f', 5 )
QString trans2string( Transform t )
{
float xr, yr, zr;
t.rotation.toEuler( xr, yr, zr );
return QString( "translation X %1, Y %2, Z %3\n" ).Farg( t.translation[0] ).Farg( t.translation[1] ).Farg( t.translation[2] )
+ QString( "rotation Y %1, P %2, R %3 " ).Farg( xr * 180 / PI ).Farg( yr * 180 / PI ).Farg( zr * 180 / PI )
+ QString( "( (%1, %2, %3), " ).Farg( t.rotation( 0, 0 ) ).Farg( t.rotation( 0, 1 ) ).Farg( t.rotation( 0, 2 ) )
+ QString( "(%1, %2, %3), " ).Farg( t.rotation( 1, 0 ) ).Farg( t.rotation( 1, 1 ) ).Farg( t.rotation( 1, 2 ) )
+ QString( "(%1, %2, %3) )\n" ).Farg( t.rotation( 2, 0 ) ).Farg( t.rotation( 2, 1 ) ).Farg( t.rotation( 2, 2 ) )
+ QString( "scale %1\n" ).Farg( t.scale );
}
QString Node::textStats() const
{
return QString( "%1\n\nglobal\n%2\nlocal\n%3\n" ).arg( name ).arg( trans2string( worldTrans() ) ).arg( trans2string( localTrans() ) );
}
BoundSphere Node::bounds() const
{
BoundSphere boundsphere;
// the node itself
if ( Options::drawNodes() || Options::drawHavok() ) {
boundsphere |= BoundSphere( worldTrans().translation, 0 );
}
const NifModel * nif = static_cast<const NifModel *>( iBlock.model() );
if ( ! ( iBlock.isValid() && nif ) )
return boundsphere;
// old style collision bounding box
if ( nif->get<bool>( iBlock, "Has Bounding Box" ) == true )
{
QModelIndex iBox = nif->getIndex( iBlock, "Bounding Box" );
Vector3 trans = nif->get<Vector3>( iBox, "Translation" );
Vector3 rad = nif->get<Vector3>( iBox, "Radius" );
boundsphere |= BoundSphere(trans, rad.length());
}
// BSBound collision bounding box
QModelIndex iExtraDataList = nif->getIndex( iBlock, "Extra Data List" );
if ( iExtraDataList.isValid() )
{
for ( int d = 0; d < nif->rowCount( iExtraDataList ); d++ )
{
QModelIndex iBound = nif->getBlock( nif->getLink( iExtraDataList.child( d, 0 ) ), "BSBound" );
if ( ! iBound.isValid() )
continue;
Vector3 center = nif->get<Vector3>( iBound, "Center" );
Vector3 dim = nif->get<Vector3>( iBound, "Dimensions" );
boundsphere |= BoundSphere(center, dim.length());
}
}
return boundsphere;
}
LODNode::LODNode( Scene * scene, const QModelIndex & iBlock )
: Node( scene, iBlock )
{
}
void LODNode::clear()
{
Node::clear();
ranges.clear();
}
void LODNode::update( const NifModel * nif, const QModelIndex & index )
{
Node::update( nif, index );
if ( ( iBlock.isValid() && index == iBlock ) || ( iData.isValid() && index == iData ) )
{
ranges.clear();
iData = nif->getBlock( nif->getLink( iBlock, "LOD Level Data" ), "NiRangeLODData" );
QModelIndex iLevels;
if ( iData.isValid() )
{
center = nif->get<Vector3>( iData, "LOD Center" );
iLevels = nif->getIndex( iData, "LOD Levels" );
}
else
{
center = nif->get<Vector3>( iBlock, "LOD Center" );
iLevels = nif->getIndex( iBlock, "LOD Levels" );
}
if ( iLevels.isValid() )
for ( int r = 0; r < nif->rowCount( iLevels ); r++ )
ranges.append( qMakePair<float,float>( nif->get<float>( iLevels.child( r, 0 ), "Near Extent" ), nif->get<float>( iLevels.child( r, 0 ), "Far Extent" ) ) );
}
}
void LODNode::transform()
{
Node::transform();
if ( children.list().isEmpty() )
return;
if ( ranges.isEmpty() )
{
foreach ( Node * child, children.list() )
child->flags.node.hidden = true;
children.list().first()->flags.node.hidden = false;
return;
}
float distance = ( viewTrans() * center ).length();
int c = 0;
foreach ( Node * child, children.list() )
{
if ( c < ranges.count() )
child->flags.node.hidden = ! ( ranges[c].first <= distance && distance < ranges[c].second );
else
child->flags.node.hidden = true;
c++;
}
}
BillboardNode::BillboardNode( Scene * scene, const QModelIndex & iBlock )
: Node( scene, iBlock )
{
}
const Transform & BillboardNode::viewTrans() const
{
if ( scene->viewTrans.contains( nodeId ) )
return scene->viewTrans[ nodeId ];
Transform t;
if ( parent )
t = parent->viewTrans() * local;
else
t = scene->view * worldTrans();
t.rotation = Matrix();
scene->viewTrans.insert( nodeId, t );
return scene->viewTrans[ nodeId ];
}
| [
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]"
]
| [
[
[
1,
4
],
[
6,
15
],
[
17,
35
],
[
37,
390
],
[
392,
400
],
[
404,
411
],
[
413,
770
],
[
772,
791
],
[
816,
824
],
[
826,
829
],
[
831,
839
],
[
857,
857
],
[
861,
917
],
[
919,
934
],
[
948,
955
],
[
957,
960
],
[
966,
969
],
[
975,
982
],
[
988,
992
],
[
998,
1005
],
[
1011,
1052
],
[
1058,
1061
],
[
1073,
1075
],
[
1081,
1121
],
[
1123,
1127
],
[
1140,
1215
],
[
1231,
1269
],
[
1272,
1281
],
[
1284,
1293
],
[
1296,
1302
],
[
1304,
1312
],
[
1314,
1316
],
[
1338,
1342
],
[
1345,
1351
],
[
1354,
1363
],
[
1366,
1386
],
[
1389,
1390
],
[
1392,
1394
],
[
1397,
1400
],
[
1403,
1410
],
[
1413,
1435
],
[
1438,
1475
],
[
1478,
1486
],
[
1489,
1499
],
[
1501,
1501
],
[
1503,
1505
],
[
1507,
1507
],
[
1509,
1510
],
[
1513,
1513
],
[
1524,
1524
],
[
1527,
1528
],
[
1560,
1560
],
[
1566,
1567
],
[
1569,
1579
],
[
1593,
1606
],
[
1617,
1618
],
[
1622,
1622
],
[
1633,
1702
],
[
1709,
1737
],
[
1752,
1758
],
[
1760,
1940
]
],
[
[
5,
5
],
[
16,
16
],
[
391,
391
],
[
401,
403
],
[
412,
412
],
[
1122,
1122
],
[
1128,
1139
],
[
1313,
1313
],
[
1317,
1337
],
[
1387,
1388
],
[
1391,
1391
],
[
1500,
1500
],
[
1502,
1502
],
[
1506,
1506
],
[
1508,
1508
],
[
1511,
1512
],
[
1514,
1514
],
[
1525,
1526
],
[
1529,
1548
],
[
1558,
1559
],
[
1561,
1565
],
[
1568,
1568
]
],
[
[
36,
36
],
[
792,
815
],
[
825,
825
],
[
830,
830
],
[
840,
856
],
[
858,
860
],
[
918,
918
],
[
935,
947
],
[
956,
956
],
[
961,
965
],
[
970,
974
],
[
983,
987
],
[
993,
997
],
[
1006,
1010
],
[
1053,
1057
],
[
1062,
1072
],
[
1076,
1080
],
[
1216,
1230
],
[
1270,
1271
],
[
1282,
1283
],
[
1294,
1295
],
[
1343,
1344
],
[
1352,
1353
],
[
1364,
1365
],
[
1395,
1396
],
[
1401,
1402
],
[
1411,
1412
],
[
1436,
1437
],
[
1476,
1477
],
[
1487,
1488
],
[
1515,
1523
],
[
1549,
1557
],
[
1580,
1592
],
[
1607,
1616
],
[
1619,
1621
],
[
1623,
1632
],
[
1703,
1708
],
[
1738,
1751
],
[
1759,
1759
]
],
[
[
771,
771
],
[
1303,
1303
]
]
]
|
aef8343c727585455743e165a5be835344303094 | ed9ecdcba4932c1adacac9218c83e19f71695658 | /UniversalSoftwareRasterizer/trunk/UniversalSoftwareRasterizer/USRMatrix.h | 76de33781646ff0210ba9044add42073bdaf022e | []
| no_license | karansapra/futurattack | 59cc71d2cc6564a066a8e2f18e2edfc140f7c4ab | 81e46a33ec58b258161f0dd71757a499263aaa62 | refs/heads/master | 2021-01-10T08:47:01.902600 | 2010-09-20T20:25:04 | 2010-09-20T20:25:04 | 45,804,375 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,968 | h | #ifndef USRMatrix_h__
#define USRMatrix_h__
#include "USRVector3.h"
#include <math.h>
/**
\brief Matrix used in 3d maths
*/
class USRMatrix
{
public:
USRMatrix()
{
for (int i=0;i<16;i++)
_m[i] = 0;
_m[0] = 1;
_m[5] = 1;
_m[10] = 1;
_m[15] = 1;
}
USRVector3 operator*(USRVector3 & v)
{
USRVector3 result;
for (unsigned int c=0;c<4;c++)
{
for (unsigned int x=0;x<4;x++)
result.Values[c] += v.Values[x]*GetValue(x,c);
}
return result;
}
USRMatrix operator*(USRMatrix & m)
{
USRMatrix result;
for (unsigned int y=0;y<4;y++)
{
for (unsigned int x=0;x<4;x++)
{
result.GetValue(x,y) = 0;
for (unsigned int i=0;i<4;i++)
result.GetValue(x,y) += GetValue(i,y) * m.GetValue(x,i);
}
}
return result;
}
void Translate(USRVector3 & t)
{
USRMatrix tm = CreateTranslationMatrix(t);
USRMatrix res = (*this)*tm;
memcpy(_m,res._m,sizeof(float)*16);
}
static USRMatrix CreateTranslationMatrix(USRVector3 & t)
{
USRMatrix m;
m[12] = t.X;
m[13] = t.Y;
m[14] = t.Z;
return m;
}
static USRMatrix CreateZRotationMatrix(float angle)
{
USRMatrix m;
float c = cosf(angle);
float s = sinf(angle);
m[0] = c;
m[1] = s;
m[4] = -s;
m[5] = c;
return m;
}
static USRMatrix CreateYRotationMatrix(float angle)
{
USRMatrix m;
float c = cosf(angle);
float s = sinf(angle);
m[0] = c;
m[2] = -s;
m[8] = s;
m[10] = c;
return m;
}
static USRMatrix CreateXRotationMatrix(float angle)
{
USRMatrix m;
float c = cosf(angle);
float s = sinf(angle);
m[5] = c;
m[6] = s;
m[9] = -s;
m[10] = c;
return m;
}
/**
\brief Used to setup a Camera matrix
*/
static USRMatrix CreateLookAtMatrix(USRVector3 eye, USRVector3 center ,USRVector3 up)
{
USRVector3 ViewDirection = center-eye;
ViewDirection.Normalize();
up.Normalize();
USRVector3 RightDirection = ViewDirection.CrossProduct(up);
RightDirection.Normalize();
up = RightDirection.CrossProduct(ViewDirection);
USRMatrix result;
result[0] = RightDirection.X;
result[4] = RightDirection.Y;
result[8] = RightDirection.Z;
result[1] = up.X;
result[5] = up.Y;
result[9] = up.Z;
result[2] = -ViewDirection.X;
result[6] = -ViewDirection.Y;
result[10] = -ViewDirection.Z;
eye.Invert();
result.Translate(eye);
/*
result[12] = -(result[0]*eye.X + result[4]*eye.Y + result[8]*eye.Z);
result[13] = -(result[1]*eye.X + result[5]*eye.Y + result[9]*eye.Z);
result[14] = -(result[2]*eye.X + result[6]*eye.Y + result[10]*eye.Z);
*/
return result;
}
static USRMatrix CreateWindowMatrix(float width, float height)
{
USRMatrix m;
m[0] = width/2;
m[5] = -height/2;
m[12] = width/2;
m[13] = height/2;
return m;
}
static USRMatrix CreateOrthoProjectionMatrix(float left, float right, float bottom, float top, float near, float far)
{
USRMatrix m;
m[0] = 2.0f/(right-left);
m[5] = 2.0f/(top-bottom);
m[10] = 1.0f/(far-near);
m[12] = (right+left)/(left-right);
m[13] = (top+bottom)/(bottom-top);
m[14] = near/(near-far);
return m;
}
static USRMatrix CreateProjectionMatrix(float left, float right, float bottom, float up, float near, float far)
{
USRMatrix m;
m[0] = (2.0f*near)/(right-left);
m[5] = (2.0f*near)/(up-bottom);
m[10] = (far)/(far-near);
m[11] = 1;
m[15] = 0;
m[14] = (-near*far)/(far-near);
return m;
}
static USRMatrix CreateScaleMatrix(USRVector3 & scale)
{
USRMatrix m;
m[0] = scale.X;
m[5] = scale.Y;
m[10] = scale.Z;
return m;
}
private:
float _m[16];
inline float & operator[](unsigned int index)
{
return _m[index];
}
inline float & GetValue(unsigned int x,unsigned int y)
{
return _m[(x<<2)+y];
}
};
#endif // USRMatrix_h__ | [
"clems71@52ecbd26-af3e-11de-a2ab-0da4ed5138bb"
]
| [
[
[
1,
222
]
]
]
|
687b4491e326b908dc85244e4fb8ae5489aa09bf | 0dfa7f23c2384251443da0cb129f79e3ea4d6b52 | /GClient/message/MessageTimeToStartGame.h | 581c8ae2111fbd3819675cafbd05d46c6a045cf1 | []
| no_license | TeamFirst/Galcon | b908a1df4e161b3e726084a6e8054cbfa95d3ec4 | f7ccb7f0bb27820d2246529a577be2e89de248e4 | refs/heads/master | 2020-12-25T15:40:04.411443 | 2011-06-14T14:25:38 | 2011-06-14T14:25:38 | 1,810,650 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 328 | h | #pragma once
#include <QSharedPointer>
namespace Message
{
struct CMessageTimeToStartGame;
typedef QSharedPointer<CMessageTimeToStartGame> CMessageTimeToStartGamePtr;
struct CMessageTimeToStartGame
{
unsigned int m_second;
}; // struct CMessaheTimeToStartGame
}; // namespace Message
| [
"vlad@vlad-laptop.(none)",
"[email protected]",
"GrafAllukard"
]
| [
[
[
1,
6
],
[
8,
8
],
[
10,
10
],
[
12,
12
],
[
15,
17
]
],
[
[
7,
7
],
[
9,
9
],
[
13,
14
]
],
[
[
11,
11
]
]
]
|
7191c0731c6c34937b1c014dc81f394ae89d13bd | 6c8c4728e608a4badd88de181910a294be56953a | /Interfaces/ModuleLoggingFunctions.h | 453961136df10439d5f18b650f7c118fde848831 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | caocao/naali | 29c544e121703221fe9c90b5c20b3480442875ef | 67c5aa85fa357f7aae9869215f840af4b0e58897 | refs/heads/master | 2021-01-21T00:25:27.447991 | 2010-03-22T15:04:19 | 2010-03-22T15:04:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,361 | h | // For conditions of distribution and use, see copyright notice in license.txt
#ifndef incl_Interfaces_ModuleLoggingFunctions_h
#define incl_Interfaces_ModuleLoggingFunctions_h
#include <Poco/Logger.h>
#define MODULE_LOGGING_FUNCTIONS \
static void LogFatal(const std::string &msg) { Poco::Logger::get(NameStatic()).fatal("Fatal: " + msg); } \
static void LogCritical(const std::string &msg) { Poco::Logger::get(NameStatic()).critical("Critical: " + msg); } \
static void LogError(const std::string &msg) { Poco::Logger::get(NameStatic()).error("Error: " + msg); } \
static void LogWarning(const std::string &msg) { Poco::Logger::get(NameStatic()).warning("Warning: " + msg); } \
static void LogNotice(const std::string &msg) { Poco::Logger::get(NameStatic()).notice("Notice: " + msg); } \
static void LogInfo(const std::string &msg) { Poco::Logger::get(NameStatic()).information(msg); } \
static void LogTrace(const std::string &msg) { Poco::Logger::get(NameStatic()).trace("Trace: " + msg); } \
static void LogDebug(const std::string &msg) { Poco::Logger::get(NameStatic()).debug("Debug: " + msg); }
#endif
| [
"jujjyl@5b2332b8-efa3-11de-8684-7d64432d61a3"
]
| [
[
[
1,
19
]
]
]
|
80c87592d8635e6ad7b9ba7ec1d5c14d653daa6d | 5ac13fa1746046451f1989b5b8734f40d6445322 | /minimangalore/Nebula2/code/nebula2/src/gfx2/nfont2_main.cc | e31672a59a540d09d5dbc0882ffcbba0d427c1e2 | []
| 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 | 946 | cc | //------------------------------------------------------------------------------
// nfont2_main.cc
// (C) 2003 RadonLabs GmbH
//------------------------------------------------------------------------------
#include "gfx2/nfont2.h"
nNebulaClass(nFont2, "nresource");
//------------------------------------------------------------------------------
/**
*/
nFont2::nFont2()
{
// empty
}
//------------------------------------------------------------------------------
/**
*/
nFont2::~nFont2()
{
if (!this->IsUnloaded())
{
this->Unload();
}
}
//------------------------------------------------------------------------------
/**
*/
void
nFont2::SetFontDesc(const nFontDesc& desc)
{
this->fontDesc = desc;
}
//------------------------------------------------------------------------------
/**
*/
const nFontDesc&
nFont2::GetFontDesc() const
{
return this->fontDesc;
}
| [
"BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c"
]
| [
[
[
1,
44
]
]
]
|
37ae4b4294b73a47791c6e123f05d530dcee67f1 | f77f105963cd6447d0f392b9ee7d923315a82ac6 | /Box2DandOgre/include/KGBTimer.h | c5b165e113b0ffa26d1c0764b39d43d3c6aac60a | []
| no_license | GKimGames/parkerandholt | 8bb2b481aff14cf70a7a769974bc2bb683d74783 | 544f7afa462c5a25c044445ca9ead49244c95d3c | refs/heads/master | 2016-08-07T21:03:32.167272 | 2010-08-26T03:01:35 | 2010-08-26T03:01:35 | 32,834,451 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,117 | h | /*=============================================================================
KGBTimer.h
Author: Matt King
=============================================================================*/
#ifndef KGBTIMER_H
#define KGBTIMER_H
#include "windows.h"
class KGBTimer
{
public:
KGBTimer()
{
totalTime_ = 0;
count_ = 0;
t1.QuadPart = t2.QuadPart = 0;
QueryPerformanceFrequency(&frequency);
}
~KGBTimer()
{
}
void StartTimer()
{
lastTime = t1;
QueryPerformanceCounter(&t1);
// Get the processor time.
LONGLONG qpart = (t1.QuadPart - lastTime.QuadPart);
// There is some weird math error here, I don't know what it is but
// I had to multiply by 10000000 or it gave wrong results.
double time = LONGLONG( (qpart * 10000000) / frequency.QuadPart );
time /= 10000000.0;
totalTime_ += time;
count_++;
}
double EndTimer()
{
return totalTime_ / count_;
}
private:
LARGE_INTEGER frequency;
LARGE_INTEGER t1;
LARGE_INTEGER lastTime;
LARGE_INTEGER t2;
double totalTime_;
double count_;
};
#endif | [
"mapeki@34afb35a-be5b-11de-bb5c-85734917f5ce"
]
| [
[
[
1,
65
]
]
]
|
9615eb5b1a688e94a265128335c324c2cfc248ae | 1dba10648f60dea02c9be242c668f3488ae8dec4 | /modules/video_acq_opencv/src/va_opencv.cpp | 34616e511b647e2f02f3eb0e57ec1618bd422979 | []
| no_license | hateom/si-air | f02ffc8ba9fac9777d12a40627f06044c92865f0 | 2094c98a04a6785078b4c8bcded8f8b4450c8b92 | refs/heads/master | 2021-01-15T17:42:12.887029 | 2007-01-21T17:48:48 | 2007-01-21T17:48:48 | 32,139,237 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,006 | cpp | #define MOD_CPP
#include "va_opencv.h"
#include "../../module_base/src/types.h"
#include "../../module_base/src/status_codes.h"
#include "../../module_base/src/property_mgr.h"
//////////////////////////////////////////////////////////////////////////
#include <cv.h>
#include <highgui.h>
#include <cvcam.h>
#pragma comment(lib,"cv.lib")
#pragma comment(lib,"cvcam.lib")
#pragma comment(lib,"cxcore.lib")
#pragma comment(lib,"cvaux.lib")
#pragma comment(lib,"ml.lib")
#pragma comment(lib,"highgui.lib")
//////////////////////////////////////////////////////////////////////////
vaOpenCV::vaOpenCV() : capture(NULL), alloc_mem(0)
{
REG_PARAM( PT_INT, device, "Device id number", 0 );
REG_PARAM( PT_FILENAME, filename, "Video filename", 0 );
REG_PARAM( PT_BOOL, invert_x, "Mirror mode (invert x)", 1 );
set_param( "preview_param", 1 );
}
//////////////////////////////////////////////////////////////////////////
vaOpenCV::~vaOpenCV()
{
}
//////////////////////////////////////////////////////////////////////////
const char * vaOpenCV::get_module_description()
{
static char descritpion[] = "OpenCV Acquisition module";
return( descritpion );
}
//////////////////////////////////////////////////////////////////////////
int vaOpenCV::input_type()
{
return( MT_NONE );
}
//////////////////////////////////////////////////////////////////////////
int vaOpenCV::output_type()
{
return( MT_FRAME );
}
//////////////////////////////////////////////////////////////////////////
int vaOpenCV::init( PropertyMgr * pm )
{
USE_PROPERTY_MGR( pm );
if( capture != NULL ) free();
if( ( filename != NULL ) && ( strcmp( filename, "" ) != 0 ) )
{
capture = cvCaptureFromFile( filename );
}
else
{
capture = cvCaptureFromCAM( device );
}
if( !capture )
{
return( ST_DEVICE_NOT_FOUND );
}
return( ST_OK );
}
//////////////////////////////////////////////////////////////////////////
proc_data * vaOpenCV::process_frame( proc_data * prev_frame, int * result )
{
if( !capture )
{
*result = ST_DEVICE_NOT_FOUND;
return( NULL );
}
IplImage * frame = cvQueryFrame( capture );
if( !frame )
{
*result = ST_FRAME_ERROR;
return( NULL );
}
static frame_data static_frame;
static proc_data p_data = { 0, 0, 0, 0 };
static_frame.depth = 4;
static_frame.width = frame->width;
static_frame.height = frame->height;
if( alloc_mem == 0 )
{
alloc_mem = static_frame.depth*static_frame.height*static_frame.width;
static_frame.bits = new unsigned char[alloc_mem];
}
else
{
if( alloc_mem != frame->depth*frame->height*frame->width )
{
delete [] static_frame.bits;
alloc_mem = static_frame.depth*static_frame.height*static_frame.width;
static_frame.bits = new unsigned char[alloc_mem];
}
}
long offs1, offs2, aof1, aof2;
for( int y=0; y<(int)static_frame.height; ++y )
{
aof1 = (static_frame.height-y-1)*static_frame.width;
aof2 = y*static_frame.width;
for( int x=0; x<(int)static_frame.width; ++x )
{
offs1 = (x+aof1)*4;
offs2 = (x+aof2)*3;
if( invert_x )
{
offs1 = (static_frame.width-1-x+aof1)*4;
}
static_frame.bits[offs1+0] = frame->imageData[offs2+0];
static_frame.bits[offs1+1] = frame->imageData[offs2+1];
static_frame.bits[offs1+2] = frame->imageData[offs2+2];
}
}
*result = ST_OK;
p_data.input_frame = &static_frame;
p_data.frame = &static_frame;
return( &p_data );
}
//////////////////////////////////////////////////////////////////////////
void vaOpenCV::free()
{
if( capture != NULL )
{
cvReleaseCapture( &capture );
capture = NULL;
}
}
//////////////////////////////////////////////////////////////////////////
extern "C" {
__declspec(dllexport) vaOpenCV * export_module()
{
return( new vaOpenCV );
}
};
//////////////////////////////////////////////////////////////////////////
| [
"tomasz.huczek@9b5b1781-be22-0410-ac8e-a76ce1d23082"
]
| [
[
[
1,
175
]
]
]
|
dbcad9275ea547439cb5df208df2dcad3fdad4db | 6a69593bdd78c65cbaeb731155c44d1ccb134802 | /recap/test_list.cpp | 838f604f1ca2956896adc004f13482c396bfe133 | []
| no_license | fannix/poj | 2ccf77e5ed0c1ea54602015026e17fda8107dd71 | 49b8c49a48fb67cba38bd72d7d12c103545a4511 | refs/heads/master | 2016-09-06T01:35:49.157774 | 2011-05-10T06:04:30 | 2011-05-10T06:04:30 | 1,726,476 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,228 | cpp | #include <iostream>
#include <list>
using namespace std;
struct node{
int a;
int b;
node(int _a, int _b){
this->a = _a;
this->b = _b;
}
};
int cmp(node node1, node node2){
return node1.b < node2.b;
}
void add(list<node> &li1, list<node> &li2){
li1.sort(cmp);
li2.sort(cmp);
list<node>::iterator it1;
list<node>::iterator it2;
for (it1 = li1.begin(), it2 = li2.begin(); it1 != li1.end() && it2 != li2.end();){
if (it1->b < it2->b){
cout << it1->a << "x" << it1->b << " ";
it1++;
}
else if (it1->b == it2->b){
cout << it1->a + it2->a << "x" << it2->b << " ";
it1++;
it2++;
}
else{
cout << it2->a << "x" << it2->b << " ";
it2++;
}
}
for(; it1 != li1.end(); it1++)
cout << it1->a << "x" << it1->b << " ";
for(; it2 != li2.end(); it2++)
cout << it2->a << "x" << it2->b << " ";
}
int main(){
list<node> li1;
for (int i = 9; i >= 0; i--){
li1.push_back(node(i, i));
}
list<node> li2;
for (int i = 0; i < 9; i+=2){
li2.push_back(node(i, i));
}
add(li1, li2);
return 0;
}
/*
* error1 : when you dereference a iterator, the iterator must be valid
* note1: container is passed by value
*/
| [
"[email protected]"
]
| [
[
[
1,
68
]
]
]
|
b574b774f919ac3a9d71a5ccfd226d44355d0d6e | a36d7a42310a8351aa0d427fe38b4c6eece305ea | /core_billiard/RenderTarget.h | 4705cecd9f91ad5ba05ed96b69a26366eb78e491 | []
| no_license | newpolaris/mybilliard01 | ca92888373c97606033c16c84a423de54146386a | dc3b21c63b5bfc762d6b1741b550021b347432e8 | refs/heads/master | 2020-04-21T06:08:04.412207 | 2009-09-21T15:18:27 | 2009-09-21T15:18:27 | 39,947,400 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 258 | h | #pragma once
namespace my_render {
MY_INTERFACE RenderTarget {
virtual ~RenderTarget() {}
virtual bool displayOnRenderTarget( Render * render, RenderTargetCallBack * ) PURE;
virtual Texture * getRenderTargetTexture() PURE;
};
} | [
"wrice127@af801a76-7f76-11de-8b9f-9be6f49bd635"
]
| [
[
[
1,
14
]
]
]
|
bf33f83a6c66e61a90760fc2faac6ae4e37f0b57 | 4891542ea31c89c0ab2377428e92cc72bd1d078f | /Arcanoid/Arcanoid/MovingAnimation.h | 929e015c663657034b2913e0b62f41c15fa0e124 | []
| no_license | koutsop/arcanoid | aa32c46c407955a06c6d4efe34748e50c472eea8 | 5bfef14317e35751fa386d841f0f5fa2b8757fb4 | refs/heads/master | 2021-01-18T14:11:00.321215 | 2008-07-17T21:50:36 | 2008-07-17T21:50:36 | 33,115,792 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,069 | h | /*
* author: koutsop
*/
/*
Orizei mia metakinish me sugkekrimeno (dx, dy), ka8ws kai daley
meta apo thn parodo tou opoiou h kinhsh 8a efarmostei.
*/
#ifndef MOVINGANIMATION_H
#define MOVINGANIMATION_H
#include "Animation.h"
class MovingAnimation : public Animation {
private:
bool continuous;
delay_t delay;
offset_t dx, dy;
public:
offset_t GetDx(void) const { return dx; }
offset_t GetDy(void) const { return dy; }
delay_t GetDelay(void) const { return delay; }
bool GetContinuous(void) const { return continuous; }
void SetDx (offset_t v) { dx = v; }
void SetDy (offset_t v) { dy = v; }
void SetDelay (delay_t v) { delay = v; }
void SetContinuous (bool v) { continuous = v; }
virtual Animation* Clone (animid_t newId) const;
//cunstractor
MovingAnimation (
offset_t _dx, offset_t _dy, delay_t _delay, bool c, animid_t _id
): dx(_dx), dy(_dy), delay(_delay), continuous(c), Animation(_id){}
//destructor
virtual ~MovingAnimation(void) {}
};
#endif | [
"apixkernel@5c4dd20e-9542-0410-abe3-ad2d610f3ba4"
]
| [
[
[
1,
42
]
]
]
|
3ff0ebc6fa254e2a3a6d0b3c15f153ce98b86c45 | 5ed707de9f3de6044543886ea91bde39879bfae6 | /ASFantasy/Shared/Source/ASFantasyObjectStore.h | 14435db18bb02805f8282ccb5fcda3035d8cd920 | []
| no_license | grtvd/asifantasysports | 9e472632bedeec0f2d734aa798b7ff00148e7f19 | 76df32c77c76a76078152c77e582faa097f127a8 | refs/heads/master | 2020-03-19T02:25:23.901618 | 1999-12-31T16:00:00 | 2018-05-31T19:48:19 | 135,627,290 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,782 | h | /* ASFantasyObjectStore.h */
/******************************************************************************/
/******************************************************************************/
#ifndef ASFantasyObjectStoreH
#define ASFantasyObjectStoreH
#include "ObjectStore.h"
#include "ASFantasyType.h"
#include "ASDraftType.h"
#include "ASFantasyObjectBuilder.h"
#include "ASFantasyObjectShelf.h"
/******************************************************************************/
namespace asfantasy
{
/******************************************************************************/
class ASFantasyObjectStore : public ObjectStore
{
protected:
ASFantasyObjectStore(ASFantasyObjectBuilder& builder);
public:
static ASFantasyObjectStore& getThe()
{ return(dynamic_cast<ASFantasyObjectStore&>(ObjectStore::getThe())); }
ASFantasyObjectBuilder& getBuilder()
{ return(dynamic_cast<ASFantasyObjectBuilder&>(fBuilder)); }
/**************************************************************************/
// Functions to retrieve ObjectShelfKeys
// virtual ObjectShelfKeyType getLeagueShelfKey(void) = 0;
virtual ObjectShelfKeyType getTeamShelfKey(void)
{ return(typeid(TTeamPtr).name()); }
virtual ObjectShelfKeyType getProfPlayerShelfKey(void)
{ return(typeid(TProfPlayerPtr).name()); }
virtual ObjectShelfKeyType getProfTeamShelfKey(void)
{ return(typeid(TProfTeamPtr).name()); }
virtual ObjectShelfKeyType getPlayerShelfKey(void)
{ return(typeid(TPlayerPtr).name()); }
virtual ObjectShelfKeyType getOffGameStatShelfKey(void)
{ return(typeid(TOffGameStatPtr).name()); }
virtual ObjectShelfKeyType getDefGameStatShelfKey(void)
{ return(typeid(TDefGameStatPtr).name()); }
virtual ObjectShelfKeyType getDraftRankingShelfKey(void)
{ return(typeid(TDraftRankingPtr).name()); }
virtual ObjectShelfKeyType getDraftPosCountShelfKey(void)
{ return(typeid(TDraftPosCount).name()); }
virtual ObjectShelfKeyType getScheduleDayShelfKey(void)
{ return(typeid(TScheduleDayPtr).name()); }
// ObjectShelf Functions
TeamObjectShelf* getTeamShelf()
{ return(dynamic_cast<TeamObjectShelf*>(getShelfByKey(getTeamShelfKey(),
gsm_MustExist))); }
void addTeamShelf();
void delTeamShelf() { delShelf(getTeamShelfKey()); }
void saveAndDelAllTeamShelfItems();
ProfPlayerObjectShelf* getProfPlayerShelf()
{ return(dynamic_cast<ProfPlayerObjectShelf*>(
getShelfByKey(getProfPlayerShelfKey(),gsm_MustExist))); }
void addProfPlayerShelf();
void delProfPlayerShelf() { delShelf(getProfPlayerShelfKey()); }
void delAllProfPlayerShelfItems();
ProfTeamObjectShelf* getProfTeamShelf()
{ return(dynamic_cast<ProfTeamObjectShelf*>(
getShelfByKey(getProfTeamShelfKey(),gsm_MustExist))); }
void addProfTeamShelf();
void delProfTeamShelf() { delShelf(getProfTeamShelfKey()); }
void delAllProfTeamShelfItems();
PlayerObjectShelf* getPlayerShelf()
{ return(dynamic_cast<PlayerObjectShelf*>(getShelfByKey(getPlayerShelfKey(),
gsm_MustExist))); }
void addPlayerShelf();
void delPlayerShelf() { delShelf(getPlayerShelfKey()); }
void saveAndDelAllPlayerShelfItems();
OffGameStatObjectShelf* getOffGameStatShelf()
{ return(dynamic_cast<OffGameStatObjectShelf*>(getShelfByKey(
getOffGameStatShelfKey(),gsm_MustExist))); }
void addOffGameStatShelf();
void delOffGameStatShelf() { delShelf(getOffGameStatShelfKey()); }
void delAllOffGameStatShelfItems() { getOffGameStatShelf()->delAllItems(); }
DefGameStatObjectShelf* getDefGameStatShelf()
{ return(dynamic_cast<DefGameStatObjectShelf*>(getShelfByKey(
getDefGameStatShelfKey(),gsm_MustExist))); }
void addDefGameStatShelf();
void delDefGameStatShelf() { delShelf(getDefGameStatShelfKey()); }
void delAllDefGameStatShelfItems() { getDefGameStatShelf()->delAllItems(); }
void addDraftRankingShelf();
void delDraftRankingShelf() { delShelf(getDraftRankingShelfKey()); }
void addDraftPosCountShelf();
void delDraftPosCountShelf() { delShelf(getDraftPosCountShelfKey()); }
ScheduleDayObjectShelf* getScheduleDayShelf()
{ return(dynamic_cast<ScheduleDayObjectShelf*>(getShelfByKey(
getScheduleDayShelfKey(),gsm_MustExist))); }
void addScheduleDayShelf();
void delScheduleDayShelf() { delShelf(getScheduleDayShelfKey()); }
void saveAndDelAllScheduleDayShelfItems();
/**************************************************************************/
// Team Retrieval Functions
void addTeam(TTeamPtr teamPtr);
TTeamPtr getTeam(TTeamID teamID,GetItemMode getItemMode = gim_LoadOnCall);
void delTeam(TTeamID teamID);
TTeamPtr newTeam();
void saveTeam(TTeamID teamID);
// ProfPlayer Retrieval Functions
void addProfPlayer(TProfPlayerPtr profPlayerPtr);
TProfPlayerPtr getProfPlayer(TPlayerID playerID,
GetItemMode getItemMode = gim_MustExist);
void saveProfPlayer(TPlayerID playerID);
// ProfTeam Retrieval Functions
void addProfTeam(TProfTeamPtr profTeamPtr);
TProfTeamPtr getProfTeam(TProfTeamID profTeamID,
GetItemMode getItemMode = gim_MustExist);
TProfTeamPtr getProfTeamAbbr(TProfTeamAbbr profTeamAbbr,
GetItemMode getItemMode = gim_MustExist);
// Player Retrieval Functions
void addPlayer(TPlayerPtr playerPtr);
TPlayerPtr getPlayer(TLeagueID leagueID,TPlayerID playerID,
GetItemMode getItemMode = gim_MustExist);
TPlayerPtr newPlayer(TLeagueID leagueID,TPlayerID playerID);
// OffGameStat Retrieval Functions
void addOffGameStat(TOffGameStatPtr offGameStatPtr);
// DefGameStat Retrieval Functions
void addDefGameStat(TDefGameStatPtr defGameStatPtr);
// DraftRanking Retrieval Functions
void addDraftRanking(TDraftRankingPtr draftRankingPtr);
TDraftRankingPtr getDraftRanking(TTeamID teamID,
GetItemMode getItemMode = gim_MustExist);
TDraftRankingPtr getDefaultDraftRanking(GetItemMode getItemMode = gim_MustExist)
{ return(getDraftRanking(DefaultDraftRankingTeamID,getItemMode)); }
// DraftPosCount Retrieval Functions
void storeDraftPosCount(TDraftPosCount& draftPosCount);
TDraftPosCount getDraftPosCount(TDraftPosCountKey draftPosCountKey);
// ScheduleDay Retrieval Functions
void addScheduleDay(TScheduleDayPtr scheduleDayPtr);
/**************************************************************************/
// Utility Methods
void loadTeamsForLeague(TLeagueID leagueID);
void loadProfPlayersByPositionGameStatus(const TPositionVector& posVector,
const TProfPlayerGameStatus gameStatus);
void loadKeyProfPlayers();
void loadAllProfPlayers();
void loadAllProfTeams();
void loadPlayersForLeague(TLeagueID leagueID);
void loadOffGameStatVectorByWhereStr(const char* whereStr);
void loadOffGameStatVectorByDatePeriod(TDateTime fromStatDate,
TDateTime toStatDate,TStatPeriod statPeriod);
void loadDefGameStatVectorByWhereStr(const char* whereStr);
void loadDefGameStatVectorByDatePeriod(TDateTime fromStatDate,
TDateTime toStatDate,TStatPeriod statPeriod);
void loadDraftRankingsForLeague(TLeagueID leagueID);
void createDraftPosCountsForTeamIDVector(
const TTeamIDVector& teamIDVector,const TPositionVector& posVector);
void getTeamIDVector(TTeamIDVector& teamIDVector)
{ getTeamShelf()->getItemKeyVector(teamIDVector); }
void getTeamVector(TTeamVector& teamVector)
{ getTeamShelf()->getItemVector(teamVector); }
void getProfPlayerIDVector(TPlayerIDVector& playerIDVector)
{ getProfPlayerShelf()->getItemKeyVector(playerIDVector); }
void getProfPlayerIDVectorByNewPlayerDateRange(TDateTime fromDate,
TDateTime toDate,TPlayerIDVector& playerIDVector)
{ getProfPlayerShelf()->getIDVectorByNewPlayerDateRange(fromDate,toDate,
playerIDVector); }
void getProfPlayerVector(TProfPlayerVector& profPlayerVector)
{ getProfPlayerShelf()->getItemVector(profPlayerVector); }
void getPlayerIDVector(TLeaguePlayerIDVector& leaguePlayerIDVector)
{ getPlayerShelf()->getItemKeyVector(leaguePlayerIDVector); }
void getPlayerVector(TPlayerVector& playerVector)
{ getPlayerShelf()->getItemVector(playerVector); }
void getTeamPlayerIDVectorByTeam(TTeamID teamID,TPlayerIDVector& playerIDVector)
{ getPlayerShelf()->getTeamPlayerIDVectorByTeam(teamID,playerIDVector); }
void getOffGameStatVectorByPlayerIDVector(TPlayerIDVector& playerIDVector,
TOffGameStatVector& offGameStatVector)
{ getOffGameStatShelf()->getVectorByPlayerIDVector(playerIDVector,offGameStatVector); }
void getOffGameStatVectorRandomByPlayerIDVector(TPlayerIDVector& playerIDVector,
TOffGameStatVector& offGameStatVector)
{ getOffGameStatShelf()->getVectorRandomByPlayerIDVector(playerIDVector,offGameStatVector); }
void getDefGameStatVectorByPlayerIDVector(TPlayerIDVector& playerIDVector,
TDefGameStatVector& defGameStatVector)
{ getDefGameStatShelf()->getVectorByPlayerIDVector(playerIDVector,defGameStatVector); }
void getDefGameStatVectorRandomByPlayerIDVector(TPlayerIDVector& playerIDVector,
TDefGameStatVector& defGameStatVector)
{ getDefGameStatShelf()->getVectorRandomByPlayerIDVector(playerIDVector,defGameStatVector); }
bool isPlayerIDVectorValidForProfPlayers(const TPlayerIDVector& playerIDVector,
bool undefinedIDsAllowed = false);
void loadScheduleDayVectorByLeagueID(TLeagueID leagueID);
void getScheduleDayVector(TScheduleDayVector& scheduleDayVector)
{ getScheduleDayShelf()->getItemVector(scheduleDayVector); }
};
/******************************************************************************/
}; //namespace asfantasy
#endif //ASFantasyObjectStoreH
/******************************************************************************/
/******************************************************************************/
| [
"[email protected]"
]
| [
[
[
1,
233
]
]
]
|
73ae9b04bf573ff7e24128ede2c889811699c8c0 | d425cf21f2066a0cce2d6e804bf3efbf6dd00c00 | /Tactical/Faces.cpp | 2e9f44276d336f24966fb8a253698cfd5aac993b | []
| no_license | infernuslord/ja2 | d5ac783931044e9b9311fc61629eb671f376d064 | 91f88d470e48e60ebfdb584c23cc9814f620ccee | refs/heads/master | 2021-01-02T23:07:58.941216 | 2011-10-18T09:22:53 | 2011-10-18T09:22:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 84,605 | cpp | #ifdef PRECOMPILEDHEADERS
#include "Tactical All.h"
#else
#include "builddefines.h"
#include "math.h"
#include <stdio.h>
#include <errno.h>
#include "worlddef.h"
#include "renderworld.h"
#include "vsurface.h"
#include "Render Dirty.h"
#include "sysutil.h"
#include "container.h"
#include "wcheck.h"
#include "video.h"
#include "vobject_blitters.h"
#include "faces.h"
#include "utilities.h"
#include "overhead.h"
#include "gap.h"
#include "Soldier Profile.h"
#include "Sound Control.h"
#include "teamturns.h"
#include "soldier macros.h"
#include "dialogue control.h"
#include "font control.h"
#include "Assignments.h"
#include "Random.h"
#include "line.h"
#include "GameSettings.h"
#include "squads.h"
#include "interface.h"
#include "Quests.h"
#include "animation control.h"
#include "drugs and alcohol.h"
#include "Interface Items.h"
#include "meanwhile.h"
#include "Map Screen Interface.h"
// HEADROCK HAM 3.2: Added two includes so that a function can read values of the Gun Range/hospital location
#include "Campaign Types.h"
#include "Strategic Event Handler.h"
#endif
// Defines
#define NUM_FACE_SLOTS 50
#define END_FACE_OVERLAY_DELAY 2000
// GLOBAL FOR FACES LISTING
FACETYPE gFacesData[ NUM_FACE_SLOTS ];
UINT32 guiNumFaces = 0;
// LOCAL FUNCTIONS
void NewEye( FACETYPE *pFace );
void NewMouth( FACETYPE *pFace );
INT32 GetFreeFace(void);
void RecountFaces(void);
void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLEAN fUseExternBuffer, UINT32 uiBuffer, INT16 sFaceX, INT16 sFaceY, UINT16 usEyesX, UINT16 usEyesY );
extern BOOLEAN gfInItemPickupMenu;
RPC_SMALL_FACE_VALUES gRPCSmallFaceValues[200];
UINT8 ubRPCNumSmallFaceValues = 200;
CAMO_FACE gCamoFace[255];
FACE_GEAR_VALUES zNewFaceGear[MAXITEMS];
FACE_GEAR_VALUES zNewFaceGearIMP[MAXITEMS];
extern BOOLEAN gfSMDisableForItems;
extern INT16 gsCurInterfacePanel;
extern UINT16 gusSMCurrentMerc;
extern BOOLEAN gfRerenderInterfaceFromHelpText;
extern BOOLEAN gfInItemPickupMenu;
BOOLEAN FaceRestoreSavedBackgroundRect( INT32 iFaceIndex, INT16 sDestLeft, INT16 sDestTop, INT16 sSrcLeft, INT16 sSrcTop, INT16 sWidth, INT16 sHeight );
void SetupFinalTalkingDelay( FACETYPE *pFace );
INT32 GetFreeFace(void)
{
UINT32 uiCount;
for(uiCount=0; uiCount < guiNumFaces; uiCount++)
{
if((gFacesData[uiCount].fAllocated==FALSE) )
return((INT32)uiCount);
}
if(guiNumFaces < NUM_FACE_SLOTS )
return((INT32)guiNumFaces++);
return(-1);
}
void RecountFaces(void)
{
INT32 uiCount;
for(uiCount=guiNumFaces-1; (uiCount >=0) ; uiCount--)
{
if( ( gFacesData[uiCount].fAllocated ) )
{
guiNumFaces=(UINT32)(uiCount+1);
break;
}
}
}
INT32 InitSoldierFace( SOLDIERTYPE *pSoldier )
{
INT32 iFaceIndex;
// Check if we have a face init already
iFaceIndex = pSoldier->iFaceIndex;
if ( iFaceIndex != -1 )
{
return( iFaceIndex );
}
return( InitFace( pSoldier->ubProfile, pSoldier->ubID, 0) );
}
INT32 InitFace( UINT8 usMercProfileID, UINT8 ubSoldierID, UINT32 uiInitFlags )
{
UINT32 uiBlinkFrequency;
UINT32 uiExpressionFrequency;
if ( usMercProfileID == NO_PROFILE )
{
return( -1 );
}
uiBlinkFrequency = gMercProfiles[ usMercProfileID ].uiBlinkFrequency;
uiExpressionFrequency = gMercProfiles[ usMercProfileID ].uiExpressionFrequency;
if ( Random( 2 ) )
{
uiBlinkFrequency += Random( 2000 );
}
else
{
uiBlinkFrequency -= Random( 2000 );
}
return( InternalInitFace( usMercProfileID, ubSoldierID, uiInitFlags, gMercProfiles[ usMercProfileID ].ubFaceIndex, uiBlinkFrequency, uiExpressionFrequency ) );
}
INT32 InternalInitFace( UINT8 usMercProfileID, UINT8 ubSoldierID, UINT32 uiInitFlags, INT32 iFaceFileID, UINT32 uiBlinkFrequency, UINT32 uiExpressionFrequency )
{
FACETYPE *pFace;
VOBJECT_DESC VObjectDesc;
UINT32 uiVideoObject;
INT32 iFaceIndex;
ETRLEObject ETRLEObject;
HVOBJECT hVObject;
UINT32 uiCount;
SGPPaletteEntry Pal[256];
if( ( iFaceIndex = GetFreeFace() )==(-1) )
return(-1);
// Load face file
VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE;
// ATE: If we are merc profile ID #151-154, all use 151's protrait....
if ( usMercProfileID >= 151 && usMercProfileID <= 154 )
{
iFaceFileID = 151;
}
// Check if we are a big-face....
if ( uiInitFlags & FACE_BIGFACE )
{
// The filename is the profile ID!
if( iFaceFileID < 100 )
{
sprintf( VObjectDesc.ImageFile, "FACES\\b%02d.sti", iFaceFileID );
}
else
{
sprintf( VObjectDesc.ImageFile, "FACES\\b%03d.sti", iFaceFileID );
}
// ATE: Check for profile - if elliot , use special face :)
if ( usMercProfileID == ELLIOT )
{
if ( gMercProfiles[ ELLIOT ].bNPCData > 3 && gMercProfiles[ ELLIOT ].bNPCData < 7 )
{
sprintf( VObjectDesc.ImageFile, "FACES\\b%02da.sti", iFaceFileID );
}
else if ( gMercProfiles[ ELLIOT ].bNPCData > 6 && gMercProfiles[ ELLIOT ].bNPCData < 10 )
{
sprintf( VObjectDesc.ImageFile, "FACES\\b%02db.sti", iFaceFileID );
}
else if ( gMercProfiles[ ELLIOT ].bNPCData > 9 && gMercProfiles[ ELLIOT ].bNPCData < 13 )
{
sprintf( VObjectDesc.ImageFile, "FACES\\b%02dc.sti", iFaceFileID );
}
else if ( gMercProfiles[ ELLIOT ].bNPCData > 12 && gMercProfiles[ ELLIOT ].bNPCData < 16 )
{
sprintf( VObjectDesc.ImageFile, "FACES\\b%02dd.sti", iFaceFileID );
}
else if ( gMercProfiles[ ELLIOT ].bNPCData == 17 )
{
sprintf( VObjectDesc.ImageFile, "FACES\\b%02de.sti", iFaceFileID );
}
}
#ifdef JA2UB
else if ( usMercProfileID == 64 )
{
// SANDRO - old/new traits check (I am not sure if this is used at all)
if ( gGameOptions.fNewTraitSystem )
{
if ( ProfileHasSkillTrait( 64, RANGER_NT ) > 0 )
{
sprintf( VObjectDesc.ImageFile, "FACES\\B64c.sti" );
}
}
else
{
if ( ProfileHasSkillTrait( 64, CAMOUFLAGED_OT ) > 0 )
{
sprintf( VObjectDesc.ImageFile, "FACES\\B64c.sti" );
}
}
}
#else
else if ( usMercProfileID == TEX )
{
// SANDRO - old/new traits check (I am not sure if this is used at all)
if ( gGameOptions.fNewTraitSystem )
{
if ( ProfileHasSkillTrait( TEX, RANGER_NT ) > 0 )
{
sprintf( VObjectDesc.ImageFile, "FACES\\B167c.sti" );
}
}
else
{
if ( ProfileHasSkillTrait( TEX, CAMOUFLAGED_OT ) > 0 )
{
sprintf( VObjectDesc.ImageFile, "FACES\\B167c.sti" );
}
}
}
#endif
}
else
{
if (gGameExternalOptions.fShowCamouflageFaces == TRUE )
{
if( iFaceFileID < 100 )
{
// The filename is the profile ID!
sprintf( VObjectDesc.ImageFile, "FACES\\%02d.sti", iFaceFileID );
if ( gCamoFace[usMercProfileID].gCamoface == TRUE )
{
sprintf( VObjectDesc.ImageFile, "FACES\\WoodCamo\\%02d.sti", iFaceFileID );
}
else if ( gCamoFace[usMercProfileID].gUrbanCamoface == TRUE )
{
sprintf( VObjectDesc.ImageFile, "FACES\\UrbanCamo\\%02d.sti", iFaceFileID );
}
else if ( gCamoFace[usMercProfileID].gDesertCamoface == TRUE )
{
sprintf( VObjectDesc.ImageFile, "FACES\\DesertCamo\\%02d.sti", iFaceFileID );
}
else if ( gCamoFace[usMercProfileID].gSnowCamoface == TRUE )
{
sprintf( VObjectDesc.ImageFile, "FACES\\SnowCamo\\%02d.sti", iFaceFileID );
}
if (!FileExists(VObjectDesc.ImageFile))
sprintf( VObjectDesc.ImageFile, "FACES\\%02d.sti", iFaceFileID );
}
else
{
sprintf( VObjectDesc.ImageFile, "FACES\\%03d.sti", iFaceFileID );
if ( gCamoFace[usMercProfileID].gCamoface == TRUE )
{
sprintf( VObjectDesc.ImageFile, "FACES\\Woodcamo\\%03d.sti", iFaceFileID );
}
else if ( gCamoFace[usMercProfileID].gUrbanCamoface == TRUE )
{
sprintf( VObjectDesc.ImageFile, "FACES\\UrbanCamo\\%03d.sti", iFaceFileID );
}
else if ( gCamoFace[usMercProfileID].gDesertCamoface == TRUE )
{
sprintf( VObjectDesc.ImageFile, "FACES\\DesertCamo\\%03d.sti", iFaceFileID );
}
else if ( gCamoFace[usMercProfileID].gSnowCamoface == TRUE )
{
sprintf( VObjectDesc.ImageFile, "FACES\\SnowCamo\\%03d.sti", iFaceFileID );
}
if (!FileExists(VObjectDesc.ImageFile))
sprintf( VObjectDesc.ImageFile, "FACES\\%03d.sti", iFaceFileID );
}
}
else if (gGameExternalOptions.fShowCamouflageFaces == FALSE )
{
if( iFaceFileID < 100 )
{
// The filename is the profile ID!
sprintf( VObjectDesc.ImageFile, "FACES\\%02d.sti", iFaceFileID );
}
else
{
sprintf( VObjectDesc.ImageFile, "FACES\\%03d.sti", iFaceFileID );
}
}
}
// Load
if( AddVideoObject( &VObjectDesc, &uiVideoObject ) == FALSE )
{
// If we are a big face, use placeholder...
if ( uiInitFlags & FACE_BIGFACE )
{
sprintf( VObjectDesc.ImageFile, "FACES\\placeholder.sti" );
if( AddVideoObject( &VObjectDesc, &uiVideoObject ) == FALSE )
{
return( -1 );
}
}
else
{
return( -1 );
}
}
memset(&gFacesData[ iFaceIndex ], 0, sizeof( FACETYPE ) );
pFace = &gFacesData[ iFaceIndex ];
// Get profile data and set into face data
pFace->ubSoldierID = ubSoldierID;
pFace->iID = iFaceIndex;
pFace->fAllocated = TRUE;
//Default to off!
pFace->fDisabled = TRUE;
pFace->iVideoOverlay = -1;
//pFace->uiEyeDelay = gMercProfiles[ usMercProfileID ].uiEyeDelay;
//pFace->uiMouthDelay = gMercProfiles[ usMercProfileID ].uiMouthDelay;
pFace->uiEyeDelay = 50 + Random( 30 );
pFace->uiMouthDelay = 120;
pFace->ubCharacterNum = usMercProfileID;
pFace->uiBlinkFrequency = uiBlinkFrequency;
pFace->uiExpressionFrequency = uiExpressionFrequency;
pFace->sEyeFrame = 0;
pFace->sMouthFrame = 0;
pFace->uiFlags = uiInitFlags;
// Set palette
if( GetVideoObject( &hVObject, uiVideoObject ) )
{
// Build a grayscale palette! ( for testing different looks )
for(uiCount=0; uiCount < 256; uiCount++)
{
Pal[uiCount].peRed=255;
Pal[uiCount].peGreen=255;
Pal[uiCount].peBlue=255;
}
hVObject->pShades[ FLASH_PORTRAIT_NOSHADE ] = Create16BPPPaletteShaded( hVObject->pPaletteEntry, 255, 255, 255, FALSE );
hVObject->pShades[ FLASH_PORTRAIT_STARTSHADE ] = Create16BPPPaletteShaded( Pal, 255, 255, 255, FALSE );
hVObject->pShades[ FLASH_PORTRAIT_ENDSHADE ] = Create16BPPPaletteShaded( hVObject->pPaletteEntry, 250, 25, 25, TRUE );
hVObject->pShades[ FLASH_PORTRAIT_DARKSHADE ] = Create16BPPPaletteShaded( hVObject->pPaletteEntry, 100, 100, 100, TRUE );
hVObject->pShades[ FLASH_PORTRAIT_LITESHADE ] = Create16BPPPaletteShaded( hVObject->pPaletteEntry, 100, 100, 100, FALSE );
for(uiCount=0; uiCount < 256; uiCount++)
{
Pal[uiCount].peRed=(UINT8)(uiCount%128)+128;
Pal[uiCount].peGreen=(UINT8)(uiCount%128)+128;
Pal[uiCount].peBlue=(UINT8)(uiCount%128)+128;
}
hVObject->pShades[ FLASH_PORTRAIT_GRAYSHADE ] = Create16BPPPaletteShaded( Pal, 255, 255, 255, FALSE );
}
// Get FACE height, width
if( GetVideoObjectETRLEPropertiesFromIndex( uiVideoObject, &ETRLEObject, 0 ) == FALSE )
{
return( -1 );
}
pFace->usFaceWidth = ETRLEObject.usWidth;
pFace->usFaceHeight = ETRLEObject.usHeight;
// OK, check # of items
if ( hVObject->usNumberOfObjects == 8 )
{
pFace->fInvalidAnim = FALSE;
// Get EYE height, width
if( GetVideoObjectETRLEPropertiesFromIndex( uiVideoObject, &ETRLEObject, 1 ) == FALSE )
{
return( -1 );
}
pFace->usEyesWidth = ETRLEObject.usWidth;
pFace->usEyesHeight = ETRLEObject.usHeight;
// Get Mouth height, width
if( GetVideoObjectETRLEPropertiesFromIndex( uiVideoObject, &ETRLEObject, 5 ) == FALSE )
{
return( -1 );
}
pFace->usMouthWidth = ETRLEObject.usWidth;
pFace->usMouthHeight = ETRLEObject.usHeight;
}
else
{
pFace->fInvalidAnim = TRUE;
}
// Set id
pFace->uiVideoObject = uiVideoObject;
return( iFaceIndex );
}
void DeleteSoldierFace( SOLDIERTYPE *pSoldier )
{
DeleteFace( pSoldier->iFaceIndex );
pSoldier->iFaceIndex = -1;
}
void DeleteFace( INT32 iFaceIndex )
{
FACETYPE *pFace;
// Check face index
CHECKV( iFaceIndex != -1 );
pFace = &gFacesData[ iFaceIndex ];
// Check for a valid slot!
CHECKV( pFace->fAllocated != FALSE );
pFace->fCanHandleInactiveNow = TRUE;
if ( !pFace->fDisabled )
{
SetAutoFaceInActive( iFaceIndex );
}
// If we are still talking, stop!
if ( pFace->fTalking )
{
// Call dialogue handler function
pFace->fTalking = FALSE;
HandleDialogueEnd( pFace );
}
// Delete vo
DeleteVideoObjectFromIndex( pFace->uiVideoObject );
// Set uncallocated
pFace->fAllocated = FALSE;
RecountFaces( );
}
void SetAutoFaceActiveFromSoldier( UINT32 uiDisplayBuffer, UINT32 uiRestoreBuffer, UINT8 ubSoldierID , UINT16 usFaceX, UINT16 usFaceY )
{
if( ubSoldierID == NOBODY )
{
return;
}
SetAutoFaceActive( uiDisplayBuffer, uiRestoreBuffer, MercPtrs[ ubSoldierID ]->iFaceIndex, usFaceX, usFaceY );
}
void GetFaceRelativeCoordinates( FACETYPE *pFace, UINT16 *pusEyesX, UINT16 *pusEyesY, UINT16 *pusMouthX, UINT16 *pusMouthY )
{
UINT16 usMercProfileID;
UINT16 usEyesX;
UINT16 usEyesY;
UINT16 usMouthX;
UINT16 usMouthY;
INT32 cnt;
usMercProfileID = pFace->ubCharacterNum;
//Take eyes x,y from profile unless we are an RPC and we are small faced.....
usEyesX = gMercProfiles[ usMercProfileID ].usEyesX;
usEyesY = gMercProfiles[ usMercProfileID ].usEyesY;
usMouthY = gMercProfiles[ usMercProfileID ].usMouthY;
usMouthX = gMercProfiles[ usMercProfileID ].usMouthX;
#ifdef JA2UB
if ( gGameOptions.fNewTraitSystem )
{
if( usMercProfileID == 64 && ( gMercProfiles[ 64 ].bSkillTraits[0] == RANGER_NT || gMercProfiles[ 64 ].bSkillTraits[1] == RANGER_NT ) )
{
usEyesX = 13;
usEyesY = 34;
usMouthX = 13;
usMouthY = 55;
}
}
else
{
if( usMercProfileID == 64 && ( gMercProfiles[ 64 ].bSkillTraits[0] == CAMOUFLAGED_OT || gMercProfiles[ 64 ].bSkillTraits[1] == CAMOUFLAGED_OT ) )
{
usEyesX = 13;
usEyesY = 34;
usMouthX = 13;
usMouthY = 55;
}
}
#endif
// Use some other values for x,y, base on if we are a RPC!
if ( !( pFace->uiFlags & FACE_BIGFACE ) ||( pFace->uiFlags & FACE_FORCE_SMALL ))
{
// Loop through all values of availible merc IDs to find ours!
for ( cnt = 0; cnt < ubRPCNumSmallFaceValues; cnt++ )
{
// We've found one!
if (gRPCSmallFaceValues[ cnt ].FaceIndex == usMercProfileID &&
gRPCSmallFaceValues[ cnt ].uiIndex != 65535)
{
usEyesX = gRPCSmallFaceValues[ cnt ].bEyesX;
usEyesY = gRPCSmallFaceValues[ cnt ].bEyesY;
usMouthY = gRPCSmallFaceValues[ cnt ].bMouthY;
usMouthX = gRPCSmallFaceValues[ cnt ].bMouthX;
}
}
}
(*pusEyesX) = usEyesX;
(*pusEyesY) = usEyesY;
(*pusMouthX) = usMouthX;
(*pusMouthY) = usMouthY;
}
void SetAutoFaceActive( UINT32 uiDisplayBuffer, UINT32 uiRestoreBuffer, INT32 iFaceIndex , UINT16 usFaceX, UINT16 usFaceY )
{
UINT16 usEyesX;
UINT16 usEyesY;
UINT16 usMouthX;
UINT16 usMouthY;
FACETYPE *pFace;
// Check face index
CHECKV( iFaceIndex != -1 );
pFace = &gFacesData[ iFaceIndex ];
GetFaceRelativeCoordinates( pFace, &usEyesX, &usEyesY, &usMouthX, &usMouthY );
InternalSetAutoFaceActive( uiDisplayBuffer, uiRestoreBuffer, iFaceIndex , usFaceX, usFaceY, usEyesX, usEyesY, usMouthX, usMouthY );
}
void InternalSetAutoFaceActive( UINT32 uiDisplayBuffer, UINT32 uiRestoreBuffer, INT32 iFaceIndex , UINT16 usFaceX, UINT16 usFaceY, UINT16 usEyesX, UINT16 usEyesY, UINT16 usMouthX, UINT16 usMouthY )
{
UINT16 usMercProfileID;
FACETYPE *pFace;
VSURFACE_DESC vs_desc;
UINT16 usWidth;
UINT16 usHeight;
UINT8 ubBitDepth;
// Check face index
CHECKV( iFaceIndex != -1 );
pFace = &gFacesData[ iFaceIndex ];
// IF we are already being contained elsewhere, return without doing anything!
// ATE: Don't allow another activity from setting active....
if ( pFace->uiFlags & FACE_INACTIVE_HANDLED_ELSEWHERE )
{
return;
}
// Check if we are active already, remove if so!
if ( pFace->fDisabled )
{
SetAutoFaceInActive( iFaceIndex );
}
if ( uiRestoreBuffer == FACE_AUTO_RESTORE_BUFFER )
{
// BUILD A BUFFER
GetCurrentVideoSettings( &usWidth, &usHeight, &ubBitDepth );
// OK, ignore screen widths, height, only use BPP
vs_desc.fCreateFlags = VSURFACE_CREATE_DEFAULT | VSURFACE_SYSTEM_MEM_USAGE;
vs_desc.usWidth = pFace->usFaceWidth;
vs_desc.usHeight = pFace->usFaceHeight;
vs_desc.ubBitDepth = ubBitDepth;
pFace->fAutoRestoreBuffer = TRUE;
CHECKV( AddVideoSurface( &vs_desc, &(pFace->uiAutoRestoreBuffer) ) );
}
else
{
pFace->fAutoRestoreBuffer = FALSE;
pFace->uiAutoRestoreBuffer = uiRestoreBuffer;
}
if ( uiDisplayBuffer == FACE_AUTO_DISPLAY_BUFFER )
{
// BUILD A BUFFER
GetCurrentVideoSettings( &usWidth, &usHeight, &ubBitDepth );
// OK, ignore screen widths, height, only use BPP
vs_desc.fCreateFlags = VSURFACE_CREATE_DEFAULT | VSURFACE_SYSTEM_MEM_USAGE;
vs_desc.usWidth = pFace->usFaceWidth;
vs_desc.usHeight = pFace->usFaceHeight;
vs_desc.ubBitDepth = ubBitDepth;
pFace->fAutoDisplayBuffer = TRUE;
CHECKV( AddVideoSurface( &vs_desc, &(pFace->uiAutoDisplayBuffer) ) );
}
else
{
pFace->fAutoDisplayBuffer = FALSE;
pFace->uiAutoDisplayBuffer = uiDisplayBuffer;
}
usMercProfileID = pFace->ubCharacterNum;
pFace->usFaceX = usFaceX;
pFace->usFaceY = usFaceY;
pFace->fCanHandleInactiveNow = FALSE;
//Take eyes x,y from profile unless we are an RPC and we are small faced.....
pFace->usEyesX = usEyesX + usFaceX;
pFace->usEyesY = usEyesY + usFaceY;
pFace->usMouthY = usMouthY + usFaceY;
pFace->usMouthX = usMouthX + usFaceX;
// Save offset values
pFace->usEyesOffsetX = usEyesX;
pFace->usEyesOffsetY = usEyesY;
pFace->usMouthOffsetY = usMouthY;
pFace->usMouthOffsetX = usMouthX;
if ( pFace->usEyesY == usFaceY || pFace->usMouthY == usFaceY )
{
pFace->fInvalidAnim = TRUE;
}
pFace->fDisabled = FALSE;
pFace->uiLastBlink = GetJA2Clock();
pFace->uiLastExpression = GetJA2Clock();
pFace->uiEyelast = GetJA2Clock();
pFace->fStartFrame = TRUE;
// Are we a soldier?
if ( pFace->ubSoldierID != NOBODY )
{
pFace->bOldSoldierLife = MercPtrs[ pFace->ubSoldierID ]->stats.bLife;
}
}
void SetAutoFaceInActiveFromSoldier( UINT8 ubSoldierID )
{
// Check for valid soldier
CHECKV( ubSoldierID != NOBODY );
SetAutoFaceInActive( MercPtrs[ ubSoldierID ]->iFaceIndex );
}
void SetAutoFaceInActive(INT32 iFaceIndex )
{
FACETYPE *pFace;
SOLDIERTYPE *pSoldier;
// Check face index
CHECKV( iFaceIndex != -1 );
pFace = &gFacesData[ iFaceIndex ];
// Check for a valid slot!
CHECKV( pFace->fAllocated != FALSE );
// Turn off some flags
if ( pFace->uiFlags & FACE_INACTIVE_HANDLED_ELSEWHERE )
{
if ( !pFace->fCanHandleInactiveNow )
{
return;
}
}
if ( pFace->uiFlags & FACE_MAKEACTIVE_ONCE_DONE )
{
//
if ( pFace->ubSoldierID != NOBODY )
{
pSoldier = MercPtrs[ pFace->ubSoldierID ];
// IF we are in tactical
if ( pSoldier->bAssignment == iCurrentTacticalSquad && guiCurrentScreen == GAME_SCREEN )
{
// Make the interfac panel dirty..
// This will dirty the panel next frame...
gfRerenderInterfaceFromHelpText = TRUE;
}
}
}
if ( pFace->fAutoRestoreBuffer )
{
DeleteVideoSurfaceFromIndex( pFace->uiAutoRestoreBuffer );
}
if ( pFace->fAutoDisplayBuffer )
{
DeleteVideoSurfaceFromIndex( pFace->uiAutoDisplayBuffer );
}
if ( pFace->iVideoOverlay != -1 )
{
RemoveVideoOverlay( pFace->iVideoOverlay );
pFace->iVideoOverlay = -1;
}
// Turn off some flags
pFace->uiFlags &= ( ~FACE_INACTIVE_HANDLED_ELSEWHERE );
// Disable!
pFace->fDisabled = TRUE;
}
BOOLEAN SetCamoFace(SOLDIERTYPE * pSoldier)
{
INT8 worn = -1;
INT8 applied = -1;
INT16 wornCamo[4];
INT16 appliedCamo[4];
//reset gCamoFace
gCamoFace[pSoldier->ubProfile].gCamoface = FALSE;
gCamoFace[pSoldier->ubProfile].gUrbanCamoface = FALSE;
gCamoFace[pSoldier->ubProfile].gDesertCamoface = FALSE;
gCamoFace[pSoldier->ubProfile].gSnowCamoface = FALSE;
appliedCamo[0] = pSoldier->bCamo;
appliedCamo[1] = pSoldier->urbanCamo;
appliedCamo[2] = pSoldier->desertCamo;
appliedCamo[3] = pSoldier->snowCamo;
wornCamo[0] = pSoldier->wornCamo;
wornCamo[1] = pSoldier->wornUrbanCamo;
wornCamo[2] = pSoldier->wornDesertCamo;
wornCamo[3] = pSoldier->wornSnowCamo;
for(INT8 loop = 0; loop < 4; loop ++)
{
if(wornCamo[loop] > 50)
worn = loop;
if(appliedCamo[loop] > 50)
applied = loop;
}
BOOLEAN isCamoFace = FALSE;
if(applied != -1 && worn != -1)
{
isCamoFace = TRUE;
if(appliedCamo[applied] >= wornCamo[worn])
{
if(applied == 0)
gCamoFace[pSoldier->ubProfile].gCamoface = TRUE;
if(applied == 1)
gCamoFace[pSoldier->ubProfile].gUrbanCamoface = TRUE;
if(applied == 2)
gCamoFace[pSoldier->ubProfile].gDesertCamoface = TRUE;
if(applied == 3)
gCamoFace[pSoldier->ubProfile].gSnowCamoface = TRUE;
return TRUE;
}
else
{
isCamoFace = TRUE;
if(worn == 0)
gCamoFace[pSoldier->ubProfile].gCamoface = TRUE;
if(worn == 1)
gCamoFace[pSoldier->ubProfile].gUrbanCamoface = TRUE;
if(worn == 2)
gCamoFace[pSoldier->ubProfile].gDesertCamoface = TRUE;
if(worn == 3)
gCamoFace[pSoldier->ubProfile].gSnowCamoface = TRUE;
}
}
else if(applied != -1 || worn != -1)
{
isCamoFace = TRUE;
if(applied == 0 || worn == 0)
gCamoFace[pSoldier->ubProfile].gCamoface = TRUE;
if(applied == 1 || worn == 1)
gCamoFace[pSoldier->ubProfile].gUrbanCamoface = TRUE;
if(applied == 2 || worn == 2)
gCamoFace[pSoldier->ubProfile].gDesertCamoface = TRUE;
if(applied == 3 || worn == 3)
gCamoFace[pSoldier->ubProfile].gSnowCamoface = TRUE;
}
return isCamoFace;
}
void SetAllAutoFacesInactive( )
{
UINT32 uiCount;
FACETYPE *pFace;
for ( uiCount = 0; uiCount < guiNumFaces; uiCount++ )
{
if ( gFacesData[ uiCount ].fAllocated )
{
pFace = &gFacesData[ uiCount ];
SetAutoFaceInActive( uiCount );
}
}
}
void BlinkAutoFace( INT32 iFaceIndex )
{
FACETYPE *pFace;
INT16 sFrame;
BOOLEAN fDoBlink = FALSE;
if ( gFacesData[ iFaceIndex ].fAllocated && !gFacesData[ iFaceIndex ].fDisabled && !gFacesData[ iFaceIndex ].fInvalidAnim )
{
pFace = &gFacesData[ iFaceIndex ];
// CHECK IF BUDDY IS DEAD, UNCONSCIOUS, ASLEEP, OR POW!
if ( pFace->ubSoldierID != NOBODY )
{
if ( ( MercPtrs[ pFace->ubSoldierID ]->stats.bLife < OKLIFE ) ||
( MercPtrs[ pFace->ubSoldierID ]->flags.fMercAsleep == TRUE ) ||
( MercPtrs[ pFace->ubSoldierID ]->bAssignment == ASSIGNMENT_POW ) )
{
return;
}
}
if ( pFace->ubExpression == NO_EXPRESSION )
{
// Get Delay time, if the first frame, use a different delay
if ( ( GetJA2Clock() - pFace->uiLastBlink ) > pFace->uiBlinkFrequency )
{
pFace->uiLastBlink = GetJA2Clock();
pFace->ubExpression = BLINKING;
pFace->uiEyelast = GetJA2Clock();
}
if ( pFace->fAnimatingTalking )
{
if ( ( GetJA2Clock() - pFace->uiLastExpression ) > pFace->uiExpressionFrequency )
{
pFace->uiLastExpression = GetJA2Clock();
if ( Random( 2 ) == 0 )
{
pFace->ubExpression = ANGRY;
}
else
{
pFace->ubExpression = SURPRISED;
}
}
}
}
if ( pFace->ubExpression != NO_EXPRESSION )
{
if ( pFace->fStartFrame )
{
if ( ( GetJA2Clock() - pFace->uiEyelast ) > pFace->uiEyeDelay ) //> Random( 10000 ) )
{
fDoBlink = TRUE;
pFace->fStartFrame = FALSE;
}
}
else
{
if ( ( GetJA2Clock() - pFace->uiEyelast ) > pFace->uiEyeDelay )
{
fDoBlink = TRUE;
}
}
// Are we going to blink?
if ( fDoBlink )
{
pFace->uiEyelast = GetJA2Clock();
// Adjust
NewEye( pFace );
sFrame = pFace->sEyeFrame;
if ( sFrame >= 5 )
{
sFrame = 4;
}
if ( sFrame > 0 )
{
// Blit Accordingly!
BltVideoObjectFromIndex( pFace->uiAutoDisplayBuffer, pFace->uiVideoObject, (INT16)( sFrame ), pFace->usEyesX, pFace->usEyesY, VO_BLT_SRCTRANSPARENCY, NULL );
if ( pFace->uiAutoDisplayBuffer == FRAME_BUFFER )
{
InvalidateRegion( pFace->usEyesX, pFace->usEyesY, pFace->usEyesX + pFace->usEyesWidth, pFace->usEyesY + pFace->usEyesHeight );
}
}
else
{
//RenderFace( uiDestBuffer , uiCount );
pFace->ubExpression = NO_EXPRESSION;
// Update rects just for eyes
if ( pFace->uiAutoRestoreBuffer == guiSAVEBUFFER )
{
FaceRestoreSavedBackgroundRect( iFaceIndex, pFace->usEyesX, pFace->usEyesY, pFace->usEyesX, pFace->usEyesY, pFace->usEyesWidth, pFace->usEyesHeight );
}
else
{
FaceRestoreSavedBackgroundRect( iFaceIndex, pFace->usEyesX, pFace->usEyesY, pFace->usEyesOffsetX, pFace->usEyesOffsetY, pFace->usEyesWidth, pFace->usEyesHeight );
}
}
HandleRenderFaceAdjustments( pFace, TRUE, FALSE, 0, pFace->usFaceX, pFace->usFaceY, pFace->usEyesX, pFace->usEyesY );
}
}
}
}
void HandleFaceHilights( FACETYPE *pFace, UINT32 uiBuffer, INT16 sFaceX, INT16 sFaceY )
{
UINT32 uiDestPitchBYTES;
UINT8 *pDestBuf;
UINT16 usLineColor;
INT32 iFaceIndex;
iFaceIndex = pFace->iID;
if ( !gFacesData[ iFaceIndex ].fDisabled )
{
if ( pFace->uiAutoDisplayBuffer == FRAME_BUFFER && guiCurrentScreen == GAME_SCREEN )
{
// If we are highlighted, do this now!
if ( ( pFace->uiFlags & FACE_SHOW_WHITE_HILIGHT ) )
{
// Lock buffer
pDestBuf = LockVideoSurface( uiBuffer, &uiDestPitchBYTES );
SetClippingRegionAndImageWidth( uiDestPitchBYTES, sFaceX-2, sFaceY-1, sFaceX + pFace->usFaceWidth + 4, sFaceY + pFace->usFaceHeight + 4 );
usLineColor = Get16BPPColor( FROMRGB( 255, 255, 255 ) );
RectangleDraw( TRUE, (sFaceX - 2 ), (sFaceY - 1),sFaceX + pFace->usFaceWidth + 1, sFaceY + pFace->usFaceHeight , usLineColor, pDestBuf );
SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
UnLockVideoSurface( uiBuffer );
}
else if ( ( pFace->uiFlags & FACE_SHOW_MOVING_HILIGHT ) )
{
if ( pFace->ubSoldierID != NOBODY )
{
if ( MercPtrs[ pFace->ubSoldierID ]->stats.bLife >= OKLIFE )
{
// Lock buffer
pDestBuf = LockVideoSurface( uiBuffer, &uiDestPitchBYTES );
SetClippingRegionAndImageWidth( uiDestPitchBYTES, sFaceX-2, sFaceY-1, sFaceX + pFace->usFaceWidth + 4, sFaceY + pFace->usFaceHeight + 4 );
if ( MercPtrs[ pFace->ubSoldierID ]->bStealthMode )
{
usLineColor = Get16BPPColor( FROMRGB( 158, 158, 12 ) );
}
else
{
usLineColor = Get16BPPColor( FROMRGB( 8, 12, 118 ) );
}
RectangleDraw( TRUE, (sFaceX - 2 ), (sFaceY - 1),sFaceX + pFace->usFaceWidth + 1, sFaceY + pFace->usFaceHeight , usLineColor, pDestBuf );
SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
UnLockVideoSurface( uiBuffer );
}
}
}
else
{
// ATE: Zero out any highlight boxzes....
// Lock buffer
pDestBuf = LockVideoSurface( pFace->uiAutoDisplayBuffer, &uiDestPitchBYTES );
SetClippingRegionAndImageWidth( uiDestPitchBYTES, pFace->usFaceX-2, pFace->usFaceY-1, pFace->usFaceX + pFace->usFaceWidth + 4, pFace->usFaceY + pFace->usFaceHeight + 4 );
usLineColor = Get16BPPColor( FROMRGB( 0, 0, 0 ) );
RectangleDraw( TRUE, (pFace->usFaceX - 2 ), (pFace->usFaceY - 1), pFace->usFaceX + pFace->usFaceWidth + 1, pFace->usFaceY + pFace->usFaceHeight , usLineColor, pDestBuf );
SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
UnLockVideoSurface( pFace->uiAutoDisplayBuffer );
}
}
}
if ( ( pFace->fCompatibleItems && !gFacesData[ iFaceIndex ].fDisabled ) )
{
// Lock buffer
pDestBuf = LockVideoSurface( uiBuffer, &uiDestPitchBYTES );
SetClippingRegionAndImageWidth( uiDestPitchBYTES, sFaceX-2, sFaceY-1, sFaceX + pFace->usFaceWidth+ 4, sFaceY + pFace->usFaceHeight + 4 );
usLineColor = Get16BPPColor( FROMRGB( 255, 0, 0 ) );
RectangleDraw( TRUE, (sFaceX - 2), (sFaceY - 1), sFaceX + pFace->usFaceWidth + 1, sFaceY + pFace->usFaceHeight , usLineColor, pDestBuf );
SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
UnLockVideoSurface( uiBuffer );
}
}
void MouthAutoFace( INT32 iFaceIndex )
{
FACETYPE *pFace;
INT16 sFrame;
if ( gFacesData[ iFaceIndex ].fAllocated )
{
pFace = &gFacesData[ iFaceIndex ];
// Remove video overlay is present....
if ( pFace->uiFlags & FACE_DESTROY_OVERLAY )
{
//if ( pFace->iVideoOverlay != -1 )
//{
// if ( pFace->uiStopOverlayTimer != 0 )
// {
// if ( ( GetJA2Clock( ) - pFace->uiStopOverlayTimer ) > END_FACE_OVERLAY_DELAY )
// {
// RemoveVideoOverlay( pFace->iVideoOverlay );
// pFace->iVideoOverlay = -1;
// }
// }
//}
}
if ( pFace->fTalking )
{
if ( !gFacesData[ iFaceIndex ].fDisabled && !gFacesData[ iFaceIndex ].fInvalidAnim )
{
if ( pFace->fAnimatingTalking )
{
PollAudioGap( pFace->uiSoundID, &(pFace->GapList ) );
// Check if we have an audio gap
if ( pFace->GapList.audio_gap_active )
{
pFace->sMouthFrame = 0;
if ( pFace->uiAutoRestoreBuffer == guiSAVEBUFFER )
{
FaceRestoreSavedBackgroundRect( iFaceIndex, pFace->usMouthX, pFace->usMouthY, pFace->usMouthX, pFace->usMouthY, pFace->usMouthWidth, pFace->usMouthHeight );
}
else
{
FaceRestoreSavedBackgroundRect( iFaceIndex, pFace->usMouthX, pFace->usMouthY, pFace->usMouthOffsetX, pFace->usMouthOffsetY, pFace->usMouthWidth, pFace->usMouthHeight );
}
}
else
{
// Get Delay time
if ( ( GetJA2Clock() - pFace->uiMouthlast ) > pFace->uiMouthDelay )
{
pFace->uiMouthlast = GetJA2Clock();
// Adjust
NewMouth( pFace );
sFrame = pFace->sMouthFrame;
if ( sFrame > 0 )
{
// Blit Accordingly!
BltVideoObjectFromIndex( pFace->uiAutoDisplayBuffer, pFace->uiVideoObject, (INT16)( sFrame + 4 ), pFace->usMouthX, pFace->usMouthY, VO_BLT_SRCTRANSPARENCY, NULL );
// Update rects
if ( pFace->uiAutoDisplayBuffer == FRAME_BUFFER )
{
InvalidateRegion( pFace->usMouthX, pFace->usMouthY, pFace->usMouthX + pFace->usMouthWidth, pFace->usMouthY + pFace->usMouthHeight );
}
}
else
{
//RenderFace( uiDestBuffer , uiCount );
//pFace->fTaking = FALSE;
// Update rects just for Mouth
if ( pFace->uiAutoRestoreBuffer == guiSAVEBUFFER )
{
FaceRestoreSavedBackgroundRect( iFaceIndex, pFace->usMouthX, pFace->usMouthY, pFace->usMouthX, pFace->usMouthY, pFace->usMouthWidth, pFace->usMouthHeight );
}
else
{
FaceRestoreSavedBackgroundRect( iFaceIndex, pFace->usMouthX, pFace->usMouthY, pFace->usMouthOffsetX, pFace->usMouthOffsetY, pFace->usMouthWidth, pFace->usMouthHeight );
}
}
HandleRenderFaceAdjustments( pFace, TRUE, FALSE, 0, pFace->usFaceX, pFace->usFaceY, pFace->usEyesX, pFace->usEyesY );
}
}
}
}
}
if ( !( pFace->uiFlags & FACE_INACTIVE_HANDLED_ELSEWHERE ) )
{
HandleFaceHilights( pFace, pFace->uiAutoDisplayBuffer, pFace->usFaceX, pFace->usFaceY );
}
}
}
void HandleTalkingAutoFace( INT32 iFaceIndex )
{
FACETYPE *pFace;
if ( gFacesData[ iFaceIndex ].fAllocated )
{
pFace = &gFacesData[ iFaceIndex ];
if ( pFace->fTalking )
{
// Check if we are done! ( Check this first! )
if ( pFace->fValidSpeech )
{
// Check if we have finished, set some flags for the final delay down if so!
if ( !SoundIsPlaying( pFace->uiSoundID ) && !pFace->fFinishTalking )
{
SetupFinalTalkingDelay( pFace );
}
}
else
{
// Check if our delay is over
if ( !pFace->fFinishTalking )
{
if ( ( GetJA2Clock() - pFace->uiTalkingTimer ) > pFace->uiTalkingDuration )
{
// If here, setup for last delay!
SetupFinalTalkingDelay( pFace );
}
}
}
// Now check for end of talking
if ( pFace->fFinishTalking )
{
if ( ( GetJA2Clock() - pFace->uiTalkingTimer ) > pFace->uiTalkingDuration )
{
pFace->fTalking = FALSE;
pFace->fAnimatingTalking = FALSE;
// Remove gap info
AudioGapListDone( &(pFace->GapList) );
// Remove video overlay is present....
if ( pFace->iVideoOverlay != -1 )
{
//if ( pFace->uiStopOverlayTimer == 0 )
//{
// pFace->uiStopOverlayTimer = GetJA2Clock();
//}
}
// Call dialogue handler function
HandleDialogueEnd( pFace );
}
}
}
}
}
// Local function - uses these variables because they have already been validated
void SetFaceShade( SOLDIERTYPE *pSoldier, FACETYPE *pFace, BOOLEAN fExternBlit )
{
// Set to default
SetObjectHandleShade( pFace->uiVideoObject, FLASH_PORTRAIT_NOSHADE );
if ( pFace->iVideoOverlay == -1 && !fExternBlit )
{
if ( ( pSoldier->bActionPoints == 0 ) && !( gTacticalStatus.uiFlags & REALTIME ) && (gTacticalStatus.uiFlags & INCOMBAT ) )
{
SetObjectHandleShade( pFace->uiVideoObject, FLASH_PORTRAIT_LITESHADE );
}
}
if ( pSoldier->stats.bLife < OKLIFE )
{
SetObjectHandleShade( pFace->uiVideoObject, FLASH_PORTRAIT_DARKSHADE );
}
// ATE: Don't shade for damage if blitting extern face...
if ( !fExternBlit )
{
if ( pSoldier->flags.fFlashPortrait == FLASH_PORTRAIT_START )
{
SetObjectHandleShade( pFace->uiVideoObject, pSoldier->bFlashPortraitFrame );
}
}
}
BOOLEAN RenderAutoFaceFromSoldier( UINT8 ubSoldierID )
{
// Check for valid soldier
CHECKF( ubSoldierID != NOBODY );
return( RenderAutoFace( MercPtrs[ ubSoldierID ]->iFaceIndex ) );
}
//---------------------------------------LEGION-------------------------------
/*
void GetXYForIconPlacement_legion( FACETYPE *pFace, UINT16 ubIndex, INT16 sFaceX, INT16 sFaceY, INT16 *psX, INT16 *psY )
{
INT16 sX, sY;
UINT16 usWidth, usHeight;
ETRLEObject *pTrav;
HVOBJECT hVObject;
// Get height, width of icon...
GetVideoObject( &hVObject, guiPORTRAITICONS_NV );
pTrav = &(hVObject->pETRLEObject[ ubIndex ] );
usHeight = pTrav->usHeight;
usWidth = pTrav->usWidth;
sX = sFaceX + pFace->usFaceWidth - usWidth - 1;
sY = sFaceY + pFace->usFaceHeight - usHeight - 1;
*psX = sX;
*psY = sY;
}
void GetXYForRightIconPlacement_legion_NV( FACETYPE *pFace, UINT16 ubIndex, INT16 sFaceX, INT16 sFaceY, INT16 *psX, INT16 *psY, INT8 bNumIcons, BOOLEAN isIMP )
{
INT16 sX, sY;
UINT16 usWidth, usHeight;
ETRLEObject *pTrav;
HVOBJECT hVObject;
// Get height, width of icon...
if (isIMP)
GetVideoObject( &hVObject, guiPORTRAITICONS_NV_IMP );
else
GetVideoObject( &hVObject, guiPORTRAITICONS_NV );
pTrav = &(hVObject->pETRLEObject[ ubIndex ] );
usHeight = pTrav->usHeight;
usWidth = pTrav->usWidth;
sX = sFaceX + ( usWidth * bNumIcons ) + 1;
sY = sFaceY + pFace->usFaceHeight - usHeight - 1;
*psX = sX;
*psY = sY;
}
void DoRightIcon_legion_NV( UINT32 uiRenderBuffer, FACETYPE *pFace, INT16 sFaceX, INT16 sFaceY, INT8 bNumIcons, UINT8 sIconIndex, BOOLEAN isIMP )
{
INT16 sIconX, sIconY;
GetXYForRightIconPlacement_legion_NV( pFace, sIconIndex, sFaceX, sFaceY, &sIconX, &sIconY, bNumIcons, isIMP );
if (isIMP)
BltVideoObjectFromIndex( uiRenderBuffer, guiPORTRAITICONS_NV_IMP, sIconIndex, sIconX, sIconY, VO_BLT_SRCTRANSPARENCY, NULL );
else
BltVideoObjectFromIndex( uiRenderBuffer, guiPORTRAITICONS_NV, sIconIndex, sIconX, sIconY, VO_BLT_SRCTRANSPARENCY, NULL );
}
void GetXYForRightIconPlacement_legion_GAS_MASK( FACETYPE *pFace, UINT16 ubIndex, INT16 sFaceX, INT16 sFaceY, INT16 *psX, INT16 *psY, INT8 bNumIcons, BOOLEAN isIMP )
{
INT16 sX, sY;
UINT16 usWidth, usHeight;
ETRLEObject *pTrav;
HVOBJECT hVObject;
// Get height, width of icon...
if (isIMP)
GetVideoObject( &hVObject, guiPORTRAITICONS_GAS_MASK_IMP );
else
GetVideoObject( &hVObject, guiPORTRAITICONS_GAS_MASK );
pTrav = &(hVObject->pETRLEObject[ ubIndex ] );
usHeight = pTrav->usHeight;
usWidth = pTrav->usWidth;
sX = sFaceX + ( usWidth * bNumIcons ) + 1;
sY = sFaceY + pFace->usFaceHeight - usHeight - 1;
*psX = sX;
*psY = sY;
}
void DoRightIcon_legion_GAS_MASK( UINT32 uiRenderBuffer, FACETYPE *pFace, INT16 sFaceX, INT16 sFaceY, INT8 bNumIcons, UINT8 sIconIndex, BOOLEAN isIMP )
{
INT16 sIconX, sIconY;
// Find X, y for placement
GetXYForRightIconPlacement_legion_GAS_MASK( pFace, sIconIndex, sFaceX, sFaceY, &sIconX, &sIconY, bNumIcons, isIMP );
if (isIMP)
BltVideoObjectFromIndex( uiRenderBuffer, guiPORTRAITICONS_GAS_MASK_IMP, sIconIndex, sIconX, sIconY, VO_BLT_SRCTRANSPARENCY, NULL );
else
BltVideoObjectFromIndex( uiRenderBuffer, guiPORTRAITICONS_GAS_MASK, sIconIndex, sIconX, sIconY, VO_BLT_SRCTRANSPARENCY, NULL );
}
*/
void GetXYForRightIconPlacement_FaceGera( FACETYPE *pFace, UINT16 ubIndex, INT16 sFaceX, INT16 sFaceY, INT16 *psX, INT16 *psY, INT8 bNumIcons , UINT32 uIDFaceGear, BOOLEAN isIMP)
{
INT16 sX, sY;
UINT16 usWidth, usHeight;
ETRLEObject *pTrav;
HVOBJECT hVObject;
// Get height, width of icon...
if (isIMP)
GetVideoObject( &hVObject, zNewFaceGearIMP[uIDFaceGear].uiIndex );
else
GetVideoObject( &hVObject, zNewFaceGear[uIDFaceGear].uiIndex );
pTrav = &(hVObject->pETRLEObject[ ubIndex ] );
usHeight = pTrav->usHeight;
usWidth = pTrav->usWidth;
sX = sFaceX + ( usWidth * bNumIcons ) + 1;
sY = sFaceY + pFace->usFaceHeight - usHeight - 1;
*psX = sX;
*psY = sY;
}
void DoRightIcon_FaceGear( UINT32 uiRenderBuffer, FACETYPE *pFace, INT16 sFaceX, INT16 sFaceY, INT8 bNumIcons, UINT8 sIconIndex , UINT32 uIDFaceGear, BOOLEAN isIMP)
{
INT16 sIconX, sIconY;
// Find X, y for placement
if (isIMP)
{
GetXYForRightIconPlacement_FaceGera( pFace, sIconIndex, sFaceX, sFaceY, &sIconX, &sIconY, bNumIcons , uIDFaceGear,isIMP);
BltVideoObjectFromIndex( uiRenderBuffer, zNewFaceGearIMP[uIDFaceGear].uiIndex, sIconIndex, sIconX, sIconY, VO_BLT_SRCTRANSPARENCY, NULL );
}
else
{
GetXYForRightIconPlacement_FaceGera( pFace, sIconIndex, sFaceX, sFaceY, &sIconX, &sIconY, bNumIcons , uIDFaceGear,isIMP);
BltVideoObjectFromIndex( uiRenderBuffer, zNewFaceGear[uIDFaceGear].uiIndex, sIconIndex, sIconX, sIconY, VO_BLT_SRCTRANSPARENCY, NULL );
}
}
//----------------------------------------------------------------
void GetXYForIconPlacement( FACETYPE *pFace, UINT16 ubIndex, INT16 sFaceX, INT16 sFaceY, INT16 *psX, INT16 *psY )
{
INT16 sX, sY;
UINT16 usWidth, usHeight;
ETRLEObject *pTrav;
HVOBJECT hVObject;
// Get height, width of icon...
GetVideoObject( &hVObject, guiPORTRAITICONS );
pTrav = &(hVObject->pETRLEObject[ ubIndex ] );
usHeight = pTrav->usHeight;
usWidth = pTrav->usWidth;
sX = sFaceX + pFace->usFaceWidth - usWidth - 1;
sY = sFaceY + pFace->usFaceHeight - usHeight - 1;
*psX = sX;
*psY = sY;
}
void GetXYForRightIconPlacement( FACETYPE *pFace, UINT16 ubIndex, INT16 sFaceX, INT16 sFaceY, INT16 *psX, INT16 *psY, INT8 bNumIcons )
{
INT16 sX, sY;
UINT16 usWidth, usHeight;
ETRLEObject *pTrav;
HVOBJECT hVObject;
// Get height, width of icon...
GetVideoObject( &hVObject, guiPORTRAITICONS );
pTrav = &(hVObject->pETRLEObject[ ubIndex ] );
usHeight = pTrav->usHeight;
usWidth = pTrav->usWidth;
sX = sFaceX + ( usWidth * bNumIcons ) + 1;
sY = sFaceY + pFace->usFaceHeight - usHeight - 1;
*psX = sX;
*psY = sY;
}
void DoRightIcon( UINT32 uiRenderBuffer, FACETYPE *pFace, INT16 sFaceX, INT16 sFaceY, INT8 bNumIcons, INT8 sIconIndex )
{
INT16 sIconX, sIconY;
// Find X, y for placement
GetXYForRightIconPlacement( pFace, sIconIndex, sFaceX, sFaceY, &sIconX, &sIconY, bNumIcons );
BltVideoObjectFromIndex( uiRenderBuffer, guiPORTRAITICONS, sIconIndex, sIconX, sIconY, VO_BLT_SRCTRANSPARENCY, NULL );
}
void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLEAN fUseExternBuffer, UINT32 uiBuffer, INT16 sFaceX, INT16 sFaceY, UINT16 usEyesX, UINT16 usEyesY )
{
INT16 sIconX, sIconY;
INT16 sIconIndex=-1;
BOOLEAN fDoIcon = FALSE;
UINT32 uiRenderBuffer;
INT16 sPtsAvailable = 0;
UINT16 usMaximumPts = 0;
CHAR16 sString[ 32 ];
UINT16 usTextWidth;
BOOLEAN fShowNumber = FALSE;
BOOLEAN fShowMaximum = FALSE;
SOLDIERTYPE *pSoldier;
INT16 sFontX, sFontY;
INT16 sX1, sY1, sY2, sX2;
UINT32 uiDestPitchBYTES;
UINT8 *pDestBuf;
UINT16 usLineColor;
INT8 bNumRightIcons = 0;
BOOLEAN fDoIcon_legion = FALSE; //legion
INT16 sIconIndex_legion =-1; //legion
INT8 bNumRightIcons_legion = 0;
BOOLEAN MASK = FALSE; //legion
UINT32 uiFaceItemOne=0;
UINT32 uiFaceItemTwo=0;
UINT8 ubFaceItemsCombined=0;
UINT32 uiFaceOne=0;
UINT32 uiFaceTwo=0;
// If we are using an extern buffer...
if ( fUseExternBuffer )
{
uiRenderBuffer = uiBuffer;
}
else
{
if ( fDisplayBuffer )
{
uiRenderBuffer = pFace->uiAutoDisplayBuffer;
}
else
{
uiRenderBuffer = pFace->uiAutoRestoreBuffer;
if ( pFace->uiAutoRestoreBuffer == FACE_NO_RESTORE_BUFFER )
{
return;
}
}
}
// BLIT HATCH
if ( pFace->ubSoldierID != NOBODY )
{
pSoldier = MercPtrs[ pFace->ubSoldierID ];
if ( ( MercPtrs[ pFace->ubSoldierID ]->stats.bLife < CONSCIOUSNESS || MercPtrs[ pFace->ubSoldierID ]->flags.fDeadPanel ) )
{
// Blit Closed eyes here!
BltVideoObjectFromIndex( uiRenderBuffer, pFace->uiVideoObject, 1, usEyesX, usEyesY, VO_BLT_SRCTRANSPARENCY, NULL );
// Blit hatch!
BltVideoObjectFromIndex( uiRenderBuffer, guiHATCH, 0, sFaceX, sFaceY, VO_BLT_SRCTRANSPARENCY, NULL );
}
if( MercPtrs[ pFace->ubSoldierID ]->flags.fMercAsleep == TRUE )
{
// blit eyes closed
BltVideoObjectFromIndex( uiRenderBuffer, pFace->uiVideoObject, 1, usEyesX, usEyesY, VO_BLT_SRCTRANSPARENCY, NULL );
}
if ( ( pSoldier->flags.uiStatusFlags & SOLDIER_DEAD ) )
{
// IF we are in the process of doing any deal/close animations, show face, not skill...
if ( !pSoldier->flags.fClosePanel && !pSoldier->flags.fDeadPanel && !pSoldier->flags.fUIdeadMerc && !pSoldier->flags.fUICloseMerc )
{
// Put close panel there
BltVideoObjectFromIndex( uiRenderBuffer, guiDEAD, 5, sFaceX, sFaceY, VO_BLT_SRCTRANSPARENCY, NULL );
// Blit hatch!
BltVideoObjectFromIndex( uiRenderBuffer, guiHATCH, 0, sFaceX, sFaceY, VO_BLT_SRCTRANSPARENCY, NULL );
}
}
// ATE: If talking in popup, don't do the other things.....
if ( pFace->fTalking && gTacticalStatus.uiFlags & IN_ENDGAME_SEQUENCE )
{
return;
}
// ATE: Only do this, because we can be talking during an interrupt....
if ( ( pFace->uiFlags & FACE_INACTIVE_HANDLED_ELSEWHERE ) && !fUseExternBuffer )
{
// Don't do this if we are being handled elsewhere and it's not an extern buffer...
}
else
{
HandleFaceHilights( pFace, uiRenderBuffer, sFaceX, sFaceY );
#ifdef JA2BETAVERSION
if ( pSoldier->aiData.bOppCnt != 0 )
#else
if ( pSoldier->aiData.bOppCnt > 0 )
#endif
{
SetFontDestBuffer( uiRenderBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE );
swprintf( sString, L"%d", pSoldier->aiData.bOppCnt );
SetFont( TINYFONT1 );
SetFontForeground( FONT_DKRED );
SetFontBackground( FONT_NEARBLACK );
sX1 = (INT16)( sFaceX );
sY1 = (INT16)( sFaceY );
sX2 = sX1 + StringPixLength( sString, TINYFONT1 ) + 1;
sY2 = sY1 + GetFontHeight( TINYFONT1 ) - 1;
mprintf( (INT16)( sX1 + 1), (INT16)( sY1 - 1 ), sString );
SetFontDestBuffer( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE );
// Draw box
pDestBuf = LockVideoSurface( uiRenderBuffer, &uiDestPitchBYTES );
SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
usLineColor = Get16BPPColor( FROMRGB( 105, 8, 9 ) );
RectangleDraw( TRUE, sX1, sY1, sX2, sY2, usLineColor, pDestBuf );
UnLockVideoSurface( uiRenderBuffer );
}
if ( MercPtrs[ pFace->ubSoldierID ]->bInSector && ( ( ( gTacticalStatus.ubCurrentTeam != OUR_TEAM ) || !OK_INTERRUPT_MERC( MercPtrs[ pFace->ubSoldierID ] ) ) && !gfHiddenInterrupt ) || ( ( gfSMDisableForItems && !gfInItemPickupMenu ) && gusSMCurrentMerc == pFace->ubSoldierID && gsCurInterfacePanel == SM_PANEL ) )
{
// Blit hatch!
BltVideoObjectFromIndex( uiRenderBuffer, guiHATCH, 0, sFaceX, sFaceY, VO_BLT_SRCTRANSPARENCY, NULL );
}
if ( !pFace->fDisabled && !pFace->fInvalidAnim )
{
// Render text above here if that's what was asked for
if ( pFace->fDisplayTextOver != FACE_NO_TEXT_OVER )
{
SetFont( TINYFONT1 );
SetFontBackground( FONT_MCOLOR_BLACK );
SetFontForeground( FONT_MCOLOR_WHITE );
SetFontDestBuffer( uiRenderBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE );
VarFindFontCenterCoordinates( sFaceX, sFaceY, pFace->usFaceWidth, pFace->usFaceHeight, TINYFONT1, &sFontX, &sFontY, pFace->zDisplayText );
if ( pFace->fDisplayTextOver == FACE_DRAW_TEXT_OVER )
{
gprintfinvalidate( sFontX, sFontY, pFace->zDisplayText );
mprintf( sFontX, sFontY, pFace->zDisplayText );
}
else if ( pFace->fDisplayTextOver == FACE_ERASE_TEXT_OVER )
{
gprintfRestore( sFontX, sFontY, pFace->zDisplayText );
pFace->fDisplayTextOver = FACE_NO_TEXT_OVER;
}
SetFontDestBuffer( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE );
}
}
}
// Check if a robot and is not controlled....
if ( MercPtrs[ pFace->ubSoldierID ]->flags.uiStatusFlags & SOLDIER_ROBOT )
{
if ( !MercPtrs[ pFace->ubSoldierID ]->CanRobotBeControlled( ) )
{
// Not controlled robot
sIconIndex = 5;
fDoIcon = TRUE;
}
}
if ( MercPtrs[ pFace->ubSoldierID ]->ControllingRobot( ) )
{
// controlling robot
sIconIndex = 4;
fDoIcon = TRUE;
}
//------------------------------------Legion 2 by jazz--------------------------------
UINT8 faceProfileId = MercPtrs[ pFace->ubSoldierID ]->ubProfile;
BOOLEAN isIMP = FALSE;
//IMP
if ( gProfilesIMP[ MercPtrs[ pFace->ubSoldierID ]->ubProfile ].ProfilId == MercPtrs[ pFace->ubSoldierID ]->ubProfile )
{
faceProfileId = gMercProfiles[MercPtrs[ pFace->ubSoldierID ]->ubProfile].ubFaceIndex;
isIMP = TRUE;
}
// rewritten by silversurfer
// this section chooses the icons for face gear if the ini setting "SHOW_TACTICAL_FACE_ICONS" is TRUE
// and the merc actually wears something to be shown
if (gGameSettings.fOptions[ TOPTION_SHOW_TACTICAL_FACE_ICONS ] == TRUE && MercPtrs[ pFace->ubSoldierID ]->stats.bLife > 0 &&
( MercPtrs[ pFace->ubSoldierID ]->inv[HEAD1POS].usItem + MercPtrs[ pFace->ubSoldierID ]->inv[HEAD2POS].usItem ) > 0 )
{
uiFaceItemOne=MercPtrs[ pFace->ubSoldierID ]->inv[HEAD1POS].usItem;
uiFaceItemTwo=MercPtrs[ pFace->ubSoldierID ]->inv[HEAD2POS].usItem;
// check first face slot
if ( uiFaceItemOne != NONE )
{
switch( uiFaceItemOne )
{
// gas mask
case GASMASK:
uiFaceItemOne = 1;
break;
// NV goggles
case 211:
case 246:
case 1024:
case 1025:
uiFaceItemOne = 2;
break;
// sun goggles
case 212:
uiFaceItemOne = 3;
break;
// extended ear
case 210:
uiFaceItemOne = 4;
break;
default:
uiFaceItemOne = 0;
break;
}
}
// check second face slot
if ( uiFaceItemTwo != NONE )
{
switch( uiFaceItemTwo )
{
// gas mask
case GASMASK:
uiFaceItemTwo = 21;
break;
// NV goggles
case 211:
case 246:
case 1024:
case 1025:
uiFaceItemTwo = 42;
break;
// sun goggles
case 212:
uiFaceItemTwo = 63;
break;
// extended ear
case 210:
uiFaceItemTwo = 84;
break;
default:
uiFaceItemTwo = 0;
break;
}
}
// Now select the correct icon. This uses a matrix from uiFaceOneItem and uiFaceTwoItem (simple addition)
// the numbers on the outer border are used if that is the only item worn in that slot
//
// 21 42 63 84
// face slot 1 \ slot 2 gas mask | NV goggles | sun goggles | extended ear
// 1 gas mask -- 43 64 85
// 2 NV goggles 23 -- -- 86
// 3 sun goggles 24 -- -- 87
// 4 extended ear 25 46 67 --
//
// this matrix leaves room for expansion
ubFaceItemsCombined = uiFaceItemOne + uiFaceItemTwo;
switch( ubFaceItemsCombined )
{
// gas mask only
case 1:
case 21:
sIconIndex = 9;
fDoIcon = TRUE;
break;
// NV goggles only
case 2:
case 42:
sIconIndex = 10;
fDoIcon = TRUE;
break;
// sun goggles only
case 3:
case 63:
sIconIndex = 15;
fDoIcon = TRUE;
break;
// extended ear only
case 4:
case 84:
sIconIndex = 12;
fDoIcon = TRUE;
break;
// gas mask + NV goggles
case 23:
case 43:
sIconIndex = 11;
fDoIcon = TRUE;
break;
// gas mask + sun goggles
case 24:
case 64:
sIconIndex = 16;
fDoIcon = TRUE;
break;
// gas mask + extended ear
case 25:
case 85:
sIconIndex = 13;
fDoIcon = TRUE;
break;
// NV goggles + extended ear
case 46:
case 86:
sIconIndex = 14;
fDoIcon = TRUE;
break;
// sun goggles + extended ear
case 67:
case 87:
sIconIndex = 18;
fDoIcon = TRUE;
break;
default:
break;
}
}
if (gGameSettings.fOptions[ TOPTION_SHOW_TACTICAL_FACE_GEAR ] == TRUE && MercPtrs[ pFace->ubSoldierID ]->stats.bLife > 0 &&
( MercPtrs[ pFace->ubSoldierID ]->inv[HELMETPOS].usItem > 0 ) )
{
uiFaceItemOne=MercPtrs[ pFace->ubSoldierID ]->inv[HELMETPOS].usItem;
if ( uiFaceItemOne != NONE && zNewFaceGear[uiFaceItemOne].Type == 1 ) //back
{
DoRightIcon_FaceGear( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId ,uiFaceItemOne, isIMP);
}
}
// this section chooses the pictures for gas mask and NV goggles if the ini setting "SHOW_TACTICAL_FACE_GEAR" is TRUE
// and the merc actually wears something to be shown
if (gGameSettings.fOptions[ TOPTION_SHOW_TACTICAL_FACE_GEAR ] == TRUE && MercPtrs[ pFace->ubSoldierID ]->stats.bLife > 0 &&
( MercPtrs[ pFace->ubSoldierID ]->inv[HEAD1POS].usItem + MercPtrs[ pFace->ubSoldierID ]->inv[HEAD2POS].usItem ) > 0 )
{
/*
BOOLEAN isIMP = FALSE;
UINT8 faceProfileId = MercPtrs[ pFace->ubSoldierID ]->ubProfile;
// WANNE: IMP: Special handling for face gear
if (MercPtrs[ pFace->ubSoldierID ]->ubProfile >= 51 && MercPtrs[ pFace->ubSoldierID ]->ubProfile <= 56)
{
// IMP: Imps anhand des FaceIndex rausfinden!!
faceProfileId = gMercProfiles[MercPtrs[ pFace->ubSoldierID ]->ubProfile].ubFaceIndex;
isIMP = TRUE;
}
*/
// WANNE: Removed the limitation
// silversurfer: don't overwrite icons if they shall be shown!
//if ( !gGameSettings.fOptions[ SHOW_TACTICAL_FACE_ICONS ] )
{
uiFaceItemOne=MercPtrs[ pFace->ubSoldierID ]->inv[HEAD1POS].usItem;
uiFaceItemTwo=MercPtrs[ pFace->ubSoldierID ]->inv[HEAD2POS].usItem;
uiFaceOne=MercPtrs[ pFace->ubSoldierID ]->inv[HEAD1POS].usItem;
uiFaceTwo=MercPtrs[ pFace->ubSoldierID ]->inv[HEAD2POS].usItem;
// check first face slot
if ( uiFaceItemOne != NONE )
{
if ( zNewFaceGear[uiFaceOne].Type == 3 )
{
uiFaceItemOne = 1;
}
else if ( zNewFaceGear[uiFaceOne].Type == 4 )
{
uiFaceItemOne = 2;
}
else uiFaceItemOne = 0;
}
// check second face slot
if ( uiFaceItemTwo != NONE )
{
if ( zNewFaceGear[uiFaceTwo].Type == 3 )
{
uiFaceItemTwo = 21;
}
else if ( zNewFaceGear[uiFaceTwo].Type == 4 )
{
uiFaceItemTwo = 42;
}
else uiFaceItemTwo = 0;
}
/*
// check first face slot
if ( uiFaceItemOne != NONE )
{
switch( uiFaceItemOne )
{
// gas mask
case GASMASK:
uiFaceItemOne = 1;
break;
// NV goggles
case 211:
case 246:
case 1024:
case 1025:
uiFaceItemOne = 2;
break;
default:
uiFaceItemOne = 0;
break;
}
}
// check second face slot
if ( uiFaceItemTwo != NONE )
{
switch( uiFaceItemTwo )
{
// gas mask
case GASMASK:
uiFaceItemTwo = 21;
break;
// NV goggles
case 211:
case 246:
case 1024:
case 1025:
uiFaceItemTwo = 42;
break;
default:
uiFaceItemTwo = 0;
break;
}
}
*/
// Now select the correct picture. This uses a matrix from uiFaceOneItem and uiFaceTwoItem (simple addition)
// the numbers on the outer border are used if that is the only item worn in that slot
//
// 21 42 63 84
// face slot 1 \ slot 2 gas mask | NV goggles | sun goggles | extended ear
// 1 gas mask -- 43 64 85
// 2 NV goggles 23 -- -- 86
// 3 sun goggles 24 -- -- 87
// 4 extended ear 25 46 67 --
//
// this matrix leaves room for expansion
// we only need a few of the matrix' values this time because we only show gas mask or NV goggles pictures
ubFaceItemsCombined = uiFaceItemOne + uiFaceItemTwo;
}
// WANNE: Removed silversurfers limitation, because it is too complex for the players :)
// silversurfer: we don't want to display icons for gas mask or NV goggles because you can actually see the merc wearing the gear
// in case of gas mask together with NV we display the picture of the item in face slot 1 and the icon of the item
// in face slot 2 (if icons are allowed)
//Type : 3 - gas mask ; 4 - NV googles
// gas mask only
if ( ubFaceItemsCombined == 1 || ubFaceItemsCombined == 21 )
{
if ( zNewFaceGear[uiFaceOne].Type == 3 )
{
DoRightIcon_FaceGear( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId ,uiFaceOne, isIMP);
}
else if ( zNewFaceGear[uiFaceTwo].Type == 3 )
{
DoRightIcon_FaceGear( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId ,uiFaceTwo, isIMP);
}
}
// NV goggles only
if ( ubFaceItemsCombined == 2 || ubFaceItemsCombined == 42 )
{
if ( zNewFaceGear[uiFaceOne].Type == 4 )
{
DoRightIcon_FaceGear( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId ,uiFaceOne, isIMP);
}
else if ( zNewFaceGear[uiFaceTwo].Type == 4 )
{
DoRightIcon_FaceGear( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId ,uiFaceTwo, isIMP);
}
}
// NV goggles + gas mask
if ( ubFaceItemsCombined == 23 )
{
if ( zNewFaceGear[uiFaceOne].Type == 4 && zNewFaceGear[uiFaceTwo].Type == 3 )
{
DoRightIcon_FaceGear( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId ,uiFaceTwo, isIMP);
DoRightIcon_FaceGear( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId ,uiFaceOne, isIMP);
}
}
// gas mask + NV goggles
if ( ubFaceItemsCombined == 43 )
{
if ( zNewFaceGear[uiFaceOne].Type == 3 && zNewFaceGear[uiFaceTwo].Type == 4 )
{
DoRightIcon_FaceGear( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId ,uiFaceOne, isIMP);
DoRightIcon_FaceGear( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId ,uiFaceTwo, isIMP);
}
}
// gas mask + extended ear
if ( ubFaceItemsCombined == 24 || ubFaceItemsCombined == 64 )
{
if ( zNewFaceGear[uiFaceOne].Type == 3 )
{
DoRightIcon_FaceGear( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId ,uiFaceOne, isIMP);
}
else if ( zNewFaceGear[uiFaceTwo].Type == 3 )
{
DoRightIcon_FaceGear( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId ,uiFaceTwo, isIMP);
}
}
// gas mask + extended ear
if ( ubFaceItemsCombined == 25 || ubFaceItemsCombined == 85 )
{
if ( zNewFaceGear[uiFaceOne].Type == 3 )
{
DoRightIcon_FaceGear( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId ,uiFaceOne, isIMP);
}
else if ( zNewFaceGear[uiFaceTwo].Type == 3 )
{
DoRightIcon_FaceGear( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId ,uiFaceTwo, isIMP);
}
}
// NV goggles + extended ear
if ( ubFaceItemsCombined == 46 || ubFaceItemsCombined == 86 )
{
if ( zNewFaceGear[uiFaceOne].Type == 4 )
{
DoRightIcon_FaceGear( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId ,uiFaceOne, isIMP);
}
else if ( zNewFaceGear[uiFaceTwo].Type == 4 )
{
DoRightIcon_FaceGear( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId ,uiFaceTwo, isIMP);
}
}
/*
switch( ubFaceItemsCombined )
{
// gas mask only
case 1:
case 21:
DoRightIcon_legion_GAS_MASK( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, isIMP );
// WANNE: Removed silversurfers limitation, because it is too complex for the players :)
//fDoIcon = FALSE;
break;
// NV goggles only
case 2:
case 42:
DoRightIcon_legion_NV( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, isIMP );
// WANNE: Removed silversurfers limitation, because it is too complex for the players :)
//fDoIcon = FALSE;
break;
// NV goggles + gas mask
case 23:
DoRightIcon_legion_GAS_MASK( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, isIMP );
DoRightIcon_legion_NV( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, isIMP );
// WANNE: Removed silversurfers limitation, because it is too complex for the players :)
//if ( gGameSettings.fOptions[ SHOW_TACTICAL_FACE_ICONS ] )
//{
// sIconIndex = 9;
// fDoIcon = TRUE;
//}
break;
// gas mask + NV goggles
case 43:
DoRightIcon_legion_GAS_MASK( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, isIMP );
DoRightIcon_legion_NV( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, isIMP );
// WANNE: Removed silversurfers limitation, because it is too complex for the players :)
//if ( gGameSettings.fOptions[ SHOW_TACTICAL_FACE_ICONS ] )
//{
// sIconIndex = 10;
// fDoIcon = TRUE;
//}
break;
// gas mask + sun goggles
case 24:
case 64:
DoRightIcon_legion_GAS_MASK( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, isIMP );
// WANNE: Removed silversurfers limitation, because it is too complex for the players :)
//sIconIndex = 15;
//fDoIcon = TRUE;
break;
// gas mask + extended ear
case 25:
case 85:
DoRightIcon_legion_GAS_MASK( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, isIMP );
// WANNE: Removed silversurfers limitation, because it is too complex for the players :)
//sIconIndex = 12;
//fDoIcon = TRUE;
break;
// NV goggles + extended ear
case 46:
case 86:
DoRightIcon_legion_NV( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, isIMP );
// WANNE: Removed silversurfers limitation, because it is too complex for the players :)
//sIconIndex = 12;
//fDoIcon = TRUE;
break;
default:
break;
}
*/
}
if (gGameSettings.fOptions[ TOPTION_SHOW_TACTICAL_FACE_GEAR ] == TRUE && MercPtrs[ pFace->ubSoldierID ]->stats.bLife > 0 &&
( MercPtrs[ pFace->ubSoldierID ]->inv[HELMETPOS].usItem > 0 )
// dirty hack for IMPs because they don't have pictures for face gear
/* && ( MercPtrs[ pFace->ubSoldierID ]->ubProfile < 51 || MercPtrs[ pFace->ubSoldierID ]->ubProfile > 56 ) */ )
{
uiFaceItemOne=MercPtrs[ pFace->ubSoldierID ]->inv[HELMETPOS].usItem;
if ( uiFaceItemOne != NONE )
{
if ( uiFaceItemOne != NONE && zNewFaceGear[uiFaceItemOne].Type == 2 ) //front
{
DoRightIcon_FaceGear( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId ,uiFaceItemOne, isIMP);
}
}
}
//------------------------------------end of tactical face gear-----------------------------
// If blind...
if ( MercPtrs[ pFace->ubSoldierID ]->bBlindedCounter > 0 )
{
DoRightIcon( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons, 6 );
bNumRightIcons++;
}
if ( MercPtrs[ pFace->ubSoldierID ]->drugs.bDrugEffect[ DRUG_TYPE_ADRENALINE ] )
{
DoRightIcon( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons, 7 );
bNumRightIcons++;
}
if ( GetDrunkLevel( MercPtrs[ pFace->ubSoldierID ] ) != SOBER )
{
DoRightIcon( uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons, 8 );
bNumRightIcons++;
}
switch( pSoldier->bAssignment )
{
case DOCTOR:
sIconIndex = 1;
fDoIcon = TRUE;
sPtsAvailable = CalculateHealingPointsForDoctor( MercPtrs[ pFace->ubSoldierID ], &usMaximumPts, FALSE );
fShowNumber = TRUE;
fShowMaximum = TRUE;
// divide both amounts by 10 to make the displayed numbers a little more user-palatable (smaller)
sPtsAvailable = ( sPtsAvailable + 5 ) / 10;
usMaximumPts = ( usMaximumPts + 5 ) / 10;
break;
case PATIENT:
sIconIndex = 2;
fDoIcon = TRUE;
// show current health / maximum health
sPtsAvailable = MercPtrs[ pFace->ubSoldierID ]->stats.bLife;
usMaximumPts = MercPtrs[ pFace->ubSoldierID ]->stats.bLifeMax;
fShowNumber = TRUE;
fShowMaximum = TRUE;
break;
case TRAIN_SELF:
case TRAIN_TOWN:
// HEADROCK HAM 3.6: New assignment.
case TRAIN_MOBILE:
case TRAIN_TEAMMATE:
case TRAIN_BY_OTHER:
sIconIndex = 3;
fDoIcon = TRUE;
fShowNumber = TRUE;
fShowMaximum = TRUE;
switch( MercPtrs[ pFace->ubSoldierID ]->bAssignment )
{
case( TRAIN_SELF ):
sPtsAvailable = GetSoldierTrainingPts( MercPtrs[ pFace->ubSoldierID ], MercPtrs[ pFace->ubSoldierID ]->bTrainStat, &usMaximumPts );
break;
case( TRAIN_BY_OTHER ):
sPtsAvailable = GetSoldierStudentPts( MercPtrs[ pFace->ubSoldierID ], MercPtrs[ pFace->ubSoldierID ]->bTrainStat, &usMaximumPts );
break;
case( TRAIN_TOWN ):
case( TRAIN_MOBILE ):
sPtsAvailable = GetTownTrainPtsForCharacter( MercPtrs[ pFace->ubSoldierID ], &usMaximumPts );
// divide both amounts by 10 to make the displayed numbers a little more user-palatable (smaller)
sPtsAvailable = ( sPtsAvailable + 5 ) / 10;
usMaximumPts = ( usMaximumPts + 5 ) / 10;
break;
case( TRAIN_TEAMMATE ):
sPtsAvailable = GetBonusTrainingPtsDueToInstructor( MercPtrs[ pFace->ubSoldierID ], NULL , MercPtrs[ pFace->ubSoldierID ]->bTrainStat, &usMaximumPts );
break;
}
break;
case REPAIR:
sIconIndex = 0;
fDoIcon = TRUE;
sPtsAvailable = CalculateRepairPointsForRepairman( MercPtrs[ pFace->ubSoldierID ], &usMaximumPts, FALSE );
fShowNumber = TRUE;
fShowMaximum = TRUE;
// check if we are repairing a vehicle
if ( Menptr[ pFace->ubSoldierID ].bVehicleUnderRepairID != -1 )
{
// reduce to a multiple of VEHICLE_REPAIR_POINTS_DIVISOR. This way skill too low will show up as 0 repair pts.
sPtsAvailable -= ( sPtsAvailable % VEHICLE_REPAIR_POINTS_DIVISOR );
usMaximumPts -= ( usMaximumPts % VEHICLE_REPAIR_POINTS_DIVISOR );
}
break;
}
// Check for being serviced...
if ( MercPtrs[ pFace->ubSoldierID ]->ubServicePartner != NOBODY )
{
// Doctor...
sIconIndex = 1;
fDoIcon = TRUE;
}
if ( MercPtrs[ pFace->ubSoldierID ]->ubServiceCount != 0 )
{
// Patient
sIconIndex = 2;
fDoIcon = TRUE;
}
if ( fDoIcon )
{
// Find X, y for placement
GetXYForIconPlacement( pFace, sIconIndex, sFaceX, sFaceY, &sIconX, &sIconY );
BltVideoObjectFromIndex( uiRenderBuffer, guiPORTRAITICONS, sIconIndex, sIconX, sIconY, VO_BLT_SRCTRANSPARENCY, NULL );
// ATE: Show numbers only in mapscreen
if( fShowNumber )
{
SetFontDestBuffer( uiRenderBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE );
if ( fShowMaximum )
{
swprintf( sString, L"%d/%d", sPtsAvailable, usMaximumPts );
}
else
{
swprintf( sString, L"%d", sPtsAvailable );
}
usTextWidth = StringPixLength( sString, FONT10ARIAL );
usTextWidth += 1;
SetFont( FONT10ARIAL );
SetFontForeground( FONT_YELLOW );
SetFontBackground( FONT_BLACK );
mprintf( sFaceX + pFace->usFaceWidth - usTextWidth, ( INT16 )( sFaceY + 3 ), sString );
SetFontDestBuffer( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE );
}
}
}
else
{
if ( pFace->ubCharacterNum == FATHER || pFace->ubCharacterNum == MICKY )
{
if ( gMercProfiles[ pFace->ubCharacterNum ].bNPCData >= 5 )
{
DoRightIcon( uiRenderBuffer, pFace, sFaceX, sFaceY, 0, 8 );
}
}
}
}
BOOLEAN RenderAutoFace( INT32 iFaceIndex )
{
FACETYPE *pFace;
// Check face index
CHECKF( iFaceIndex != -1 );
pFace = &gFacesData[ iFaceIndex ];
// Check for a valid slot!
CHECKF( pFace->fAllocated != FALSE );
// Check for disabled guy!
CHECKF( pFace->fDisabled != TRUE );
// Set shade
if ( pFace->ubSoldierID != NOBODY )
{
SetFaceShade( MercPtrs[ pFace->ubSoldierID ], pFace, FALSE );
}
// Blit face to save buffer!
if ( pFace->uiAutoRestoreBuffer != FACE_NO_RESTORE_BUFFER )
{
if ( pFace->uiAutoRestoreBuffer == guiSAVEBUFFER )
{
BltVideoObjectFromIndex( pFace->uiAutoRestoreBuffer, pFace->uiVideoObject, 0, pFace->usFaceX, pFace->usFaceY, VO_BLT_SRCTRANSPARENCY, NULL );
}
else
{
BltVideoObjectFromIndex( pFace->uiAutoRestoreBuffer, pFace->uiVideoObject, 0, 0, 0, VO_BLT_SRCTRANSPARENCY, NULL );
}
}
HandleRenderFaceAdjustments( pFace, FALSE, FALSE, 0, pFace->usFaceX, pFace->usFaceY, pFace->usEyesX, pFace->usEyesY );
// Restore extern rect
if ( pFace->uiAutoRestoreBuffer == guiSAVEBUFFER )
{
FaceRestoreSavedBackgroundRect( iFaceIndex, (INT16)( pFace->usFaceX ), (INT16)( pFace->usFaceY ), (INT16)( pFace->usFaceX ), (INT16)( pFace->usFaceY ), ( INT16)( pFace->usFaceWidth ), (INT16)( pFace->usFaceHeight ) );
}
else
{
FaceRestoreSavedBackgroundRect( iFaceIndex, pFace->usFaceX, pFace->usFaceY, 0, 0, pFace->usFaceWidth, pFace->usFaceHeight );
}
return( TRUE );
}
BOOLEAN ExternRenderFaceFromSoldier( UINT32 uiBuffer, UINT8 ubSoldierID, INT16 sX, INT16 sY )
{
// Check for valid soldier
CHECKF( ubSoldierID != NOBODY );
return( ExternRenderFace( uiBuffer, MercPtrs[ ubSoldierID ]->iFaceIndex, sX, sY ) );
}
BOOLEAN ExternRenderFace( UINT32 uiBuffer, INT32 iFaceIndex, INT16 sX, INT16 sY )
{
UINT16 usEyesX;
UINT16 usEyesY;
UINT16 usMouthX;
UINT16 usMouthY;
FACETYPE *pFace;
// Check face index
CHECKF( iFaceIndex != -1 );
pFace = &gFacesData[ iFaceIndex ];
// Check for a valid slot!
CHECKF( pFace->fAllocated != FALSE );
// Here, any face can be rendered, even if disabled
// Set shade
if ( pFace->ubSoldierID != NOBODY )
{
SetFaceShade( MercPtrs[ pFace->ubSoldierID ], pFace , TRUE );
}
// Blit face to save buffer!
BltVideoObjectFromIndex( uiBuffer, pFace->uiVideoObject, 0, sX, sY, VO_BLT_SRCTRANSPARENCY, NULL );
GetFaceRelativeCoordinates( pFace, &usEyesX, &usEyesY, &usMouthX, &usMouthY );
HandleRenderFaceAdjustments( pFace, FALSE, TRUE, uiBuffer, sX, sY, ( UINT16)( sX + usEyesX ), ( UINT16)( sY + usEyesY ) );
// Restore extern rect
if ( uiBuffer == guiSAVEBUFFER )
{
RestoreExternBackgroundRect( sX, sY, pFace->usFaceWidth, pFace->usFaceWidth );
}
return( TRUE );
}
void NewEye( FACETYPE *pFace )
{
switch(pFace->sEyeFrame)
{
case 0 : //pFace->sEyeFrame = (INT16)Random(2); // normal - can blink or frown
if ( pFace->ubExpression == ANGRY )
{
pFace->ubEyeWait = 0;
pFace->sEyeFrame = 3;
}
else if ( pFace->ubExpression == SURPRISED )
{
pFace->ubEyeWait = 0;
pFace->sEyeFrame = 4;
}
else
//if (pFace->sEyeFrame && Talk.talking && Talk.expression != DYING)
/// pFace->sEyeFrame = 3;
//else
pFace->sEyeFrame = 1;
break;
case 1 : // starting to blink - has to finish unless dying
//if (Talk.expression == DYING)
// pFace->sEyeFrame = 1;
//else
pFace->sEyeFrame = 2;
break;
case 2 : //pFace->sEyeFrame = (INT16)Random(2); // finishing blink - can go normal or frown
//if (pFace->sEyeFrame && Talk.talking)
// pFace->sEyeFrame = 3;
//else
// if (Talk.expression == ANGRY)
// pFace->sEyeFrame = 3;
// else
pFace->sEyeFrame = 0;
break;
case 3 : //pFace->sEyeFrame = 4; break; // frown
pFace->ubEyeWait++;
if ( pFace->ubEyeWait > 6 )
{
pFace->sEyeFrame = 0;
}
break;
case 4 :
pFace->ubEyeWait++;
if ( pFace->ubEyeWait > 6 )
{
pFace->sEyeFrame = 0;
}
break;
case 5 : pFace->sEyeFrame = 6;
pFace->sEyeFrame = 0;
break;
case 6 : pFace->sEyeFrame = 7; break;
case 7 : pFace->sEyeFrame = (INT16)Random(2); // can stop frowning or continue
//if (pFace->sEyeFrame && Talk.expression != DYING)
// pFace->sEyeFrame = 8;
//else
// pFace->sEyeFrame = 0;
//break;
case 8 : pFace->sEyeFrame = 9; break;
case 9 : pFace->sEyeFrame = 10; break;
case 10: pFace->sEyeFrame = 11; break;
case 11: pFace->sEyeFrame = 12; break;
case 12: pFace->sEyeFrame = 0; break;
}
}
void NewMouth( FACETYPE *pFace )
{
BOOLEAN OK = FALSE;
UINT16 sOld = pFace->sMouthFrame;
// if (audio_gap_active == 1)
// {
// Talk.mouth = 0;
// return;
// }
do
{
//Talk.mouth = random(4);
pFace->sMouthFrame = (INT16)Random(6);
if ( pFace->sMouthFrame > 3)
{
pFace->sMouthFrame = 0;
}
switch( sOld)
{
case 0 : if ( pFace->sMouthFrame != 0 )
OK = TRUE;
break;
case 1 : if ( pFace->sMouthFrame != 1 )
OK = TRUE;
break;
case 2 : if ( pFace->sMouthFrame != 2 )
OK = TRUE;
break;
case 3 : if ( pFace->sMouthFrame != 3 )
OK = TRUE;
break;
}
} while (!OK);
}
void HandleAutoFaces( )
{
UINT32 uiCount;
FACETYPE *pFace;
INT8 bLife;
INT8 bInSector;
INT16 bAPs;
BOOLEAN fRerender = FALSE;
BOOLEAN fHandleFace;
BOOLEAN fHandleUIHatch;
SOLDIERTYPE *pSoldier;
for ( uiCount = 0; uiCount < guiNumFaces; uiCount++ )
{
fRerender = FALSE;
fHandleFace = TRUE;
fHandleUIHatch = FALSE;
// OK, NOW, check if our bLife status has changed, re-render if so!
if ( gFacesData[ uiCount ].fAllocated )
{
pFace = &gFacesData[ uiCount ];
// Are we a soldier?
if ( pFace->ubSoldierID != NOBODY )
{
// Get Life now
pSoldier = MercPtrs[ pFace->ubSoldierID ];
bLife = pSoldier->stats.bLife;
bInSector = pSoldier->bInSector;
bAPs = pSoldier->bActionPoints;
if ( pSoldier->ubID == gsSelectedGuy && gfUIHandleSelectionAboveGuy )
{
pFace->uiFlags |= FACE_SHOW_WHITE_HILIGHT;
}
else
{
pFace->uiFlags &= ( ~FACE_SHOW_WHITE_HILIGHT );
}
if ( pSoldier->sGridNo != pSoldier->pathing.sFinalDestination && !TileIsOutOfBounds(pSoldier->sGridNo))
{
pFace->uiFlags |= FACE_SHOW_MOVING_HILIGHT;
}
else
{
pFace->uiFlags &= ( ~FACE_SHOW_MOVING_HILIGHT );
}
if ( pSoldier->bStealthMode != pFace->bOldStealthMode )
{
fRerender = TRUE;
}
// Check if we have fallen below OKLIFE...
if ( bLife < OKLIFE && pFace->bOldSoldierLife >= OKLIFE )
{
fRerender = TRUE;
}
if ( bLife >= OKLIFE && pFace->bOldSoldierLife < OKLIFE )
{
fRerender = TRUE;
}
// Check if we have fallen below CONSCIOUSNESS
if ( bLife < CONSCIOUSNESS && pFace->bOldSoldierLife >= CONSCIOUSNESS )
{
fRerender = TRUE;
}
if ( bLife >= CONSCIOUSNESS && pFace->bOldSoldierLife < CONSCIOUSNESS )
{
fRerender = TRUE;
}
if ( pSoldier->aiData.bOppCnt != pFace->bOldOppCnt )
{
fRerender = TRUE;
}
// Check if assignment is idfferent....
if ( pSoldier->bAssignment != pFace->bOldAssignment )
{
pFace->bOldAssignment = pSoldier->bAssignment;
fRerender = TRUE;
}
// Check if we have fallen below CONSCIOUSNESS
if ( bAPs == 0 && pFace->bOldActionPoints > 0 )
{
fRerender = TRUE;
}
if ( bAPs > 0 && pFace->bOldActionPoints == 0 )
{
fRerender = TRUE;
}
if ( !( pFace->uiFlags & FACE_SHOW_WHITE_HILIGHT ) && pFace->fOldShowHighlight )
{
fRerender = TRUE;
}
if ( ( pFace->uiFlags & FACE_SHOW_WHITE_HILIGHT ) && !( pFace->fOldShowHighlight ) )
{
fRerender = TRUE;
}
if ( !( pFace->uiFlags & FACE_SHOW_MOVING_HILIGHT ) && pFace->fOldShowMoveHilight )
{
fRerender = TRUE;
}
if ( ( pFace->uiFlags & FACE_SHOW_MOVING_HILIGHT ) && !( pFace->fOldShowMoveHilight ) )
{
fRerender = TRUE;
}
if ( pFace->ubOldServiceCount != pSoldier->ubServiceCount )
{
fRerender = TRUE;
pFace->ubOldServiceCount = pSoldier->ubServiceCount;
}
if ( pFace->fOldCompatibleItems != pFace->fCompatibleItems || gfInItemPickupMenu || gpItemPointer != NULL )
{
fRerender = TRUE;
pFace->fOldCompatibleItems = pFace->fCompatibleItems;
}
if ( pFace->ubOldServicePartner != pSoldier->ubServicePartner )
{
fRerender = TRUE;
pFace->ubOldServicePartner = pSoldier->ubServicePartner;
}
pFace->fOldHandleUIHatch = fHandleUIHatch;
pFace->bOldSoldierLife = bLife;
pFace->bOldActionPoints = bAPs;
pFace->bOldStealthMode = pSoldier->bStealthMode;
pFace->bOldOppCnt = pSoldier->aiData.bOppCnt;
if ( pFace->uiFlags & FACE_SHOW_WHITE_HILIGHT )
{
pFace->fOldShowHighlight = TRUE;
}
else
{
pFace->fOldShowHighlight = FALSE;
}
if ( pFace->uiFlags & FACE_SHOW_MOVING_HILIGHT )
{
pFace->fOldShowMoveHilight = TRUE;
}
else
{
pFace->fOldShowMoveHilight = FALSE;
}
if ( pSoldier->flags.fGettingHit && pSoldier->flags.fFlashPortrait == FLASH_PORTRAIT_STOP )
{
pSoldier->flags.fFlashPortrait = TRUE;
pSoldier->bFlashPortraitFrame = FLASH_PORTRAIT_STARTSHADE;
RESETTIMECOUNTER( pSoldier->timeCounters.PortraitFlashCounter, FLASH_PORTRAIT_DELAY );
fRerender = TRUE;
}
if ( pSoldier->flags.fFlashPortrait == FLASH_PORTRAIT_START )
{
// Loop through flash values
if ( TIMECOUNTERDONE( pSoldier->timeCounters.PortraitFlashCounter, FLASH_PORTRAIT_DELAY ) )
{
RESETTIMECOUNTER( pSoldier->timeCounters.PortraitFlashCounter, FLASH_PORTRAIT_DELAY );
pSoldier->bFlashPortraitFrame++;
if ( pSoldier->bFlashPortraitFrame > FLASH_PORTRAIT_ENDSHADE )
{
pSoldier->bFlashPortraitFrame = FLASH_PORTRAIT_ENDSHADE;
if ( pSoldier->flags.fGettingHit )
{
pSoldier->flags.fFlashPortrait = FLASH_PORTRAIT_WAITING;
}
else
{
// Render face again!
pSoldier->flags.fFlashPortrait = FLASH_PORTRAIT_STOP;
}
fRerender = TRUE;
}
}
}
// CHECK IF WE WERE WAITING FOR GETTING HIT TO FINISH!
if ( !pSoldier->flags.fGettingHit && pSoldier->flags.fFlashPortrait == FLASH_PORTRAIT_WAITING )
{
pSoldier->flags.fFlashPortrait = FALSE;
fRerender = TRUE;
}
if ( pSoldier->flags.fFlashPortrait == FLASH_PORTRAIT_START )
{
fRerender = TRUE;
}
if( pFace->uiFlags & FACE_REDRAW_WHOLE_FACE_NEXT_FRAME )
{
pFace->uiFlags &= ~FACE_REDRAW_WHOLE_FACE_NEXT_FRAME;
fRerender = TRUE;
}
if ( fInterfacePanelDirty == DIRTYLEVEL2 && guiCurrentScreen == GAME_SCREEN )
{
fRerender = TRUE;
}
if ( fRerender )
{
RenderAutoFace( uiCount );
}
if ( bLife < CONSCIOUSNESS )
{
fHandleFace = FALSE;
}
}
if ( fHandleFace )
{
BlinkAutoFace( uiCount );
}
MouthAutoFace( uiCount );
}
}
}
void HandleTalkingAutoFaces( )
{
UINT32 uiCount;
FACETYPE *pFace;
for ( uiCount = 0; uiCount < guiNumFaces; uiCount++ )
{
// OK, NOW, check if our bLife status has changed, re-render if so!
if ( gFacesData[ uiCount ].fAllocated )
{
pFace = &gFacesData[ uiCount ];
HandleTalkingAutoFace( uiCount );
}
}
}
BOOLEAN FaceRestoreSavedBackgroundRect( INT32 iFaceIndex, INT16 sDestLeft, INT16 sDestTop, INT16 sSrcLeft, INT16 sSrcTop, INT16 sWidth, INT16 sHeight )
{
FACETYPE *pFace;
UINT32 uiDestPitchBYTES, uiSrcPitchBYTES;
UINT8 *pDestBuf, *pSrcBuf;
// Check face index
CHECKF( iFaceIndex != -1 );
pFace = &gFacesData[ iFaceIndex ];
// DOn't continue if we do not want the resotre to happen ( ei blitting entrie thing every frame...
if ( pFace->uiAutoRestoreBuffer == FACE_NO_RESTORE_BUFFER )
{
return( FALSE );
}
pDestBuf = LockVideoSurface(pFace->uiAutoDisplayBuffer, &uiDestPitchBYTES);
pSrcBuf = LockVideoSurface( pFace->uiAutoRestoreBuffer, &uiSrcPitchBYTES);
Blt16BPPTo16BPP((UINT16 *)pDestBuf, uiDestPitchBYTES,
(UINT16 *)pSrcBuf, uiSrcPitchBYTES,
sDestLeft , sDestTop,
sSrcLeft , sSrcTop,
sWidth, sHeight);
UnLockVideoSurface(pFace->uiAutoDisplayBuffer);
UnLockVideoSurface(pFace->uiAutoRestoreBuffer);
// Add rect to frame buffer queue
if ( pFace->uiAutoDisplayBuffer == FRAME_BUFFER )
{
InvalidateRegionEx( sDestLeft - 2, sDestTop - 2, (sDestLeft + sWidth + 3), ( sDestTop + sHeight + 2 ), 0 );
}
return(TRUE);
}
BOOLEAN SetFaceTalking( INT32 iFaceIndex, CHAR8 *zSoundFile, STR16 zTextString,
UINT32 usRate, UINT32 ubVolume, UINT32 ubLoops, UINT32 uiPan )
{
FACETYPE *pFace;
pFace = &gFacesData[ iFaceIndex ];
// Set face to talking
pFace->fTalking = TRUE;
pFace->fAnimatingTalking = TRUE;
pFace->fFinishTalking = FALSE;
#ifdef JA2UB
//Ja25: No Meanwhiles
#else
if ( !AreInMeanwhile( ) )
{
TurnOnSectorLocator( pFace->ubCharacterNum );
}
#endif
// Play sample
if( gGameSettings.fOptions[ TOPTION_SPEECH ] )
pFace->uiSoundID = PlayJA2GapSample( zSoundFile, RATE_11025, HIGHVOLUME, 1, MIDDLEPAN, &(pFace->GapList ) );
else
pFace->uiSoundID = SOUND_ERROR;
if ( pFace->uiSoundID != SOUND_ERROR )
{
pFace->fValidSpeech = TRUE;
pFace->uiTalkingFromVeryBeginningTimer = GetJA2Clock( );
}
else
{
pFace->fValidSpeech = FALSE;
// Set delay based on sound...
pFace->uiTalkingTimer = pFace->uiTalkingFromVeryBeginningTimer = GetJA2Clock( );
pFace->uiTalkingDuration = FindDelayForString( zTextString );
}
return( TRUE );
}
BOOLEAN ExternSetFaceTalking( INT32 iFaceIndex, UINT32 uiSoundID )
{
FACETYPE *pFace;
pFace = &gFacesData[ iFaceIndex ];
// Set face to talki ng
pFace->fTalking = TRUE;
pFace->fAnimatingTalking = TRUE;
pFace->fFinishTalking = FALSE;
pFace->fValidSpeech = TRUE;
pFace->uiSoundID = uiSoundID;
return( TRUE );
}
void InternalShutupaYoFace( INT32 iFaceIndex, BOOLEAN fForce )
{
FACETYPE *pFace;
// Check face index
CHECKV( iFaceIndex != -1 );
pFace = &gFacesData[ iFaceIndex ];
if ( pFace->fTalking )
{
// OK, only do this if we have been talking for a min. amount fo time...
if ( ( GetJA2Clock( ) - pFace->uiTalkingFromVeryBeginningTimer ) < 500 && !fForce )
{
return;
}
if ( pFace->uiSoundID != SOUND_ERROR )
{
SoundStop( pFace->uiSoundID );
}
// Remove gap info
AudioGapListDone( &(pFace->GapList) );
// Shutup mouth!
pFace->sMouthFrame = 0;
// ATE: Only change if active!
if ( !pFace->fDisabled )
{
if ( pFace->uiAutoRestoreBuffer == guiSAVEBUFFER )
{
FaceRestoreSavedBackgroundRect( iFaceIndex, pFace->usMouthX, pFace->usMouthY, pFace->usMouthX, pFace->usMouthY, pFace->usMouthWidth, pFace->usMouthHeight );
}
else
{
FaceRestoreSavedBackgroundRect( iFaceIndex, pFace->usMouthX, pFace->usMouthY, pFace->usMouthOffsetX, pFace->usMouthOffsetY, pFace->usMouthWidth, pFace->usMouthHeight );
}
}
// OK, smart guy, make sure this guy has finished talking,
// before attempting to end dialogue UI.
pFace->fTalking = FALSE;
// Call dialogue handler function
HandleDialogueEnd( pFace );
pFace->fTalking = FALSE;
pFace->fAnimatingTalking = FALSE;
gfUIWaitingForUserSpeechAdvance = FALSE;
}
}
void ShutupaYoFace( INT32 iFaceIndex )
{
InternalShutupaYoFace( iFaceIndex, TRUE );
}
void SetupFinalTalkingDelay( FACETYPE *pFace )
{
pFace->fFinishTalking = TRUE;
pFace->fAnimatingTalking = FALSE;
pFace->uiTalkingTimer = GetJA2Clock( );
if ( gGameSettings.fOptions[ TOPTION_SUBTITLES ] )
{
//pFace->uiTalkingDuration = FINAL_TALKING_DURATION;
pFace->uiTalkingDuration = 300;
}
else
{
pFace->uiTalkingDuration = 300;
}
pFace->sMouthFrame = 0;
// Close mouth!
if ( !pFace->fDisabled )
{
if ( pFace->uiAutoRestoreBuffer == guiSAVEBUFFER )
{
FaceRestoreSavedBackgroundRect( pFace->iID, pFace->usMouthX, pFace->usMouthY, pFace->usMouthX, pFace->usMouthY, pFace->usMouthWidth, pFace->usMouthHeight );
}
else
{
FaceRestoreSavedBackgroundRect( pFace->iID, pFace->usMouthX, pFace->usMouthY, pFace->usMouthOffsetX, pFace->usMouthOffsetY, pFace->usMouthWidth, pFace->usMouthHeight );
}
}
// Setup flag to wait for advance ( because we have no text! )
if ( gGameSettings.fOptions[ TOPTION_KEY_ADVANCE_SPEECH ] && ( pFace->uiFlags & FACE_POTENTIAL_KEYWAIT ) )
{
// Check if we have had valid speech!
if ( !pFace->fValidSpeech || gGameSettings.fOptions[ TOPTION_SUBTITLES ] )
{
// Set false!
pFace->fFinishTalking = FALSE;
// Set waiting for advance to true!
gfUIWaitingForUserSpeechAdvance = TRUE;
}
}
// Set final delay!
pFace->fValidSpeech = FALSE;
}
| [
"jazz_ja@b41f55df-6250-4c49-8e33-4aa727ad62a1"
]
| [
[
[
1,
3014
]
]
]
|
bd06afcbf2e2c904fee2dbbfccff902c3cba51b3 | ed41104173ed37bcec9d4c4d6d7537d0c329fdd3 | /MC Tetris/Board.h | e98cd03f66706bff35c54391f87bf105c69f7733 | [
"CC-BY-3.0"
]
| permissive | abajwa/Tetris | 13959449022dcac9cfbe7b9bf39247360749b074 | 1b3cb26c066445b961a2dbe3fa90acf10cfa6cd8 | refs/heads/master | 2021-01-01T17:27:08.436031 | 2011-12-07T06:08:45 | 2011-12-07T06:08:45 | 2,699,305 | 0 | 0 | null | null | null | null | WINDOWS-1250 | C++ | false | false | 2,447 | h | /*****************************************************************************************
/* File: Board.h
/* Desc: Board of the game. A matrix of n x n holes.
/*
/* gametuto.com - Javier López López (javilop.com)
/*
/*****************************************************************************************
/*
/* Creative Commons - Attribution 3.0 Unported
/* You are free:
/* to Share — to copy, distribute and transmit the work
/* to Remix — to adapt the work
/*
/* Under the following conditions:
/* Attribution. You must attribute the work in the manner specified by the author or licensor
/* (but not in any way that suggests that they endorse you or your use of the work).
/*
/*****************************************************************************************/
#ifndef _BOARD_
#define _BOARD_
// ------ Includes -----
#include "Pieces.h"
// ------ Defines -----
#define BOARD_LINE_WIDTH 6 // Width of each of the two lines that delimit the board
#define BLOCK_SIZE 16 // Width and Height of each block of a piece
#define BOARD_POSITION 320 // Center position of the board from the left of the screen
#define BOARD_WIDTH 10 // Board width in blocks
#define BOARD_HEIGHT 20 // Board height in blocks
#define MIN_VERTICAL_MARGIN 20 // Minimum vertical margin for the board limit
#define MIN_HORIZONTAL_MARGIN 20 // Minimum horizontal margin for the board limit
#define PIECE_BLOCKS 5 // Number of horizontal and vertical blocks of a matrix piece
// --------------------------------------------------------------------------------
// Board
// --------------------------------------------------------------------------------
class Board
{
public:
Board (Pieces *pPieces, int pScreenHeight);
int GetXPosInPixels (int pPos);
int GetYPosInPixels (int pPos);
bool IsFreeBlock (int pX, int pY);
bool IsPossibleMovement (int pX, int pY, int pPiece, int pRotation);
void StorePiece (int pX, int pY, int pPiece, int pRotation);
int DeletePossibleLines ();
bool IsGameOver ();
int rowsDeleted;
private:
enum { POS_FREE, POS_FILLED }; // POS_FREE = free position of the board; POS_FILLED = filled position of the board
int mBoard [BOARD_WIDTH][BOARD_HEIGHT]; // Board that contains the pieces
Pieces *mPieces;
int mScreenHeight;
void InitBoard();
void DeleteLine (int pY);
};
#endif // _BOARD_
| [
"[email protected]"
]
| [
[
[
1,
68
]
]
]
|
66a71d05a873fcd7b7f830e124236ebb0892f4e6 | cd387cba6088f351af4869c02b2cabbb678be6ae | /src/electronic/include/i2c_devices.h | ffe8d400ebb46b7c05991e754ef85d30931bd89c | []
| no_license | pedromartins/mew-dev | e8a9cd10f73fbc9c0c7b5bacddd0e7453edd097e | e6384775b00f76ab13eb046509da21d7f395909b | refs/heads/master | 2016-09-06T14:57:00.937033 | 2009-04-13T15:16:15 | 2009-04-13T15:16:15 | 32,332,332 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,707 | h | /*
* i2c_devices.h
*
* This file contains object-oriented wrappers for the i2c device API.
*
* Created on: 15-Feb-2009
* Author: Hok Shun Poon
*/
#ifndef I2C_DEVICES_H_
#define I2C_DEVICES_H_
#include "electronic.h"
/**
* I2CMotor
*
* Represents a I2CMotor with encoder.
*/
class I2CMotor : public IMotor {
public:
I2CMotor(int motor_number) : id(motor_number){}
bool hasEncoder() { return true; }
float getRPM() { return get_motor_speed(id); }
void setRPM(float rpm) { set_motor_speed(rpm); }
float getMaxSpeed() {
return get_motor_max_speed(id);
}
float getMaxAngularAcceleration() {
return get_motor_max_angular_acceleration(id);
}
private:
int id;
};
/**
* I2CCompass
*
* Represents a I2CCompass, from which you could get a reading of the orientation.
*/
class I2CCompass : public IOrientator {
public:
I2CCompass(){}
virtual ~I2CCompass(){};
float getReading() { return get_compass_reading(); }
};
/**
* TODO I2CInfrared(Array)
*/
class I2CInfrared {
public:
I2CInfrared(ir_t direction):dir(direction){}
virtual ~I2CInfrared(){};
float getReading() { return get_ir_reading(dir); }
private:
ir_t dir;
};
/**
* TODO I2CUltrasound(Array)
* Could be used as a ILocator.
*/
class I2CUltrasound {
public:
I2CUltrasound(ultrasound_t direction): dir(direction) {}
virtual ~I2CInfrared(){};
float getReading() { return get_ultrasound_reading(dir); }
private:
ultrasound_t dir;
};
/**
* TODO I2CClaw
* Provide useful high-level functions.
*/
class I2CClaw {
public:
I2CClaw(){}
virtual ~I2CInfrared(){};
private:
};
#endif /* I2C_DEVICES_H_ */
| [
"fushunpoon@1fd432d8-e285-11dd-b2d9-215335d0b316"
]
| [
[
[
1,
96
]
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.