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
316b3a70374cc0470cd15874d15d8b85eac465a3
3533c9f37def95dcc9d6b530c59138f7570ca239
/guCORE/include/guCORE_ETypes.h
7c9cadacfb7ee5ccaedbbfe5fb60637b81d0eaa0
[]
no_license
LiberatorUSA/GU
7e8af0dccede7edf5fc9c96c266b9888cff6d76e
2493438447e5cde3270e1c491fe2a6094dc0b4dc
refs/heads/master
2021-01-01T18:28:53.809051
2011-06-04T00:12:42
2011-06-04T00:12:42
41,840,823
0
0
null
null
null
null
UTF-8
C++
false
false
5,693
h
/* * guCORE: Main module of the Galaxy Unlimited system * Copyright (C) 2002 - 2008. Dinand Vanvelzen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef GU_CORE_ETYPES_H #define GU_CORE_ETYPES_H /*-------------------------------------------------------------------------// // // // INCLUDES // // // //-------------------------------------------------------------------------*/ #ifndef GUCEF_CORE_ETYPES_H #include "gucefCORE_ETypes.h" /* GUCEF::CORE types are imported */ #define GUCEF_CORE_ETYPES_H #endif /* GUCEF_CORE_ETYPES_H ? */ #ifndef GUCEF_CORE_CDVSTRING_H #include "CDVString.h" #define GUCEF_CORE_CDVSTRING_H #endif /* GUCEF_CORE_CDVSTRING_H ? */ /*-------------------------------------------------------------------------// // // // CONSTANTS // // // //-------------------------------------------------------------------------*/ /* * Maximum and minimal values for the simple types which we are about to * define. */ #define GUCORE_INT8MAX GUCEFCORE_INT8MAX #define GUCORE_INT8MIN GUCEFCORE_INT8MIN #define GUCORE_UINT8MAX GUCEFCORE_UINT8MAX #define GUCORE_UINT8MIN GUCEFCORE_UINT8MIN #define GUCORE_INT16MAX GUCEFCORE_INT16MAX #define GUCORE_INT16MIN GUCEFCORE_INT16MIN #define GUCORE_UINT16MAX GUCEFCORE_UINT16MAX #define GUCORE_UINT16MIN GUCEFCORE_UINT16MIN #define GUCORE_INT32MAX GUCEFCORE_INT32MAX #define GUCORE_INT32MIN GUCEFCORE_INT32MIN #define GUCORE_UINT32MAX GUCEFCORE_UINT32MAX #define GUCORE_UINT32MIN GUCEFCORE_UINT32MIN #define GUCORE_FLOAT32MAX GUCEFCORE_FLOAT32MAX #define GUCORE_FLOAT32MIN GUCEFCORE_FLOAT32MIN /*--------------------------------------------------------------------------*/ /* * We only have to define types when using C++ due to namespacing * For C the gucefCORE versions are automaticly used in the global namespace */ #ifdef __cplusplus /*-------------------------------------------------------------------------// // // // NAMESPACE // // // //-------------------------------------------------------------------------*/ namespace GU { namespace CORE { /*-------------------------------------------------------------------------// // // // TYPES // // // //-------------------------------------------------------------------------*/ typedef GUCEF::CORE::UInt8 UInt8; /* 1 byte, unsigned */ typedef GUCEF::CORE::Int8 Int8; /* 1 byte, signed */ typedef GUCEF::CORE::UInt16 UInt16; /* 2 bytes, unsigned */ typedef GUCEF::CORE::Int16 Int16; /* 2 bytes, signed */ typedef GUCEF::CORE::UInt32 UInt32; /* 4 bytes, unsigned */ typedef GUCEF::CORE::Int32 Int32; /* 4 bytes, signed */ typedef GUCEF::CORE::Int64 Int64; /* 8 bytes, signed */ typedef GUCEF::CORE::UInt64 UInt64; /* 8 bytes, unsigned */ typedef GUCEF::CORE::Float32 Float32; /* 4 bytes, signed, decimal */ typedef GUCEF::CORE::Float64 Float64; /* 8 bytes, signed, decimal */ typedef GUCEF::CORE::CString CString; /*-------------------------------------------------------------------------// // // // NAMESPACE // // // //-------------------------------------------------------------------------*/ }; /* namespace CORE */ }; /* namespace GU */ /*--------------------------------------------------------------------------*/ #endif /* __cplusplus ? */ #endif /* GU_CORE_ETYPES_H ? */ /*-------------------------------------------------------------------------// // // // Info & Changes // // // //-------------------------------------------------------------------------// - 31-12-2004 : - Dinand: Added this section -----------------------------------------------------------------------------*/
[ [ [ 1, 127 ] ] ]
d0db31c5454a96904012fdfb52a3c50e848b6062
bbc02822aeffdfaa8050907c1d9bd41ff4e9f3f3
/MinecraftPSP/MinecraftPSP/FileManager.cpp
ea670fe39175835de9581290885cba3b63201a23
[]
no_license
DragonNeos/minecraft-psp
5184361c0beab2a4a25d789ba24a5cf185ef18cf
fde4e012c8ecc94f52bf222738f29e5efac47d0e
refs/heads/master
2020-03-26T15:06:44.654834
2011-03-01T09:38:49
2011-03-01T09:38:49
40,795,370
0
0
null
null
null
null
UTF-8
C++
false
false
1,280
cpp
//Author: David Kilford & Mouhamad Abdallah //Date: Wedsday 12th January 2011 //Description: Class for text IO (mainly for savegames but could be used for configuration files) //Modification: Renaming and organising class to perform a better use //Author: David Kilford & Mouhamad Abdallah //Date: Wednesday 12th January 2011 //Description: Loads and saves files //Modification: Renaming and organising class to perform a better use - Monday 17th January 2010 #include <stdio.h> #include <stdlib.h> #include "FileManager.h" FileManager::FileManager() { } void FileManager::saveFile(char* filepath, char *bufferData) //Saves the buffer information into the given file path { FILE * pFile; pFile = fopen (filepath , "w"); fwrite (bufferData , 1 , 29 , pFile); fclose (pFile); } char* FileManager::loadFile(char* filepath) //Loads the file from a path and returns a buffer of data { FILE * pFile; long lSize; char * buffer; pFile = fopen ( filepath, "rb" ); if (pFile==NULL) exit (1); fseek (pFile , 0 , SEEK_END); lSize = ftell (pFile); rewind (pFile); buffer = (char*) malloc (lSize); if (buffer == NULL) exit (2); fread (buffer,1,lSize,pFile); fclose (pFile); return buffer; }
[ [ [ 1, 50 ] ] ]
986c95b0e1c40a7e9c7510805fffa2f6ac6ceee2
444a151706abb7bbc8abeb1f2194a768ed03f171
/trunk/ENIGMAsystem/SHELL/Platforms/Win32/file_manip.cpp
4ce8d782b23b9691a7d83f6d1a89c025b0687e28
[]
no_license
amorri40/Enigma-Game-Maker
9d01f70ab8de42f7c80af9a0f8c7a66e412d19d6
c6b701201b6037f2eb57c6938c184a5d4ba917cf
refs/heads/master
2021-01-15T11:48:39.834788
2011-11-22T04:09:28
2011-11-22T04:09:28
1,855,342
1
1
null
null
null
null
UTF-8
C++
false
false
6,270
cpp
/********************************************************************************\ ** ** ** Copyright (C) 2008 Josh Ventura ** ** ** ** This file is a part of the ENIGMA Development Environment. ** ** ** ** ** ** ENIGMA is free software: you can redistribute it and/or modify it under the ** ** terms of the GNU General Public License as published by the Free Software ** ** Foundation, version 3 of the license or any later version. ** ** ** ** This application and its source code is distributed AS-IS, WITHOUT ANY ** ** WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ** ** FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ** ** details. ** ** ** ** You should have recieved a copy of the GNU General Public License along ** ** with this code. If not, see <http://www.gnu.org/licenses/> ** ** ** ** ENIGMA is an environment designed to create games and other programs with a ** ** high-level, fully compilable language. Developers of ENIGMA or anything ** ** associated with ENIGMA are in no way responsible for its users or ** ** applications created by its users, or damages caused by the environment ** ** or programs made in the environment. ** ** ** \********************************************************************************/ #include <string> #include <windows.h> using namespace std; /* OS Specific; should be moved */ int file_exists(std::string fname) { DWORD attributes = GetFileAttributes(fname.c_str()); if(attributes == 0xFFFFFFFF) { return 0; } else { return 1; } } int file_delete(std::string fname) { DWORD result = DeleteFileA(fname.c_str()); switch(result) { case 0: return 0; break; case ERROR_FILE_NOT_FOUND: return 0; break; case ERROR_ACCESS_DENIED: return 0; break; default: return 1; break; } } int file_rename(std::string oldname, std::string newname) { DWORD result = MoveFileA(oldname.c_str(), newname.c_str()); switch(result) { case 0: return 0; break; default: return 1; break; } } int file_copy(std::string fname, std::string newname) { DWORD result = CopyFileA(fname.c_str(), newname.c_str(), false); switch(result) { case 0: return 0; break; default: return 1; break; } } int directory_exists(std::string dname); // NOTICE: May behave differently than GM. May fail if there are // directories in the path missing, whereas GM would create them all int directory_create(std::string dname) { DWORD result = CreateDirectoryA(dname.c_str(), NULL); switch(result) { case 0: return 0; break; case ERROR_ALREADY_EXISTS: return 0; break; case ERROR_PATH_NOT_FOUND: return 0; break; default: return 1; break; } } // Maintainer: If this segment errors, it is an error of philosophy. // The Game Maker constants do not have a standard, but line up with // their Windows equivalents. Should either change, we have an issue. enum { fa_readonly = FILE_ATTRIBUTE_READONLY, fa_hidden = FILE_ATTRIBUTE_HIDDEN, fa_sysfile = FILE_ATTRIBUTE_SYSTEM, fa_volumeid = 0x00000008, fa_directory = FILE_ATTRIBUTE_DIRECTORY, fa_archive = FILE_ATTRIBUTE_ARCHIVE }; static int ff_attribs = 0; static HANDLE current_find = INVALID_HANDLE_VALUE; static WIN32_FIND_DATA found; string file_find_first(string name,int attributes) { if (current_find != INVALID_HANDLE_VALUE) { FindClose(current_find); current_find=INVALID_HANDLE_VALUE; } ff_attribs=attributes; HANDLE d=FindFirstFile(name.c_str(),&found); if (d==INVALID_HANDLE_VALUE) return ""; while (found.dwFileAttributes!=FILE_ATTRIBUTE_NORMAL and !(ff_attribs^found.dwFileAttributes)) { if (FindNextFile(d,&found)==0) return ""; } current_find=d; return found.cFileName; } string file_find_next() { if (current_find==INVALID_HANDLE_VALUE) return ""; if (FindNextFile(current_find,&found)==0) return ""; while (found.dwFileAttributes!=FILE_ATTRIBUTE_NORMAL and !(ff_attribs^found.dwFileAttributes)) { if (FindNextFile(current_find,&found)==0) return ""; } return found.cFileName; } int file_find_close() { FindClose(current_find); return 0; } bool file_attributes(std::string fname,int attr); std::string filename_name(std::string fname); std::string filename_path(std::string fname); std::string filename_dir(std::string fname); std::string filename_drive(std::string fname); std::string filename_ext(std::string fname); std::string filename_change_ext(std::string fname,std::string newext); void export_include_file(std::string fname); void export_include_file_location(std::string fname,std::string location); void discard_include_file(std::string fname); extern unsigned game_id; extern std::string working_directory; extern std::string program_directory; extern std::string temp_directory; int parameter_count(); string parameter_string(int n); string environment_get_variable(std::string name);
[ [ [ 1, 187 ] ] ]
1ea1f2b468fb2423887170fedcb81025f7a3f6a8
d22b77645ee83ee72fed70cb2a3ca4fb268ada4a
/common/charls/losslesstraits.h
eec1ae708a94aac72877dce57a299821574d23e9
[]
no_license
catid/Splane
8f94f7d8983cf994955e599fc53ce6f763157486
c9f79f0034d1762948b7c26e42f50f58793067ac
refs/heads/master
2020-04-26T00:28:48.571474
2010-06-02T05:37:43
2010-06-02T05:37:43
628,653
1
0
null
null
null
null
UTF-8
C++
false
false
2,814
h
// // (C) Jan de Vaan 2007-2009, all rights reserved. See the accompanying "License.txt" for licensed use. // #ifndef CHARLS_LOSSLESSTRAITS #define CHARLS_LOSSLESSTRAITS // // optimized trait classes for lossless compression of 8 bit color and 8/16 bit monochrome images. // This class is assumes MAXVAL correspond to a whole number of bits, and no custom RESET value is set when encoding. // The point of this is to have the most optimized code for the most common and most demanding scenario. template <class sample, LONG bitsperpixel> struct LosslessTraitsImplT { typedef sample SAMPLE; enum { NEAR = 0, bpp = bitsperpixel, qbpp = bitsperpixel, RANGE = (1 << bpp), MAXVAL= (1 << bpp) - 1, LIMIT = 2 * (bitsperpixel + MAX(8,bitsperpixel)), RESET = BASIC_RESET }; static inlinehint LONG ComputeErrVal(LONG d) { return ModRange(d); } static inlinehint bool IsNear(LONG lhs, LONG rhs) { return lhs == rhs; } static inlinehint LONG ModRange(LONG Errval) { return LONG(Errval << (LONG_BITCOUNT - bpp)) >> (LONG_BITCOUNT - bpp); } static inlinehint SAMPLE ComputeReconstructedSample(LONG Px, LONG ErrVal) { return SAMPLE(MAXVAL & (Px + ErrVal)); } static inlinehint LONG CorrectPrediction(LONG Pxc) { if ((Pxc & MAXVAL) == Pxc) return Pxc; return (~(Pxc >> (LONG_BITCOUNT-1))) & MAXVAL; } }; template <class SAMPLE, LONG bpp> struct LosslessTraitsT : public LosslessTraitsImplT<SAMPLE, bpp> { typedef SAMPLE PIXEL; }; template<> struct LosslessTraitsT<BYTE,8> : public LosslessTraitsImplT<BYTE, 8> { typedef SAMPLE PIXEL; static inlinehint signed char ModRange(LONG Errval) { return (signed char)Errval; } static inlinehint LONG ComputeErrVal(LONG d) { return (signed char)(d); } static inlinehint BYTE ComputeReconstructedSample(LONG Px, LONG ErrVal) { return BYTE(Px + ErrVal); } }; template<> struct LosslessTraitsT<USHORT,16> : public LosslessTraitsImplT<USHORT,16> { typedef SAMPLE PIXEL; static inlinehint short ModRange(LONG Errval) { return short(Errval); } static inlinehint LONG ComputeErrVal(LONG d) { return short(d); } static inlinehint SAMPLE ComputeReconstructedSample(LONG Px, LONG ErrVal) { return SAMPLE(Px + ErrVal); } }; template<class SAMPLE, LONG bpp> struct LosslessTraitsT<Triplet<SAMPLE>,bpp> : public LosslessTraitsImplT<SAMPLE,bpp> { typedef Triplet<SAMPLE> PIXEL; static inlinehint bool IsNear(LONG lhs, LONG rhs) { return lhs == rhs; } static inlinehint bool IsNear(PIXEL lhs, PIXEL rhs) { return lhs == rhs; } static inlinehint SAMPLE ComputeReconstructedSample(LONG Px, LONG ErrVal) { return SAMPLE(Px + ErrVal); } }; #endif
[ "kuang@.(none)" ]
[ [ [ 1, 118 ] ] ]
e91e624e3f27a28988716130ca9dcc842a5b2d66
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/mpl/preprocessed/src/less_equal.cpp
fcf529a964a9bf83f0ba7375f23fda8aa8941351
[ "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
514
cpp
// Copyright Aleksey Gurtovoy 2002-2004 // // 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/libs/mpl for documentation. // $Source: /cvsroot/boost/boost/libs/mpl/preprocessed/src/less_equal.cpp,v $ // $Date: 2006/06/12 05:11:54 $ // $Revision: 1.3.8.1 $ #define BOOST_MPL_PREPROCESSING_MODE #include <boost/config.hpp> #include <boost/mpl/less_equal.hpp>
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 16 ] ] ]
e044bb0e1e131bcbeac0f5a4560aaf3035f3365e
c4001da8f012dfbc46fef0d9c11f8412f4ad9c6f
/allegro/demos/a5teroids/src/GUI.cpp
1f3c16f6b416c15e63a52263e907a705136339d2
[ "Zlib", "BSD-3-Clause" ]
permissive
sesc4mt/mvcdecoder
4602fdfe42ab39706cfa3c749282782ca9da73c9
742a5c0d9cad43f0b01aa6e9169d96a286458e72
refs/heads/master
2021-01-01T17:56:47.666505
2010-11-02T12:36:52
2010-11-02T12:36:52
40,896,775
1
0
null
null
null
null
UTF-8
C++
false
false
2,103
cpp
#include "a5teroids.hpp" int do_gui(std::vector<Widget *>& widgets, unsigned int selected) { ResourceManager& rm = ResourceManager::getInstance(); ALLEGRO_BITMAP *bg = (ALLEGRO_BITMAP *)rm.getData(RES_BACKGROUND); Input *input = (Input *)rm.getData(RES_INPUT); ALLEGRO_BITMAP *logo = (ALLEGRO_BITMAP *)rm.getData(RES_LOGO); int lw = al_get_bitmap_width(logo); int lh = al_get_bitmap_height(logo); ALLEGRO_FONT *myfont = (ALLEGRO_FONT *)rm.getData(RES_SMALLFONT); for (;;) { input->poll(); float ud = input->ud(); if (ud < 0 && selected) { selected--; my_play_sample(RES_FIRELARGE); al_rest(0.200); } else if (ud > 0 && selected < (widgets.size()-1)) { selected++; my_play_sample(RES_FIRELARGE); al_rest(0.200); } if (input->b1()) { if (!widgets[selected]->activate()) return selected; } if (input->esc()) return -1; al_draw_scaled_bitmap(bg, 0, 0, al_get_bitmap_width(bg), al_get_bitmap_height(bg), 0, 0, BB_W, BB_H, 0); al_draw_rotated_bitmap(logo, lw/2, lh/2, BB_W/2, BB_H/4, 0.0f, 0); al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, al_map_rgb(255, 255, 0)); al_draw_textf(myfont, BB_W/2, BB_H/2, ALLEGRO_ALIGN_CENTRE, "z/y to start"); al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, al_map_rgb(255, 255, 255)); for (unsigned int i = 0; i < widgets.size(); i++) { widgets[i]->render(i == selected); } al_flip_display(); al_rest(0.010); } } int do_menu(void) { ButtonWidget *play = new ButtonWidget(BB_W/2, BB_H/4*3-16, true, "PLAY"); ButtonWidget *end = new ButtonWidget(BB_W/2, BB_H/4*3+16, true, "EXIT"); std::vector<Widget *> widgets; widgets.push_back(play); widgets.push_back(end); int ret = do_gui(widgets, 0); delete play; delete end; widgets.clear(); return ret; }
[ "edwardtoday@34199c9c-95aa-5eba-f35a-9ba8a8a04cd7" ]
[ [ [ 1, 69 ] ] ]
ffcacddac2ff319bf302960abef320d5bf163919
1092bd6dc9b728f3789ba96e37e51cdfb9e19301
/loci/video/d3d9/managed_vertex_buffer.cpp
789104c7c239fd0019b3c6160c932e9402aa440e
[]
no_license
dtbinh/loci-extended
772239e63b4e3e94746db82d0e23a56d860b6f0d
f4b5ad6c4412e75324d19b71559a66dd20f4f23f
refs/heads/master
2021-01-10T12:23:52.467480
2011-03-15T22:03:06
2011-03-15T22:03:06
36,032,427
0
0
null
null
null
null
UTF-8
C++
false
false
1,822
cpp
/** * Implementation of a managed_vertex_buffer. * Encapsulates a d3d9 vertex buffer, providing RAII. * * @file managed_vertex_buffer.cpp * @author David Gill * @date 06/11/2009 */ #include <algorithm> #include <boost/shared_ptr.hpp> #include <d3d9.h> #include "loci/video/d3d9/managed_vertex_buffer.h" #include "loci/video/d3d9/device_services.h" #include "loci/video/d3d9/d3d_error.h" namespace loci { namespace video { namespace d3d9 { managed_vertex_buffer::managed_vertex_buffer(const boost::shared_ptr<device_services> & device, unsigned int bytes) : device(device) { device->allocate_vertex_buffer(buffer, bytes, false, 0, D3DPOOL_MANAGED); } managed_vertex_buffer::~managed_vertex_buffer() { buffer->Release(); } void managed_vertex_buffer::update(const void * vertices, unsigned int bytes) { void * data; map(data); const char * source = reinterpret_cast<const char *>(vertices); char * destination = reinterpret_cast<char *>(data); std::copy(source, source + bytes, destination); unmap(); } void managed_vertex_buffer::bind(unsigned int stride, DWORD fvf) { device->bind_fvf(fvf); device->bind_vertex_buffer(buffer, stride); } void managed_vertex_buffer::map(void *& destination) { HRESULT r = buffer->Lock(0, 0, &destination, 0); check_failure(r, "Failed to map vertex buffer", "Lock"); } void managed_vertex_buffer::unmap() { HRESULT r = buffer->Unlock(); check_failure(r, "Failed to unmap vertex buffer", "UnLock"); } } // namespace d3d9 } // namespace video } // namespace loci
[ "[email protected]@0e8bac56-0901-9d1a-f0c4-3841fc69e132" ]
[ [ [ 1, 67 ] ] ]
1ae24fbf142fd870954012099e0418bebe02fca3
8e4d21a99d0ce5413eab7a083544aff9f944b26f
/src/NthText.cpp
2c1412ea73c07b05198b4974faadd71abd01a11e
[]
no_license
wangjunbao/nontouchsdk
957612b238b8b221b4284efb377db220bd41186a
81ab8519ea1af45dbb7ff66c6784961f14f9930c
refs/heads/master
2021-01-23T13:57:20.020732
2010-10-31T12:03:49
2010-10-31T12:03:49
34,656,556
0
0
null
null
null
null
UTF-8
C++
false
false
254
cpp
/* * NthText.cpp * CopyRight @South China Institute of Software Engineering,.GZU * Author: * 2010/10/20 */ #ifndef DLL_FILE #define DLL_FILE #endif #include "NthText.h" NthText::NthText(void) { } NthText::~NthText(void) { }
[ "tinya0913@6b3f5b0f-ac10-96f7-b72e-cc4b20d3e213" ]
[ [ [ 1, 20 ] ] ]
be9fef7b561170829a2849bda43918d21c548f68
b90f7dce513fd3d13bab0b8769960dea901d4f3b
/game_client/game_client/ServerGame.cpp
6cb229a0d10bda044f91c58e1776e3e6f7860f3c
[]
no_license
lasti15/easygametools
f447052cd4c42609955abd76b4c8571422816b11
0b819c957077a4eeaf9a2492772040dafdfca4c3
refs/heads/master
2021-01-10T09:14:52.182154
2011-03-09T01:51:51
2011-03-09T01:51:51
55,684,684
0
0
null
null
null
null
UTF-8
C++
false
false
3,159
cpp
#include "ServerGame.h" #include "UserList.h" using namespace ROG; const static Logger* logger = Logger::getLogger("ServerGame"); void ServerGame::loadFromReader(irr::io::IrrXMLReader* reader) { logger->info("load XMl from reader"); char* nodeName = NULL; char nodeNameBuf[255]; do { irr::io::EXML_NODE nodeType = reader->getNodeType(); switch (nodeType) { case irr::io::EXN_COMMENT: case irr::io::EXN_ELEMENT_END: case irr::io::EXN_NONE: break; case irr::io::EXN_TEXT: if (nodeName == NULL || nodeName[0] < 33) { nodeName = NULL; continue; } if (strncmp(nodeName, "hostName", 8) == 0) { this->hostName = strdup((char*)reader->getNodeData()); logger->debug("found hostName"); continue; } if (strncmp(nodeName, "hostPort", 8) == 0) { this->hostPort = atoi((char*)reader->getNodeData()); logger->debug("found hostPort"); continue; } if (strncmp(nodeName, "lastUpdate", 10) == 0) { this->lastUpdate = atol((char*)reader->getNodeData()); logger->debug("found lastUpdate"); continue; } if (strncmp(nodeName, "numberOfPlayers", 15) == 0) { this->numberOfPlayers = atoi((char*)reader->getNodeData()); logger->debug("found numberOfPlayers"); continue; } if (strncmp(nodeName, "maxPlayers", 10) == 0) { this->maxPlayers = atoi((char*)reader->getNodeData()); logger->debug("found maxPlayers"); continue; } if (strncmp(nodeName, "hostGuid", 10) == 0) { this->hostGuid = strdup((char*)reader->getNodeData()); logger->debug("found hostGuid"); continue; } break; case irr::io::EXN_ELEMENT: nodeName = (char*)reader->getNodeName(); if (nodeName == NULL || nodeName[0] < 33) { nodeName = NULL; continue; } int nodeNameLen = strlen(nodeName); strncpy(nodeNameBuf, nodeName, nodeNameLen); nodeNameBuf[nodeNameLen] = 0; nodeName = nodeNameBuf; if (strncmp(nodeName, "game", strlen(nodeName)) == 0) { //get the user id attribute for (unsigned int i=0; i<reader->getAttributeCount(); i++) { const char* attrName = reader->getAttributeName(i); if (attrName != NULL || attrName[0] < 33) { if (strncmp("id", attrName, 2) == 0) { //we found the right attribute this->gameId = atol((char*)reader->getAttributeValue(attrName)); logger->debug("found GameId"); } } } continue; } if (strncmp(nodeName, "hostUser", strlen(nodeName)) == 0) { logger->debug("Found User node"); Object<User> user = new User(); user->loadFromReader(reader); this->hostUser = user; continue; } if (strncmp(nodeName, "players", strlen(nodeName)) == 0) { logger->debug("Found PLAYERS node"); Object<UserList> list = new UserList(); list->loadFromReader(reader); this->players.clear(); this->players = list->getUserList(); continue; } break; } } while (reader->read()); }
[ [ [ 1, 119 ] ] ]
32e84ec7aaa706173f9c3417574221a7816b2d16
c2153dcfa8bcf5b6d7f187e5a337b904ad9f91ac
/src/Engine/Script/ExposeGuiEventParams.cpp
029b6e7b204be971c8e9386047328a17f94d5fc9
[]
no_license
ptrefall/smn6200fluidmechanics
841541a26023f72aa53d214fe4787ed7f5db88e1
77e5f919982116a6cdee59f58ca929313dfbb3f7
refs/heads/master
2020-08-09T17:03:59.726027
2011-01-13T22:39:03
2011-01-13T22:39:03
32,448,422
1
0
null
null
null
null
UTF-8
C++
false
false
3,440
cpp
#include "precomp.h" #include "ExposeGuiEventParams.h" #include "ExposeEvent.h" #include <Core/CoreMgr.h> #include <Gui/GuiMgr.h> #include "ScriptMgr.h" using namespace Engine; using namespace LuaPlus; ExposeGuiEventParams::ExposeGuiEventParams(CoreMgr *coreMgr, ExposeEvent &e_event, Rocket::Core::Event& event) : e_event(e_event), event(event) { this->coreMgr = coreMgr; init(); } ExposeGuiEventParams::~ExposeGuiEventParams() { } void ExposeGuiEventParams::init() { LuaObject globals = (*coreMgr->getScriptMgr()->GetGlobalState())->GetGlobals(); LuaObject &lEvent = e_event.getLEvent(); lParams = lEvent.CreateTable("Parameters"); const Rocket::Core::Dictionary *params = event.GetParameters(); if(params == NULL || params->Size() <= 0) return; for(int i = 0; i < params->Size(); i++) { LuaObject lParam; Rocket::Core::String param_name; int pos = i; Rocket::Core::Variant *v; params->Iterate(pos, param_name, v); Rocket::Core::Variant::Type type = v->GetType(); if(type == Rocket::Core::Variant::BYTE) { Rocket::Core::byte value = v->Get<Rocket::Core::byte>(); lParam.AssignInteger(coreMgr->getScriptMgr()->GetGlobalState()->Get(), (int)value); } else if(type == Rocket::Core::Variant::CHAR) { char value = v->Get<char>(); lParam.AssignInteger(coreMgr->getScriptMgr()->GetGlobalState()->Get(), (int)value); } else if(type == Rocket::Core::Variant::COLOURB) { Rocket::Core::Colourb value = v->Get<Rocket::Core::Colourb>(); lParam.AssignNewTable(coreMgr->getScriptMgr()->GetGlobalState()->Get()); lParam.SetInteger("red", (int)value.red); lParam.SetInteger("green", (int)value.green); lParam.SetInteger("blue", (int)value.blue); lParam.SetInteger("alpha", (int)value.alpha); } else if(type == Rocket::Core::Variant::COLOURF) { Rocket::Core::Colourf value = v->Get<Rocket::Core::Colourf>(); lParam.AssignNewTable(coreMgr->getScriptMgr()->GetGlobalState()->Get()); lParam.SetNumber("red", value.red); lParam.SetNumber("green", value.green); lParam.SetNumber("blue", value.blue); lParam.SetNumber("alpha", value.alpha); } else if(type == Rocket::Core::Variant::FLOAT) { float value = v->Get<float>(); lParam.AssignNumber(coreMgr->getScriptMgr()->GetGlobalState()->Get(), value); } else if(type == Rocket::Core::Variant::INT) { int value = v->Get<int>(); lParam.AssignInteger(coreMgr->getScriptMgr()->GetGlobalState()->Get(), value); } else if(type == Rocket::Core::Variant::STRING) { Rocket::Core::String value = v->Get<Rocket::Core::String>(); lParam.AssignString(coreMgr->getScriptMgr()->GetGlobalState()->Get(), value.CString()); } else if(type == Rocket::Core::Variant::VECTOR2) { Rocket::Core::Vector2f value = v->Get<Rocket::Core::Vector2f>(); lParam.AssignNewTable(coreMgr->getScriptMgr()->GetGlobalState()->Get()); lParam.SetNumber("x", value.x); lParam.SetNumber("y", value.y); } else if(type == Rocket::Core::Variant::WORD) { Rocket::Core::word value = v->Get<Rocket::Core::word>(); lParam.AssignInteger(coreMgr->getScriptMgr()->GetGlobalState()->Get(), (int)value); } else continue; lParams.SetObject(param_name.CString(), lParam); } } LuaObject ExposeGuiEventParams::getLParam(const CL_String &name) { return lParams.GetByName(name.c_str()); }
[ "[email protected]@c628178a-a759-096a-d0f3-7c7507b30227" ]
[ [ [ 1, 107 ] ] ]
1e76b4f5beac8210d6509124bf17d0c63d8dc21d
6253ab92ce2e85b4db9393aa630bde24655bd9b4
/Scene Estimator 2/TrackGeneratorFilter.h
897a669712576a7e7dde2a8aa28f4eb2c38c1195
[]
no_license
Aand1/cornell-urban-challenge
94fd4df18fd4b6cc6e12d30ed8eed280826d4aed
779daae8703fe68e7c6256932883de32a309a119
refs/heads/master
2021-01-18T11:57:48.267384
2008-10-01T06:43:18
2008-10-01T06:43:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,143
h
#ifndef TRACKGENERATORFILTER_H #define TRACKGENERATORFILTER_H #include "IDGenerator.h" #include "MatrixIndex.h" #include "PosteriorPosePosition.h" #include "RandomNumberCache.h" #include "RandomNumberGenerator.h" #include "RoadGraph.h" #include "SceneEstimatorFunctions.h" #include "Sensor.h" #include "Target.h" #include "Track.h" #include "VehicleOdometry.h" //include for interface to AI and Operational #include "sceneEstimatorInterface/sceneEstimatorInterface.h" #include <FLOAT.H> #include <MATH.H> #include <MEMORY.H> #include <SEARCH.H> #include <STDLIB.H> #include <STRING.H> #ifdef __cplusplus_cli #pragma managed(push,off) #endif //default lengths of string buffers used in printing tracks #define TG_LINESIZE 1024 #define TG_FIELDSIZE 128 class TrackGeneratorFilter { //The track generator class. Implements the track generator. private: //the current TrackGenerator timestamp double mTrackGeneratorTime; //whether the TrackGenerator has been initialized bool mIsInitialized; //pointer to the road graph structure used in scene estimator RoadGraph* mRoadGraph; //pointer to the random number generator used to draw random numbers RandomNumberGenerator* mTGGenerator; //a cache of Gaussian random numbers RandomNumberCache mGaussianCache; //UNUSED OBSTACLE DATA: //number of loose obstacle points int mNumLoosePoints; //array of cluster memberships- for each point, which cluster it belongs to int* mLooseClusterIDs; //array of loose point heights (see CLUSTER CONSTANTS for values) int* mLoosePointHeights; //array of loose (unused) obstacle points //(each row is an x, y pair for a single point, in ego-vehicle coordinates) double* mLoosePoints; //TRACKED OBSTACLE DATA: //the unique ID generator for the tracks IDGenerator mIDGenerator; //the number of tracks stored in the generator int mNumTracks; //the first track in the list of tracks stored in the generator Track* mFirstTrack; //TRANSMIT VARIABLES //the timestamp of the data being sent to AI double mAITime; //the tracks being sent to AI Track* mAIFirstTrack; //the unused obstacle data being sent to AI int mAINumLoosePoints; int* mAILooseClusterIDs; int* mAILoosePointHeights; double* mAILoosePoints; void AddTrack(Track* iNewTrack); double BirthLikelihood(Target* iTarget); double RandGaussian() {return mGaussianCache.RandomNumber();} void RemoveAllTracks(); void RemoveTrack(Track* iOldTrack); void ReplaceGaussian() {mGaussianCache.ReplaceRandomNumber(mTGGenerator->RandGaussian()); return;} public: TrackGeneratorFilter(RandomNumberGenerator* iRandomNumberGenerator, RoadGraph* iRoadGraph = NULL); ~TrackGeneratorFilter(); bool IsInitialized() {return mIsInitialized;} int NumTracks() {return mNumTracks;} double TrackGeneratorTime() {return mTrackGeneratorTime;} //input / output functions void GenerateTrackedClusterMessage(SceneEstimatorTrackedClusterMsg* oTrackedClusterMsg, PosteriorPosePosition* iPosteriorPose); void GenerateUntrackedClusterMessage(SceneEstimatorUntrackedClusterMsg* oUntrackedClusterMsg); bool PredictForTransmit(double iPredictTime, VehicleOdometry* iVehicleOdometry, PosteriorPosePosition* iPosteriorPosePosition); void PrintTracks(FILE* iTrackFile, PosteriorPosePosition* iPosteriorPosePosition); void PrintLoosePoints(FILE* iLoosePointsFile, PosteriorPosePosition* iPosteriorPosePosition); //filtering functions void Initialize(double iInitialTime); void MaintainTracks(Sensor* iFrontSensor, Sensor* iBackSensor); void Predict(double iPredictTime, VehicleOdometry* iVehicleOdometry, PosteriorPosePosition* iPosteriorPosePosition); void UpdateWithLocalMapPoints(double iUpdateTime, int iNumPoints, double* iLocalMapPacket); void UpdateWithLocalMapTargets(double iUpdateTime, int iNumTargets, double* iLocalMapTargets, double* iLocalMapCovariances, int iNumPoints, double* iLocalMapPoints, PosteriorPosePosition* iPosteriorPosePosition); }; #ifdef __cplusplus_cli #pragma managed(pop) #endif #endif //TRACKGENERATORFILTER_H
[ "anathan@5031bdca-8e6f-11dd-8a4e-8714b3728bc5" ]
[ [ [ 1, 120 ] ] ]
4909655fcf69553f2734ace76a67de2f5571a76e
9c62af23e0a1faea5aaa8dd328ba1d82688823a5
/rl/branches/persistence2/engine/rules/src/JumpHighMovement.cpp
fd36aaaca0fb722ad7da0715829e70c3bf606264
[ "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
8,126
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 "JumpHighMovement.h" using namespace std; using namespace Ogre; namespace rl { JumpHighMovement::JumpHighMovement(CreatureController *creature) : AbstractMovement(creature), mState(DOWN), mHeight(0), mJumpNow(false), mTimer(0), mMoveForward(0) { mAnimation = creature->getCreature()->getAnimation("hochsprung"); mAnimationAbsprung = creature->getCreature()->getAnimation("hochsprung_absprung"); mAnimationLandung = creature->getCreature()->getAnimation("hochsprung_landung"); mAnimationForCollision = creature->getCreature()->getAnimation("stehen"); // wird das hier gebraucht? } void JumpHighMovement::activate() { AbstractMovement::activate(); mState = DOWNTOUP; mMovingCreature->setAnimation(mAnimationAbsprung.first,mAnimationAbsprung.second,1,mAnimationForCollision.first); mTimer = 0; calculateBaseVelocity(mHeight); if( mMovingCreature->getCreature()->hasTalent("Athletik") ) { int tap = mMovingCreature->getCreature()->doTalentprobe("Athletik", 0); if( tap > 0 ) { if( tap == RESULT_SPEKT_AUTOERFOLG ) { mHeight += mMovingCreature->getCreature()->getTalent("Athletik") / 12.5; } else if( tap == RESULT_AUTOERFOLG ) { mHeight += mMovingCreature->getCreature()->getTalent("Athletik") / 25.0; } else { mHeight += tap / 25.0; } } } else { } mMovingCreature->getCreature()->damageAu(2./3); } void JumpHighMovement::deactivate() { AbstractMovement::deactivate(); } bool JumpHighMovement::calculateBaseVelocity(Real &velocity) { velocity = (mMovingCreature->getCreature()->getEigenschaft("GE") + mMovingCreature->getCreature()->getEigenschaft("KK")) / 4.0 / 5.0; // steht nicht in den Regeln aber finde ich sinnvoll // velocityBase *= (1 - getrageneLast/KK); // steht in den Regeln: pro Ersch�pfung ein KK abziehen //if( mErschoepfung > getEigenschaft("KO") ) // velocity -= (mErschoepfung - getEigenschaft("KO")) / 4.0 / 5.0; // steht nicht in den Regeln, aber finde ich sinnvoll //if( getAu() < getAuBasis() / 3.0 ) // velocity -= (getAu() / getAuBasis() * 3.0) * getEigenschaft("GE") / 4.0 / 5.0; return isPossible(); } bool JumpHighMovement::isPossible() const { if( mMovingCreature->getMovement() == this ) return (mMovingCreature->getAbstractLocation() == CreatureController::AL_FLOOR || mMovingCreature->getAbstractLocation() == CreatureController::AL_AIRBORNE) && mMovingCreature->getCreature()->getAu() > 6 && !(mMovingCreature->getCreature()->getLifeState() & (Effect::LS_IMMOBILE)); else return mMovingCreature->getAbstractLocation() == CreatureController::AL_FLOOR && mMovingCreature->getCreature()->getAu() > 8 && mMovingCreature->getCreature()->getAu() > mMovingCreature->getCreature()->getAuMax()/3.0 && !(mMovingCreature->getCreature()->getLifeState() & (Effect::LS_IMMOBILE)); } void JumpHighMovement::calculateForceAndTorque(Vector3 &force, Vector3 &torque, Real timestep) { Real mass; Vector3 inertia; OgreNewt::Body *body = mMovingCreature->getCreature()->getActor()->getPhysicalThing()->_getBody(); body->getMassMatrix(mass, inertia); if( mJumpNow ) { mJumpNow = false; Real m = mass; Real g = PhysicsManager::getSingleton().getGravity().length(); Real t = timestep; Real h = mHeight; Real jumpForce = 0.5f*g*m * (Math::Sqrt(1 + 8*h/(g * t * t)) - 1); force = Vector3(0, jumpForce, 0); mMovingCreature->setAbstractLocation( CreatureController::AL_AIRBORNE ); } else if (mState == UP && mMoveForward != 0) // try to move forward, if wanted { // low velocity towards this direction if(mMoveForward > 0) mMoveForward = 1.0; else mMoveForward = -1.0; Real mass; Vector3 inertia; OgreNewt::Body *body = mMovingCreature->getCreature()->getActor()->getPhysicalThing()->_getBody(); body->getMassMatrix(mass, inertia); Vector3 vel = mMovingCreature->getVelocity(); Real delay = 0.05;//(2 * PhysicsManager::getSingleton().getMaxTimestep()); Real diff = (mMoveForward - vel.z); force.z += mass * diff / delay; } Vector3 omega = mMovingCreature->getCreature()->getActor()->getPhysicalThing()->_getBody()->getOmega(); torque = -omega / PhysicsManager::getSingleton().getMaxTimestep() * 2 * inertia; } bool JumpHighMovement::run(Ogre::Real elapsedTime, Ogre::Vector3 direction, Ogre::Vector3 rotation) { mMoveForward = direction.z; if( mState == DOWN ) { mMovingCreature->setMovement(CreatureController::MT_STEHEN, direction, rotation); } if( mState == UPTODOWN ) { mTimer += elapsedTime; if( mTimer >= 0.5f ) { mState = DOWN; } } if( mState == UP ) { mTimer += elapsedTime; if( mTimer < 0.5f ) { mMovingCreature->setAbstractLocation( CreatureController::AL_AIRBORNE ); } else if( mMovingCreature->getAbstractLocation() != CreatureController::AL_AIRBORNE ) { mState = UPTODOWN; mMovingCreature->setAnimation(mAnimationLandung.first, mAnimationLandung.second, 1, mAnimationForCollision.first); mTimer = 0; } } if( mState == DOWNTOUP ) { mTimer += elapsedTime; if( mTimer >= 0.25f ) { mState = UP; mMovingCreature->setAbstractLocation(CreatureController::AL_AIRBORNE); mMovingCreature->setAnimation(mAnimation.first, mAnimation.second); mJumpNow = true; mTimer = 0; } } return false; } bool JumpHighMovement::isDirectionPossible(Ogre::Vector3 &direction) const { Vector3 oldDirection(direction); direction.x = 0; if(direction.y < 0) direction.y = 0; return oldDirection.x == 0 && oldDirection.y > 0; } bool JumpHighMovement::isRotationPossible(Ogre::Vector3 &rotation) const { rotation = Vector3::ZERO; return false; } bool JumpHighMovement::canChangeToMovement(CreatureController::MovementType id) { return mState == DOWN; } }
[ "timm@4c79e8ff-cfd4-0310-af45-a38c79f83013" ]
[ [ [ 1, 219 ] ] ]
94a3f5df19bac1fe5e6b1633e51fabf0bc0a7347
13f30850677b4b805aeddbad39cd9369d7234929
/ astrocytes --username [email protected]/CT_tutorial/Figures.cpp
a53c7a57a44b25f4860853d1143077dc3e653012
[]
no_license
hksonngan/astrocytes
2548c73bbe45ea4db133e465fa8a90d29dc60f64
e14544d21a077cdbc05356b05148cc408c255e04
refs/heads/master
2021-01-10T10:04:14.265392
2011-11-09T07:42:06
2011-11-09T07:42:06
46,898,541
0
0
null
null
null
null
UTF-8
C++
false
false
2,492
cpp
#include "Figures.h" #include "AllDef.h" #include <math.h> void AddQuad(Geometry*g, vec3 a,vec3 b,vec3 c,vec3 d) { g->AddTriangle(a,b,c); g->AddTriangle(a,c,d); } void AddBox(Geometry*g, vec3 a,vec3 b) { Geometry tmp; if(a.x>b.x)swap(a.x,b.x); if(a.y>b.y)swap(a.y,b.y); if(a.z>b.z)swap(a.z,b.z); vec3 s = b - a; vec3 a_x(s.x,0,0); vec3 a_y(0,s.y,0); vec3 a_z(0,0,s.z); AddQuad(&tmp,a,a+a_y,a+a_x+a_y,a+a_x); AddQuad(&tmp,a,a+a_x,a+a_x+a_z,a+a_z); AddQuad(&tmp,a,a+a_z,a+a_z+a_y,a+a_y); AddQuad(&tmp,b,b-a_x,b-a_x-a_y,b-a_y); AddQuad(&tmp,b,b-a_z,b-a_x-a_z,b-a_x); AddQuad(&tmp,b,b-a_y,b-a_z-a_y,b-a_z); tmp.SetNormOutOf((a+b)*0.5f); g->Add(tmp); } void AddCylinder(Geometry*g,float h,float r, int sides) { Geometry tmp; float ang=(float)(PI*2.0/sides); float sina=sin(ang),cosa=cos(ang); int i; vec3 t1(r,0,0),t0(r,0,0),hh(0,h,0),hh0(0,0,0); for(i=0;i<sides;i++) { t1.RotateOij(sina,cosa,0,2); AddQuad(&tmp,t0,t1,t1+hh,t0+hh); tmp.AddTriangle(t0,t1,hh0); tmp.AddTriangle(t1+hh,t0+hh,hh); t0=t1; } tmp.SetNormOutOf(vec3(0,h/2,0)); g->Add(tmp); } void AddSphere(Geometry*g,float r, int sides_a, int sides_b) { Geometry tmp; float ang=(float)(PI/sides_a); float sina=sin(ang),cosa=cos(ang); float ang2=(float)(PI*2.0/sides_b); float sinb=sin(ang2),cosb=cos(ang2); int i,j; vec3 v0(0,r,0),u0,u1,w0,w1; vec3 v1(v0); for(i=0;i<sides_a;i++) { v1.RotateOij(sina,cosa,0,1); u0 = v0; w0 = v1; u1 = v0; w1 = v1; for(j=0;j<sides_b;j++) { u1.RotateOij(sinb,cosb,0,2); w1.RotateOij(sinb,cosb,0,2); if(i==sides_b-1) tmp.AddTriangle(u0,u1,w0); else if(!i) tmp.AddTriangle(u1,w1,w0); else AddQuad(&tmp,u0,u1,w1,w0); u0=u1; w0=w1; } v0=v1; } tmp.SetNormOutOf(vec3(0,0,0)); g->Add(tmp); } void AddArmDetail(Geometry*g,float w,float r, int sides) { Geometry tmp; float ang=(float)(PI/sides); float sina=sin(ang),cosa=cos(ang); int i; vec3 t1(0,0,r),t0(0,0,r),hh(w/2,0,0),hh0(0,0,0); for(i=0;i<sides;i++) { t1.RotateOij(sina,cosa,1,2); AddQuad(&tmp,t0,t1,t1+hh,t0+hh); tmp.AddTriangle(t0,t1,hh0); tmp.AddTriangle(t1+hh,t0+hh,hh); t0=t1; } tmp.SetNormOutOf(vec3((w)/4,0,0)); g->Add(tmp); //tmp.renull(); //AddQuad(&tmp,); AddBox(g,vec3(0,0,r),vec3(w/2,r,-r)); AddBox(g,vec3(-w/2,2*r,r),vec3(w/2,r,-r)); }
[ [ [ 1, 135 ] ] ]
8a3f54faa502a0c7f7f7ccc69b85971d47dc1c1a
478570cde911b8e8e39046de62d3b5966b850384
/apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.0/bctestmenu/inc/bctestmenuview.h
126752b646a0663cb200ffdf96a4c5cdb97a08ac
[]
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,964
h
/* * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: Test BC for Menu control API. * */ #ifndef BCTEST_MENU_VIEW_H #define BCTEST_MENU_VIEW_H #include <aknview.h> const TUid KBCTestMenuViewId = { 1 }; class CBCTestMenuContainer; class CBCTestUtil; /** * Application UI class * * @lib bctestutil.lib */ class CBCTestMenuView : public CAknView { public: // Constructors and destructor /** * Symbian static 2nd constructor */ static CBCTestMenuView* NewL(); /** * dtor */ virtual ~CBCTestMenuView(); public: // from CAknView /** * Return view Id. */ TUid Id() const; /** * From CAknView, HandleCommandL. * @param aCommand Command to be handled. */ void HandleCommandL( TInt aCommand ); protected: // from CAknView /** * When view is activated, do something */ void DoActivateL( const TVwsViewId&, TUid, const TDesC8& ); /** * When view is deactivated, do something */ void DoDeactivate(); private: // constructor /** * C++ default constructor */ CBCTestMenuView(); /** * symbian 2nd ctor */ void ConstructL(); private: // data /** * pointor to the BC Test framework utility. * own */ CBCTestUtil* iTestUtil; /** * pointor to the container. * own */ CBCTestMenuContainer* iContainer; }; #endif // BCTEST_Menu_VIEW_H // End of File
[ "none@none" ]
[ [ [ 1, 103 ] ] ]
48dc6502cc3fa63dfb0c41a8fd8ddc8ba40e4159
b84a38aad619acf34c22ed6e6caa0f7b00ebfa0a
/Code/TootleCore/PC/PCThread.h
5e6c5316fc07005e72b9e23818e3ec85d460263b
[]
no_license
SoylentGraham/Tootle
4ae4e8352f3e778e3743e9167e9b59664d83b9cb
17002da0936a7af1f9b8d1699d6f3e41bab05137
refs/heads/master
2021-01-24T22:44:04.484538
2010-11-03T22:53:17
2010-11-03T22:53:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,680
h
#pragma once #ifndef _MSC_EXTENSIONS #error PC file should not be included in ansi builds #endif #include <TootleGui/PC/PCGui.h> // windows headers #include <process.h> // threads - may want to use pthreads lib instead for maximum portability namespace TLThread { namespace Platform { template<class T> Bool CreateAsThread(T* pClassObj); template<class T> class Win32ThreadWrapper; } }; template<class T> Bool TLThread::Platform::CreateAsThread(T* pClassObj) { Win32ThreadWrapper* pThread = new Win32ThreadWrapper(pClassObject); delete pThread; return TRUE; } /* ThreadWrapper class - allows you to create an object as a thread if required without having to explicitly alter the class to support threading Class (that will be threaded) requirements: * ThreadEntryPoint routine - the main 'update' routine of the thread part of the class. When it returns the thread will be removed. NOTE: This may change to be an update routine that is called manually from the thread wrapper. TODO: * Add message handling for each thread so that each thread has it's own message pipeline */ template<class T> class TLThread::Platform::Win32ThreadWrapper { public: Win32ThreadWrapper(T* pThreadClass); ~Win32ThreadWrapper(void); static unsigned __stdcall ThreadStaticEntryPoint(void * pClass) { T* pthX = (T*)pClass; // the tricky cast pthX->ThreadEntryPoint(); // now call the true entry-point-function // A thread terminates automatically if it completes execution, // or it can terminate itself with a call to _endthread(). return 1; // the thread exit code } private: T* m_pThreadClass; HANDLE m_ThreadHandle; unsigned int m_uiThreadID; }; // Thread wrapper constructor template<class T> TLThread::Platform::Win32ThreadWrapper<T>::Win32ThreadWrapper(T* pThreadClass) { m_pThreadClass = pThreadClass; // Create the thread m_ThreadHandle = (HANDLE)_beginthreadex( NULL, // security 0, // stack size ThreadStaticEntryPoint,// entry-point-function m_pThreadClass, // arg list holding the "this" pointer 0, // so we can later call ResumeThread() &m_uiThreadID ); }; // ThreadWrapper destructor template<class T> TLThread::Platform::Win32ThreadWrapper<T>::~Win32ThreadWrapper(void) { printf_s("Waiting for thread\n"); // Wait for the thread to finish WaitForSingleObject( m_ThreadHandle, INFINITE ); m_pThreadClass = NULL; printf_s("Thread finished\n"); };
[ [ [ 1, 7 ], [ 9, 9 ], [ 11, 65 ], [ 68, 96 ] ], [ [ 8, 8 ], [ 10, 10 ], [ 66, 67 ], [ 97, 97 ] ] ]
4876935b77d00b2f99ae87c62f5e9b3867b91d07
52eec3f146a11a5092aeead6fb0ad9654c6e76f7
/ultracache/Server.h
4198d01bcf876b4bba88c992c7fd3f818488d9d1
[]
no_license
isabella232/ultracache
b497f54f5b8b6f3d6ca30a1188050170edde5ff0
ed03dc953c74bb2600c5eb54dfd5fe3ca1164216
refs/heads/master
2023-03-18T23:31:59.136171
2011-10-11T22:01:01
2011-10-11T22:01:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,000
h
#pragma once #include "socketdefs.h" #include "Request.h" #include "Cache.h" #include "ByteStream.h" #include <map> #ifdef _WIN32 #include <hash_map> #else #include <ext/hash_map> #endif #include "JThreadQueue.h" #include "Response.h" #include "JThread.h" #include "Spinlock.h" #include "types.h" class Server { private: #ifdef _WIN32 typedef std::hash_map<UINT64, Request *> REQUESTMAP; #else typedef __gnu_cxx::hash_map<UINT64, Request *> REQUESTMAP; #endif public: Server(); ~Server(); int main(int argc, char **argv); void shutdown(); void rxThread(); void txThread(); private: Cache *m_cache; SOCKET m_sockfd; private: SOCKET createSocket(int port); void decodeRequest(Request *request); UINT8 *m_buffer; volatile bool m_bIsRunning; JThreadQueue<Request> m_rxQueue; JThreadQueue<Response> m_txQueue; JThread m_rxThread[32]; JThread m_txThread[32]; int m_cThreads; Spinlock m_rmapSL; REQUESTMAP m_rmap; };
[ [ [ 1, 58 ] ] ]
dcda4f16b90c500642d1307a7eb82f81342a01a6
857b85d77dfcf9d82c445ad44fedf5c83b902b7c
/source/Headers/SkyBox.h
ecade11eb70d0b7617edb608d5cef11ee7ebec23
[]
no_license
TheProjecter/nintendo-ds-homebrew-framework
7ecf88ef5b02a0b1fddc8939011adde9eabf9430
8ab54265516e20b69fbcbb250677557d009091d9
refs/heads/master
2021-01-10T15:13:28.188530
2011-05-19T12:24:39
2011-05-19T12:24:39
43,224,572
0
0
null
null
null
null
UTF-8
C++
false
false
363
h
#ifndef SKYBOX_H #define SKYBOX_H #include "GameObject.h" #include "DisplayList.h" class SkyBox : public GameObject { public: SkyBox(); ~SkyBox() {} static GameObject* CreateSkyBox(); virtual const char* GetTypeName() const { return "SkyBox"; } virtual bool Load(File* pFile); void Update(float gameSpeed); void Draw(); }; #endif
[ [ [ 1, 22 ] ] ]
698ccaa4ebfb9d022e22d790833f4d7df92c4590
3a577d02f876776b22e2bf1c0db12a083f49086d
/vba2/gba2/backupmedia.cpp
c24c1557a8e02e583993990a3281fa3ff087de6f
[]
no_license
xiaoluoyuan/VisualBoyAdvance-2
d19565617b26e1771f437842dba5f0131d774e73
cadd2193ba48e1846b45f87ff7c36246cd61b6ee
refs/heads/master
2021-01-10T01:19:23.884491
2010-05-12T09:59:37
2010-05-12T09:59:37
46,539,728
0
0
null
null
null
null
UTF-8
C++
false
false
11,162
cpp
/* VisualBoyAdvance 2 Copyright (C) 2009-2010 VBA development team This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "backupmedia.h" #include <assert.h> #include <string.h> // memset BackupMedia::BackupMedia() { m_type = NONE; m_data = NULL; m_size = 0; writeOccured = false; } BackupMedia::~BackupMedia() { if( m_data != NULL ) { delete[] m_data; } } void BackupMedia::setType( BACKUPMEDIATYPE type ) { m_type = type; switch( m_type ) { case NONE: break; case SRAM: // SRAM is always 32 KiB m_size = SIZE_SRAM; m_data = new u8[SIZE_SRAM]; assert( m_data != NULL ); memset( m_data, 0xFF, SIZE_SRAM ); break; case EEPROM: // EEPROM is either 512 Bytes or 8 KiB m_size = 0; // has to be detected first! m_eepromAddressBits = 0; m_data = new u8[SIZE_EEPROM_LARGE]; assert( m_data != NULL ); memset( m_data, 0xFF, SIZE_EEPROM_LARGE ); m_eepromState = IDLE; m_eepromBitsRead = 68; // 68 means can not read more break; case FLASH64KiB: m_size = SIZE_FLASH_SMALL; m_data = new u8[SIZE_FLASH_SMALL]; assert( m_data != NULL ); memset( m_data, 0xFF, SIZE_FLASH_SMALL ); m_flashState = F_IDLE; m_flashEraseMode = false; // (64 KiB) Panasonic MN63F805MNP m_mfgID = 0x32; m_deviceID = 0x1B; break; case FLASH128KiB: m_size = SIZE_FLASH_LARGE; m_data = new u8[SIZE_FLASH_LARGE]; assert( m_data != NULL ); memset( m_data, 0xFF, SIZE_FLASH_LARGE ); m_flashState = F_IDLE; m_flashEraseMode = false; m_bankSwitched = false; // (128 KiB) Sanyo LE26FV10N1TS m_mfgID = 0x62; m_deviceID = 0x13; break; } } BACKUPMEDIATYPE BackupMedia::getType() { return m_type; } bool BackupMedia::read8( u32 address, u8 &value ) { if( address & 0x0E000000 ) { u32 address16 = address & 0xFFFF; switch( m_type ) { default: break; case SRAM: if( address16 >= 0x8000 ) break; value = m_data[address16 & 0x7FFF]; return true; case FLASH128KiB: if( m_bankSwitched ) { address16 += 0x10000; } // no break/return here, fall through to FLASH64KiB is intended. case FLASH64KiB: if( m_flashState == F_IDLE ) { // read & return data from flash cells value = m_data[address16]; return true; } // return flash manufacturer/device ID if( m_flashState == F_ID_MODE ) { if( address16 == 0 ) { value = m_mfgID; return true; } else if( address16 == 1 ) { value = m_deviceID; return true; } } } } assert( false ); return false; } bool BackupMedia::write8( u32 address, u8 value ) { if( address & 0x0E000000 ) { u32 address16 = address & 0xFFFF; switch( m_type ) { default: break; case SRAM: if( address16 < 0x8000 ) { m_data[address16] = value; writeOccured = true; return true; } break; case FLASH64KiB: case FLASH128KiB: switch( m_flashState ) { case F_IDLE: if( value == 0xF0 ) { return true; // ignore } // no break; here case F_ID_MODE: if( address16 == 0x5555 ) { if( value == 0xAA ) { m_flashState = F_RECEIVING_COMMAND1; return true; } } break; case F_RECEIVING_COMMAND1: if( (address16==0x2AAA) && (value==0x55) ) { m_flashState = F_RECEIVING_COMMAND2; return true; } break; case F_RECEIVING_COMMAND2: if( address16 == 0x5555 ) { switch( value ) { default: break; case 0x10: // erase entire chip if( m_flashEraseMode ) { memset( m_data, 0xFF, m_size ); m_flashEraseMode = false; m_flashState = F_IDLE; writeOccured = true; return true; } break; case 0x80: // enter erase mode m_flashEraseMode = true; m_flashState = F_IDLE; return true; case 0x90: // enter ID mode m_flashState = F_ID_MODE; return true; case 0xA0: // write single byte mode m_flashState = F_WRITE_SINGLE_BYTE; return true; case 0xB0: // enter bank switching mode m_flashState = F_BANK_MODE; return true; case 0xF0: // back to idle mode m_flashState = F_IDLE; return true; } } if( m_flashEraseMode && (value == 0x30) && !(address16 & 0x0FFF) ) { // erase specific sector (4 KiB) by writing 0xFF bytes if( m_bankSwitched && (m_type==FLASH128KiB) ) { address16 += 0x10000; } memset( &m_data[address16], 0xFF, 0x1000 ); m_flashEraseMode = false; m_flashState = F_IDLE; writeOccured = true; return true; } break; case F_BANK_MODE: if( address16 == 0 ) { assert( value <= 1 ); m_bankSwitched = value & 1; m_flashState = F_IDLE; return true; } break; case F_WRITE_SINGLE_BYTE: // write a single byte to address if( m_bankSwitched && (m_type==FLASH128KiB) ) { address16 += 0x10000; } // the address must have been previously erased assert( m_data[address16] == 0xFF ); m_data[address16] = value; m_flashState = F_IDLE; writeOccured = true; return true; } } } assert( false ); return false; } bool BackupMedia::detectEEPROMSize( u32 dmaCount ) { if( (m_type == EEPROM) && (m_eepromState == IDLE) ) { /* dmaCount for different EEPROM sizes 512 Bytes: set read address: 9 bits (!) read: 68 bits write data to address: 73 bits 8 KiB: set read address: 17 bits (!) read: 68 bits write data to address: 81 bits other dmaCount values should NOT occur in the EEPROM address space! */ switch( dmaCount ) { case 9: m_size = SIZE_EEPROM_SMALL; m_eepromAddressBits = ADDRESS_BITS_EEPROM_SMALL; return true; case 17: m_size = SIZE_EEPROM_LARGE; m_eepromAddressBits = ADDRESS_BITS_EEPROM_LARGE; return true; } } assert( false ); return false; } bool BackupMedia::read16( u32 address, u16 &value ) { if( ( m_type == EEPROM ) && ( address & 0x0D000000 ) ) { switch( m_eepromState ) { case READING: { // read out: // - garbage (4 bits) // - data (64 bits, MSB first) assert( m_eepromBitsRead < 68 ); if( m_eepromBitsRead < 4 ) { m_eepromBitsRead++; value = 0; // garbage return true; } else { const u8 data_bit_index = m_eepromBitsRead - 4; const u8 data_byte_index = data_bit_index >> 3; const u8 mask = 1 << ( 7 - (data_bit_index & 7) ); const u16 current_eeprom_address = m_eepromAddress + data_byte_index; assert( current_eeprom_address < m_size ); m_eepromBitsRead++; if( m_eepromBitsRead == 68 ) { m_eepromState = IDLE; } value = (m_data[current_eeprom_address] & mask) ? 1 : 0; return true; } break; } case IDLE: case SETTING_ADDRESS: case WRITING: // acknowledge we are ready value = 1; return true; } } // error: read occured, but no address was specified before assert( false ); return false; } bool BackupMedia::write16( u32 address, u16 value ) { if( (m_type != EEPROM) || !(address & 0x0D000000) || (m_size == 0) ) { assert( false ); return false; } const bool bit = value & 1; static u8 bit_count; // number of bits already received static u16 buffer; switch( m_eepromState ) { case IDLE: // receive a '1' bit to awake from idle state assert( bit == 1 ); bit_count = 0; buffer = 0; m_eepromState = SETTING_ADDRESS; break; case SETTING_ADDRESS: { assert( bit_count < m_eepromAddressBits ); // receive in order: // - requested mode (1=read 0=write) // - address (6/14 bit, MSB first), references an 8 byte block of EEPROM storage if( bit_count < m_eepromAddressBits ) { buffer <<= 1; buffer |= bit; } if( bit_count == (m_eepromAddressBits-1) ) { // receiving last address bit const u16 modeMask = (1 << (m_eepromAddressBits-2)); m_eepromState = (buffer & modeMask) ? READING : WRITING; m_eepromAddress = (buffer & (modeMask - 1)) << 3; buffer = 0; // we need this to be 0 in case WRITING } } break; case READING: // after SETTING_ADDRESS, a single end bit is expected to be received, not more! assert( bit_count == m_eepromAddressBits ); m_eepromBitsRead = 0; break; case WRITING: // receive in order: // - data to be written to m_eepromAddress (64 bit, MSB first) // - a single end bit assert( bit_count >= m_eepromAddressBits ); if( bit_count < (m_eepromAddressBits+64) ) { buffer <<= 1; buffer |= bit; if( ((bit_count+1) % 8) == 0 ) { assert( m_eepromAddress < m_size ); m_data[ m_eepromAddress ] = buffer; m_eepromAddress++; writeOccured = true; // signal there was a change to the save data buffer = 0; } } else { // ignore end bit assert( bit_count == (m_eepromAddressBits+64) ); m_eepromState = IDLE; // reset state to beginning } break; } bit_count++; return true; } u32 BackupMedia::getSize() { if( (m_size == 0) && (m_type == EEPROM) ) { // exception: Since we can not know about the size before emulation started, we // return the maximum size in case the emu wants to load a save file. return SIZE_EEPROM_LARGE; } return m_size; } u8 *BackupMedia::getData() { return m_data; }
[ "spacy51@5a53c671-dd2d-0410-9261-3f5c817b7aa0" ]
[ [ [ 1, 400 ] ] ]
f67a67e7e98f002a34a6a3c5b1d72be1de452efc
9ef88cf6a334c82c92164c3f8d9f232d07c37fc3
/TestApp/DemoGameLogic.cpp
b74d376b4cc50514356d0cff4293362874176d12
[]
no_license
Gussoh/bismuthengine
eba4f1d6c2647d4b73d22512405da9d7f4bde88a
4a35e7ae880cebde7c557bd8c8f853a9a96f5c53
refs/heads/master
2016-09-05T11:28:11.194130
2010-01-10T14:09:24
2010-01-10T14:09:24
33,263,368
0
0
null
null
null
null
UTF-8
C++
false
false
10,145
cpp
#include "stdafx.h" #include "Renderer.h" #include "OgreSceneManager.h" #include "OgreEntity.h" #include "OgreSceneNode.h" #include "Entity.h" #include "DemoGameLogic.h" using namespace Bismuth; Ogre::String playerNames[] = { "Goran", "Maria", "Lars", "Thomas", "Leif", "Jimmie", "Fredrik", "Riddler" }; DemoGameLogic::DemoGameLogic(std::string host) : GameLogic(host), scores(NULL), health(100), weapon(2), gDown(false), gogglesEnabled(false), nextShotAllowed(0), dead(true), spawnOnFrame(100) { } DemoGameLogic::DemoGameLogic(int numberOfPlayers) : GameLogic(numberOfPlayers), scores(NULL), health(100), weapon(2), gDown(false), gogglesEnabled(false), nextShotAllowed(0), dead(true), spawnOnFrame(100) { } DemoGameLogic::~DemoGameLogic() { if(scores != NULL) { delete[] scores; } } void DemoGameLogic::initGui() { GameLogic::initGui(); QuickGUI::SkinTypeManager::getSingletonPtr()->loadTypes(); QuickGUI::GUIManagerDesc d; d.sceneManager = getRenderer()->getDefaultSceneManager(); d.viewport = getRenderer()->getDefaultCamera()->getViewport(); //d.queueID = Ogre::RENDER_QUEUE_OVERLAY; QuickGUI::GUIManager* mGUIManager = QuickGUI::Root::getSingletonPtr()->createGUIManager(d); // SHEET QuickGUI::SheetDesc* sd = QuickGUI::DescManager::getSingleton().getDefaultSheetDesc(); sd->resetToDefault(); sd->widget_dimensions.size = QuickGUI::Size(800,600); QuickGUI::Sheet* mySheet = QuickGUI::SheetManager::getSingleton().createSheet(sd); mGUIManager->setActiveSheet(mySheet); // Create background for health QuickGUI::ImageDesc *imgdHealthBack = QuickGUI::DescManager::getSingleton().getDefaultImageDesc(); imgdHealthBack->widget_name = "HealthBack"; imgdHealthBack->widget_dimensions.size = QuickGUI::Size(100, 19); imgdHealthBack->widget_dimensions.position = QuickGUI::Point(88, 571); QuickGUI::Image* imgHealthBack = mySheet->createImage(imgdHealthBack); imgHealthBack->setImage("health2.png"); imgHealthBack->setTileImage(true); // Create health QuickGUI::ImageDesc *imgdHealth = QuickGUI::DescManager::getSingleton().getDefaultImageDesc(); imgdHealth->widget_name = "Health"; imgdHealth->widget_dimensions.size = QuickGUI::Size(100, 19); imgdHealth->widget_dimensions.position = QuickGUI::Point(88, 571); imgHealth = mySheet->createImage(imgdHealth); imgHealth->setImage("health1.png"); imgHealth->setMinSize(QuickGUI::Size(1, 1)); imgHealth->setTileImage(true); // Create background for reload QuickGUI::ImageDesc *imgdReloadBack = QuickGUI::DescManager::getSingleton().getDefaultImageDesc(); imgdReloadBack->widget_name = "ReloadBack"; imgdReloadBack->widget_dimensions.size = QuickGUI::Size(100, 19); imgdReloadBack->widget_dimensions.position = QuickGUI::Point(690, 571); QuickGUI::Image* imgReloadBack = mySheet->createImage(imgdReloadBack); imgReloadBack->setImage("reload2.png"); imgReloadBack->setTileImage(true); // Create reload bar QuickGUI::ImageDesc *imgdReload = QuickGUI::DescManager::getSingleton().getDefaultImageDesc(); imgdReload->widget_name = "Reload"; imgdReload->widget_dimensions.size = QuickGUI::Size(100, 19); imgdReload->widget_dimensions.position = QuickGUI::Point(690, 571); imgReload = mySheet->createImage(imgdReload); imgReload->setImage("reload1.png"); imgReload->setMinSize(QuickGUI::Size(1, 1)); imgReload->setTileImage(true); // Create weapon QuickGUI::ImageDesc *imgdWeapon = QuickGUI::DescManager::getSingleton().getDefaultImageDesc(); imgdWeapon->widget_name = "Weapon"; imgdWeapon->widget_dimensions.size = QuickGUI::Size(62, 67); imgdWeapon->widget_dimensions.position = QuickGUI::Point(107, 498); imgWeapon = mySheet->createImage(imgdWeapon); imgWeapon->setImage("weapon1.png"); imgWeapon->setTileImage(true); // Create cross QuickGUI::ImageDesc *imgdCross = QuickGUI::DescManager::getSingleton().getDefaultImageDesc(); imgdCross->widget_name = "Cross"; imgdCross->widget_dimensions.size = QuickGUI::Size(41, 41); imgdCross->widget_dimensions.position = QuickGUI::Point(400 - 21, 300 - 21); QuickGUI::Image* imgCross = mySheet->createImage(imgdCross); imgCross->setImage("cross1.png"); imgCross->setTileImage(false); // Create character avatar QuickGUI::ImageDesc *imgdFace = QuickGUI::DescManager::getSingleton().getDefaultImageDesc(); imgdFace->widget_name = "Face"; imgdFace->widget_dimensions.size = QuickGUI::Size(73, 98); imgdFace->widget_dimensions.position = QuickGUI::Point(10, 492); playerAvatar = mySheet->createImage(imgdFace); playerAvatar->setImage("riddler.jpg"); playerAvatar->setTileImage(true); // Create score text QuickGUI::TextAreaDesc *textadScoreText = QuickGUI::DescManager::getSingleton().getDefaultTextAreaDesc(); textadScoreText->widget_dimensions.position = QuickGUI::Point(0, 0); //19 textaScoreText = mySheet->createTextArea(textadScoreText); textaScoreText->setText("Maria\nLars\nPlayer4"); textaScoreText->setFont("verdana.14"); QuickGUI::TextAreaDesc *textadPlayerScoreText = QuickGUI::DescManager::getSingleton().getDefaultTextAreaDesc(); textadPlayerScoreText->widget_dimensions.position = QuickGUI::Point(0, 0); textaPlayerScoreText = mySheet->createTextArea(textadPlayerScoreText); textaPlayerScoreText->setText("YOU"); textaPlayerScoreText->setFont("verdana.14"); textaPlayerScoreText->setTextColor(QuickGUI::ColourValue(1.0f, 1.0f, 0.0f, 1.0f)); // Create score QuickGUI::TextAreaDesc *textadScore = QuickGUI::DescManager::getSingleton().getDefaultTextAreaDesc(); textadScore->widget_dimensions.position = QuickGUI::Point(80, 0); //19 textaScore = mySheet->createTextArea(textadScore); textaScore->setText("\n4\n3\n7"); textaScore->setFont("verdana.14"); QuickGUI::TextAreaDesc *textadPlayerScore = QuickGUI::DescManager::getSingleton().getDefaultTextAreaDesc(); textadPlayerScore->widget_dimensions.position = QuickGUI::Point(80, 0); textaPlayerScore = mySheet->createTextArea(textadPlayerScore); textaPlayerScore->setText("42"); textaPlayerScore->setFont("verdana.14"); textaPlayerScore->setTextColor(QuickGUI::ColourValue(1.0f, 1.0f, 0.0f, 1.0f)); // Create waiting background QuickGUI::ImageDesc *imgdWaiting = QuickGUI::DescManager::getSingleton().getDefaultImageDesc(); imgdWaiting->widget_name = "Waiting"; imgdWaiting->widget_dimensions.size = QuickGUI::Size(800, 600); imgdWaiting->widget_dimensions.position = QuickGUI::Point(0, 0); imgWaiting = mySheet->createImage(imgdWaiting); imgWaiting->setImage("waiting.png"); imgWaiting->setTileImage(true); } void DemoGameLogic::update() { // Get the animations running for (EntityList::iterator iter = getEntities()->begin(); iter != getEntities()->end(); ++iter) { Ogre::AnimationStateSet *states = iter->second->getAnimationStates(); if (states != 0 && states->hasEnabledAnimationState()) { Ogre::ConstEnabledAnimationStateIterator state = states->getEnabledAnimationStateIterator(); while (state.hasMoreElements()) { state.peekNext()->addTime(1.0f / 50.0f); state.moveNext(); } } if (states != 0) { float velocity = getPhysicsManager()->getVelocity(iter->second); if (velocity <= 0.1f && states->hasAnimationState("Idle1")) { states->getAnimationState("Idle1")->setEnabled(true); if (states->hasAnimationState("Walk")) { states->getAnimationState("Walk")->setEnabled(false); } if (states->hasAnimationState("JumpNoHeight")) { states->getAnimationState("JumpNoHeight")->setEnabled(false); } } else if (velocity > 0.1f && states->hasAnimationState("Walk")) { if (states->hasAnimationState("Idle1")) { states->getAnimationState("Idle1")->setEnabled(false); } if (!iter->second->hasContact() && states->hasAnimationState("JumpNoHeight")) { states->getAnimationState("JumpNoHeight")->setEnabled(true); states->getAnimationState("Walk")->setEnabled(false); } else { states->getAnimationState("Walk")->setEnabled(true); if (states->hasAnimationState("JumpNoHeight")) { states->getAnimationState("JumpNoHeight")->setEnabled(false); } } } } } GameLogic::update(); } void DemoGameLogic::updateGui() { GameLogic::updateGui(); // Remove waiting screen if started if (imgWaiting != NULL && isGameStarted() == true) { imgWaiting->setVisible(false); imgWaiting->destroy(); imgWaiting = NULL; } // UPDATE AVATAR if (getMyPlayerId() > 6 || getMyPlayerId() < 0) { playerAvatar->setImage("riddler.jpg"); } else if (playerAvatar->getImageName().compare(playerNames[getMyPlayerId()] + ".jpg") != 0) { playerAvatar->setImage(playerNames[getMyPlayerId()] + ".jpg"); } // Update score text Ogre::String scoreNames = ""; for (int i = 0; i < getNumberOfPlayers(); ++i) { if (i == getMyPlayerId()) continue; if (i > 6) { scoreNames += "\nRiddler"; } else { scoreNames += "\n" + playerNames[i]; } } textaScoreText->setText(scoreNames); // Update score if (scores != NULL) { Ogre::String scoreString; for (int i = 0; i < getNumberOfPlayers(); ++i) { if (i == getMyPlayerId()) continue; scoreString += "\n" + Ogre::StringConverter::toString(scores[i]); } textaScore->setText(scoreString); textaPlayerScore->setText(Ogre::StringConverter::toString(scores[getMyPlayerId()])); } // Update health bar if (health < 1) { imgHealth->setVisible(false); } else { imgHealth->setVisible(true); imgHealth->setWidth((float)health); } // Update reload bar if (nextShotAllowed - getFrameCounter() < 1) { imgReload->setVisible(false); } else { imgReload->setVisible(true); imgReload->setWidth((float)(nextShotAllowed - getFrameCounter())); imgReload->setPosition(QuickGUI::Point(690 + (100 - (nextShotAllowed - getFrameCounter())), 571)); } // Update weapon imgWeapon->setImage("weapon" + Ogre::StringConverter::toString(weapon) + ".png"); }
[ "[email protected]@aefdbfa2-c794-11de-8410-e5b1e99fc78e", "[email protected]@aefdbfa2-c794-11de-8410-e5b1e99fc78e", "andreas.duchen@aefdbfa2-c794-11de-8410-e5b1e99fc78e" ]
[ [ [ 1, 12 ], [ 23, 25 ], [ 36, 39 ], [ 43, 49 ], [ 52, 161 ], [ 163, 172 ], [ 174, 206 ], [ 208, 214 ], [ 216, 218 ], [ 220, 220 ], [ 222, 226 ], [ 228, 228 ], [ 230, 248 ], [ 250, 250 ], [ 252, 257 ], [ 259, 272 ], [ 274, 279 ], [ 282, 286 ] ], [ [ 13, 22 ], [ 26, 35 ], [ 40, 42 ] ], [ [ 50, 51 ], [ 162, 162 ], [ 173, 173 ], [ 207, 207 ], [ 215, 215 ], [ 219, 219 ], [ 221, 221 ], [ 227, 227 ], [ 229, 229 ], [ 249, 249 ], [ 251, 251 ], [ 258, 258 ], [ 273, 273 ], [ 280, 281 ] ] ]
7889af6bbe5784464efa0208ce0502e15fd9d97b
d8f64a24453c6f077426ea58aaa7313aafafc75c
/GUIManager.h
ae53b462fd37acc53aa69c5c3f0620247532ceb6
[]
no_license
dotted/wfto
5b98591645f3ddd72cad33736da5def09484a339
6eebb66384e6eb519401bdd649ae986d94bcaf27
refs/heads/master
2021-01-20T06:25:20.468978
2010-11-04T21:01:51
2010-11-04T21:01:51
32,183,921
1
0
null
null
null
null
UTF-8
C++
false
false
723
h
#ifndef GUI_MANAGER_H #define GUI_MANAGER_H #include "Manager.h" #include "GUI/PlayGUI.h" /* Wrapper around the original NBK CPlayGUI */ namespace game_utils { namespace managers { class CGUIManager: public CManager { public: CGUIManager(); ~CGUIManager(); // from CManager virtual bool init(); virtual bool update(); virtual bool shutdown(); DK_GUI::CPlayGUI *getPlayGUI(); // should be called from different managers that need to know what happened in the GUI ACTION_EVENT *getLastActionEvent(); private: DK_GUI::CPlayGUI *playGUI; // contains the last event ACTION_EVENT last_action_event; }; }; }; #endif // GUI_MANAGER_H
[ [ [ 1, 40 ] ] ]
73c5ffaea1f6e3ebfefcd40a2f3f583644aa8221
b6c9433cefda8cfe76c8cb6550bf92dde38e68a8
/epoc32/include/assp/omap3530_assp/omap3530_hardware_base.h
fc732403cd0bcf55e8dd56e838df6736bf5eb3d1
[]
no_license
fedor4ever/public-headers
667f8b9d0dc70aa3d52d553fd4cbd5b0a532835f
3666a83565a8de1b070f5ac0b22cc0cbd59117a4
refs/heads/master
2021-01-01T05:51:44.592006
2010-03-31T11:33:34
2010-03-31T11:33:34
33,378,397
0
0
null
null
null
null
UTF-8
C++
false
false
18,117
h
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of the License "Eclipse Public License v1.0" // which accompanies this distribution, and is available // at the URL "http://www.eclipse.org/legal/epl-v10.html". // // Initial Contributors: // Nokia Corporation - initial contribution. // // Contributors: // // Description: // omap3530/assp/inc/omap3530_hardware_base.h // Linear base addresses for hardware peripherals on the beagle board. // This file is part of the Beagle Base port // #ifndef OMAP3530_HARDWARE_BASE_H__ # define OMAP3530_HARDWARE_BASE_H__ #include <assp.h> // for TPhysAddr, AsspRegister #include <assp/omap3530_assp/omap3530_asspreg.h> namespace TexasInstruments { namespace Omap3530 { /** Define constants for the various physical address blocks used on the OMAP3530 */ enum TPhysicalAddresses { KKiloByte = 1024, KMegaByte = (1024 * KKiloByte), KL4_Core_PhysicalBase = 0x48000000, KL4_Core_PhysicalSize = (4 * KMegaByte), KL4_Core_PhysicalEnd = (KL4_Core_PhysicalBase + KL4_Core_PhysicalSize), KL4_WakeUp_PhysicalBase = 0x48300000, KL4_WakeUp_PhysicalSize = (256 * KKiloByte ), KL4_WakeUp_PhysicalEnd = (KL4_WakeUp_PhysicalBase + KL4_WakeUp_PhysicalSize), KL4_Per_PhysicalBase = 0x49000000, KL4_Per_PhysicalSize = (1 * KMegaByte), KL4_Per_PhysicalEnd = (KL4_Per_PhysicalBase + KL4_Per_PhysicalSize), KL4_Sgx_PhysicalBase = 0x50000000, KL4_Sgx_PhysicalSize = (64 * KKiloByte), KL4_Sgx_PhysicalEnd = (KL4_Sgx_PhysicalBase + KL4_Sgx_PhysicalSize), KL4_Emu_PhysicalBase = 0x54000000, KL4_Emu_PhysicalSize = (8 * KMegaByte), KL4_Emu_PhysicalEnd = (KL4_Emu_PhysicalBase + KL4_Emu_PhysicalSize), KL3_Control_PhysicalBase = 0x68000000, KL3_Control_PhysicalSize = (1 * KMegaByte), KL3_Control_PhysicalEnd = (KL3_Control_PhysicalBase + KL3_Control_PhysicalSize), KL3_Gpmc_PhysicalBase = 0x6e000000, KL3_Gpmc_PhysicalSize = (1 * KMegaByte), KL3_Gpmc_PhysicalEnd = (KL3_Gpmc_PhysicalBase + KL3_Gpmc_PhysicalSize) } ; /** Define constants for the virtual address mappings used on the OMAP3530 */ enum TLinearAddresses { KL4_Core_LinearBase = 0xC6000000, KL4_Core_LinearSize = KL4_Core_PhysicalSize, KL4_Core_LinearEnd = (KL4_Core_LinearBase + KL4_Core_LinearSize), KL4_WakeUp_LinearBase = (KL4_Core_LinearBase + (KL4_WakeUp_PhysicalBase - KL4_Core_PhysicalBase)), KL4_WakeUp_LinearSize = KL4_WakeUp_PhysicalSize, KL4_WakeUp_LinearEnd = (KL4_WakeUp_LinearBase + KL4_WakeUp_LinearSize), KL4_Per_LinearBase = KL4_Core_LinearEnd, KL4_Per_LinearSize = KL4_Per_PhysicalSize, KL4_Per_LinearEnd = (KL4_Per_LinearBase + KL4_Per_LinearSize), KL4_Sgx_LinearBase = KL4_Per_LinearEnd, KL4_Sgx_LinearSize = KL4_Sgx_PhysicalSize, KL4_Sgx_LinearEnd = (KL4_Sgx_LinearBase + KL4_Sgx_LinearSize), KL4_Emu_LinearBase = KL4_Sgx_LinearBase + KMegaByte, KL4_Emu_LinearSize = KL4_Emu_PhysicalSize, KL4_Emu_LinearEnd = (KL4_Emu_LinearBase + KL4_Emu_LinearSize), KL3_Control_LinearBase = KL4_Emu_LinearEnd, KL3_Control_LinearSize = KL3_Control_PhysicalSize, KL3_Control_LinearEnd = (KL3_Control_LinearBase + KL3_Control_LinearSize), KL3_Gpmc_LinearBase = KL3_Control_LinearEnd, KL3_Gpmc_LinearSize = KL3_Gpmc_PhysicalSize, KL3_Gpmc_LinearEnd = (KL3_Gpmc_LinearBase + KL3_Gpmc_LinearSize) } ; /** A template to provide the virtual address of a given physical address. @example @code enum TTimerBaseAddress { KGPTIMER1_Base = Omap3530HwBase::TVirtual<0x48318000>::Value, } ; */ template<const TPhysAddr aDdReSs> struct TVirtual { enum TConstants { KIsL4Core = ((aDdReSs >= KL4_Core_PhysicalBase) && (aDdReSs < KL4_Core_PhysicalEnd)), KIsL4WakeUp = ((aDdReSs >= KL4_WakeUp_PhysicalBase) && (aDdReSs < KL4_WakeUp_PhysicalEnd)), // Subset of L4Core KIsL4Per = ((aDdReSs >= KL4_Per_PhysicalBase) && (aDdReSs < KL4_Per_PhysicalEnd)), KIsL4Sgx = ((aDdReSs >= KL4_Sgx_PhysicalBase) && (aDdReSs < KL4_Sgx_PhysicalEnd)), KIsL4Emu = ((aDdReSs >= KL4_Emu_PhysicalBase) && (aDdReSs < KL4_Emu_PhysicalEnd)), KIsL3Control = ((aDdReSs >= KL3_Control_PhysicalBase) && (aDdReSs < KL3_Control_PhysicalEnd)), KIsL3Gpmc = ((aDdReSs >= KL3_Gpmc_PhysicalBase) && (aDdReSs < KL3_Gpmc_PhysicalEnd)), KIsConvertable = (KIsL4Core || KIsL4Per || KIsL4Sgx || KIsL4Emu || KIsL3Control || KIsL3Gpmc), KIsMapped = (KIsL4Core || KIsL4Per || KIsL4Sgx || KIsL4Emu || KIsL3Control || KIsL3Gpmc), KOffset = ((KIsL4Core) ? (aDdReSs - KL4_Core_PhysicalBase) : ((KIsL4Per) ? (aDdReSs - KL4_Per_PhysicalBase) : ((KIsL4Sgx) ? (aDdReSs - KL4_Sgx_PhysicalBase) : ((KIsL4Emu) ? (aDdReSs - KL4_Emu_PhysicalBase) : ((KIsL3Control) ? (aDdReSs - KL3_Control_PhysicalBase) : ((KIsL3Gpmc) ? (aDdReSs - KL3_Gpmc_PhysicalBase) : (0))))))), // TODO: Change to give compile time error if address not mapped KLinearBase = ((KIsL4Core) ? (KL4_Core_LinearBase) : ((KIsL4Per) ? (KL4_Per_LinearBase) : ((KIsL4Sgx) ? (KL4_Sgx_LinearBase) : ((KIsL4Emu) ? (KL4_Emu_LinearBase) : ((KIsL3Control) ? (KL3_Control_LinearBase) : ((KIsL3Gpmc) ? (KL3_Gpmc_LinearBase) : (0))))))), /** Returns the Linear address mapping for a specific Physical address */ Value = (KLinearBase + KOffset) } ; } ; template<const TLinAddr aDdReSs> struct TLinearCheck { enum TConstants { KIsL4Core = ((aDdReSs >= KL4_Core_LinearBase) && (aDdReSs < KL4_Core_LinearEnd)), KIsL4Per = ((aDdReSs >= KL4_Per_LinearBase) && (aDdReSs < KL4_Per_LinearEnd)), KIsL4Sgx = ((aDdReSs >= KL4_Sgx_LinearBase) && (aDdReSs < KL4_Sgx_LinearEnd)), KIsL4Emu = ((aDdReSs >= KL4_Emu_LinearBase) && (aDdReSs < KL4_Emu_LinearEnd)), KIsL3Control = ((aDdReSs >= KL3_Control_LinearBase) && (aDdReSs < KL3_Control_LinearBase)), KIsL3Gpmc = ((aDdReSs >= KL3_Gpmc_LinearBase) && (aDdReSs < KL3_Gpmc_LinearBase)), KIsMapped = (KIsL4Core || KIsL4Per || KIsL4Sgx || KIsL4Emu || KIsL3Control || KIsL3Gpmc) } ; } ; # ifdef __MEMMODEL_MULTIPLE__ const TUint KL4_Core = KL4_Core_LinearBase; // KPrimaryIOBase const TUint KL4_Per = KL4_Per_LinearBase; const TUint KSgx = KL4_Sgx_LinearBase; const TUint KL4_Emu = KL4_Emu_LinearBase; const TUint KL3_Control = KL3_Control_LinearBase; const TUint KL3_Gpmc = KL3_Gpmc_LinearBase; //const TUint KIva2_2Ss = KL4_Core + 0x01910000; //const TUint KL3ControlRegisters = KL4_Core + 0x04910000; //const TUint KSmsRegisters = KL4_Core + 0x05910000; //const TUint KSdrcRegisters = KL4_Core + 0x06910000; //const TUint KGpmcRegisters = KL4_Core + 0x07910000; //#elif __MEMMODEL_FLEXIBLE__ // define flexible memery model hw base addresses # else // unknown memery model # error hardware_base.h: Constants may need changing # endif // memory model // Register Access types. typedef TUint32 TRegValue; typedef TUint32 TRegValue32; typedef TUint16 TRegValue16; typedef TUint8 TRegValue8; /** An interface template for read-only registers. */ template <TLinAddr aDdReSs> class TReg32_R { public : static inline TRegValue Read() { __ASSERT_COMPILE((TLinearCheck<aDdReSs>::KIsMapped)) ; return AsspRegister::Read32(aDdReSs) ; } } ; template <TLinAddr aDdReSs> class TReg16_R { public : static inline TRegValue16 Read() { __ASSERT_COMPILE((TLinearCheck<aDdReSs>::KIsMapped)) ; return AsspRegister::Read16(aDdReSs) ; } } ; template <TLinAddr aDdReSs> class TReg8_R { public : static inline TRegValue8 Read() { __ASSERT_COMPILE((TLinearCheck<aDdReSs>::KIsMapped)) ; return AsspRegister::Read8(aDdReSs) ; } } ; /** An interface template for read-write registers. */ template <TLinAddr aDdReSs> class TReg32_RW : public TReg32_R<aDdReSs> { public : static inline void Write(const TRegValue aValue) { __ASSERT_COMPILE((TLinearCheck<aDdReSs>::KIsMapped)) ; AsspRegister::Write32(aDdReSs, aValue) ; } static inline void Modify(const TRegValue aClearMask, const TRegValue aSetMask) { __ASSERT_COMPILE((TLinearCheck<aDdReSs>::KIsMapped)) ; AsspRegister::Modify32(aDdReSs, aClearMask, aSetMask) ; } } ; template <TLinAddr aDdReSs> class TReg16_RW : public TReg16_R<aDdReSs> { public : static inline void Write(const TRegValue16 aValue) { __ASSERT_COMPILE((TLinearCheck<aDdReSs>::KIsMapped)) ; AsspRegister::Write16(aDdReSs, aValue) ; } static inline void Modify(const TRegValue16 aClearMask, const TRegValue16 aSetMask) { __ASSERT_COMPILE((TLinearCheck<aDdReSs>::KIsMapped)) ; AsspRegister::Modify16(aDdReSs, aClearMask, aSetMask) ; } } ; template <TLinAddr aDdReSs> class TReg8_RW : public TReg8_R<aDdReSs> { public : static inline void Write(const TRegValue8 aValue) { __ASSERT_COMPILE((TLinearCheck<aDdReSs>::KIsMapped)) ; AsspRegister::Write8(aDdReSs, aValue) ; } static inline void Modify(const TRegValue8 aClearMask, const TRegValue8 aSetMask) { __ASSERT_COMPILE((TLinearCheck<aDdReSs>::KIsMapped)) ; AsspRegister::Modify8(aDdReSs, aClearMask, aSetMask) ; } } ; /** An interface template for write-only registers. */ template <TLinAddr aDdReSs> class TReg32_W { public : static inline void Write(const TRegValue aValue) { __ASSERT_COMPILE((TLinearCheck<aDdReSs>::KIsMapped)) ; AsspRegister::Write32(aDdReSs, aValue) ; } } ; template <TLinAddr aDdReSs> class TReg16_W { public : static inline void Write(const TRegValue16 aValue) { __ASSERT_COMPILE((TLinearCheck<aDdReSs>::KIsMapped)) ; AsspRegister::Write16(aDdReSs, aValue) ; } } ; template <TLinAddr aDdReSs> class TReg8_W { public : static inline void Write(const TRegValue8 aValue) { __ASSERT_COMPILE((TLinearCheck<aDdReSs>::KIsMapped)) ; AsspRegister::Write8(aDdReSs, aValue) ; } } ; /** Class for registers that have dynamic base address */ template <class T, TUint OfFsEt> class TDynReg8_R { public : static inline TRegValue8 Read( const T& aOwner ) { return AsspRegister::Read8( aOwner.Base() + OfFsEt ) ; } } ; template <class T, TUint OfFsEt> class TDynReg16_R { public : static inline TRegValue16 Read( const T& aOwner ) { return AsspRegister::Read16( aOwner.Base() + OfFsEt ) ; } } ; template <class T, TUint OfFsEt> class TDynReg32_R { public : static inline TRegValue32 Read( const T& aOwner ) { return AsspRegister::Read32( aOwner.Base() + OfFsEt ) ; } } ; template <class T, TUint OfFsEt> class TDynReg8_RW : public TDynReg8_R<T, OfFsEt> { public : static inline void Write( T& aOwner, const TRegValue8 aValue) { AsspRegister::Write8( aOwner.Base() + OfFsEt, aValue) ; } static inline void Modify( T& aOwner, const TRegValue8 aClearMask, const TRegValue8 aSetMask) { AsspRegister::Modify8( aOwner.Base() + OfFsEt, aClearMask, aSetMask) ; } } ; template <class T, TUint OfFsEt> class TDynReg16_RW : public TDynReg16_R<T, OfFsEt> { public : static inline void Write( T& aOwner, const TRegValue16 aValue) { AsspRegister::Write16( aOwner.Base() + OfFsEt, aValue) ; } static inline void Modify( T& aOwner, const TRegValue16 aClearMask, const TRegValue16 aSetMask) { AsspRegister::Modify16( aOwner.Base() + OfFsEt, aClearMask, aSetMask) ; } } ; template <class T, TUint OfFsEt> class TDynReg32_RW : public TDynReg32_R<T, OfFsEt> { public : static inline void Write( T& aOwner, const TRegValue32 aValue) { AsspRegister::Write32( aOwner.Base() + OfFsEt, aValue) ; } static inline void Modify( T& aOwner, const TRegValue32 aClearMask, const TRegValue32 aSetMask) { AsspRegister::Modify32( aOwner.Base() + OfFsEt, aClearMask, aSetMask) ; } } ; template <class T, TUint OfFsEt> class TDynReg8_W { public : static inline void Write( T& aOwner, const TRegValue8 aValue) { AsspRegister::Write8( aOwner.Base() + OfFsEt, aValue) ; } static inline void Modify( T& aOwner, const TRegValue8 aClearMask, const TRegValue8 aSetMask) { AsspRegister::Modify8( aOwner.Base() + OfFsEt, aClearMask, aSetMask) ; } } ; template <class T, TUint OfFsEt> class TDynReg16_W { public : static inline void Write( T& aOwner, const TRegValue16 aValue) { AsspRegister::Write16( aOwner.Base() + OfFsEt, aValue) ; } static inline void Modify( T& aOwner, const TRegValue16 aClearMask, const TRegValue16 aSetMask) { AsspRegister::Modify16( aOwner.Base() + OfFsEt, aClearMask, aSetMask) ; } } ; template <class T, TUint OfFsEt> class TDynReg32_W { public : static inline void Write( T& aOwner, const TRegValue32 aValue) { AsspRegister::Write32( aOwner.Base() + OfFsEt, aValue) ; } static inline void Modify( T& aOwner, const TRegValue32 aClearMask, const TRegValue32 aSetMask) { AsspRegister::Modify32( aOwner.Base() + OfFsEt, aClearMask, aSetMask) ; } } ; /** An Null class for when no register access is required. */ class TNull_Reg { public : static inline TRegValue Read() { return 0 ; } static inline void Write(const TRegValue) { } static inline void Modify(const TRegValue, const TRegValue) { } } ; template <int aBiTpOsItIoN> class TBit { public : enum TConstants { KValue = (1 << aBiTpOsItIoN) } ; } ; template <int aBiTpOsItIoN, int aBiTwIdTh> class TBitFieldBase { public : enum TConstants { KShift = aBiTpOsItIoN, KValueMask = (TBit<aBiTwIdTh>::KValue - 1), KFieldMask = (KValueMask << KShift), KValueMax = KValueMask } ; } ; template <int aBiTpOsItIoN, int aBiTwIdTh, int aVaLuE> class TBitFieldValue : public TBitFieldBase<aBiTpOsItIoN, aBiTwIdTh> { public : using TBitFieldBase<aBiTpOsItIoN, aBiTwIdTh>::KShift ; using TBitFieldBase<aBiTpOsItIoN, aBiTwIdTh>::KValueMask ; using TBitFieldBase<aBiTpOsItIoN, aBiTwIdTh>::KFieldMask ; using TBitFieldBase<aBiTpOsItIoN, aBiTwIdTh>::KValueMax ; enum TValues { KValue = ((KValueMask & aVaLuE) << KShift) } ; } ; template <int aBiTpOsItIoN, int aBiTwIdTh> class TBitField : public TBitFieldBase<aBiTpOsItIoN, aBiTwIdTh> { using TBitFieldBase<aBiTpOsItIoN, aBiTwIdTh>::KShift ; using TBitFieldBase<aBiTpOsItIoN, aBiTwIdTh>::KValueMask ; using TBitFieldBase<aBiTpOsItIoN, aBiTwIdTh>::KFieldMask ; using TBitFieldBase<aBiTpOsItIoN, aBiTwIdTh>::KValueMax ; public : template <int aVaLuE> class TConstVal : public TBitFieldValue<aBiTpOsItIoN, aBiTwIdTh, aVaLuE> { public : using TBitFieldValue<aBiTpOsItIoN, aBiTwIdTh, aVaLuE>::KValue ; } ; inline TBitField(const TRegValue aValue) : iValue((KValueMask & aValue) << KShift) {} inline TBitField(const TRegValue * aValuePtr) : iValue(KFieldMask & *aValuePtr) {} template <TLinAddr aDdReSs> inline TBitField(const TReg32_R<aDdReSs>& aReg) : iValue(KFieldMask & aReg.Read()) {} inline TRegValue Value() const {return (KValueMask & (iValue >> KShift)) ;} inline TRegValue RegField() const {return (iValue) ;} private : TRegValue iValue ; } ; template <int aBiTpOsItIoN> class TSingleBitField : public TBitField<aBiTpOsItIoN, 1> { public : enum TConstants { KOff = 0, KOn = (1 << aBiTpOsItIoN), KClear = KOff, KSet = KOn, KMask = KOn, } ; } ; } ; // namespace Omap3530 } ; // namespace TexasInstruments namespace TI = TexasInstruments ; namespace OMAP3530 = TexasInstruments::Omap3530 ; namespace Omap3530HwBase = TexasInstruments::Omap3530 ; // **** TEST CODE **** //# define HEADER_OMAP3530_HARDWARE_BASE_H_DO_COMPILE_TIME_CHECK_TESTS 1 # ifdef HEADER_OMAP3530_HARDWARE_BASE_H_DO_COMPILE_TIME_CHECK_TESTS inline void CompileTimeChecks(void) { __ASSERT_COMPILE((Omap3530HwBase::TVirtual<0x48318000>::KIsL4Core)) ; __ASSERT_COMPILE((TI::Omap3530::TVirtual<0x48318000>::KIsL4WakeUp)) ; __ASSERT_COMPILE((!Omap3530HwBase::TVirtual<0x48318000>::KIsL4Emu)) ; __ASSERT_COMPILE((!Omap3530HwBase::TVirtual<0x0000FFFF>::KIsConvertable)) ; __ASSERT_COMPILE((Omap3530HwBase::TLinearCheck< Omap3530HwBase::TVirtual<0x48318000>::Value >::KIsMapped)) ; __ASSERT_COMPILE((!Omap3530HwBase::TLinearCheck< Omap3530HwBase::TVirtual<0x0000FFFF>::Value >::KIsMapped)) ; const TLinAddr mapped(Omap3530HwBase::TVirtual<0x48318000>::Value) ; const TLinAddr unmapped(Omap3530HwBase::TVirtual<0x0000FFFF>::Value) ; __ASSERT_COMPILE((Omap3530HwBase::TLinearCheck< mapped >::KIsMapped)) ; __ASSERT_COMPILE((!Omap3530HwBase::TLinearCheck< unmapped >::KIsMapped)) ; __ASSERT_COMPILE((0)) ; // Prove that testing is happening } # endif const TUint KSetNone = 0; const TUint KSetAll = 0xffffffff; const TUint KClearNone = 0; const TUint KClearAll = 0xffffffff; const TUint KHOmapClkULPD48Mhz = 48000000; #endif // !OMAP3530_HARDWARE_BASE_H__
[ [ [ 1, 569 ] ] ]
406700609b255afcc4abbea17eb93206ba393d93
3ec3b97044e4e6a87125470cfa7eef535f26e376
/darkbits-secret_of_fantasy_2/src/Character.hpp
2b1ce6104877498f811b5292144d3a31856370d9
[]
no_license
strategist922/TINS-Is-not-speedhack-2010
6d7a43ebb9ab3b24208b3a22cbcbb7452dae48af
718b9d037606f0dbd9eb6c0b0e021eeb38c011f9
refs/heads/master
2021-01-18T14:14:38.724957
2010-10-17T14:04:40
2010-10-17T14:04:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,901
hpp
#pragma once #include "Entity.hpp" #include "ActionTrigger.hpp" class Action; class Battle; class Font; class Character : public Entity { public: enum Damage { Damage_Physical, Damage_Fire, Damage_Ice, Damage_Lighting, Damage_Cure, Damage_Hack }; enum Faction { Faction_Player, Faction_Enemy, Faction_None, }; void setBattle(Battle* battle); protected: Character(Faction faction, const std::string &name, int homeX, int homeY, int level, int hp, int mp, float speed); void setHeight(int aHeight); public: virtual ~Character(); virtual bool isPrepareCastStateEntered() { return true;} virtual void enterPrepareCastState() {} virtual void enterIdleState() {} virtual bool isIdleStateEntered() { return true;} virtual void enterCastState() {} virtual bool isCastStateEntered() { return true; } virtual void enterDeadState() { myDying = true; } virtual bool isDeadStateEntered() { return true; } virtual void enterDamageState() {} virtual void enterAttackState() {} virtual bool isAttackStateEntered() { return true; } virtual void enterHideState() {} virtual bool isHideStateEntered() { return true; } virtual Faction getFaction(); virtual std::string getName(); virtual int getMarkerX(); virtual int getMarkerY(); virtual void onLogic(); virtual void onRender(BITMAP *dest); virtual float getZOrder(); virtual bool isToBeDestroyed(); virtual int getX(); virtual int getY(); virtual bool isDead(); virtual int getHP(); virtual void setHP(int hp); virtual int getMaxHP(); virtual void setMaxHP(int maxHP); virtual void adjustHP(int delta); virtual int getMP(); virtual void setMP(int mp); virtual int getMaxMP(); virtual void setMaxMP(int maxMP); virtual void adjustMP(int delta); virtual int getLevel(); virtual void setLevel(int level); virtual float getSpeed(); virtual void setSpeed(float speed); virtual float getTime(); virtual bool isReadyForAction(); virtual float getDamageSensitivity(Damage type); virtual int damage(int amount, Damage type); void addActionTrigger(const std::string& name); const std::set<ActionTrigger> getActionTriggers(); const std::set<ActionTrigger> getSpellActionTriggers(); const std::set<ActionTrigger> getSpecialActionTriggers(); void setQueuedAction(Action *action); virtual void flee() {}; int getHeight(); int getCenterX(); int getCenterY(); void setHome(int x, int y); void setPosition(int x, int y); protected: Faction myFaction; std::string myName; int myX, myY; int myHomeX, myHomeY; int myHeight; int myHP, myMaxHP, myMP, myMaxMP; int myLevel; float mySpeed; float myTime; Action *myQueuedAction; Battle *myBattle; bool myDying; std::set<ActionTrigger> myActionTriggers; };
[ [ [ 1, 144 ] ] ]
5741fe6998d2487afed7a4e23118a3ab80ddc3ae
6c8c4728e608a4badd88de181910a294be56953a
/Interfaces/ServiceInterface.h
18059e807b1a1d55aafbdd72ae4b8d61c017114b
[ "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,141
h
// For conditions of distribution and use, see copyright notice in license.txt #ifndef incl_Interfaces_ServiceInterface_h #define incl_Interfaces_ServiceInterface_h #include "CoreModuleApi.h" namespace Foundation { //! Common interface for all services /*! \ingroup Foundation_group \ingroup Services_group */ class MODULE_API ServiceInterface { public: ServiceInterface() {} virtual ~ServiceInterface() {} }; typedef boost::shared_ptr<ServiceInterface> ServicePtr; typedef boost::weak_ptr<ServiceInterface> ServiceWeakPtr; namespace Service { //! Service types. When creating a new core service, add it here. /*! If you can't or don't want to alter the framework, an arbitrary int can be used as service type. For details, see \ref creating_services. \ingroup Services_group */ enum Type {ST_Renderer, ST_Physics, ST_Gui, ST_Scripting, ST_Console, ST_ConsoleCommand, ST_Asset, ST_Texture, ST_Sound, ST_Input, ST_Communication, ST_Unknown }; } } #endif
[ "cmayhem@5b2332b8-efa3-11de-8684-7d64432d61a3", "jujjyl@5b2332b8-efa3-11de-8684-7d64432d61a3", "jaakkoallander@5b2332b8-efa3-11de-8684-7d64432d61a3", "jjj@5b2332b8-efa3-11de-8684-7d64432d61a3", "cadaver@5b2332b8-efa3-11de-8684-7d64432d61a3" ]
[ [ [ 1, 5 ], [ 8, 14 ], [ 16, 23 ], [ 35, 37 ] ], [ [ 6, 6 ] ], [ [ 7, 7 ] ], [ [ 15, 15 ] ], [ [ 24, 34 ] ] ]
e05b509fa943cd4a6363eadafe6f449a240d79a8
51574a600a87ecfaaec8ea0e46b3809884859680
/MotionPlan/GridMapView.inl
d244ba61da1d061a4f2cce1dd924676b31ab9c43
[]
no_license
suilevap/motion-plan
b5ad60a8448b118c3742c8c9c42b29fd5e41ef3e
d9f5693938287f2179ca2cb4eb75bda51b97bbb0
refs/heads/master
2021-01-10T03:29:50.373970
2011-12-20T22:39:55
2011-12-20T22:39:55
49,495,165
0
0
null
null
null
null
UTF-8
C++
false
false
14,858
inl
#ifndef MOTIONPLAN_GRIDMAPVIEW_H_ #error "Include from GridMapView.h only." #else #include "DistanceEvaluator.h" #include "MathConstants.h" template<class CellType, typename CoordType> void GridMapView<CellType, CoordType>::GetNeighbors(int node, FastVector<AStar::EdgeInfo<int,float>>& neighbors) { neighbors.clear(); neighbors.resize(8); static float step1 = 1 * _cellSize.X;//_cellSize.X; static float stepD = SQRT_2 * _cellSize.X;//_cellSize.X * SQRT_2; AddNeighbor( GetNodeDxDy(node, 1, 0) , step1, neighbors); AddNeighbor( GetNodeDxDy(node, - 1, 0) , step1, neighbors); AddNeighbor( GetNodeDxDy(node, 0, 1) , step1, neighbors); AddNeighbor( GetNodeDxDy(node, 0, -1) , step1, neighbors); AddNeighbor( GetNodeDxDy(node, 1, 1), stepD, neighbors); AddNeighbor( GetNodeDxDy(node, 1, -1), stepD, neighbors); AddNeighbor( GetNodeDxDy(node, -1, 1), stepD, neighbors); AddNeighbor( GetNodeDxDy(node, -1, -1), stepD, neighbors); } template<class CellType, typename CoordType> inline void GridMapView<CellType, CoordType>::AddNeighbor(int node, float d, FastVector<AStar::EdgeInfo<int,float>>& neighbors) { if (GetCell(node) != ObstacleCellValue) { neighbors.push_back(AStar::EdgeInfo<int,float>(node, d)); } } template<class CellType, typename CoordType> inline void GridMapView<CellType, CoordType>::TransformPointToCell(Point<CoordType>& pointFrom, Point<int>& pointTo) { pointTo.X = static_cast<int>(pointFrom.X * _scale.X ); pointTo.Y = static_cast<int>(pointFrom.Y * _scale.Y ); } template<class CellType, typename CoordType> inline void GridMapView<CellType, CoordType>::TransformPointToWorld(Point<int>& pointFrom, Point<CoordType>& pointTo) { pointTo.X = static_cast<CoordType>((pointFrom.X + 0.5) * _cellSize.X ); pointTo.Y = static_cast<CoordType>((pointFrom.Y + 0.5) * _cellSize.Y ); } template<class CellType, typename CoordType> inline Point<int> GridMapView<CellType, CoordType>::GetMapPoint(int node) { Point<int> pointMap; pointMap.X = node % _width - _border; pointMap.Y = node / _width - _border; return pointMap; } template<class CellType, typename CoordType> inline int GridMapView<CellType, CoordType>:: GetNodeFromMapPoint(const Point<int>& pointMap) { return (pointMap.X + _border) + (pointMap.Y + _border) * _width ; } template<class CellType, typename CoordType> inline int GridMapView<CellType, CoordType>::GetNodeDxDy(int node, int dx, int dy) { return node + dx + dy * _width; } template<class CellType, typename CoordType> Point<CoordType> GridMapView<CellType, CoordType>::GetPoint(int node) { Point<CoordType> pointWorld; Point<int> pointMap = GetMapPoint(node); TransformPointToWorld(pointMap, pointWorld ); return pointWorld; } template<class CellType, typename CoordType> float GridMapView<CellType, CoordType>::GetCost(Point<CoordType>& p1,Point<CoordType>& p2) { float cost = AStar::DistanceEvaluator::DiagonalDistance<float>(p1, p2); return cost; } template<class CellType, typename CoordType> int GridMapView<CellType, CoordType>::GetNode(Point<CoordType>& pointWorld) { Point<int >pointMap; TransformPointToCell(pointWorld, pointMap); return GetNodeFromMapPoint(pointMap); } template<class CellType, typename CoordType> Point<CoordType> GridMapView<CellType, CoordType>::GetMaxPoint() { Point<int> p; p.X = _width - _border * 2 - 1; p.Y = _height - _border * 2 - 1; Point<CoordType> result; TransformPointToWorld(p, result); result.X += _cellSize.X / 2; result.Y += _cellSize.Y / 2; return result; } template<class CellType, typename CoordType> bool GridMapView<CellType, CoordType>::OnMap(Point<CoordType>& point) { Point<CoordType> maxPoint = GetMaxPoint(); return ((point.X >= 0) &&(point.Y >= 0)&&(point.X < maxPoint.X)&&(point.Y < maxPoint.Y)); } template<class CellType, typename CoordType> int GridMapView<CellType, CoordType>::GetMaxNode() { return _width * _height; } template<class CellType, typename CoordType> inline int GridMapView<CellType, CoordType>::GetBorder() { return _border; } template<class CellType, typename CoordType> void GridMapView<CellType, CoordType>::InitMap(CoordType width, CoordType height, int border, Point<CoordType> cellSize) { _distanceField = NULL; _cellSize = cellSize; _scale = Point<float>(1.0f / _cellSize.X, 1.0f / _cellSize.Y); Point<int> mapSize; Point<CoordType> dataSize(width, height); TransformPointToCell(dataSize, mapSize); _border = border; _width = mapSize.X + _border * 2; _height = mapSize.Y + _border * 2; int size = _width * _height; //_map = new CellType[size]; _map.resize(size); Clear( FreeCellValue, ObstacleCellValue); } template<class CellType, typename CoordType> GridMapView<CellType, CoordType>::GridMapView(CoordType width, CoordType height) :ObstacleCellValue(1),FreeCellValue(0) { InitMap(width, height, 1, Point<CoordType>(1,1)); } template<class CellType, typename CoordType> GridMapView<CellType, CoordType>::GridMapView(CoordType width, CoordType height, CoordType cellWidth) :ObstacleCellValue(1),FreeCellValue(0) { InitMap(width, height, 1, Point<CoordType>(cellWidth, cellWidth)); } template<class CellType, typename CoordType> GridMapView<CellType, CoordType>::GridMapView() :ObstacleCellValue(1),FreeCellValue(0) { } //template<class CellType, typename CoordType> //GridMapView<CellType, CoordType>::GridMapView(int width, int height, int border) //{ // InitMap(width, height, border); //} template<class CellType, typename CoordType> GridMapView<CellType, CoordType>::~GridMapView(void) { //delete[] _map; } template<class CellType, typename CoordType> void GridMapView<CellType, CoordType>::SetCellRegion(Point<CoordType>& point, CellType cell, Point<CoordType>& size) { for (float i = point.X; i < (point.X + size.X); i += _cellSize.X/2) { for (float k = point.Y; k < (point.Y + size.Y); k += _cellSize.Y/2) { Point<CoordType> curPoint(i,k); int node = GetNodeWrite(curPoint); SetCell(node, cell); } } } template<class CellType, typename CoordType> void GridMapView<CellType, CoordType>::Clear(CellType value, CellType valueBorder) { int size = _width*_height; _map.assign(size, value); if (value != valueBorder) { for (int i = 0; i < _height; ++i) { for (int k = 0; k < _border; ++k) { //TODO: use SetCell _map[i * _width + k] = valueBorder; _map[i * _width + _width - k - 1] = valueBorder; } } for (int k = _border; k < _width - _border; ++k) { for (int i = 0; i < _border; ++i) { //TODO: use SetCell _map[i * _width + k] = valueBorder; _map[(_height - i - 1) * _width + k] = valueBorder; } } } } template<class CellType, typename CoordType> bool GridMapView<CellType, CoordType>:: IsCellRegionIsotropic(Point<CoordType>& point1, Point<CoordType>& point2, CellType* cell) { bool result; CellType baseCell = GetCellPoint(point1); CellType currentCell; Point<CoordType> cellSize = GetCellSize(); for (float i = point1.X; i < point2.X; i += cellSize.X/2) { for (float k = point1.Y; k < point2.Y; k += cellSize.Y/2) { Point<CoordType> curPoint(i,k); currentCell = GetCellPoint(curPoint); if (currentCell != baseCell) { //TODO: several return - bad return false; } } } *cell = baseCell; return true; } template<class CellType, typename CoordType> GridMapView<float, CoordType>* GridMapView<CellType, CoordType>:: GetDistanceField() { //TODO: thread unsafe if (_distanceField == NULL) { CreateDistanceField(); } return _distanceField; } template<class CellType, typename CoordType> void GridMapView<CellType, CoordType>:: CreateDistanceField() { Point<CoordType> size = GetMaxPoint(); GridMapView<float, CoordType>* result = new GridMapView<float, CoordType>( size.X, size.Y, _cellSize.X); float width = size.X; float height = size.Y; Point<CoordType> fieldCellSize = result->GetCellSize(); //generate distance field //pass 1 for (float k = 0; k < height; k += fieldCellSize.Y) { for (float i = 0; i < width; i += fieldCellSize.X) { Point<CoordType> point(i, k); int id = result->GetNode(point); int value; if (GetCellPoint(point) == GridMapView<CellType, CoordType>::FreeCellValue) { //border if(k>0 && k<height-fieldCellSize.Y && i>0 && i<width-fieldCellSize.X) { value = min( min( result->GetCell(result->GetNodeDxDy(id, -1, 0)), result->GetCell(result->GetNodeDxDy(id, 0, -1))) +1, min( result->GetCell(result->GetNodeDxDy(id, -1, -1)), result->GetCell(result->GetNodeDxDy(id, 1, -1))) +SQRT_2 ); } else { value = 1; } } else { value = 0; } result->SetCell(id, value); } } //pass 2 for (float k = height-fieldCellSize.Y/2; k >= 0; k -= fieldCellSize.Y) { for (float i = width-fieldCellSize.X/2; i >= 0; i -= fieldCellSize.X) { Point<CoordType> point(i, k); int id = result->GetNode(point); int value; if (GetCellPoint(point) == GridMapView<CellType, CoordType>::FreeCellValue) { //border if(k>0 && k<height-fieldCellSize.Y && i>0 && i<width-fieldCellSize.X) { value = min( min( result->GetCell(result->GetNodeDxDy(id, 1, 0)), result->GetCell(result->GetNodeDxDy(id, 0, 1))) +1, min( result->GetCell(result->GetNodeDxDy(id, 1, 1)), result->GetCell(result->GetNodeDxDy(id, -1, 1))) +SQRT_2 ); value = min(value, result->GetCell(id)); } else { value = 1; } } else { value = 0; } result->SetCell(id, value); } } ////blur //for (int k = height-fieldCellSize.Y; k > fieldCellSize.Y; k -= fieldCellSize.Y) //{ // for (int i = width-fieldCellSize.X; i > fieldCellSize.X; i -= fieldCellSize.X) // { // Point<CoordType> point(i, k); // float // result->SetCellPoint(point // } //} //TODO: thread unsafe if (_distanceField != NULL) { delete _distanceField; } _distanceField = result; } template<class CellType, typename CoordType> int GridMapView<CellType, CoordType>:: ToVector(std::vector<CellType>* data) { Point<CoordType> size = GetMaxPoint(); int width = static_cast<int>(size.X /_cellSize.X); int height = static_cast<int>(size.Y / _cellSize.Y); data->resize(width*height); for (int k = 0; k < height; k++) { for (int i = 0; i < width; i++) { Point<CoordType> point(i * _cellSize.X, k * _cellSize.Y); int id = k*width + i; (*data)[id] = GetCellPoint(point); } } return width; } //only for test!! template<class CellType, typename CoordType> void GridMapView<CellType, CoordType>::ToOutput() { Point<CoordType> size = GetMaxPoint(); float w = size.X; float h = size.Y; for (float k = 0; k < h; k += _cellSize.Y) { for (float i =0; i < w; i += _cellSize.X) { //printf("%3d",(int)( (int)(GetCell(i , k)*10 )%100 )); Point<CoordType> point(i , k); printf("%2d",(int)GetCellPoint(point)); } printf("\n"); } printf("========================\n"); } template<class CellType, typename CoordType> void GridMapView<CellType, CoordType>::ToOutputField() { const char * presentation = "\\|/-.-/|\\"; Point<CoordType> size = GetMaxPoint(); int w = size.X; int h = size.Y; for (int k = 0; k < h; k += _cellSize.Y) { for (int i =0; i < w; i += _cellSize.X) { int dx; int dy; int ind1 = (int)GetCell(i , k); int ind2 = GetCellIndex(i, k); GetD(ind1, ind2, &dx, &dy); char s; if (ind1 != 0) { s = presentation[(dx+1)+(dy+1)*3]; } else { s = '.'; } printf("%c", s); //printf("%3d",(dx+1)*10+(dy+1)); } printf("\n"); } printf("========================\n"); } template<class CellType, typename CoordType> GridMapView<int>* GridMapView<CellType, CoordType>::LoadFrom(std::string &data, std::vector<Point<CoordType>>* specialPoints) { int width = data.find("\r\n"); int height = (data.length()+2) / (width + 2); GridMapView<int>* map = new GridMapView<int>(width, height); specialPoints->resize(10); int index = 0; int cell; for (int k = 0; k < height; k++) { for (int i = 0; i < width; i++) { char symbol=data[index]; if (symbol =='#') { cell = ObstacleCellValue; } else { cell = 0; } if ((symbol>='0') && (symbol<='9')) { int idx = (int)(symbol-'0'); Point<CoordType> point(i, k); (*specialPoints)[idx]=point; } map->SetCellPoint(Point<CoordType>(i,k), cell); index++; } index+=2; } return map; } template<class CellType, typename CoordType> void GridMapView<CellType, CoordType>::LoadFromVector(const std::vector<CellType>& data) { for (int i = 0; i < data.size(); ++i) { SetCell(i, data[i]); } } template<class CellType, typename CoordType> void GridMapView<CellType, CoordType>::LoadFromVector2D(Vector2D<CellType>& data) { int width = data.Width; int height = data.Height; for (int x = 0; x < width; ++x) { for (int y = 0; y < height; ++y) { int node = GetNodeFromMapPoint(Point<int>(x, y)); CellType value= data.GetData(x,y); SetCell(node, value); } } } #endif
[ "suilevap@localhost", "[email protected]" ]
[ [ [ 1, 13 ], [ 16, 30 ], [ 32, 80 ], [ 82, 147 ], [ 149, 271 ], [ 273, 278 ], [ 280, 280 ], [ 282, 291 ], [ 300, 315 ], [ 317, 317 ], [ 319, 328 ], [ 337, 462 ], [ 464, 485 ], [ 487, 493 ], [ 511, 511 ] ], [ [ 14, 15 ], [ 31, 31 ], [ 81, 81 ], [ 148, 148 ], [ 272, 272 ], [ 279, 279 ], [ 281, 281 ], [ 292, 299 ], [ 316, 316 ], [ 318, 318 ], [ 329, 336 ], [ 463, 463 ], [ 486, 486 ], [ 494, 510 ] ] ]
adc0af07d6c951946e64d3498b15e6175581b2fb
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/boost/tr1/utility.hpp
6cb90fde7ea9d15c1ad3d0fab960c5fb502109b6
[ "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
3,539
hpp
// (C) Copyright John Maddock 2005. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_TR1_UTILITY_HPP_INCLUDED # define BOOST_TR1_UTILITY_HPP_INCLUDED # include <boost/tr1/detail/config.hpp> #ifdef BOOST_HAS_TR1_UTILITY # ifdef BOOST_HAS_INCLUDE_NEXT # include_next BOOST_TR1_HEADER(utility) # else # include BOOST_TR1_STD_HEADER(BOOST_TR1_PATH(utility)) # endif #else #if defined(BOOST_TR1_USE_OLD_TUPLE) #include <boost/type_traits/integral_constant.hpp> #include <boost/type_traits/add_const.hpp> #include <boost/type_traits/add_reference.hpp> #include <boost/mpl/if.hpp> namespace std{ namespace tr1{ template <class T> struct tuple_size; // forward declaration template < int I, class T> struct tuple_element; // forward declaration #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template <class T1, class T2> struct tuple_size< ::std::pair<T1, T2> > : public ::boost::integral_constant< ::std::size_t, 2> { }; template <class T1, class T2> struct tuple_element<0, ::std::pair<T1, T2> > { typedef typename std::pair<T1, T2>::first_type type; }; template <class T1, class T2> struct tuple_element<1, std::pair<T1, T2> > { typedef typename std::pair<T1, T2>::second_type type; }; #endif namespace tuple_detail{ template <int I, class T1, class T2> struct tuple_get_result { typedef typename boost::mpl::if_c<I==0, T1, T2>::type t1; typedef typename boost::add_reference<t1>::type type; }; template <int I, class T1, class T2> struct const_tuple_get_result { typedef typename boost::mpl::if_c<I==0, T1, T2>::type t1; # if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x582)) // I have absolutely no idea why add_const is not working here for Borland! // It passes all other free-standing tests, some strange interaction going on typedef typename boost::add_reference< const t1 >::type type; # else typedef typename boost::add_const<t1>::type t2; typedef typename boost::add_reference<t2>::type type; # endif }; template<int I, class T1, class T2> inline typename tuple_detail::tuple_get_result<I,T1,T2>::type get(std::pair<T1, T2>& p, const ::boost::true_type&) { return p.first; } template<int I, class T1, class T2> inline typename tuple_detail::const_tuple_get_result<I,T1,T2>::type get(const std::pair<T1, T2>& p, const ::boost::true_type&) { return p.first; } template<int I, class T1, class T2> inline typename tuple_detail::tuple_get_result<I,T1,T2>::type get(std::pair<T1, T2>& p, const ::boost::false_type&) { return p.second; } template<int I, class T1, class T2> inline typename tuple_detail::const_tuple_get_result<I,T1,T2>::type get(const std::pair<T1, T2>& p, const ::boost::false_type&) { return p.second; } } template<int I, class T1, class T2> inline typename tuple_detail::tuple_get_result<I,T1,T2>::type get(std::pair<T1, T2>& p) { return tuple_detail::get<I>(p, boost::integral_constant<bool, I==0>()); } template<int I, class T1, class T2> inline typename tuple_detail::const_tuple_get_result<I,T1,T2>::type get(const std::pair<T1, T2>& p) { return tuple_detail::get<I>(p, boost::integral_constant<bool, I==0>()); } } } // namespaces #else #include <boost/tr1/tuple.hpp> #endif #endif #endif
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 122 ] ] ]
faea3ff783b6d1a4005133a9754b4e0bf27bc9ff
119ba245bea18df8d27b84ee06e152b35c707da1
/unreal/branches/typeRefactor-newAge/qrrepo/logicalRepoApi.h
fc474615625a7795d1b3b310910feda843c424ac
[]
no_license
nfrey/qreal
05cd4f9b9d3193531eb68ff238d8a447babcb3d2
71641e6c5f8dc87eef9ec3a01cabfb9dd7b0e164
refs/heads/master
2020-04-06T06:43:41.910531
2011-05-30T19:30:09
2011-05-30T19:30:09
1,634,768
0
0
null
null
null
null
UTF-8
C++
false
false
1,478
h
#pragma once #include "../qrgui/kernel/roles.h" #include "../qrgui/kernel/newType.h" #include "commonRepoApi.h" namespace qrRepo { class LogicalRepoApi : public CommonRepoApi { public: virtual ~LogicalRepoApi(){} virtual void addChild(qReal::Id const &id, qReal::Id const &child, qReal::NewType const &type) = 0; virtual qReal::Id otherEntityFromLink(qReal::Id const &linkId, qReal::Id const &firstNode) const = 0; virtual qReal::IdList outgoingConnections(qReal::Id const &id) const = 0; virtual qReal::IdList incomingConnections(qReal::Id const &id) const = 0; virtual void connect(qReal::Id const &source, qReal::Id const &destination) = 0; virtual void disconnect(qReal::Id const &source, qReal::Id const &destination) = 0; virtual qReal::IdList outgoingUsages(qReal::Id const &id) const = 0; virtual qReal::IdList incomingUsages(qReal::Id const &id) const = 0; virtual void addUsage(qReal::Id const &source, qReal::Id const &destination) = 0; virtual void deleteUsage(qReal::Id const &source, qReal::Id const &destination) = 0; virtual qReal::IdList logicalElements(qReal::NewType const &type) const = 0; virtual bool isLogicalElement(qReal::Id const &id) const = 0; virtual qReal::TypeList getAllTypes() const = 0; virtual void changeType(qReal::Id const &id, qReal::NewType const &type) const = 0; virtual qReal::IdList elementsByType(QString const &type) const = 0; virtual int elementsCount() const = 0; }; }
[ [ [ 1, 35 ] ] ]
9de77bb6573039c9c9c147439b44f959f7bd1762
a52ab677945cab174095a4f2315a63acf1903567
/P436/GESH_2/jobs.h
6fed54a3ae8bf4d23c7c67371785c157c69ff4f4
[]
no_license
grpatter/iu_cs_jegm
fe5f499c79fbbb7e0cd3d954d4fac95d0a0f631e
2a2d45eb4f7c5560a945d94a0e4e32f50ca46817
refs/heads/master
2021-01-19T18:30:34.722909
2009-12-30T02:51:20
2009-12-30T02:51:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
510
h
#include <iostream> #include <string> #define ARGS 10 struct jobStore{ int job_n; //char *cmd_a[ARGS]; //char *cmd_s; char *cmd_status; char *cmd_name; //string cmd_location; bool is_bg; struct jobStruct *realJob; }; typedef struct jobStruct{ char *cmd_path; int argc; char *argv[ARGS]; char *cmd_full; }jobStruct; struct filename{ char name[512]; off_t fsize; int links; uid_t uid; gid_t gid; mode_t mode; time_t mod_time; long file_blocks; dev_t dev_att; };
[ [ [ 1, 35 ] ] ]
3f7a56b724f288d50c66448350691390f8c90ae8
c1a2953285f2a6ac7d903059b7ea6480a7e2228e
/deitel/ch11/Fig11_03_05/Fig11_05.cpp
1de580677dd6f8fc38422ac7c1a529f071f7412d
[]
no_license
tecmilenio/computacion2
728ac47299c1a4066b6140cebc9668bf1121053a
a1387e0f7f11c767574fcba608d94e5d61b7f36c
refs/heads/master
2016-09-06T19:17:29.842053
2008-09-28T04:27:56
2008-09-28T04:27:56
50,540
4
3
null
null
null
null
UTF-8
C++
false
false
1,815
cpp
// Fig. 11.5: fig11_05.cpp // Demonstrating class PhoneNumber's overloaded stream insertion // and stream extraction operators. #include <iostream> using std::cout; using std::cin; using std::endl; #include "PhoneNumber.h" int main() { PhoneNumber phone; // create object phone cout << "Enter phone number in the form (123) 456-7890:" << endl; // cin >> phone invokes operator>> by implicitly issuing // the global function call operator>>( cin, phone ) cin >> phone; cout << "The phone number entered was: "; // cout << phone invokes operator<< by implicitly issuing // the global function call operator<<( cout, phone ) cout << phone << endl; return 0; } // end main /************************************************************************** * (C) Copyright 1992-2008 by Deitel & Associates, Inc. and * * Pearson Education, Inc. All Rights Reserved. * * * * DISCLAIMER: The authors and publisher of this book have used their * * best efforts in preparing the book. These efforts include the * * development, research, and testing of the theories and programs * * to determine their effectiveness. The authors and publisher make * * no warranty of any kind, expressed or implied, with regard to these * * programs or to the documentation contained in these books. The authors * * and publisher shall not be liable in any event for incidental or * * consequential damages in connection with, or arising out of, the * * furnishing, performance, or use of these programs. * **************************************************************************/
[ [ [ 1, 42 ] ] ]
425b52bd28ffbd3505a4141828af58bce7633c73
b7c073dfd73823cf85fcc5467644a307b52b90db
/projekt/projects/reSounder/VstHost/VstHost.cpp
46cc9348234e0066c6dabf2b409257cba6f0f9d0
[]
no_license
eriser/bfoozrocnikovy
dc0272cfd2869b611c76ee8859f961d6b3151f64
49244511e5fe15ce3dbd92f932fccec5df7f6bf1
refs/heads/master
2021-01-18T20:08:45.364014
2010-05-23T10:48:01
2010-05-23T10:48:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
40,927
cpp
#include "stdafx.h" #include "VstHost.h" #include <String> #include <cmath> #include "libraries/fft/fft.h" #include "libraries/FftConv/FftConv.h" #include "libraries/vst/audioeffect.h" using namespace std; VstHost::VstHost(){ message = gcnew String("VstHost > VstHost initialized"); ok_dry = ok_wet = ok_effect = false; processed = false; //logFile = new ofstream("c:/ReSounder_log.txt"); //null logFile = new ofstream(); logFile->clear(ios::failbit); logFile->precision(16); logFile->setf(ios::fixed); fftSize = rmsWindowSize = 1024; rmsOverlap = 0; segmentLength = rmsWindowSize; nl = gcnew String(Environment::NewLine); defaultParamValues = new float[9]; } VstHost::~VstHost(){ logFile->close(); delete logFile; delete drySound; delete wetSound; delete loader; delete defaultParamValues; } void VstHost::openDryFile(System::String ^name) { drySound = gcnew WaveReader(name); sampleRate = (long)drySound->getSampleRate(); message = gcnew String("VstHost > clean file '" + name + "' loaded"); ok_dry = true; } void VstHost::openWetFile(System::String ^ name) { wetSound = gcnew WaveReader(name); message = gcnew String("VstHost > wanted file '" + name + "' loaded"); ok_wet = true; } void VstHost::openEffectFile(String ^ fileName) { if (ok_effect) { delete loader; ok_effect = false; } loader = new VstLoader(); //konverzia z String na wchar_t* koli loadEffect(wchar_t*) wchar_t* chars = reinterpret_cast<wchar_t*>((Runtime::InteropServices::Marshal::StringToHGlobalUni(fileName)).ToPointer()); try { loader->loadEffect(chars); } catch (exception* e) { message = gcnew String(string("VstHost > ").append(e->what()).c_str()); throw gcnew Exception(message); } //ulozime defaultne hodnoty parametrov for (int i=0; i<loader->getNumParams(); i++) { defaultParamValues[i] = loader->getParam(i); } message = gcnew String(string("VstHost > ").append(loader->message.c_str()).c_str()); ok_effect = true; } int VstHost::getNumParams(){ return loader->getNumParams(); } String ^ VstHost::getParamName(int i) { String ^ name = gcnew String(loader->getParamName(i).c_str()); return name; } bool VstHost::getOk() { return (ok_dry & ok_wet & ok_effect); } void VstHost::fillArray(WaveReader ^reader, float *left, float *right) { reader->resetPosition(); if (reader->getNumChan() == 1) { //mono for (int i=0; i<dataLength; i++) { left[i] = right[i] = reader->getCurrentSample(0); reader->step(); } } else if (reader->getNumChan() == 2) { //stereo for (int i=0; i<dataLength; i++) { left[i] = reader->getCurrentSample(0); right[i] = reader->getCurrentSample(1); reader->step(); } } } void VstHost::process(int type, int* selectedParams, bool* volType, int* stepSize, int numSelectedParams, bool fastMethod, System::Windows::Forms::ProgressBar^ progressBar) { dataLength = min(drySound->getDataLength(), wetSound->getDataLength()); //segmentLength = dataLength; //floatove polia so samplami dry = new float*[2]; //stereo wet = new float*[2]; //stereo dry[0] = new float[dataLength]; dry[1] = new float[dataLength]; wet[0] = new float[dataLength]; wet[1] = new float[dataLength]; fillArray(drySound, dry[0], dry[1]); //ziskame sample z dry signalu fillArray(wetSound, wet[0], wet[1]); //ziskame sample z wet signalu //nastavime premenne this->type = type; this->progressBar = progressBar; this->selectedParams = selectedParams; this->numSelectedParams = numSelectedParams; this->stepSize = stepSize; this->volType = volType; this->fastMethod = fastMethod; segmentNum = dataLength / segmentLength; //pocet segmentov ////------------ RMS inicializacia //zistime, ci aspon jeden parameter je volume-type bool vol = false; //true == aspon jeden parameter je volume-type for (int i=0; i<numSelectedParams; i++) { if (volType[i]) { vol = true; } } if (vol) { //ak ano segmentRmsLength = segmentLength / (rmsWindowSize-rmsOverlap); //dlzka jedneho segmentu v segmentRmsWet segmentRmsEff = new float[segmentRmsLength]; //ulozene RMS pre jeden segment efektovaneho zvuku segmentRmsWet = new float*[segmentNum]; //ulozene RMS pre cely wet signal, uz rozdelene do segmentov for (int i=0; i<segmentNum; i++) { segmentRmsWet[i] = new float[segmentRmsLength]; } float* segmentRmsPom = new float[segmentLength]; //pomocne pole //spocitame segmentRmsWet for (int segment=0; segment<segmentNum; segment++) { //cez vsetky segmenty //zoberieme sample z wet signalu aktualneho segmentu for (int pos=0; pos<segmentLength; pos++) { //cez cely aktualny semgent segmentRmsPom[pos] = wet[0][(segment*segmentLength)+pos] + wet[1][(segment*segmentLength)+pos]; //odhryzneme segment z wet signalu } calculateRms(segmentRmsPom, segmentLength, segmentRmsWet[segment]); //spocitame RMS pre aktualy segment } delete [] segmentRmsPom; } ////------------- / RMS inicializacia //nastavime efektu vsetky parametre na defaultne hodnoty { int numParams = loader->getNumParams(); for (int i=0; i<numParams; i++) { loader->setParam(i, defaultParamValues[i]); } } //spustime process vector<float>* bestValues = new vector<float>(); message = gcnew String("result:" + nl); switch(type) { case tDelay : processGeneral(numSelectedParams-1, bestValues); break; case tEq : processEq(numSelectedParams-1, bestValues); break; case tLimiter : processLimiter(bestValues); break; case tComp : processComp(bestValues); break; case tPitchShift: processPitch(bestValues); break; case tGeneral : processGeneral(numSelectedParams-1, bestValues); break; } progressBar->Value = 100; //nastavime efektu vsetky parametre na defaultne hodnoty { int numParams = loader->getNumParams(); for (int i=0; i<numParams; i++) { loader->setParam(i, defaultParamValues[i]); } } //nastavime efektu vybrane parametre na vysledne hodnoty for (int i=0; i<(int)bestValues->size(); i++) { loader->setParam(selectedParams[i], (*bestValues)[i]); } //vypis for (int i=0; i<(int)bestValues->size(); i++) { (*logFile) << "parameter " << selectedParams[i] << " == " << (*bestValues)[i] << endl; String^ name = gcnew String(loader->getParamName(selectedParams[i]).c_str()); String^ value = gcnew String( (loader->getParamDisplay(selectedParams[i])).c_str()); String^ label = gcnew String((loader->getLabel(selectedParams[i])).c_str()); message = message->Insert(message->Length,(name + "\t=\t" + value + " " + label + "\t(" + (*bestValues)[i] + ") ;" + nl )); } delete bestValues; delete [] dry[0]; delete [] dry[1]; delete [] dry; delete [] wet[0]; delete [] wet[1]; delete [] wet; if (vol) { delete [] segmentRmsEff; for (int i=0; i<segmentNum; i++) { delete [] segmentRmsWet[i]; } delete [] segmentRmsWet; } //message = gcnew String("VstHost > process complete"); processed = true; } void VstHost::processEq(int actParam, vector<float>* bestValues) { long fftSize2 = fftSize/2; float PI = 3.1415926536f; float freqPerBin = (float)sampleRate / fftSize; //kolko Hz je v jednom bin-e int bandsNum = 3; //pocet pasiem int bandsFreq [] = {100, 1000, 10000}; //frekvencie pasiem float gain = 0.5; //hodnota parametru gain long fftSegmentNum = dataLength / fftSize; //pocet fft segmentov float* fftWet = new float[fftSize2]; //ulozena eq krivka wet signalu float* fftDry = new float[fftSize2]; //ulozena eq krivka dry signalu float* fftDiff = new float[fftSize2]; //ulozeny rozdiel magnitud wet - dry float* fftEff = new float[fftSize2]; //eq krivka zefektovaneho signalu float* fftSegment = new float[2*fftSize]; //pouzivane pre ukladanie segmentu wet alebo dry signalu pre fft memset(fftWet, 0, (fftSize2) * sizeof(float)); memset(fftDry, 0, (fftSize2) * sizeof(float)); memset(fftDiff, 0, (fftSize2) * sizeof(float)); memset(fftEff, 0, (fftSize2) * sizeof(float)); //--- vypocet ----------------------------------------------------------------------------------------------------- for (int segment=0; segment<fftSegmentNum; segment++) { //cez vsetky fft segmenty progressBar->Value = (int)(100* ((float)segment/fftSegmentNum)); //------ dry signal memset(fftSegment, 0, 2 * fftSize * sizeof(float)); //nacitame dry segment for (long i=0; i<fftSize; i++) { fftSegment[2*i] = dry[0][segment*fftSize + i] + dry[1][segment*fftSize + i]; //left + right } //spocitame fft segmentu Fft(fftSegment, fftSize, -1); //zvysime fftDry o vypocitane hodnoty magnitudy for (long i=0; i<fftSize2; i++) { //cez cely dlzku segmentu fftDry[i]+= sqrt( (fftSegment[2*i]*fftSegment[2*i] + fftSegment[2*i+1]*fftSegment[2*i+1])); } //-------- wet signal memset(fftSegment, 0, 2 * fftSize * sizeof(float)); //nacitame wet segment for (long i=0; i<fftSize; i++) { fftSegment[2*i] = wet[0][segment*fftSize + i] + wet[1][segment*fftSize + i]; //left + right } //spocitame fft segmentu Fft(fftSegment, fftSize, -1); //zvysime fftWet o vypocitane hodnoty magnitudy for (long i=0; i<fftSize2; i++) { //cez cely dlzku segmentu fftWet[i]+= sqrt(fftSegment[2*i]*fftSegment[2*i] + fftSegment[2*i+1]*fftSegment[2*i+1] ); } } /* //spocitame rozdiel wet - dry subtract(fftWet, fftDry, fftSize2, fftDiff); ////znormalizujeme fftWet na uroven fftDry //nejdeme frekvenciu ktora je v dry a wet na co najpodobnejsej urovni, tzn. abs(fftWet - fftDry) je co najblizsie k 0 long binSimilar = -1; //frekvencie, v ktorej su dry a wet najpodobnejsie float diff = float::MaxValue; //najmensi rozdiel wet-dry for (long bin=0; bin<fftSize2; bin++) { //cez vsetky biny if ( (abs(fftDiff[bin])) < diff) { //ak sme nasli zatal najpodobnejsiu frekvenciu binSimilar = bin; diff = abs(fftDiff[bin]); } } //zistime hodnotu gain gain = fftWet[binSimilar] / fftDry[binSimilar]; */ //zistime pomery v pasmach z bandsFreq for (int i=0; i<numSelectedParams; i++) { if (selectedParams[i]==3) { bestValues->push_back(0.5); //gain } else { int param = selectedParams[i]; long bin = (long)(bandsFreq[param] / freqPerBin); float x = 0; for (int j=-1; j<=1; j++) { //okolie x+=fftWet[bin+j] / fftDry[bin+j]; } x /= 3; bestValues->push_back((float)((log(x)/2)+0.5)); //inverzny vzorec z equalizer.cpp } } ////vypis do logu //-- konvolucia int filterLength = 4; float* convFilter = new float[filterLength]; for (int i=0; i<filterLength; i++) { convFilter[i] = 0.25; } float* fftDiff2 = new float[fftSize/2]; float* pom = new float[fftSize]; float* pom2 = new float[fftSize]; memset(pom, 0, fftSize * sizeof(float)); memset(pom, 0, fftSize * sizeof(float)); memset(fftDiff2, 0, fftSize/2 * sizeof(float)); //FftConv(fftDiff, fftSize/2 - filterLength , convFilter, filterLength, fftDiff2, 1); //konvolucia FftConv(fftDry, fftSize2-filterLength, convFilter, filterLength, pom, 1); FftConv(fftWet, fftSize2-filterLength, convFilter, filterLength, pom2, 1); //vypis for (long i=0; i<fftSize/2; i++) { (*logFile) << pom[i]; (*logFile) << "\t" << pom2[i]; (*logFile) << endl; } delete [] convFilter; delete [] fftDiff2; delete [] pom; delete [] pom2; delete [] fftWet; delete [] fftDry; delete [] fftDiff; delete [] fftEff; delete [] fftSegment; } void VstHost::processGeneral(int actParam, vector<float>* bestValues) { if (actParam!=-1) { //ak mame este nejaky parameter na spracovanie, inak koniec rekurzie float** effected = new float*[2]; //bude ukladany zefektovany signal for (int i=0; i<2; i++) { effected[i] = new float[dataLength]; } float* segmentEff = new float[segmentLength]; //left + right float* segmentWet = new float[segmentLength]; int stepIters = (int)((100. /stepSize[actParam]) + 1); //pocet iteracii ktorymi prejdeme vsetky hodnoty parametru float value = 0; //hodnoty parametru float segmentRating = 0; //rating aktualneho segmentu float stepRating = 0; //rating aktualneho kroku (aktualnej hodnoty parametru) float lastStepRating = 0; //stepRating v predchadzajucom kroku float last2StepRating = 0; //stepRating v pred-predchadzajucom kroku float bestValue = -1; //najlepsia hodnota parametru float lastValue = 0; //value v predchadzajucej iteracii float resultRating = float::MaxValue; //vysledny rating long stepCounter = 0; //pocita, kolko krokov sme spravili vector<float>* bestValuesStep = new vector<float>(); //bestValues aktualneho kroku vector<float>* bestValuesResult = new vector<float>(); //vysledne bestValues //--- vypocet ----------------------------------------------------------------------------------------------------- for (int step=0; step<stepIters; step++) { //uprava progress baru, iba najvyssou urovnou rekurzie if (actParam==numSelectedParams-1) { progressBar->Value = (int)( 100 * ((step+1.)/stepIters)); } stepCounter++; loader->setParam(selectedParams[actParam], value); //nastavime parameter actParam bestValuesStep->clear(); processGeneral(actParam-1, bestValuesStep); //rekurzia //nastavime parametre, ktore sme vypocitali rekurziou for (int i=0; i<(int)bestValuesStep->size(); i++) { loader->setParam(i, (*bestValuesStep)[i]); } loader->process(dry, effected, dataLength); //zefektujeme zvuk stepRating = 0; for (int segment=0; segment<segmentNum; segment+=2) { //cez (vsetky) segmenty //nacitame aktualne spracovavany segment for (int i = 0; i<segmentLength; i++) { segmentEff[i] = effected[0][(segment*segmentLength)+i] + effected[1][(segment*segmentLength)+i]; if (!volType[actParam]) segmentWet[i] = wet[0][(segment*segmentLength)+i] + wet[1][(segment*segmentLength)+i]; //ak aktualny parameter nie je volume-type } //spocitame rating aktualneho segmentu if (volType[actParam]) { //ak je parameter volume-type //spocitame RMS aktualneho segmentu efektovaneho signalu calculateRms(segmentEff, segmentLength, segmentRmsEff); //spocitame RMS rating segmentRating = getRatingRms(segmentRmsWet[segment], segmentRmsEff, segmentRmsLength); } else { //spocitame obycajny rating segmentRating = getRating(segmentEff, segmentWet, segmentLength); } //zvysime celkovy rating kroku stepRating += segmentRating; } if (actParam==numSelectedParams-1){ (*logFile) << stepRating << "\t" << value << "\t" << endl; } if (stepRating<resultRating && stepRating>0) { //ak sme nasli doteraz najlepsi rating resultRating = stepRating; bestValuesResult->assign(bestValuesStep->begin(), bestValuesStep->end()); //pridame vector z rekurzie bestValuesResult->push_back(value); //pridame vypocitanu hodnotu } lastValue = value; value+=((float)stepSize[actParam])/100; //----- orezavanie if (fastMethod) { //ak je zvolena fast method if (!volType[actParam]) { //ak nie je parameter volume-type if ( (stepRating) <= 0.6 * lastStepRating ) { //ak je aktualny stepRating ovela mensi ako lastStepRating break; } } else { //ak je parameter volume-type if ( (last2StepRating>lastStepRating) && (lastStepRating<stepRating) ) break; } } //----- /orezavanie last2StepRating = lastStepRating; lastStepRating = stepRating; } bestValues->insert(bestValues->end(), bestValuesResult->begin(), bestValuesResult->end()); for (int i=0; i<2; i++) { delete [] effected[i]; } delete [] effected; delete [] segmentWet; delete [] segmentEff; delete bestValuesStep; delete bestValuesResult; } } void VstHost::processLimiter(std::vector<float> *bestValues) { float* ratio = new float[dataLength]; float tresh = 0; //najdeny treshold //spocitame pomer wet / dry divide(wet[0], dry[0], ratio, dataLength); //najdeme taku poziciu, kde je pomer==1 a zaroven velkost samplu v dry na tejto pozicii je najvacsia float treshSample = 0; //zatial najvacsia hodnota vhodneho samplu for (long i=0; i<dataLength; i++) { if (ratio[i]==1 && abs(dry[0][i])>treshSample) { treshSample = abs(dry[0][i]); } } //zapiseme bestValues->push_back(treshSample); //spocitame treshold v dB //tresh = 20. * log10((double)treshSample); //String^ treshMessage = gcnew String("" + tresh + nl); //message = message->Insert(message->Length, treshMessage); delete ratio; } void VstHost::processComp(std::vector<float> *bestValues){ int peaksPrecision = 1000; //pocet roznych vstupnych hodnot peakov int peakNum = 10000; //pocet zaznamov pre jednu vstupnu hodnotu peaku float** peaks = new float*[peaksPrecision]; //zoznam pomerov velkosti peakov for (int i=0; i<peaksPrecision; i++) { peaks[i] = new float[peakNum]; } peaks[0][0] = 1; int* peaksCalculated = new int[peaksPrecision]; //pocet vypocitanych pomerov peakov jednotlivo memset(peaksCalculated, 0, peaksPrecision * sizeof(float)); int peaksCalculatedSum = 0; //celkovy pocet vypocitanych pomerov peakov int peaksCalculatedMax = peaksPrecision * peakNum; //maximalna hodnota peaksCalculatedSum int inPeak = 0; //umiestnenie aktualnej vstupnej velkosti peaku v zozname 'peaks' float* rmsDry = new float[dataLength]; //vypocitane RMS dry signalu memset(rmsDry, 0, dataLength); //vypocitane RMS wet signalu float* rmsWet = new float[dataLength]; memset(rmsWet, 0, dataLength); long rmsLength = 0; float* ratioPeak = new float[dataLength]; //pomer wet / dry float* ratioRms = new float[dataLength]; //pomer rmsWet / rmsDry long pos = 0; //pomocna int treshNum = 0; //pomocna float tresh = 0; //treshold int maxAttack = (int)(sampleRate * 0.1); //maximalny attack int minAttack = (int)(sampleRate * 0.001); //minimalny attack time == rms window size long maxRelease = (long)(sampleRate * 0.5); //maximalny release vector<float>* attackTimes = new vector<float>(); //ulozene casy attacku float attack = 0; //vysledny attack float attackParam = 0; //hodnota pre nastavenie parametru float releaseParam = 0; //hodnota pre nastavenie parametru float release = 0; //vysledny release int sectionNum = 4; //pocet vypoctovych "sekcii", koli progressBaru float actSection = 0; //aktualna sekcia float compressRatio = float::MaxValue; //vysledny kompresny pomer float* params = new float[loader->getNumParams()]; //-------------- vypocet //spocitame rmsWet aj rmsDry, ako velkost RMS okna pouzijeme minimalny attack time int defaultRmsWindowSize = rmsWindowSize; rmsWindowSize = minAttack; rmsLength = min(calculateRms(dry, dataLength, rmsDry), calculateRms(wet, dataLength, rmsWet) ); rmsWindowSize = defaultRmsWindowSize; //spocitame pomer wet / dry divide(wet[0], dry[0], ratioPeak, dataLength); abs(ratioPeak, dataLength); //spocitame pomer rmsWet / rmsDry divide(rmsWet, rmsDry, ratioRms, rmsLength); //sekcia COMPRESS RATIO------------------------------ actSection++; /* //naplnime 'peaks[]' pos = 0; while ( (pos<dataLength) && (peaksCalculatedSum < peaksCalculatedMax) ) { //kym mame vstupne data alebo kym sme nenasli dostatok pomerov peakov inPeak = (int)(abs(dry[0][pos] * peaksPrecision)); //na ktorej pozicii v zozname 'peaks' sa nachadza aktualny vstupny peak if (inPeak > 0) { if (peaksCalculated[inPeak]<peakNum) { //ak este nemam vypocitanych dost pomerov pre aktualnu velksot vstupneho peaku peaks[inPeak][peaksCalculated[inPeak]] = abs(wet[0][pos] / dry[0][pos]); //vypocitame pomer peaksCalculated[inPeak]++; //zvysime pocet vypocitanych pomerov pre aktualny vstupny peak peaksCalculatedSum++; //zvysime celkovy pocet vypocitanych pomerov } } progressBar->Value =(int)( 50 + (50 * ((float)pos) / dataLength) ); pos++; }*/ //pomocou RMS pos = 0; while ( (pos<rmsLength) && (peaksCalculatedSum < peaksCalculatedMax) ) { //kym mame vstupne data alebo kym sme nenasli dostatok pomerov peakov progressBar->Value = (int)( (100*((actSection-1)/sectionNum)) + ((100./sectionNum)*((float)pos/rmsLength)) ); inPeak = (int)(rmsDry[pos] * peaksPrecision); //na ktorej pozicii v zozname 'peaks' sa nachadza aktualny vstupny peak if (inPeak > 0) { if (peaksCalculated[inPeak]<peakNum) { //ak este nemam vypocitanych dost pomerov pre aktualnu velksot vstupneho peaku peaks[inPeak][peaksCalculated[inPeak]] = ratioRms[pos]; //vypocitame pomer peaksCalculated[inPeak]++; //zvysime pocet vypocitanych pomerov pre aktualny vstupny peak peaksCalculatedSum++; //zvysime celkovy pocet vypocitanych pomerov } } pos++; } //spocitame premerne pomery v 'peaks[]' a zaroven najdeme najmensi pomer == compressRatio for (int i=1; i<peaksPrecision; i++) { //cez cele vrchne pole 'peaks' if (peaksCalculated[i]!=0) { //ak sme pre aktualnu hodnotu peaku vypocitali nejake pomery //float avg = EX(peaks[i], peaksCalculated[i]); //spocitame priemer float avg = float::MaxValue; for (int j=0; j<peaksCalculated[i]; j++) { if (peaks[i][j] < avg) { avg = peaks[i][j]; } } peaks[i][0] = avg; //vysledny priemer ulozime } else { //ak sme pre aktualnu hodnotu peaku nespocitali nijake pomery peaks[i][0] = peaks[i-1][0]; //doplnime hodnotu z nizsej hodnoty peaku } if (peaks[i][0]<compressRatio) { compressRatio = peaks[i][0]; } } //sekcia TRESHOLD --------------------------------------------- actSection++; /* //pomocou peakov for (long i=1; i<dataLength; i++) { if (ratioPeak[i-1]==1 && ratioPeak[i]<1 && abs(dry[0][i-1]!=0)) { tresh += abs(dry[0][i-1]); treshNum++; } } tresh/=treshNum; */ //pomocou RMS tresh = 0; treshNum=0; for (long i=1; i<rmsLength; i++) { if (ratioRms[i-1]>(compressRatio + (1-compressRatio)/2 ) && ratioRms[i]<=(compressRatio + (1-compressRatio)/2 ) && rmsDry[i-1]!=0) { //if (rmsDry[i]<tresh && rmsDry[i]>0) { tresh+=rmsDry[i]; treshNum++; //} } progressBar->Value = (int)( (100*((actSection-1)/sectionNum)) + ((100./sectionNum)*((float)i/rmsLength)) ); } tresh/=treshNum; //prevedieme na dB float treshdB = (float)(20. * log10(tresh)); //sekcia ATTACK TIME ------------------------------------------- actSection++; pos = 0; while (pos<rmsLength) { //cez celu dlzku ratioRms[] //najdeme zaciatok useku, ktory je komprimovany while ( (ratioRms[pos]>0.96 || ratioRms[pos]==0) && pos<rmsLength) { pos++; } //najdeme attack time, v rozpati (pos-maxAttac, pos) najdeme prvu rms hodnotu s hodnotou vacsou a treshold float maxSample = 0; //hodnota hladaneho samplu long maxSamplePos = -1; //pozicia hladaneho samplu v rmsDry[] for (int reverse = pos-1; reverse>(int)(pos-(maxAttack/minAttack)); reverse--) { //cez cele rozpatie, ideme spatne, hladame v rmsDry, preto maxAttack/attack == pocet rms okien za dobu maxAttack if (reverse<0 || ratioRms[reverse]<=0.96 ) break; //proti preteceniu alebo zasiahnutiu do predchadzajuceho skomprimovaneho useku if (rmsDry[reverse]>tresh) { maxSample = rmsDry[reverse]; maxSamplePos = reverse; } } if (maxSamplePos!=-1) { //ak sme nieco nasli attackTimes->push_back((float)( minAttack * (pos-maxSamplePos) )); //ulozime najdeny attack time, hodnota v samploch } //posunieme sa na zaciatok dalsieho useku jednotiek while (ratioRms[pos]<=0.96 && pos<rmsLength) { pos++; } pos++; progressBar->Value = (int)( (100*((actSection-1)/sectionNum)) + ((100./sectionNum)*((float)pos/rmsLength)) ); } attack = EX(attackTimes); attack /= sampleRate; //attack v samploch int attackMs = (int)(floor( (1000 * attack) + 0.5 )); //v milisekundach //najdeme hodnotu parametru z intervalu (0..1) pre najdeny attack v milisekundach { float lastDiff = float::MaxValue; //velkost posledneho rozdielu float actDiff = float::MaxValue; //velkost aktualneho rozdielu float lastDisp = 0; //posledna zobrazovana hodnota float value = 0; //skutocna hodnota parametru float disp; //zobrazovana hodnota while (value<=1){ loader->setParam(2, value); disp = (float)(atof(loader->getParamDisplay(2).c_str())); actDiff = abs(attackMs-disp); if (lastDiff < actDiff) { //ak sa rozdiel zacal zvacsovat to znamena, ze sme uz hladanu hodnotu presli attackParam = (float)(value-0.01); break; } else { lastDiff = actDiff; value+=(float)0.01; //zvysime o 1 percento } } } //sekcia RELEASE TIME----------------------------------------------------- attackTimes->clear(); actSection++; pos = 0; while (pos<rmsLength) { //cez celu dlzku ratioRms[] //najdeme koniec useku, ktory je komprimovany while ( (ratioRms[pos]<=0.96 || ratioRms[pos]==0) && pos<rmsLength) { pos++; } //najdeme release time, v rozpati (pos-maxRelease, pos) najdeme prvu rms hodnotu s hodnotou vacsou ako treshold long searchedPos = -1; //pozicia hladaneho samplu v rmsDry[] for (int reverse = pos-1; reverse>(int)(pos-(maxRelease/minAttack)); reverse--) { //cez cele rozpatie, ideme spatne, hladame v rmsDry, preto maxRelease/minAttack == pocet rms okien za dobu maxRelease //hladame prvu hodnotu, ktora je vacsia ako treshold if (reverse<0) break; //proti preteceniu if (rmsDry[reverse]>tresh) { searchedPos = reverse; break; } } if (searchedPos!=-1) { //ak sme nieco nasli attackTimes->push_back((float)( minAttack * (pos-searchedPos) )); //ulozime najdeny release time, hodnota v samploch; pouzivame vektor z predchadzajucej sekcie } //posunieme sa na zaciatok dalsieho komprimovaneho useku, tzn. na koniec aktualneho nekomprimovaneho useku while ((ratioRms[pos]>0.96 || ratioRms[pos]==0) && pos<rmsLength) { pos++; } pos++; progressBar->Value = (int)( (100*((actSection-1)/sectionNum)) + ((100./sectionNum)*((float)pos/rmsLength)) ); } release = EX(attackTimes); release /= sampleRate; int releaseMs = (int)(floor( (1000 * release) + 0.5 )); //najdeme hodnotu parametru z intervalu (0..1) pre najdeny release v milisekundach { float lastDiff = float::MaxValue; //velkost posledneho rozdielu float actDiff = float::MaxValue; //velkost aktualneho rozdielu float lastDisp = 0; //posledna zobrazovana hodnota float value = 0; //skutocna hodnota parametru float disp; //zobrazovana hodnota while (value<=1){ loader->setParam(3, value); disp = (float)(atof(loader->getParamDisplay(3).c_str())); actDiff = abs(releaseMs-disp); if (lastDiff < actDiff) { //ak sa rozdiel zacal zvacsovat to znamena, ze sme uz hladanu hodnotu presli releaseParam = (float)(value-0.01); break; } else { lastDiff = actDiff; value+=(float)0.01; //zvysime o 1 percento } } } //---- ZAPIS VYSLEDKOV ---------------------------------------------------------------------- /* message = message->Insert(message->Length, gcnew String("attack: " + attackMs + " ms" + nl)); message = message->Insert(message->Length, gcnew String("release: " + releaseMs + " ms" + nl)); message = message->Insert(message->Length, gcnew String("ratio: " + compressRatio + "" + nl)); message = message->Insert(message->Length, gcnew String("treshold: " + treshdB + " dB" + nl)); */ //zapis do logu (*logFile) << "attack: " << (int)(attack*1000) << endl; (*logFile) << "release: " << (int)(release*1000) << endl; (*logFile) << "ratio: " << compressRatio << endl; (*logFile) << "treshold: " << tresh << endl; for (int i=0; i<peaksPrecision; i++) { (*logFile) << peaks[i][0] << endl; } params[0] = 0.5; //default input params[1] = 0; //kompresor, nie limiter params[2] = attackParam; params[3] = releaseParam; params[4] = ((1/compressRatio) - 1 ) /9; //inverzny vzorec z compressor.cpp params[5] = tresh; params[6] = 0; //auto makeup off params[7] = 0.5; //default output for (int i=0; i<numSelectedParams; i++) { bestValues->push_back(params[selectedParams[i]]); } //--- DELETOVANIE ------------------------------------------- for (int i=0; i<peaksPrecision; i++) { delete [] peaks[i]; } delete [] peaks; delete [] peaksCalculated; delete [] ratioPeak; delete [] ratioRms; delete [] rmsDry; delete [] rmsWet; delete attackTimes; delete params; } void VstHost::processPitch(std::vector<float> *bestValues){ long fftSize2 = fftSize/2; int numStep = (int) ((100. /stepSize[0]) + 1); //pocet iteracii ktorymi prejdeme vsetky hodnoty parametru float value = 0; //aktualna hodnota parametru float resultValue = 0; //vysledna hodnota parametru float rating = 0; //aktualny rating float lastRating = 0; //rating v predchazajucej interacii float lastRating2 = 0; //ratign v pred-predchadzajucej iteracii float resultRating = float::MaxValue; //vysledny rating long fftSegmentNum = dataLength / fftSize; //pocet fft segmentov float** effected = new float*[2]; //bude ukladany zefektovany signal for (int i=0; i<2; i++) { effected[i] = new float[dataLength]; } float* fftWet = new float[fftSize2]; //ulozena eq krivka wet signalu float* fftEff = new float[fftSize2]; //ulozena eq krivka efektovaneho signalu float* fftSegment = new float[2*fftSize]; //pouzivane pre ukladanie segmentu wet alebo dry signalu pre fft memset(fftWet, 0, (fftSize2) * sizeof(float)); memset(fftEff, 0, (fftSize2) * sizeof(float)); //--- VYPOCET ------------------------------------------------------------------------------- (*logFile) << "processPitch" << endl; //zistime frekvencny obraz wet signalu for (int segment=0; segment<fftSegmentNum-1; segment++) { //cez vsetky fft segmenty memset(fftSegment, 0, 2 * fftSize * sizeof(float)); //nacitame wet segment for (long i=0; i<fftSize; i++) { fftSegment[2*i] = wet[0][segment*fftSize + i] + wet[1][segment*fftSize + i]; //left + right } //spocitame fft segmentu Fft(fftSegment, fftSize, -1); //zvysime fftWet o vypocitane hodnoty magnitudy for (long i=0; i<fftSize2; i++) { //cez cely dlzku segmentu fftWet[i]+= sqrt(fftSegment[2*i]*fftSegment[2*i] + fftSegment[2*i+1]*fftSegment[2*i+1] ); } } for (int step = 0; step<numStep; step++) { //cez vsetky hodnoty parametru progressBar->Value = (int)(((float)step/numStep)*100); loader->setParam(0, value); //nastavime parameter float x = loader->getParam(0); loader->process(dry, effected, dataLength); //spracujeme //zistime rekvencny obraz zefektovaneho signalu memset(fftEff, 0, (fftSize2) * sizeof(float)); for (int segment=0; segment<fftSegmentNum-1; segment++) { //cez vsetky fft segmenty memset(fftSegment, 0, 2 * fftSize * sizeof(float)); //nacitame eff segment for (long i=0; i<fftSize; i++) { fftSegment[2*i] = effected[0][segment*fftSize + i] + effected[1][segment*fftSize + i]; //left + right } //spocitame fft segmentu Fft(fftSegment, fftSize, -1); //zvysime fftEff o vypocitane hodnoty magnitudy for (long i=0; i<fftSize2; i++) { //cez cely dlzku segmentu fftEff[i]+= sqrt(fftSegment[2*i]*fftSegment[2*i] + fftSegment[2*i+1]*fftSegment[2*i+1] ); if (fftEff[0] > 1000) { float x = fftEff[0]; } } } //spocitame rating rating = getRatingFft(fftWet, fftEff, fftSize2); //porovname wet a zefektovany signal if (rating<resultRating) { resultRating = rating; resultValue = value; } //zapis do log (*logFile) << rating << "\t" << value << endl; //-- orezavanie ----------------------------------------- if (fastMethod) { //ak je zvolena fastMethod if (lastRating2>lastRating && lastRating<rating) { //ak sme presli minimom v postupnosti ratingov break; } } lastRating2 = lastRating; lastRating = rating; value+=((float)stepSize[0])/100; } bestValues->push_back(resultValue); //---- DELETOVANIE ----------------------------------------------------------------- delete [] effected[0]; delete [] effected[1]; delete [] effected; delete [] fftWet; delete [] fftEff; delete [] fftSegment; } /* bool VstHost::testParam(int param) { //nastavi vsetky parametre na 0.5, potom spocita dva zefektovane signaly, zakazdym ina hodnota zvoleneho parametru, potom porovna znormalizovane zefektovane signaly bool result; float rating; float avgRms1; //priemerne RMS float avgRms2; float** eff1 = new float*[2]; //1. efektovany signal float** eff2 = new float*[2]; //2. efektovany signal float** effPom = new float*[2]; //pomocna for (int i=0; i<2; i++) { eff1[i] = new float[dataLength]; eff2[i] = new float[dataLength]; effPom[i] = new float[dataLength]; } float* rms1 = new float[dataLength]; float* rms2 = new float[dataLength]; long rmsLength; for (int i=0; i<numSelectedParams; i++) { //cez vsetky zvolene parametre loader->setParam(selectedParams[i], 0.25); //nastavime ich } //zefektujeme s prvou hodnotou vybraneho parametru loader->setParam(param, 0.0); loader->process(dry, effPom, dataLength); normalize(effPom, eff1, dataLength); //zefektujeme s druhou hodnotou vybraneho parametru loader->setParam(param, 1.0); loader->process(dry, effPom, dataLength); normalize(effPom, eff2, dataLength); //spocitame RMS prveho signalu rmsLength = calculateRms(eff1, dataLength, rms1); //spocitame RMS druheho signalu calculateRms(eff2, dataLength, rms2); rating = getRatingRms(rms1, rms2, rmsLength); avgRms1 = EX(rms1, rmsLength); avgRms2 = EX(rms2, rmsLength); (*logFile) << endl << "rating== " << rating << endl; (*logFile) << "avg rms1 == " << avgRms1 << endl; (*logFile) << "avg rms2 == " << avgRms2 << endl; for (int i=0; i<2; i++) { delete [] eff1[i]; delete [] eff2[i]; delete [] effPom[i]; } delete [] eff1; delete [] eff2; delete [] effPom; delete [] rms1; delete [] rms2; return true; } */ float VstHost::EX(vector<float>* v) { float ex = 0; for (int i=0; i<(int)v->size(); i++) { ex+=(*v)[i]; } ex/=v->size(); return ex; } float VstHost::EX(float** in, long length) { float sum = 0; for (long i=0; i<length; i++) { sum+=in[0][i] + in[1][i]; } return (sum/(2*length)); } float VstHost::EX(float* in, long length) { float sum = 0; for (long i=0; i<length; i++) { sum+=in[i]; } return (sum/length); } float VstHost::odch(vector<float>* v, float ex) { float o = 0; for (int i=0; i<(int)v->size(); i++) { o+=abs((*v)[i]-ex); } o/=v->size(); return o; } void VstHost::saveProgram(String^ fileName) { if (!processed) { message = gcnew String("VstHost > Parameters values not processed, cannot save!"); throw gcnew Exception(); } else { int numParams = loader->getNumParams(); float * params = new float[numParams]; //hodnoty parametrov //zistime nastavenia parametrov for(int i=0; i<numParams; i++) { params[i] = loader->getParam(i); } //z fileName vytvorime nazov presetu, prevedieme zo String^ na char* int pos1 = fileName->LastIndexOf("\\") + 1; int pos2 = fileName->LastIndexOf("."); String^ name = gcnew String(fileName->Substring(pos1, pos2-pos1)); char* fileNameChar = (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(fileName); char* nameChar = (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(name); //ulozime VstProgramSaver VstProgramSaver(loader->getUniqueID(), loader->getFxVersion(), numParams, fileNameChar, nameChar, name->Length, params); message = gcnew String("VstHost > Saved to file " + fileName); delete [] params; } } bool VstHost::getProcessed(){ return processed; } void VstHost::setProcessed(bool b) { processed = b; } void VstHost::normalize (float** in, float** out, int length) { float peak; float mul; //multiplikator peak = getPeak(in, length); mul = 1 / peak; for (long j=0; j<length; j++) { out[0][j] = in[0][j] * mul; out[1][j] = in[1][j] * mul; } } float * * VstHost::normalize_mul(float **input, int length, float mul) { float * * output = new float*[2]; output[0] = new float[length]; output[1] = new float[length]; for (long i=0; i<length; i++) { output[0][i] = input[0][i] * mul; output[1][i] = input[1][i] * mul; } return output; } float VstHost::getPeak(float * * in, long length) { float peak = 0; long pos = 0; for (long i=0; i<length; i++ ) { float maxpom = max(abs(in[0][i]), abs(in[1][i])); if (maxpom > peak) { peak = maxpom; pos = i; } } return peak; } float VstHost::abs(float f) { if (f<0) { return -f; } else { return f; } } void VstHost::subtract(float **in1, float **in2, long length, float** out){ for (long i=0; i<length; i++) { out[0][i] = in1[0][i] - in2[0][i]; out[1][i] = in1[1][i] - in2[1][i]; } } void VstHost::subtract(float* in1, float* in2, long length, float* out) { for (long i=0; i<length; i++) { out[i] = in1[i] - in2[i]; } } void VstHost::divide(float* in1, float* in2, float* out, long length) { for (long i=0; i<length; i++) { if (in2[i]==0) { out[i] = 0; } else { out[i] = in1[i] / in2[i]; } } } long VstHost::calculateRms(float* in, long inLength, float* out) { float rms = 0; int overlap = rmsOverlap; int i_in = 0; int i_out = 0; //memset(out, 0, inLength * sizeof(float)); for (i_in=0, i_out=0; i_in<=(inLength-rmsWindowSize); i_in+=(rmsWindowSize-overlap), i_out++){ //cez cele pole in[] rms = 0; for (int ri=0; ri<rmsWindowSize; ri++) { //cez cele rms okno rms+=in[i_in] * in[i_in]; } out[i_out]=sqrt(rms/rmsWindowSize); } return i_out; } long VstHost::calculateRms(float** in, long inLength, float* out) { float* pom = new float[inLength]; long result; for (long i=0; i<inLength; i++) { pom[i] = in[0][i] + in[1][i]; } result = calculateRms(in[0], inLength, out); return result; } float VstHost::getRatingRms(float* rms1, float* rms2, long length) { float differenceSum = 0; //sucet rozdielov rms float* difference = new float[length]; //pole pre rozdiely RMS //rozdiely subtract(rms1, rms2, length, difference); //scitame rozdiely for (int i=0; i<length; i++) { //cez vsetky vypocitane hodnoty RMS differenceSum+= abs(difference[i]); //suma rozdielov } //priemerny rozdiel rms differenceSum /= length; delete [] difference; return differenceSum; } float VstHost::getRating(float *in1, float *in2, long length){ float mulSum = 0; //suma zapornych 'mul' for (long i=0; i<length; i++) { if ( (in1[i]<0 && in2[i]>0) || (in1[i]>0 && in2[i]<0) ) { mulSum+=in1[i] * in2[i]; } } return abs(mulSum); } float VstHost::getRating(float** in1, float** in2, long length) { float * pom1 = new float[length]; float * pom2 = new float[length]; float rating = float::MaxValue; for (long i=0; i<length; i++) { pom1[i] = in1[0][i] + in1[1][i]; pom2[i] = in2[0][i] + in2[1][i]; } rating = getRating(pom1, pom2, length); delete [] pom1; delete [] pom2; return rating; } float VstHost::getRatingFft(float* fftSignal1, float* fftSignal2, long length) { float * subtracted = new float[length]; float difference = 0; subtract(fftSignal1, fftSignal2, length, subtracted); for (int i=0; i<length; i++) { difference+=abs(subtracted[i]); } delete subtracted; return difference; } void VstHost::abs(float *f, long length) { for (long i=0; i<length; i++) { if (f[i]<0) { f[i]*=-1; } } } bool VstHost::isPeak(int pos) { bool result = false; if (pos>0 && pos<dataLength-1) { if ( (abs(dry[0][pos]) > abs(dry[0][pos-1])) && (abs(dry[0][pos]) < abs(dry[0][pos+1])) ) { result = true; } } return result; }
[ "fabry.brano@7dde01ba-876c-11de-b48b-8f0b266c3b3d" ]
[ [ [ 1, 1249 ] ] ]
d8dc1738c8f6a1aec912906bb760b55b34bd8032
d2996420f8c3a6bbeef63a311dd6adc4acc40436
/src/net/UdpServer.cpp
b6ca5bfffc812da5c5e39d2b0bd6db84d35116c2
[]
no_license
aruwen/graviator
4d2e06e475492102fbf5d65754be33af641c0d6c
9a881db9bb0f0de2e38591478429626ab8030e1d
refs/heads/master
2021-01-19T00:13:10.843905
2011-03-13T13:15:25
2011-03-13T13:15:25
32,136,578
0
0
null
null
null
null
UTF-8
C++
false
false
5,516
cpp
#include "UdpServer.h" using namespace net; // DEBUG #include <iostream> UdpServer::UdpServer() { mIsRunning = false; mMaxConnectionCount = 2; mIdCounter = 1; } UdpServer::~UdpServer() { stop(); } bool UdpServer::start(unsigned short port) { if (mIsRunning) return false; if ( !mSocket.open(port) ) return false; if ( !mMulticastReceiver.join( Address(225,1,1,1,1337) )) return false; mIsRunning = true; return true; } void UdpServer::stop() { if (mIsRunning) { mSocket.close(); mIsRunning = false; clear(); } } void UdpServer::update() { processReadReadyOnSocket(); processReadReadyOnMulticastReceiver(); vector<unsigned int> keys; map<unsigned int, UdpConnection*>::iterator it; for (it = mConnections.begin(); it != mConnections.end(); it++) keys.push_back((*it).first); for (unsigned int i = 0; i < keys.size(); i++) { mConnections[keys[i]]->update(); if (mConnections[keys[i]]->isDisconnected() || mConnections[keys[i]]->hasConnectFailed()) { UdpConnection *tempConnection = mConnections[keys[i]]; mConnections.erase(keys[i]); delete tempConnection; } } } bool UdpServer::sendTo(const Address &address, string data) { if (!mIsRunning) return false; return mSocket.send(address, data.c_str(), data.size()); } bool UdpServer::send(string data) { if (!mIsRunning) return false; if (mConnections.size() == 0) return false; bool returnValue = true; map<unsigned int, UdpConnection*>::iterator it; for (it = mConnections.begin(); it != mConnections.end(); it++) { if (!(*it).second->isReady()) continue; if (!(*it).second->sendData(data)) returnValue = false; } return returnValue; } void UdpServer::processReadReadyOnSocket() { int receivedBytes = 0; Address sender; char data[1024]; string dataString = data; int size = 1024; memset(data, 0, 1024); receivedBytes = mSocket.receive(sender, data, size); while (receivedBytes > 0) { dataString = data; UdpConnection *currentConnection = getConnection(sender); if (currentConnection == 0 && mConnections.size() < mMaxConnectionCount) { UdpConnection *newConnection = new UdpConnection(&mSocket, sender); while(!mConnections.insert( pair<unsigned int, UdpConnection*>(mIdCounter, newConnection)).second) { mIdCounter++; } newConnection->setId(mIdCounter); mIdCounter++; newConnection->handleIncomming(dataString); } else { currentConnection->handleIncomming(dataString); } memset(data, 0, 1024); receivedBytes = mSocket.receive(sender, data, size); } } void UdpServer::processReadReadyOnMulticastReceiver() { int receivedBytes = 0; Address sender; char data[1024]; string dataString = data; int size = 1024; memset(data, 0, 1024); receivedBytes = mMulticastReceiver.receive(sender, data, size); while (receivedBytes > 0) { dataString = data; Address responseAddress(sender.getAddress(), atoi(dataString.c_str())); string responseString = "I_AM_A_SERVER"; mSocket.send(responseAddress, responseString.c_str(), responseString.size()); memset(data, 0, 1024); receivedBytes = mMulticastReceiver.receive(sender, data, size); } } int UdpServer::getConnectionCount() { int counter = 0; map<unsigned int, UdpConnection*>::iterator it; for (it = mConnections.begin(); it != mConnections.end(); it++) { if ((*it).second->isReady()) counter++; } return counter; } void UdpServer::setMaxConnectionCount(unsigned short count) { mMaxConnectionCount = count; } multimap<unsigned int, string> UdpServer::getData() { multimap<unsigned int, string> returnMap; map<unsigned int, UdpConnection*>::iterator it; for (it = mConnections.begin(); it != mConnections.end(); it++) { string currentData; while (true) { currentData = (*it).second->getData(); if (currentData.size() > 0) returnMap.insert(pair<unsigned int, string>((*it).second->getId(), currentData)); else break; } } return returnMap; } void UdpServer::clear() { map<unsigned int, UdpConnection*>::iterator it; for (it = mConnections.begin(); it != mConnections.end(); it++) { delete (*it).second; } mConnections.clear(); } UdpConnection* UdpServer::getConnection(const Address &address) { map<unsigned int, UdpConnection*>::iterator it; for (it = mConnections.begin(); it != mConnections.end(); it++) { if ((*it).second->getAddress() == address) return (*it).second; } return 0; }
[ "[email protected]@c8d5bfcc-1391-a108-90e5-e810ef6ef867" ]
[ [ [ 1, 234 ] ] ]
4ec6952a0e8689f1c0c575ad9c6acf955dafee1a
1736474d707f5c6c3622f1cd370ce31ac8217c12
/PseudoUnitTest/TestBitArray.hpp
44651ae87fffc45e11a924adc92f0608ded2b526
[]
no_license
arlm/pseudo
6d7450696672b167dd1aceec6446b8ce137591c0
27153e50003faff31a3212452b1aec88831d8103
refs/heads/master
2022-11-05T23:38:08.214807
2011-02-18T23:18:36
2011-02-18T23:18:36
275,132,368
0
0
null
null
null
null
UTF-8
C++
false
false
759
hpp
#include <Pseudo\BitArray.hpp> using namespace Pseudo; BEGIN_TEST_CLASS(TestBitArray) BEGIN_TEST_METHODS TEST_METHOD(Test) END_TEST_METHODS void Test() { BitArray bits(12); TEST_ASSERT(bits[1] == false, L"Testing bit 1 of array is false"); TEST_ASSERT(bits[2] == false, L"Testing bit 2 of array is false"); TEST_ASSERT(bits[3] == false, L"Testing bit 3 of array is false"); TEST_ASSERT(bits[4] == false, L"Testing bit 4 of array is false"); bits.Set(3, true); TEST_ASSERT(bits[3] == true, L"Testing bit 3 of array is true"); TEST_ASSERT(bits[2] == false, L"Testing bit 2 of array is false"); TEST_ASSERT(bits[4] == false, L"Testing bit 4 of array is false"); } END_TEST_CLASS
[ [ [ 1, 27 ] ] ]
0f0c79d0727d3997436189aec5f84fdff8779c17
f2cf9ead30a7298b3c1ec672ac118429fbac0a40
/Poc1/Source/Poc1.Fast.Terrain/LatitudeTerrainFunction.cpp
f77eee7ef3e67b0c5484d010e4c5d6aa47710480
[]
no_license
johann-gambolputty/robotbastards
3af0b6cf5d948e8bb0450d596ecb5362bfe5a28d
1874568ada150e04ba83fff2ea067f5a4b63f893
refs/heads/master
2021-01-10T09:52:51.773773
2009-08-08T00:19:33
2009-08-08T00:19:33
44,774,636
0
0
null
null
null
null
UTF-8
C++
false
false
1,207
cpp
#include "stdafx.h" #include "LatitudeTerrainFunction.h" namespace Poc1 { namespace Fast { namespace Terrain { LatitudeTerrainFunction::LatitudeTerrainFunction( const TerrainFunctionType functionType, const int numLatitudeBands ) { m_Function = functionType; m_Bands = gcnew array<Band^>( numLatitudeBands ); float step = 1.0f / ( float )numLatitudeBands; float lower = 0; float upper = step; for ( int bandIndex = 0; bandIndex < numLatitudeBands; ++bandIndex ) { m_Bands[ bandIndex ] = gcnew Band( ); m_Bands[ bandIndex ]->m_LowerBound = lower; m_Bands[ bandIndex ]->m_UpperBound = upper; m_Bands[ bandIndex ]->m_Parameters = TerrainFunction::CreateParameters( functionType ); lower = upper; upper += step; } } int LatitudeTerrainFunction::NumberOfLatitudeBands::get() { return m_Bands->Length; } TerrainFunctionType LatitudeTerrainFunction::FunctionType::get() { return m_Function; } LatitudeTerrainFunction::Band^ LatitudeTerrainFunction::GetLatitudeBand( int index ) { return m_Bands[ index ]; } }; // Terrain }; //Fast }; //Poc1
[ "fishy.coder@1e31eab0-7329-0410-87fb-016d5637cad0" ]
[ [ [ 1, 48 ] ] ]
efcb359d648e2f220431c55a8c3e0683980a642b
21da454a8f032d6ad63ca9460656c1e04440310e
/src/wcpp/lang/service/wscRuntimeService.cpp
6790380df96d86584632b0867b193c09d702d26e
[]
no_license
merezhang/wcpp
d9879ffb103513a6b58560102ec565b9dc5855dd
e22eb48ea2dd9eda5cd437960dd95074774b70b0
refs/heads/master
2021-01-10T06:29:42.908096
2009-08-31T09:20:31
2009-08-31T09:20:31
46,339,619
0
0
null
null
null
null
UTF-8
C++
false
false
384
cpp
#include "wscRuntimeService.h" const ws_char * const wscRuntimeService::s_class_name = "wcpp.lang.service.wscRuntimeService"; wscRuntimeService::wscRuntimeService(void) { } wscRuntimeService::~wscRuntimeService(void) { } ws_result wscRuntimeService::GetRuntime(wsiRuntime ** ret) { m_runtime.CopyTo( ret ); return ws_result( WS_RLT_SUCCESS ); }
[ "xukun0217@98f29a9a-77f1-11de-91f8-ab615253d9e8" ]
[ [ [ 1, 22 ] ] ]
36d33ab6113f13c50d7d7a78b80e0516eaba7059
205069c97095da8f15e45cede1525f384ba6efd2
/Casino/Code/Server/ServerModule/GameFrameModule/ServerUserManager.h
84ded5417642dc1db8525ae85a68d4b22d5599c3
[]
no_license
m0o0m/01technology
1a3a5a48a88bec57f6a2d2b5a54a3ce2508de5ea
5e04cbfa79b7e3cf6d07121273b3272f441c2a99
refs/heads/master
2021-01-17T22:12:26.467196
2010-01-05T06:39:11
2010-01-05T06:39:11
null
0
0
null
null
null
null
GB18030
C++
false
false
7,353
h
#ifndef SERVER_USER_MANAGER_HEAD_FILE #define SERVER_USER_MANAGER_HEAD_FILE #pragma once #include "Stdafx.h" #include "GameServiceExport.h" typedef CMap<DWORD,DWORD,DWORD,DWORD> CalculateItemPosMap; ////////////////////////////////////////////////////////////////////////// //用户信息项 class CServerUserItem : public IServerUserItem { //友元定义 friend class CServerUserManager; //基本信息 protected: bool m_bAcitve; //激活标志 tagUserRule m_UserRule; //用户规则 tagServerUserData m_ServerUserData; //用户信息 IServerUserItem* m_pParent; //父亲 LONG m_lUserRefCount; //下线引用计数 //辅助信息 protected: WORD m_wUserIndex; //用户索引 DWORD m_dwClientIP; //连接地址 DWORD m_dwLogonTime; //登录时间 DWORD m_dwPlayTimeCount; //游戏时间 TCHAR m_szPassword[PASS_LEN]; //用户密码 CalculateItemPosMap m_CalculateItemPosMap; //计算辅助 //函数定义 public: //构造函数 CServerUserItem(void); //析构函数 virtual ~CServerUserItem(void); //基础接口 public: //释放对象 virtual bool __cdecl Release() { if (IsValid()) delete this; return true; } //是否有效 virtual bool __cdecl IsValid() { return AfxIsValidAddress(this,sizeof(CServerUserItem))?true:false; } //接口查询 virtual void * __cdecl QueryInterface(const IID & Guid, DWORD dwQueryVer); //引用接口 public: //增加引用 virtual void __cdecl AddUserRefCount(); //减少引用 virtual void __cdecl ReleaseUserRefCount(); //引用为空 virtual bool __cdecl IsUserRefCountZero(); //信息接口 public: //是否激活 virtual bool __cdecl IsActive() { return m_bAcitve; } //用户索引 virtual WORD __cdecl GetUserIndex() { return m_wUserIndex; } //获取地址 virtual DWORD __cdecl GetClientIP() { return m_dwClientIP; } //获取密码 virtual LPCTSTR __cdecl GetPassword() { return m_szPassword; } //获取规则 virtual const tagUserRule * __cdecl GetUserRule() { return &m_UserRule; } //获取信用额度 virtual tagUserScore * __cdecl GetUserScore() { return &m_ServerUserData.UserData.UserScore;} //获取信息 virtual tagServerUserData * __cdecl GetUserData() { return &m_ServerUserData; }; //获取父用户 virtual IServerUserItem * __cdecl GetParent(){return m_pParent;} //设置父用户 virtual bool __cdecl SetParent(IServerUserItem* pParent); //属性接口 public: //用户名字 virtual LPCTSTR __cdecl GetAccounts() { return m_ServerUserData.UserData.szAccount; } //用户 I D virtual DWORD __cdecl GetUserID() { return m_ServerUserData.UserData.dwUserID; } //父用户 I D virtual DWORD __cdecl GetParentUserID(){return m_ServerUserData.UserData.dwParentUserID;} //用户等级 virtual BYTE __cdecl GetUserLevel(){ return m_ServerUserData.UserData.cbLevel;} //桌子号码 virtual WORD __cdecl GetTableID() { return m_ServerUserData.UserStatus.wTableID; } //椅子号码 virtual WORD __cdecl GetChairID() { return m_ServerUserData.UserStatus.wChairID; } //用户状态 virtual BYTE __cdecl GetUserStatus() { return m_ServerUserData.UserStatus.cbUserStatus; } //用户体系正确 virtual bool __cdecl IsUserTreeFrameOK(); //判断机器人 virtual bool __cdecl IsAIUser(); //统计接口 public: //游戏时间 virtual DWORD __cdecl GetPlayTimeCount() { return m_dwPlayTimeCount; } //在线时间 virtual DWORD __cdecl GetOnlineTimeCount() { return (DWORD)time(NULL)-m_dwLogonTime; } //信用额度信息 virtual bool __cdecl GetUserScoreInfo(tagUserScore & ScoreResultInfo); //功能接口 public: //设置规则 virtual bool __cdecl SetUserRule(tagUserRule & UserRule); //修改信用额度 virtual bool __cdecl WriteScore(tagScoreInfo & ScoreInfo, DWORD dwPlayTimeCount); //设置状态 virtual bool __cdecl SetUserStatus(BYTE cbUserStatus, WORD wTableID, WORD wChairID); //功能函数 public: //初始化 void InitServerUserItem(); //计算辅助接口 public: virtual DWORD __cdecl GetCalculateItemPos(WORD wTableID); virtual void __cdecl SetCalculateItemPos(WORD wTableID, DWORD dwItemPos); }; ////////////////////////////////////////////////////////////////////////// //类说明 typedef CArrayTemplate<CServerUserItem *> CServerUserItemArray; //服务器用户管理 class CServerUserManager : public IServerUserManager { //变量定义 protected: CServerUserItemArray m_UserItemStore; //存储用户 CServerUserItemArray m_OnLineUserItem; //在线用户 CServerUserItemArray m_OffLineUserItem; //断线用户 //函数定义 public: //构造函数 CServerUserManager(void); //析构函数 virtual ~CServerUserManager(void); //基础接口 public: //释放对象 virtual bool __cdecl Release() { if (IsValid()) delete this; return true; } //是否有效 virtual bool __cdecl IsValid() { return AfxIsValidAddress(this,sizeof(CServerUserManager))?true:false; } //接口查询 virtual void * __cdecl QueryInterface(const IID & Guid, DWORD dwQueryVer); //管理接口 public: //重置用户 virtual bool __cdecl ResetUserManager(); //切换用户 virtual bool __cdecl SwitchOnLineUserItem(IServerUserItem * pIServerUserItem, DWORD dwClientIP, WORD wUserIndex); //激活用户 virtual bool __cdecl ActiveOffLineUserItem(IServerUserItem * pIServerUserItem, DWORD dwClientIP, WORD wUserIndex); //激活用户 virtual IServerUserItem * __cdecl ActiveUserItem(tagServerUserData & ServerUserData, DWORD dwClientIP, WORD wUserIndex, TCHAR szPassword[PASS_LEN]); //激活用户 virtual IServerUserItem * __cdecl ActiveLinkUserItem(tagServerUserData & ServerUserData); //删除用户 virtual bool __cdecl DeleteUserItem(IServerUserItem * pIServerUserItem); //注册断线 virtual bool __cdecl RegOffLineUserItem(IServerUserItem * pIServerUserItem); //删除断线 virtual bool __cdecl UnRegOffLineUserItem(IServerUserItem * pIServerUserItem); //检测用户计数 virtual bool __cdecl CheckGameUserRefCount(IServerUserItem * pIServerUserItem); //查找接口 public: //枚举用户 virtual IServerUserItem * __cdecl EnumOnLineUser(WORD wEnumIndex); //枚举用户 virtual IServerUserItem * __cdecl EnumOffLineUser(WORD wEnumIndex); //查找用户 virtual IServerUserItem * __cdecl SearchOnLineUser(DWORD dwUserID); //查找用户 virtual IServerUserItem * __cdecl SearchOffLineUser(DWORD dwUserID); //查找用户 virtual IServerUserItem * __cdecl SearchOnLineUser(LPCTSTR pszAccounts); //查找用户 virtual IServerUserItem * __cdecl SearchOffLineUser(LPCTSTR pszAccounts); //查找用户 virtual IServerUserItem * __cdecl SearchUser(DWORD dwUserID){ IServerUserItem* pItem = SearchOnLineUser(dwUserID); if(pItem) return pItem; return SearchOffLineUser(dwUserID); } //信息接口 public: //在线人数 virtual DWORD __cdecl GetOnLineCount() { return (DWORD)m_OnLineUserItem.GetCount(); } //断线人数 virtual DWORD __cdecl GetOffLineCount() { return (DWORD)m_OffLineUserItem.GetCount(); } }; ////////////////////////////////////////////////////////////////////////// #endif
[ [ [ 1, 213 ] ] ]
33d00e12dcf817c78194fb9826e582cbb1f143ae
65c92f6c171a0565fe5275ecc48033907090d69d
/Client/Plugins/Course/Implementation/LessonDocument.cpp
f1a9dca1fdf7645e28929823ec03a8a4bad3b080
[]
no_license
freakyzoidberg/horus-edu
653ac573887d83a803ddff1881924ab82b46f5f6
2757766a6cb8c1f1a1b0a8e209700e6e3ccea6bc
refs/heads/master
2020-05-20T03:08:15.276939
2010-01-07T14:34:51
2010-01-07T14:34:51
32,684,226
0
0
null
null
null
null
UTF-8
C++
false
false
3,795
cpp
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Horus is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * * (at your option) any later version. * * * * Horus is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Horus. If not, see <http://www.gnu.org/licenses/>. * * * * The orginal content of this material was realized as part of * * 'Epitech Innovative Project' www.epitech.eu * * * * You are required to preserve the names of the original authors * * of this content in every copy of this material * * * * Authors : * * - BERTHOLON Romain * * - GRANDEMANGE Adrien * * - LACAVE Pierre * * - LEON-BONNET Valentin * * - NANOUCHE Abderrahmane * * - THORAVAL Gildas * * - VIDAL Jeremy * * * * You are also invited but not required to send a mail to the original * * authors of this content in case of modification of this material * * * * Contact: [email protected] * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "LessonDocument.h" LessonDocument::LessonDocument(QObject *parent, int id, QString title, QString _type, QString _content, QHash<QString, QVariant> _parameters) : ILessonDocument(parent) { this->_title = title; this->type = _type; this->content = _content; this->parameters = _parameters; this->_id = id; } QVariant LessonDocument::data(int , int role) const { if (role == Qt::DisplayRole) return QVariant(tr("Document")); return QVariant(); } void LessonDocument::setId(int id) { this->_id = id; } int LessonDocument::getId() { return (this->_id); } QString LessonDocument::getContent() const { return (this->content); } void LessonDocument::setContent(QString _content) { this->content = _content; } QHash<QString, QVariant> &LessonDocument::getParameters() { return (this->parameters); } QString LessonDocument::getType() const { return type; } void LessonDocument::setType(QString type) { this->type = type; }
[ "git@cb2ab776-01a4-11df-b136-7f7962f7bc17", "val@cb2ab776-01a4-11df-b136-7f7962f7bc17" ]
[ [ [ 1, 34 ] ], [ [ 35, 86 ] ] ]
65572d64fab558781cc12d2e374ea749eaae0787
03f06dde16b4b08989eefa144ebc2c7cc21e95ad
/tags/0.3/WinProf/CountCallsStat.h
f1de72140cd75146dbe38dead786f686bb8270ae
[]
no_license
BackupTheBerlios/winprof-svn
c3d557c72d7bc0306cb6bd7fd5ac189e5c277251
21ab1356cf6d16723f688734c995c7743bbde852
refs/heads/master
2021-01-25T05:35:44.550759
2005-06-23T11:51:27
2005-06-23T11:51:27
40,824,500
0
0
null
null
null
null
UTF-8
C++
false
false
1,093
h
#pragma once #include "WinProfStatistics.h" class CCountCallsStat : public CWinProfStatistics { virtual CString ToString(stat_val_t val) const {return Format("%d", val.int_val);} virtual CString GetStatCaption(void) const {return "Call Count";} virtual string GetStatName() const {return "CountCallsStat";} virtual bool IsPerFunction(void) const {return true;} virtual bool Satisfies(const INVOC_INFO& iv, stat_val_t bound, cmp_oper oper) const {return CmpOper::cmp_oper_vect_int[oper](GetStatValue(iv).int_val, bound.int_val);} virtual bool GetNumerical(CString str, stat_val_t& val) const { if (!ValidForStat(str, IsDigit)) return false; val.int_val = atoi(str); return true; } protected: // calculate stat value virtual stat_val_t CalculateStatVal(const calls_vector_t& v, const INVOC_INFO& call) const { stat_val_t val; val.int_val = (int)v.size(); return val; } virtual stat_val_t CalculateStatVal(const filtered_list_t& list) const { stat_val_t val; val.int_val = (int)list.size(); return val; } };
[ "landau@f5a2dbeb-61f3-0310-bb71-ba092b21bc01" ]
[ [ [ 1, 39 ] ] ]
b4f5c9a179fe08047a629e85133020fbfef17257
638c9b075ac3bfdf3b2d96f1dd786684d7989dcd
/spark/source/SpString.h
8e707b97f05a00406388e251507858274ff1efc0
[]
no_license
cycle-zz/archives
4682d6143b9057b21af9845ecbd42d7131750b1b
f92b677342e75e5cb7743a0d1550105058aff8f5
refs/heads/master
2021-05-27T21:07:16.240438
2010-03-18T08:01:46
2010-03-18T08:01:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,601
h
// ############################################################################# //! SpString.h : String utility class for character data // // Created : Aug 2004 // Copyright : (C) 2004 by Derek Gerstmann // Email : [email protected] // // ############################################################################# // ============================================================================= // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // ============================================================================= #ifndef SP_STRING_H #define SP_STRING_H // headers #include <string> #include <sstream> #include <vector> #include <list> using std::vector; using std::list; using std::string; using std::stringstream; // --------------------------------------------------------------------------- namespace Spark { // --------------------------------------------------------------------------- #if WCHAR_STRINGS typedef std::wstring SpStringBase; #else typedef std::string SpStringBase; #endif class SpString; typedef std::stringstream SpStringStreamType; typedef std::vector<SpString> SpStringArray; typedef std::list<SpString> SpStringList; typedef std::pair<SpString, SpString> SpStringPair; // --------------------------------------------------------------------------- //! String utility class for character data // --------------------------------------------------------------------------- class SpString : public SpStringBase { //! Typedefs: public: typedef size_type SizeType; //! Construction: public: SpString(); SpString(const SpString& rkStr); SpString(const string& rkStr); SpString(const char* acStr); SpString(const char* acStr, SizeType kLength); SpString(const SpString& rkStr, SizeType kStart, SizeType kEnd); SpString(SizeType kLength, char c); //! Operations: public: inline SpString& operator=(const SpString& rkStr); inline SpString& operator=(const std::string& rkStr); inline SpString& operator=(const char *acStr); inline SpString& operator=(char c); // append data from various sources inline SpString& operator+=(const SpString& rkStr); inline SpString& operator+=(const std::string& rkStr); inline SpString& operator+=(const char *acStr); inline SpString& operator+=(char c); // append data from various sources inline SpString& operator+(const SpString& rkStr); inline SpString& operator+(const std::string& rkStr); inline SpString& operator+(const char *acStr); inline SpString& operator+(char c); // test equality and inequality (case sensitive) //inline bool operator==(const SpString& rkStr); //inline bool operator!=(const SpString& rkStr); //! Utilites: public: // clear method (for older stdlibs that don't have it) void clear(); // template operator for appending another type into the string. template<class Class> SpString& add(const Class &rtValue); // c-string support inline operator const char* () const; // operator that allows SpString to be used as an STL map key value inline bool operator<(const SpString& rkStr); // special strings static const SpString EMPTY; }; // --------------------------------------------------------------------------- #include "SpString.inc" // --------------------------------------------------------------------------- } // end namespace: Adorn #endif // AD_STRING_H
[ [ [ 1, 126 ] ] ]
4f89d3707cf60b3d3bbb28e63ae93fa2d99c5179
1c4a1cd805be8bc6f32b0a616de751ad75509e8d
/jacknero/src/pku_src/1904/.svn/text-base/3584228_AC_6141MS_7136K.cc.svn-base
04043c6ba741aecb1f595d943791bf34c38944ad
[]
no_license
jacknero/mycode
30313261d7e059832613f26fa453abf7fcde88a0
44783a744bb5a78cee403d50eb6b4a384daccf57
refs/heads/master
2016-09-06T18:47:12.947474
2010-05-02T10:16:30
2010-05-02T10:16:30
180,950
1
0
null
null
null
null
UTF-8
C++
false
false
1,995
# #include <vector> #include <algorithm> using namespace std; const int N = 2010; int nv; vector<int> head[N], head2[N], S; int go[N], back[N]; int scc[N]; bool chk[N]; bool love[N][N]; void DFS(int x) { int i; chk[x] = 1; for(i = 0; i < head[x].size(); ++i) { int j = back[head[x][i]]; if(!chk[j]) DFS(j); } S.push_back(x); //入栈 } void DFS2(int x, int id) { int y = go[x], i; chk[y] = 1; scc[x] = id; //标记连通分支 for(i = 0; i < head2[y].size(); ++i) { int j = go[head2[y][i]]; //找到对应的公主 if(!chk[j]) DFS2(head2[y][i], id); } } int main() { scanf("%d", &nv); int i, t, u, j; for(i = 0; i < nv; ++i) { scanf("%d", &t); while(t--) { scanf("%d", &u); love[i][u-1] = 1; head[i].push_back(u-1); //有向边 head2[u-1].push_back(i); //逆转的有向边 } } for(i = 0; i < nv; ++i) { scanf("%d", &t); go[i] = t-1; back[t-1] = i; } memset(chk, 0, sizeof(chk)); for(i = 0; i < nv; ++i) if(!chk[i]) { DFS(i); //对王子作DFS 确定i到达的点 } memset(chk, 0, sizeof(chk)); int sccId = 0; for(i = S.size()-1; i >= 0; --i) { int j = S[i]; if(!chk[go[j]]) { DFS2(j, sccId); //再对公主做DFS 确定连通分支(对王子和对公主其实是一样的 写法有点不同而已:) sccId++; } } for(i = 0; i < nv; ++i) { vector<int> ans; for(j = 0; j < nv; ++j) if(love[i][j]) { if(scc[i] == scc[back[j]]) ans.push_back(j); } sort(ans.begin(), ans.end()); printf("%d", ans.size()); for(j = 0; j < ans.size(); ++j) printf(" %d", ans[j]+1); printf("\n"); } return 0; }
[ [ [ 1, 86 ] ] ]
25cdecec0e62fb42bab3023acfed7790a6c9a718
fd3f2268460656e395652b11ae1a5b358bfe0a59
/cryptopp/nbtheory.h
6fa490a84f1d78e48ff448db4cdf8b20b4522fcf
[ "LicenseRef-scancode-cryptopp", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
mikezhoubill/emule-gifc
e1cc6ff8b1bb63197bcfc7e67c57cfce0538ff60
46979cf32a313ad6d58603b275ec0b2150562166
refs/heads/master
2021-01-10T20:37:07.581465
2011-08-13T13:58:37
2011-08-13T13:58:37
32,465,033
4
2
null
null
null
null
UTF-8
C++
false
false
6,298
h
// nbtheory.h - written and placed in the public domain by Wei Dai #ifndef CRYPTOPP_NBTHEORY_H #define CRYPTOPP_NBTHEORY_H #include "integer.h" #include "algparam.h" NAMESPACE_BEGIN(CryptoPP) // obtain pointer to small prime table and get its size CRYPTOPP_DLL const word16 * CRYPTOPP_API GetPrimeTable(unsigned int &size); // ************ primality testing **************** // generate a provable prime CRYPTOPP_DLL Integer CRYPTOPP_API MaurerProvablePrime(RandomNumberGenerator &rng, unsigned int bits); CRYPTOPP_DLL Integer CRYPTOPP_API MihailescuProvablePrime(RandomNumberGenerator &rng, unsigned int bits); CRYPTOPP_DLL bool CRYPTOPP_API IsSmallPrime(const Integer &p); // returns true if p is divisible by some prime less than bound // bound not be greater than the largest entry in the prime table CRYPTOPP_DLL bool CRYPTOPP_API TrialDivision(const Integer &p, unsigned bound); // returns true if p is NOT divisible by small primes CRYPTOPP_DLL bool CRYPTOPP_API SmallDivisorsTest(const Integer &p); // These is no reason to use these two, use the ones below instead CRYPTOPP_DLL bool CRYPTOPP_API IsFermatProbablePrime(const Integer &n, const Integer &b); CRYPTOPP_DLL bool CRYPTOPP_API IsLucasProbablePrime(const Integer &n); CRYPTOPP_DLL bool CRYPTOPP_API IsStrongProbablePrime(const Integer &n, const Integer &b); CRYPTOPP_DLL bool CRYPTOPP_API IsStrongLucasProbablePrime(const Integer &n); // Rabin-Miller primality test, i.e. repeating the strong probable prime test // for several rounds with random bases CRYPTOPP_DLL bool CRYPTOPP_API RabinMillerTest(RandomNumberGenerator &rng, const Integer &w, unsigned int rounds); // primality test, used to generate primes CRYPTOPP_DLL bool CRYPTOPP_API IsPrime(const Integer &p); // more reliable than IsPrime(), used to verify primes generated by others CRYPTOPP_DLL bool CRYPTOPP_API VerifyPrime(RandomNumberGenerator &rng, const Integer &p, unsigned int level = 1); class CRYPTOPP_DLL PrimeSelector { public: const PrimeSelector *GetSelectorPointer() const {return this;} virtual bool IsAcceptable(const Integer &candidate) const =0; }; // use a fast sieve to find the first probable prime in {x | p<=x<=max and x%mod==equiv} // returns true iff successful, value of p is undefined if no such prime exists CRYPTOPP_DLL bool CRYPTOPP_API FirstPrime(Integer &p, const Integer &max, const Integer &equiv, const Integer &mod, const PrimeSelector *pSelector); CRYPTOPP_DLL unsigned int CRYPTOPP_API PrimeSearchInterval(const Integer &max); CRYPTOPP_DLL AlgorithmParameters CRYPTOPP_API MakeParametersForTwoPrimesOfEqualSize(unsigned int productBitLength); // ********** other number theoretic functions ************ inline Integer GCD(const Integer &a, const Integer &b) {return Integer::Gcd(a,b);} inline bool RelativelyPrime(const Integer &a, const Integer &b) {return Integer::Gcd(a,b) == Integer::One();} inline Integer LCM(const Integer &a, const Integer &b) {return a/Integer::Gcd(a,b)*b;} inline Integer EuclideanMultiplicativeInverse(const Integer &a, const Integer &b) {return a.InverseMod(b);} // use Chinese Remainder Theorem to calculate x given x mod p and x mod q, and u = inverse of p mod q CRYPTOPP_DLL Integer CRYPTOPP_API CRT(const Integer &xp, const Integer &p, const Integer &xq, const Integer &q, const Integer &u); // if b is prime, then Jacobi(a, b) returns 0 if a%b==0, 1 if a is quadratic residue mod b, -1 otherwise // check a number theory book for what Jacobi symbol means when b is not prime CRYPTOPP_DLL int CRYPTOPP_API Jacobi(const Integer &a, const Integer &b); // calculates the Lucas function V_e(p, 1) mod n CRYPTOPP_DLL Integer CRYPTOPP_API Lucas(const Integer &e, const Integer &p, const Integer &n); // calculates x such that m==Lucas(e, x, p*q), p q primes, u=inverse of p mod q CRYPTOPP_DLL Integer CRYPTOPP_API InverseLucas(const Integer &e, const Integer &m, const Integer &p, const Integer &q, const Integer &u); inline Integer ModularExponentiation(const Integer &a, const Integer &e, const Integer &m) {return a_exp_b_mod_c(a, e, m);} // returns x such that x*x%p == a, p prime CRYPTOPP_DLL Integer CRYPTOPP_API ModularSquareRoot(const Integer &a, const Integer &p); // returns x such that a==ModularExponentiation(x, e, p*q), p q primes, // and e relatively prime to (p-1)*(q-1) // dp=d%(p-1), dq=d%(q-1), (d is inverse of e mod (p-1)*(q-1)) // and u=inverse of p mod q CRYPTOPP_DLL Integer CRYPTOPP_API ModularRoot(const Integer &a, const Integer &dp, const Integer &dq, const Integer &p, const Integer &q, const Integer &u); // find r1 and r2 such that ax^2 + bx + c == 0 (mod p) for x in {r1, r2}, p prime // returns true if solutions exist CRYPTOPP_DLL bool CRYPTOPP_API SolveModularQuadraticEquation(Integer &r1, Integer &r2, const Integer &a, const Integer &b, const Integer &c, const Integer &p); // returns log base 2 of estimated number of operations to calculate discrete log or factor a number CRYPTOPP_DLL unsigned int CRYPTOPP_API DiscreteLogWorkFactor(unsigned int bitlength); CRYPTOPP_DLL unsigned int CRYPTOPP_API FactoringWorkFactor(unsigned int bitlength); // ******************************************************** //! generator of prime numbers of special forms class CRYPTOPP_DLL PrimeAndGenerator { public: PrimeAndGenerator() {} // generate a random prime p of the form 2*q+delta, where delta is 1 or -1 and q is also prime // Precondition: pbits > 5 // warning: this is slow, because primes of this form are harder to find PrimeAndGenerator(signed int delta, RandomNumberGenerator &rng, unsigned int pbits) {Generate(delta, rng, pbits, pbits-1);} // generate a random prime p of the form 2*r*q+delta, where q is also prime // Precondition: qbits > 4 && pbits > qbits PrimeAndGenerator(signed int delta, RandomNumberGenerator &rng, unsigned int pbits, unsigned qbits) {Generate(delta, rng, pbits, qbits);} void Generate(signed int delta, RandomNumberGenerator &rng, unsigned int pbits, unsigned qbits); const Integer& Prime() const {return p;} const Integer& SubPrime() const {return q;} const Integer& Generator() const {return g;} private: Integer p, q, g; }; NAMESPACE_END #endif
[ "Mike.Ken.S@dd569cc8-ff36-11de-bbca-1111db1fd05b", "[email protected]@dd569cc8-ff36-11de-bbca-1111db1fd05b" ]
[ [ [ 1, 58 ], [ 60, 71 ], [ 73, 80 ], [ 82, 89 ], [ 92, 131 ] ], [ [ 59, 59 ], [ 72, 72 ], [ 81, 81 ], [ 90, 91 ] ] ]
e080f57d0e609f9619e3c6960035aeb6f567c5a9
5d36f6102c8cadcf1a124b366ae189d6a2609c59
/src/Qt/psx4cute/main.cpp
f3798c87ebb16c74bf196d64da1c4c311be2a773
[]
no_license
Devil084/psx4all
336f2861246367c8d397ef5acfc0b7972085c21b
04c02bf8840007792d23d15ca42a572035a1d703
refs/heads/master
2020-02-26T15:18:04.554046
2010-08-11T13:49:24
2010-08-11T13:49:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,376
cpp
/* psx4cute * * Copyright (C) 2010 Summeli <[email protected]> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "cuteDebug.h" #include "viewcontroller.h" #include <QtGui> #include <QApplication> #ifdef __SYMBIAN32__ #include "relocutils.h" #endif int main(int argc, char *argv[]) { #ifdef __SYMBIAN32__ //TODO: use the relocator for performance improvemtn! //BEGIN_RELOCATED_CODE(0x10000000); //relocate symbian code #endif initdebug(); QApplication a(argc, argv); ViewController* vc = new ViewController(); return a.exec(); #ifdef __SYMBIAN32__ // END_RELOCATED_CODE(); // return to the original code section #endif }
[ [ [ 1, 44 ] ] ]
432d76b5c7a0b5c5071d88722770d6b9f3e22fec
4275e8a25c389833c304317bdee5355ed85c7500
/KylTek/CGlobal.cpp
07a8041f5a3b8260262adbaff94f5249fae02b92
[]
no_license
kumorikarasu/KylTek
482692298ef8ff501fd0846b5f41e9e411afe686
be6a09d20159d0a320abc4d947d4329f82d379b9
refs/heads/master
2021-01-10T07:57:40.134888
2010-07-26T12:10:09
2010-07-26T12:10:09
55,943,006
0
0
null
null
null
null
UTF-8
C++
false
false
187
cpp
#include "CGlobal.h" CGlobal* CGlobal::m_pInstance = 0; CGlobal* CGlobal::GetInstance(){ if (m_pInstance == 0) { m_pInstance = new CGlobal; } return m_pInstance; }
[ "Sean Stacey@localhost" ]
[ [ [ 1, 8 ] ] ]
c89506eda850243389a915987fbd48b789b7451b
1a5b43c98479a5c44c6da4b01fa35af95c6d7bcd
/CFGGen/SForNode.h
8d0b975436858edf64f9a531910de44ab69cb561
[]
no_license
eknowledger/mcfromc
827641a5f670d18ee2a7e1d8d76b783d37d33004
41b6ba1065b27a8468d3b70c3698cbcef0dc698b
refs/heads/master
2016-09-05T12:11:29.137266
2010-08-08T05:11:43
2010-08-08T05:11:43
34,752,799
0
0
null
null
null
null
UTF-8
C++
false
false
236
h
#pragma once #include "snode.h" class SForNode : public SNode { public: SForNode(const NodeData& node): SNode(node) { } virtual ~SForNode(void); virtual bool ShouldCreateEdgeFromChildren() { return true; } };
[ "man701@46565ccc-2a3b-0f42-2bc5-e45c9856c86c", "[email protected]@46565ccc-2a3b-0f42-2bc5-e45c9856c86c" ]
[ [ [ 1, 11 ], [ 16, 16 ] ], [ [ 12, 15 ] ] ]
64ebb428726f60707f1f2a00dc7922528590f8a0
028d79ad6dd6bb4114891b8f4840ef9f0e9d4a32
/src/drivers/hydra.cpp
08cadd7a99e8a55d24c923f68e91fabca61fc933
[]
no_license
neonichu/iMame4All-for-iPad
72f56710d2ed7458594838a5152e50c72c2fb67f
4eb3d4ed2e5ccb5c606fcbcefcb7c5a662ace611
refs/heads/master
2020-04-21T07:26:37.595653
2011-11-26T12:21:56
2011-11-26T12:21:56
2,855,022
4
0
null
null
null
null
UTF-8
C++
false
false
21,903
cpp
#include "../vidhrdw/hydra.cpp" /*************************************************************************** Hydra/Pit Fighter ****************************************************************************/ #include "driver.h" #include "sound/adpcm.h" #include "machine/atarigen.h" #include "sndhrdw/atarijsa.h" #include "vidhrdw/generic.h" /* Note: if this is set to 1, it must also be set in the vidhrdw module */ #define HIGH_RES 0 extern struct rectangle hydra_mo_area; extern UINT32 hydra_mo_priority_offset; extern INT32 hydra_pf_xoffset; static UINT8 which_input; WRITE_HANDLER( hydra_playfieldram_w ); int hydra_vh_start(void); void hydra_vh_stop(void); void hydra_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh); void hydra_scanline_update(int param); WRITE_HANDLER( hydra_mo_control_w ); /************************************* * * Initialization * *************************************/ static void update_interrupts(void) { int newstate = 0; if (atarigen_video_int_state) newstate = 1; if (atarigen_sound_int_state) newstate = 2; if (newstate) cpu_set_irq_line(0, newstate, ASSERT_LINE); else cpu_set_irq_line(0, 7, CLEAR_LINE); } static void init_machine(void) { atarigen_eeprom_reset(); atarigen_slapstic_reset(); atarigen_interrupt_reset(update_interrupts); atarigen_scanline_timer_reset(hydra_scanline_update, 8); atarijsa_reset(); } /************************************* * * I/O read dispatch. * *************************************/ static READ_HANDLER( special_port0_r ) { int temp = input_port_0_r(offset); if (atarigen_cpu_to_sound_ready) temp ^= 0x1000; temp ^= 0x2000; /* A2DOK always high for now */ return temp; } static WRITE_HANDLER( a2d_select_w ) { (void)data; which_input = (offset / 2); } static READ_HANDLER( a2d_data_r ) { /* Pit Fighter has no A2D, just another input port */ if (hydra_mo_area.min_x != 0) return input_port_1_r(offset); /* otherwise, assume it's hydra */ if (which_input < 3) return readinputport(1 + which_input) << 8; return 0; } /************************************* * * Main CPU memory handlers * *************************************/ static struct MemoryReadAddress main_readmem[] = { { 0x000000, 0x07ffff, MRA_ROM }, { 0xfc0000, 0xfc0001, special_port0_r }, { 0xfc8000, 0xfc8001, a2d_data_r }, { 0xfd0000, 0xfd0001, atarigen_sound_upper_r }, { 0xfd8000, 0xfdffff, atarigen_eeprom_r }, /* { 0xfe0000, 0xfe7fff, from_r },*/ { 0xfe8000, 0xfe89ff, MRA_BANK1 }, { 0xff0000, 0xff3fff, MRA_BANK2 }, { 0xff4000, 0xff5fff, MRA_BANK3 }, { 0xff6000, 0xff6fff, MRA_BANK4 }, { 0xff7000, 0xffffff, MRA_BANK5 }, { -1 } /* end of table */ }; static struct MemoryWriteAddress main_writemem[] = { { 0x000000, 0x07ffff, MWA_ROM }, { 0xf80000, 0xf80001, watchdog_reset_w }, { 0xf88000, 0xf8ffff, atarigen_eeprom_enable_w }, { 0xf90000, 0xf90001, atarigen_sound_upper_w }, { 0xf98000, 0xf98001, atarigen_sound_reset_w }, { 0xfa0000, 0xfa0001, hydra_mo_control_w }, { 0xfb0000, 0xfb0001, atarigen_video_int_ack_w }, { 0xfc8000, 0xfc8007, a2d_select_w }, { 0xfd8000, 0xfdffff, atarigen_eeprom_w, &atarigen_eeprom, &atarigen_eeprom_size }, { 0xfe8000, 0xfe89ff, atarigen_666_paletteram_w, &paletteram }, { 0xff0000, 0xff3fff, MWA_BANK2, &atarigen_spriteram, &atarigen_spriteram_size }, { 0xff4000, 0xff5fff, hydra_playfieldram_w, &atarigen_playfieldram, &atarigen_playfieldram_size }, { 0xff6000, 0xff6fff, MWA_BANK4, &atarigen_alpharam, &atarigen_alpharam_size }, { 0xff7000, 0xffffff, MWA_BANK5 }, { -1 } /* end of table */ }; /************************************* * * Port definitions * *************************************/ INPUT_PORTS_START( hydra ) PORT_START /* fc0000 */ PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_BIT( 0x0fe0, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_SERVICE( 0x4000, IP_ACTIVE_LOW ) PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_VBLANK ) PORT_START /* ADC 0 @ fc8000 */ PORT_ANALOG( 0x00ff, 0x0080, IPT_AD_STICK_X, 50, 10, 0, 255 ) PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* ADC 1 @ fc8000 */ PORT_ANALOG( 0x00ff, 0x0080, IPT_AD_STICK_Y, 70, 10, 0, 255 ) PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* ADC 2 @ fc8000 */ PORT_ANALOG( 0xff, 0x00, IPT_PEDAL, 100, 16, 0x00, 0xff ) JSA_II_PORT /* audio board port */ INPUT_PORTS_END INPUT_PORTS_START( pitfight ) PORT_START /* fc0000 */ PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER1 ) PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER1 ) PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 ) PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER1 ) PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 ) PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 ) PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 ) PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x0f80, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_SERVICE( 0x4000, IP_ACTIVE_LOW ) PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_VBLANK ) PORT_START /* fc8000 */ PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER2 ) PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER2 ) PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 ) PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER2 ) PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 ) PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 ) PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 ) PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER3 ) PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER3 ) PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER3 ) PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER3 ) PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER3 ) PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER3 ) PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER3 ) PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_START3 ) PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* not used */ PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START /* not used */ PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNUSED ) JSA_II_PORT /* audio board port */ INPUT_PORTS_END /************************************* * * Graphics definitions * *************************************/ static struct GfxLayout pflayout = { 8 << HIGH_RES,8, /* 8*8 chars */ 16384, /* 16384 chars */ 5, /* 5 bits per pixel */ { 0, 0, 1, 2, 3 }, #if HIGH_RES { 0x40000*8+0,0x40000*8+0, 0x40000*8+4,0x40000*8+4, 0,0, 4,4, 0x40000*8+8,0x40000*8+8, 0x40000*8+12,0x40000*8+12, 8,8, 12,12 }, #else { 0x40000*8+0, 0x40000*8+4, 0, 4, 0x40000*8+8, 0x40000*8+12, 8, 12 }, #endif { 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 }, 16*8 /* every char takes 16 consecutive bytes */ }; static struct GfxLayout anlayout = { 8 << HIGH_RES,8, /* 8*8 chars */ 4096, /* 4096 chars */ 4, /* 4 bits per pixel */ { 0, 1, 2, 3 }, #if HIGH_RES { 0,0, 4,4, 8,8, 12,12, 16,16, 20,20, 24,24, 28,28 }, #else { 0, 4, 8, 12, 16, 20, 24, 28 }, #endif { 0*8, 4*8, 8*8, 12*8, 16*8, 20*8, 24*8, 28*8 }, 32*8 /* every char takes 32 consecutive bytes */ }; static struct GfxDecodeInfo gfxdecodeinfo[] = { { REGION_GFX1, 0, &pflayout, 0x300, 8 }, { REGION_GFX2, 0, &anlayout, 0x100, 16 }, { -1 } /* end of array */ }; /************************************* * * Machine driver * *************************************/ static struct MachineDriver machine_driver_hydra = { /* basic machine hardware */ { { CPU_M68000, /* verified */ ATARI_CLOCK_14MHz, main_readmem,main_writemem,0,0, atarigen_video_int_gen,1 }, JSA_II_CPU }, 60, DEFAULT_REAL_60HZ_VBLANK_DURATION, /* frames per second, vblank duration */ 1, init_machine, /* video hardware */ 42*(8 << HIGH_RES), 30*8, { 0*(8 << HIGH_RES), 42*(8 << HIGH_RES)-1, 0*8, 30*8-1 }, gfxdecodeinfo, 1024,1024, 0, #if HIGH_RES VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE | VIDEO_UPDATE_BEFORE_VBLANK | VIDEO_PIXEL_ASPECT_RATIO_1_2, #else VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE | VIDEO_UPDATE_BEFORE_VBLANK, #endif 0, hydra_vh_start, hydra_vh_stop, hydra_vh_screenrefresh, /* sound hardware */ JSA_II_MONO(REGION_SOUND1), atarigen_nvram_handler }; /************************************* * * Driver initialization * *************************************/ static void init_hydra(void) { atarigen_eeprom_default = NULL; atarigen_slapstic_init(0, 0x078000, 116); hydra_mo_area.min_x = 0 << HIGH_RES; hydra_mo_area.max_x = 255 << HIGH_RES; hydra_mo_area.min_y = 0; hydra_mo_area.max_y = 239; hydra_mo_priority_offset = 10; hydra_pf_xoffset = 0; atarijsa_init(1, 4, 0, 0x8000); /* speed up the 6502 */ atarigen_init_6502_speedup(1, 0x4159, 0x4171); /* display messages */ atarigen_show_slapstic_message(); atarigen_show_sound_message(); } static void init_hydrap(void) { atarigen_eeprom_default = NULL; hydra_mo_area.min_x = 0 << HIGH_RES; hydra_mo_area.max_x = 255 << HIGH_RES; hydra_mo_area.min_y = 0; hydra_mo_area.max_y = 239; hydra_mo_priority_offset = 10; hydra_pf_xoffset = 0; atarijsa_init(1, 4, 0, 0x8000); /* speed up the 6502 */ atarigen_init_6502_speedup(1, 0x4159, 0x4171); /* display messages */ atarigen_show_sound_message(); } static void init_pitfight(void) { atarigen_eeprom_default = NULL; atarigen_slapstic_init(0, 0x038000, 111); hydra_mo_area.min_x = 40 << HIGH_RES; hydra_mo_area.max_x = (40 + 255) << HIGH_RES; hydra_mo_area.min_y = 0; hydra_mo_area.max_y = 239; hydra_mo_priority_offset = 12; hydra_pf_xoffset = 2; atarijsa_init(1, 4, 0, 0x8000); /* speed up the 6502 */ atarigen_init_6502_speedup(1, 0x4159, 0x4171); /* display messages */ atarigen_show_slapstic_message(); atarigen_show_sound_message(); } /************************************* * * ROM definition(s) * *************************************/ ROM_START( hydra ) ROM_REGION( 0x80000, REGION_CPU1 ) /* 8*64k for 68000 code */ ROM_LOAD_EVEN( "hydr3028.bin", 0x00000, 0x10000, 0x43475f73 ) ROM_LOAD_ODD ( "hydr3029.bin", 0x00000, 0x10000, 0x886e1de8 ) ROM_LOAD_EVEN( "hydr3034.bin", 0x20000, 0x10000, 0x5115aa36 ) ROM_LOAD_ODD ( "hydr3035.bin", 0x20000, 0x10000, 0xa28ba44b ) ROM_LOAD_EVEN( "hydr1032.bin", 0x40000, 0x10000, 0xecd1152a ) ROM_LOAD_ODD ( "hydr1033.bin", 0x40000, 0x10000, 0x2ebe1939 ) ROM_LOAD_EVEN( "hydr1030.bin", 0x60000, 0x10000, 0xb31fd41f ) ROM_LOAD_ODD ( "hydr1031.bin", 0x60000, 0x10000, 0x453d076f ) ROM_REGION( 0x14000, REGION_CPU2 ) /* 64k for 6502 code */ ROM_LOAD( "hydraa0.bin", 0x10000, 0x4000, 0x619d7319 ) ROM_CONTINUE( 0x04000, 0xc000 ) ROM_REGION( 0x0a0000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "hydr1017.bin", 0x000000, 0x10000, 0xbd77b747 ) /* playfield, planes 0-3 odd */ ROM_LOAD( "hydr1018.bin", 0x010000, 0x10000, 0x7c24e637 ) ROM_LOAD( "hydr1019.bin", 0x020000, 0x10000, 0xaa2fb07b ) ROM_LOAD( "hydr1020.bin", 0x030000, 0x10000, 0x906ccd98 ) ROM_LOAD( "hydr1021.bin", 0x040000, 0x10000, 0xf88cdac2 ) /* playfield, planes 0-3 even */ ROM_LOAD( "hydr1022.bin", 0x050000, 0x10000, 0xa9c612ff ) ROM_LOAD( "hydr1023.bin", 0x060000, 0x10000, 0xb706aa6e ) ROM_LOAD( "hydr1024.bin", 0x070000, 0x10000, 0xc49eac53 ) ROM_LOAD( "hydr1025.bin", 0x080000, 0x10000, 0x98b5b1a1 ) /* playfield plane 4 */ ROM_LOAD( "hydr1026.bin", 0x090000, 0x10000, 0xd68d44aa ) ROM_REGION( 0x020000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "hydr1027.bin", 0x000000, 0x20000, 0xf9135b9b ) /* alphanumerics */ ROM_REGION( 0x100000, REGION_GFX3 ) ROM_LOAD_ODD ( "hydr1001.bin", 0x00000, 0x10000, 0x3f757a53 ) ROM_LOAD_EVEN( "hydr1002.bin", 0x00000, 0x10000, 0xa1169469 ) ROM_LOAD_ODD ( "hydr1003.bin", 0x20000, 0x10000, 0xaa21ec33 ) ROM_LOAD_EVEN( "hydr1004.bin", 0x20000, 0x10000, 0xc0a2be66 ) ROM_LOAD_ODD ( "hydr1005.bin", 0x40000, 0x10000, 0x80c285b3 ) ROM_LOAD_EVEN( "hydr1006.bin", 0x40000, 0x10000, 0xad831c59 ) ROM_LOAD_ODD ( "hydr1007.bin", 0x60000, 0x10000, 0xe0688cc0 ) ROM_LOAD_EVEN( "hydr1008.bin", 0x60000, 0x10000, 0xe6827f6b ) ROM_LOAD_ODD ( "hydr1009.bin", 0x80000, 0x10000, 0x33624d07 ) ROM_LOAD_EVEN( "hydr1010.bin", 0x80000, 0x10000, 0x9de4c689 ) ROM_LOAD_ODD ( "hydr1011.bin", 0xa0000, 0x10000, 0xd55c6e49 ) ROM_LOAD_EVEN( "hydr1012.bin", 0xa0000, 0x10000, 0x43af45d0 ) ROM_LOAD_ODD ( "hydr1013.bin", 0xc0000, 0x10000, 0x2647a82b ) ROM_LOAD_EVEN( "hydr1014.bin", 0xc0000, 0x10000, 0x8897d5e9 ) ROM_LOAD_ODD ( "hydr1015.bin", 0xe0000, 0x10000, 0xcf7f69fd ) ROM_LOAD_EVEN( "hydr1016.bin", 0xe0000, 0x10000, 0x61aaf14f ) ROM_REGION( 0x30000, REGION_SOUND1 ) /* 192k for ADPCM samples */ ROM_LOAD( "hydr1037.bin", 0x00000, 0x10000, 0xb974d3d0 ) ROM_LOAD( "hydr1038.bin", 0x10000, 0x10000, 0xa2eda15b ) ROM_LOAD( "hydr1039.bin", 0x20000, 0x10000, 0xeb9eaeb7 ) ROM_END ROM_START( hydrap ) ROM_REGION( 0x80000, REGION_CPU1 ) /* 8*64k for 68000 code */ ROM_LOAD_EVEN( "hydhi0.bin", 0x00000, 0x10000, 0xdab2e8a2 ) ROM_LOAD_ODD ( "hydlo0.bin", 0x00000, 0x10000, 0xc18d4f16 ) ROM_LOAD_EVEN( "hydhi1.bin", 0x20000, 0x10000, 0x50c12bb9 ) ROM_LOAD_ODD ( "hydlo1.bin", 0x20000, 0x10000, 0x5ee0a846 ) ROM_LOAD_EVEN( "hydhi2.bin", 0x40000, 0x10000, 0x436a6d81 ) ROM_LOAD_ODD ( "hydlo2.bin", 0x40000, 0x10000, 0x182bfd6a ) ROM_LOAD_EVEN( "hydhi3.bin", 0x60000, 0x10000, 0x29e9e03e ) ROM_LOAD_ODD ( "hydlo3.bin", 0x60000, 0x10000, 0x7b5047f0 ) ROM_REGION( 0x14000, REGION_CPU2 ) /* 64k for 6502 code */ ROM_LOAD( "hydraa0.bin", 0x10000, 0x4000, BADCRC(0x619d7319) ) ROM_CONTINUE( 0x04000, 0xc000 ) ROM_REGION( 0x0a0000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "hydr1017.bin", 0x000000, 0x10000, 0xbd77b747 ) /* playfield, planes 0-3 odd */ ROM_LOAD( "hydr1018.bin", 0x010000, 0x10000, 0x7c24e637 ) ROM_LOAD( "hydr1019.bin", 0x020000, 0x10000, 0xaa2fb07b ) ROM_LOAD( "hydpl03.bin", 0x030000, 0x10000, 0x1f0dfe60 ) ROM_LOAD( "hydr1021.bin", 0x040000, 0x10000, 0xf88cdac2 ) /* playfield, planes 0-3 even */ ROM_LOAD( "hydr1022.bin", 0x050000, 0x10000, 0xa9c612ff ) ROM_LOAD( "hydr1023.bin", 0x060000, 0x10000, 0xb706aa6e ) ROM_LOAD( "hydphi3.bin", 0x070000, 0x10000, 0x917e250c ) ROM_LOAD( "hydr1025.bin", 0x080000, 0x10000, 0x98b5b1a1 ) /* playfield plane 4 */ ROM_LOAD( "hydpl41.bin", 0x090000, 0x10000, 0x85f9afa6 ) ROM_REGION( 0x020000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "hydalph.bin", 0x000000, 0x20000, 0x7dd2b062 ) /* alphanumerics */ ROM_REGION( 0x100000, REGION_GFX3 ) ROM_LOAD_ODD ( "hydmhi0.bin", 0x00000, 0x10000, 0x3c83b42d ) ROM_LOAD_EVEN( "hydmlo0.bin", 0x00000, 0x10000, 0x6d49650c ) ROM_LOAD_ODD ( "hydmhi1.bin", 0x20000, 0x10000, 0x689b3376 ) ROM_LOAD_EVEN( "hydmlo1.bin", 0x20000, 0x10000, 0xc81a4e88 ) ROM_LOAD_ODD ( "hydmhi2.bin", 0x40000, 0x10000, 0x77098e14 ) ROM_LOAD_EVEN( "hydmlo2.bin", 0x40000, 0x10000, 0x40015d9d ) ROM_LOAD_ODD ( "hydmhi3.bin", 0x60000, 0x10000, 0xdfebdcbd ) ROM_LOAD_EVEN( "hydmlo3.bin", 0x60000, 0x10000, 0x213c407c ) ROM_LOAD_ODD ( "hydmhi4.bin", 0x80000, 0x10000, 0x2897765f ) ROM_LOAD_EVEN( "hydmlo4.bin", 0x80000, 0x10000, 0x730157f3 ) ROM_LOAD_ODD ( "hydmhi5.bin", 0xa0000, 0x10000, 0xecd061ae ) ROM_LOAD_EVEN( "hydmlo5.bin", 0xa0000, 0x10000, 0xa5a08c53 ) ROM_LOAD_ODD ( "hydmhi6.bin", 0xc0000, 0x10000, 0xaa3f2903 ) ROM_LOAD_EVEN( "hydmlo6.bin", 0xc0000, 0x10000, 0xdb8ea56f ) ROM_LOAD_ODD ( "hydmhi7.bin", 0xe0000, 0x10000, 0x71fc3e43 ) ROM_LOAD_EVEN( "hydmlo7.bin", 0xe0000, 0x10000, 0x7960b0c2 ) ROM_REGION( 0x30000, REGION_SOUND1 ) /* 192k for ADPCM samples */ ROM_LOAD( "hydr1037.bin", 0x00000, 0x10000, BADCRC(0xb974d3d0) ) ROM_LOAD( "hydr1038.bin", 0x10000, 0x10000, BADCRC(0xa2eda15b) ) ROM_LOAD( "hydr1039.bin", 0x20000, 0x10000, BADCRC(0xeb9eaeb7) ) ROM_END ROM_START( pitfight ) ROM_REGION( 0x80000, REGION_CPU1 ) /* 8*64k for 68000 code */ ROM_LOAD_EVEN( "4028", 0x00000, 0x10000, 0xf7cb1a4b ) ROM_LOAD_ODD ( "4029", 0x00000, 0x10000, 0x13ae0d4f ) ROM_LOAD_EVEN( "3030", 0x20000, 0x10000, 0xb053e779 ) ROM_LOAD_ODD ( "3031", 0x20000, 0x10000, 0x2b8c4d13 ) ROM_REGION( 0x14000, REGION_CPU2 ) /* 64k for 6502 code */ ROM_LOAD( "1060", 0x10000, 0x4000, 0x231d71d7 ) ROM_CONTINUE( 0x04000, 0xc000 ) ROM_REGION( 0x0a0000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "1017", 0x000000, 0x10000, 0xad3cfea5 ) /* playfield, planes 0-3 odd */ ROM_LOAD( "1018", 0x010000, 0x10000, 0x1a0f8bcf ) ROM_LOAD( "1021", 0x040000, 0x10000, 0x777efee3 ) /* playfield, planes 0-3 even */ ROM_LOAD( "1022", 0x050000, 0x10000, 0x524319d0 ) ROM_LOAD( "1025", 0x080000, 0x10000, 0xfc41691a ) /* playfield plane 4 */ ROM_REGION( 0x020000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "1027", 0x000000, 0x10000, 0xa59f381d ) /* alphanumerics */ ROM_REGION( 0x200000, REGION_GFX3 ) ROM_LOAD_ODD ( "1001", 0x000000, 0x20000, 0x3af31444 ) ROM_LOAD_EVEN( "1002", 0x000000, 0x20000, 0xf1d76a4c ) ROM_LOAD_ODD ( "1003", 0x040000, 0x20000, 0x28c41c2a ) ROM_LOAD_EVEN( "1004", 0x040000, 0x20000, 0x977744da ) ROM_LOAD_ODD ( "1005", 0x080000, 0x20000, 0xae59aef2 ) ROM_LOAD_EVEN( "1006", 0x080000, 0x20000, 0xb6ccd77e ) ROM_LOAD_ODD ( "1007", 0x0c0000, 0x20000, 0xba33b0c0 ) ROM_LOAD_EVEN( "1008", 0x0c0000, 0x20000, 0x09bd047c ) ROM_LOAD_ODD ( "1009", 0x100000, 0x20000, 0xab85b00b ) ROM_LOAD_EVEN( "1010", 0x100000, 0x20000, 0xeca94bdc ) ROM_LOAD_ODD ( "1011", 0x140000, 0x20000, 0xa86582fd ) ROM_LOAD_EVEN( "1012", 0x140000, 0x20000, 0xefd1152d ) ROM_LOAD_ODD ( "1013", 0x180000, 0x20000, 0xa141379e ) ROM_LOAD_EVEN( "1014", 0x180000, 0x20000, 0x93bfcc15 ) ROM_LOAD_ODD ( "1015", 0x1c0000, 0x20000, 0x9378ad0b ) ROM_LOAD_EVEN( "1016", 0x1c0000, 0x20000, 0x19c3fbe0 ) ROM_REGION( 0x40000, REGION_SOUND1 ) /* 256k for ADPCM samples */ ROM_LOAD( "1061", 0x00000, 0x10000, 0x5b0468c6 ) ROM_LOAD( "1062", 0x10000, 0x10000, 0xf73fe3cb ) ROM_LOAD( "1063", 0x20000, 0x10000, 0xaa93421d ) ROM_LOAD( "1064", 0x30000, 0x10000, 0x33f045d5 ) ROM_END ROM_START( pitfigh3 ) ROM_REGION( 0x80000, REGION_CPU1 ) /* 8*64k for 68000 code */ ROM_LOAD_EVEN( "3028", 0x00000, 0x10000, 0x99530da4 ) ROM_LOAD_ODD ( "3029", 0x00000, 0x10000, 0x78c7afbf ) ROM_LOAD_EVEN( "3030", 0x20000, 0x10000, 0xb053e779 ) ROM_LOAD_ODD ( "3031", 0x20000, 0x10000, 0x2b8c4d13 ) ROM_REGION( 0x14000, REGION_CPU2 ) /* 64k for 6502 code */ ROM_LOAD( "1060", 0x10000, 0x4000, 0x231d71d7 ) ROM_CONTINUE( 0x04000, 0xc000 ) ROM_REGION( 0x0a0000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "1017", 0x000000, 0x10000, 0xad3cfea5 ) /* playfield, planes 0-3 odd */ ROM_LOAD( "1018", 0x010000, 0x10000, 0x1a0f8bcf ) ROM_LOAD( "1021", 0x040000, 0x10000, 0x777efee3 ) /* playfield, planes 0-3 even */ ROM_LOAD( "1022", 0x050000, 0x10000, 0x524319d0 ) ROM_LOAD( "1025", 0x080000, 0x10000, 0xfc41691a ) /* playfield plane 4 */ ROM_REGION( 0x020000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "1027", 0x000000, 0x10000, 0xa59f381d ) /* alphanumerics */ ROM_REGION( 0x200000, REGION_GFX3 ) ROM_LOAD_ODD ( "1001", 0x000000, 0x20000, 0x3af31444 ) ROM_LOAD_EVEN( "1002", 0x000000, 0x20000, 0xf1d76a4c ) ROM_LOAD_ODD ( "1003", 0x040000, 0x20000, 0x28c41c2a ) ROM_LOAD_EVEN( "1004", 0x040000, 0x20000, 0x977744da ) ROM_LOAD_ODD ( "1005", 0x080000, 0x20000, 0xae59aef2 ) ROM_LOAD_EVEN( "1006", 0x080000, 0x20000, 0xb6ccd77e ) ROM_LOAD_ODD ( "1007", 0x0c0000, 0x20000, 0xba33b0c0 ) ROM_LOAD_EVEN( "1008", 0x0c0000, 0x20000, 0x09bd047c ) ROM_LOAD_ODD ( "1009", 0x100000, 0x20000, 0xab85b00b ) ROM_LOAD_EVEN( "1010", 0x100000, 0x20000, 0xeca94bdc ) ROM_LOAD_ODD ( "1011", 0x140000, 0x20000, 0xa86582fd ) ROM_LOAD_EVEN( "1012", 0x140000, 0x20000, 0xefd1152d ) ROM_LOAD_ODD ( "1013", 0x180000, 0x20000, 0xa141379e ) ROM_LOAD_EVEN( "1014", 0x180000, 0x20000, 0x93bfcc15 ) ROM_LOAD_ODD ( "1015", 0x1c0000, 0x20000, 0x9378ad0b ) ROM_LOAD_EVEN( "1016", 0x1c0000, 0x20000, 0x19c3fbe0 ) ROM_REGION( 0x40000, REGION_SOUND1 ) /* 256k for ADPCM samples */ ROM_LOAD( "1061", 0x00000, 0x10000, 0x5b0468c6 ) ROM_LOAD( "1062", 0x10000, 0x10000, 0xf73fe3cb ) ROM_LOAD( "1063", 0x20000, 0x10000, 0xaa93421d ) ROM_LOAD( "1064", 0x30000, 0x10000, 0x33f045d5 ) ROM_END /************************************* * * Game driver(s) * *************************************/ GAME( 1990, hydra, 0, hydra, hydra, hydra, ROT0, "Atari Games", "Hydra" ) GAME( 1990, hydrap, hydra, hydra, hydra, hydrap, ROT0, "Atari Games", "Hydra (prototype)" ) GAME( 1990, pitfight, 0, hydra, pitfight, pitfight, ROT0, "Atari Games", "Pit Fighter (version 4)" ) GAME( 1990, pitfigh3, pitfight, hydra, pitfight, pitfight, ROT0, "Atari Games", "Pit Fighter (version 3)" )
[ [ [ 1, 619 ] ] ]
b6dd903cb4c55b72b72ae42b865cdd0dd04a4a60
c440e6c62e060ee70b82fc07dfb9a93e4cc13370
/src/modules/delay.h
76d4c33a990960523e053bed7e661fe143d60885
[]
no_license
BackupTheBerlios/pgrtsound-svn
2a3f2ae2afa4482f9eba906f932c30853c6fe771
d7cefe2129d20ec50a9e18943a850d0bb26852e1
refs/heads/master
2020-05-21T01:01:41.354611
2005-10-02T13:09:13
2005-10-02T13:09:13
40,748,578
0
0
null
null
null
null
MacCentralEurope
C++
false
false
436
h
#ifndef DELAY_H #define DELAY_H #include "module.h" /** Modul opů?nienia. Reguleje opů?nienie */ class Delay : public Module { public: Delay(); ~Delay(); void Process(); REGISTER_MODULE( "Delay", Delay ) private: Input iIn; Output oOut; ParameterFloat pDelay; float *buffor; int n1, n2; int maxDelay; }; #endif // DELAY_H
[ "mariusz@fa088095-53e8-0310-8a07-f9518708c3e6" ]
[ [ [ 1, 27 ] ] ]
aa3c3202d6ea7e7ff6cfe4820d439cafa5d019c0
38664d844d9fad34e88160f6ebf86c043db9f1c5
/branches/initialize/skin/src/base/SkinScheme.h
c30633a920290bf93bee7fd8fbd23f4cf7d95750
[]
no_license
cnsuhao/jezzitest
84074b938b3e06ae820842dac62dae116d5fdaba
9b5f6cf40750511350e5456349ead8346cabb56e
refs/heads/master
2021-05-28T23:08:59.663581
2010-11-25T13:44:57
2010-11-25T13:44:57
null
0
0
null
null
null
null
GB18030
C++
false
false
22,065
h
#ifndef __SKINSCHEME_H__ #define __SKINSCHEME_H__ #include <boost/shared_ptr.hpp> #include <tmschema.h> #include "../skinitf.h" #include "skiniid.h" #include "scheme.h" #include "CacheDC.h" // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 // +-----------+-----------+-------+-------------------------------+ // | class | part | state | prop | // +-----------+-----------|-------+-------------------------------+ namespace Skin{ using ATL::CWindow; class ATL_NO_VTABLE SkinScheme : public ATL::CComObjectRoot , public ISkinScheme { public: typedef SkinScheme thisType; BEGIN_COM_MAP(thisType) COM_INTERFACE_ENTRY_IID(IID_ISkinScheme, ISkinScheme) END_COM_MAP() SkinScheme() { _changeColor = false; } DECLARE_PROTECT_FINAL_CONSTRUCT() HRESULT FinalConstruct() { // Do Nothing return S_OK; } void FinalRelease() { } // ISkinScheme STDMETHODIMP_(BOOL) Draw(HDC hdc, int iClassId, int iPartId, int iStateId, long dx, long dy, long dcx = 0, long dcy = 0, DWORD dwRop = SRCCOPY) { ASSERT( hdc ); if (!_spCache) return FALSE; area_t area; BOOL f = _psd->get(make_key(iClassId, iPartId, iStateId), area); ASSERT(f); if (f) { if( 0 == dcx ) dcx = area.right - area.left; if( 0 == dcy ) dcy = area.bottom - area.top; // TransparentBlt2(hdc, dx, dy, dcx, dcy, _spCache->GetDC(), area.left, // area.top, scx, scy, _spCache->TranslateColor()); if (area.hstep && !area.vstep) { // horz and !vert // ___________________ // || || // || || // || || // ------------------- // 左 TransparentBlt2(hdc, dx, dy, area.hstep, dcy, _spCache->GetDC(), area.left, area.top, area.hstep, area.Height(), _spCache->TranslateColor()); // 中 StretchBlt(hdc, dx + area.hstep, dy, dcx - 2 * area.hstep, dcy, _spCache->GetDC(), area.left + area.hstep, area.top, area.Width() - 2 * area.hstep, area.Height(), SRCCOPY); // 右 TransparentBlt2(hdc, dx + dcx - area.hstep , dy, area.hstep, dcy, _spCache->GetDC(), area.right - area.hstep, area.top, area.hstep, area.Height(), _spCache->TranslateColor()); } else if (!area.hstep && area.vstep) { // !horz and vert // ___________________ // | | // ------------------- // | | // | | // ------------------- // | | // ------------------- // 上 TransparentBlt2(hdc, dx, dy, dcx, area.vstep, _spCache->GetDC(), area.left, area.top, area.Width(), area.vstep, _spCache->TranslateColor()); // 中 StretchBlt(hdc, dx, dy + area.vstep, dcx, dy - 2 * area.vstep, _spCache->GetDC(), area.left, area.top + area.vstep, area.Width(), area.Height() - 2 * area.vstep, SRCCOPY); // 下 TransparentBlt2(hdc, dx, dy + dcy - area.vstep, dcx, area.vstep, _spCache->GetDC(), area.left, area.bottom - area.vstep, area.Width(), area.vstep, _spCache->TranslateColor()); } else if (area.hstep && area.vstep) { // horz and vert // ___________________ // || || // ------------------- // || || // || || // ------------------- // || || // ------------------- // 左上角 TransparentBlt2(hdc, dx, dy, area.hstep, area.vstep, _spCache->GetDC(), area.left, area.top, area.hstep, area.vstep, _spCache->TranslateColor()); // 上部中间 StretchBlt(hdc, dx + area.hstep, dy, dcx - 2 * area.hstep, area.vstep, _spCache->GetDC(), area.left + area.hstep, area.top, area.Width() - 2 * area.hstep, area.vstep, SRCCOPY); // 上部右边 TransparentBlt2(hdc, dx + dcx - area.hstep, dy, area.hstep, area.vstep, _spCache->GetDC(), area.right - area.hstep, area.top, area.hstep, area.vstep, _spCache->TranslateColor()); // 中间部分 左边 StretchBlt(hdc, dx, dy + area.vstep, area.hstep, dcy - 2 * area.vstep, _spCache->GetDC(), area.left, area.top + area.vstep, area.hstep, area.Height() - 2 * area.vstep, SRCCOPY); // 中间部分 中部 StretchBlt(hdc, dx + area.hstep, dy + area.vstep, dcx - 2 * area.hstep, dcy - 2 * area.vstep, _spCache->GetDC(), area.left + area.hstep, area.top + area.vstep, area.Width() - 2 * area.hstep, area.Height() - 2 * area.vstep, SRCCOPY); // 中间部分 右边 StretchBlt(hdc, dx + dcx - area.hstep, dy + area.vstep, area.hstep, dcy - 2 * area.vstep, _spCache->GetDC(), area.right - area.hstep, area.top + area.vstep, area.hstep, area.Height() - 2 * area.vstep, SRCCOPY); // 下面部分 左边 TransparentBlt2(hdc, dx, dy + dcy - area.vstep, area.hstep, area.vstep, _spCache->GetDC(), area.left, area.top + area.Height() - area.vstep, area.hstep, area.vstep, _spCache->TranslateColor()); // 下面部分 中间 StretchBlt(hdc, dx + area.hstep, dy + dcy - area.vstep, dcx - 2 * area.hstep, area.vstep, _spCache->GetDC(), area.left + area.hstep, area.bottom - area.vstep, area.Width() - 2 * area.hstep, area.vstep, SRCCOPY); // 下面部分 右边 TransparentBlt2(hdc, dx + dcx - area.hstep, dy + dcy - area.vstep, area.hstep, area.vstep, _spCache->GetDC(), area.right - area.hstep, area.bottom - area.vstep, area.hstep, area.vstep, _spCache->TranslateColor()); } else if (!area.hstep && !area.vstep) { f = ::StretchBlt(hdc, dx, dy, dcx, dcy, _spCache->GetDC(), area.left, area.top, area.right-area.left, area.bottom-area.top, dwRop); ASSERT(f); } #if 0 HDC d = ::GetDC(0); BitBlt(d, dx, dy, dcx, dcy, _spCache->GetDC(), area.left, area.top, SRCCOPY); ::ReleaseDC(0, d); #endif } return f; } // source 部分参数: sx/sy 相对于本图片的左上角的坐标,scx/scy 尺寸 // d: dest s: source STDMETHODIMP_(BOOL) Draw(HDC hdc, int iClassId, int iPartId, int iStateId, long dx, long dy, long dcx, long dcy, long sx, long sy, long scx, long scy, DWORD dwRop = SRCCOPY) { ASSERT( hdc ); if (!_spCache) return FALSE; area_t area; BOOL f = _psd->get(make_key(iClassId, iPartId, iStateId), area); ASSERT(f); if (f) { ASSERT( sx + scx <= area.right - area.left ); ASSERT( sy + scy <= area.bottom - area.top ); area.left += sx; area.top += sy; f = ::StretchBlt(hdc, dx, dy, dcx, dcy, _spCache->GetDC(), area.left, area.top, area.right-area.left, area.bottom-area.top, dwRop); ASSERT(f); } return f; } STDMETHODIMP_(BOOL) TransparentDraw(HDC hdc, int iClassId, int iPartId, int iStateId, long dx, long dy, long dcx, long dcy, long sx, long sy, long scx, long scy) { ASSERT( hdc ); if (!_spCache) return FALSE; area_t area; BOOL f = _psd->get(make_key(iClassId, iPartId, iStateId), area); ASSERT(f); if (f) { ASSERT( sx + scx <= area.right - area.left ); ASSERT( sy + scy <= area.bottom - area.top ); area.left += sx; area.top += sy; f = TransparentBlt2(hdc, dx, dy, dcx, dcy, _spCache->GetDC(), area.left, area.top, scx, scy, _spCache->TranslateColor()); ASSERT(f); } return f; } STDMETHODIMP_(BOOL) TransparentDraw(HDC hdc, int iClassId, int iPartId, int iStateId, const RECT* lprc) { ASSERT( lprc ); return lprc && TransparentDraw(hdc, iClassId, iPartId, iStateId, lprc->left, lprc->top, lprc->right-lprc->left, lprc->bottom-lprc->top ); } STDMETHODIMP_(BOOL) TransparentDraw(HDC hdc, int iClassId, int iPartId, int iStateId, long dx, long dy, long dcx = 0, long dcy = 0) { ASSERT( hdc ); if (!_spCache) return FALSE; area_t area; BOOL f = _psd->get(make_key(iClassId, iPartId, iStateId), area); ASSERT(f); if (f) { if( 0 == dcx ) dcx = area.right - area.left; if( 0 == dcy ) dcy = area.bottom - area.top; // TransparentBlt2(hdc, dx, dy, dcx, dcy, _spCache->GetDC(), area.left, // area.top, scx, scy, _spCache->TranslateColor()); if (area.hstep && !area.vstep) { // horz and !vert // ___________________ // || || // || || // || || // ------------------- // 左 TransparentBlt2(hdc, dx, dy, area.hstep, dcy, _spCache->GetDC(), area.left, area.top, area.hstep, area.Height(), _spCache->TranslateColor()); // 中 TransparentBlt2(hdc, dx + area.hstep, dy, dcx - 2 * area.hstep, dcy, _spCache->GetDC(), area.left + area.hstep, area.top, area.Width() - 2 * area.hstep, area.Height(), _spCache->TranslateColor()); // 右 TransparentBlt2(hdc, dx + dcx - area.hstep , dy, area.hstep, dcy, _spCache->GetDC(), area.right - area.hstep, area.top, area.hstep, area.Height(), _spCache->TranslateColor()); } else if (!area.hstep && area.vstep) { // !horz and vert // ___________________ // | | // ------------------- // | | // | | // ------------------- // | | // ------------------- // 上 TransparentBlt2(hdc, dx, dy, dcx, area.vstep, _spCache->GetDC(), area.left, area.top, area.Width(), area.vstep, _spCache->TranslateColor()); // 中 TransparentBlt2(hdc, dx, dy + area.vstep, dcx, dy - 2 * area.vstep, _spCache->GetDC(), area.left, area.top + area.vstep, area.Width(), area.Height() - 2 * area.vstep, _spCache->TranslateColor()); // 下 TransparentBlt2(hdc, dx, dy + dcy - area.vstep, dcx, area.vstep, _spCache->GetDC(), area.left, area.bottom - area.vstep, area.Width(), area.vstep, _spCache->TranslateColor()); } else if (area.hstep && area.vstep) { // horz and vert // ___________________ // || || // ------------------- // || || // || || // ------------------- // || || // ------------------- // 左上角 TransparentBlt2(hdc, dx, dy, area.hstep, area.vstep, _spCache->GetDC(), area.left, area.top, area.hstep, area.vstep, _spCache->TranslateColor()); // 上部中间 TransparentBlt2(hdc, dx + area.hstep, dy, dcx - 2 * area.hstep, area.vstep, _spCache->GetDC(), area.left + area.hstep, area.top, area.Width() - 2 * area.hstep, area.vstep, _spCache->TranslateColor()); // 上部右边 TransparentBlt2(hdc, dx + dcx - area.hstep, dy, area.hstep, area.vstep, _spCache->GetDC(), area.right - area.hstep, area.top, area.hstep, area.vstep, _spCache->TranslateColor()); // 中间部分 左边 TransparentBlt2(hdc, dx, dy + area.vstep, area.hstep, dcy - 2 * area.vstep, _spCache->GetDC(), area.left, area.top + area.vstep, area.hstep, area.Height() - 2 * area.vstep, _spCache->TranslateColor()); // 中间部分 中部 TransparentBlt2(hdc, dx + area.hstep, dy + area.vstep, dcx - 2 * area.hstep, dcy - 2 * area.vstep, _spCache->GetDC(), area.left + area.hstep, area.top + area.vstep, area.Width() - 2 * area.hstep, area.Height() - 2 * area.vstep, _spCache->TranslateColor()); // 中间部分 右边 TransparentBlt2(hdc, dx + dcx - area.hstep, dy + area.vstep, area.hstep, dcy - 2 * area.vstep, _spCache->GetDC(), area.right - area.hstep, area.top + area.vstep, area.hstep, area.Height() - 2 * area.vstep, _spCache->TranslateColor()); // 下面部分 左边 TransparentBlt2(hdc, dx, dy + dcy - area.vstep, area.hstep, area.vstep, _spCache->GetDC(), area.left, area.top + area.Height() - area.vstep, area.hstep, area.vstep, _spCache->TranslateColor()); // 下面部分 中间 TransparentBlt2(hdc, dx + area.hstep, dy + dcy - area.vstep, dcx - 2 * area.hstep, area.vstep, _spCache->GetDC(), area.left + area.hstep, area.bottom - area.vstep, area.Width() - 2 * area.hstep, area.vstep, _spCache->TranslateColor()); // 下面部分 右边 TransparentBlt2(hdc, dx + dcx - area.hstep, dy + dcy - area.vstep, area.hstep, area.vstep, _spCache->GetDC(), area.right - area.hstep, area.bottom - area.vstep, area.hstep, area.vstep, _spCache->TranslateColor()); } else if (!area.hstep && !area.vstep) { f = TransparentBlt2(hdc, dx, dy, dcx, dcy, _spCache->GetDC(), area.left, area.top, area.right-area.left, area.bottom-area.top, _spCache->TranslateColor()); ASSERT(f); } #if 0 HDC d = ::GetDC(0); BitBlt(d, dx, dy, dcx, dcy, _spCache->GetDC(), area.left, area.top, SRCCOPY); ::ReleaseDC(0, d); #endif } return f; /* ASSERT( hdc ); if (!_spCache) return FALSE; area_t area; BOOL f = _psd->get(make_key(iClassId, iPartId, iStateId), area); ASSERT(f); if (f) { if( 0 == dcx ) dcx = area.right - area.left; if( 0 == dcy ) dcy = area.bottom - area.top; f = TransparentBlt2(hdc, dx, dy, dcx, dcy, _spCache->GetDC(), area.left, area.top, area.right-area.left, area.bottom-area.top, _spCache->TranslateColor()); ASSERT(f); } return f; */ } // 类似于 ExtractIcon STDMETHODIMP_(BOOL) GetBitmap(int iClassId, int iPartId, int iStateId, int iPropId, HBITMAP *pBitmap) { if (!_spCache) return FALSE; area_t area; BOOL f = _psd->get(make_key(iClassId, iPartId, iStateId), area); ASSERT(f); if (!f) return FALSE; // 1 target bitmap and target dc HDC dcTarget = ::CreateCompatibleDC( 0 ); //(HDC)_cache ); ATLASSERT( dcTarget ); if( !dcTarget ) return FALSE; int bitsPixel = ::GetDeviceCaps( dcTarget, BITSPIXEL ); int planes = ::GetDeviceCaps( dcTarget, PLANES ); HBITMAP bmpTarget = ::CreateBitmap( area.right - area.left, area.bottom-area.top, planes, bitsPixel, 0 ); ATLASSERT( bmpTarget ); if( !bmpTarget ) { ::DeleteDC( dcTarget ); return FALSE; } HGDIOBJ pOldTargetBmp = ::SelectObject( dcTarget, bmpTarget ); ATLASSERT( pOldTargetBmp ); if( !pOldTargetBmp ) { ::DeleteObject( bmpTarget ); ::DeleteDC( dcTarget ); return FALSE; } // 2 just bitblt on target bitmap int nRet = 0; nRet = ::BitBlt(dcTarget, 0, 0, area.right-area.left, area.bottom-area.top, _spCache->GetDC(), area.left, area.top, SRCCOPY); ATLASSERT( nRet ); // 3 release ::SelectObject( dcTarget, pOldTargetBmp ); ::DeleteDC( dcTarget ); *pBitmap = bmpTarget; return TRUE; } STDMETHOD(DrawParentBackground)(HWND hwnd, HDC hdc, RECT *prc) { RECT rt; POINT org; HWND hParent; HRGN clip = NULL; int hasClip = -1; //TRACE("(%p,%p,%p)\n", hwnd, hdc, prc); hParent = GetParent(hwnd); if(!hParent) hParent = hwnd; if(prc) { CopyRect(&rt, prc); MapWindowPoints(hwnd, NULL, (LPPOINT)&rt, 2); clip = CreateRectRgn(0,0,1,1); hasClip = GetClipRgn(hdc, clip); if(hasClip == -1) TRACE("Failed to get original clipping region\n"); else IntersectClipRect(hdc, prc->left, prc->top, prc->right, prc->bottom); } else { GetClientRect(hParent, &rt); MapWindowPoints(hParent, NULL, (LPPOINT)&rt, 2); } OffsetViewportOrgEx(hdc, -rt.left, -rt.top, &org); SendMessageW(hParent, WM_ERASEBKGND, (WPARAM)hdc, 0); SendMessageW(hParent, WM_PRINTCLIENT, (WPARAM)hdc, PRF_CLIENT); SetViewportOrgEx(hdc, org.x, org.y, NULL); if(prc) { if(hasClip == 0) SelectClipRgn(hdc, NULL); else if(hasClip == 1) SelectClipRgn(hdc, clip); DeleteObject(clip); } return S_OK; #if 0 CWindow wndparent( GetParent(hwnd) ); CWindow wndchild(hwnd); // 直接使用纯色填充 HBRUSH br = (HBRUSH)wndparent.SendMessage(WM_CTLCOLORDLG, (WPARAM)hdc, (LPARAM)hwnd); if (br) FillRect(hdc, prc, br); // TODO: 检测 WM_PRINTCLIENT 返回值,确定 Dialog 是否有底图 CRect rcparent; wndparent.GetClientRect(&rcparent); // memory dc HDC dcMem = ::CreateCompatibleDC(hdc); ASSERT( dcMem ); HBITMAP bmpMemBg = ::CreateCompatibleBitmap(hdc, rcparent.Width(), rcparent.Height()); ASSERT( bmpMemBg ); HGDIOBJ pOldBmp = ::SelectObject(dcMem, bmpMemBg); ASSERT( pOldBmp ); // 1绘制再memdc 上面 LRESULT lRes = wndparent.SendMessage(WM_PRINTCLIENT, (WPARAM)dcMem, PRF_CLIENT | PRF_ERASEBKGND | PRF_CHECKVISIBLE); // memory dc // ::BitBlt(hdc, prc->left, prc->top, prc->right - prc->left, // prc->bottom - prc->top, dcMem, pt.x, pt.y, SRCCOPY); ::SelectObject(dcMem, pOldBmp); ::DeleteObject(bmpMemBg); ::DeleteDC(dcMem); #endif return S_OK; } STDMETHOD_(BOOL, IsThemeBackgroundPartiallyTransparent)(int iClassId, int iPartId, int iStateId) { // TODO: 从配置中读取一些信息来确定是否为透明控件 if (iClassId == BUTTON ) return TRUE; if (iClassId == PROGRESS ) return TRUE; if (iClassId == TRACKBAR) return TRUE; if (iClassId == TAB) return TRUE; return FALSE; } // 在非MemoryDC中,参数pClipRect非常有意义,在本Skin的实现中可以不使用 STDMETHOD(DrawBackground)(HDC hdc, int iClassId, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect) { BOOL f = Draw( hdc, iClassId, iPartId, iStateId, pRect->left, pRect->top, pRect->right - pRect->left, pRect->bottom - pRect->top ); return f; } // dwTextFlags, dwTextFlags2 的定义见 MSDN: DrawThemeText STDMETHOD(DrawText)(HDC hdc, int iClassId, int iPartId, int iStateId, LPCSTR szText, DWORD dwTextFlags,DWORD dwTextFlags2, const RECT *pRect) { // TODO: use logfont COLORREF cr; if (pRect && GetColor(iClassId, iPartId, iStateId, TMT_TEXTCOLOR, &cr)) { RECT rc = *pRect; int mode = SetBkMode(hdc, TRANSPARENT); COLORREF clrOldText = ::SetTextColor( hdc, cr ); ::DrawText(hdc, szText, -1, &rc, dwTextFlags); SetBkMode(hdc, mode); ::SetTextColor(hdc,clrOldText); } return S_OK; } STDMETHOD(DrawIcon)(HDC hdc, int iClassId, int iPartId, int iStateId, const RECT *pRect, HIMAGELIST himl, int iImageIndex) { return S_OK; } // uEdge, uFlags, pContentRect 现在可以不使用 STDMETHOD(DrawEdge)(HDC hdc, int iClassId, int iPartId, int iStateId, const RECT *pDestRect, UINT uEdge, UINT uFlags, OPTIONAL OUT RECT *pContentRect) { return S_OK; } STDMETHODIMP_(BOOL) GetColor(int iClassId, int iPartId, int iStateId, int iPropId, COLORREF *pColor) { bool bRet = _psd->get(make_key(iClassId, iPartId, iStateId, iPropId), *pColor); if ( _changeColor ) { BYTE lR = 255 - (255 - GetRValue(*pColor)) * (255 - GetRValue(_clr)) / 255; BYTE lG = 255 - (255 - GetGValue(*pColor)) * (255 - GetGValue(_clr)) / 255; BYTE lB = 255 - (255 - GetBValue(*pColor)) * (255 - GetBValue(_clr)) / 255; *pColor = RGB( lR, lG, lB ); } return bRet ? TRUE : FALSE; } STDMETHOD_(BOOL, GetRect)(int iClassId, int iPartId, int iStateId, RECT *pRect) { area_t area; BOOL f = _psd->get(make_key(iClassId, iPartId, iStateId), area); if (!f && iStateId) { ATLTRACE("iStateId change to zero\n"); f = _psd->get(make_key(iClassId, iPartId, 0), area); } ASSERT(f); if (f && pRect) *pRect = area; return f; } STDMETHOD_(BOOL, GetFont) (int iClassId, int iPartId, int iStateId, int iPropId, LOGFONT *pFont) { return FALSE; } STDMETHOD_(BOOL, GetRegion)(int iClassId, int iPartId, int iStateId, int iPropId, HRGN *pRegion) { area_t area; BOOL f = _psd->get(make_key(iClassId, iPartId, iStateId), area); if (f) { HBITMAP bmp = _spCache->GetBitmap(); if( bmp ) { HRGN rgn = BitmapToRegion( bmp, _spCache->TranslateColor(), _spCache->TranslateColor(), &area); f = TRUE; *pRegion = rgn; } } return f; } STDMETHOD_(COLORREF, TranslateColor)() { return _spCache->TranslateColor(); } STDMETHOD_(BOOL, ChangeSchemeColor)( COLORREF clr ) { // _changeColor = true; _clr = clr; _spCache->ChangeColor( clr ); return TRUE; } STDMETHOD_(BOOL, ClearSchemeColor)( ) { // _changeColor = false; //_clr = clr; _spCache->ClearColor( ); return TRUE; } public: void SetSchemeData(const scheme_data * psd, boost::shared_ptr<CCacheDC> cdc) { _psd = psd; _spCache = cdc; } private: boost::shared_ptr<CCacheDC> _spCache; // todo: use shared_ptr<CCacheDC> const scheme_data * _psd; bool _changeColor; COLORREF _clr; }; } // Skin #endif //__SKINSCHEME_H__
[ "ken.shao@ba8f1dc9-3c1c-0410-9eed-0f8a660c14bd", "zhongzeng@ba8f1dc9-3c1c-0410-9eed-0f8a660c14bd" ]
[ [ [ 1, 11 ], [ 13, 30 ], [ 35, 84 ], [ 86, 165 ], [ 170, 244 ], [ 246, 250 ], [ 387, 404 ], [ 406, 463 ], [ 508, 517 ], [ 519, 551 ], [ 561, 582 ], [ 584, 584 ], [ 586, 587 ], [ 589, 608 ], [ 620, 657 ], [ 695, 700 ], [ 702, 704 ], [ 707, 710 ] ], [ [ 12, 12 ], [ 31, 34 ], [ 85, 85 ], [ 166, 169 ], [ 245, 245 ], [ 251, 386 ], [ 405, 405 ], [ 464, 507 ], [ 518, 518 ], [ 552, 560 ], [ 583, 583 ], [ 585, 585 ], [ 588, 588 ], [ 609, 619 ], [ 658, 694 ], [ 701, 701 ], [ 705, 706 ] ] ]
8d57383cdff30274d0568a1d9f6d4370c711fa8f
95a8d2b18434b00ff35ffddd6b4c2fb744ffab48
/src/mainwnd.h
ee630108e27b0a7c640a5b9d3db342941401027d
[]
no_license
DTM9025/musicroom
912ee0829a26e67be2d3c070fcb1cf2680ec2883
cf1e97209c279fbbeb210601e7466af35f9848fd
refs/heads/master
2020-03-20T13:07:44.448378
2011-09-01T22:50:42
2011-09-01T22:50:42
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
3,813
h
// Music Room Interface // -------------------- // mainwnd.h - GUI // -------------------- // "©" Nmlgc, 2010-2011 #ifndef MUSICROOM_MAINWD_H #define MUSICROOM_MAINWD_H // Action states #define MW_ACT_NONE 0x00 #define MW_ACT_EXTRACT 0x01 #define MW_ACT_TAG 0x02 #define MW_ACT_ALL MW_ACT_EXTRACT | MW_ACT_TAG // Forward declarations class LCListBox; class LCTable; class LCText; class LCDirFrame; class MainWnd : public FXMainWindow { FXDECLARE(MainWnd); friend class Extractor; friend class MainWndFront; private: MainWnd() {} protected: volatile bool Lock; short PrevTrackID; TrackInfo* CurTrack; // Widgets LCDirFrame* GameDir; FXCheckButton* TrackPlay; FXSlider* TrackVol; FXDataTarget VolDT; LCTable* TrackView; LCText* Comment; FXDataTarget WikiDT; FXCheckButton* GetWiki; FXTextField* FNField; FXLabel* FNExample; FXSpinner* LoopField; FXRealSpinner* FadeField; FXDataTarget AlgDT; FXListBox* AlgBox; FXCheckButton* RemoveSilence; LCDirFrame* OutDir; FXButton* StartAll; FXButton* StartSel; FXButton* TagUpdate; FXButton* Stop; FXDataTarget EncDT; FXRadioButton** EncBtn; LCText* Stat; FXProgressBar* ProgBar; FXDataTarget ProgDT; FXStatusLine* PlayStat; bool CheckOutDir(); void SetComment(TrackInfo* TI); public: MainWnd(FXApp* App, FXIcon* AppIcon = NULL); FXString StatCache; // PrintStat collector FXString Notice; // Personal appeal cache LCListBox* GameList; bool CFGFail; // Messages enum { MW_INIT = FXMainWindow::ID_LAST, // GUI MW_CHANGE_ACTION_STATE, MW_STOP_SHOW, MW_SHOW_NOTICE, MW_FILLTABLE_BASIC, MW_UPDATE_STRINGS, MW_UPDATE_LENGTHS, MW_FN_PATTERN, MW_LOAD_BGM_INFO, MW_SELECT_DIR, MW_LOAD_GAME, MW_SWITCH_GAME, MW_CHANGE_TRACK, MW_PROG_REDRAW, MW_TOGGLE_PLAY, MW_PLAY_STAT, MW_UPDATE_ENC, MW_UPDATE_ENC_END = MW_UPDATE_ENC + MAX_ENCODERS, MW_ENC_SETTINGS, MW_OUTDIR, // Actions MW_EXTRACT_ALL, MW_EXTRACT_SEL, MW_TAG_UPDATE, MW_STOP, MW_THREAD_STAT, MW_THREAD_MSG, MW_ACT_FINISH, ID_LAST }; void create(); // Inits the streamer and reads BGM info files FXbool close(FXbool notify = true); MSG_FUNC(onChangeActionState); // Changes the state of the extraction and tag buttons. [ptr] takes any valid action state value (see above) MSG_FUNC(onStopShow); MSG_FUNC(onShowNotice); MSG_FUNC(onFillTableBasic); MSG_FUNC(onCmdStrings); // Updates all string labels with the set language MSG_FUNC(onUpdStrings); // Updates all string labels with the set language MSG_FUNC(onCmdLengths); // Calculate track lengths based on loop count and fade duration MSG_FUNC(onFNPattern); MSG_FUNC(onLoadBGMInfo); MSG_FUNC(onSelectDir); MSG_FUNC(onLoadGame); // Loads the game in the [ptr] directory MSG_FUNC(onSwitchGame); MSG_FUNC(onChangeTrack); MSG_FUNC(onProgRedraw); MSG_FUNC(onTogglePlay); MSG_FUNC(onPlayStat); // Displays playing status tooltip MSG_FUNC(onStream); MSG_FUNC(onUpdEnc); // Selects a new encoder MSG_FUNC(onEncSettings); // Shows encoding settings dialog MSG_FUNC(onExtractTrack); MSG_FUNC(onExtract); MSG_FUNC(onTagUpdate); MSG_FUNC(onStop); MSG_FUNC(onThreadStat); // Prints out collected stat messages from other threads MSG_FUNC(onThreadMsg); MSG_FUNC(onActFinish); void LoadGame(FXString& Path); void LoadGame(GameInfo* NewGame); void PrintStat(const FXString& NewStat); void ProgConnect(volatile FXulong* Var = NULL, FXuint Max = 0); // Connects any variable to the progress bar at the bottom. Call again with [Var = NULL] to unresolve. }; extern MainWnd* MWBack; // Back end GUI class #endif /* MUSICROOM_MAINWD_H */
[ [ [ 1, 171 ] ] ]
15dcb00da3535cf7fba5ba4e52b7c2ae0d6d1d63
0531b270535a46f315ead3524e60fb70fd6055da
/Source/libkwl/IrcMessages.h
79eb20bb4cc1ba2ecae412065f9f229cc2af7f1e
[]
no_license
jannispl/kwlbot
e7588283d395ea6d54f6a82d45f2f0577f66fde1
a5c1ea65c38067747893eeccdae726faeedec0d5
refs/heads/master
2021-01-01T19:10:16.324535
2010-12-12T22:58:24
2010-12-12T22:58:24
33,863,720
0
0
null
null
null
null
UTF-8
C++
false
false
2,291
h
/* kwlbot IRC bot File: IrcMessages.h Purpose: Various classes describing IRC messages */ class CRawMessage; class CJoinMessage; class CPartMessage; class CPrivateMessage; class CNoticeMessage; class CTopicMessage; class CWhoMessage; #ifndef _IRCMESSAGES_H #define _IRCMESSAGES_H #include "IrcMessage.h" #include "Bot.h" #ifdef WIN32 #define snprintf _snprintf #endif class CRawMessage : public CIrcMessage { public: CRawMessage(const char *szFormat, ...) { static char szBuffer[IRC_MAX_LEN + 1]; va_list vaArgs; va_start(vaArgs, szFormat); int iLength = vsnprintf(szBuffer, IRC_MAX_LEN + 1, szFormat, vaArgs); va_end(vaArgs); m_strRaw.assign(szBuffer, iLength); } }; class CJoinMessage : public CIrcMessage { public: #if !defined(SERVICE) || IRCD != HYBRID CJoinMessage(const std::string &strChannel) { m_strRaw = "JOIN " + strChannel; } #else CJoinMessage(time_t ullChannelStamp, const std::string &strNickname, const std::string &strChannel) { m_bServiceMessage = true; char szTemp[32]; sprintf(szTemp, "%ld", (long)ullChannelStamp); m_strRaw = "SJOIN " + std::string(szTemp) + " " + strChannel + " " + strNickname; } #endif }; class CPartMessage : public CIrcMessage { public: CPartMessage(const std::string &strChannel) { m_strRaw = "PART " + strChannel; } CPartMessage(const std::string &strChannel, const std::string &strReason) { m_strRaw = "PART " + strChannel + " :" + strReason; } }; class CPrivateMessage : public CIrcMessage { public: CPrivateMessage(const std::string &strTarget, const std::string &strMessage) { m_strRaw = "PRIVMSG " + strTarget + " :" + strMessage; } }; class CNoticeMessage : public CIrcMessage { public: CNoticeMessage(const std::string &strTarget, const std::string &strMessage) { m_strRaw = "NOTICE " + strTarget + " :" + strMessage; } }; class CTopicMessage : public CIrcMessage { public: CTopicMessage(const std::string &strChannel, const std::string &strTopic) { m_strRaw = "TOPIC " + strChannel + " :" + strTopic; } }; class CWhoMessage : public CIrcMessage { public: CWhoMessage(const std::string &strTarget) { m_strRaw = "WHO " + strTarget; } }; #endif
[ "[email protected]@f9c66ffb-4930-c197-0f80-100fa691f586" ]
[ [ [ 1, 113 ] ] ]
58086f591afda03c78c243a8de0c685953bf5332
b546f33f58d2fad0c6fd1bb431532ab6124c118a
/shared-code/BitSet.h
cf36e3bcb9efe418e6a8cfed62c0de17ef251dc4
[ "MIT" ]
permissive
hacker/T42
cdcc02f91d52262374f1e0b6f286e387bfb9b582
025f8c9b1a478eed9dcb9e0ac13b9e26e955860a
refs/heads/master
2021-01-20T11:59:58.800561
2005-08-06T13:59:18
2005-08-06T13:59:18
892,107
2
0
null
null
null
null
UTF-8
C++
false
false
2,665
h
#ifndef __BITSET_H #define __BITSET_H namespace Klever { class CBitSet : public CObject { public: CWordArray m_Bits; ULONG m_BitsInSet; enum { bitsPerWord = sizeof(WORD)*8 }; CBitSet(ULONG size = 0) : m_BitsInSet(0) { SetSize(size); } CBitSet(CBitSet& o) : m_BitsInSet(0) { CopyFrom(o); } void SetSize(ULONG size,BOOL bFillOnes=FALSE) { UINT os = m_Bits.GetSize(); UINT ns = (size+bitsPerWord-1)/bitsPerWord; if(os==ns){ if(os){ if(bFillOnes) m_Bits[m_BitsInSet/bitsPerWord]|=(~(WORD)0)<<(m_BitsInSet%bitsPerWord); else m_Bits[m_BitsInSet/bitsPerWord]&=~((~(WORD)0)<<(m_BitsInSet%bitsPerWord)); } m_BitsInSet=size; }else{ // *?* ASSERT((!os) || (((os-1)*bitsPerWord)<=m_BitsInSet && m_BitsInSet<(os*bitsPerWord))); if(os<ns){ m_Bits.SetSize(ns); if(bFillOnes) m_Bits[m_BitsInSet/bitsPerWord]|=(~(WORD)0)<<(m_BitsInSet%bitsPerWord); else m_Bits[m_BitsInSet/bitsPerWord]&=~((~(WORD)0)<<(m_BitsInSet%bitsPerWord)); WORD* ws = m_Bits.GetData(); ASSERT(ws); memset(&ws[os],bFillOnes?0xFF:0,(ns-os)*sizeof(WORD)); m_BitsInSet=size; }else{ m_Bits.SetSize(ns); m_BitsInSet=size; } } } BOOL BitSet(UINT bit,BOOL bGrow=TRUE) { return SetBit(bit,TRUE,bGrow); } BOOL BitClear(UINT bit,BOOL bGrow=TRUE) { return SetBit(bit,FALSE,bGrow); } BOOL SetBit(UINT bit,BOOL state,BOOL bGrow=TRUE) { if(m_BitsInSet<=bit){ if(!bGrow) return FALSE; SetSize(bit+1); } WORD mask = ((WORD)1)<<(bit%bitsPerWord); if(state) m_Bits[bit/bitsPerWord]|=mask; else m_Bits[bit/bitsPerWord]&=~mask; return TRUE; } BOOL IsSet(UINT bit) { if(m_BitsInSet<=bit) return FALSE; return (m_Bits[bit/bitsPerWord]&(((WORD)1)<<(bit%bitsPerWord)))!=0; } void Invert() { for(int i=m_Bits.GetUpperBound();i>=0;i--) m_Bits[i]=~m_Bits[i]; } CBitSet& operator&=(CBitSet& o) { if(o.m_BitsInSet<m_BitsInSet) SetSize(o.m_BitsInSet); for(int i=m_Bits.GetUpperBound();i>=0;i--) m_Bits[i]&=o.m_Bits[i]; return *this; } CBitSet& operator|=(CBitSet& o) { if(o.m_BitsInSet>m_BitsInSet) SetSize(o.m_BitsInSet); for(int i=o.m_Bits.GetUpperBound();i>=0;i--) m_Bits[i]|=o.m_Bits[i]; return *this; } CBitSet& operator=(CBitSet& o) { CopyFrom(o); return *this; } void CopyFrom(CBitSet& o) { m_BitsInSet=o.m_BitsInSet; m_Bits.Copy(o.m_Bits); } void Serialize(CArchive& ar) { if(ar.IsStoring()){ ar << m_BitsInSet; m_Bits.Serialize(ar); }else{ ar >> m_BitsInSet; m_Bits.Serialize(ar); } } }; }; #endif // __BITSET_H
[ [ [ 1, 105 ] ] ]
cea52df95e96eed61164cca8bdf9b2a4ec4cef71
b822313f0e48cf146b4ebc6e4548b9ad9da9a78e
/KylinSdk/Standard/Source/Singleton.h
d183a1e4b183ee215682d8fb39c4d6ede3b90e03
[]
no_license
dzw/kylin001v
5cca7318301931bbb9ede9a06a24a6adfe5a8d48
6cec2ed2e44cea42957301ec5013d264be03ea3e
refs/heads/master
2021-01-10T12:27:26.074650
2011-05-30T07:11:36
2011-05-30T07:11:36
46,501,473
0
0
null
null
null
null
UTF-8
C++
false
false
819
h
#pragma once namespace Kylin { template<typename T> class Singleton { static T* ms_singleton; public: Singleton() { assert(!ms_singleton); //use a cunning trick to get the singleton pointing to the start of the whole, rather than //the start of the Singleton part of the object KINT offset = (KINT)(T*)1 - (KINT)(Singleton <T>*)(T*)1; ms_singleton = (T*)((KINT)this + offset); } ~Singleton() { assert(ms_singleton); ms_singleton=0; } static KBOOL Initialized() { return NULL != ms_singleton; } static T& GetSingleton() { assert(ms_singleton); return *ms_singleton; } static T* GetSingletonPtr() { assert(ms_singleton); return ms_singleton; } }; template <typename T> T* Singleton <T>::ms_singleton = 0; }
[ [ [ 1, 39 ] ] ]
f284be1ded6e39e5dd292fa706d28eb7fea59fb5
ebc739a35cb8a455d9119bb71eb879c0060f5a5e
/src/intensity/client_system.cpp
58d9fe7ad108a2d7d51b96caa917cc58de864c52
[ "Zlib", "MIT" ]
permissive
t7g/intensityengine
c7171f4d3688f4abde921c52a11eebdbc3d9bcbb
fd814369bf8ec87676224bdaf1b78491447d59a4
refs/heads/master
2021-01-18T09:05:44.952676
2010-05-27T20:45:47
2010-05-27T20:45:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
20,718
cpp
// Copyright 2010 Alon Zakai ('kripken'). All rights reserved. // This file is part of Syntensity/the Intensity Engine, an open source project. See COPYING.txt for licensing. #include "cube.h" #include "engine.h" #include "game.h" #include "message_system.h" #include "world_system.h" #include "fpsserver_interface.h" #include "editing_system.h" #include "script_engine_manager.h" #include "utility.h" #include "client_engine_additions.h" #include "targeting.h" #include "intensity_gui.h" #include "intensity_texture.h" #include "master.h" #ifdef INTENSITY_PLUGIN #include "intensity_plugin_listener.h" #endif #include "client_system.h" #include "shared_module_members_boost.h" std::string ClientSystem::blankPassword = "1111111111"; // TODO: We should ensure the users can never have this for a real password! // Note: Sending CEGUI characters that are invalid to enter in the field might // seem like a nice solution here, but CEGUI has issues with that int ClientSystem::playerNumber = -1; LogicEntityPtr ClientSystem::playerLogicEntity; bool ClientSystem::loggedIn = false; bool ClientSystem::editingAlone = false; int ClientSystem::uniqueId = -1; std::string ClientSystem::currMap = ""; std::string ClientSystem::currTransactionCode = "MISSING_TRANSACTION_CODE"; std::string ClientSystem::currHost = ""; int ClientSystem::currPort = -1; std::string ClientSystem::currScenarioCode = ""; bool _scenarioStarted = false; bool _mapCompletelyReceived = false; #define USER_INFO_SECTION "UserInfo" #define VIDEO_SECTION "Video" std::string ClientSystem::getUsername() { return Utility::Config::getString(USER_INFO_SECTION, "username", ""); } std::string ClientSystem::getHashedPassword() { return Utility::Config::getString(USER_INFO_SECTION, "password", ""); } std::string ClientSystem::getVisualPassword() { if (getHashedPassword() != "") return blankPassword; // Visually, we show just 8 or so letters, not the entire hash of course else return ""; } void ClientSystem::connect(std::string host, int port) { // // Tell scripting there is no player entity until we finish logging in // ScriptEngineManager::getGlobal()->call("setPlayerUniqueId", ScriptEngineManager::getNull()); editingAlone = false; currHost = host; currPort = port; connectserv((char *)host.c_str(), port, ""); } void ClientSystem::login(int clientNumber) { Logging::log(Logging::DEBUG, "ClientSystem::login()\r\n"); playerNumber = clientNumber; MessageSystem::send_LoginRequest(currTransactionCode); // Utility::Config::getString(USER_INFO_SECTION, "username", "*error1*"), // Utility::Config::getString(USER_INFO_SECTION, "password", "*error2*") // ); } void ClientSystem::finishLogin(bool local) { editingAlone = local; loggedIn = true; // There is no Python LE for the player yet, we await its arrival from the server just like any other LE. When // it does arrive, we will point playerLogicEntity to it. See messages.template. Logging::log(Logging::DEBUG, "Now logged in, with unique_ID: %d\r\n", uniqueId); } void ClientSystem::doDisconnect() { disconnect(); } void ClientSystem::onDisconnect() { editingAlone = false; playerNumber = -1; loggedIn = false; _scenarioStarted = false; _mapCompletelyReceived = false; // it's also useful to stop all mapsounds and gamesounds (but only for client that disconnects!) stopsounds(); LogicSystem::clear(); } void ClientSystem::clearPlayerEntity() { Logging::log(Logging::DEBUG, "ClientSystem::clearPlayerEntity\r\n"); playerLogicEntity.reset(); } void ClientSystem::sendSavedMap() { assert(0); // Deprecated } /* bool ClientSystem::mapCompletelyReceived() { return _mapCompletelyReceived; } */ bool ClientSystem::scenarioStarted() { if (!_mapCompletelyReceived) Logging::log(Logging::INFO, "Map not completely received, so scenario not started\r\n"); // If not already started, test if indeed started if (_mapCompletelyReceived && !_scenarioStarted) { if (ScriptEngineManager::hasEngine()) _scenarioStarted = ScriptEngineManager::getGlobal()->call("testScenarioStarted")->getBool(); } return _mapCompletelyReceived && _scenarioStarted; } VAR(can_edit, 0, 0, 1); void ClientSystem::frameTrigger(int curtime) { if (scenarioStarted()) { PlayerControl::handleExtraPlayerMovements(curtime); TargetingControl::determineMouseTarget(); can_edit = int(isAdmin()); IntensityTexture::doBackgroundLoading(); } ClientSystem::cleanupHUD(); #ifdef INTENSITY_PLUGIN PluginListener::frameTrigger(); #endif } void ClientSystem::gotoLoginScreen() { assert(0); #if 0 Logging::log(Logging::DEBUG, "Going to login screen\r\n"); INDENT_LOG(Logging::DEBUG); LogicSystem::init(); // This is also done later, but as the mainloop assumes there is always a ScriptEngine, we do it here as well ClientSystem::onDisconnect(); // disconnect has several meanings... localconnect(); game::gameconnect(false); // FPSServerInterface::vote("login", 0); game::changemap("login"); Logging::log(Logging::DEBUG, "Going to login screen complete\r\n"); #endif } // Boost access for Python extern void sethomedir(const char *dir); // shared/tools.cpp int saved_argc = 0; char **saved_argv = NULL; extern int sauer_main(int argc, char **argv); // from main.cpp void client_main() { Logging::log(Logging::DEBUG, "client_main"); sauer_main(saved_argc, saved_argv); } void setTransactionCode(std::string code) { ClientSystem::currTransactionCode = code; } void show_message(std::string title, std::string content) { IntensityGUI::showMessage(title, content); printf("%s : %s\r\n", title.c_str(), content.c_str()); } // // HUD // struct queuedHUDRect { float x1, y1, x2, y2; int color; float alpha; }; std::vector<queuedHUDRect> queuedHUDRects; void ClientSystem::addHUDRect(float x1, float y1, float x2, float y2, int color, float alpha) { queuedHUDRect q; q.x1 = x1; q.y1 = y1; q.x2 = x2; q.y2 = y2; q.color = color; q.alpha = alpha; queuedHUDRects.push_back(q); } struct queuedHUDImage { std::string tex; float centerX, centerY; //!< In relative coordinates (to each axis, the center of where to draw the HUD // float widthInX, heightInY; //!< In axis-relative coordinates, how big the HUD should be. // //!< E.g. widthInX 0.5 means its width is half of the X dimension float width, height; int color; float alpha; queuedHUDImage() { tex = ""; centerX = 0.5; centerY = 0.5; // widthInX = 0; heightInY = 0; width = 0.61803399; height = 0.61803399; color = 0xFFFFFF, alpha = 1.0; } }; std::vector<queuedHUDImage> queuedHUDImages; void ClientSystem::addHUDImage(std::string tex, float centerX, float centerY, float width, float height, int color, float alpha) { queuedHUDImage q; q.tex = tex; q.centerX = centerX; q.centerY = centerY; q.width = width; q.height = height; q.color = color; q.alpha = alpha; queuedHUDImages.push_back(q); } struct queuedHUDText { std::string text; float x, y, scale; int color; }; std::vector<queuedHUDText> queuedHUDTexts; void ClientSystem::addHUDText(std::string text, float x, float y, float scale, int color) { queuedHUDText q; q.text = text; q.x = x; q.y = y; q.scale = scale; q.color = color; queuedHUDTexts.push_back(q); } void ClientSystem::drawHUD(int w, int h) { if (g3d_windowhit(true, false)) return; // Showing sauer GUI - do not show HUD float wFactor = float(h)/max(w,h); float hFactor = float(w)/max(w,h); // Rects glPushMatrix(); glScalef(w, h, 1); for (unsigned int i = 0; i < queuedHUDRects.size(); i++) { queuedHUDRect& q = queuedHUDRects[i]; if (q.x2 < 0) { float x1 = q.x1, y1 = q.y1; q.x1 = x1 - wFactor*fabs(q.x2)/2; q.y1 = y1 - hFactor*fabs(q.y2)/2; q.x2 = x1 + wFactor*fabs(q.x2)/2; q.y2 = y1 + hFactor*fabs(q.y2)/2; } vec rgb(q.color>>16, (q.color>>8)&0xFF, q.color&0xFF); rgb.mul(1.0/256.0); glColor4f(rgb[0], rgb[1], rgb[2], q.alpha); glDisable(GL_TEXTURE_2D); notextureshader->set(); glBegin(GL_TRIANGLE_STRIP); glVertex2f(q.x1, q.y1); glVertex2f(q.x2, q.y1); glVertex2f(q.x1, q.y2); glVertex2f(q.x2, q.y2); glEnd(); glEnable(GL_TEXTURE_2D); defaultshader->set(); } glPopMatrix(); // Images glPushMatrix(); glScalef(w, h, 1); for (unsigned int i = 0; i < queuedHUDImages.size(); i++) { queuedHUDImage& q = queuedHUDImages[i]; glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); float x1 = q.centerX - (wFactor*q.width/2); float y1 = q.centerY - (hFactor*q.height/2); float x2 = q.centerX + (wFactor*q.width/2); float y2 = q.centerY + (hFactor*q.height/2); vec rgb(q.color>>16, (q.color>>8)&0xFF, q.color&0xFF); rgb.mul(1.0/256.0); glColor4f(rgb[0], rgb[1], rgb[2], q.alpha); settexture(q.tex.c_str(), 3); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 0.0f); glVertex2f(x1, y1); glTexCoord2f(1.0f, 0.0f); glVertex2f(x2, y1); glTexCoord2f(0.0f, 1.0f); glVertex2f(x1, y2); glTexCoord2f(1.0f, 1.0f); glVertex2f(x2, y2); glEnd(); } glPopMatrix(); // Texts for (unsigned int i = 0; i < queuedHUDTexts.size(); i++) { queuedHUDText& q = queuedHUDTexts[i]; glPushMatrix(); glScalef(q.scale, q.scale, 1); int b = q.color & 255; q.color = q.color >> 8; int g = q.color & 255; int r = q.color >> 8; draw_text(q.text.c_str(), w*q.x/q.scale - text_width(q.text.c_str())/2, h*q.y/q.scale - FONTH/2, r, g, b); glPopMatrix(); } } void ClientSystem::cleanupHUD() { queuedHUDRects.clear(); queuedHUDImages.clear(); queuedHUDTexts.clear(); } int get_escape() { return SDLK_ESCAPE; } extern void checkinput(); void upload_texture_data(std::string name, int x, int y, int w, int h, long long int pixels) { IntensityTexture::uploadTextureData(name, x, y, w, h, (void*)pixels); } //! Main starting point - initialize Python, set up the embedding, and //! run the main Python script that sets everything in motion int main(int argc, char **argv) { saved_argc = argc; saved_argv = argv; initPython(argc, argv); // Expose client-related functions to Python exposeToPython("main", client_main); exposeToPython("set_transaction_code", setTransactionCode); exposeToPython("connect", ClientSystem::connect); exposeToPython("disconnect", ClientSystem::doDisconnect); exposeToPython("logout", MasterServer::logout); exposeToPython("show_message", show_message); exposeToPython("intercept_key", interceptkey); exposeToPython("get_escape", get_escape); exposeToPython("inject_mouse_position", IntensityGUI::injectMousePosition); exposeToPython("inject_mouse_click", IntensityGUI::injectMouseClick); exposeToPython("inject_key_press", IntensityGUI::injectKeyPress); exposeToPython("flush_input_events", checkinput); exposeToPython("upload_texture_data", upload_texture_data); // Shared exposed stuff stuff with the server module #include "shared_module_members.boost" // Start the main Python script that runs it all EXEC_PYTHON_FILE("../../intensity_client.py"); return 0; } void ClientSystem::finishLoadWorld() { extern bool finish_load_world(); finish_load_world(); _mapCompletelyReceived = true; // We have the original map + static entities (still, scenarioStarted might want more stuff) EditingSystem::madeChanges = false; // Clean the slate ClientSystem::editingAlone = false; // Assume not in this mode mainmenu = 0; // (see prepareForMap) } void ClientSystem::prepareForNewScenario(std::string scenarioCode) { _mapCompletelyReceived = false; // We no longer have a map. This implies scenarioStarted will return false, thus // stopping sending of position updates, as well as rendering mainmenu = 1; // Keep showing GUI meanwhile (in particular, to show the message about a new map on the way // Clear the logic system, as it is no longer valid - were it running, we might try to process messages from // the new map being set up on the server, even though they are irrelevant to the existing engine, set up for // another map with its Classes etc. LogicSystem::clear(); currScenarioCode = scenarioCode; } void ClientSystem::handleConfigSettings() { assert(0); #if 0 // Shaders extern int useshaders, shaderprecision; int n = Utility::Config::getInt(VIDEO_SECTION, "shaders", 2); useshaders = n ? 1 : 0; shaderprecision = min(max(n - 1, 0), 3); // Fullscreen extern int fullscreen; fullscreen = Utility::Config::getInt(VIDEO_SECTION, "fullscreen", 0); extern int scr_w, scr_h; scr_w = Utility::Config::getInt(VIDEO_SECTION, "screen_width", 1024); scr_h = Utility::Config::getInt(VIDEO_SECTION, "screen_height", 768); // Shadows std::string shadows = Utility::Config::getString(VIDEO_SECTION, "shadows", "medium"); extern int dynshadow, shadowmap, shadowmapsize, blurshadowmap; if (shadows == "none") { dynshadow = 0; shadowmap = 0; } else if (shadows == "low") { dynshadow = 60; shadowmap = 1; shadowmapsize = 8; blurshadowmap = 1; } else if (shadows == "medium") { dynshadow = 60; shadowmap = 1; shadowmapsize = 9; blurshadowmap = 1; } else if (shadows == "high") { dynshadow = 60; shadowmap = 1; shadowmapsize = 10; blurshadowmap = 2; } else if (shadows == "ultra") { dynshadow = 60; shadowmap = 1; shadowmapsize = 11; blurshadowmap = 2; } else { printf("Invalid value for Video::shadows; valid values are among: none, low, medium, high, ultra\r\n"); } #endif } bool ClientSystem::isAdmin() { if (!loggedIn) return false; if (!playerLogicEntity.get()) return false; if ( !playerLogicEntity.get()->scriptEntity->hasProperty("_canEdit") ) return false; return playerLogicEntity.get()->scriptEntity->getPropertyBool("_canEdit"); } // cubescript stuff void connect_to_instance(char *instance_id) { REFLECT_PYTHON( login_to_instance ); std::string instanceId = instance_id; login_to_instance(instanceId); } COMMAND(connect_to_instance, "s"); void connect_to_lobby() { REFLECT_PYTHON_ALTNAME( connect_to_lobby, ctl ); ctl(); } COMMAND(connect_to_lobby, ""); void connect_to_selected_instance() { REFLECT_PYTHON_ALTNAME( connect_to_selected_instance, ctji ); ctji(); } COMMAND(connect_to_selected_instance, ""); // Get instance data and create a GUI for it void show_instances() { REFLECT_PYTHON( get_possible_instances ); boost::python::object instances = get_possible_instances(); REFLECT_PYTHON( None ); if (instances == None) { setsvar("error_message", "Could not get the list of instances"); showgui("error"); return; } std::string command = "newgui instances [\n" " guitext \"Pick an instance to enter:\"\n" " guibar\n"; int numInstances = boost::python::extract<int>(instances.attr("__len__")()); for (int i = 0; i < numInstances; i++) { boost::python::object instance = instances[i]; std::string instance_id = boost::python::extract<std::string>(instance.attr("__getitem__")("instance_id")); std::string event_name = boost::python::extract<std::string>(instance.attr("__getitem__")("event_name")); assert( Utility::validateAlphaNumeric(instance_id) ); assert( Utility::validateAlphaNumeric(event_name, " (),.;") ); // XXX: Allow more than alphanumeric+spaces: ()s, .s, etc. command += " guibutton \"" + event_name + "\" \"connect_to_instance " + instance_id + "\"\n"; } command += "]\n"; command += "showgui instances\n"; Logging::log(Logging::DEBUG, "Instances GUI: %s\r\n", command.c_str()); execute(command.c_str()); } COMMAND(show_instances, ""); //! Tries to compile a script, and prints errors if any bool checkCompile(std::string filename) { std::string script = Utility::readFile(filename); std::string errors = ScriptEngineManager::compileScript(script); if (errors != "") { IntensityGUI::showMessage("Compilation failed", errors); return false; } else { return true; } } //! The asset ID of the last saved map. This is useful if we want to reload it (if it //! crashed the server, for example SVARP(last_uploaded_map_asset, ""); //! The user picks 'upload map' in the GUI. //! First we save the map. Then we call Python, which packages the map //! and uploads it to the correct asset server, then notify the instance we //! are connected to that the map has been updated, which then gets and runs //! that new map. That process causes it to tell all clients of a new map that //! they should get, which makes them get the new version. Among those clients is //! this one, the uploader, which we do not treat differently in that respect. void do_upload() { renderprogress(0.1, "compiling scripts..."); // Make sure the script compiles ok TODO: All scripts, not just the main one REFLECT_PYTHON( get_map_script_filename ); std::string filename = boost::python::extract<std::string>( get_map_script_filename() ); if (!checkCompile(filename)) return; // Save ogz renderprogress(0.3, "generating map..."); save_world(game::getclientmap()); // load_world: ogzname, mname, cname: packages/base/spiral/map.ogz,base/spiral/map,(null) // save_world ogzname, mname, cname: packages//packages.ogz,/packages // Save entities (and backup) renderprogress(0.4, "exporting entities..."); REFLECT_PYTHON( export_entities ); export_entities("entities.json"); // Do the upload renderprogress(0.5, "uploading map..."); REFLECT_PYTHON( upload_map ); upload_map(); // Remember asset REFLECT_PYTHON( get_curr_map_asset_id ); std::string assetId = boost::python::extract<std::string>( get_curr_map_asset_id() ); setsvar("last_uploaded_map_asset", assetId.c_str()); } COMMAND(do_upload, ""); //! Upload the last map once more. This does NOT save the world - it can be called without //! even having a world loaded (e.g., from the main menu, right after startup). It simply //! packages the files in the map directory and uploads them. This is useful for making //! fixes to map scripts that crash the server, but can also be used after manually //! replacing the .ogz file, etc. void repeat_upload() { std::string lastUploadedMapAsset = last_uploaded_map_asset; // Acquire the asset info, so we know its file locations, asset server, etc. renderprogress(0.2, "getting map asset info..."); REFLECT_PYTHON( AssetManager ); boost::python::object assetInfo = AssetManager.attr("get_info")( lastUploadedMapAsset ); // Set the map asset ID to the last one uploaded REFLECT_PYTHON( set_curr_map_asset_id ); set_curr_map_asset_id( lastUploadedMapAsset ); REFLECT_PYTHON( World ); World.attr("asset_info") = assetInfo; // // Make sure the script compiles ok TODO: All scripts, not just the main one // renderprogress(0.5, "compiling scripts..."); // REFLECT_PYTHON( get_map_script_filename ); // std::string filename = boost::python::extract<std::string>( get_map_script_filename() ); // if (!checkCompile(filename)) XXX - need engine for this! // return; // Do the upload renderprogress(0.7, "compiling scripts..."); REFLECT_PYTHON( upload_map ); upload_map(); conoutf("Upload complete."); } COMMAND(repeat_upload, ""); // Restart server/map void restart_map() { MessageSystem::send_RestartMap(); } COMMAND(restart_map, "");
[ "alon@sanctity.(none)", "[email protected]" ]
[ [ [ 1, 119 ], [ 123, 235 ], [ 237, 240 ], [ 242, 248 ], [ 250, 259 ], [ 262, 268 ], [ 270, 274 ], [ 276, 282 ], [ 285, 333 ], [ 336, 338 ], [ 340, 342 ], [ 344, 363 ], [ 368, 368 ], [ 370, 372 ], [ 374, 731 ] ], [ [ 120, 122 ], [ 236, 236 ], [ 241, 241 ], [ 249, 249 ], [ 260, 261 ], [ 269, 269 ], [ 275, 275 ], [ 283, 284 ], [ 334, 335 ], [ 339, 339 ], [ 343, 343 ], [ 364, 367 ], [ 369, 369 ], [ 373, 373 ] ] ]
b0afef88f2b77285367cc599f675afd7f943a037
478570cde911b8e8e39046de62d3b5966b850384
/apicompatanamdw/bcdrivers/os/ossrv/stdlibs/apps/libc/testcapsocket/src/tsocketserver.cpp
b4567d3fdd4362e7ccc94056d990f87a518b610a
[]
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
8,946
cpp
/* * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "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: * */ /* * ============================================================================== * Name : tsocketserver.cpp * Part of : testsocket * * Description : ?Description * */ #include <c32comm.h> #if defined (__WINS__) #define PDD_NAME _L("ECDRV") #else #define PDD_NAME _L("EUART1") #define PDD2_NAME _L("EUART2") #define PDD3_NAME _L("EUART3") #define PDD4_NAME _L("EUART4") #endif #define LDD_NAME _L("ECOMM") /** * @file * * Pipe test server implementation */ #include "tsocketserver.h" #include "tsocket.h" //_LIT(KServerName, "tsocketcap"); CSocketTestServer* CSocketTestServer::NewL() { CSocketTestServer *server = new(ELeave) CSocketTestServer(); CleanupStack::PushL(server); //server->ConstructL(KServerName); RProcess handle = RProcess(); TParsePtrC serverName(handle.FileName()); server->StartL(serverName.Name()); CleanupStack::Pop(server); return server; } static void InitCommsL() { TInt ret = User::LoadPhysicalDevice(PDD_NAME); User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); #ifndef __WINS__ ret = User::LoadPhysicalDevice(PDD2_NAME); ret = User::LoadPhysicalDevice(PDD3_NAME); ret = User::LoadPhysicalDevice(PDD4_NAME); #endif ret = User::LoadLogicalDevice(LDD_NAME); User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); ret = StartC32(); User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); } LOCAL_C void MainL() { // Leave the hooks in for platform security #if (defined __DATA_CAGING__) RProcess().DataCaging(RProcess::EDataCagingOn); RProcess().SecureApi(RProcess::ESecureApiOn); #endif //InitCommsL(); CActiveScheduler* sched=NULL; sched=new(ELeave) CActiveScheduler; CActiveScheduler::Install(sched); CSocketTestServer* server = NULL; // Create the CTestServer derived server TRAPD(err, server = CSocketTestServer::NewL()); if(!err) { // Sync with the client and enter the active scheduler RProcess::Rendezvous(KErrNone); sched->Start(); } delete server; delete sched; } /** * Server entry point * @return Standard Epoc error code on exit */ TInt main() { __UHEAP_MARK; CTrapCleanup* cleanup = CTrapCleanup::New(); if(cleanup == NULL) { return KErrNoMemory; } TRAP_IGNORE(MainL()); delete cleanup; __UHEAP_MARKEND; return KErrNone; } CTestStep* CSocketTestServer::CreateTestStep(const TDesC& aStepName) { CTestStep* testStep = NULL; // This server creates just one step but create as many as you want // They are created "just in time" when the worker thread is created // install steps if(aStepName == KExampleL) { testStep = new CTestSocket(aStepName); } if(aStepName == KUDP) { testStep = new CTestSocket(aStepName); } if(aStepName == KTCP) { testStep = new CTestSocket(aStepName); } if(aStepName == KGetSocketName) { testStep = new CTestSocket(aStepName); } if(aStepName == KGetSocketNameUsingFileDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KGetSocketNameUsingInvalidSocketDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KGetSocketNameInvalidLength) { testStep = new CTestSocket(aStepName); } if(aStepName == KGetSocketNameInvalidSocketBuffer) { testStep = new CTestSocket(aStepName); } if(aStepName == KGetPeerSocketName) { testStep = new CTestSocket(aStepName); } if(aStepName == KGetPeerSocketNameUsingFileDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KGetPeerSocketNameUsingInvalidSocketDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KGetPeerSocketNameforUnconnectedSocket) { testStep = new CTestSocket(aStepName); } if(aStepName == KGetPeerSocketNameInvalidLengthSockAddr) { testStep = new CTestSocket(aStepName); } if(aStepName == KBindTest) { testStep = new CTestSocket(aStepName); } if(aStepName == KMultipleBindOnSameSocket) { testStep = new CTestSocket(aStepName); } if(aStepName == KBindInvalidAddress) { testStep = new CTestSocket(aStepName); } if(aStepName == KBindUsingInvalidSocketDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KBindUsingFileDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KShutdownTest) { testStep = new CTestSocket(aStepName); } if(aStepName == KShutDownTestWithInvalidShutdownOption) { testStep = new CTestSocket(aStepName); } if(aStepName == KShutdownUsingFileDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KShutdownUsingInvalidSocketDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KShutdownDisconnectedSocket) { testStep = new CTestSocket(aStepName); } if(aStepName == KSocketTest) { testStep = new CTestSocket(aStepName); } if(aStepName == KListenTest) { testStep = new CTestSocket(aStepName); } if(aStepName == KListenUsingFileDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KListenUsingInvalidSocketDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KAcceptTest) { testStep = new CTestSocket(aStepName); } if(aStepName == KUDPAccept) { testStep = new CTestSocket(aStepName); } if(aStepName == KAcceptUsingFileDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KAcceptUsingInvalidSocketDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KConnectTestFailCases) { testStep = new CTestSocket(aStepName); } if(aStepName == KConnectUsingFileDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KConnectUsingInvalidSocketDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KRecvTestFailCases) { testStep = new CTestSocket(aStepName); } if(aStepName == KRecvUsingInvalidSocketDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KRecvUsingFileDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KSendTestFailCases) { testStep = new CTestSocket(aStepName); } if(aStepName == KSendUsingFileDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KSendUsingInvalidSocketDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KSocketOptions) { testStep = new CTestSocket(aStepName); } if(aStepName == KGetSockOptFailCases) { testStep = new CTestSocket(aStepName); } if(aStepName == KSetSockOptFailCases) { testStep = new CTestSocket(aStepName); } if(aStepName == KSendToTestFailCases) { testStep = new CTestSocket(aStepName); } if(aStepName == KSendToUsingFileDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KSendToUsingInvalidSocketDescriptor) { testStep = new CTestSocket(aStepName); } if(aStepName == KRecvFromTestFailCases) { testStep = new CTestSocket(aStepName); } if(aStepName == KSockAtMark) { testStep = new CTestSocket(aStepName); } if(aStepName == KBindResvPort) { testStep = new CTestSocket(aStepName); } if(aStepName == KBindResvPortFailCases) { testStep = new CTestSocket(aStepName); } if(aStepName == KHErrNoLocation) { testStep = new CTestSocket(aStepName); } if(aStepName == KSendMsgRecvMsg) { testStep = new CTestSocket(aStepName); } if(aStepName == KTestRecv) { testStep = new CTestSocket(aStepName); } if(aStepName == KTestReadStream) { testStep = new CTestSocket(aStepName); } if(aStepName == KTestReadDatagram) { testStep = new CTestSocket(aStepName); } if(aStepName == KBindFailCases) { testStep = new CTestSocket(aStepName); } if(aStepName == KAcceptFailCases) { testStep = new CTestSocket(aStepName); } if(aStepName == KListenUdp) { testStep = new CTestSocket(aStepName); } if(aStepName == KGetHostName) { testStep = new CTestSocket(aStepName); } if(aStepName == KGetHostNameNull) { testStep = new CTestSocket(aStepName); } if(aStepName == KGetHostNameZero) { testStep = new CTestSocket(aStepName); } return testStep; }
[ "none@none" ]
[ [ [ 1, 381 ] ] ]
b4c1b98b2b235d38f53f9ec9a3303344485f19e8
4aadb120c23f44519fbd5254e56fc91c0eb3772c
/Source/EduNetGames/ModZoning/NetPedestrian.cpp
52dd29113ff2c104c115f700c659bd38fdc8c0fb
[]
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
15,243
cpp
//----------------------------------------------------------------------------- // 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 "NetPedestrian.h" #include "NetPedestrianPlugin.h" #include "OpenSteerUT/ZonePlugin.h" using namespace OpenSteer; namespace { ObstacleGroup gObstacles; } #pragma warning(push) #pragma warning(disable: 4355) // warning C4355: 'this' : used in base member initializer list //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // constructor NetPedestrian::NetPedestrian(): path(NULL) { // size of bounding sphere, for obstacle avoidance, etc. setRadius (0.5); // width = 0.7, add 0.3 margin, take half // reset Pedestrian state reset (); // for debugging const char* pszClassName = this->getClassName(); #ifdef ET_DEBUG static TNetPedestrian kTestPedestrian; OpenSteer::EntityClassId classId = kTestPedestrian.getClassId(); #endif } #pragma warning(pop) //----------------------------------------------------------------------------- NetPedestrian::~NetPedestrian() { } //----------------------------------------------------------------------------- AbstractVehicle* NetPedestrian::cloneVehicle( void ) const { AbstractVehicle* pkVehicle = ET_NEW NetPedestrian(); return pkVehicle; } //----------------------------------------------------------------------------- // reset all instance state void NetPedestrian::reset (void) { float currRadius = this->radius(); // reset the vehicle // but keep the radius SimpleVehicle::reset (); this->setRadius( currRadius ); // max speed and max steering force (maneuverability) // setMaxSpeed (2.0); setMaxForce (8.0); setMaxSpeed (4.0f * currRadius); // setMaxForce (16.0f * currRadius); // initially stopped setSpeed (0); // // size of bounding sphere, for obstacle avoidance, etc. // setRadius (0.5); // width = 0.7, add 0.3 margin, take half // set the path for this Pedestrian to follow // path = getTestPath (); if( path != NULL ) { // set initial position // (random point on path + random horizontal offset) const float d = path->length() * frandom01(); const float r = path->radius(); const osVector3 randomOffset = randomVectorOnUnitRadiusXZDisk () * r; setPosition( path->mapPathDistanceToPoint (d) + randomOffset ); } // randomize 2D heading randomizeHeadingOnXZPlane (); // pick a random direction for path following (upstream or downstream) pathDirection = (frandom01() > 0.5) ? -1 : +1; // trail parameters: 3 seconds with 60 points along the trail setTrailParameters (3, 60); // notify proximity database that our position has changed if( NULL != this->m_pkProximityToken ) { m_pkProximityToken->updateForNewPosition(position()); } // notify the update states this->m_kSteeringForceUpdate.setVehicle( this ); this->m_kEulerUpdate.setVehicle( this ); } //----------------------------------------------------------------------------- // per frame simulation update void NetPedestrian::update (const float currentTime, const float elapsedTime) { BaseClass::update( currentTime, elapsedTime ); // reverse direction when we reach an endpoint NetPedestrianPlugin* netPedestrianPlugin = dynamic_cast<NetPedestrianPlugin*>(this->getParentEntity()); if( netPedestrianPlugin->m_bUseDirectedPathFollowing ) { const Color darkRed (0.7f, 0, 0); float const pathRadius = path->radius(); if (osVector3::distance (position(), path->getStartPoint()) < pathRadius ) { pathDirection = +1; annotationXZCircle (NULL, pathRadius, path->getStartPoint(), darkRed, 20); } if (osVector3::distance (position(), path->getEndPoint()) < pathRadius ) { pathDirection = -1; annotationXZCircle (NULL, pathRadius, path->getEndPoint(), darkRed, 20); } } } //----------------------------------------------------------------------------- // compute combined steering force: move forward, avoid obstacles // or neighbors if needed, otherwise follow the path and wander osVector3 NetPedestrian::determineCombinedSteering (const float elapsedTime) { // note: to enable a better view on a remote vehicle we just // skip computing a steering force for these guys if( this->isRemoteObject() ) { return osVector3::zero; } // move forward osVector3 steeringForce = forward(); // probability that a lower priority behavior will be given a // chance to "drive" even if a higher priority behavior might // otherwise be triggered. // const float leakThrough = 0.1f; // no random behaviour for network samples const float leakThrough = -1.0f; // determine if obstacle avoidance is required osVector3 obstacleAvoidance; if (leakThrough < frandom01()) { const float oTime = 6; // minTimeToCollision = 6 seconds // ------------------------------------ xxxcwr11-1-04 fixing steerToAvoid // just for testing // obstacleAvoidance = steerToAvoidObstacles (oTime, gObstacles); // obstacleAvoidance = steerToAvoidObstacle (oTime, gObstacle1); // obstacleAvoidance = steerToAvoidObstacle (oTime, gObstacle3); obstacleAvoidance = steerToAvoidObstacles (oTime, gObstacles); // ------------------------------------ xxxcwr11-1-04 fixing steerToAvoid } // if obstacle avoidance is needed, do it if (obstacleAvoidance != osVector3::zero) { steeringForce += obstacleAvoidance; } else { NetPedestrianPlugin* netPedestrianPlugin = dynamic_cast<NetPedestrianPlugin*>(this->getParentEntity()); // otherwise consider avoiding collisions with others osVector3 collisionAvoidance; const float caLeadTime = 3; // find all neighbors within maxRadius using proximity database // (radius is largest distance between vehicles traveling head-on // where a collision is possible within caLeadTime seconds.) const float maxRadius = caLeadTime * maxSpeed() * 2; m_kNeighbors.clear(); m_pkProximityToken->findNeighbors (position(), maxRadius, m_kNeighbors); if (leakThrough < frandom01()) collisionAvoidance = steerToAvoidNeighbors (caLeadTime, m_kNeighbors) * 10; // if collision avoidance is needed, do it if (collisionAvoidance != osVector3::zero) { steeringForce += collisionAvoidance; } else { // add in wander component (according to user switch) if (netPedestrianPlugin->m_bWanderSwitch) steeringForce += steerForWander (elapsedTime); // do (interactively) selected type of path following const float pfLeadTime = 3; const osVector3 pathFollow = (netPedestrianPlugin->m_bUseDirectedPathFollowing ? steerToFollowPath (pathDirection, pfLeadTime, *path) : steerToStayOnPath (pfLeadTime, *path)); // add in to steeringForce steeringForce += pathFollow * 0.5; } } // return steering constrained to global XZ "ground" plane return steeringForce.setYtoZero(); } //----------------------------------------------------------------------------- // draw this pedestrian into scene void NetPedestrian::draw( OpenSteer::AbstractRenderer* pRenderer, const float currentTime, const float elapsedTime ) { BaseClass::draw( pRenderer, currentTime, elapsedTime ); Color kColor; Vec3 kPosition = this->position(); bool bGotParentColor = false; AbstractPlugin* parentPlugin = dynamic_cast<AbstractPlugin*>(this->getParentEntity()); ZonePlugin* zonePlugin = NULL; if( NULL != parentPlugin ) { zonePlugin = dynamic_cast<ZonePlugin*>(parentPlugin->getParentPlugin()); bGotParentColor = parentPlugin->queryVehicleColor( *this, kColor ) ; if( true == bGotParentColor ) { } else { if( true == this->isRemoteObject() ) { kColor = gGreen; Vec3 kTempPosition = kPosition; kTempPosition.y += 0.05f; this->setPosition( kTempPosition ); } else { kColor = gRed; } kColor.setA( 0.5f ); } } pRenderer->drawBasic2dCircularVehicle (*this, kColor); this->setPosition( kPosition ); kColor.setA( 1.0f ); OpenSteer::EAnnotationMode eMode = this->getAnnotationMode(); this->setAnnotationMode( OpenSteer::EAnnotationMode_local ); this->drawTrail( pRenderer, kColor, gWhite ); this->setAnnotationMode( eMode ); if( NULL != zonePlugin ) { // check for zone memberships // textual annotation std::ostringstream annote; annote << std::setprecision (2) << std::setiosflags (std::ios::fixed); annote << "["; for( size_t i = 0; i < 4; ++i ) { if( true == this->getIsZoneMember(i) ) { annote << i; } else { annote << " "; } if( i < 3 ) { annote << "-"; } } annote << "]"; pRenderer->draw2dTextAt3dLocation (annote, this->position(), gWhite, pRenderer->drawGetWindowWidth(), pRenderer->drawGetWindowHeight()); } } //----------------------------------------------------------------------------- // called when steerToFollowPath decides steering is required void NetPedestrian::annotatePathFollowing (const osVector3& future, const osVector3& onPath, const osVector3& target, const float outside) { const Color yellow (1, 1, 0); const Color lightOrange (1.0f, 0.5f, 0.0f); const Color darkOrange (0.6f, 0.3f, 0.0f); const Color yellowOrange (1.0f, 0.75f, 0.0f); // draw line from our position to our predicted future position annotationLine (NULL, position(), future, yellow); // draw line from our position to our steering target on the path annotationLine (NULL, position(), target, yellowOrange); // draw a two-toned line between the future test point and its // projection onto the path, the change from dark to light color // indicates the boundary of the tube. const osVector3 boundaryOffset = (onPath - future).normalized() * outside; const osVector3 onPathBoundary = future + boundaryOffset; annotationLine (NULL, onPath, onPathBoundary, darkOrange); annotationLine (NULL, onPathBoundary, future, lightOrange); } //----------------------------------------------------------------------------- // called when steerToAvoidCloseNeighbors decides steering is required // (parameter names commented out to prevent compiler warning from "-W") void NetPedestrian::annotateAvoidCloseNeighbor (const AbstractVehicle& other, const float /*additionalDistance*/) { //// draw the word "Ouch!" above colliding vehicles //const float headOn = forward().dot(other.forward()) < 0; //const Color green (0.4f, 0.8f, 0.1f); //const Color red (1, 0.1f, 0); //const Color color = headOn ? red : green; //const char* string = headOn ? "OUCH!" : "pardon me"; //const osVector3 location = position() + osVector3 (0, 0.5f, 0); //if (OpenSteer::annotationIsOn()) // draw2dTextAt3dLocation (string, location, color, drawGetWindowWidth(), drawGetWindowHeight()); } //----------------------------------------------------------------------------- // (parameter names commented out to prevent compiler warning from "-W") void NetPedestrian::annotateAvoidNeighbor (const AbstractVehicle& threat, const float /*steer*/, const osVector3& ourFuture, const osVector3& threatFuture) { const Color green (0.15f, 0.6f, 0.0f); annotationLine( NULL, position(), ourFuture, green ); annotationLine( NULL, threat.position(), threatFuture, green ); annotationLine( NULL, ourFuture, threatFuture, gRed ); annotationXZCircle( NULL, radius(), ourFuture, green, 12 ); annotationXZCircle( NULL, radius(), threatFuture, green, 12 ); } //----------------------------------------------------------------------------- // xxx perhaps this should be a call to a general purpose annotation for // xxx "local xxx axis aligned box in XZ plane" -- same code in in // xxx CaptureTheFlag.cpp void NetPedestrian::annotateAvoidObstacle( const float minDistanceToCollision ) { const osVector3 boxSide = side() * radius(); const osVector3 boxFront = forward() * minDistanceToCollision; const osVector3 FR = position() + boxFront - boxSide; const osVector3 FL = position() + boxFront + boxSide; const osVector3 BR = position() - boxSide; const osVector3 BL = position() + boxSide; const Color white( 1,1,1 ); annotationLine( NULL, FR, FL, white ); annotationLine( NULL, FL, BL, white ); annotationLine( NULL, BL, BR, white ); annotationLine( NULL, BR, FR, white ); } //----------------------------------------------------------------------------- int NetPedestrian::serialize( RakNet::SerializeParameters *serializeParameters ) const { int serializeOption = BaseClass::serialize( serializeParameters ); return serializeOption; } //----------------------------------------------------------------------------- void NetPedestrian::deserialize( RakNet::DeserializeParameters *deserializeParameters ) { BaseClass::deserialize( deserializeParameters ); } //----------------------------------------------------------------------------- void NetPedestrian::serializeConstruction( RakNet::BitStream *constructionBitstream ) { BaseClass::serializeConstruction( constructionBitstream ); } //----------------------------------------------------------------------------- bool NetPedestrian::deserializeConstruction( RakNet::BitStream *constructionBitstream ) { bool bConstruct = BaseClass::deserializeConstruction( constructionBitstream ); return bConstruct; }
[ "janfietz@localhost" ]
[ [ [ 1, 420 ] ] ]
9d497dd12920d124ca6f10f9655656969a5abf1e
9a48be80edc7692df4918c0222a1640545384dbb
/Libraries/Boost1.40/libs/intrusive/test/slist_test.cpp
c03e402948423df4f4ca6fe46a014b0fbfd37486
[ "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
26,582
cpp
///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. // (C) Copyright Ion Gaztanaga 2006-2008. // // 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/libs/intrusive for documentation. // ///////////////////////////////////////////////////////////////////////////// #include <boost/intrusive/detail/config_begin.hpp> #include <boost/intrusive/slist.hpp> #include <boost/intrusive/detail/pointer_to_other.hpp> #include "itestvalue.hpp" #include "smart_ptr.hpp" #include "common_functors.hpp" #include <vector> #include <boost/detail/lightweight_test.hpp> #include "test_macros.hpp" #include "test_container.hpp" using namespace boost::intrusive; struct my_tag; template<class VoidPointer> struct hooks { typedef slist_base_hook<void_pointer<VoidPointer> > base_hook_type; typedef slist_base_hook< link_mode<auto_unlink> , void_pointer<VoidPointer>, tag<my_tag> > auto_base_hook_type; typedef slist_member_hook<void_pointer<VoidPointer>, tag<my_tag> > member_hook_type; typedef slist_member_hook< link_mode<auto_unlink> , void_pointer<VoidPointer> > auto_member_hook_type; }; template<class ValueTraits, bool Linear, bool CacheLast> struct test_slist { typedef typename ValueTraits::value_type value_type; static void test_all(std::vector<value_type>& values); static void test_front(std::vector<value_type>& values); static void test_back(std::vector<value_type>& values, detail::bool_<true>); static void test_back(std::vector<value_type>& values, detail::bool_<false>); static void test_sort(std::vector<value_type>& values); static void test_merge(std::vector<value_type>& values); static void test_remove_unique(std::vector<value_type>& values); static void test_insert(std::vector<value_type>& values); static void test_shift(std::vector<value_type>& values); static void test_swap(std::vector<value_type>& values); static void test_slow_insert(std::vector<value_type>& values); static void test_clone(std::vector<value_type>& values); static void test_container_from_end(std::vector<value_type> &, detail::bool_<true>){} static void test_container_from_end(std::vector<value_type> &values, detail::bool_<false>); }; template<class ValueTraits, bool Linear, bool CacheLast> void test_slist<ValueTraits, Linear, CacheLast> ::test_all (std::vector<typename ValueTraits::value_type>& values) { typedef typename ValueTraits::value_type value_type; typedef slist < value_type , value_traits<ValueTraits> , size_type<std::size_t> , constant_time_size<value_type::constant_time_size> , linear<Linear> , cache_last<CacheLast> > list_type; { list_type list(values.begin(), values.end()); test::test_container(list); list.clear(); list.insert(list.end(), values.begin(), values.end()); test::test_sequence_container(list, values); } test_front(values); test_back(values, detail::bool_<CacheLast>()); test_sort(values); test_merge (values); test_remove_unique(values); test_insert(values); test_shift(values); test_slow_insert (values); test_swap(values); test_clone(values); test_container_from_end(values, detail::bool_<Linear>()); } //test: push_front, pop_front, front, size, empty: template<class ValueTraits, bool Linear, bool CacheLast> void test_slist<ValueTraits, Linear, CacheLast> ::test_front(std::vector<typename ValueTraits::value_type>& values) { typedef typename ValueTraits::value_type value_type; typedef slist < value_type , value_traits<ValueTraits> , size_type<std::size_t> , constant_time_size<value_type::constant_time_size> , linear<Linear> , cache_last<CacheLast> > list_type; list_type testlist; BOOST_TEST (testlist.empty()); testlist.push_front (values[0]); BOOST_TEST (testlist.size() == 1); BOOST_TEST (&testlist.front() == &values[0]); testlist.push_front (values[1]); BOOST_TEST (testlist.size() == 2); BOOST_TEST (&testlist.front() == &values[1]); testlist.pop_front(); BOOST_TEST (testlist.size() == 1); BOOST_TEST (&testlist.front() == &values[0]); testlist.pop_front(); BOOST_TEST (testlist.empty()); } //test: push_front, pop_front, front, size, empty: template<class ValueTraits, bool Linear, bool CacheLast> void test_slist<ValueTraits, Linear, CacheLast> ::test_back(std::vector<typename ValueTraits::value_type>& values, detail::bool_<true>) { typedef typename ValueTraits::value_type value_type; typedef slist < value_type , value_traits<ValueTraits> , size_type<std::size_t> , constant_time_size<value_type::constant_time_size> , linear<Linear> , cache_last<CacheLast> > list_type; list_type testlist; BOOST_TEST (testlist.empty()); testlist.push_back (values[0]); BOOST_TEST (testlist.size() == 1); BOOST_TEST (&testlist.front() == &values[0]); BOOST_TEST (&testlist.back() == &values[0]); testlist.push_back(values[1]); BOOST_TEST(*testlist.previous(testlist.end()) == values[1]); BOOST_TEST (&testlist.front() == &values[0]); BOOST_TEST (&testlist.back() == &values[1]); } //test: push_front, pop_front, front, size, empty: template<class ValueTraits, bool Linear, bool CacheLast> void test_slist<ValueTraits, Linear, CacheLast> ::test_back(std::vector<typename ValueTraits::value_type>&, detail::bool_<false>) {} //test: merge due to error in merge implementation: template<class ValueTraits, bool Linear, bool CacheLast> void test_slist<ValueTraits, Linear, CacheLast> ::test_merge (std::vector<typename ValueTraits::value_type>& values) { typedef typename ValueTraits::value_type value_type; typedef slist < value_type , value_traits<ValueTraits> , size_type<std::size_t> , constant_time_size<value_type::constant_time_size> , linear<Linear> , cache_last<CacheLast> > list_type; list_type testlist1, testlist2; testlist1.push_front (values[0]); testlist2.push_front (values[4]); testlist2.push_front (values[3]); testlist2.push_front (values[2]); testlist1.merge (testlist2); int init_values [] = { 1, 3, 4, 5 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } //test: merge due to error in merge implementation: template<class ValueTraits, bool Linear, bool CacheLast> void test_slist<ValueTraits, Linear, CacheLast> ::test_remove_unique (std::vector<typename ValueTraits::value_type>& values) { typedef typename ValueTraits::value_type value_type; typedef slist < value_type , value_traits<ValueTraits> , size_type<std::size_t> , constant_time_size<value_type::constant_time_size> , linear<Linear> , cache_last<CacheLast> > list_type; { list_type list(values.begin(), values.end()); list.remove_if(is_even()); int init_values [] = { 1, 3, 5 }; TEST_INTRUSIVE_SEQUENCE( init_values, list.begin() ); } { std::vector<typename ValueTraits::value_type> values2(values); list_type list(values.begin(), values.end()); list.insert_after(list.before_begin(), values2.begin(), values2.end()); list.sort(); int init_values [] = { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 }; TEST_INTRUSIVE_SEQUENCE( init_values, list.begin() ); list.unique(); int init_values2 [] = { 1, 2, 3, 4, 5 }; TEST_INTRUSIVE_SEQUENCE( init_values2, list.begin() ); } } //test: constructor, iterator, sort, reverse: template<class ValueTraits, bool Linear, bool CacheLast> void test_slist<ValueTraits, Linear, CacheLast> ::test_sort(std::vector<typename ValueTraits::value_type>& values) { typedef typename ValueTraits::value_type value_type; typedef slist < value_type , value_traits<ValueTraits> , size_type<std::size_t> , constant_time_size<value_type::constant_time_size> , linear<Linear> , cache_last<CacheLast> > list_type; list_type testlist (values.begin(), values.end()); { int init_values [] = { 1, 2, 3, 4, 5 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist.begin() ); } testlist.sort (even_odd()); { int init_values [] = { 2, 4, 1, 3, 5 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist.begin() ); } testlist.reverse(); { int init_values [] = { 5, 3, 1, 4, 2 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist.begin() ); } } //test: assign, insert_after, const_iterator, erase_after, s_iterator_to, previous: template<class ValueTraits, bool Linear, bool CacheLast> void test_slist<ValueTraits, Linear, CacheLast> ::test_insert(std::vector<typename ValueTraits::value_type>& values) { typedef typename ValueTraits::value_type value_type; typedef slist < value_type , value_traits<ValueTraits> , size_type<std::size_t> , constant_time_size<value_type::constant_time_size> , linear<Linear> , cache_last<CacheLast> > list_type; list_type testlist; testlist.assign (&values[0] + 2, &values[0] + 5); const list_type& const_testlist = testlist; { int init_values [] = { 3, 4, 5 }; TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); } typename list_type::iterator i = ++testlist.begin(); BOOST_TEST (i->value_ == 4); testlist.insert_after (i, values[0]); { int init_values [] = { 3, 4, 1, 5 }; TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); } i = testlist.iterator_to (values[4]); BOOST_TEST (&*i == &values[4]); i = list_type::s_iterator_to (values[4]); BOOST_TEST (&*i == &values[4]); i = testlist.previous (i); BOOST_TEST (&*i == &values[0]); testlist.erase_after (i); BOOST_TEST (&*i == &values[0]); { int init_values [] = { 3, 4, 1 }; TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); } } //test: insert, const_iterator, erase, siterator_to: template<class ValueTraits, bool Linear, bool CacheLast> void test_slist<ValueTraits, Linear, CacheLast> ::test_slow_insert (std::vector<typename ValueTraits::value_type>& values) { typedef typename ValueTraits::value_type value_type; typedef slist < value_type , value_traits<ValueTraits> , size_type<std::size_t> , constant_time_size<value_type::constant_time_size> , linear<Linear> , cache_last<CacheLast> > list_type; list_type testlist; testlist.push_front (values[4]); testlist.insert (testlist.begin(), &values[0] + 2, &values[0] + 4); const list_type& const_testlist = testlist; { int init_values [] = { 3, 4, 5 }; TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); } typename list_type::iterator i = ++testlist.begin(); BOOST_TEST (i->value_ == 4); testlist.insert (i, values[0]); { int init_values [] = { 3, 1, 4, 5 }; TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); } i = testlist.iterator_to (values[4]); BOOST_TEST (&*i == &values[4]); i = list_type::s_iterator_to (values[4]); BOOST_TEST (&*i == &values[4]); i = testlist.erase (i); BOOST_TEST (i == testlist.end()); { int init_values [] = { 3, 1, 4 }; TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); } testlist.erase (++testlist.begin(), testlist.end()); BOOST_TEST (testlist.size() == 1); BOOST_TEST (testlist.front().value_ == 3); } template<class ValueTraits, bool Linear, bool CacheLast> void test_slist<ValueTraits, Linear, CacheLast> ::test_shift(std::vector<typename ValueTraits::value_type>& values) { typedef typename ValueTraits::value_type value_type; typedef slist < value_type , value_traits<ValueTraits> , size_type<std::size_t> , constant_time_size<value_type::constant_time_size> , linear<Linear> , cache_last<CacheLast> > list_type; list_type testlist; const int num_values = (int)values.size(); std::vector<int> expected_values(num_values); //Shift forward all possible positions 3 times for(int s = 1; s <= num_values; ++s){ expected_values.resize(s); for(int i = 0; i < s*3; ++i){ testlist.insert_after(testlist.before_begin(), &values[0], &values[0] + s); testlist.shift_forward(i); for(int j = 0; j < s; ++j){ expected_values[(j + s - i%s) % s] = (j + 1); } TEST_INTRUSIVE_SEQUENCE_EXPECTED(expected_values, testlist.begin()) testlist.clear(); } //Shift backwards all possible positions for(int i = 0; i < s*3; ++i){ testlist.insert_after(testlist.before_begin(), &values[0], &values[0] + s); testlist.shift_backwards(i); for(int j = 0; j < s; ++j){ expected_values[(j + i) % s] = (j + 1); } TEST_INTRUSIVE_SEQUENCE_EXPECTED(expected_values, testlist.begin()) testlist.clear(); } } } //test: insert_after (seq-version), swap, splice_after: template<class ValueTraits, bool Linear, bool CacheLast> void test_slist<ValueTraits, Linear, CacheLast> ::test_swap(std::vector<typename ValueTraits::value_type>& values) { typedef typename ValueTraits::value_type value_type; typedef slist < value_type , value_traits<ValueTraits> , size_type<std::size_t> , constant_time_size<value_type::constant_time_size> , linear<Linear> , cache_last<CacheLast> > list_type; { list_type testlist1 (&values[0], &values[0] + 2); list_type testlist2; testlist2.insert_after (testlist2.before_begin(), &values[0] + 2, &values[0] + 5); testlist1.swap(testlist2); { int init_values [] = { 3, 4, 5 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } { int init_values [] = { 1, 2 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); } testlist2.splice_after (testlist2.begin(), testlist1); { int init_values [] = { 1, 3, 4, 5, 2 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); } BOOST_TEST (testlist1.empty()); testlist1.splice_after (testlist1.before_begin(), testlist2, ++testlist2.begin()); { int init_values [] = { 4 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } { int init_values [] = { 1, 3, 5, 2 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); } testlist1.splice_after (testlist1.begin(), testlist2, testlist2.before_begin(), ++++testlist2.begin()); { int init_values [] = { 4, 1, 3, 5 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } { int init_values [] = { 2 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); } } { //Now test swap when testlist2 is empty list_type testlist1 (&values[0], &values[0] + 2); list_type testlist2; testlist1.swap(testlist2); BOOST_TEST (testlist1.empty()); { int init_values [] = { 1, 2 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); } } { //Now test swap when testlist1 is empty list_type testlist2 (&values[0], &values[0] + 2); list_type testlist1; testlist1.swap(testlist2); BOOST_TEST (testlist2.empty()); { int init_values [] = { 1, 2 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } } { //Now test when both are empty list_type testlist1, testlist2; testlist2.swap(testlist1); BOOST_TEST (testlist1.empty() && testlist2.empty()); } if(!list_type::linear) { list_type testlist1 (&values[0], &values[0] + 2); list_type testlist2 (&values[0] + 3, &values[0] + 5); values[0].swap_nodes(values[2]); { int init_values [] = { 3, 2 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } values[2].swap_nodes(values[4]); { int init_values [] = { 5, 2 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } { int init_values [] = { 4, 3 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); } } if(!list_type::linear) { list_type testlist1 (&values[0], &values[1]); { int init_values [] = { 1 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } values[1].swap_nodes(values[2]); { int init_values [] = { 1 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } values[0].swap_nodes(values[2]); { int init_values [] = { 3 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } values[0].swap_nodes(values[2]); { int init_values [] = { 1 }; TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } } } template<class ValueTraits, bool Linear, bool CacheLast> void test_slist<ValueTraits, Linear, CacheLast> ::test_clone(std::vector<typename ValueTraits::value_type>& values) { typedef typename ValueTraits::value_type value_type; typedef slist < value_type , value_traits<ValueTraits> , size_type<std::size_t> , constant_time_size<value_type::constant_time_size> , linear<Linear> , cache_last<CacheLast> > list_type; list_type testlist1 (&values[0], &values[0] + values.size()); list_type testlist2; testlist2.clone_from(testlist1, test::new_cloner<value_type>(), test::delete_disposer<value_type>()); BOOST_TEST (testlist2 == testlist1); testlist2.clear_and_dispose(test::delete_disposer<value_type>()); BOOST_TEST (testlist2.empty()); } template<class ValueTraits, bool Linear, bool CacheLast> void test_slist<ValueTraits, Linear, CacheLast> ::test_container_from_end(std::vector<typename ValueTraits::value_type>& values ,detail::bool_<false>) { typedef typename ValueTraits::value_type value_type; typedef slist < value_type , value_traits<ValueTraits> , size_type<std::size_t> , constant_time_size<value_type::constant_time_size> , linear<Linear> , cache_last<CacheLast> > list_type; list_type testlist1 (&values[0], &values[0] + values.size()); BOOST_TEST (testlist1 == list_type::container_from_end_iterator(testlist1.end())); BOOST_TEST (testlist1 == list_type::container_from_end_iterator(testlist1.cend())); } template<class VoidPointer, bool constant_time_size> class test_main_template { public: int operator()() { typedef testvalue<hooks<VoidPointer> , constant_time_size> value_type; std::vector<value_type> data (5); for (int i = 0; i < 5; ++i) data[i].value_ = i + 1; test_slist < typename detail::get_base_value_traits < value_type , typename hooks<VoidPointer>::base_hook_type >::type , false , false >::test_all(data); test_slist < typename detail::get_member_value_traits < value_type , member_hook< value_type , typename hooks<VoidPointer>::member_hook_type , &value_type::node_ > >::type , false , false >::test_all(data); //Now linear slists test_slist < typename detail::get_base_value_traits < value_type , typename hooks<VoidPointer>::base_hook_type >::type , true , false >::test_all(data); test_slist < typename detail::get_member_value_traits < value_type , member_hook< value_type , typename hooks<VoidPointer>::member_hook_type , &value_type::node_ > >::type , true , false >::test_all(data); //Now the same but caching the last node test_slist < typename detail::get_base_value_traits < value_type , typename hooks<VoidPointer>::base_hook_type >::type , false , true >::test_all(data); test_slist < typename detail::get_member_value_traits < value_type , member_hook< value_type , typename hooks<VoidPointer>::member_hook_type , &value_type::node_ > >::type , false , true >::test_all(data); //Now linear slists test_slist < typename detail::get_base_value_traits < value_type , typename hooks<VoidPointer>::base_hook_type >::type , true , true >::test_all(data); test_slist < typename detail::get_member_value_traits < value_type , member_hook< value_type , typename hooks<VoidPointer>::member_hook_type , &value_type::node_ > >::type , true , true >::test_all(data); return 0; } }; template<class VoidPointer> class test_main_template<VoidPointer, false> { public: int operator()() { typedef testvalue<hooks<VoidPointer> , false> value_type; std::vector<value_type> data (5); for (int i = 0; i < 5; ++i) data[i].value_ = i + 1; test_slist < typename detail::get_base_value_traits < value_type , typename hooks<VoidPointer>::base_hook_type >::type , false , false >::test_all(data); test_slist < typename detail::get_member_value_traits < value_type , member_hook< value_type , typename hooks<VoidPointer>::member_hook_type , &value_type::node_ > >::type , false , false >::test_all(data); test_slist < typename detail::get_base_value_traits < value_type , typename hooks<VoidPointer>::auto_base_hook_type >::type , false , false >::test_all(data); test_slist < typename detail::get_member_value_traits < value_type , member_hook< value_type , typename hooks<VoidPointer>::auto_member_hook_type , &value_type::auto_node_ > >::type , false , false >::test_all(data); test_slist < typename detail::get_base_value_traits < value_type , typename hooks<VoidPointer>::base_hook_type >::type , true , false >::test_all(data); test_slist < typename detail::get_member_value_traits < value_type , member_hook< value_type , typename hooks<VoidPointer>::member_hook_type , &value_type::node_ > >::type , true , false >::test_all(data); //Now cache last test_slist < typename detail::get_base_value_traits < value_type , typename hooks<VoidPointer>::base_hook_type >::type , false , true >::test_all(data); test_slist < typename detail::get_member_value_traits < value_type , member_hook< value_type , typename hooks<VoidPointer>::member_hook_type , &value_type::node_ > >::type , false , true >::test_all(data); test_slist < typename detail::get_base_value_traits < value_type , typename hooks<VoidPointer>::base_hook_type >::type , true , true >::test_all(data); test_slist < typename detail::get_member_value_traits < value_type , member_hook< value_type , typename hooks<VoidPointer>::member_hook_type , &value_type::node_ > >::type , true , true >::test_all(data); return 0; } }; int main(int, char* []) { test_main_template<void*, false>()(); test_main_template<smart_ptr<void>, false>()(); test_main_template<void*, true>()(); test_main_template<smart_ptr<void>, true>()(); return boost::report_errors(); } #include <boost/intrusive/detail/config_end.hpp>
[ "metrix@Blended.(none)" ]
[ [ [ 1, 732 ] ] ]
3e4a4696f22855a8e27a28bdd4f54fd6d35aac99
9ad9345e116ead00be7b3bd147a0f43144a2e402
/Integration_WAH_&_Extraction/SMDataExtraction/SEEDMinerGUIApplication/FlexHandler.h
3a524498df4e5e76a565b65fb4f579becd4cf64a
[]
no_license
asankaf/scalable-data-mining-framework
e46999670a2317ee8d7814a4bd21f62d8f9f5c8f
811fddd97f52a203fdacd14c5753c3923d3a6498
refs/heads/master
2020-04-02T08:14:39.589079
2010-07-18T16:44:56
2010-07-18T16:44:56
33,870,353
0
0
null
null
null
null
UTF-8
C++
false
false
1,676
h
#if !defined(AFX_MFLEXHANDLER_H__B4F42467_6EB2_41C3_8D52_B6BC1D47199E__INCLUDED_) #define AFX_MFLEXHANDLER_H__B4F42467_6EB2_41C3_8D52_B6BC1D47199E__INCLUDED_ #if _MSC_VER > 1000 #pragma once #pragma warning(disable : 4786) #include <shlobj.h> #include <shlwapi.h> #include <objbase.h> #include <sstream> #include <windows.h> #include "Logger.h" #include "FlexBridge.h" #include "ASObject.h" #include "BridgeException.h" #include "BridgeManager.h" #include "FlexCallQueue.h" #include "FlashIDManager.h" #include "BridgeManager.h" #include "FlexCtrl.h" #endif // _MSC_VER > 1000 // MFlexHandler.h : header file // ///////////////////////////////////////////////////////////////////////////// // MFlexHandler window class CFlexHandler : public CWnd { // Construction public: CFlexHandler(); // Attributes public: // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(MFlexHandler) //}}AFX_VIRTUAL // Implementation public: virtual ~CFlexHandler(); afx_msg LRESULT OnFlexCallback(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnFlexCallbackRet(WPARAM wParam, LPARAM lParam); // Generated message map functions protected: //{{AFX_MSG(MFlexHandler) // NOTE - the ClassWizard will add and remove member functions here. //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_MFLEXHANDLER_H__B4F42467_6EB2_41C3_8D52_B6BC1D47199E__INCLUDED_)
[ "jaadds@c7f6ba40-6498-11de-987a-95e5a5a5d5f1" ]
[ [ [ 1, 63 ] ] ]
6376cea1d62d6a92223d110da516106dabdf5719
9c62af23e0a1faea5aaa8dd328ba1d82688823a5
/rl/tags/v0-1/engine/common/src/Logger.cpp
9bdb8f54e7c8b1afe75f41b31b4c1f66ce8cf53c
[ "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
ISO-8859-1
C++
false
false
2,488
cpp
#include "Logger.h" #include <OgreLogManager.h> using Ogre::LogManager; using Ogre::Singleton; template<> rl::Logger* Singleton<rl::Logger>::ms_Singleton = 0; const char* rl::Logger::RULES = "Rules"; const char* rl::Logger::CORE = "Core"; const char* rl::Logger::DIALOG = "Dialog"; const char* rl::Logger::UI = "Ui"; const char* rl::Logger::SOUND = "Sound"; const char* rl::Logger::MAIN = "Main"; const char* rl::Logger::SCRIPT = "Script"; namespace rl { Logger& Logger::getSingleton(void) { return Singleton<Logger>::getSingleton(); } Logger* Logger::getSingletonPtr(void) { return Singleton<Logger>::getSingletonPtr(); } Logger::Logger(const Ogre::String& logPath, const Ogre::String& ogreLogPath) { if (LogManager::getSingletonPtr() == 0) { new LogManager(); } //Log für Ogre LogManager::getSingleton().setDefaultLog(LogManager::getSingleton().createLog(ogreLogPath)); //Log für RL mLog = LogManager::getSingleton().createLog(logPath); } Logger::~Logger() { } void Logger::log(const Ogre::String& component, const Ogre::LogMessageLevel level, const Ogre::String& message, const Ogre::String& ident) { if (ident.length() == 0) log(level, "[" + component + "] " + message); else log(level, "[" + component + "] (" + ident + ") " + message); } void Logger::log(const Ogre::String& component, const Ogre::LogMessageLevel level, const CeGuiString& message, const Ogre::String& ident) { if (ident.length() == 0) log(level, "[" + component + "] " + message.c_str()); else log(level, "[" + component + "] (" + ident + ") " + message.c_str()); } void Logger::log(const Ogre::String& component, const Ogre::LogMessageLevel level, const char* message, const Ogre::String& ident) { if (ident.length() == 0) log(level, "[" + component + "] " + message); else log(level, "[" + component + "] (" + ident + ") " + message); } void Logger::log(const Ogre::LogMessageLevel level, const Ogre::String& msg ) { mLog->logMessage(msg, level); } void Logger::setLogDetail(const Ogre::LoggingLevel level) { mLogLevel = level; mLog->setLogDetail(level); } const CEGUI::LoggingLevel Logger::getCeGuiLogDetail() { if (mLogLevel == Ogre::LL_LOW) return CEGUI::Errors; else if (mLogLevel == Ogre::LL_NORMAL) return CEGUI::Standard; else if (mLogLevel == Ogre::LL_BOREME) return CEGUI::Insane; return CEGUI::Errors; } }
[ "blakharaz@4c79e8ff-cfd4-0310-af45-a38c79f83013" ]
[ [ [ 1, 100 ] ] ]
2f30ad4c3cad18ee4a0aa7078b4f3e768010acb4
854ee643a4e4d0b7a202fce237ee76b6930315ec
/arcemu_svn/src/sun/src/InstanceScripts/Instance_Arcatraz.cpp
249f04c0e9a06d789c976fc093ee343d3cd76d13
[]
no_license
miklasiak/projekt
df37fa82cf2d4a91c2073f41609bec8b2f23cf66
064402da950555bf88609e98b7256d4dc0af248a
refs/heads/master
2021-01-01T19:29:49.778109
2008-11-10T17:14:14
2008-11-10T17:14:14
34,016,391
2
0
null
null
null
null
UTF-8
C++
false
false
119,751
cpp
/* * Moon++ Scripts for Ascent MMORPG Server * Copyright (C) 2005-2007 Ascent Team <http://www.ascentemu.com/> * Copyright (C) 2007-2008 Moon++ Team <http://www.moonplusplus.info/> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "StdAfx.h" #include "Setup.h" #include "Base.h" /************************************************************************/ /* Instance_Arcatraz.cpp Script */ /************************************************************************/ // Arcatraz DefenderAI #define CN_ARCATRAZ_DEFENDER 20857 #define ARCATRAZ_DEFENDER_PROTEAN_SUBDUAL 36288 #define ARCATRAZ_DEFENDER_FLAMING_WEAPON 36601 #define ARCATRAZ_DEFENDER_IMMOLATE 36638 class ArcatrazDefenderAI : public MoonScriptCreatureAI { MOONSCRIPT_FACTORY_FUNCTION(ArcatrazDefenderAI, MoonScriptCreatureAI); ArcatrazDefenderAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature) { AddSpell(ARCATRAZ_DEFENDER_PROTEAN_SUBDUAL, Target_Current, 5, 0, 0, 0, 5); AddSpell(ARCATRAZ_DEFENDER_FLAMING_WEAPON, Target_Current, 15, 0, 0, 0, 5); AddSpell(ARCATRAZ_DEFENDER_IMMOLATE, Target_Current, 8, 0, 0, 0, 30); } }; // Arcatraz SentinelAI #define CN_ARCATRAZ_SENTINEL 20869 #define ARCATRAZ_SENTINEL_ENERGY_DISCHARGE 36716 //36717 #define ARCATRAZ_SENTINEL_EXPLODE 36719 // DBC: 36722, 36719 //Permanent Feign Death (Root) 31261 ? class ArcatrazSentinelAI : public MoonScriptCreatureAI { MOONSCRIPT_FACTORY_FUNCTION(ArcatrazSentinelAI, MoonScriptCreatureAI); ArcatrazSentinelAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature) { AddSpell(ARCATRAZ_SENTINEL_ENERGY_DISCHARGE, Target_Self, 8, 0, 0); mExplode = AddSpell(ARCATRAZ_SENTINEL_EXPLODE, Target_Self, 0, 0, 0); } void OnCombatStart(Unit* pTarget) { mExplode->mEnabled = true; ParentClass::OnCombatStart(pTarget); } void AIUpdate() { if( mExplode->mEnabled && GetHealthPercent() <= 5 && !IsCasting() ) { CastSpellNowNoScheduling(mExplode); mExplode->mEnabled = false; } ParentClass::AIUpdate(); } SpellDesc* mExplode; }; // Arcatraz WarderAI // SPELL CASTING TO REWRITE (spell ids are correct) #define CN_ARCATRAZ_WARDER 20859 #define ARCANE_SHOT 36609 #define SHOT 15620 #define IMPROVED_WING_CLIP 35963 #define CHARGED_ARCANE_SHOT 36608 //Shoot Arcane Explosion Arrow 36327 ? class ArcatrazWarderAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(ArcatrazWarderAI); SP_AI_Spell spells[4]; bool m_spellcheck[4]; ArcatrazWarderAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 4; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(ARCANE_SHOT); spells[0].targettype = TARGET_ATTACKING; spells[0].instant = true; spells[0].cooldown = -1; spells[0].perctrigger = 0.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(SHOT); spells[1].targettype = TARGET_ATTACKING; spells[1].instant = true; spells[1].cooldown = -1; spells[1].perctrigger = 0.0f; spells[1].attackstoptimer = 1000; spells[2].info = dbcSpell.LookupEntry(IMPROVED_WING_CLIP); spells[2].targettype = TARGET_ATTACKING; spells[2].instant = true; spells[2].cooldown = -1; spells[2].perctrigger = 8.0f; spells[2].attackstoptimer = 1000; spells[3].info = dbcSpell.LookupEntry(CHARGED_ARCANE_SHOT); spells[3].targettype = TARGET_ATTACKING; spells[3].instant = true; spells[3].cooldown = -1; spells[3].perctrigger = 0.0f; spells[3].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnTargetDied(Unit* mTarget) { } void OnCombatStop(Unit *mTarget) { CastTime(); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { CastTime(); RemoveAIUpdateEvent(); } void AIUpdate() { if (_unit->GetAIInterface()->GetNextTarget()) { Unit *target = NULL; target = _unit->GetAIInterface()->GetNextTarget(); if (_unit->GetDistance2dSq(target) >= 100.0f && _unit->GetDistanceSq(target) <= 900.0f) { _unit->GetAIInterface()->m_canMove = false; int RangedSpell; RandomUInt(1000); RangedSpell=rand()%100; if (RangedSpell >= 0 && RangedSpell <= 20) { _unit->CastSpell(target, spells[3].info, spells[3].instant); _unit->setAttackTimer(spells[3].attackstoptimer, false); } if (RangedSpell > 20 && RangedSpell <= 40) { _unit->CastSpell(target, spells[0].info, spells[0].instant); _unit->setAttackTimer(spells[0].attackstoptimer, false); } else { _unit->CastSpell(target, spells[1].info, spells[1].instant); _unit->setAttackTimer(spells[1].attackstoptimer, false); } } else { _unit->GetAIInterface()->m_canMove = true; if (_unit->GetDistance2dSq(target) < 100.0f) { float val = (float)RandomFloat(100.0f); SpellCast(val); } } } } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) // I was too lazy to rewrite it =S { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // Blackwing DrakonaarAI // SIMPLE_TELEPORT should be used when creature is summoned during Skyriss encounter #define CN_BLACKWING_DRAKONAAR 20911 #define BLACKWING_DRAKONAAR_SIMPLE_TELEPORT 12980 #define BLACKWING_DRAKONAAR_BROOD_POWER_BLACK 39033 #define BLACKWING_DRAKONAAR_MORTAL_STRIKE 13737 #define BLACKWING_DRAKONAAR_BLAST_WAVE 39038 class BlackwingDrakonaarAI : public MoonScriptCreatureAI { MOONSCRIPT_FACTORY_FUNCTION(BlackwingDrakonaarAI, MoonScriptCreatureAI); BlackwingDrakonaarAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature) { AddSpell(BLACKWING_DRAKONAAR_BROOD_POWER_BLACK, Target_Self, 7, 0, 0); AddSpell(BLACKWING_DRAKONAAR_MORTAL_STRIKE, Target_Current, 10, 0, 0, 0, 8, true); AddSpell(BLACKWING_DRAKONAAR_BLAST_WAVE, Target_Self, 6, 0, 0); } }; // Blazing TricksterAI #define CN_BLACKWING_TRICKSTER 20905 #define BLACKWING_TRICKSTER_FIREBOLT 36906 #define BLACKWING_TRICKSTER_FIRE_SHIELD 36907 class BlackwingTricksterAI : public MoonScriptCreatureAI { MOONSCRIPT_FACTORY_FUNCTION(BlackwingTricksterAI, MoonScriptCreatureAI); BlackwingTricksterAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature) { AddSpell(BLACKWING_TRICKSTER_FIREBOLT, Target_Current, 10, 1000, 0, 0, 40, true); AddSpell(BLACKWING_TRICKSTER_FIRE_SHIELD, Target_Self, 7, 0, 0); } }; // Death WatcherAI #define CN_DEATH_WATCHER 20867 #define DEATH_WATCHER_TENTACLE_CLEAVE 36664 #define DEATH_WATCHER_DRAIN_LIFE 36655 #define DEATH_WATCHER_DEATH_COUNT 36657 // DBC: 36657, 36660 class DeathWatcherAI : public MoonScriptCreatureAI { MOONSCRIPT_FACTORY_FUNCTION(DeathWatcherAI, MoonScriptCreatureAI); DeathWatcherAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature) { AddSpell(DEATH_WATCHER_TENTACLE_CLEAVE, Target_Current, 10, 0, 0, 0, 8, true); AddSpell(DEATH_WATCHER_DRAIN_LIFE, Target_Current, 8, 0, 0, 0, 20, true); mDeathCount = AddSpell(DEATH_WATCHER_DEATH_COUNT, Target_Self, 0, 0, 0); } void OnCombatStart(Unit* pTarget) { mDeathCount->mEnabled = true; ParentClass::OnCombatStart(pTarget); } void AIUpdate() { if( mDeathCount->mEnabled && GetHealthPercent() <= 50 && !IsCasting() ) { CastSpellNowNoScheduling(mDeathCount); mDeathCount->mEnabled = false; } ParentClass::AIUpdate(); } SpellDesc* mDeathCount; }; // Defender CorpseAI // Seems to be ok, but not sure if I won't mess with this script a bit #define CN_DEFENDER_CORPSE 21303 #define DEFENDER_CORPSE_CORPSE_BURST 36593 #define DEFENDER_CORPSE_BLOODY_EXPLOSION 36599 //#define PERMANENT_FEIGN_DEATH_ROOT 31261 // I don't have much infos and I am not sure about how it should work // I presume this is just corpse which should cast spell when player is close or attk it class DefenderCorpseAI : public MoonScriptCreatureAI { MOONSCRIPT_FACTORY_FUNCTION(DefenderCorpseAI, MoonScriptCreatureAI); DefenderCorpseAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature) { mCorpseBurst = AddSpell(DEFENDER_CORPSE_CORPSE_BURST, Target_Self, 0, 0, 0); mBloodyExplosion = AddSpell(DEFENDER_CORPSE_BLOODY_EXPLOSION, Target_Self, 0, 0, 0); } void OnCombatStart(Unit* pTarget) { CastSpellNowNoScheduling(mCorpseBurst); CastSpellNowNoScheduling(mBloodyExplosion); // Slap me, if this does not work _unit->SetUInt32Value(UNIT_FIELD_HEALTH, 0); _unit->setDeathState(DEAD); // Let's keep it safe tho Despawn(10000, 0); } SpellDesc* mCorpseBurst; SpellDesc* mBloodyExplosion; }; // Protean SpawnAI #define CN_PROTEAN_SPAWN 21395 // it's sth that spawns from Defender Corpse #define PROTEAN_SPAWN_ACIDIC_BITE 36796 //#define BLOODY_EXPLOSION 36588 class ProteanSpawnAI : public MoonScriptCreatureAI { MOONSCRIPT_FACTORY_FUNCTION(ProteanSpawnAI, MoonScriptCreatureAI); ProteanSpawnAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature) { AddSpell(PROTEAN_SPAWN_ACIDIC_BITE, Target_Current, 8, 0, 0, 0, 8, true); } }; // Entropic EyeAI -- TO RECHECK BEFORE REWRITE -- #define CN_ENTROPIC_EYE 20868 #define WAVERING_WILL 36699 // not sure if this is right one (I mean spell, not ID) #define PIERCING_SHADOW 36698 // this "smaller" list must be rechecked =S #define HEX 36700 #define TANTACLE_CLEAVE_EYE 36664 /* #define TANTACLE_CLEAVE_EYE 36664 #define FIREBALL_EYE 36711 #define FROSTBOLT_EYE 36710 #define WITHERED_TOUCH_EYE 36696 #define HEX_EYE 36700 #define PIERCING_SHADOW_EYE 36698 #define CHAOS_BREATH_EYE 36677 // SSS #define POISON_BOLT_EYE 36713 // DBC List :O #define NECROTIC_POISON_EYE 36693 #define SHRINK_EYE 36697 #define SHADOW_BOLT_EYE 36714 #define FEVERED_FATIGUE_EYE 36695 #define WAVERING_WILL_EYE 36699 #define CORROSIVE_POISON_EYE 36694 #define ARCANE_BOLT_EYE 36712 */ class EntropicEyeAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(EntropicEyeAI); SP_AI_Spell spells[4]; bool m_spellcheck[4]; EntropicEyeAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 4; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(WAVERING_WILL); spells[0].targettype = TARGET_VARIOUS; spells[0].instant = true; spells[0].cooldown = -1; spells[0].perctrigger = 5.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(PIERCING_SHADOW); spells[1].targettype = TARGET_VARIOUS; spells[1].instant = true; spells[1].cooldown = -1; spells[1].perctrigger = 5.0f; spells[1].attackstoptimer = 1000; spells[2].info = dbcSpell.LookupEntry(HEX); spells[2].targettype = TARGET_VARIOUS; spells[2].instant = true; spells[2].cooldown = -1; spells[2].perctrigger = 5.0f; spells[2].attackstoptimer = 1000; spells[3].info = dbcSpell.LookupEntry(TANTACLE_CLEAVE_EYE); spells[3].targettype = TARGET_ATTACKING; // changed from VAR. to prevent crashes spells[3].instant = true; spells[3].cooldown = -1; spells[3].perctrigger = 12.0f; spells[3].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); CastTime(); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); CastTime(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); CastTime(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // Eredar DeathbringerAI #define CN_EREDAR_DEATHBRINGER 20880 #define EREDAR_DEATHBRINGER_UNHOLY_AURA 27987 // DBC: 27988, 27987 #define EREDAR_DEATHBRINGER_DIMINISH_SOUL 36789 // DBC: 36789, 36791 (SSS) #define EREDAR_DEATHBRINGER_FORCEFUL_CLEAVE 36787 class EredarDeathbringerAI : public MoonScriptCreatureAI { MOONSCRIPT_FACTORY_FUNCTION(EredarDeathbringerAI, MoonScriptCreatureAI); EredarDeathbringerAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature) { AddSpell(EREDAR_DEATHBRINGER_DIMINISH_SOUL, Target_Current, 7, 0, 0, 0, 8, true); // Correct target type? AddSpell(EREDAR_DEATHBRINGER_FORCEFUL_CLEAVE, Target_Current, 13, 0, 0, 0, 8, true); ApplyAura(EREDAR_DEATHBRINGER_UNHOLY_AURA); } }; // Eredar Soul-EaterAI #define CN_EREDAR_SOUL_EATER 20879 #define SOUL_CHILL 36786 #define SOUL_STEAL1 36778 // this on target, another on self #define SOUL_STEAL2 36782 // DBC: 36782, 36778 class EredarSoulEaterAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(EredarSoulEaterAI); SP_AI_Spell spells[3]; bool m_spellcheck[3]; EredarSoulEaterAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 2; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(SOUL_CHILL); spells[0].targettype = TARGET_VARIOUS; spells[0].instant = true; spells[0].cooldown = -1; spells[0].perctrigger = 10.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(SOUL_STEAL1); spells[1].targettype = TARGET_ATTACKING; spells[1].instant = true; spells[1].cooldown = -1; spells[1].perctrigger = 7.0f; spells[1].attackstoptimer = 1000; spells[2].info = dbcSpell.LookupEntry(SOUL_STEAL2); spells[2].targettype = TARGET_SELF; spells[2].instant = true; spells[2].cooldown = -1; spells[2].perctrigger = 0.0f; spells[2].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); CastTime(); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); CastTime(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); CastTime(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (m_spellcheck[1] == true) _unit->CastSpell(_unit, spells[2].info, spells[2].instant); if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // Ethereum Life-BinderAI #define CN_ETHEREUM_LIFE_BINDER 21702 #define ETHEREUM_LIFE_BINDER_BIND 37480 #define ETHEREUM_LIFE_BINDER_SHADOW_WORD_PAIN 15654 class EthereumLifeBinderAI : public MoonScriptCreatureAI { MOONSCRIPT_FACTORY_FUNCTION(EthereumLifeBinderAI, MoonScriptCreatureAI); EthereumLifeBinderAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature) { AddSpell(ETHEREUM_LIFE_BINDER_BIND, Target_Self, 8, 1500, 0); AddSpell(ETHEREUM_LIFE_BINDER_SHADOW_WORD_PAIN, Target_Current, 7, 0, 0, 0, 30, true); } }; // Ethereum SlayerAI #define CN_ETHEREUM_SLAYER 20896 #define ETHEREUM_SLAYER_IMPARING_POISON 36839 #define ETHEREUM_SLAYER_SLAYER_STRIKE 36838 #define ETHEREUM_SLAYER_EVASION 15087 class EthereumSlayerAI : public MoonScriptCreatureAI { MOONSCRIPT_FACTORY_FUNCTION(EthereumSlayerAI, MoonScriptCreatureAI); EthereumSlayerAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature) { AddSpell(ETHEREUM_SLAYER_IMPARING_POISON, Target_Current, 7, 0, 0, 0, 40, true); AddSpell(ETHEREUM_SLAYER_SLAYER_STRIKE, Target_Current, 12, 0, 0, 0, 8, true); AddSpell(ETHEREUM_SLAYER_EVASION, Target_Self, 6, 0, 0); } }; // Ethereum Wave-CasterAI #define CN_ETHEREUM_WAVE_CASTER 20897 #define ETHEREUM_WAVE_CASTER_POLYMORPH 36840 #define ETHEREUM_WAVE_CASTER_ARCANE_HASTE 32693 #define ETHEREUM_WAVE_CASTER_SONIC_BOMB 36841 // should counter spell so I must code it a bit more // KNOCKBACK ? class EthereumWaveCasterAI : public MoonScriptCreatureAI { MOONSCRIPT_FACTORY_FUNCTION(EthereumWaveCasterAI, MoonScriptCreatureAI); EthereumWaveCasterAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature) { AddSpell(ETHEREUM_WAVE_CASTER_POLYMORPH, Target_RandomPlayer, 7, 1500, 0, 0, 30, true); AddSpell(ETHEREUM_WAVE_CASTER_ARCANE_HASTE, Target_Self, 5, 0, 0); AddSpell(ETHEREUM_WAVE_CASTER_SONIC_BOMB, Target_Current, 11, 0, 0, 0, 45, true); } }; // Gargantuan AbyssalAI #define CN_GARGANTUAN_ABYSSAL 20898 #define GARGANTUAN_ABYSSAL_FIRE_SHIELD 38855 // DBC: 38855, 38893 #define GARGANTUAN_ABYSSAL_METEOR 36837 class GargantuanAbyssalAI : public MoonScriptCreatureAI { MOONSCRIPT_FACTORY_FUNCTION(GargantuanAbyssalAI, MoonScriptCreatureAI); GargantuanAbyssalAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature) { AddSpell(GARGANTUAN_ABYSSAL_FIRE_SHIELD, Target_Self, 7, 0, 0); AddSpell(GARGANTUAN_ABYSSAL_METEOR, Target_RandomPlayerDestination, 8, 3000, 0, 0, 80, true); } }; // Greater Fire ElementalAI // FIX ME: Mark of death #define CN_GREATER_FIRE_ELEMENTAL 15438 #define GREATER_FIRE_ELEMENTAL_FIRE_SHIELD 13376 #define GREATER_FIRE_ELEMENTAL_FIRE_NOVA 12470 #define GREATER_FIRE_ELEMENTAL_FIRE_BLAST 13339 #define GREATER_FIRE_ELEMENTAL_MARK_OF_DEATH 37128 // SSS // should be applied on target class GreaterFireElementalAI : public MoonScriptCreatureAI { MOONSCRIPT_FACTORY_FUNCTION(GreaterFireElementalAI, MoonScriptCreatureAI); GreaterFireElementalAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature) { AddSpell(GREATER_FIRE_ELEMENTAL_FIRE_NOVA, Target_Self, 9, 2000, 0); AddSpell(GREATER_FIRE_ELEMENTAL_FIRE_BLAST, Target_Current, 8, 0, 0, 0, 20, true); AddSpell(GREATER_FIRE_ELEMENTAL_MARK_OF_DEATH, Target_RandomPlayerApplyAura, 5, 0, 0, 0, 80, true); ApplyAura(GREATER_FIRE_ELEMENTAL_FIRE_SHIELD); } }; // IronjawAI -- NEEDS TO BE RECHECKED BEFORE REWRITE -- // Comment says all ---^ #define CN_IRONJAW 18670 // I couldn't force Ironjaw to cast spells with "?" #define FURIOUS_HOWL 24597 // ? #define DASH 23110 #define BITE 27050 #define GROWL 14921 // ? #define FEROCIOUS_INSPIRATION 34456 // ? #define FRENZY_EFFECT 19615 #define KILL_COMMAND 34027 #define BESTIAL_WRATH 24395 // DBC: 24395, 24396, 24397, 26592 (all are diffrent) // ? #define SNARL 32919 #define CHILLING_HOWL 32918 class IronjawAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(IronjawAI); SP_AI_Spell spells[10]; bool m_spellcheck[10]; IronjawAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 10; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(FURIOUS_HOWL); spells[0].targettype = TARGET_VARIOUS; spells[0].instant = true; spells[0].cooldown = -1; spells[0].perctrigger = 3.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(DASH); spells[1].targettype = TARGET_SELF; spells[1].instant = true; spells[1].cooldown = -1; spells[1].perctrigger = 3.0f; spells[1].attackstoptimer = 1000; spells[2].info = dbcSpell.LookupEntry(BITE); spells[2].targettype = TARGET_ATTACKING; spells[2].instant = true; spells[2].cooldown = -1; spells[2].perctrigger = 8.0f; spells[2].attackstoptimer = 1000; spells[3].info = dbcSpell.LookupEntry(GROWL); spells[3].targettype = TARGET_ATTACKING; spells[3].instant = true; spells[3].cooldown = -1; spells[3].perctrigger = 5.0f; spells[3].attackstoptimer = 1000; spells[4].info = dbcSpell.LookupEntry(FEROCIOUS_INSPIRATION); spells[4].targettype = TARGET_SELF; spells[4].instant = true; spells[4].cooldown = -1; spells[4].perctrigger = 3.0f; spells[4].attackstoptimer = 1000; spells[5].info = dbcSpell.LookupEntry(FRENZY_EFFECT); spells[5].targettype = TARGET_SELF; spells[5].instant = true; spells[5].cooldown = -1; spells[5].perctrigger = 4.0f; spells[5].attackstoptimer = 1000; spells[6].info = dbcSpell.LookupEntry(KILL_COMMAND); spells[6].targettype = TARGET_ATTACKING; spells[6].instant = true; spells[6].cooldown = -1; spells[6].perctrigger = 6.0f; spells[6].attackstoptimer = 1000; spells[7].info = dbcSpell.LookupEntry(BESTIAL_WRATH); spells[7].targettype = TARGET_ATTACKING; spells[7].instant = true; spells[7].cooldown = -1; spells[7].perctrigger = 4.0f; spells[7].attackstoptimer = 1000; spells[8].info = dbcSpell.LookupEntry(SNARL); spells[8].targettype = TARGET_ATTACKING; spells[8].instant = true; spells[8].cooldown = -1; spells[8].perctrigger = 8.0f; spells[8].attackstoptimer = 1000; spells[9].info = dbcSpell.LookupEntry(CHILLING_HOWL); spells[9].targettype = TARGET_ATTACKING; spells[9].instant = true; spells[9].cooldown = -1; spells[9].perctrigger = 5.0f; spells[9].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnCombatStop(Unit *mTarget) { CastTime(); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { CastTime(); RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // Millhouse ManastormAI -- SHOULD BE RECHECKED BEFORE REWRITE -- // Probably should be rewritten and is part of Skyriss encounter #define CN_MILLHOUSE_MANASTORM 20977 #define SIMPLE_TELEPORT_MM 12980 #define CONJURE_WATER 36879 // SSS =/ #define ARCANE_INTELLECT 36880 #define ICE_ARMOR 36881 #define DRINK 30024 #define FIREBALL_MM 14034 #define FROSTBOLT_MM 15497 #define FIRE_BLAST_MM 13341 #define CONE_OF_COLD 12611 #define ARCANE_MISSILES 33832 // DBC: 33832, 33833 #define PYROBLAST 33975 //#define CHILLED 7321 effect of ICE_ARMOR 36881 class MillhouseManastormAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(MillhouseManastormAI); SP_AI_Spell spells[11]; bool m_spellcheck[11]; MillhouseManastormAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 11; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(SIMPLE_TELEPORT_MM); spells[0].targettype = TARGET_SELF; spells[0].instant = true; spells[0].cooldown = -1; spells[0].perctrigger = 0.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(CONJURE_WATER); spells[1].targettype = TARGET_SELF; spells[1].instant = false; spells[1].cooldown = -1; spells[1].perctrigger = 0.0f; spells[1].attackstoptimer = 1000; spells[2].info = dbcSpell.LookupEntry(ARCANE_INTELLECT); spells[2].targettype = TARGET_SELF; spells[2].instant = true; spells[2].cooldown = -1; spells[2].perctrigger = 3.0f; spells[2].attackstoptimer = 1000; spells[3].info = dbcSpell.LookupEntry(ICE_ARMOR); spells[3].targettype = TARGET_SELF; spells[3].instant = true; spells[3].cooldown = -1; spells[3].perctrigger = 3.0f; spells[3].attackstoptimer = 1000; spells[4].info = dbcSpell.LookupEntry(DRINK); spells[4].targettype = TARGET_SELF; spells[4].instant = true; spells[4].cooldown = -1; spells[4].perctrigger = 0.0f; spells[4].attackstoptimer = 1000; spells[5].info = dbcSpell.LookupEntry(FIREBALL_MM); spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].cooldown = -1; spells[5].perctrigger = 5.0f; spells[5].attackstoptimer = 1000; spells[6].info = dbcSpell.LookupEntry(FROSTBOLT_MM); spells[6].targettype = TARGET_ATTACKING; spells[6].instant = false; spells[6].cooldown = -1; spells[6].perctrigger = 5.0f; spells[6].attackstoptimer = 1000; spells[7].info = dbcSpell.LookupEntry(FIRE_BLAST_MM); spells[7].targettype = TARGET_ATTACKING; spells[7].instant = true; spells[7].cooldown = -1; spells[7].perctrigger = 5.0f; spells[7].attackstoptimer = 1000; spells[8].info = dbcSpell.LookupEntry(CONE_OF_COLD); spells[8].targettype = TARGET_VARIOUS; spells[8].instant = true; spells[8].cooldown = -1; spells[8].perctrigger = 4.0f; spells[8].attackstoptimer = 1000; spells[9].info = dbcSpell.LookupEntry(ARCANE_MISSILES); spells[9].targettype = TARGET_ATTACKING; spells[9].instant = false; spells[9].cooldown = -1; spells[9].perctrigger = 5.0f; spells[9].attackstoptimer = 1000; spells[10].info = dbcSpell.LookupEntry(PYROBLAST); spells[10].targettype = TARGET_ATTACKING; spells[10].instant = false; spells[10].cooldown = -1; spells[10].perctrigger = 2.0f; spells[10].attackstoptimer = 1000; _unit->CastSpell(_unit, spells[0].info, spells[0].instant); } void OnCombatStart(Unit* mTarget) { CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnCombatStop(Unit *mTarget) {/* CastTime(); if (_unit->GetUInt32Value(UNIT_FIELD_POWER1) < _unit->GetUInt32Value(UNIT_FIELD_BASE_MANA)) { _unit->CastSpell(_unit, spells[1].info, spells[1].instant); _unit->CastSpell(_unit, spells[4].info, spells[4].instant); }*/ _unit->CastSpell(_unit, spells[1].info, spells[1].instant); _unit->CastSpell(_unit, spells[4].info, spells[4].instant); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { CastTime(); RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // Negaton ScreamerAI -- NEEDS TO BE RECHECKED BEFORE REWRITE -- // this one needs some more work for dmg taken dmg type, but I don't have time for it... // Add missing function ------------------------------ look below #define CN_NEGATON_SCREAMER 20875 // I need to add missing about 15 mobs (w00t? More? =() and to this script // OnDamageTaken function with check of spell dmg type and correct spell casts in diff cases #define PSYCHIC_SCREAM 13704 #define DAMAGE_REDUCTION_SHADOW 34338 #define DAMAGE_REDUCTION_FROST 34334 #define DAMAGE_REDUCTION_ARCANE 34331 #define DAMAGE_REDUCTION_FIRE 34333 #define DAMAGE_REDUCTION_HOLY 34336 #define DAMAGE_REDUCTION_NATURE 34335 //#define DAMAGE_REDUCTION_PHYSICAL 34337 #define SHADOW_ENERGY 34399 // Energy SSS-s (I am sure only to spells shadow-frost-arcane-fire) #define FROST_ENERGY 34404 #define ARCANE_ENERGY 34401 #define FIRE_ENERGY 34398 #define HOLY_ENERGY 34403 #define NATURE_ENERGY 34402 //#define PHYSICAL_ENERGY #define SHADOW_BOLT_VOLLEY 36736 #define FROSTBOLT_VOLLEY 36741 #define ARCANE_VOLLEY 36738 #define FIREBALL_VOLLEY 36742 #define HOLY_VOLLEY 36743 #define LIGHTNING_BOLT_VOLLEY 36740 //#define _VOLLEY class NegatonScreamerAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(NegatonScreamerAI); SP_AI_Spell spells[19]; bool m_spellcheck[19]; NegatonScreamerAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 19; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(PSYCHIC_SCREAM); spells[0].targettype = TARGET_VARIOUS; spells[0].instant = true; spells[0].cooldown = -1; spells[0].perctrigger = 5.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(DAMAGE_REDUCTION_SHADOW); spells[1].targettype = TARGET_SELF; spells[1].instant = true; spells[1].cooldown = -1; spells[1].perctrigger = 0.0f; spells[1].attackstoptimer = 1000; spells[2].info = dbcSpell.LookupEntry(DAMAGE_REDUCTION_FROST); spells[2].targettype = TARGET_SELF; spells[2].instant = true; spells[2].cooldown = -1; spells[2].perctrigger = 0.0f; spells[2].attackstoptimer = 1000; spells[3].info = dbcSpell.LookupEntry(DAMAGE_REDUCTION_ARCANE); spells[3].targettype = TARGET_SELF; spells[3].instant = true; spells[3].cooldown = -1; spells[3].perctrigger = 0.0f; spells[3].attackstoptimer = 1000; spells[4].info = dbcSpell.LookupEntry(DAMAGE_REDUCTION_FIRE); spells[4].targettype = TARGET_SELF; spells[4].instant = true; spells[4].cooldown = -1; spells[4].perctrigger = 0.0f; spells[4].attackstoptimer = 1000; spells[5].info = dbcSpell.LookupEntry(DAMAGE_REDUCTION_HOLY); spells[5].targettype = TARGET_SELF; spells[5].instant = true; spells[5].cooldown = -1; spells[5].perctrigger = 0.0f; spells[5].attackstoptimer = 1000; spells[6].info = dbcSpell.LookupEntry(DAMAGE_REDUCTION_NATURE); spells[6].targettype = TARGET_SELF; spells[6].instant = true; spells[6].cooldown = -1; spells[6].perctrigger = 0.0f; spells[6].attackstoptimer = 1000; spells[7].info = dbcSpell.LookupEntry(SHADOW_ENERGY); spells[7].targettype = TARGET_SELF; spells[7].instant = true; spells[7].cooldown = -1; spells[7].perctrigger = 0.0f; spells[7].attackstoptimer = 1000; spells[8].info = dbcSpell.LookupEntry(FROST_ENERGY); spells[8].targettype = TARGET_SELF; spells[8].instant = true; spells[8].cooldown = -1; spells[8].perctrigger = 0.0f; spells[8].attackstoptimer = 1000; spells[9].info = dbcSpell.LookupEntry(ARCANE_ENERGY); spells[9].targettype = TARGET_SELF; spells[9].instant = true; spells[9].cooldown = -1; spells[9].perctrigger = 0.0f; spells[9].attackstoptimer = 1000; spells[10].info = dbcSpell.LookupEntry(FIRE_ENERGY); spells[10].targettype = TARGET_SELF; spells[10].instant = true; spells[10].cooldown = -1; spells[10].perctrigger = 0.0f; spells[10].attackstoptimer = 1000; spells[11].info = dbcSpell.LookupEntry(HOLY_ENERGY); spells[11].targettype = TARGET_SELF; spells[11].instant = true; spells[11].cooldown = -1; spells[11].perctrigger = 0.0f; spells[11].attackstoptimer = 1000; spells[12].info = dbcSpell.LookupEntry(NATURE_ENERGY); spells[12].targettype = TARGET_SELF; spells[12].instant = true; spells[12].cooldown = -1; spells[12].perctrigger = 0.0f; spells[12].attackstoptimer = 1000; spells[13].info = dbcSpell.LookupEntry(SHADOW_BOLT_VOLLEY); spells[13].targettype = TARGET_VARIOUS; spells[13].instant = false; spells[13].cooldown = -1; spells[13].perctrigger = 0.0f; spells[13].attackstoptimer = 1000; spells[14].info = dbcSpell.LookupEntry(FROSTBOLT_VOLLEY); spells[14].targettype = TARGET_VARIOUS; spells[14].instant = false; spells[14].cooldown = -1; spells[14].perctrigger = 0.0f; spells[14].attackstoptimer = 1000; spells[15].info = dbcSpell.LookupEntry(ARCANE_VOLLEY); spells[15].targettype = TARGET_VARIOUS; spells[15].instant = false; spells[15].cooldown = -1; spells[15].perctrigger = 0.0f; spells[15].attackstoptimer = 1000; spells[16].info = dbcSpell.LookupEntry(FIREBALL_VOLLEY); spells[16].targettype = TARGET_VARIOUS; spells[16].instant = false; spells[16].cooldown = -1; spells[16].perctrigger = 0.0f; spells[16].attackstoptimer = 1000; spells[17].info = dbcSpell.LookupEntry(HOLY_VOLLEY); spells[17].targettype = TARGET_VARIOUS; spells[17].instant = false; spells[17].cooldown = -1; spells[17].perctrigger = 0.0f; spells[17].attackstoptimer = 1000; spells[18].info = dbcSpell.LookupEntry(LIGHTNING_BOLT_VOLLEY); spells[18].targettype = TARGET_VARIOUS; spells[18].instant = false; spells[18].cooldown = -1; spells[18].perctrigger = 0.0f; spells[18].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnCombatStop(Unit *mTarget) { CastTime(); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { CastTime(); RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // Negaton Warp-MasterAI #define CN_NEGATON_WARP_MASTER 20873 #define NEGATON_WARP_MASTER_SUMMON_NEGATION_FIELD 36813 class NegatonWarpMasterAI : public MoonScriptCreatureAI { MOONSCRIPT_FACTORY_FUNCTION(NegatonWarpMasterAI, MoonScriptCreatureAI); NegatonWarpMasterAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature) { AddSpell(NEGATON_WARP_MASTER_SUMMON_NEGATION_FIELD, Target_Self, 10, 20000, 0); } }; // Negaton FieldAI -- HUH? TO RECHECK? -- // Not sure if shouldn't be rewritten. #define CN_NEGATON_FIELD 21414 #define NEGATION_FIELD 36728 // DBC: 36728, 36729; class NegatonFieldAI : public MoonScriptCreatureAI { MOONSCRIPT_FACTORY_FUNCTION(NegatonFieldAI, MoonScriptCreatureAI); NegatonFieldAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature) { ApplyAura(NEGATION_FIELD); } }; // Phase-HunterAI // This unit is part of Skyriss encounter and it's teleport skill should be used during that encounter #define CN_PHASE_HUNTER 20906 #define PHASE_HUNTER_SIMPLE_TELEPORT 12980 #define PHASE_HUNTER_BACK_ATTACK 36909 #define PHASE_HUNTER_WARP 36908 // lack of core support? #define PHASE_HUNTER_PHASE_BURST 36910 class PhaseHunterAI : public MoonScriptCreatureAI { MOONSCRIPT_FACTORY_FUNCTION(PhaseHunterAI, MoonScriptCreatureAI); PhaseHunterAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature) { AddSpell(PHASE_HUNTER_WARP, Target_Self, 5, 0, 0); AddSpell(PHASE_HUNTER_PHASE_BURST, Target_Self, 5, 0, 0); ApplyAura(NEGATION_FIELD); } void AIUpdate() { if (_unit->GetAIInterface()->GetNextTarget() != NULL && _unit->GetCurrentSpell() == NULL) { Unit *pUnit = _unit->GetAIInterface()->GetNextTarget(); if (_unit->isInBack(pUnit) && _unit->GetDistance2dSq(pUnit) <= 64.0f && RandomUInt(2) == 0) { this->CastSpellOnTarget(pUnit, Target_Current, dbcSpell.LookupEntry(PHASE_HUNTER_BACK_ATTACK), true); } } ParentClass::AIUpdate(); } }; // Protean HorrorAI #define CN_PROTEAN_HORROR 20865 #define PROTEAN_HORROR_TOOTHY_BITE 36612 //#define BLOODY_EXPLOSION 36588 class ProteanHorrorAI : public MoonScriptCreatureAI { MOONSCRIPT_FACTORY_FUNCTION(ProteanHorrorAI, MoonScriptCreatureAI); ProteanHorrorAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature) { AddSpell(PROTEAN_HORROR_TOOTHY_BITE, Target_Current, 10, 0, 0, 0, 8, true); } }; // Protean NightmareAI #define CN_PROTEAN_NIGHTMARE 20864 #define PROTEAN_NIGHTMARE_INCUBATION 36622 #define PROTEAN_NIGHTMARE_INFECTIOUS_POISON 36619 #define PROTEAN_NIGHTMARE_GAPIND_MAW 36617 class ProteanNightmareAI : public MoonScriptCreatureAI { MOONSCRIPT_FACTORY_FUNCTION(ProteanNightmareAI, MoonScriptCreatureAI); ProteanNightmareAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature) { AddSpell(PROTEAN_NIGHTMARE_INCUBATION, Target_Current, 6, 0, 0, 0, 8, true); AddSpell(PROTEAN_NIGHTMARE_INFECTIOUS_POISON, Target_Self, 10, 0, 0); AddSpell(PROTEAN_NIGHTMARE_GAPIND_MAW, Target_Self, 6, 600, 0); } }; // Sulfuron Magma-ThrowerAI // Part of Skyriss encounter (so same thing to teleport stuff) #define CN_SULFURON_MAGMA_THROWER 20909 #define SIMPLE_TELEPORT_SMT 12980 #define SHADOW_BOLT_SMT 36986 // DBC: 36987, 36986; #define MAGMA_THROWERS_CURSE 36917 #define RAIN_OF_FIRE 19717 class SulfuronMagmaThrowerAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(SulfuronMagmaThrowerAI); SP_AI_Spell spells[4]; bool m_spellcheck[4]; SulfuronMagmaThrowerAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 4; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(SIMPLE_TELEPORT_SMT); spells[0].targettype = TARGET_SELF; spells[0].instant = true; spells[0].cooldown = -1; spells[0].perctrigger = 0.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(SHADOW_BOLT_SMT); spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].cooldown = -1; spells[1].perctrigger = 12.0f; spells[1].attackstoptimer = 1000; spells[2].info = dbcSpell.LookupEntry(MAGMA_THROWERS_CURSE); spells[2].targettype = TARGET_ATTACKING; spells[2].instant = true; spells[2].cooldown = -1; spells[2].perctrigger = 6.0f; spells[2].attackstoptimer = 1000; spells[3].info = dbcSpell.LookupEntry(RAIN_OF_FIRE); spells[3].targettype = TARGET_DESTINATION; spells[3].instant = true; spells[3].cooldown = -1; spells[3].perctrigger = 9.0f; spells[3].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnCombatStop(Unit *mTarget) { CastTime(); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { CastTime(); RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // Spiteful TemptressAI #define CN_SPITEFUL_TEMPTRESS 20883 #define SHADOW_BOLT_ST 36868 #define DOMINATION_ST 36866 #define SPITEFUL_FURY 36886 #define PRAYER_OF_MENDING 33280 // DBC: 33280, 33110; SSS class SpitefulTemptressAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(SpitefulTemptressAI); SP_AI_Spell spells[4]; bool m_spellcheck[4]; SpitefulTemptressAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 4; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(SHADOW_BOLT_ST); spells[0].targettype = TARGET_DESTINATION; // not sure DESTINATION or ATTACKING spells[0].instant = false; spells[0].cooldown = -1; spells[0].perctrigger = 12.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(DOMINATION_ST); spells[1].targettype = TARGET_ATTACKING; spells[1].instant = true; spells[1].cooldown = -1; spells[1].perctrigger = 5.0f; spells[1].attackstoptimer = 1000; spells[2].info = dbcSpell.LookupEntry(SPITEFUL_FURY); spells[2].targettype = TARGET_ATTACKING; spells[2].instant = true; spells[2].cooldown = -1; spells[2].perctrigger = 7.0f; spells[2].attackstoptimer = 1000; spells[3].info = dbcSpell.LookupEntry(PRAYER_OF_MENDING); spells[3].targettype = TARGET_VARIOUS; spells[3].instant = true; spells[3].cooldown = -1; spells[3].perctrigger = 8.0f; spells[3].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnCombatStop(Unit *mTarget) { CastTime(); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { CastTime(); RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // Soul DevourerAI #define CN_SOUL_DEVOURER 20866 #define SIGHTLESS_EYE 36644 #define LAVA_BREATH 21333 // doesn't have animation? #define FEL_BREATH 36654 #define FRENZY 33958 class SoulDevourerAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(SoulDevourerAI); SP_AI_Spell spells[4]; bool m_spellcheck[4]; SoulDevourerAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 4; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(SIGHTLESS_EYE); spells[0].targettype = TARGET_SELF; spells[0].instant = false; spells[0].cooldown = -1; spells[0].perctrigger = 7.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(LAVA_BREATH); spells[1].targettype = TARGET_VARIOUS; spells[1].instant = true; spells[1].cooldown = -1; spells[1].perctrigger = 12.0f; spells[1].attackstoptimer = 1000; spells[2].info = dbcSpell.LookupEntry(FEL_BREATH); spells[2].targettype = TARGET_VARIOUS; spells[2].instant = true; spells[2].cooldown = -1; spells[2].perctrigger = 8.0f; spells[2].attackstoptimer = 1000; spells[3].info = dbcSpell.LookupEntry(FRENZY); spells[3].targettype = TARGET_SELF; spells[3].instant = true; spells[3].cooldown = -1; spells[3].perctrigger = 8.0f; spells[3].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { _unit->CastSpell(_unit, spells[0].info, spells[0].instant); CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnCombatStop(Unit *mTarget) { CastTime(); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { CastTime(); RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // SolomonAI #define CN_SOLOMON 798 // not sure if this boy should be scripted, but he was in DBC and had spells, so I couldn't // stop myself to not give little boy deadly skills muhahah =) #define SLIME_SPRAY 36486 #define SAW_BLADE 32735 #define CRUSADER_STRIKE 35509 // SE (script effect) class SolomonAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(SolomonAI); SP_AI_Spell spells[3]; bool m_spellcheck[3]; SolomonAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 3; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(SLIME_SPRAY); spells[0].targettype = TARGET_VARIOUS; spells[0].instant = false; spells[0].cooldown = -1; spells[0].perctrigger = 8.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(SAW_BLADE); spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].cooldown = -1; spells[1].perctrigger = 8.0f; spells[1].attackstoptimer = 1000; spells[2].info = dbcSpell.LookupEntry(CRUSADER_STRIKE); spells[2].targettype = TARGET_ATTACKING; spells[2].instant = true; spells[2].cooldown = -1; spells[2].perctrigger = 12.0f; spells[2].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnCombatStop(Unit *mTarget) { CastTime(); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { CastTime(); RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // Skulking WitchAI #define CN_SKULKING_WITCH 20882 // works really cool as assassin :) #define CHASTISE 36863 #define GOUGE 36862 #define LASH_OF_PAIN 36864 #define GREAT_INVISIBILITY 16380 class SkulkingWitchAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(SkulkingWitchAI); SP_AI_Spell spells[4]; bool m_spellcheck[4]; SkulkingWitchAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 4; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(CHASTISE); spells[0].targettype = TARGET_ATTACKING; spells[0].instant = true; spells[0].cooldown = -1; spells[0].perctrigger = 12.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(GOUGE); spells[1].targettype = TARGET_ATTACKING; spells[1].instant = true; spells[1].cooldown = -1; spells[1].perctrigger = 0.0f; spells[1].attackstoptimer = 1000; spells[2].info = dbcSpell.LookupEntry(LASH_OF_PAIN); spells[2].targettype = TARGET_ATTACKING; spells[2].instant = true; spells[2].cooldown = -1; spells[2].perctrigger = 5.0f; spells[2].attackstoptimer = 1000; spells[3].info = dbcSpell.LookupEntry(GREAT_INVISIBILITY); spells[3].targettype = TARGET_SELF; spells[3].instant = true; spells[3].cooldown = -1; spells[3].perctrigger = 0.0f; spells[3].attackstoptimer = 1000; _unit->CastSpell(_unit, spells[3].info, spells[3].instant); FIRST_ATTACK = 1; } void OnCombatStart(Unit* mTarget) { FIRST_ATTACK = 1; CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnTargetDied(Unit* mTarget) { } void OnCombatStop(Unit *mTarget) { CastTime(); FIRST_ATTACK = 1; _unit->CastSpell(_unit, spells[3].info, spells[3].instant); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { FIRST_ATTACK = 1; CastTime(); RemoveAIUpdateEvent(); } void AIUpdate() { if (FIRST_ATTACK && _unit->GetAIInterface()->GetNextTarget()) { FIRST_ATTACK = 0; Unit * target = NULL; target = _unit->GetAIInterface()->GetNextTarget(); _unit->CastSpell(target, spells[1].info, spells[1].instant); } else { float val = (float)RandomFloat(100.0f); SpellCast(val); } } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: uint32 FIRST_ATTACK; int nrspells; }; // Sightless EyeAI #define CN_SIGHTLESS_EYE 21346 #define SIGHTLESS_TOUCH 36646 class SightlessEyeAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(SightlessEyeAI); SP_AI_Spell spells[1]; bool m_spellcheck[1]; SightlessEyeAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 1; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(SIGHTLESS_TOUCH); spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].cooldown = -1; spells[0].perctrigger = 10.0f; spells[0].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnCombatStop(Unit *mTarget) { CastTime(); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { CastTime(); RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // Sargeron HellcallerAI #define CN_SARGERON_HELLCALLER 20902 #define HELL_RAIN 36829 #define CURSE_OF_THE_ELEMENTS 36831 #define INCINERATE 36832 class SargeronHellcallerAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(SargeronHellcallerAI); SP_AI_Spell spells[3]; bool m_spellcheck[3]; SargeronHellcallerAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 3; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(HELL_RAIN); spells[0].targettype = TARGET_DESTINATION; spells[0].instant = true; spells[0].cooldown = -1; spells[0].perctrigger = 8.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(CURSE_OF_THE_ELEMENTS); spells[1].targettype = TARGET_ATTACKING; spells[1].instant = true; spells[1].cooldown = -1; spells[1].perctrigger = 6.0f; spells[1].attackstoptimer = 1000; spells[2].info = dbcSpell.LookupEntry(INCINERATE); spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].cooldown = -1; spells[2].perctrigger = 11.0f; spells[2].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnCombatStop(Unit *mTarget) { CastTime(); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { CastTime(); RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // Unbound DevastatorAI #define CN_UNBOUND_DEVASTATOR 20881 #define DEAFENING_ROAR 36887 #define DEVASTATE 36894 // DBC: 36891, 36894; class UnboundDevastatorAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(UnboundDevastatorAI); SP_AI_Spell spells[2]; bool m_spellcheck[2]; UnboundDevastatorAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 2; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(DEAFENING_ROAR); spells[0].targettype = TARGET_VARIOUS; spells[0].instant = true; spells[0].cooldown = -1; spells[0].perctrigger = 7.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(DEVASTATE); spells[1].targettype = TARGET_ATTACKING; spells[1].instant = true; spells[1].cooldown = -1; spells[1].perctrigger = 10.0f; spells[1].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnCombatStop(Unit *mTarget) { CastTime(); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { CastTime(); RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // Unchained DoombringerAI // TO DO: Look at charge note #define CN_UNCHAINED_DOOMBRINGER 20900 #define AGONIZING_ARMOR 36836 #define WAR_STOMP 36835 #define BERSEKER_CHARGE 36833 // should charge the furthest enemy class UnchainedDoombringerAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(UnchainedDoombringerAI); SP_AI_Spell spells[3]; bool m_spellcheck[3]; UnchainedDoombringerAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 3; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(AGONIZING_ARMOR); spells[0].targettype = TARGET_ATTACKING; spells[0].instant = true; spells[0].cooldown = -1; spells[0].perctrigger = 9.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(WAR_STOMP); spells[1].targettype = TARGET_VARIOUS; spells[1].instant = true; spells[1].cooldown = -1; spells[1].perctrigger = 12.0f; spells[1].attackstoptimer = 1000; spells[2].info = dbcSpell.LookupEntry(BERSEKER_CHARGE); spells[2].targettype = TARGET_ATTACKING; spells[2].instant = true; spells[2].cooldown = -1; spells[2].perctrigger = 6.0f; spells[2].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnCombatStop(Unit *mTarget) { CastTime(); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { CastTime(); RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // Warder CorpseAI #define CN_WARDER_CORPSE 21303 #define CORPSE_BURST_WC 36593 #define BLOODY_EXPLOSION_WC 36599 //#define PERMANENT_FEIGN_DEATH_ROOT_WC 31261 // I don't have much infos and I am not sure about how it should work // I presume this is just corpse which should cast spell when player is close or attk it // so same situation like in Defender Corpse class WarderCorpseAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(WarderCorpseAI); SP_AI_Spell spells[2]; bool m_spellcheck[2]; WarderCorpseAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 2; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(CORPSE_BURST_WC); spells[0].targettype = TARGET_SELF; spells[0].instant = true; spells[0].cooldown = -1; spells[0].perctrigger = 0.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(BLOODY_EXPLOSION_WC); spells[1].targettype = TARGET_SELF; spells[1].instant = true; spells[1].cooldown = -1; spells[1].perctrigger = 0.0f; spells[1].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { _unit->CastSpell(_unit, spells[1].info, spells[1].instant); _unit->CastSpell(_unit, spells[0].info, spells[0].instant); CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnCombatStop(Unit *mTarget) { CastTime(); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { CastTime(); RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // Sargeron ArcherAI // Probably to rewrite #define CN_SARGERON_ARCHER 20901 #define FROST_ARROW 35964 //DBC: 35965, 35964; #define SHOT_SA 22907 #define RAPID_FIRE 36828 #define SCATTER_SHOT 23601 #define HOOKED_NET 36827 #define IMMOLATION_ARROW 35932 // DBC: 35932, 35935 class SargeronArcherAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(SargeronArcherAI); SP_AI_Spell spells[6]; bool m_spellcheck[6]; SargeronArcherAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 6; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(FROST_ARROW); spells[0].targettype = TARGET_ATTACKING; spells[0].instant = true; spells[0].cooldown = -1; spells[0].perctrigger = 0.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(SHOT_SA); spells[1].targettype = TARGET_ATTACKING; spells[1].instant = true; spells[1].cooldown = -1; spells[1].perctrigger = 0.0f; spells[1].attackstoptimer = 1000; spells[2].info = dbcSpell.LookupEntry(RAPID_FIRE); spells[2].targettype = TARGET_SELF; spells[2].instant = true; spells[2].cooldown = -1; spells[2].perctrigger = 0.0f; spells[2].attackstoptimer = 1000; spells[3].info = dbcSpell.LookupEntry(SCATTER_SHOT); spells[3].targettype = TARGET_ATTACKING; spells[3].instant = true; spells[3].cooldown = -1; spells[3].perctrigger = 0.0f; spells[3].attackstoptimer = 1000; spells[4].info = dbcSpell.LookupEntry(HOOKED_NET); spells[4].targettype = TARGET_VARIOUS; spells[4].instant = false; spells[4].cooldown = -1; spells[4].perctrigger = 6.0f; spells[4].attackstoptimer = 1000; spells[5].info = dbcSpell.LookupEntry(IMMOLATION_ARROW); spells[5].targettype = TARGET_ATTACKING; spells[5].instant = false; spells[5].cooldown = -1; spells[5].perctrigger = 0.0f; spells[5].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnCombatStop(Unit *mTarget) { CastTime(); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { CastTime(); RemoveAIUpdateEvent(); } void AIUpdate() { if (_unit->GetAIInterface()->GetNextTarget()) { Unit *target = NULL; target = _unit->GetAIInterface()->GetNextTarget(); if (_unit->GetDistance2dSq(target) >= 100.0f && _unit->GetDistanceSq(target) <= 900.0f) { _unit->GetAIInterface()->m_canMove = false; int RangedSpell; RandomUInt(1000); RangedSpell=rand()%100; if (RangedSpell >= 0 && RangedSpell <= 13) { _unit->CastSpell(target, spells[0].info, spells[0].instant); _unit->setAttackTimer(spells[0].attackstoptimer, false); } if (RangedSpell > 12 && RangedSpell <= 25) { _unit->CastSpell(target, spells[3].info, spells[3].instant); _unit->setAttackTimer(spells[3].attackstoptimer, false); } if (RangedSpell > 25 && RangedSpell <= 38) { _unit->CastSpell(target, spells[5].info, spells[5].instant); _unit->setAttackTimer(spells[5].attackstoptimer, false); } if (RangedSpell > 38 && RangedSpell <= 44) { _unit->CastSpell(target, spells[2].info, spells[2].instant); _unit->setAttackTimer(spells[2].attackstoptimer, false); } if (RangedSpell > 44 && RangedSpell <= 50) { _unit->CastSpell(target, spells[4].info, spells[4].instant); _unit->setAttackTimer(spells[4].attackstoptimer, false); } else { _unit->CastSpell(target, spells[1].info, spells[1].instant); _unit->setAttackTimer(spells[1].attackstoptimer, false); } } else { _unit->GetAIInterface()->m_canMove = true; if (_unit->GetDistance2dSq(target) < 100.0f) { float val = (float)RandomFloat(100.0f); SpellCast(val); } } } } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) // I was too lazy to rewrite it =S { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; /*****************************/ /* */ /* Boss AIs */ /* */ /*****************************/ // Zereketh the UnboundAI #define CN_ZEREKETH 20870 #define CN_VOIDZONEARC 21101 #define SEED_OF_C 36123 //32865, 36123 #define SHADOW_NOVA 36127 // 30533, 39005, 36127 (normal mode), 39005 (heroic mode?) #define SHADOW_NOVA_H 39005 #define CONSUMPTION 30498 #define CONSUMPTION_H 39004 // #define VOID_ZONE 36119 // DBC: 36119; it's not fully functionl without additional core support (for dmg and random place targeting). class ZerekethAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(ZerekethAI); SP_AI_Spell spells[2]; bool m_spellcheck[2]; ZerekethAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 2; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(SEED_OF_C); spells[0].targettype = TARGET_RANDOM_SINGLE; spells[0].instant = false; spells[0].cooldown = 20; spells[0].perctrigger = 6.0f; spells[0].attackstoptimer = 2000; spells[0].mindist2cast = 0.0f; spells[0].maxdist2cast = 100.0f; if(_unit->GetMapMgr()->iInstanceMode != MODE_HEROIC) { spells[1].info = dbcSpell.LookupEntry(SHADOW_NOVA); spells[1].targettype = TARGET_VARIOUS; spells[1].instant = false; spells[1].cooldown = 15; spells[1].perctrigger = 15.0f; spells[1].attackstoptimer = 1500; } else { spells[1].info = dbcSpell.LookupEntry(SHADOW_NOVA_H); spells[1].targettype = TARGET_VARIOUS; spells[1].instant = false; spells[1].cooldown = 15; spells[1].perctrigger = 15.0f; spells[1].attackstoptimer = 1500; } } void OnCombatStart(Unit* mTarget) { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Life energy to... consume."); _unit->PlaySoundToSet(11250); uint32 t = (uint32)time(NULL); VoidTimer = t + RandomUInt(10)+30; SpeechTimer = t + RandomUInt(10)+40; } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { //despawn voids Creature *creature = NULL; for(set<Object*>::iterator itr = _unit->GetInRangeSetBegin(); itr != _unit->GetInRangeSetEnd(); ++itr) { if((*itr)->GetTypeId() == TYPEID_UNIT) { creature = static_cast<Creature*>((*itr)); if(creature && creature->GetCreatureInfo() && creature->GetCreatureInfo()->Id == 21101 && creature->isAlive()) { creature->Despawn(0, 0); //creature->SafeDelete(); } } } _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "The Void... beckons."); _unit->PlaySoundToSet(11255); RemoveAIUpdateEvent(); } void OnTargetDied(Unit* mTarget) { if (_unit->GetHealthPct() > 0) // Hack to prevent double yelling (OnDied and OnTargetDied when creature is dying) { int RandomSpeach; RandomUInt(1000); RandomSpeach=rand()%2; switch (RandomSpeach) { case 0: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "This vessel...is empty."); _unit->PlaySoundToSet(11251); break; case 1: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "No... more... life."); // not sure _unit->PlaySoundToSet(11252); break; } } } void Speech() { switch (RandomUInt(1)) { case 0: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "The shadow... will engulf you."); _unit->PlaySoundToSet(11253); break; case 1: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Darkness... consumes all."); _unit->PlaySoundToSet(11254); break; } SpeechTimer = (uint32)time(NULL) + RandomUInt(10)+40; } void VoidZoneArc() { VoidTimer = (uint32)time(NULL) + RandomUInt(10)+30; CreatureInfo * ci = CreatureNameStorage.LookupEntry(CN_VOIDZONEARC); CreatureProto * cp = CreatureProtoStorage.LookupEntry(CN_VOIDZONEARC); if(!cp || !ci) return; std::vector<Player*> TargetTable; std::set<Player*>::iterator Itr = _unit->GetInRangePlayerSetBegin(); for(; Itr != _unit->GetInRangePlayerSetEnd(); Itr++) { Player* RandomTarget = NULL; RandomTarget = static_cast< Player* >(*Itr); if(RandomTarget && RandomTarget->isAlive() && isHostile(*Itr, _unit)) TargetTable.push_back(RandomTarget); RandomTarget = NULL; } if (!TargetTable.size()) return; size_t RandTarget = rand()%TargetTable.size(); Player * RTarget = TargetTable[RandTarget]; if (!RTarget) return; float vzX = RandomUInt(5) * cos(RandomFloat(6.28f))+RTarget->GetPositionX(); float vzY = RandomUInt(5) * cos(RandomFloat(6.28f))+RTarget->GetPositionY(); float vzZ = RTarget->GetPositionZ(); Creature *VoidZone = _unit->GetMapMgr()->CreateCreature(cp->Id); VoidZone->Load(cp, vzX, vzY, vzZ); VoidZone->SetInstanceID(_unit->GetInstanceID()); VoidZone->SetZoneId(_unit->GetZoneId()); VoidZone->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_2); VoidZone->m_noRespawn = true; if(VoidZone->CanAddToWorld()) { VoidZone->PushToWorld(_unit->GetMapMgr()); } else { VoidZone->SafeDelete(); return; } RTarget = NULL; sEventMgr.AddEvent(VoidZone, &Creature::SafeDelete, EVENT_CREATURE_SAFE_DELETE, 60000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); } void AIUpdate() { uint32 t = (uint32)time(NULL); if(t > SpeechTimer) Speech(); if(t > VoidTimer) VoidZoneArc(); float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if(m_spellcheck[i]) { target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; case TARGET_RANDOM_SINGLE: case TARGET_RANDOM_DESTINATION: CastSpellOnRandomTarget(i, spells[i].mindist2cast, spells[i].maxdist2cast, spells[i].minhp2cast, spells[i].maxhp2cast); break; } m_spellcheck[i] = false; return; } uint32 t = (uint32)time(NULL); if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger) && t > spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); spells[i].casttime = t + spells[i].cooldown; m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } target = NULL; } } void CastSpellOnRandomTarget(uint32 i, float mindist2cast, float maxdist2cast, int minhp2cast, int maxhp2cast) { if (!maxdist2cast) maxdist2cast = 100.0f; if (!maxhp2cast) maxhp2cast = 100; if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { std::vector<Player *> TargetTable; for(set<Player*>::iterator itr = _unit->GetInRangePlayerSetBegin(); itr != _unit->GetInRangePlayerSetEnd(); ++itr) { Player* RandomTarget = NULL; RandomTarget = (Player*)(*itr); if (RandomTarget && RandomTarget->isAlive() && _unit->GetDistance2dSq(RandomTarget) >= mindist2cast*mindist2cast && _unit->GetDistance2dSq(RandomTarget) <= maxdist2cast*maxdist2cast) TargetTable.push_back(RandomTarget); RandomTarget = NULL; } if (!TargetTable.size()) return; size_t RandTarget = rand()%TargetTable.size(); Unit * RTarget = TargetTable[RandTarget]; if (!RTarget) return; switch (spells[i].targettype) { case TARGET_RANDOM_SINGLE: _unit->CastSpell(RTarget, spells[i].info, spells[i].instant); break; case TARGET_RANDOM_DESTINATION: _unit->CastSpellAoF(RTarget->GetPositionX(), RTarget->GetPositionY(), RTarget->GetPositionZ(), spells[i].info, spells[i].instant); break; } RTarget = NULL; TargetTable.clear(); } } void Destroy() { delete this; } protected: uint32 SpeechTimer; uint32 VoidTimer; int nrspells; }; class VoidZoneARC : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(VoidZoneARC); VoidZoneARC(Creature* pCreature) : CreatureAIScript(pCreature) { _unit->Root(); _unit->DisableAI(); SpellEntry *Sp = NULL; if(_unit->GetMapMgr()->iInstanceMode != MODE_HEROIC) Sp = dbcSpell.LookupEntry(CONSUMPTION); else Sp = dbcSpell.LookupEntry(CONSUMPTION_H); sEventMgr.AddEvent(((Unit*)_unit), &Unit::EventCastSpell, ((Unit*)_unit), Sp, EVENT_UNK, (uint32)1000, 0, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); } }; // Dalliah the DoomsayerAI #define CN_DALLIAH_THE_DOOMSAYER 20885 #define GIFT_OF_THE_DOOMSAYER 36173 // DBC: 36173 #define WHIRLWIND 36175 // DBC: 36142, 36175 #define HEAL 36144 #define SHADOW_WAVE 39016 // Heroic mode spell // sounds missing related to Wrath... (look on script below this one) class DalliahTheDoomsayerAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(DalliahTheDoomsayerAI); SP_AI_Spell spells[4]; bool m_spellcheck[4]; DalliahTheDoomsayerAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 4; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(GIFT_OF_THE_DOOMSAYER); spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].cooldown = -1; spells[0].perctrigger = 8.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(WHIRLWIND); spells[1].targettype = TARGET_VARIOUS; spells[1].instant = false; spells[1].cooldown = -1; spells[1].perctrigger = 15.0f; spells[1].attackstoptimer = 1000; spells[2].info = dbcSpell.LookupEntry(HEAL); spells[2].targettype = TARGET_SELF; spells[2].instant = false; spells[2].cooldown = -1; spells[2].perctrigger = 0.0f; spells[2].attackstoptimer = 1000; spells[3].info = dbcSpell.LookupEntry(SHADOW_WAVE); spells[3].targettype = TARGET_ATTACKING; spells[3].instant = false; spells[3].cooldown = -1; spells[3].perctrigger = 8.0f; spells[3].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "It is unwise to anger me."); // verification needed _unit->PlaySoundToSet(11086); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnTargetDied(Unit* mTarget) { if (_unit->GetHealthPct() > 0) { int RandomSpeach; RandomSpeach=rand()%2; switch (RandomSpeach) { case 0: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Completely ineffective! Just like someone else I know!"); // need verif. _unit->PlaySoundToSet(11087); break; case 1: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "You chose the wrong opponent!"); // verification needed _unit->PlaySoundToSet(11088); break; } } } void OnCombatStop(Unit *mTarget) { CastTime(); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { CastTime(); RemoveAIUpdateEvent(); _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Now I'm really... angry..."); // verification needed _unit->PlaySoundToSet(11093); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void HealSound() { int RandomSpeach; RandomSpeach=rand()%20; switch (RandomSpeach) { case 0: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "That is much better."); _unit->PlaySoundToSet(11091); break; case 1: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Ah, just what I needed."); // both need verif. _unit->PlaySoundToSet(11092); break; } } void WhirlwindSound() { int RandomWhirlwind; RandomWhirlwind=rand()%20; switch (RandomWhirlwind) { case 0: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Reap the Whirlwind!"); _unit->PlaySoundToSet(11089); break; case 1: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "I'll cut you to pices!"); // all to verification _unit->PlaySoundToSet(11090); break; } } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { if (m_spellcheck[2] == true) HealSound(); spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (m_spellcheck[1] == true) { WhirlwindSound(); int NextAttack; NextAttack=rand()%100+1; if (NextAttack <= 25 && NextAttack > 0) { m_spellcheck[2] = true; } } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // Wrath-Scryer SoccothratesAI // TO DO: Add moar sounds #define CN_WRATH_SCRYER_SOCCOTHRATES 20886 #define IMMOLATION 35959 // DBC: 36051, 35959 #define FELFIRE_SHOCK 35759 #define FELFIRE_LINE_UP 35770 // ? #define KNOCK_AWAY 20686 // DBC: 36512; but it uses it on himself too so changed to other #define CHARGE 35754 // DBC: 36058, 35754 =( =( // CHARGE_TARGETING 36038 ? // There are more sounds connected with Dalliah and some spells, but I don't know situation in which they are used // so haven't added them. class WrathScryerSoccothratesAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(WrathScryerSoccothratesAI); SP_AI_Spell spells[5]; bool m_spellcheck[5]; WrathScryerSoccothratesAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 5; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(IMMOLATION); spells[0].targettype = TARGET_VARIOUS; spells[0].instant = false; spells[0].cooldown = -1; spells[0].perctrigger = 10.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(FELFIRE_SHOCK); spells[1].targettype = TARGET_ATTACKING; spells[1].instant = true; spells[1].cooldown = -1; spells[1].perctrigger = 8.0f; spells[1].attackstoptimer = 1000; spells[2].info = dbcSpell.LookupEntry(FELFIRE_LINE_UP); // ? spells[2].targettype = TARGET_SELF; spells[2].instant = true; spells[2].cooldown = -1; spells[2].perctrigger = 8.0f; spells[2].attackstoptimer = 1000; spells[3].info = dbcSpell.LookupEntry(KNOCK_AWAY); spells[3].targettype = TARGET_DESTINATION; // changed from VARIOUS to prevent crashes and gives it at least half working spell spells[3].instant = true; spells[3].cooldown = -1; spells[3].perctrigger = 6.0f; spells[3].attackstoptimer = 1000; spells[4].info = dbcSpell.LookupEntry(CHARGE); spells[4].targettype = TARGET_ATTACKING; spells[4].instant = true; spells[4].cooldown = -1; spells[4].perctrigger = 4.0f; spells[4].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "At last, a target for my frustrations!"); // verified _unit->PlaySoundToSet(11238); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnTargetDied(Unit* mTarget) { if (_unit->GetHealthPct() > 0) { int RandomSpeach; RandomSpeach=rand()%2; switch (RandomSpeach) { case 0: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Yes, that was quiet... satisfying."); // verified _unit->PlaySoundToSet(11239); break; case 1: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Ha! Much better!"); // verified _unit->PlaySoundToSet(11240); break; } } } void OnCombatStop(Unit *mTarget) { CastTime(); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { CastTime(); RemoveAIUpdateEvent(); _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Knew this was... the only way out."); // verified _unit->PlaySoundToSet(11243); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; // Harbinger SkyrissAI // Full event must be scripted for this guy. #define CN_HARBRINGER_SKYRISS 20912 #define MIND_REND 36924 // DBC: 36859, 36924; #define FEAR 39415 #define DOMINATION 37162 #define SUMMON_ILLUSION_66 36931 // those 2 don't work #define SUMMON_ILLUSION_33 36932 // BLINK_VISUAL 36937 ? // SIMPLE_TELEPORT 12980 ? // Add sounds related to his dialog with mind controlled guy class HarbringerSkyrissAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(HarbringerSkyrissAI); SP_AI_Spell spells[5]; bool m_spellcheck[5]; HarbringerSkyrissAI(Creature* pCreature) : CreatureAIScript(pCreature) { IllusionCount = 0; nrspells = 5; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(MIND_REND); spells[0].targettype = TARGET_ATTACKING; spells[0].instant = false; spells[0].cooldown = -1; spells[0].perctrigger = 15.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(FEAR); spells[1].targettype = TARGET_ATTACKING; spells[1].instant = false; spells[1].cooldown = -1; spells[1].perctrigger = 8.0f; spells[1].attackstoptimer = 1000; spells[2].info = dbcSpell.LookupEntry(DOMINATION); spells[2].targettype = TARGET_ATTACKING; spells[2].instant = false; spells[2].cooldown = -1; spells[2].perctrigger = 6.0f; spells[2].attackstoptimer = 1000; spells[3].info = dbcSpell.LookupEntry(SUMMON_ILLUSION_66); spells[3].targettype = TARGET_SELF; spells[3].instant = true; spells[3].cooldown = -1; spells[3].perctrigger = 0.0f; spells[3].attackstoptimer = 1000; spells[4].info = dbcSpell.LookupEntry(SUMMON_ILLUSION_33); spells[4].targettype = TARGET_SELF; spells[4].instant = true; spells[4].cooldown = -1; spells[4].perctrigger = 0.0f; spells[4].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { IllusionCount = 0; CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Bear witness to the agent of your demise!"); // used when he kills Warden Mellichar _unit->PlaySoundToSet(11123); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnTargetDied(Unit* mTarget) { if (_unit->GetHealthPct() > 0) { int RandomSpeach; RandomSpeach=rand()%2; switch (RandomSpeach) { case 0: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Your fate is written!"); // this one needs verification _unit->PlaySoundToSet(11124); break; case 1: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "The chaos I have sown here is but a taste...."); _unit->PlaySoundToSet(11125); break; } } } void OnCombatStop(Unit *mTarget) { IllusionCount = 0; CastTime(); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { IllusionCount = 0; CastTime(); RemoveAIUpdateEvent(); _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "I am merely one of... infinite multitudes."); _unit->PlaySoundToSet(11126); } void AIUpdate() { if (_unit->GetHealthPct() <= 66 && !IllusionCount) { IllusionCount = 1; _unit->CastSpell(_unit, spells[3].info, spells[3].instant); //_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "We span the universe, as countless as the stars!"); _unit->PlaySoundToSet(11131); // Idk if those texts shouldn't be told by clones and by org. so disabled MSG to make it harder to detect =P } if (_unit->GetHealthPct() <= 33 && IllusionCount == 1) { IllusionCount = 2; _unit->CastSpell(_unit, spells[4].info, spells[4].instant); //_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "We span the universe, as countless as the stars!"); _unit->PlaySoundToSet(11131); } else { float val = (float)RandomFloat(100.0f); SpellCast(val); } } void FearSound() { int RandomFear; RandomFear=rand()%4; switch (RandomFear) { case 0: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Flee in terror."); _unit->PlaySoundToSet(11129); break; case 1: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "I will show you horrors undreamed of."); _unit->PlaySoundToSet(11130); break; } } void DominationSound() { int RandomDomination; RandomDomination=rand()%4; switch (RandomDomination) { case 0: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "You will do my bidding, weakling."); _unit->PlaySoundToSet(11127); break; case 1: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Your will is no longer your own."); _unit->PlaySoundToSet(11128); break; } } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } if (m_spellcheck[1] == true) { FearSound(); } if (m_spellcheck[2] == true) { DominationSound(); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: uint32 IllusionCount; int nrspells; }; /* // Warden MellicharAI // he is EVENT STARTER and needs some more time I don't have atm =( #define CN_WARDEN_MELLICHAR 20904 #define class WardenMellicharAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(WardenMellicharAI); SP_AI_Spell spells[1]; bool m_spellcheck[1]; WardenMellicharAI(Creature* pCreature) : CreatureAIScript(pCreature) { nrspells = 1; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(); spells[0].targettype = TARGET_; spells[0].instant = false; spells[0].cooldown = -1; spells[0].perctrigger = 0.0f; spells[0].attackstoptimer = 1000; } void OnCombatStart(Unit* mTarget) { CastTime(); RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, ""); _unit->PlaySoundToSet(); } void CastTime() { for(int i=0;i<nrspells;i++) spells[i].casttime = spells[i].cooldown; } void OnTargetDied(Unit* mTarget) { int RandomSpeach; RandomSpeach=rand()%2; switch (RandomSpeach) { case 0: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, ""); _unit->PlaySoundToSet(); break; case 1: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, ""); _unit->PlaySoundToSet(); break; } } } void OnCombatStop(Unit *mTarget) { CastTime(); _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { CastTime(); RemoveAIUpdateEvent(); _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, ""); _unit->PlaySoundToSet(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;i<nrspells;i++) { spells[i].casttime--; if (m_spellcheck[i]) { spells[i].casttime = spells[i].cooldown; target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } if (spells[i].speech != "") { _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str()); _unit->PlaySoundToSet(spells[i].soundid); } m_spellcheck[i] = false; return; } if ((val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) || !spells[i].casttime) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; }; */ void SetupArcatraz(ScriptMgr * mgr) { mgr->register_creature_script(CN_ARCATRAZ_DEFENDER, &ArcatrazDefenderAI::Create); mgr->register_creature_script(CN_ARCATRAZ_SENTINEL, &ArcatrazSentinelAI::Create); mgr->register_creature_script(CN_ARCATRAZ_WARDER, &ArcatrazWarderAI::Create); mgr->register_creature_script(CN_BLACKWING_DRAKONAAR, &BlackwingDrakonaarAI::Create); mgr->register_creature_script(CN_BLACKWING_TRICKSTER, &BlackwingTricksterAI::Create); mgr->register_creature_script(CN_DEATH_WATCHER, &DeathWatcherAI::Create); mgr->register_creature_script(CN_DEFENDER_CORPSE, &DefenderCorpseAI::Create); mgr->register_creature_script(CN_PROTEAN_SPAWN, &ProteanSpawnAI::Create); mgr->register_creature_script(CN_ENTROPIC_EYE, &EntropicEyeAI::Create); mgr->register_creature_script(CN_EREDAR_DEATHBRINGER, &EredarDeathbringerAI::Create); mgr->register_creature_script(CN_EREDAR_SOUL_EATER, &EredarSoulEaterAI::Create); mgr->register_creature_script(CN_ETHEREUM_LIFE_BINDER, &EthereumLifeBinderAI::Create); mgr->register_creature_script(CN_ETHEREUM_SLAYER, &EthereumSlayerAI::Create); mgr->register_creature_script(CN_ETHEREUM_WAVE_CASTER, &EthereumWaveCasterAI::Create); mgr->register_creature_script(CN_GARGANTUAN_ABYSSAL, &GargantuanAbyssalAI::Create); mgr->register_creature_script(CN_GREATER_FIRE_ELEMENTAL, &GreaterFireElementalAI::Create); mgr->register_creature_script(CN_IRONJAW, &IronjawAI::Create); mgr->register_creature_script(CN_MILLHOUSE_MANASTORM, &MillhouseManastormAI::Create); mgr->register_creature_script(CN_NEGATON_SCREAMER, &NegatonScreamerAI::Create); mgr->register_creature_script(CN_NEGATON_WARP_MASTER, &NegatonWarpMasterAI::Create); mgr->register_creature_script(CN_NEGATON_FIELD, &NegatonFieldAI::Create); mgr->register_creature_script(CN_PHASE_HUNTER, &PhaseHunterAI::Create); mgr->register_creature_script(CN_PROTEAN_HORROR, &ProteanHorrorAI::Create); mgr->register_creature_script(CN_PROTEAN_NIGHTMARE, &ProteanNightmareAI::Create); mgr->register_creature_script(CN_SULFURON_MAGMA_THROWER, &SulfuronMagmaThrowerAI::Create); mgr->register_creature_script(CN_SPITEFUL_TEMPTRESS, &SpitefulTemptressAI::Create); mgr->register_creature_script(CN_SOUL_DEVOURER, &SoulDevourerAI::Create); mgr->register_creature_script(CN_SOLOMON, &SolomonAI::Create); mgr->register_creature_script(CN_SKULKING_WITCH, &SkulkingWitchAI::Create); mgr->register_creature_script(CN_SIGHTLESS_EYE, &SightlessEyeAI::Create); mgr->register_creature_script(CN_SARGERON_HELLCALLER, &SargeronHellcallerAI::Create); mgr->register_creature_script(CN_UNBOUND_DEVASTATOR, &UnboundDevastatorAI::Create); mgr->register_creature_script(CN_UNCHAINED_DOOMBRINGER, &UnchainedDoombringerAI::Create); mgr->register_creature_script(CN_WARDER_CORPSE, &WarderCorpseAI::Create); mgr->register_creature_script(CN_SARGERON_ARCHER, &SargeronArcherAI::Create); mgr->register_creature_script(CN_ZEREKETH, &ZerekethAI::Create); mgr->register_creature_script(CN_VOIDZONEARC, &VoidZoneARC::Create); mgr->register_creature_script(CN_DALLIAH_THE_DOOMSAYER, &DalliahTheDoomsayerAI::Create); mgr->register_creature_script(CN_WRATH_SCRYER_SOCCOTHRATES, &WrathScryerSoccothratesAI::Create); mgr->register_creature_script(CN_HARBRINGER_SKYRISS, &HarbringerSkyrissAI::Create); //mgr->register_creature_script(CN_WARDEN_MELLICHAR, &WardenMellicharAI::Create); } // Note: Don't have infos about: Akkiris Lightning-Waker, Nathan, Third Fragment Guardian, Udalo, Whisper and // Twilight Drakonaar; some of those mobs aren't aggresive.
[ "[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef", "[email protected]@3074cc92-8d2b-11dd-8ab4-67102e0efeef" ]
[ [ [ 1, 3101 ], [ 3103, 4135 ] ], [ [ 3102, 3102 ] ] ]
0e39664cf6224ffc069f731762d46cd194ce7813
0f40e36dc65b58cc3c04022cf215c77ae31965a8
/src/apps/routing/tree/tree_creation_task.h
487a562bb916ea5780d4070516d11786edf51320
[ "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
2,678
h
/************************************************************************ ** This file is part of the network simulator Shawn. ** ** Copyright (C) 2004-2007 by the SwarmNet (www.swarmnet.de) project ** ** Shawn is free software; you can redistribute it and/or modify it ** ** under the terms of the BSD License. Refer to the shawn-licence.txt ** ** file in the root of the Shawn source tree for further details. ** ************************************************************************/ #ifndef __SHAWN_APPS_ROUTING_TREE_TREE_CREATION_TASK_H #define __SHAWN_APPS_ROUTING_TREE_TREE_CREATION_TASK_H #include "_apps_enable_cmake.h" #ifdef ENABLE_ROUTING #include <limits.h> #include <map> #include "sys/simulation/simulation_task.h" #include "sys/misc/dynamic_node_array.h" namespace shawn{ class SimulationController; class Node; } namespace routing { namespace tree { class TreeRouting; class TreeCreationTask : public shawn::SimulationTask { public: typedef std::multimap<double,const shawn::Node*> NodesToExamineMap; typedef std::multimap<double,const shawn::Node*>::iterator NodesToExamineMapIterator; typedef std::multimap<double,const shawn::Node*>::value_type NodesToExamineMapValueType; struct TreeCreationHopsToSinkInfo { TreeCreationHopsToSinkInfo() : hops_(INT_MAX) {} TreeCreationHopsToSinkInfo( const TreeCreationHopsToSinkInfo& other ) : hops_(other.hops_) {} virtual ~TreeCreationHopsToSinkInfo() {} int hops_; }; class TreeCreationHopsToSinkResult : public shawn::DynamicNodeArray<TreeCreationHopsToSinkInfo> { public: TreeCreationHopsToSinkResult( shawn::World& world ) : shawn::DynamicNodeArray<TreeCreationHopsToSinkInfo>( world ) {} virtual ~TreeCreationHopsToSinkResult() {} }; TreeCreationTask(); virtual ~TreeCreationTask(); virtual std::string name( void ) const throw(); virtual std::string description( void ) const throw(); virtual void run( shawn::SimulationController& sc ) throw( std::runtime_error ); protected: virtual void create_tree_in_tree_routing( routing::tree::TreeRouting& routing_instance, const shawn::Node& sink ) throw(); virtual void create_tree_in_file( shawn::SimulationController& sc, const std::string& filename, const shawn::Node& sink, int max_hops ) throw(); virtual void create_tree_from_file( shawn::SimulationController& sc, routing::tree::TreeRouting& routint_instance, const std::string& filename ) throw(); }; std::string conv_double_to_string(double d) throw(); } } #endif #endif
[ [ [ 1, 72 ] ] ]
721d5a3f9436022668f567a1701b84268a63a027
ce1b0d027c41f70bc4cfa13cb05f09bd4edaf6a2
/ edge2d --username [email protected]/include/EdgeLog.h
46f1174c10e4a70bda5308104de5079e56b5474b
[]
no_license
ratalaika/edge2d
11189c41b166960d5d7d5dbcf9bfaf833a41c079
79470a0fa6e8f5ea255df1696da655145bbf83ff
refs/heads/master
2021-01-10T04:59:22.495428
2010-02-19T13:45:03
2010-02-19T13:45:03
36,088,756
1
0
null
null
null
null
UTF-8
C++
false
false
2,155
h
/* ----------------------------------------------------------------------------- This source file is part of EDGE (A very object-oriented and plugin-based 2d game engine) For the latest info, see http://edge2d.googlecode.com Copyright (c) 2007-2008 The EDGE Team Also see acknowledgements in Readme.html This program 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 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt. ----------------------------------------------------------------------------- */ #ifndef EDGE_LOG_H #define EDGE_LOG_H #include "EdgeCompile.h" #include <fstream> #include <string> using std::ofstream ; using std::string; namespace Edge { /** * log level * it will help you write some useful information * */ enum ELogLevel { LL_ERROR, LL_WARNING, LL_INFORMATION, }; /** * a log will wirte messages to a file * @remarks Usually you should use LogManager::logMessage to write messages to a log file. * */ class EDGE_EXPORT Log { public: /** * Constructor will open a file for output * * */ Log( const string &name, const string &file ); /** * Destructor will close the file * */ ~Log(); /** * get the log name * */ string &getName() { return mName; } /** * logMessage, write message to the log file. * */ void logMessage( ELogLevel level, const string &msg ); private: string mName; ofstream mFile; }; } #endif
[ "[email protected]@539dfdeb-0f3d-0410-9ace-d34ff1985647" ]
[ [ [ 1, 89 ] ] ]
2175ebc566b64d380cf7ca707d90b8413371cdd0
2acd91cf2dfe87f4c78fba230de2c2ffc90350ea
/ salad-bar-in-space-game/edge/bouncibility/include/Menu.h
f032a983668229076f1f9901cc6323e500917c7b
[]
no_license
Joshvanburen/salad-bar-in-space-game
5f410a06be475edee1ab85950c667e6a6f970763
b23a35c832258f4fc1a921a45ab4238c734ef1f0
refs/heads/master
2016-09-01T18:46:29.672326
2008-05-07T18:40:30
2008-05-07T18:40:30
32,195,299
0
0
null
null
null
null
UTF-8
C++
false
false
1,379
h
/* Header file for the menu system #pragma once #include "Common.h" #include "singleton.h" #include "irrlicht.h" //Access to the irr namespace namespace irr { //Access to class IrrlichtDevice class IrrlichtDevice; //Access to the scene namespace namespace scene { //Access to IBillboardSceneNode class IBillboardSceneNode; //Access to class ISceneManager class ISceneManager; } //Access to video namespace namespace video { //Access to class class IVideoDriver; } } //Defines the menu class class Menu : //Menu is a Singleton object so only one can be created public CSingleton <Menu> { //CSingleton as friend friend CSingleton; friend class GameSystem; //Private functions and members private: //Initialization void init(irr::IrrlichtDevice* device); //Quit void quit(); //New game void newGame(); //New game irr::scene::IBillboardSceneNode * b_newGame; //Quit irr::scene::IBillboardSceneNode * b_quit; //Video driver irr::video::IVideoDriver* s_Driver; //Scene manager irr::scene::ISceneManager* s_Smgr; //Device irr::IrrlichtDevice* s_Device; //Public functions and members public: //Constructor Menu(); //Destructor ~Menu(); //Pause void pause(); //Unpause void unPause(); }; */
[ "Joshvanburen@1a2710a4-8244-0410-8b66-391840787a9e", "tkahlow@1a2710a4-8244-0410-8b66-391840787a9e" ]
[ [ [ 1, 2 ], [ 4, 71 ], [ 74, 74 ] ], [ [ 3, 3 ], [ 72, 73 ] ] ]
94015ee60ef49f1f4e5ba142e9e1378de49af712
270515cee0e43cf1ed1b5e295215465f33e72d21
/skypecheckers/SkypeCheckersView.h
ef30284798379d54ebaa5f53226615e206d82c09
[]
no_license
ramenia/sa2asamples
d45ca12b93bb4530b374aa4cad1d7000e0831bd1
c0d9317d71f9c2be61fb717599be9af5940a5009
refs/heads/master
2021-05-29T16:41:20.471283
2007-05-22T17:07:01
2007-05-22T17:07:01
null
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
1,239
h
// SkypeCheckersView.h : CSkypeCheckersView クラスのインターフェイス // #pragma once #include "SkypeCheckersDoc.h" class CSkypeCheckersView : public CView { protected: // シリアル化からのみ作成します。 CSkypeCheckersView(); DECLARE_DYNCREATE(CSkypeCheckersView) // 属性 public: CSkypeCheckersDoc* GetDocument() const; // 操作 public: // オーバーライド public: virtual void OnDraw(CDC* pDC); // このビューを描画するためにオーバーライドされます。 virtual BOOL PreCreateWindow(CREATESTRUCT& cs); protected: // 実装 public: virtual ~CSkypeCheckersView(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // 生成された、メッセージ割り当て関数 protected: DECLARE_MESSAGE_MAP() public: void DrawBoard(CDC* pDC); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); }; #ifndef _DEBUG // SkypeCheckersView.cpp のデバッグ バージョン inline CSkypeCheckersDoc* CSkypeCheckersView::GetDocument() const { return reinterpret_cast<CSkypeCheckersDoc*>(m_pDocument); } #endif
[ "komakura@e21e20eb-d230-0410-9e73-79da4af2494c" ]
[ [ [ 1, 48 ] ] ]
290b3cc8e20d98916a1a4ba2a1e026da9256ec70
b2601dbc552b4ffa9b439dc17e5f18bb75b09379
/src/arm9/source/lg/texture.cpp
4e6b5ab0d1f25c657740174ee6c9fdd8aa292bf1
[]
no_license
sgraham/twinisles
70e9989e47933c87aa66f43efdd9b03c2b4e9d64
e0086154fcc4f3be130d4c88b9af3a0aab490715
refs/heads/master
2021-01-18T13:53:55.740730
2010-10-13T06:59:12
2010-10-13T06:59:12
34,834,093
0
0
null
null
null
null
UTF-8
C++
false
false
4,381
cpp
#include "lg/lg.h" #include "lg/texture.h" #include <climits> namespace luvafair { // todo; init/purge static uint32* sNextBlock = (uint32*)0x06800000; //static uint32 sNextPBlock = 0; static void GetDimensionsFromTexFormat(u16 texFormat, u16& width, u16& height, u16& bpp) { u16 wlog2m3 = (texFormat >> (20 - 16)) & 7; u16 hlog2m3 = (texFormat >> (23 - 16)) & 7; u16 fmt = (texFormat >> (26 - 16)) & 7; assert(fmt == 6 && "haven't encoded formats other than rgb8_a5 yet"); bpp = 8; width = 1 << (wlog2m3 + 3); height = 1 << (hlog2m3 + 3); } static void GetDataPointers(u16 texFormat, const u8* data, const void*& palette, const void*& texture) { int fmt = (texFormat >> (26 - 16)) & 7; data += 2; // texFormat u16 switch (fmt) { case 1: palette = data; // rgb32_a3 texture = data + 32 * sizeof(u16); break; case 2: palette = data; // rgb4 texture = data + 4 * sizeof(u16); break; case 3: palette = data; // rgb16 texture = data + 16 * sizeof(u16); break; case 4: palette = data; // rgb256 texture = data + 256 * sizeof(u16); break; case 6: palette = data; // rgb8_a5 texture = data + 8 * sizeof(u16); break; case 7: palette = 0; // rgba texture = data; default: palette = 0; texture = 0; assert(false && "unhandled texture format"); } } static inline uint32 alignVal(uint32 val, uint32 to) { return (val & (to-1))? (val & ~(to-1)) + to : val; } /* static int GetNextPaletteSlot(u16 count, uint8 format) { // ensure the result aligns on a palette block for this format uint32 result = alignVal(nextPBlock, 1<<(4-(format==GL_RGB4))); // convert count to bytes and align to next (smallest format) palette block count = alignVal( count<<1, 1<<3 ); // ensure that end is within palette video mem if( result+count > 0x10000 ) // VRAM_F - VRAM_E return -1; nextPBlock = result+count; return (int)result; } */ uint16* VramGetBank(uint16 *addr) { if(addr >= VRAM_A && addr < VRAM_B) return VRAM_A; else if(addr >= VRAM_B && addr < VRAM_C) return VRAM_B; else if(addr >= VRAM_C && addr < VRAM_D) return VRAM_C; else if(addr >= VRAM_D && addr < VRAM_E) return VRAM_D; else if(addr >= VRAM_E && addr < VRAM_F) return VRAM_E; else if(addr >= VRAM_F && addr < VRAM_G) return VRAM_F; else if(addr >= VRAM_G && addr < VRAM_H) return VRAM_H; else if(addr >= VRAM_H && addr < VRAM_I) return VRAM_H; else return VRAM_I; } int VramIsTextureBank(uint16 *addr) { uint16* vram = VramGetBank(addr); if(vram == VRAM_A) { if((VRAM_A_CR & 3) == ((VRAM_A_TEXTURE) & 3)) return 1; else return 0; } else if(vram == VRAM_B) { if((VRAM_B_CR & 3) == ((VRAM_B_TEXTURE) & 3)) return 1; else return 0; } else if(vram == VRAM_C) { if((VRAM_C_CR & 3) == ((VRAM_C_TEXTURE) & 3)) return 1; else return 0; } else if(vram == VRAM_D) { if((VRAM_D_CR & 3) == ((VRAM_D_TEXTURE) & 3)) return 1; else return 0; } else return 0; } uint32* GetNextTextureSlot(int size) { uint32* result = sNextBlock; sNextBlock += size >> 2; //uh-oh...out of texture memory in this bank...find next one assigned to textures while(!VramIsTextureBank((uint16*)sNextBlock - 1) && sNextBlock <= (uint32*)VRAM_E) { sNextBlock = (uint32*)VramGetBank((uint16*)result) + (0x20000 >> 2); //next bank result = sNextBlock; sNextBlock += size >> 2; } if(sNextBlock > (uint32*)VRAM_E) return 0; else return result; } Texture::Texture(const u8* data) : mData(data) { u16 width, height, bpp; const void* texture; const void* palette; u16 texFormat = *(const u16*)mData; GetDimensionsFromTexFormat(texFormat, width, height, bpp); GetDataPointers(texFormat, mData, palette, texture); uint32 size = width * height * bpp / CHAR_BIT; uint32* addr = GetNextTextureSlot(size); uint32 vramTemp = vramSetMainBanks(VRAM_A_LCD, VRAM_B_LCD, VRAM_C_LCD, VRAM_D_LCD); swiCopy((void*)texture, addr, size / 4 | COPY_MODE_WORD); mAddress = (((uint32)addr) / 8) & 0xffff; vramRestoreMainBanks(vramTemp); } }
[ [ [ 1, 179 ] ] ]
c7b7019ff934a77d4bff16b30cfcbfa8f957951e
138a353006eb1376668037fcdfbafc05450aa413
/source/ogre/OgreNewt/boost/mpl/aux_/config/dmc_ambiguous_ctps.hpp
1abd643033142b986c1a4e52e17e05870e73e9b5
[]
no_license
sonicma7/choreopower
107ed0a5f2eb5fa9e47378702469b77554e44746
1480a8f9512531665695b46dcfdde3f689888053
refs/heads/master
2020-05-16T20:53:11.590126
2009-11-18T03:10:12
2009-11-18T03:10:12
32,246,184
0
0
null
null
null
null
UTF-8
C++
false
false
896
hpp
#ifndef BOOST_MPL_AUX_CONFIG_DMC_AMBIGUOUS_CTPS_HPP_INCLUDED #define BOOST_MPL_AUX_CONFIG_DMC_AMBIGUOUS_CTPS_HPP_INCLUDED // Copyright Aleksey Gurtovoy 2004 // // 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/libs/mpl for documentation. // $Source: /cvsroot/ogre/ogreaddons/ogrenewt/OgreNewt_Main/inc/boost/mpl/aux_/config/dmc_ambiguous_ctps.hpp,v $ // $Date: 2006/04/17 23:47:07 $ // $Revision: 1.1 $ #include <boost/mpl/aux_/config/workaround.hpp> #if !defined(BOOST_MPL_CFG_DMC_AMBIGUOUS_CTPS) \ && !defined(BOOST_MPL_PREPROCESSING_MODE) \ && BOOST_WORKAROUND(__DMC__, BOOST_TESTED_AT(0x840)) # define BOOST_MPL_CFG_DMC_AMBIGUOUS_CTPS #endif #endif // BOOST_MPL_AUX_CONFIG_DMC_AMBIGUOUS_CTPS_HPP_INCLUDED
[ "Sonicma7@0822fb10-d3c0-11de-a505-35228575a32e" ]
[ [ [ 1, 27 ] ] ]
b6aed048ef09a40a71d003a1d1183710e5831a46
21da454a8f032d6ad63ca9460656c1e04440310e
/src/modules/main/pimap_server/wscPimapServerApp.h
ccd17d21ae34a1eb4dda340d9abcf666ff3c98e8
[]
no_license
merezhang/wcpp
d9879ffb103513a6b58560102ec565b9dc5855dd
e22eb48ea2dd9eda5cd437960dd95074774b70b0
refs/heads/master
2021-01-10T06:29:42.908096
2009-08-31T09:20:31
2009-08-31T09:20:31
46,339,619
0
0
null
null
null
null
UTF-8
C++
false
false
1,008
h
#pragma once #include <wcpp/caf/wscConsoleApp.h> #include <net/worldscale/pimap/wsiPimapLibrary.h> #define WS_ClassName_OF_wscPimapServerApp "modules.main.pimap_server.wscPimapServerApp" class wscPimapServerApp : public wscConsoleApp { public: static const ws_char * const s_class_name; typedef wscConsoleApp t_super_class; public: enum cmds { cmdExit, cmdHelp, cmdInfo, }; private: ws_safe_ptr<wsiPimapServer> m_server; protected: wscPimapServerApp(void); ~wscPimapServerApp(void); protected: WS_METHOD( ws_result , OnInit )( void ); WS_METHOD( ws_result , OnExit )( void ); WS_METHOD( ws_result , OnCmd )( wsiConsoleCommand * cmd ); WS_METHOD( ws_result , OnCmdMapped )(ws_int cmdId , wsiConsoleCommand * cmd); WS_METHOD( ws_result , WaitForCmd )(wsiConsoleCommand ** ret); private: void OnCmdHelp(wsiConsoleCommand * cmd); void OnCmdInfo(wsiConsoleCommand * cmd); };
[ "xukun0217@98f29a9a-77f1-11de-91f8-ab615253d9e8" ]
[ [ [ 1, 37 ] ] ]
e610b77cac4c40816ba11ef97d951a6f053c0926
b44e5bee016d44c596e1e5484429643fb0b5924d
/QWindowSystemWidgets/QWindowSystem/qxtwindowsystem_x11.cpp
916c01c9e48e58cec9862f7e6e25ece0d0e380ce
[ "MIT" ]
permissive
junaid124/Quantum
604ea6c393d6fbd34e13b2ebe8ff4449b6e7c90e
429d11f0b2c737164005ba70c98611baef69d1c5
refs/heads/master
2021-01-18T14:45:08.320080
2011-09-21T05:23:52
2011-09-21T05:23:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,828
cpp
#include "qxtwindowsystem.h" #include <QLibrary> #include <QX11Info> #include <X11/Xutil.h> static WindowList qxt_getWindows(Atom prop) { WindowList res; Atom type = 0; int format = 0; uchar* data = 0; ulong count, after; Display* display = QX11Info::display(); Window window = QX11Info::appRootWindow(); if (XGetWindowProperty(display, window, prop, 0, 1024 * sizeof(Window) / 4, False, AnyPropertyType, &type, &format, &count, &after, &data) == Success) { Window* list = reinterpret_cast<Window*>(data); for (uint i = 0; i < count; ++i) res += list[i]; if (data) XFree(data); } return res; } WindowList QWindowSystem::windows() { static Atom net_clients = 0; if (!net_clients) net_clients = XInternAtom(QX11Info::display(), "_NET_CLIENT_LIST_STACKING", True); return qxt_getWindows(net_clients); } WId QWindowSystem::activeWindow() { static Atom net_active = 0; if (!net_active) net_active = XInternAtom(QX11Info::display(), "_NET_ACTIVE_WINDOW", True); return qxt_getWindows(net_active).value(0); } WId QWindowSystem::findWindow(const QString& title) { Window result = 0; WindowList list = windows(); foreach (const Window &wid, list) { if (windowTitle(wid) == title) { result = wid; break; } } return result; } WId QWindowSystem::windowAt(const QPoint& pos) { Window result = 0; WindowList list = windows(); for (int i = list.size() - 1; i >= 0; --i) { WId wid = list.at(i); if (windowGeometry(wid).contains(pos)) { result = wid; break; } } return result; } QString QWindowSystem::windowTitle(WId window) { QString name; char* str = 0; if (XFetchName(QX11Info::display(), window, &str)) name = QString::fromLatin1(str); if (str) XFree(str); return name; } QRect QWindowSystem::windowGeometry(WId window) { int x, y; uint width, height, border, depth; Window root, child; Display* display = QX11Info::display(); XGetGeometry(display, window, &root, &x, &y, &width, &height, &border, &depth); XTranslateCoordinates(display, window, root, x, y, &x, &y, &child); static Atom net_frame = 0; if (!net_frame) net_frame = XInternAtom(QX11Info::display(), "_NET_FRAME_EXTENTS", True); QRect rect(x, y, width, height); Atom type = 0; int format = 0; uchar* data = 0; ulong count, after; if (XGetWindowProperty(display, window, net_frame, 0, 4, False, AnyPropertyType, &type, &format, &count, &after, &data) == Success) { // _NET_FRAME_EXTENTS, left, right, top, bottom, CARDINAL[4]/32 if (count == 4) { long* extents = reinterpret_cast<long*>(data); rect.adjust(-extents[0], -extents[2], extents[1], extents[3]); } if (data) XFree(data); } return rect; } typedef struct { Window window; /* screen saver window - may not exist */ int state; /* ScreenSaverOff, ScreenSaverOn, ScreenSaverDisabled*/ int kind; /* ScreenSaverBlanked, ...Internal, ...External */ unsigned long til_or_since; /* time til or since screen saver */ unsigned long idle; /* total time since last user input */ unsigned long eventMask; /* currently selected events for this client */ } XScreenSaverInfo; typedef XScreenSaverInfo* (*XScreenSaverAllocInfo)(); typedef Status (*XScreenSaverQueryInfo)(Display* display, Drawable* drawable, XScreenSaverInfo* info); static XScreenSaverAllocInfo _xScreenSaverAllocInfo = 0; static XScreenSaverQueryInfo _xScreenSaverQueryInfo = 0; uint QWindowSystem::idleTime() { static bool xssResolved = false; if (!xssResolved) { QLibrary xssLib(QLatin1String("Xss"), 1); if (xssLib.load()) { _xScreenSaverAllocInfo = (XScreenSaverAllocInfo) xssLib.resolve("XScreenSaverAllocInfo"); _xScreenSaverQueryInfo = (XScreenSaverQueryInfo) xssLib.resolve("XScreenSaverQueryInfo"); xssResolved = true; } } uint idle = 0; if (xssResolved) { XScreenSaverInfo* info = _xScreenSaverAllocInfo(); const int screen = QX11Info::appScreen(); Qt::HANDLE rootWindow = QX11Info::appRootWindow(screen); _xScreenSaverQueryInfo(QX11Info::display(), (Drawable*) rootWindow, info); idle = info->idle; if (info) XFree(info); } return idle; }
[ [ [ 1, 160 ] ] ]
2fc521c188175a23afac47f2b6d1c076be26d2cb
460b4422ba8b81fbc001a22da31969cf9d28ed12
/SslPyFilter/ClassFactory.cpp
b2a4333298eaf551498b2d2d18167c27a0afb065
[]
no_license
killvxk/sslpyfilter
02d953dd96aec622b8a78e16efa818cb301e776d
6803ee2e27039628d6cc94b9a7f521598894c39f
refs/heads/master
2020-12-07T19:27:48.627612
2008-04-14T23:04:08
2008-04-14T23:04:08
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
2,906
cpp
// ======================================================================================================================== // SslPyFilter // // Copyright ©2007-2008 Liam Kirton <[email protected]> // ======================================================================================================================== // ClassFactory.cpp // // Created: 18/04/2007 // ======================================================================================================================== #include "ClassFactory.h" #include <iostream> #include "Guid.h" #include "SslPyFilter.h" // ======================================================================================================================== ClassFactory::ClassFactory(CLSID clsid) : clsid_(clsid), dwObjRefCount_(1) { } // ======================================================================================================================== ClassFactory::~ClassFactory() { } // ======================================================================================================================== STDMETHODIMP ClassFactory::QueryInterface(REFIID iid, void **ppvObject) { *ppvObject = NULL; HRESULT hResult = E_NOINTERFACE; if(IsEqualIID(iid, IID_IUnknown)) { *ppvObject = this; } else if(IsEqualIID(iid, IID_IClassFactory)) { *ppvObject = dynamic_cast<IClassFactory *>(this); } if(*ppvObject != NULL) { AddRef(); hResult = S_OK; } return hResult; } // ======================================================================================================================== STDMETHODIMP_(DWORD) ClassFactory::AddRef() { return ++dwObjRefCount_; } // ======================================================================================================================== STDMETHODIMP_(DWORD) ClassFactory::Release() { if(--dwObjRefCount_ == 0) { delete this; return 0; } return dwObjRefCount_; } // ======================================================================================================================== STDMETHODIMP ClassFactory::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObject) { HRESULT hResult = E_FAIL; *ppvObject = NULL; if(pUnkOuter != NULL) { hResult = CLASS_E_NOAGGREGATION; } else { if(IsEqualCLSID(clsid_, CLSID_SslPyFilter)) { SslPyFilter *sslPyFilter = new SslPyFilter(); hResult = sslPyFilter->QueryInterface(riid, ppvObject); sslPyFilter->Release(); } } return hResult; } // ======================================================================================================================== STDMETHODIMP ClassFactory::LockServer(BOOL fLock) { return S_OK; } // ========================================================================================================================
[ [ [ 1, 108 ] ] ]
8335d73494889f402409776f1ecb4bc43c651b7e
40b507c2dde13d14bb75ee1b3c16b4f3f82912d1
/extensions/mysql/extension.cpp
f6238abb5c04c65945e744c9ece3d3c7b62c5566
[]
no_license
Nephyrin/-furry-octo-nemesis
5da2ef75883ebc4040e359a6679da64ad8848020
dd441c39bd74eda2b9857540dcac1d98706de1de
refs/heads/master
2016-09-06T01:12:49.611637
2008-09-14T08:42:28
2008-09-14T08:42:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,082
cpp
/** * vim: set ts=4 : * ============================================================================= * SourceMod MySQL Extension * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. * ============================================================================= * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License, version 3.0, as published by the * Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program. If not, see <http://www.gnu.org/licenses/>. * * As a special exception, AlliedModders LLC gives you permission to link the * code of this program (as well as its derivative works) to "Half-Life 2," the * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software * by the Valve Corporation. You must obey the GNU General Public License in * all respects for all other code used. Additionally, AlliedModders LLC grants * this exception to all derivative works. AlliedModders LLC defines further * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), * or <http://www.sourcemod.net/license.php>. * * Version: $Id$ */ #include "extension.h" #include "mysql/MyDriver.h" #include <assert.h> #include <stdlib.h> /** * @file extension.cpp * @brief Implement extension code here. */ DBI_MySQL g_MySqlDBI; /**< Global singleton for extension's main interface */ SMEXT_LINK(&g_MySqlDBI); bool DBI_MySQL::SDK_OnLoad(char *error, size_t maxlength, bool late) { dbi->AddDriver(&g_MyDriver); my_init(); return true; } void DBI_MySQL::SDK_OnUnload() { dbi->RemoveDriver(&g_MyDriver); //:TODO: is this needed? //mysql_library_end(); }
[ [ [ 1, 2 ], [ 4, 5 ], [ 7, 7 ], [ 11, 11 ], [ 16, 16 ], [ 19, 19 ], [ 28, 60 ] ], [ [ 3, 3 ], [ 6, 6 ], [ 8, 10 ], [ 12, 15 ], [ 17, 18 ], [ 20, 27 ] ] ]
3dda405a8b474c82699ba5df06be424d132203d6
33f59b1ba6b12c2dd3080b24830331c37bba9fe2
/Depend/Foundation/Intersection/Wm4IntrPlane3Box3.cpp
4cd9383032eb1615af20fae0eb84d3a3be7177d9
[]
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
2,849
cpp
// 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. #include "Wm4FoundationPCH.h" #include "Wm4IntrPlane3Box3.h" namespace Wm4 { //---------------------------------------------------------------------------- template <class Real> IntrPlane3Box3<Real>::IntrPlane3Box3 (const Plane3<Real>& rkPlane, const Box3<Real>& rkBox) : m_rkPlane(rkPlane), m_rkBox(rkBox) { } //---------------------------------------------------------------------------- template <class Real> const Plane3<Real>& IntrPlane3Box3<Real>::GetPlane () const { return m_rkPlane; } //---------------------------------------------------------------------------- template <class Real> const Box3<Real>& IntrPlane3Box3<Real>::GetBox () const { return m_rkBox; } //---------------------------------------------------------------------------- template <class Real> bool IntrPlane3Box3<Real>::Test () { Real afTmp[3] = { m_rkBox.Extent[0]*(m_rkPlane.Normal.Dot(m_rkBox.Axis[0])), m_rkBox.Extent[1]*(m_rkPlane.Normal.Dot(m_rkBox.Axis[1])), m_rkBox.Extent[2]*(m_rkPlane.Normal.Dot(m_rkBox.Axis[2])) }; Real fRadius = Math<Real>::FAbs(afTmp[0]) + Math<Real>::FAbs(afTmp[1]) + Math<Real>::FAbs(afTmp[2]); Real fSignedDistance = m_rkPlane.DistanceTo(m_rkBox.Center); return Math<Real>::FAbs(fSignedDistance) <= fRadius; } //---------------------------------------------------------------------------- template <class Real> bool IntrPlane3Box3<Real>::BoxIsCulled () const { Real afTmp[3] = { m_rkBox.Extent[0]*(m_rkPlane.Normal.Dot(m_rkBox.Axis[0])), m_rkBox.Extent[1]*(m_rkPlane.Normal.Dot(m_rkBox.Axis[1])), m_rkBox.Extent[2]*(m_rkPlane.Normal.Dot(m_rkBox.Axis[2])) }; Real fRadius = Math<Real>::FAbs(afTmp[0]) + Math<Real>::FAbs(afTmp[1]) + Math<Real>::FAbs(afTmp[2]); Real fSignedDistance = m_rkPlane.DistanceTo(m_rkBox.Center); return fSignedDistance <= -fRadius; } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- // explicit instantiation //---------------------------------------------------------------------------- template WM4_FOUNDATION_ITEM class IntrPlane3Box3<float>; template WM4_FOUNDATION_ITEM class IntrPlane3Box3<double>; //---------------------------------------------------------------------------- }
[ "yf.flagship@e79fdf7c-a9d8-11de-b950-3d5b5f4ea0aa" ]
[ [ [ 1, 82 ] ] ]
98b746540ead4544cd280a4c6762df252588b043
205069c97095da8f15e45cede1525f384ba6efd2
/Casino/Code/Server/Template/Array.h
9fef210b9457061ff1b15bd9d426af5eb3db80f7
[]
no_license
m0o0m/01technology
1a3a5a48a88bec57f6a2d2b5a54a3ce2508de5ea
5e04cbfa79b7e3cf6d07121273b3272f441c2a99
refs/heads/master
2021-01-17T22:12:26.467196
2010-01-05T06:39:11
2010-01-05T06:39:11
null
0
0
null
null
null
null
GB18030
C++
false
false
11,936
h
#ifndef ARRAY_TEMPLATE_HEAD_FILE #define ARRAY_TEMPLATE_HEAD_FILE #pragma once ////////////////////////////////////////////////////////////////////////// //数组模板类 template <class TYPE, class ARG_TYPE=const TYPE &> class CArrayTemplate : public CObject { //变量定义 protected: TYPE * m_pData; //数组指针 INT_PTR m_nMaxCount; //缓冲数目 INT_PTR m_nGrowCount; //增长数目 INT_PTR m_nElementCount; //元素数目 //函数定义 public: //构造函数 CArrayTemplate(void); //析构函数 virtual ~CArrayTemplate(void); //信息函数 public: //是否空组 bool IsEmpty() const; //获取数目 INT_PTR GetCount() const; //获取上限 INT_PTR GetUpperBound() const; //功能函数 public: //获取缓冲 TYPE * GetData(); //获取缓冲 const TYPE * GetData() const; //释放内存 void FreeExtra(); //增加元素 INT_PTR Add(ARG_TYPE newElement); //拷贝数组 void Copy(const CArrayTemplate & Src); //追加数组 INT_PTR Append(const CArrayTemplate & Src); //获取元素 TYPE & GetAt(INT_PTR nIndex); //获取元素 const TYPE & GetAt(INT_PTR nIndex) const; //获取元素 TYPE & ElementAt(INT_PTR nIndex); //获取元素 const TYPE & ElementAt(INT_PTR nIndex) const; //操作函数 public: //设置大小 void SetSize(INT_PTR nNewSize); //设置元素 void SetAt(INT_PTR nIndex, ARG_TYPE newElement); //设置元素 void SetAtGrow(INT_PTR nIndex, ARG_TYPE newElement); //插入数据 void InsertAt(INT_PTR nIndex, const CArrayTemplate & Src); //插入数据 void InsertAt(INT_PTR nIndex, ARG_TYPE newElement, INT_PTR nCount=1); //删除数据 void RemoveAt(INT_PTR nIndex, INT_PTR nCount=1); //删除元素 void RemoveAll(); //操作重载 public: //操作重载 TYPE & operator[](INT_PTR nIndex); //操作重载 const TYPE & operator[](INT_PTR nIndex) const; //内部函数 private: //申请内存 void AllocMemory(INT_PTR nNewCount); }; ////////////////////////////////////////////////////////////////////////// // CArrayTemplate<TYPE, ARG_TYPE> 内联函数 //是否空组 template<class TYPE, class ARG_TYPE> AFX_INLINE bool CArrayTemplate<TYPE, ARG_TYPE>::IsEmpty() const { ASSERT_VALID(this); return (m_nElementCount==0); } //获取数目 template<class TYPE, class ARG_TYPE> AFX_INLINE INT_PTR CArrayTemplate<TYPE, ARG_TYPE>::GetCount() const { ASSERT_VALID(this); return m_nElementCount; } //获取上限 template<class TYPE, class ARG_TYPE> AFX_INLINE INT_PTR CArrayTemplate<TYPE, ARG_TYPE>::GetUpperBound() const { ASSERT_VALID(this); return m_nElementCount-1; } //增加元素 template<class TYPE, class ARG_TYPE> AFX_INLINE INT_PTR CArrayTemplate<TYPE,ARG_TYPE>::Add(ARG_TYPE newElement) { INT_PTR nIndex=m_nElementCount; SetAtGrow(nIndex,newElement); return nIndex; } //操作重载 template<class TYPE, class ARG_TYPE> AFX_INLINE TYPE & CArrayTemplate<TYPE, ARG_TYPE>::operator[](INT_PTR nIndex) { return ElementAt(nIndex); } //操作重载 template<class TYPE, class ARG_TYPE> AFX_INLINE const TYPE & CArrayTemplate<TYPE, ARG_TYPE>::operator[](INT_PTR nIndex) const { return GetAt(nIndex); } ////////////////////////////////////////////////////////////////////////// // CArrayTemplate<TYPE, ARG_TYPE> 外联函数 //构造函数 template<class TYPE, class ARG_TYPE> CArrayTemplate<TYPE, ARG_TYPE>::CArrayTemplate() { m_pData=NULL; m_nMaxCount=0; m_nGrowCount=0; m_nElementCount=0; return; } //构造函数 template<class TYPE, class ARG_TYPE> CArrayTemplate<TYPE,ARG_TYPE>::~CArrayTemplate() { if (m_pData!=NULL) { for (INT_PTR i=0;i<m_nElementCount;i++) (m_pData+i)->~TYPE(); delete [] (BYTE *)m_pData; m_pData=NULL; } return; } //获取缓冲 template<class TYPE, class ARG_TYPE> TYPE * CArrayTemplate<TYPE,ARG_TYPE>::GetData() { ASSERT_VALID(this); return m_pData; } //获取缓冲 template<class TYPE, class ARG_TYPE> const TYPE * CArrayTemplate<TYPE,ARG_TYPE>::GetData() const { ASSERT_VALID(this); return m_pData; } //释放内存 template<class TYPE, class ARG_TYPE> void CArrayTemplate<TYPE,ARG_TYPE>::FreeExtra() { ASSERT_VALID(this); if (m_nElementCount!=m_nMaxCount) { TYPE * pNewData=NULL; if (m_nElementCount!=0) { pNewData=(TYPE *) new BYTE[m_nElementCount*sizeof(TYPE)]; memcpy(pNewData,m_pData,m_nElementCount*sizeof(TYPE)); } delete [] (BYTE *)m_pData; m_pData=pNewData; m_nMaxCount=m_nElementCount; } return; } //拷贝数组 template<class TYPE, class ARG_TYPE> void CArrayTemplate<TYPE,ARG_TYPE>::Copy(const CArrayTemplate & Src) { //效验参数 ASSERT_VALID(this); ASSERT(this!=&Src); if (this==&Src) return; //拷贝数组 AllocMemory(Src.m_nElementCount); if (m_nElementCount>0) { for (INT_PTR i=0;i<m_nElementCount;i++) (m_pData+i)->~TYPE(); memset(m_pData,0,m_nElementCount*sizeof(TYPE)); } for (INT_PTR i=0;i<Src.m_nElementCount;i++) m_pData[i]=Src.m_pData[i]; m_nElementCount=Src.m_nElementCount; return; } //追加数组 template<class TYPE, class ARG_TYPE> INT_PTR CArrayTemplate<TYPE,ARG_TYPE>::Append(const CArrayTemplate & Src) { //效验参数 ASSERT_VALID(this); ASSERT(this!=&Src); if (this==&Src) AfxThrowInvalidArgException(); //拷贝数组 if (Src.m_nElementCount>0) { INT_PTR nOldCount=m_nElementCount; AllocMemory(m_nElementCount+Src.m_nElementCount); for (INT_PTR i=0;i<Src.m_nElementCount;i++) m_pData[m_nElementCount+i]=Src.m_pData[i]; m_nElementCount+=Src.m_nElementCount; } return m_nElementCount; } //获取元素 template<class TYPE, class ARG_TYPE> TYPE & CArrayTemplate<TYPE,ARG_TYPE>::GetAt(INT_PTR nIndex) { ASSERT((nIndex>=0)&&(nIndex<m_nElementCount)); if ((nIndex>=0)&&(nIndex<m_nElementCount)) return m_pData[nIndex]; AfxThrowInvalidArgException(); } //获取元素 template<class TYPE, class ARG_TYPE> const TYPE & CArrayTemplate<TYPE,ARG_TYPE>::GetAt(INT_PTR nIndex) const { ASSERT((nIndex>=0)&&(nIndex<m_nElementCount)); if ((nIndex>=0)&&(nIndex<m_nElementCount)) return m_pData[nIndex]; AfxThrowInvalidArgException(); } //获取元素 template<class TYPE, class ARG_TYPE> TYPE & CArrayTemplate<TYPE,ARG_TYPE>::ElementAt(INT_PTR nIndex) { ASSERT((nIndex>=0)&&(nIndex<m_nElementCount)); if ((nIndex>=0)&&(nIndex<m_nElementCount)) return m_pData[nIndex]; AfxThrowInvalidArgException(); } //获取元素 template<class TYPE, class ARG_TYPE> const TYPE & CArrayTemplate<TYPE,ARG_TYPE>::ElementAt(INT_PTR nIndex) const { ASSERT((nIndex>=0)&&(nIndex<m_nElementCount)); if ((nIndex>=0)&&(nIndex<m_nElementCount)) return m_pData[nIndex]; AfxThrowInvalidArgException(); } //设置大小 template<class TYPE, class ARG_TYPE> void CArrayTemplate<TYPE,ARG_TYPE>::SetSize(INT_PTR nNewSize) { //效验参数 ASSERT_VALID(this); ASSERT(nNewSize>=0); if (nNewSize<0) AfxThrowInvalidArgException(); //设置大小 AllocMemory(nNewSize); if (nNewSize>m_nElementCount) { #pragma push_macro("new") #undef new for (INT_PTR i=m_nElementCount;i<nNewSize;i++) ::new ((void *)(m_pData+i)) TYPE; #pragma pop_macro("new") } else if (nNewSize<m_nElementCount) { for (INT_PTR i=nNewSize;i<m_nElementCount;i++) (m_pData+i)->~TYPE(); memset(m_pData+nNewSize,0,(m_nElementCount-nNewSize)*sizeof(TYPE)); } m_nElementCount=nNewSize; return; } //设置元素 template<class TYPE, class ARG_TYPE> void CArrayTemplate<TYPE,ARG_TYPE>::SetAt(INT_PTR nIndex, ARG_TYPE newElement) { ASSERT((nIndex>=0)&&(nIndex<m_nElementCount)); if ((nIndex>=0)&&(nIndex<m_nElementCount)) m_pData[nIndex]=newElement; } //设置元素 template<class TYPE, class ARG_TYPE> void CArrayTemplate<TYPE,ARG_TYPE>::SetAtGrow(INT_PTR nIndex, ARG_TYPE newElement) { //效验参数 ASSERT_VALID(this); ASSERT(nIndex>=0); if (nIndex<0) AfxThrowInvalidArgException(); //设置元素 if (nIndex>=m_nElementCount) SetSize(m_nElementCount+1); m_pData[nIndex]=newElement; return; } //插入数据 template<class TYPE, class ARG_TYPE> void CArrayTemplate<TYPE,ARG_TYPE>::InsertAt(INT_PTR nIndex, const CArrayTemplate & Src) { //效验参数 ASSERT_VALID(this); ASSERT(nStartIndex>=0); if (nStartIndex<0) AfxThrowInvalidArgException(); if (Src.m_nElementCount>0) { //申请数组 if (nIndex<m_nElementCount) { INT_PTR nOldCount=m_nElementCount; SetSize(m_nElementCount+Src.m_nElementCount); for (INT_PTR i=0;i<nCount;i++) (m_pData+nOldCount+i)->~TYPE(); memmove(m_pData+nIndex+nCount,m_pData+nIndex,(nOldCount-nIndex)*sizeof(TYPE)); memset(m_pData+nIndex,0,Src.m_nElementCount*sizeof(TYPE)); #pragma push_macro("new") #undef new for (INT_PTR i=0;i<Src.m_nElementCount;i++) ::new (m_pData+nIndex+i) TYPE(); #pragma pop_macro("new") } else SetSize(nIndex+nCount); //拷贝数组 ASSERT((nIndex+Src.m_nElementCount)<=m_nElementCount); while (nCount--) m_pData[nIndex++]=newElement; } return; } //插入数据 template<class TYPE, class ARG_TYPE> void CArrayTemplate<TYPE,ARG_TYPE>::InsertAt(INT_PTR nIndex, ARG_TYPE newElement, INT_PTR nCount) { //效验参数 ASSERT_VALID(this); ASSERT(nIndex>=0); ASSERT(nCount>0); if ((nIndex<0)||(nCount<=0)) AfxThrowInvalidArgException(); //申请数组 if (nIndex<m_nElementCount) { INT_PTR nOldCount=m_nElementCount; SetSize(m_nElementCount+nCount); for (INT_PTR i=0;i<nCount;i++) (m_pData+nOldCount+i)->~TYPE(); memmove(m_pData+nIndex+nCount,m_pData+nIndex,(nOldCount-nIndex)*sizeof(TYPE)); memset(m_pData+nIndex,0,nCount*sizeof(TYPE)); #pragma push_macro("new") #undef new for (INT_PTR i=0;i<nCount;i++) ::new (m_pData+nIndex+i) TYPE(); #pragma pop_macro("new") } else SetSize(nIndex+nCount); //拷贝数组 ASSERT((nIndex+nCount)<=m_nElementCount); while (nCount--) m_pData[nIndex++]=newElement; return; } //删除数据 template<class TYPE, class ARG_TYPE> void CArrayTemplate<TYPE,ARG_TYPE>::RemoveAt(INT_PTR nIndex, INT_PTR nCount) { //效验参数 ASSERT_VALID(this); ASSERT(nIndex>=0); ASSERT(nCount>=0); ASSERT(nIndex+nCount<=m_nElementCount); if ((nIndex<0)||(nCount<0)||((nIndex+nCount>m_nElementCount))) AfxThrowInvalidArgException(); //删除数据 INT_PTR nMoveCount=m_nElementCount-(nIndex+nCount); for (INT_PTR i=0;i<nCount;i++) (m_pData+nIndex+i)->~TYPE(); if (nMoveCount>0) memmove(m_pData+nIndex,m_pData+nIndex+nCount,nMoveCount*sizeof(TYPE)); m_nElementCount-=nCount; return; } //删除元素 template<class TYPE, class ARG_TYPE> void CArrayTemplate<TYPE,ARG_TYPE>::RemoveAll() { ASSERT_VALID(this); if (m_nElementCount>0) { for (INT_PTR i=0;i<m_nElementCount;i++) (m_pData+i)->~TYPE(); memset(m_pData,0,m_nElementCount*sizeof(TYPE)); m_nElementCount=0; } return; } //申请内存 template<class TYPE, class ARG_TYPE> void CArrayTemplate<TYPE,ARG_TYPE>::AllocMemory(INT_PTR nNewCount) { //效验参数 ASSERT_VALID(this); ASSERT(nNewCount>=0); if (nNewCount>m_nMaxCount) { //计算数目 INT_PTR nGrowCount=m_nGrowCount; if (nGrowCount==0) { nGrowCount=m_nElementCount/8; nGrowCount=(nGrowCount<4)?4:((nGrowCount>1024)?1024:nGrowCount); } nNewCount+=nGrowCount; //申请内存 TYPE * pNewData=(TYPE *) new BYTE[nNewCount*sizeof(TYPE)]; memcpy(pNewData,m_pData,m_nElementCount*sizeof(TYPE)); memset(pNewData+m_nElementCount,0,(nNewCount-m_nElementCount)*sizeof(TYPE)); delete [] (BYTE *)m_pData; //设置变量 m_pData=pNewData; m_nMaxCount=nNewCount; } } ////////////////////////////////////////////////////////////////////////// #endif
[ [ [ 1, 465 ] ] ]
48844958ba07fba53003d98fa7c2bd9967102fec
6d340a0cdbabbcbdd10460852ed24770c2ec78e4
/source_codes/geometry/perceptron_split/perceptron_split.cpp
c665c98ebe6c4989eae159024545bc7be7943072
[]
no_license
vsbus/vsb-reference
5bdb5eb8c212f1e8592a1b47044f5d531d741df4
2f4434e896bd03d33c14683b3702f09d51b5992e
refs/heads/master
2021-01-10T18:38:57.392158
2011-05-10T13:08:11
2011-05-10T13:08:11
32,411,348
0
0
null
null
null
null
UTF-8
C++
false
false
564
cpp
struct Obj { Point point; int expectedSign; }; bool getSplitLine(vector<Obj> p, double &A, double &B, double &C) { A = B = C = 1; for (int it = 0; it < 1000000; ++it) { // !!! constant as bigger then better bool ok = true; for (int i = 0; i < p.size(); ++i) { double x = p[i].point.x; double y = p[i].point.y; int s = p[i].expectedSign; int ns = sign(A * x + B * y + C * 1); if (s != ns) { A += s * x; B += s * y; C += s * 1; ok = false; } } if (ok) { return true; } } return false; }
[ "victorbarinov@ad8ebaea-3bba-49b6-65e2-71ef8dee33c5" ]
[ [ [ 1, 26 ] ] ]
ecda0f02e7dcfbbe32fe426eb2138a5e2d27856f
619941b532c6d2987c0f4e92b73549c6c945c7e5
/Include/Nuclex/Input/InputServer.h
3ab96b3c95e6dcc4c3d7dd4b47ed0bb6341d4a7f
[]
no_license
dzw/stellarengine
2b70ddefc2827be4f44ec6082201c955788a8a16
2a0a7db2e43c7c3519e79afa56db247f9708bc26
refs/heads/master
2016-09-01T21:12:36.888921
2008-12-12T12:40:37
2008-12-12T12:40:37
36,939,169
0
0
null
null
null
null
ISO-8859-1
C++
false
false
6,256
h
//  // // # # ### # # -= Nuclex Library =-  // // ## # # # ## ## InputServer.h - Input device manager  // // ### # # ###  // // # ### # ### Manages all input devices and handles generation of input events  // // # ## # # ## ## for standard input  // // # # ### # # R1 (C)2002-2004 Markus Ewald -> License.txt  // //  // #ifndef NUCLEX_INPUT_INPUTSERVER_H #define NUCLEX_INPUT_INPUTSERVER_H #include "Nuclex/Nuclex.h" #include "Nuclex/Input/InputDevice.h" #include "Nuclex/Input/InputReceiver.h" #include "SigC++/SigC++.h" #include <map> /* Concept: The InputServer manages a set of input devices. An input device is a physical device accessed through a specific API. Virtual triggers can be registered to any button or axis of such a device together with a modifier which defines how the trigger will be activated. Something like this: Keyboard:KeyA.Press, Mouse:X.Axis, Joystick:Throttle.Value Need a way to gather input data a fixed number of times per second and make it easily accessable to the user. - Direct trigger value (digital oder analog) .Down - Once when the trigger went down .Up - Once when the trigger went up Controls unabhängig an- und abmeldbar ? */ namespace Nuclex { class Kernel; } namespace Nuclex { namespace Input { class InputReceiver; //  // //  Nuclex::Input::InputServer  // //  // /// Nuclex input server /** */ class InputServer : public sigc::trackable { public: /// Enumerator over a list of Input devices class DeviceEnumerator; /// Constructor NUCLEX_API InputServer(); /// Destructor NUCLEX_API virtual ~InputServer(); // // InputServer implementation // public: /// Retrieve device NUCLEX_API const shared_ptr<InputDevice> &getDevice(const string &sName) const; /// Add device NUCLEX_API void addDevice(const string &sName, const shared_ptr<InputDevice> &spDevice); /// Remove device NUCLEX_API void removeDevice(const string &sName); /// Remove all devices NUCLEX_API void clearDevices(); /// Get renderer enumerator NUCLEX_API shared_ptr<DeviceEnumerator> enumDevices() const; /// Set interval for trigger snapshots NUCLEX_API void setSnapshotInterval( const TimeSpan &Interval, size_t MaxHistory = MaxSnapshotHistory ); /// Update state on all devices NUCLEX_API void poll(); /// Add a control NUCLEX_API void bind(const string &sControl, const string &sDevice, const string &sAction); /// Remove a control NUCLEX_API void unbind(const string &sControl, const string &sDevice, const string &sAction); /// Remove all controls NUCLEX_API void clearBindings(); /// Get status of control NUCLEX_API real getState(const string &sControl) const; // enumControls // enumTriggersOfControl /// Generate an input event for the current receiver NUCLEX_API void generateInput(const InputReceiver::Event &InputEvent); /// Retrieve the current input receiver NUCLEX_API const shared_ptr<InputReceiver> &getReceiver() const { return m_spReceiver; } /// Set the input receiver NUCLEX_API void setReceiver(const shared_ptr<InputReceiver> &spReceiver = shared_ptr<InputReceiver>()); private: /// Map of Input devices typedef std::map<string, shared_ptr<InputDevice> > DeviceMap; /// Binding of an action to a control struct Binding { string sDevice; ///< Bound device string sTrigger; ///< Bound trigger InputDevice::Trigger::Interposition eInterposition; ///< Modifier for the trigger string sControl; ///< Control name size_t ControlIndex; ///< Control which is triggered }; typedef std::vector<Binding> BindingVector; typedef std::vector<float> FloatVector; typedef std::map<string, size_t> IndexMap; DeviceMap m_Devices; ///< Map of devices shared_ptr<InputReceiver> m_spReceiver; ///< Input event receiver IndexMap m_Controls; ///< Controls which have been bound FloatVector m_States; ///< Current states of the bound controls BindingVector m_Bindings; ///< Current list of bindings }; //  // //  Nuclex::Input::InputServer::DeviceEnumerator  // //  // /** Enumerates all registered devices */ class InputServer::DeviceEnumerator { public: /// Destructor /** Destroys an instance of DeviceIterator */ NUCLEX_API virtual ~DeviceEnumerator() {} // // DeviceEnumerator implementation // public: /// Cycle through devices /** Returns the current device being enumerated and advances to the next. If no more devices are remaining, NULL is returned @return The currently enumerated renderer */ NUCLEX_API virtual const shared_ptr<InputDevice> &cycle() = 0; }; }} // namespace Nuclex::Input #endif // NUCLEX_INPUT_INPUTSERVER_H
[ "ctuoMail@5f320639-c338-0410-82ad-c55551ec1e38" ]
[ [ [ 1, 160 ] ] ]
f7e0fe0257bb2b3df5d0de580c070d11f4de0a7e
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/wave/test/testwave/testfiles/t_6_066.hpp
2b61e35b20080b39190f92b56dd93a4a5457c240
[ "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
2,276
hpp
/*============================================================================= Boost.Wave: A Standard compliant C++ preprocessor library http://www.boost.org/ Copyright (c) 2001-2006 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) The tests included in this file were initially taken from the mcpp V2.5 preprocessor validation suite and were modified to fit into the Boost.Wave unit test requirements. The original files of the mcpp preprocessor are distributed under the license reproduced at the end of this file. =============================================================================*/ // Tests error reporting: undefined behavior: End of a source file is // <backslash><newline>. int dummy = 0; /*- * Copyright (c) 1998, 2002-2005 Kiyoshi Matsui <[email protected]> * 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. * * 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. */ \
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 46 ] ] ]
3427cca90da238c6818edf5278014a56af7b3633
41543fd481e363d8c4794edc97e767c8defb2273
/hello_client/src/hello_client.cpp
34bad594e89fe9b97d40fb725a1046185af1d775
[ "BSL-1.0" ]
permissive
ExpLife0011/libHTTP
550904eddf17f5fa89a2ff9fd563ff5746cbc29b
c53b85c7192f5b2cf506a71f36ec44e9b99ada1a
refs/heads/master
2020-03-08T16:35:52.022125
2010-05-14T18:13:36
2010-05-14T18:13:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,982
cpp
#include <iostream> #include <boost/thread/thread.hpp> #include <boost/format.hpp> #include <boost/filesystem/path.hpp> using namespace std; using namespace boost; using filesystem::path; #include <http/hello/client.hpp> // This class links the debug_logger provided by libHTTP to cout. // It also prefixes all libHTTP messages with "http: ". The actual // code for implementing the link is in the constructer. static class debug_link { public: debug_link(); void operator()(const string& text) { cout << "-> " << text; } private: signals::scoped_connection conn_; } debug_link_; debug_link::debug_link() : conn_(http::log().attach(debug_link_)) {} int main() { try { // asio::ssl::context::sslv23 // A connection object is created and managed by a shared_ptr. No // attempt is made to connect to a server yet. http::client::sync::connection_base_ptr con(new http::client::sync::connection("127.0.0.1", 8080)); // Here we use it twice, on on the second use we pass false to // keep-alive telling the server to disconnect the socket. cout << http::client::hello(con, "/hello", "World!", true) << "\r\n"; cout << http::client::hello(con, "/hello", "World Again!", false) << "\r\n"; # if defined(HTTP_SUPPORT_OPENSSL) // Do it all again with an SSL connection. http::client::sync::ssl_connection_ptr ssl_con(new http::client::sync::ssl_connection("127.0.0.1", 8443, http::boost__asio::ssl::context::sslv23)); http::boost__asio::ssl::context& context = ssl_con->context(); context.set_verify_mode(http::boost__asio::ssl::context::verify_peer); context.load_verify_file("server.crt"); cout << http::client::hello(ssl_con, "/hello", "Secured World!", false) << "\r\n"; # endif } catch(const std::exception& e) { cout << format("Main Error: %1%.\r\n") % e.what(); } cout << "Press enter to end application.\r\n"; cin.get(); return 0; }
[ "rhenders@oliver.(none)" ]
[ [ [ 1, 74 ] ] ]
adc59a057603da6da0c6b96a3347dbc0adc39229
ffa46b6c97ef6e0c03e034d542fa94ba02d519e5
/qfinddialog.cpp
d490ada326d4a92a9e906bc6443a413ab74576ca
[]
no_license
jason-cpc/chmcreator
50467a2bc31833aef931e24be1ac68f5c06efd97
5da66666a9df47c5cf67b71bfb115b403f41b72b
refs/heads/master
2021-12-04T11:22:23.616758
2010-07-20T23:50:15
2010-07-20T23:50:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,202
cpp
#include <QtGui> #include "qfinddialog.h" //! [0] FindDialog::FindDialog(QWidget *parent) : QDialog(parent) { label = new QLabel(tr("Find &what:")); lineEdit = new QLineEdit; label->setBuddy(lineEdit); caseCheckBox = new QCheckBox(tr("Match &case")); fromStartCheckBox = new QCheckBox(tr("Search from &start")); fromStartCheckBox->setChecked(true); //! [1] findButton = new QPushButton(tr("&Find")); findButton->setDefault(true); moreButton = new QPushButton(tr("&More")); moreButton->setCheckable(true); //! [0] moreButton->setAutoDefault(false); buttonBox = new QDialogButtonBox(Qt::Vertical); buttonBox->addButton(findButton, QDialogButtonBox::ActionRole); buttonBox->addButton(moreButton, QDialogButtonBox::ActionRole); //! [1] //! [2] extension = new QWidget; wholeWordsCheckBox = new QCheckBox(tr("&Whole words")); backwardCheckBox = new QCheckBox(tr("Search &backward")); searchSelectionCheckBox = new QCheckBox(tr("Search se&lection")); //! [2] //! [3] connect(moreButton, SIGNAL(toggled(bool)), extension, SLOT(setVisible(bool))); QVBoxLayout *extensionLayout = new QVBoxLayout; extensionLayout->setMargin(0); extensionLayout->addWidget(wholeWordsCheckBox); extensionLayout->addWidget(backwardCheckBox); extensionLayout->addWidget(searchSelectionCheckBox); extension->setLayout(extensionLayout); //! [3] //! [4] QHBoxLayout *topLeftLayout = new QHBoxLayout; topLeftLayout->addWidget(label); topLeftLayout->addWidget(lineEdit); QVBoxLayout *leftLayout = new QVBoxLayout; leftLayout->addLayout(topLeftLayout); leftLayout->addWidget(caseCheckBox); leftLayout->addWidget(fromStartCheckBox); leftLayout->addStretch(1); QGridLayout *mainLayout = new QGridLayout; mainLayout->setSizeConstraint(QLayout::SetFixedSize); mainLayout->addLayout(leftLayout, 0, 0); mainLayout->addWidget(buttonBox, 0, 1); mainLayout->addWidget(extension, 1, 0, 1, 2); setLayout(mainLayout); setWindowTitle(tr("Extension")); //! [4] //! [5] extension->hide(); } //! [5]
[ "zhurx4g@35deca34-8bc2-11de-b999-7dfecaa767bb" ]
[ [ [ 1, 72 ] ] ]
bdf64864aa17fc35a4b53f11c0b2e7c86c54e72b
a2904986c09bd07e8c89359632e849534970c1be
/topcoder/TileCutting.cpp
689749e3394cd938e72eff00e10196531f163798
[]
no_license
naturalself/topcoder_srms
20bf84ac1fd959e9fbbf8b82a93113c858bf6134
7b42d11ac2cc1fe5933c5bc5bc97ee61b6ec55e5
refs/heads/master
2021-01-22T04:36:40.592620
2010-11-29T17:30:40
2010-11-29T17:30:40
444,669
1
0
null
null
null
null
UTF-8
C++
false
false
6,860
cpp
// BEGIN CUT HERE // END CUT HERE #line 5 "TileCutting.cpp" #include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <numeric> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> using namespace std; #define debug(p) cout << #p << "=" << p << endl; #define forv(i, v) for (int i = 0; i < (int)(v.size()); ++i) #define fors(i, s) for (int i = 0; i < (int)(s.length()); ++i) #define all(a) a.begin(), a.end() #define pb push_back class TileCutting { public: int cuts(vector <string> layout) { } // BEGIN CUT HERE public: void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); if ((Case == -1) || (Case == 5)) test_case_5(); if ((Case == -1) || (Case == 6)) test_case_6(); if ((Case == -1) || (Case == 7)) test_case_7(); } private: template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); } void verify_case(int Case, const int &Expected, const int &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } } void test_case_0() { string Arr0[] = { "..", ".." }; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 0; verify_case(0, Arg1, cuts(Arg0)); } void test_case_1() { string Arr0[] = { "x.", ".." }; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 2; verify_case(1, Arg1, cuts(Arg0)); } void test_case_2() { string Arr0[] = { ".x", "xx" }; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 2; verify_case(2, Arg1, cuts(Arg0)); } void test_case_3() { string Arr0[] = { "xxxx..xxxx", "x..x..xx..", "x..xxxxx..", "xxxxxxxxxx" }; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 6; verify_case(3, Arg1, cuts(Arg0)); } void test_case_4() { string Arr0[] = { "xxxxxx", "x....x" }; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 3; verify_case(4, Arg1, cuts(Arg0)); } void test_case_5() { string Arr0[] = { "x..x....", "x..xx...", "..xx....", "...x....", "......xx", "......xx" }; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 4; verify_case(5, Arg1, cuts(Arg0)); } void test_case_6() { string Arr0[] = { "x..xx.x..x.xx..x.xx.", "..x..x..x.x..xx...x.", ".xx...x...x...x..x..", ".xx...x.x.x...x..xx.", ".x..x...x.....x...x.", ".x.x.x..x..x..x..x.x", "...x.x.x.x.x.x.x...x", ".x..x..x...x..x...x.", "...x.x.x..x.x.x.....", "...x.x.x..x.x.xxx.x.", "xx.xx.xx.x.x.x.x..x.", ".x..xxx...x.xx...x.x", "xx..x.x...x.x.x.x..x", ".xx..x.xx.xxxxx...xx", "x....x.x...x...x.x..", ".x.xx.x..x.x.xxx.x..", "...xx.xxx.....xx.xxx", ".xx..x..xx.x...x.xx.", "x.x...x.x.xx.x..x.xx", ".....xx.x.......xx.x", "x...x.xx.x..x....x..", ".x..xxx.....x.x.x.xx" } ; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 121; verify_case(6, Arg1, cuts(Arg0)); } void test_case_7() { string Arr0[] = { "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", "..................................................", ".................................................." } ; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arg1 = 0; verify_case(7, Arg1, cuts(Arg0)); } // END CUT HERE }; // BEGIN CUT HERE int main() { TileCutting ___test; ___test.run_test(-1); } // END CUT HERE
[ "shin@CF-7AUJ41TT52JO.(none)" ]
[ [ [ 1, 147 ] ] ]
e199fc0282a20e3a15e27d17017a138ce8830e12
478570cde911b8e8e39046de62d3b5966b850384
/apicompatanamdw/bcdrivers/app/contacts/phonebook_data_management_api/MTPbkContactIter/src/MTPbkContactIterBlocks.cpp
d8ce9187319562c18d7ee99b77c1d22827b3bd52
[]
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
17,836
cpp
/* * Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: ?Description * */ // [INCLUDE FILES] - do not remove #include <e32svr.h> #include <StifParser.h> #include <Stiftestinterface.h> #include "MTPbkContactIter.h" // INTERNAL INCLUDES #include <CPbkContactEngine.h> #include <CPbkContactIter.h> #include <CPbkContactItem.h> #include <TPbkContactItemField.h> // CONSTANTS _LIT(KTestDatabaseName, "c:CMTPbkContactIter.cdb"); // EXTERNAL DATA STRUCTURES //extern ?external_data; // EXTERNAL FUNCTION PROTOTYPES //extern ?external_function( ?arg_type,?arg_type ); // CONSTANTS //const ?type ?constant_var = ?constant; // MACROS //#define ?macro ?macro_def // LOCAL CONSTANTS AND MACROS //const ?type ?constant_var = ?constant; //#define ?macro_name ?macro_def // MODULE DATA STRUCTURES //enum ?declaration //typedef ?declaration // LOCAL FUNCTION PROTOTYPES //?type ?function_name( ?arg_type, ?arg_type ); // FORWARD DECLARATIONS //class ?FORWARD_CLASSNAME; // ============================= LOCAL FUNCTIONS =============================== // ----------------------------------------------------------------------------- // ?function_name ?description. // ?description // Returns: ?value_1: ?description // ?value_n: ?description_line1 // ?description_line2 // ----------------------------------------------------------------------------- // /* ?type ?function_name( ?arg_type arg, // ?description ?arg_type arg) // ?description { ?code // ?comment // ?comment ?code } */ // ============================ MEMBER FUNCTIONS =============================== // ----------------------------------------------------------------------------- // CMTPbkContactIter::Delete // Delete here all resources allocated and opened from test methods. // Called from destructor. // ----------------------------------------------------------------------------- // void CMTPbkContactIter::Delete() { } // ----------------------------------------------------------------------------- // CMTPbkContactIter::RunMethodL // Run specified method. Contains also table of test mothods and their names. // ----------------------------------------------------------------------------- // TInt CMTPbkContactIter::RunMethodL( CStifItemParser& aItem ) { TStifFunctionInfo const KFunctions[] = { // Copy this line for every implemented function. // First string is the function name used in TestScripter script file. // Second is the actual implementation member function. ENTRY( "Test_creation", CMTPbkContactIter::TestCreation ), ENTRY( "Test_create_and_reset", CMTPbkContactIter::TestCreateAndReset ), ENTRY( "Test_with_empty_db", CMTPbkContactIter::TestEmptyDbL ), ENTRY( "Test_with_empty_db_minimal_read", CMTPbkContactIter::TestEmptyDbMinimalReadL ), ENTRY( "Test_FirstL_with_one_contact_db", CMTPbkContactIter::TestIterOnDbWithOneContactL ), ENTRY( "Test_NextL_with_one_contact_db", CMTPbkContactIter::TestIterOnDbWithOneContact2L ), ENTRY( "Test_CurrentL_with_one_contact_db", CMTPbkContactIter::TestIterOnDbWithOneContact3L ), ENTRY( "Test_FirstLCurrentL_with_one_contact_db", CMTPbkContactIter::TestIterOnDbWithOneContact4L ), ENTRY( "Test_GetCurrentL_with_one_contact_db", CMTPbkContactIter::TestIterOnDbWithOneContact5L ), ENTRY( "Test_FirstLGetCurrentL_with_one_contact_db", CMTPbkContactIter::TestIterOnDbWithOneContact6L ), ENTRY( "Test_FirstL_with_one_contact_db_minimal_read", CMTPbkContactIter::TestIterOnDbWithOneContactMinimalReadL ), ENTRY( "Test_NextL_with_one_contact_db_minimal-read", CMTPbkContactIter::TestIterOnDbWithOneContactMinimalRead2L ), ENTRY( "Test_CurrentL_with_one_contact_dbminimal_read", CMTPbkContactIter::TestIterOnDbWithOneContactMinimalRead3L ), ENTRY( "Test_FirstLCurrentL_with_one_contact_db_minimal_read", CMTPbkContactIter::TestIterOnDbWithOneContactMinimalRead4L ), ENTRY( "Test_GetCurrentL_with_one_contact_db_minimal_read", CMTPbkContactIter::TestIterOnDbWithOneContactMinimalRead5L ), ENTRY( "Test_FirstLGetCurrentL_with_one_contact_db_minimal_read", CMTPbkContactIter::TestIterOnDbWithOneContactMinimalRead6L ), ENTRY( "Test_iterator_with_two_contact_db", CMTPbkContactIter::TestIterOnDbWith2ContactsL ), ENTRY( "Test_iterator_with_two_contact_db_minimal_read", CMTPbkContactIter::TestIterOnDbWith2ContactsMinimalReadL ), //ADD NEW ENTRY HERE // [test cases entries] - Do not remove }; const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo ); return RunInternalL( KFunctions, count, aItem ); } void CMTPbkContactIter::SetupL() { // create engine iEngine = CPbkContactEngine::NewL(KTestDatabaseName, ETrue); } void CMTPbkContactIter::SetupWithContactL() { SetupL(); // create Contact into db CPbkContactItem* item = iEngine->CreateEmptyContactL(); CleanupStack::PushL(item); iAddedContactId = iEngine->AddNewContactL(*item); CleanupStack::PopAndDestroy(item); } void CMTPbkContactIter::SetupWith2ContactL() { SetupL(); // create Contact into db CPbkContactItem* item = iEngine->CreateEmptyContactL(); CleanupStack::PushL(item); iAddedContactId = iEngine->AddNewContactL(*item); CleanupStack::PopAndDestroy(item); item = iEngine->CreateEmptyContactL(); CleanupStack::PushL(item); iAddedContactId2 = iEngine->AddNewContactL(*item); CleanupStack::PopAndDestroy(item); } void CMTPbkContactIter::Teardown() { delete iEngine; iAddedContactId = KNullContactId; iAddedContactId2 = KNullContactId; } TInt CMTPbkContactIter::TestCreation() { SetupL(); CPbkContactIter* iter = CPbkContactIter::NewL(*iEngine); ASSERT(iter); delete iter; iter = NULL; iter = CPbkContactIter::NewL(*iEngine, ETrue); ASSERT(iter); delete iter; iter = NULL; iter = CPbkContactIter::NewLC(*iEngine); ASSERT(iter); CleanupStack::PopAndDestroy(iter); iter = CPbkContactIter::NewLC(*iEngine, ETrue); ASSERT(iter); CleanupStack::PopAndDestroy(iter); Teardown(); return KErrNone;} TInt CMTPbkContactIter::TestCreateAndReset() { SetupWithContactL(); CPbkContactIter* iter = CPbkContactIter::NewL(*iEngine); ASSERT(iter); TContactItemId id = iter->FirstL(); ASSERT(id == iAddedContactId); iter->Reset(); ASSERT(iter->CurrentL() == NULL); id = NULL; id = iter->FirstL(); ASSERT(id == iAddedContactId); delete iter; iter = NULL; Teardown(); return KErrNone;} TInt CMTPbkContactIter::TestEmptyDbL() { SetupL(); CPbkContactIter* iter = CPbkContactIter::NewLC(*iEngine); ASSERT(iter); TContactItemId id = iter->FirstL(); ASSERT(id == KNullContactId); CleanupStack::PopAndDestroy(iter); iter = CPbkContactIter::NewLC(*iEngine); ASSERT(iter); id = iter->NextL(); ASSERT(id == KNullContactId); CleanupStack::PopAndDestroy(iter); iter = CPbkContactIter::NewLC(*iEngine); ASSERT(iter); CPbkContactItem* item = iter->CurrentL(); ASSERT(!item); CleanupStack::PopAndDestroy(iter); iter = CPbkContactIter::NewLC(*iEngine); ASSERT(iter); item = iter->GetCurrentL(); ASSERT(!item); CleanupStack::PopAndDestroy(iter); Teardown(); return KErrNone;} TInt CMTPbkContactIter::TestEmptyDbMinimalReadL() { SetupL(); // minimal read CPbkContactIter* iter = CPbkContactIter::NewLC(*iEngine, ETrue); ASSERT(iter); TContactItemId id = iter->FirstL(); ASSERT(id == KNullContactId); CleanupStack::PopAndDestroy(iter); iter = CPbkContactIter::NewLC(*iEngine, ETrue); ASSERT(iter); id = iter->NextL(); ASSERT(id == KNullContactId); CleanupStack::PopAndDestroy(iter); iter = CPbkContactIter::NewLC(*iEngine, ETrue); ASSERT(iter); CPbkContactItem* item = iter->CurrentL(); ASSERT(!item); CleanupStack::PopAndDestroy(iter); iter = CPbkContactIter::NewLC(*iEngine, ETrue); ASSERT(iter); item = iter->GetCurrentL(); ASSERT(!item); CleanupStack::PopAndDestroy(iter); Teardown(); return KErrNone;} TInt CMTPbkContactIter::TestIterOnDbWithOneContactL() { SetupWithContactL(); CPbkContactIter* iter = CPbkContactIter::NewLC(*iEngine); ASSERT(iter); TContactItemId id = iter->FirstL(); ASSERT(id == iAddedContactId); CleanupStack::PopAndDestroy(iter); Teardown(); return KErrNone;} TInt CMTPbkContactIter::TestIterOnDbWithOneContact2L() { SetupWithContactL(); CPbkContactIter* iter = CPbkContactIter::NewLC(*iEngine); ASSERT(iter); TContactItemId id = iter->NextL(); ASSERT(id == iAddedContactId); CleanupStack::PopAndDestroy(iter); Teardown(); return KErrNone;} TInt CMTPbkContactIter::TestIterOnDbWithOneContact3L() { SetupWithContactL(); CPbkContactIter* iter = CPbkContactIter::NewLC(*iEngine); ASSERT(iter); CPbkContactItem* item = iter->CurrentL(); ASSERT(!item); CleanupStack::PopAndDestroy(iter); Teardown(); return KErrNone;} TInt CMTPbkContactIter::TestIterOnDbWithOneContact4L() { SetupWithContactL(); CPbkContactIter* iter = CPbkContactIter::NewLC(*iEngine); ASSERT(iter); TContactItemId id = iter->FirstL(); ASSERT(id == iAddedContactId); CPbkContactItem* item = iter->CurrentL(); ASSERT(item); CleanupStack::PopAndDestroy(iter); Teardown(); return KErrNone;} TInt CMTPbkContactIter::TestIterOnDbWithOneContact5L() { SetupWithContactL(); CPbkContactIter* iter = CPbkContactIter::NewLC(*iEngine); ASSERT(iter); CPbkContactItem* item = iter->GetCurrentL(); ASSERT(!item); delete item; CleanupStack::PopAndDestroy(iter); Teardown(); return KErrNone;} TInt CMTPbkContactIter::TestIterOnDbWithOneContact6L() { SetupWithContactL(); CPbkContactIter* iter = CPbkContactIter::NewLC(*iEngine); ASSERT(iter); TContactItemId id = iter->FirstL(); ASSERT(id == iAddedContactId); CPbkContactItem* item = iter->GetCurrentL(); ASSERT(item); delete item; CleanupStack::PopAndDestroy(iter); Teardown(); return KErrNone;} TInt CMTPbkContactIter::TestIterOnDbWithOneContactMinimalReadL() { SetupWithContactL(); // read minimal CPbkContactIter* iter = CPbkContactIter::NewLC(*iEngine, ETrue); ASSERT(iter); TContactItemId id = iter->FirstL(); ASSERT(id == iAddedContactId); CleanupStack::PopAndDestroy(iter); Teardown(); return KErrNone;} TInt CMTPbkContactIter::TestIterOnDbWithOneContactMinimalRead2L() { SetupWithContactL(); CPbkContactIter* iter = CPbkContactIter::NewLC(*iEngine, ETrue); ASSERT(iter); TContactItemId id = iter->NextL(); ASSERT(id == iAddedContactId); CleanupStack::PopAndDestroy(iter); Teardown(); return KErrNone;} TInt CMTPbkContactIter::TestIterOnDbWithOneContactMinimalRead3L() { SetupWithContactL(); CPbkContactIter* iter = CPbkContactIter::NewLC(*iEngine, ETrue); ASSERT(iter); CPbkContactItem* item = iter->CurrentL(); ASSERT(!item); CleanupStack::PopAndDestroy(iter); Teardown(); return KErrNone;} TInt CMTPbkContactIter::TestIterOnDbWithOneContactMinimalRead4L() { SetupWithContactL(); CPbkContactIter* iter = CPbkContactIter::NewLC(*iEngine, ETrue); ASSERT(iter); TContactItemId id = iter->FirstL(); ASSERT(id == iAddedContactId); CPbkContactItem* item = iter->CurrentL(); ASSERT(item); CleanupStack::PopAndDestroy(iter); Teardown(); return KErrNone;} TInt CMTPbkContactIter::TestIterOnDbWithOneContactMinimalRead5L() { SetupWithContactL(); CPbkContactIter* iter = CPbkContactIter::NewLC(*iEngine, ETrue); ASSERT(iter); CPbkContactItem* item = iter->GetCurrentL(); ASSERT(!item); delete item; CleanupStack::PopAndDestroy(iter); Teardown(); return KErrNone;} TInt CMTPbkContactIter::TestIterOnDbWithOneContactMinimalRead6L() { SetupWithContactL(); CPbkContactIter* iter = CPbkContactIter::NewLC(*iEngine, ETrue); ASSERT(iter); TContactItemId id = iter->FirstL(); ASSERT(id == iAddedContactId); CPbkContactItem* item = iter->GetCurrentL(); ASSERT(item); delete item; CleanupStack::PopAndDestroy(iter); Teardown(); return KErrNone; } TInt CMTPbkContactIter::TestIterOnDbWith2ContactsL() { SetupWith2ContactL(); CPbkContactIter* iter1 = CPbkContactIter::NewLC(*iEngine); ASSERT(iter1); TContactItemId id = iter1->FirstL(); ASSERT(id == iAddedContactId); CleanupStack::PopAndDestroy(iter1); CPbkContactIter* iter2 = CPbkContactIter::NewLC(*iEngine); ASSERT(iter2); id = iter2->NextL(); ASSERT(id == iAddedContactId); CleanupStack::PopAndDestroy(iter2); CPbkContactIter* iter3 = CPbkContactIter::NewLC(*iEngine); ASSERT(iter3); id = iter3->FirstL(); ASSERT(id == iAddedContactId); id = iter3->NextL(); ASSERT(id == iAddedContactId2); CleanupStack::PopAndDestroy(iter3); CPbkContactIter* iter4 = CPbkContactIter::NewLC(*iEngine); ASSERT(iter4); CPbkContactItem* item = iter4->CurrentL(); ASSERT(!item); CleanupStack::PopAndDestroy(iter4); CPbkContactIter* iter5 = CPbkContactIter::NewLC(*iEngine); ASSERT(iter5); id = iter5->FirstL(); ASSERT(id == iAddedContactId); item = iter5->CurrentL(); ASSERT(item); ASSERT(item->Id() == iAddedContactId); id = iter5->NextL(); ASSERT(id == iAddedContactId2); item = iter5->CurrentL(); ASSERT(item); ASSERT(item->Id() == iAddedContactId2); CleanupStack::PopAndDestroy(iter5); CPbkContactIter* iter6 = CPbkContactIter::NewLC(*iEngine); ASSERT(iter6); item = iter6->GetCurrentL(); ASSERT(!item); delete item; CleanupStack::PopAndDestroy(iter6); CPbkContactIter* iter7 = CPbkContactIter::NewLC(*iEngine); ASSERT(iter7); id = iter7->FirstL(); ASSERT(id == iAddedContactId); item = iter7->GetCurrentL(); ASSERT(item); ASSERT(item->Id() == iAddedContactId); delete item; id = iter7->NextL(); ASSERT(id == iAddedContactId2); item = iter7->GetCurrentL(); ASSERT(item); ASSERT(item->Id() == iAddedContactId2); delete item; CleanupStack::PopAndDestroy(iter7); Teardown(); return KErrNone;} TInt CMTPbkContactIter::TestIterOnDbWith2ContactsMinimalReadL() { SetupWith2ContactL(); // read minimal CPbkContactIter* iter1 = CPbkContactIter::NewLC(*iEngine, ETrue); ASSERT(iter1); TContactItemId id = iter1->FirstL(); ASSERT(id == iAddedContactId); CleanupStack::PopAndDestroy(iter1); CPbkContactIter* iter2 = CPbkContactIter::NewLC(*iEngine, ETrue); ASSERT(iter2); id = iter2->NextL(); ASSERT(id == iAddedContactId); CleanupStack::PopAndDestroy(iter2); CPbkContactIter* iter3 = CPbkContactIter::NewLC(*iEngine, ETrue); ASSERT(iter3); id = iter3->FirstL(); ASSERT(id == iAddedContactId); id = iter3->NextL(); ASSERT(id == iAddedContactId2); CleanupStack::PopAndDestroy(iter3); CPbkContactIter* iter4 = CPbkContactIter::NewLC(*iEngine, ETrue); ASSERT(iter4); CPbkContactItem* item = iter4->CurrentL(); ASSERT(!item); CleanupStack::PopAndDestroy(iter4); CPbkContactIter* iter5 = CPbkContactIter::NewLC(*iEngine, ETrue); ASSERT(iter5); id = iter5->FirstL(); ASSERT(id == iAddedContactId); item = iter5->CurrentL(); ASSERT(item); ASSERT(item->Id() == iAddedContactId); id = iter5->NextL(); ASSERT(id == iAddedContactId2); item = iter5->CurrentL(); ASSERT(item); ASSERT(item->Id() == iAddedContactId2); CleanupStack::PopAndDestroy(iter5); CPbkContactIter* iter6 = CPbkContactIter::NewLC(*iEngine, ETrue); ASSERT(iter6); item = iter6->GetCurrentL(); ASSERT(!item); delete item; CleanupStack::PopAndDestroy(iter6); CPbkContactIter* iter7 = CPbkContactIter::NewLC(*iEngine, ETrue); ASSERT(iter7); id = iter7->FirstL(); ASSERT(id == iAddedContactId); item = iter7->GetCurrentL(); ASSERT(item); ASSERT(item->Id() == iAddedContactId); delete item; id = iter7->NextL(); ASSERT(id == iAddedContactId2); item = iter7->GetCurrentL(); ASSERT(item); ASSERT(item->Id() == iAddedContactId2); delete item; CleanupStack::PopAndDestroy(iter7); Teardown(); return KErrNone; } // [End of File] - Do not remove
[ "none@none" ]
[ [ [ 1, 568 ] ] ]
58bfbec85a9a39112ccee0394deea6b9d6675af2
c5ecda551cefa7aaa54b787850b55a2d8fd12387
/src/UILayer/CtrlEx/TabWndDef.h
2cb6b1a3404ca25f09c2194efeb0a5c66316cbaf
[]
no_license
firespeed79/easymule
b2520bfc44977c4e0643064bbc7211c0ce30cf66
3f890fa7ed2526c782cfcfabb5aac08c1e70e033
refs/heads/master
2021-05-28T20:52:15.983758
2007-12-05T09:41:56
2007-12-05T09:41:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
499
h
#pragma once enum ETabBarPos { TBP_LEFT, TBP_TOP, TBP_RIGHT, TBP_BOTTOM }; namespace TabWnd { void Real2Logic(CRect &rect, ETabBarPos eRealPos); void Logic2Real(CRect &rect, ETabBarPos eRealPos); inline void Real2LogicSolid(CRect &rect, ETabBarPos eRealPos) { rect.right--; rect.bottom--; Real2Logic(rect, eRealPos); } inline void LogicSolid2Real(CRect &rect, ETabBarPos eRealPos) { Logic2Real(rect, eRealPos); rect.right++; rect.bottom++; } }
[ "LanceFong@4a627187-453b-0410-a94d-992500ef832d" ]
[ [ [ 1, 28 ] ] ]
b43510b32fb4930c7b9548221bf246c22e20b359
d609fb08e21c8583e5ad1453df04a70573fdd531
/trunk/开发库/include/HAnimationGif.h
ab928f0f763db330656f59d480f129475464a84b
[]
no_license
svn2github/openxp
d68b991301eaddb7582b8a5efd30bc40e87f2ac3
56db08136bcf6be6c4f199f4ac2a0850cd9c7327
refs/heads/master
2021-01-19T10:29:42.455818
2011-09-17T10:27:15
2011-09-17T10:27:15
21,675,919
0
1
null
null
null
null
UTF-8
C++
false
false
6,411
h
#ifndef __HANIMATIONGIF__H__ #define __HANIMATIONGIF__H__ #include <vector> //#define GIF_TRACING // uncomment it if you want detailed TRACEs class TEMPLATE_CONTROL_API HAnimationGif : public CStatic { public: struct TFrame // structure that keeps a single frame info { IPicture *m_pPicture; // pointer to the interface used for drawing SIZE m_frameSize; SIZE m_frameOffset; UINT m_nDelay; // delay (in 1/100s of a second) UINT m_nDisposal; // disposal method }; #pragma pack(1) // turn byte alignment on enum GIFBlockTypes { BLOCK_UNKNOWN, BLOCK_APPEXT, BLOCK_COMMEXT, BLOCK_CONTROLEXT, BLOCK_PLAINTEXT, BLOCK_IMAGE, BLOCK_TRAILER }; enum ControlExtValues // graphic control extension packed field values { GCX_PACKED_DISPOSAL, // disposal method GCX_PACKED_USERINPUT, GCX_PACKED_TRANSPCOLOR }; enum LSDPackedValues // logical screen descriptor packed field values { LSD_PACKED_GLOBALCT, LSD_PACKED_CRESOLUTION, LSD_PACKED_SORT, LSD_PACKED_GLOBALCTSIZE }; enum IDPackedValues // image descriptor packed field values { ID_PACKED_LOCALCT, ID_PACKED_INTERLACE, ID_PACKED_SORT, ID_PACKED_LOCALCTSIZE }; struct TGIFHeader // GIF header { char m_cSignature[3]; // Signature - Identifies the GIF Data Stream // This field contains the fixed value 'GIF' char m_cVersion[3]; // Version number. May be one of the following: // "87a" or "89a" }; struct TGIFLSDescriptor // Logical Screen Descriptor { WORD m_wWidth; // 2 bytes. Logical screen width WORD m_wHeight; // 2 bytes. Logical screen height unsigned char m_cPacked; // packed field unsigned char m_cBkIndex; // 1 byte. Background color index unsigned char m_cPixelAspect; // 1 byte. Pixel aspect ratio inline int GetPackedValue(enum LSDPackedValues Value); }; struct TGIFAppExtension // application extension block { unsigned char m_cExtIntroducer; // extension introducer (0x21) unsigned char m_cExtLabel; // app. extension label (0xFF) unsigned char m_cBlockSize; // fixed value of 11 char m_cAppIdentifier[8]; // application identifier char m_cAppAuth[3]; // application authentication code }; struct TGIFControlExt // graphic control extension block { unsigned char m_cExtIntroducer; // extension introducer (0x21) unsigned char m_cControlLabel; // control extension label (0xF9) unsigned char m_cBlockSize; // fixed value of 4 unsigned char m_cPacked; // packed field WORD m_wDelayTime; // delay time unsigned char m_cTColorIndex; // transparent color index unsigned char m_cBlockTerm; // block terminator (0x00) public: inline int GetPackedValue(enum ControlExtValues Value); }; struct TGIFCommentExt // comment extension block { unsigned char m_cExtIntroducer; // extension introducer (0x21) unsigned char m_cCommentLabel; // comment extension label (0xFE) }; struct TGIFPlainTextExt // plain text extension block { unsigned char m_cExtIntroducer; // extension introducer (0x21) unsigned char m_cPlainTextLabel; // text extension label (0x01) unsigned char m_cBlockSize; // fixed value of 12 WORD m_wLeftPos; // text grid left position WORD m_wTopPos; // text grid top position WORD m_wGridWidth; // text grid width WORD m_wGridHeight; // text grid height unsigned char m_cCellWidth; // character cell width unsigned char m_cCellHeight; // character cell height unsigned char m_cFgColor; // text foreground color index unsigned char m_cBkColor; // text background color index }; struct TGIFImageDescriptor // image descriptor block { unsigned char m_cImageSeparator; // image separator byte (0x2C) WORD m_wLeftPos; // image left position WORD m_wTopPos; // image top position WORD m_wWidth; // image width WORD m_wHeight; // image height unsigned char m_cPacked; // packed field inline int GetPackedValue(enum IDPackedValues Value); }; #pragma pack() // turn byte alignment off public: BOOL GetPaintRect(RECT *lpRect); BOOL SetPaintRect(const RECT *lpRect); HAnimationGif(); virtual ~HAnimationGif(); void Stop(); // stops animation void UnLoad(); // stops animation plus releases all resources BOOL IsGIF() const; BOOL IsPlaying() const; BOOL IsAnimatedGIF() const; SIZE GetSize() const; int GetFrameCount() const; COLORREF GetBkColor() const; void SetBkColor(COLORREF clr); // draws the picture (starts an animation thread if needed) // if an animation was previously stopped by Stop(), // continues it from the last displayed frame BOOL Draw(); // loads a picture from a file // i.e. Load(_T("mypic.gif")); BOOL Load(LPCTSTR szFileName); // loads a picture from a global memory block (allocated by GlobalAlloc) // Warning: this function DOES NOT free the global memory, pointed to by hGlobal BOOL Load(HGLOBAL hGlobal, DWORD dwSize); // loads a picture from a program resource // i.e. Load(MAKEINTRESOURCE(IDR_MYPIC),_T("GIFTYPE")); BOOL Load(LPCTSTR szResourceName,LPCTSTR szResourceType); protected: #ifdef GIF_TRACING void EnumGIFBlocks(); void WriteDataOnDisk(CString szFileName, HGLOBAL hData, DWORD dwSize); #endif // GIF_TRACING RECT m_PaintRect; SIZE m_PictureSize; COLORREF m_clrBackground; UINT m_nCurrFrame; UINT m_nDataSize; UINT m_nCurrOffset; UINT m_nGlobalCTSize; BOOL m_bIsGIF; BOOL m_bIsPlaying; volatile BOOL m_bExitThread; BOOL m_bIsInitialized; HDC m_hMemDC; HDC m_hDispMemDC; HBITMAP m_hDispMemBM; HBITMAP m_hDispOldBM; HBITMAP m_hBitmap; HBITMAP m_hOldBitmap; HANDLE m_hThread; HANDLE m_hExitEvent; IPicture * m_pPicture; TGIFHeader * m_pGIFHeader; unsigned char * m_pRawData; TGIFLSDescriptor * m_pGIFLSDescriptor; std::vector<TFrame> m_arrFrames; void ThreadAnimation(); static UINT WINAPI _ThreadAnimation(LPVOID pParam); int GetNextBlockLen() const; BOOL SkipNextBlock(); BOOL SkipNextGraphicBlock(); BOOL PrepareDC(int nWidth, int nHeight); void ResetDataPointer(); enum GIFBlockTypes GetNextBlock() const; UINT GetSubBlocksLen(UINT nStartingOffset) const; HGLOBAL GetNextGraphicBlock(UINT *pBlockLen, UINT *pDelay, SIZE *pBlockSize, SIZE *pBlockOffset, UINT *pDisposal); afx_msg void OnDestroy(); afx_msg void OnPaint(); DECLARE_MESSAGE_MAP() }; #endif
[ "[email protected]@f92b348d-55a1-4afa-8193-148a6675784b" ]
[ [ [ 1, 217 ] ] ]
05133105e0a2ee1147e895a25d28f8151de9093a
20b20bdf31c1383d69edae0baf6b8c94f0a0251b
/Factorial.cpp
86fb93c4da74e8246828303e03cc5a3e5127d20b
[]
no_license
camilonova/Factorial
7428884f3a8de72b2830986e2292676bdc5e2215
9f4e814208f5d2918e373c75f9283c392cacdb66
refs/heads/master
2021-01-10T19:16:54.085789
2011-06-04T20:21:52
2011-06-04T20:21:52
1,848,038
0
0
null
null
null
null
UTF-8
C++
false
false
291
cpp
#include <iostream.h> int factorial(int a){ int resultado = 1; for(int i = 1; i <= a; i++){ resultado *= i; } return resultado; } void main(){ int numero; cout<< "Digite un numero:\t"; cin>> numero; cout<< "\nEl factorial es: " << factorial(numero); }
[ [ [ 1, 22 ] ] ]
0d191895d6af3fb65676393b749952c373b1685c
bef7d0477a5cac485b4b3921a718394d5c2cf700
/dingus/tools/MeshTexer/src/system/main.cpp
1a87ff1e2eae6b4dd51079e00fc26730b4db4dca
[ "MIT" ]
permissive
TomLeeLive/aras-p-dingus
ed91127790a604e0813cd4704acba742d3485400
22ef90c2bf01afd53c0b5b045f4dd0b59fe83009
refs/heads/master
2023-04-19T20:45:14.410448
2011-10-04T10:51:13
2011-10-04T10:51:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
817
cpp
#include "stdafx.h" #include "../demo/Demo.h" #include <dingus/app/DingusSystem.h> #include <dingus/utils/StringHelper.h> extern std::string gErrorMsg; INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR lpCmdLine, INT ) { try { CDemo* demo = new CDemo(); CDingusSystem* system = new CDingusSystem( *demo ); if( SUCCEEDED( system->create( hInst, false ) ) ) system->run(); delete demo; delete system; } catch( std::exception& e ) { std::string willExit = "\n\nThe application will now exit."; MessageBox( 0, (e.what()+willExit).c_str(), "Fatal error", MB_OK ); return 0; } if( !gErrorMsg.empty() ) { std::string willExit = "\n\nThe application will now exit."; MessageBox( 0, (gErrorMsg+willExit).c_str(), "Initialization error", MB_OK ); } return 0; }
[ [ [ 1, 29 ] ] ]
f54b31c9d88cfb8d13ac74c6c3b014eb3a018a63
ab4b2c5f98973babd82d47a4cf52f9701d85ea66
/src/qtree/AqlNodeCreator.h
6ad7bf0197e995edbc7c61df69f4e8d4ac353c92
[]
no_license
rodrigomicrosiga/AQL
033c1f1bd0d77275cd4561279c272c8b234becbe
cbc5a24828af779c46fb1ece740769a1d5fce338
refs/heads/master
2021-01-16T21:24:55.871464
2011-10-24T23:34:03
2011-10-24T23:34:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
175
h
#ifndef AQLNODECREATOR_H #define AQLNODECREATOR_H template<typename NodeT> class AqlNodeCreator { public: AqlNodeCreator(void); ~AqlNodeCreator(void); }; #endif
[ [ [ 1, 12 ] ] ]
14c15d9014a76ae287c0b2fac1106a5dc3e69398
2ca3ad74c1b5416b2748353d23710eed63539bb0
/Src/Lokapala/Raptor/NeverDieBI.h
28cc24e33275114ff821a0b055572ab1641a5093
[]
no_license
sjp38/lokapala
5ced19e534bd7067aeace0b38ee80b87dfc7faed
dfa51d28845815cfccd39941c802faaec9233a6e
refs/heads/master
2021-01-15T16:10:23.884841
2009-06-03T14:56:50
2009-06-03T14:56:50
32,124,140
0
0
null
null
null
null
UTF-8
C++
false
false
653
h
/**@file NeverDieBI.h * @brief NDM의 BI 정의. * @author siva */ #ifndef NEVERDIE_BI_H #define NEVERDIE_BI_H /**@ingroup GroupNDM * @class CNeverDieBI * @brief NeverDie Manager 의 Button Interface. * @remarks 인터페이다. */ class CNeverDieBI { public : /**@brief 절대 죽지 않게 한다. */ virtual void StartNeverDie() = 0; /**@brief 죽을 수도 있게 한다. */ virtual void StopNeverDie() = 0; /**@brief 죽을 수 있는지 죽어선 안되는지 알려준다. * @return 죽어선 안된다면 true, 죽어도 된다면 false */ virtual bool GetNeverDieState() = 0; }; #endif
[ "nilakantha38@b9e76448-5c52-0410-ae0e-a5aea8c5d16c" ]
[ [ [ 1, 30 ] ] ]
efd8f5291147d75c3bcd038575ee3aa629b593d0
de75637338706776f8770c9cd169761cec128579
/VHFOS/Simple Game Editor/CyoEncode.cpp
ff42c4167e4298ef3cd32a869819c06469e5866a
[]
no_license
huytd/fosengine
e018957abb7b2ea2c4908167ec83cb459c3de716
1cebb1bec49720a8e9ecae1c3d0c92e8d16c27c5
refs/heads/master
2021-01-18T23:47:32.402023
2008-07-12T07:20:10
2008-07-12T07:20:10
38,933,821
0
0
null
null
null
null
UTF-8
C++
false
false
2,385
cpp
////////////////////////////////////////////////////////////////////// // // CyoEncode.cpp // // Developed by Graham Bull for Cyotec Systems Limited. // http://www.cyotec.com // // Copyright (c) 2004 by Cyotec Systems Limited. All Rights Reserved. // // This source code may be used, modified, compiled, duplicated, and/or // distributed without restriction provided this copyright notice remains intact. // Cyotec Systems Limited and/or its employees cannot be held responsible for any // direct or indirect damage or loss of any kind that may result from using this // code, and provides no warranty, guarantee, or support. // // Associated Files // - CyoEncode.h // - CyoDecode.h // - CyoDecode.cpp // // History // - September 22, 2004 - Created // - November 04, 2004 - Not strictly ANSI compatible! // ////////////////////////////////////////////////////////////////////// #include "CyoEncode.h" #include <stdexcept> //for std::runtime_error #include <assert.h> //for assert() typedef unsigned char BYTE, *LPBYTE; typedef unsigned long DWORD; typedef const char* LPCSTR; //////////////////////////////////////// // Constants namespace CyoEncode { DWORD BASE16_INPUT = 1; DWORD BASE16_OUTPUT = 2; LPCSTR BASE16_TABLE = "0123456789ABCDEF"; const char* c_pszErrorInvalidParameter = "Invalid parameter"; } //////////////////////////////////////// // Base16 Encoding unsigned long CyoEncode::Base16EncodeGetLength( unsigned long size ) { // output 2 bytes for every 1 input: // 1 // 1 = ----1111 = 1111---- // 2 = ----1111 = ----1111 return (((size + BASE16_INPUT - 1) / BASE16_INPUT) * BASE16_OUTPUT); } unsigned long CyoEncode::Base16Encode( void* dest, const void* src, unsigned long size ) { if (!dest || !src) throw std::runtime_error( c_pszErrorInvalidParameter ); /// LPBYTE pSrc = (LPBYTE)src; LPBYTE pDest = (LPBYTE)dest; DWORD dwSrcSize = size; DWORD dwDestSize = 0; while (dwSrcSize >= 1) { // 1 input... BYTE ch = *pSrc++; dwSrcSize -= BASE16_INPUT; //1 // 2 outputs... *pDest++ = BASE16_TABLE[ (ch & 0xf0) >> 4 ]; *pDest++ = BASE16_TABLE[ (ch & 0x0f) ]; dwDestSize += BASE16_OUTPUT; //2 } return dwDestSize; }
[ "doqkhanh@52f955dd-904d-0410-b1ed-9fe3d3cbfe06" ]
[ [ [ 1, 87 ] ] ]
86240b3de5a7ef5d3f011c90499ab614458632a5
fc4946d917dc2ea50798a03981b0274e403eb9b7
/gentleman/gentleman/WindowsAPICodePack/WindowsAPICodePack/DirectX/DirectX/DXGI/DXGIFactory1.cpp
c7987bce9f2888e1f764be24c788d39575c4354f
[]
no_license
midnite8177/phever
f9a55a545322c9aff0c7d0c45be3d3ddd6088c97
45529e80ebf707e7299887165821ca360aa1907d
refs/heads/master
2020-05-16T21:59:24.201346
2010-07-12T23:51:53
2010-07-12T23:51:53
34,965,829
3
2
null
null
null
null
UTF-8
C++
false
false
1,779
cpp
// Copyright (c) Microsoft Corporation. All rights reserved. #include "stdafx.h" #include "DXGIFactory1.h" #include "DXGIAdapter1.h" #include "LibraryLoader.h" using namespace System::Collections::Generic; using namespace System::Collections::ObjectModel; using namespace Microsoft::WindowsAPICodePack::DirectX::DXGI; using namespace Microsoft::WindowsAPICodePack::DirectX::Direct3D; typedef HRESULT (*CreateDXGIFactory1FuncPtr)(REFIID riid, void **ppFactory); DXGIFactory1^ DXGIFactory1::CreateFactory1() { CreateDXGIFactory1FuncPtr createFuncPtr = (CreateDXGIFactory1FuncPtr) LibraryLoader::Instance()->GetFunctionfromDll( DXGILibrary, "CreateDXGIFactory1"); IDXGIFactory1 * factory = NULL; CommonUtils::VerifyResult( (*createFuncPtr)(__uuidof(IDXGIFactory1), (void**)(&factory))); return gcnew DXGIFactory1(factory); } ReadOnlyCollection<Adapter1^>^ DXGIFactory1::GetAdapters1() { IList<Adapter1^>^ adapters1Cache = gcnew List<Adapter1^>(); int i = 0; while (true) { IDXGIAdapter1* tempAdapter; if (DXGI_ERROR_NOT_FOUND != GetInterface<IDXGIFactory1>()->EnumAdapters1(i++, &tempAdapter)) adapters1Cache->Add(gcnew Adapter1(tempAdapter)); else break; } return gcnew ReadOnlyCollection<Adapter1^>(adapters1Cache); } Adapter1^ DXGIFactory1::GetAdapter1(UInt32 index) { IDXGIAdapter1* tempAdapter = NULL; CommonUtils::VerifyResult(GetInterface<IDXGIFactory1>()->EnumAdapters1(index, &tempAdapter)); return tempAdapter == NULL ? nullptr : gcnew Adapter1(tempAdapter); } Boolean DXGIFactory1::IsCurrent::get() { return GetInterface<IDXGIFactory1>()->IsCurrent() != 0; }
[ "lucemia@9e708c16-f4dd-11de-aa3c-59de0406b4f5" ]
[ [ [ 1, 59 ] ] ]
f6948b8285e62fbd009864e8611102d81384ec87
256259aae3b263991e496f97ea4ae49ade619fda
/zobject.cpp
676b678124967a8f5fb2314e978cafd948fdbfff
[]
no_license
majioa/zcl
a14cf2843ec2e1f1f3085ce6ac04fc1d2aebdbc1
833eafe1718939ca22f805bcaa200fc4bbf55a58
refs/heads/master
2021-01-10T18:40:31.817291
2004-07-19T03:39:57
2004-07-19T03:39:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
357
cpp
#include "zobject.h" #include "zcomponent.h" //public __fastcall ZObject::ZObject() { } __fastcall ZObject::~ZObject() { } void __fastcall ZObject::MessageHandler(ZCommand *Command) { } //public __fastcall ZComplexObject::ZComplexObject(ZComponent *Owner) { FOwner = Owner; } __fastcall ZComplexObject::~ZComplexObject() { }
[ [ [ 1, 25 ] ] ]
495407ee3025642db35c1d3bff288dbc8c759c85
cfa6cdfaba310a2fd5f89326690b5c48c6872a2a
/Sources/Library/wsock/wsock/ClientSock.cpp
d3cf95a79428394b3d1ecacfca3755e94d03754c
[]
no_license
asdlei00/project-jb
1cc70130020a5904e0e6a46ace8944a431a358f6
0bfaa84ddab946c90245f539c1e7c2e75f65a5c0
refs/heads/master
2020-05-07T21:41:16.420207
2009-09-12T03:40:17
2009-09-12T03:40:17
40,292,178
0
0
null
null
null
null
UTF-8
C++
false
false
1,949
cpp
// ClientSock.cpp : implementation file // #include "stdafx.h" #include "ClientSock.h" #ifdef _DEBUG #define new DEBUG_NEW #endif ///////////////////////////////////////////////////////////////////////////// // CClientSock CClientSock::CClientSock() { m_bConnect = false; m_Tag = -1; } CClientSock::~CClientSock() { } // Do not edit the following lines, which are needed by ClassWizard. #if 0 BEGIN_MESSAGE_MAP(CClientSock, CAsyncSocket) //{{AFX_MSG_MAP(CClientSock) //}}AFX_MSG_MAP END_MESSAGE_MAP() #endif // 0 ///////////////////////////////////////////////////////////////////////////// // CClientSock member functions void CClientSock::OnReceive(int nErrorCode) { // TODO: Add your specialized code here and/or call the base class if(nErrorCode == 0) SendMessage(g_ClienthWnd, WM_CLIENT_RECEIVE, (WPARAM) m_hSocket, (LPARAM) m_Tag); else if(nErrorCode == WSAENETDOWN) { SendMessage(g_ClienthWnd, WM_CLIENT_NETDOWN, (WPARAM) m_hSocket, (LPARAM) m_Tag); } CAsyncSocket::OnReceive(nErrorCode); } void CClientSock::OnSend(int nErrorCode) { // TODO: Add your specialized code here and/or call the base class if(nErrorCode == 0) SendMessage(g_ClienthWnd, WM_CLIENT_SEND, (WPARAM) m_hSocket, (LPARAM) m_Tag); else if(nErrorCode == WSAENETDOWN) { SendMessage(g_ClienthWnd, WM_CLIENT_SEND_ERROR, (WPARAM) m_hSocket, (LPARAM) m_Tag); } CAsyncSocket::OnReceive(nErrorCode); } void CClientSock::OnConnect(int nErrorCode) { if(nErrorCode == 0) { SendMessage(g_ClienthWnd, WM_CLIENT_CONNECT, (WPARAM) m_hSocket, 0); m_bConnect = true; } //else m_bConnect = false; CAsyncSocket::OnConnect(nErrorCode); } void CClientSock::OnClose(int nErrorCode) { if(nErrorCode == 0) { SendMessage(g_ClienthWnd, WM_CLIENT_CLOSE, (WPARAM) m_hSocket, (LPARAM) m_Tag); m_bConnect = false; } CAsyncSocket::OnClose(nErrorCode); }
[ [ [ 1, 86 ] ] ]
91db54ccbd74aa2acfcdae2f4b440cf80981e78e
29865754df7cc23c8bb5012ef8bf75f79ef20917
/include/StateManager.h
c77223325d337c27d11bd2ab305b7078590acf2e
[]
no_license
safetydank/Hexpad
b9e10ccf202b31e5662b9436fc8e9666470ff0ed
52b231fd0a6ccd03abc7a0fc729a41c7ab946598
refs/heads/master
2020-06-03T05:05:55.312896
2011-02-10T23:58:20
2011-02-10T23:58:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,422
h
#pragma once #include "boost/smart_ptr.hpp" #include "cinder/app/KeyEvent.h" #include "cinder/app/MouseEvent.h" #include <map> #include <string> namespace war { struct Shared; typedef boost::shared_ptr<Shared> SharedPtr; class StateManager; class State { public: State(StateManager& manager, Shared& shared) : mManager(manager), GG(shared) { } virtual void enter() = 0; virtual void leave() = 0; virtual void update() = 0; virtual void draw() = 0; // Optional event handlers virtual void keyDown(ci::app::KeyEvent event) {} virtual void mouseMove(ci::app::MouseEvent event) {} virtual void mouseDown(ci::app::MouseEvent event) {} virtual void mouseUp(ci::app::MouseEvent event) {} virtual void mouseDrag(ci::app::MouseEvent event) {} virtual void mouseWheel(ci::app::MouseEvent event) {} protected: StateManager& mManager; Shared& GG; }; typedef boost::shared_ptr<State> StatePtr; class StateManager { public: StateManager(SharedPtr share); ~StateManager(); void setupStates(); void setActiveState(std::string stateName); StatePtr getActiveState() { return mActiveState; } void update(); void draw(); private: std::map<std::string, StatePtr> mStates; StatePtr mActiveState; SharedPtr GG; }; typedef boost::shared_ptr<StateManager> StateManagerPtr; }
[ [ [ 1, 61 ] ] ]
ea012a044f853c0f18a60a205755ed01f3af9fd4
b1e800acd184fa242d13f877cc06fe11bdc407e4
/src/RainbowTableGenerate.cpp
aeb613d57aa469263205fa3edcdec8a32037a6a3
[]
no_license
johnjohnsp1/rainbowcrack-mc
2644a96a7c921ab4beea8a2ac1d0720b69b04336
7eeaf556bcf7ad9b81abac0749ecd07e045efc09
refs/heads/master
2021-05-29T00:40:18.079162
2009-08-17T14:18:29
2009-08-17T14:18:29
117,212,271
0
1
null
2018-01-12T08:03:50
2018-01-12T08:03:50
null
UTF-8
C++
false
false
6,887
cpp
/* RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique. Copyright (C) Zhu Shuanglei <[email protected]> */ #ifdef _WIN32 #pragma warning(disable : 4786) #endif #ifdef _WIN32 #include <windows.h> #else #include <unistd.h> #include <string.h> #include <stdlib.h> #endif #include <time.h> #include "ChainWalkContext.h" void Usage() { Logo(); printf("usage: rtgen hash_algorithm \\\n"); printf(" plain_charset plain_len_min plain_len_max \\\n"); printf(" rainbow_table_index \\\n"); printf(" rainbow_chain_length rainbow_chain_count \\\n"); printf(" file_title_suffix\n"); printf(" rtgen hash_algorithm \\\n"); printf(" plain_charset plain_len_min plain_len_max \\\n"); printf(" rainbow_table_index \\\n"); printf(" -bench\n"); printf("\n"); CHashRoutine hr; printf("hash_algorithm: available: %s\n", hr.GetAllHashRoutineName().c_str()); printf("plain_charset: use any charset name in charset.txt here\n"); printf(" use \"byte\" to specify all 256 characters as the charset of the plaintext\n"); printf("plain_len_min: min length of the plaintext\n"); printf("plain_len_max: max length of the plaintext\n"); printf("rainbow_table_index: index of the rainbow table\n"); printf("rainbow_chain_length: length of the rainbow chain\n"); printf("rainbow_chain_count: count of the rainbow chain to generate\n"); printf("file_title_suffix: the string appended to the file title\n"); printf(" add your comment of the generated rainbow table here\n"); printf("-bench: do some benchmark\n"); printf("\n"); printf("example: rtgen lm alpha 1 7 0 100 16 test\n"); printf(" rtgen md5 byte 4 4 0 100 16 test\n"); printf(" rtgen sha1 numeric 1 10 0 100 16 test\n"); printf(" rtgen lm alpha 1 7 0 -bench\n"); } void Bench(string sHashRoutineName, string sCharsetName, int nPlainLenMin, int nPlainLenMax, int nRainbowTableIndex) { // Setup CChainWalkContext if (!CChainWalkContext::SetHashRoutine(sHashRoutineName)) { printf("hash routine %s not supported\n", sHashRoutineName.c_str()); return; } if (!CChainWalkContext::SetPlainCharset(sCharsetName, nPlainLenMin, nPlainLenMax)) return; if (!CChainWalkContext::SetRainbowTableIndex(nRainbowTableIndex)) { printf("invalid rainbow table index %d\n", nRainbowTableIndex); return; } // Bench hash { CChainWalkContext cwc; cwc.GenerateRandomIndex(); cwc.IndexToPlain(); clock_t t1 = clock(); int nLoop = 25000000; int i; for (i = 0; i < nLoop; i++) cwc.PlainToHash(); clock_t t2 = clock(); float fTime = 1.0f * (t2 - t1) / CLOCKS_PER_SEC; printf("%s hash speed: %d / s\n", sHashRoutineName.c_str(), int(nLoop / fTime)); } // Bench step { CChainWalkContext cwc; cwc.GenerateRandomIndex(); clock_t t1 = clock(); int nLoop = 25000000; int i; for (i = 0; i < nLoop; i++) { cwc.IndexToPlain(); cwc.PlainToHash(); cwc.HashToIndex(i); } clock_t t2 = clock(); float fTime = 1.0f * (t2 - t1) / CLOCKS_PER_SEC; printf("%s step speed: %d / s\n", sHashRoutineName.c_str(), int(nLoop / fTime)); } } int main(int argc, char* argv[]) { if (argc == 7) { if (strcmp(argv[6], "-bench") == 0) { Bench(argv[1], argv[2], atoi(argv[3]), atoi(argv[4]), atoi(argv[5])); return 0; } } if (argc != 9) { Usage(); return 0; } string sHashRoutineName = argv[1]; string sCharsetName = argv[2]; int nPlainLenMin = atoi(argv[3]); int nPlainLenMax = atoi(argv[4]); int nRainbowTableIndex = atoi(argv[5]); int nRainbowChainLen = atoi(argv[6]); int nRainbowChainCount = atoi(argv[7]); string sFileTitleSuffix = argv[8]; // nRainbowChainCount check if (nRainbowChainCount >= 134217728) { printf("this will generate a table larger than 2GB, which is not supported\n"); printf("please use a smaller rainbow_chain_count(less than 134217728)\n"); return 0; } // Setup CChainWalkContext if (!CChainWalkContext::SetHashRoutine(sHashRoutineName)) { printf("hash routine %s not supported\n", sHashRoutineName.c_str()); return 0; } if (!CChainWalkContext::SetPlainCharset(sCharsetName, nPlainLenMin, nPlainLenMax)) return 0; if (!CChainWalkContext::SetRainbowTableIndex(nRainbowTableIndex)) { printf("invalid rainbow table index %d\n", nRainbowTableIndex); return 0; } CChainWalkContext::Dump(); // Low priority #ifdef _WIN32 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE); #else nice(19); #endif // FileName char szFileName[256]; sprintf(szFileName, "%s_%s#%d-%d_%d_%dx%d_%s.rt", sHashRoutineName.c_str(), sCharsetName.c_str(), nPlainLenMin, nPlainLenMax, nRainbowTableIndex, nRainbowChainLen, nRainbowChainCount, sFileTitleSuffix.c_str()); // Open file fclose(fopen(szFileName, "a")); FILE* file = fopen(szFileName, "r+b"); if (file == NULL) { printf("failed to create %s\n", szFileName); return 0; } // Check existing chains unsigned int nDataLen = GetFileLen(file); nDataLen = nDataLen / 16 * 16; if (nDataLen == nRainbowChainCount * 16) { printf("precomputation of this rainbow table already finished\n"); fclose(file); return 0; } if (nDataLen > 0) printf("continuing from interrupted precomputation...\n"); fseek(file, nDataLen, SEEK_SET); unsigned int nChainStart = 0; // Generate rainbow table printf("generating...\n"); CChainWalkContext cwc; nChainStart += nDataLen / 16; clock_t t1 = clock(); int i; for (i = nDataLen / 16; i < nRainbowChainCount; i++) { // cwc.GenerateRandomIndex(); cwc.SetIndex(nChainStart++); // Use predictable stating points uint64 nIndex = cwc.GetIndex(); if (fwrite(&nIndex, 1, 8, file) != 8) { printf("disk write fail\n"); break; } int nPos; for (nPos = 0; nPos < nRainbowChainLen - 1; nPos++) { cwc.IndexToPlain(); cwc.PlainToHash(); cwc.HashToIndex(nPos); } nIndex = cwc.GetIndex(); if (fwrite(&nIndex, 1, 8, file) != 8) { printf("disk write fail\n"); break; } if ((i + 1) % 100000 == 0 || i + 1 == nRainbowChainCount) { clock_t t2 = clock(); int nSecond = (t2 - t1) / CLOCKS_PER_SEC; printf("%d of %d rainbow chains generated (%d m %d s)\n", i + 1, nRainbowChainCount, nSecond / 60, nSecond % 60); t1 = clock(); } } // Close fclose(file); return 0; }
[ "mcotdp@60e29272-8b2e-11de-b841-6521bc8c149b" ]
[ [ [ 1, 251 ] ] ]
73483e109387b218c7c0d094837e5a8038480a75
0c1f669f3dfdab47085bf537348b0354f836abea
/ qtremotedroid/QtRemoteDroidClient/src/main.cpp
5a697946d63bd3eedf962bc3dad97db99f3bf423
[]
no_license
harlentan/qtremotedroid
fc5fc96d4374c39561aea73470a88d1f0a68b637
d07dd045213711538b38c7ced2fd6d5a8edcf241
refs/heads/master
2021-01-10T11:37:59.331004
2010-12-12T09:55:39
2010-12-12T09:55:39
54,114,402
0
0
null
null
null
null
UTF-8
C++
false
false
892
cpp
#include <QtGui/QApplication> #include "start.h" #include <QDesktopWidget> int main(int argc, char *argv[]) { QApplication a(argc, argv); start swind; /* swind.resize(swind.sizeHint()); int desktopArea = QApplication::desktop()->width() * QApplication::desktop()->height(); int widgetArea = swind.width() * swind.height(); if (((float)widgetArea / (float)desktopArea) < 0.75f) swind.show(); else swind.showMaximized();*/ swind.show(); swind.showFullScreen(); return a.exec(); } /* int desktopArea = QApplication::desktop()->width() * QApplication::desktop()->height(); int widgetArea = window.width() * window.height(); if (((float)widgetArea / (float)desktopArea) < 0.75f) window.show(); else window.showMaximized(); */
[ [ [ 1, 34 ] ] ]
f19a753c6c4e62c4b7e9d2670d94cc3e2e98e242
6c8c4728e608a4badd88de181910a294be56953a
/InventoryModule/WebdavInventoryDataModel.h
a0a76d6bc68b452dd26519a617ac747054dd6223
[ "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
4,946
h
// For conditions of distribution and use, see copyright notice in license.txt /** * @file WebDavInventoryDataModel.h * @brief Data model providing the WebDAV inventory model backend functionality. */ #ifndef incl_InventoryModule_WebDavInventoryDataModel_h #define incl_InventoryModule_WebDavInventoryDataModel_h #include "AbstractInventoryDataModel.h" #include "InventoryFolder.h" #include "PythonQt.h" namespace Inventory { class WebDavInventoryDataModel : public AbstractInventoryDataModel { Q_OBJECT public: /// Constructor /// @param identityUrl /// @param hostUrl WebDavInventoryDataModel(const QString &identityUrl, const QString &hostUrl); /// Destructor. virtual ~WebDavInventoryDataModel(); /// AbstractInventoryDataModel override. AbstractInventoryItem *GetFirstChildFolderByName(const QString &searchName) const; /// AbstractInventoryDataModel override. AbstractInventoryItem *GetChildFolderById(const QString &searchId) const; /// AbstractInventoryDataModel override. AbstractInventoryItem *GetChildAssetById(const QString &searchId) const; /// AbstractInventoryDataModel override. AbstractInventoryItem *GetChildById(const QString &searchId) const; /// AbstractInventoryDataModel override. AbstractInventoryItem *GetOrCreateNewFolder(const QString &id, AbstractInventoryItem &parentFolder, const QString &name = "New Folder", const bool &notify_server = true); /// AbstractInventoryDataModel override. AbstractInventoryItem *GetOrCreateNewAsset(const QString &inventory_id, const QString &asset_id, AbstractInventoryItem &parentFolder, const QString &name = "New Asset"); public slots: /// AbstractInventoryDataModel override. bool FetchInventoryDescendents(AbstractInventoryItem *item); /// AbstractInventoryDataModel override. void NotifyServerAboutItemMove(AbstractInventoryItem *item); /// AbstractInventoryDataModel override. void NotifyServerAboutItemCopy(AbstractInventoryItem *item); /// AbstractInventoryDataModel override. void NotifyServerAboutItemRemove(AbstractInventoryItem *item); /// AbstractInventoryDataModel override. void NotifyServerAboutItemUpdate(AbstractInventoryItem *item, const QString &old_name); /// AbstractInventoryDataModel override. AbstractInventoryItem *GetRoot() const { return rootFolder_; } /// AbstractInventoryDataModel override. AbstractInventoryItem *GetTrashFolder() const { return 0; }; /// AbstractInventoryDataModel override. bool OpenItem(AbstractInventoryItem *item); /// AbstractInventoryDataModel override. void UploadFile(const QString &filename, AbstractInventoryItem *parent_folder); /// AbstractInventoryDataModel override. void UploadFiles(QStringList &filenames, QStringList &item_names, AbstractInventoryItem *parent_folder); /// AbstractInventoryDataModel override. void UploadFilesFromBuffer(QStringList &filenames, QVector<QVector<uchar> > &buffers, AbstractInventoryItem *parent_folder); /// AbstractInventoryDataModel override. void DownloadFile(const QString &store_folder, AbstractInventoryItem *selected_item); /// AbstractInventoryDataModel override. bool GetUseTrashFolder() const { return false; } private: Q_DISABLE_COPY(WebDavInventoryDataModel); // Init PythonQt for usage bool InitPythonQt(); // Upload data from buffer void UploadBuffer(const QString &filename, QByteArray& buffer, AbstractInventoryItem *parent_folder); /// Fetch webdav inventory url with users identity /// @return bool true if succeeded otherwise false bool FetchWebdavUrlWithIdentity(); /// Fetch initial root folder void FetchRootFolder(); /// Fallback on error situations void ErrorOccurredCreateEmptyRootFolder(); /// Validate folder path, prepares it for pthon webdav library usage /// @param path Path to be validated. QString ValidateFolderPath(QString path); /// Related urls to store for fetching webdav url and accessing webdav QString identityUrl_; QString hostUrl_; QString webdavIdentityUrl_; QString webdavUrl_; /// The root folder. InventoryFolder *rootFolder_; /// Pointer to PythonQt main module PythonQtObjectPtr pythonQtMainModule_; /// WebDAV client pointer. PythonQtObjectPtr webdavclient_; }; } #endif // incl_InventoryModule_WebDavInventoryDataModel_h
[ "jonnenau@5b2332b8-efa3-11de-8684-7d64432d61a3", "jaakkoallander@5b2332b8-efa3-11de-8684-7d64432d61a3", "Stinkfist0@5b2332b8-efa3-11de-8684-7d64432d61a3", "[email protected]@5b2332b8-efa3-11de-8684-7d64432d61a3", "cadaver@5b2332b8-efa3-11de-8684-7d64432d61a3" ]
[ [ [ 1, 3 ], [ 6, 7 ], [ 10, 17 ], [ 21, 21 ], [ 27, 27 ], [ 32, 50 ], [ 52, 52 ], [ 54, 66 ], [ 68, 69 ], [ 78, 78 ], [ 87, 88 ], [ 94, 94 ], [ 97, 97 ], [ 104, 104 ], [ 107, 107 ], [ 110, 111 ], [ 114, 114 ], [ 120, 120 ], [ 122, 123 ], [ 130, 131 ] ], [ [ 4, 5 ], [ 8, 9 ], [ 18, 20 ], [ 22, 26 ], [ 28, 31 ], [ 53, 53 ], [ 67, 67 ], [ 70, 77 ], [ 79, 79 ], [ 81, 86 ], [ 89, 93 ], [ 95, 96 ], [ 101, 103 ], [ 105, 106 ], [ 108, 109 ], [ 112, 113 ], [ 115, 119 ], [ 121, 121 ], [ 124, 129 ], [ 132, 132 ] ], [ [ 51, 51 ] ], [ [ 80, 80 ] ], [ [ 98, 100 ] ] ]
682349b7c4830029e20c1d92d38072e0be24e651
2ca3ad74c1b5416b2748353d23710eed63539bb0
/Pilot/Lokapala_Communication/Raptor/CommunicationBI.h
f7bdc869aaa2c619d31238a6e811af7ddbc373ed
[]
no_license
sjp38/lokapala
5ced19e534bd7067aeace0b38ee80b87dfc7faed
dfa51d28845815cfccd39941c802faaec9233a6e
refs/heads/master
2021-01-15T16:10:23.884841
2009-06-03T14:56:50
2009-06-03T14:56:50
32,124,140
0
0
null
null
null
null
UHC
C++
false
false
593
h
/**@file CommunicationBI.h * @brief CCM의 Button Interface 정의 * @author siva */ #ifndef COMMUNICATION_BI_H #define COMMUNICATION_BI_H /**@ingroup GroupCCM * @class CCommunicationBI * @brief Communication Manager의 Button Interface.\n Mediator에게 자신을 노출하여 Mediator로부터 CCM으로의 인터페이스를 공개한다. * @remarks 인터페이스일 뿐으로, Facade가 상속한다. */ class CCommunicationBI { public : virtual void Initiallize(DWORD a_ServerAddress) = 0; virtual void SendTextMessage(CString a_message) = 0; }; #endif
[ "nilakantha38@b9e76448-5c52-0410-ae0e-a5aea8c5d16c" ]
[ [ [ 1, 21 ] ] ]
53e4bb072f6160a5f4ba2230f5e7dd4a47a5d2a7
36bf908bb8423598bda91bd63c4bcbc02db67a9d
/Include/CConnectedSock.h
4d7be637e4b4d37ca37103db217802cc3495a091
[]
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,177
h
/* CConnectedSock.h Classi per la gestione delle connessioni TCP/IP (lato client) - versione bloccante (SDK/MFC). Luca Piergentili, 20/01/00 [email protected] */ #ifndef _CCONNECTEDSOCK_H #define _CCONNECTEDSOCK_H 1 #include "window.h" #include "CThread.h" #include "CSock.h" /* CConnectedSocket Classe base per la gestione delle connessioni TCP/IP (lato client). Crea l'oggetto basico per il socket in connessione. Gli oggetti di tale tipo devono essere gestiti (attraverso una lista) da una classe che deve essere fatta derivare da CListeningSocket. */ class CConnectedSocket { public: CConnectedSocket(); virtual ~CConnectedSocket(); void Reset (void); // socket inline void SetSocket (CSock* pSocket) {m_pSocket = pSocket;} inline CSock* GetSocket (void) const {return(m_pSocket);} // thread inline void SetThread (CThread* pThread) {m_pThread = pThread;} inline CThread* GetThread (void) const {return(m_pThread);} private: CSock* m_pSocket; // socket in connessione CThread* m_pThread; // thread per le operazioni di I/O sul socket in connessione }; #endif // _CCONNECTEDSOCK_H
[ [ [ 1, 43 ] ] ]
7a785213073ff9b36f541856d8cff6d246e64efc
11ba7667109ae553162c7329bcd2f4902d841a66
/AugmentedTowerDefense/include/VideoDeviceManager.h
d3d44d838b3f78d0ad7c04eaad750afa208bb3ef
[]
no_license
abmantis/AugmentedTowerDefense
3cd8761034a98667a34650f6a476beb59aa7e818
00008495f538e0d982c0eae3025d02ae21e3dee2
refs/heads/master
2021-01-01T18:37:10.678181
2011-02-09T23:09:51
2011-02-09T23:09:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,654
h
#ifndef VideoDeviceManager_h__ #define VideoDeviceManager_h__ /* //Example 1 VideoDeviceManager vdm; if (vdm.size() > 0) { VideoDevice* device = vdm[0]; device->init(640, 480, 60); device->showControlPanel(); device->update(); //on app loop device->shutdown(); } //Example 2 VideoDeviceManager vdm; cout << vdm.size() << " device(s) found"<<endl; for (unsigned int i=0; i<vdm.size(); ++i) { VideoDevice* device = vdm[i]; cout << "["<<i<<"] " <<device->getName()<<endl; } */ class VideoDeviceManager; class VideoDevice { public: bool init(int width = 640, int height = 480, int fps = 60); bool update(); void shutdown(); void showControlPanel(); std::string getName() const; int getWidth() const; int getHeight() const; size_t getBufferSize() const; void* getBufferData() const; void createTexture(const std::string name); bool IsWorking() {return mIsWorking;} protected: VideoDevice(VideoDeviceManager* manager, int index); ~VideoDevice(); VideoDeviceManager* mManager; int mIndex; bool mIsWorking; std::string mName; int mWidth; int mHeight; size_t mBufferSize; unsigned char* mBuffer; Ogre::TexturePtr mTexture; Ogre::PixelBox mPixelBox; friend class VideoDeviceManager; }; class VideoDeviceManager { public: VideoDeviceManager(); ~VideoDeviceManager(); unsigned int size() const; VideoDevice* operator[](int index); protected: videoInput* mVideoInput; std::vector<VideoDevice*> mDevices; friend class VideoDevice; }; #endif // VideoDeviceManager_h__
[ [ [ 1, 86 ] ] ]
ac51edb998f666222fe56483b56b24a152e2c5be
e947bc69d8ee60ab0f1ccf28c9943027fa43f397
/ThemeHelper.h
19bf4154ffbb42a01b7c21366d555290bc5b7fa8
[]
no_license
losywee/yjui
fc33d8034d707a6663afef6cb8b55b1483992fc5
caeea083b91597f7f3c46cb9e69dcb009258649a
refs/heads/master
2021-01-10T07:35:15.909900
2010-04-01T09:14:23
2010-04-01T09:14:23
45,093,947
0
0
null
null
null
null
UTF-8
C++
false
false
3,469
h
#pragma once #if (WINVER < 0x0500) # define DFCS_TRANSPARENT 0x0800 # define DFCS_HOT 0x1000 # define DFC_POPUPMENU 5 #endif class AFX_EXT_CLASS CThemeHelper { public: CThemeHelper(CWnd* pWnd = NULL, LPCTSTR szClassList = NULL); virtual ~CThemeHelper(); BOOL AreControlsThemed(); BOOL IsNonClientThemed(); BOOL IsWebContentThemed(); static BOOL DrawFrameControl(const CWnd* pWnd, CDC* pDC, LPRECT pRect, UINT nType, UINT nState, LPCRECT prClip = NULL); static BOOL DrawEdge(const CWnd* pWnd, CDC* pDC, LPRECT pRect, UINT nType, UINT nState, UINT nEdge, UINT nFlags); static BOOL DrawCaption(const CWnd* pWnd, CDC* pDC, LPRECT pRect, UINT nFlags); BOOL Open(const CWnd* pWnd, LPCTSTR szClassList); BOOL IsValid() { return (s_hUxTheme && m_hTheme); } BOOL Close(); BOOL DrawParentBackground(const CWnd* pWnd, CDC* pDC, LPRECT pRect = NULL); BOOL DrawBackground(CDC* pDC, int nPart, int nState, const CRect& rect, LPCRECT prClip = NULL); BOOL DrawText(CDC* pDC, int nPart, int nState, const CString& sText, DWORD dwTextFlags, DWORD dwTextFlags2, const CRect& pRect); BOOL DrawEdge(CDC* pDC, int nPart, int nState, const CRect& rDest, UINT nEdge, UINT nFlags, LPRECT prContent = NULL); BOOL DrawIcon(CDC* pDC, int nPart, int nState, const CRect& rect, const CImageList* pIL, int nImage); BOOL DrawBorder(CDC* pDC, int nState, const CRect& rect); BOOL GetSize(int nPart, int nState, CSize& size, BOOL bMin = FALSE); BOOL GetTextExtent(CDC* pDC, int nPart, int nState, const CString& sText, DWORD dwTextFlags, CRect& rExtent, LPCRECT prBounding = NULL); BOOL BuildImageList(CImageList& il, int nPart, const int nStates[], int nNumStates, COLORREF crMask = 255); COLORREF GetThemeColor(int nPart, int nState, int nProp); BOOL GetThemeBackgroundContentRect(CDC* pDC, int nPart, int nState, const CRect& rBounding, CRect& rContent); protected: static HMODULE s_hUxTheme; HTHEME m_hTheme; HWND m_hWnd; protected: BOOL SupportsTheming(int nFlag); BOOL IsThemeActive(); BOOL InitUxTheme(); // uxtheme functions DWORD GetAppThemeProperties(); HTHEME OpenThemeData(HWND hwnd, LPCWSTR pszClassList); BOOL CloseThemeData(HTHEME hTheme); BOOL DrawThemeBackground(HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect); BOOL DrawThemeParentBackground(HWND hWnd, HDC hdc, RECT *pRect); BOOL DrawThemeText(HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect); BOOL DrawThemeEdge(HDC hdc, int iPartId, int iStateId, const RECT *pDestRect, UINT uEdge, UINT uFlags, RECT *pContentRect); BOOL DrawThemeIcon(HDC hdc, int iPartId, int iStateId, const RECT *pRect, HIMAGELIST himl, int iImageIndex); BOOL DrawThemeBorder(HDC hdc, int iStateId, const RECT *pRect); BOOL GetThemePartSize(int iPartId, int iStateId, THEMESIZE eSize, SIZE *psz); BOOL GetThemeTextExtent(HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, const RECT *pBoundingRect, RECT *pExtentRect); BOOL GetThemeColor(int iPartId, int iStateId, int iPropId, COLORREF *pColor); BOOL GetThemeBackgroundContentRect(HDC hdc, int iPartId, int iStateId, LPCRECT pBoundingRect, LPRECT pContentRect); // helpers static BOOL GetThemeClassPartState(int nType, int nState, CString& sThClass, int& nThPart, int& nThState); };
[ "Caiyj.84@3d1e88fc-ca97-11de-9d4f-f947ee5921c8" ]
[ [ [ 1, 74 ] ] ]
3973e383034c0a32bf46ca000f94e624b7011bb8
cf3401b4551d09b211d255c9614daaa05ce4d2e3
/src/include/k_std/list.h
6fd9e14831018547a464b58703240b437850a68e
[]
no_license
wspeirs/Mooose
0e6767dc27195ce3d6b9a6a789e70a80f0e0a489
c621d55a716033f24e6d4d81d55823685c6a7465
refs/heads/master
2020-05-13T07:41:08.620646
2010-07-27T02:44:59
2010-07-27T02:44:59
767,633
3
0
null
null
null
null
UTF-8
C++
false
false
10,418
h
#ifndef _K_LIST_H #define _K_LIST_H #include <types.h> #include <constants.h> #include <comparitors.h> #ifdef UNIT_TEST #include <stdio.h> #endif // define the namespace namespace k_std { // this is the typename for the objects in the list template<typename T> class list { protected: struct ListObj; public: // prototypes class iterator; friend class iterator; list(); // default constructor explicit list(uint n); // make n objects of T() explicit list(uint n, const T &t); // make n copies of t list(const list<T> &arg); // copy constructor list(const iterator &f, const iterator &l); // copy a range of another list ~list(); // destructor void push_back(const T &arg) { insert(end(), arg); } void push_front(const T &arg) { insert(begin(), arg); } void pop_back() { erase(--end()); } void pop_front() { erase(begin()); } iterator insert(iterator pos, const T &arg); void insert(iterator pos, const uint n, const T &arg); void insert(iterator pos, const iterator f, const iterator l); iterator erase(iterator pos); void erase(iterator f, iterator l); T &front() { return(head->obj); } T &back() { return(tail->prev->obj); } void clear(void); inline uint size(void) const { return lSize; } inline bool empty(void) const { return(lSize == 0); } list<T> &operator=(const list<T> &right); void swap(iterator r, iterator l); // swap right & left void sort(void); template<typename Comparitor> void sort(Comparitor cmp); void DebugPrint() { ListObj *tmp = head; printf("HEAD: 0x%x TAIL: 0x%x\n", head, tail); for( ; tmp != tail; tmp = tmp->next) printf("0x%x <- 0x%x -> 0x%x\n", tmp->prev, tmp, tmp->next); printf("0x%x <- TAIL: 0x%x -> 0x%x\n", tail->prev, tail, tail->next); } // // Iterator // class iterator { public: friend class list; iterator() : ptr(NULL) { ; } // constructor iterator(const iterator &it) : ptr(it.ptr) { ; } T &operator*() const { return(ptr->obj); } // return reference to the object iterator& operator++()// preincrement { ptr = ptr->next; return(*this); } iterator operator++(int) // postincrement { iterator tmp(*this); ++*this; return(tmp); } iterator& operator--() //predecriment { ptr = ptr->prev; return(*this); } iterator operator--(int) // postdecriment { iterator tmp(*this); --*this; return(tmp); } bool operator==(const iterator &right) const { return(ptr == right.ptr); } bool operator!=(const iterator &right) const { return(ptr != right.ptr); } iterator &operator=(const iterator &right) { ptr = right.ptr; return(*this); } protected: iterator(ListObj* p) : ptr(p) { ; } ListObj* ptr; }; iterator begin() const { return(iterator(head)); } iterator end() const { return(iterator(tail)); } // specific value for the end of the list protected: struct ListObj { ListObj *next; ListObj *prev; T obj; }; template<typename Comparitor> void InternalSort(ListObj **h, ListObj **t, uint s, Comparitor cmp); // used internally to help the sort void SetupBlankList(); // just like the default constructor, but can be called by others private: ListObj *head; // this is the head of our list ListObj *tail; // this is the tail of our list uint lSize; }; // // Constructors // template<typename T> list<T>::list() // default constructor { SetupBlankList(); } template<typename T> void list<T>::SetupBlankList() { lSize = 0; tail = new ListObj; tail->next = NULL; tail->prev = NULL; head = tail; } template<typename T> list<T>::list(uint n) // make n objects of T() { SetupBlankList(); for(uint i=0; i < n; i++) push_back(T()); // make the items lSize = n; // set the size } template<typename T> list<T>::list(uint n, const T &t) // make n copies of t { SetupBlankList(); for(uint i=0; i < n; i++) push_back(t); // copy the item on the list lSize = n; // set the size } template<typename T> list<T>::list(const list<T> &arg) // copy constructor { SetupBlankList(); insert(begin(), arg.begin(), arg.end()); } template<typename T> list<T>::list(const iterator &f, const iterator &l) // copy a range of another list { SetupBlankList(); lSize = 0; for(iterator it = f; it != l; ++it) { push_back(*it); // copy over the items in the range lSize++; } } template<typename T> list<T>::~list() { ListObj *tmp = head->next; // DebugPrint(); if(head == tail) // list is empty { delete head; return; } else if(tmp == tail) // list is only 2 long { delete head; delete tail; return; } else { while(tmp != tail) // go through and delete everyone { delete tmp->prev; tmp = tmp->next; } delete tmp->prev; delete tail; // delete the last guy } } template<typename T> // insert before pos typename list<T>::iterator list<T>::insert(iterator pos, const T &arg) { ListObj *tmp = new ListObj; tmp->obj = arg; // problems with complex types if we don't call operator= // memcpy(&tmp->obj, &arg, sizeof(T)); if(head == tail) // empty list { head = tail->prev = tmp; // update head & tail tmp->next = tail; // setup tmp tmp->prev = NULL; pos = tail; } else if(pos == begin()) // insert at head { head = tmp; // update head tmp->prev = NULL; // setup tmp tmp->next = pos.ptr; pos.ptr->prev = tmp; // link in tmp } else { tmp->next = pos.ptr; // setup object's links tmp->prev = pos.ptr->prev; pos.ptr->prev->next = tmp; // link in the object pos.ptr->prev = tmp; } lSize++; // update the size return(pos); } template<typename T> void list<T>::insert(iterator pos, const uint n, const T &arg) { for(uint i=0; i < n; i++) pos = insert(pos, arg); } template<typename T> void list<T>::insert(iterator pos, const iterator f, const iterator l) { for(iterator it=f; it != l; ++it) pos = insert(pos, *it); } template<typename T> typename list<T>::iterator list<T>::erase(iterator pos) { iterator newPos = pos; newPos++; if(head == tail) // empty list return(head); // not a good way to deal with this, but OK if(pos == begin()) // delete the head element { head = head->next; // update the head head->prev = NULL; delete pos.ptr; // delete the object lSize--; } else if(pos == end()) // delete the tail element return(tail->prev); // not a good way to deal with this else // some place in the middle { pos.ptr->next->prev = pos.ptr->prev; // link around the object pos.ptr->prev->next = pos.ptr->next; delete pos.ptr; // delete the object lSize--; } return(newPos); } template<typename T> void list<T>::erase(iterator f, iterator l) { if(f == begin() && l == end()) // want the whole list { clear(); // much faster f = l = end(); } else // call it one at a time { for(iterator it=f; it != l; ) it = erase(it); } } template<typename T> void list<T>::clear(void) { if(lSize == 0) return; ListObj *tmp = head->next; while(tmp != tail) // go through and delete everyone { delete tmp->prev; tmp = tmp->next; } delete tail; // delete the last guy SetupBlankList(); // update to fresh } template<typename T> list<T> &list<T>::operator=(const list<T> &right) { clear(); // clear out anything we might already have insert(begin(), right.begin(), right.end()); return(*this); } template<typename T> void list<T>::swap(iterator r, iterator l) { if(r == l) return; T tmp; // // This is certainly NOT the fastest way to swap... but certainly the easiest // This has an impact on the speed of sort // might consider chaning ListObj's obj to a T* to make this work faster // if(r == end()) { tmp = tail->obj; tail->obj = l.ptr->obj; l.ptr->obj = tmp; } else if(l == end()) { tmp = tail->obj; tail->obj = r.ptr->obj; r.ptr->obj = tmp; } else { tmp = r.ptr->obj; r.ptr->obj = l.ptr->obj; l.ptr->obj = tmp; } } template<typename T> void list<T>::sort() // perform merge sort { // simple cases first if(lSize < 2) return; this->sort(less_then<T>()); } template<typename T> template<typename Comparitor> void list<T>::sort(Comparitor cmp) { // simple case first if(lSize < 2) return; ListObj *tmp = tail->prev; tmp->next = NULL; // call the internal sort function this->InternalSort(&head, &tmp, lSize, cmp); tmp->next = tail; tail->prev = tmp; } template<typename T> template<typename Comparitor> void list<T>::InternalSort(ListObj **h, ListObj **t, uint s, Comparitor cmp) { // base cases if(s < 2) return; if(s == 2) { if(cmp((*t)->obj, (*h)->obj)) // swap these swap(iterator(*h), iterator(*t)); return; } ListObj *t1, *h2; ListObj *tmp = *h; // set tmp to the head of the list // split the list into 2 pieces for(uint i=1; i < s/2; ++i) tmp = tmp->next; t1 = tmp; // make a new end h2 = tmp->next; // make a new start t1->next = NULL; // unlink the two lists h2->prev = NULL; // make the recursive call on each list this->InternalSort(h, &t1, s/2, cmp); this->InternalSort(&h2, t, s/2 + (s%2==0?0:1), cmp); // now we have sorted lists... merge them back together ListObj *h1 = (*h); // set the new head if we need to if(cmp(h1->obj, h2->obj)) h1 = h1->next; // no need to chang the head *h = h1 already else { *h = h2; h2 = h2->next; } tmp = (*h); // this is the current one in the merged list while(h1 != NULL && h2 != NULL) // go through picking the smallest from each list { if(cmp(h1->obj,h2->obj)) { tmp->next = h1; h1->prev = tmp; h1 = h1->next; } else { tmp->next = h2; h2->prev = tmp; h2 = h2->next; } tmp = tmp->next; } if(h1 == NULL) // need to link in the rest of h2 { tmp->next = h2; h2->prev = tmp; // while(tmp->next != NULL) // tmp = tmp->next; // (*t)->prev = tmp; } else // need to link in the rest of h1 { tmp->next = h1; h1->prev = tmp; *t = t1; // update the tail // while(tmp->next != NULL) // tmp = tmp->next; // (*t)->prev = tmp; } } } #endif
[ [ [ 1, 495 ] ] ]
1d4c393270a50ffbfda552cffa13dff1bfa328e3
c1bcff0f1321de8a6425723cdfa0b5aa65b5c81f
/TransX/tags/3.11/mapfunction.h
78dddb7af1aa33f26f7c8ba0c7d2c3f59ed5de51
[]
no_license
net-lisias-orbiter/transx
560266e7a4ef73ed29d9004e406fd8db28da9a43
b9297027718a7499934a9614430aebb47422ce7f
refs/heads/master
2023-06-27T14:16:10.697238
2010-09-05T01:18:54
2010-09-05T01:18:54
390,398,358
0
0
null
null
null
null
UTF-8
C++
false
false
3,369
h
/* Copyright (c) 2007 Duncan Sharpe, Steve Arch ** ** Permission is hereby granted, free of charge, to any person obtaining a copy ** of this software and associated documentation files (the "Software"), to deal ** in the Software without restriction, including without limitation the rights ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ** copies of the Software, and to permit persons to whom the Software is ** furnished to do so, subject to the following conditions: ** ** The above copyright notice and this permission notice shall be included in ** all copies or substantial portions of the Software. ** ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ** THE SOFTWARE.*/ #ifndef __MAPFUNCTION_H #define __MAPFUNCTION_H #include "mfdfunction.h" #include "orbitelements.h" #define MAX_BODIES 101 typedef struct { OBJHANDLE bodyhandle; int parentbody; int peerring; int backpeerring; int moonring; int backmoonring; int overflow; double soisize2; double gravbodyratio2; double mass; } GBODY; typedef struct { OBJHANDLE bodyhandle; int pointer; } HASHENTRY; class mapfunction: public MFDFunction { private: GBODY *primaryarray, *secondaryarray,*array,*inarray,*outarray; int totalbodies; int actionstage,actionloop; bool initialised; static class mapfunction *themap; HASHENTRY hashtable[MAX_BODIES]; void getallhandles(); void sorthandles(); void mergelists(GBODY *list1, GBODY *endlist1, GBODY *list2, GBODY *endlist2, GBODY *listout); void initialisehashtable(); void homegbody(int listmember, OBJHANDLE handle); int getbodybyhandle(OBJHANDLE handle); void populatehashtable(); void findmajor(int position); mapfunction(); ~mapfunction(); VECTOR3 getweightedvector(OBJHANDLE, void(OBJHANDLE, VECTOR3*)); public: static class mapfunction *getthemap(); virtual void dolowpriaction(); bool getinitialised(){return initialised;}; void getorbit(OBJHANDLE handle, ORBIT *orbit); OBJHANDLE getmajor(OBJHANDLE handle);//Gets central body that handle orbits OBJHANDLE getfirstmoon(OBJHANDLE handle);//Gets heaviest moon of handle OBJHANDLE getlastmoon(OBJHANDLE handle);//Gets lightest moon of handle OBJHANDLE getnextpeer(OBJHANDLE handle);//Gets lighter peer in mass order (a peer is a body orbiting same major as handle) OBJHANDLE getpreviouspeer(OBJHANDLE handle);//Gets heavier peer in mass order double getsoisize(OBJHANDLE handle);//Gets the size of the SOI for this body OBJHANDLE getcurrbody(OBJHANDLE vessel);//Get current body for arbitrary vessel friend class shipptrs;//Allows the map to be deleted by this object VECTOR3 getbarycentre(OBJHANDLE body); // Gets the global pos of the barycentre of the system with body as the main object VECTOR3 getbarycentrevel(OBJHANDLE body); // Gets the global velocity of the barycentre of the system with body as the main object }; #endif
[ "steve@5a6c10e1-6920-0410-8c7b-9669c677a970" ]
[ [ [ 1, 84 ] ] ]
36b5c4265d0b4b0feaddb4391129312f2d0f5e9c
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/boost/spirit/fusion/sequence/detail/sequence_greater.hpp
c94d08518be6330599e2667703bfad981c0a5674
[ "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
ISO-8859-1
C++
false
false
2,062
hpp
/*============================================================================= Copyright (c) 1999-2003 Jaakko Järvi Copyright (c) 2001-2003 Joel de Guzman Copyright (c) 2004 Peder Holt Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #if !defined(FUSION_SEQUENCE_DETAIL_SEQUENCE_GREATER_HPP) #define FUSION_SEQUENCE_DETAIL_SEQUENCE_GREATER_HPP #include <boost/mpl/bool.hpp> #include <boost/static_assert.hpp> #include <boost/spirit/fusion/iterator/deref.hpp> #include <boost/spirit/fusion/iterator/next.hpp> #include <boost/spirit/fusion/iterator/equal_to.hpp> namespace boost { namespace fusion { namespace detail { namespace sequence_greater_detail { template <typename T,typename I1, typename I2> bool call(T const& self,I1 const& a, I2 const& b) { return (*b < *a) || !(*a < *b) && T::call(fusion::next(a), fusion::next(b)); } } template <typename Seq1, typename Seq2> struct sequence_greater { typedef typename meta::end<Seq1>::type end1_type; typedef typename meta::end<Seq2>::type end2_type; template <typename I1, typename I2> static bool call(I1 const& a, I2 const& b) { typename meta::equal_to<I1, end1_type>::type eq; return call(a, b, eq); } template <typename I1, typename I2> static bool call(I1 const&, I2 const&, mpl::true_) { BOOST_STATIC_ASSERT((meta::equal_to<I2, end2_type>::value)); return false; } template <typename I1, typename I2> static bool call(I1 const& a, I2 const& b, mpl::false_) { return sequence_greater_detail::call(sequence_greater<Seq1,Seq2>(),a,b); } }; }}} #endif
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 59 ] ] ]
662bd3bcb4f6269cdfe2732ccdb5856802e5172a
1736474d707f5c6c3622f1cd370ce31ac8217c12
/TestComLib/SingleFruit.h
17f81f4c2d1c41e2768eb03548e9d5987ba04558
[]
no_license
arlm/pseudo
6d7450696672b167dd1aceec6446b8ce137591c0
27153e50003faff31a3212452b1aec88831d8103
refs/heads/master
2022-11-05T23:38:08.214807
2011-02-18T23:18:36
2011-02-18T23:18:36
275,132,368
0
0
null
null
null
null
UTF-8
C++
false
false
632
h
// Copyright (c) John Lyon-Smith 2002. All rights reserved. #pragma once #include "testcomlib.h" using namespace Pseudo; class SingleFruit : public ComUnknown, public ComCreateObject<SingleFruit>, public IFruit { public: SingleFruit(); ~SingleFruit(); BEGIN_COM_IUNKNOWN_IMPL() COM_IUNKNOWN_INTERFACE(IID_IFruit, IFruit) END_COM_IUNKNOWN_IMPL() // Required for ComCreateObject support STDMETHOD(ConstructObject)(); // IFruit STDMETHOD(SetFruit)(TestFruitType e); STDMETHOD(GetFruit)(TestFruitType* pe); private: // Helper methods private: TestFruitType m_eFruit; };
[ [ [ 1, 34 ] ] ]
031f66366f043a80f24e78c1666c8c0292276a63
0f8559dad8e89d112362f9770a4551149d4e738f
/Wall_Destruction/Havok/Source/Physics/Dynamics/Constraint/Bilateral/StiffSpring/hkpStiffSpringConstraintData.h
4f60ba85cde7f80d3a6268d3a30151fb89157c1d
[]
no_license
TheProjecter/olafurabertaymsc
9360ad4c988d921e55b8cef9b8dcf1959e92d814
456d4d87699342c5459534a7992f04669e75d2e1
refs/heads/master
2021-01-10T15:15:49.289873
2010-09-20T12:58:48
2010-09-20T12:58:48
45,933,002
0
0
null
null
null
null
UTF-8
C++
false
false
4,766
h
/* * * Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's * prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok. * Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2009 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement. * */ #ifndef HK_DYNAMICS2_STIFF_SPRING_CONSTRAINT_H #define HK_DYNAMICS2_STIFF_SPRING_CONSTRAINT_H #include <Physics/ConstraintSolver/Solve/hkpSolverResults.h> #include <Physics/Dynamics/Constraint/hkpConstraintData.h> #include <Physics/ConstraintSolver/Constraint/Atom/hkpConstraintAtom.h> extern const hkClass hkpStiffSpringConstraintDataClass; /// A stiff spring constraint. It holds the constrained bodies apart at a specified distance, /// as if they were attached at each end of an invisible rod. class hkpStiffSpringConstraintData : public hkpConstraintData { public: HK_DECLARE_REFLECTION(); hkpStiffSpringConstraintData(); /// Sets the spring up with world space information. /// Will compute a rest length too (so call setlength after this if needed) /// \param pivotA bodyA's pivot point, specified in world space. /// \param pivotB bodyB's pivot point, specified in world space. inline void setInWorldSpace(const hkTransform& bodyATransform, const hkTransform& bodyBTransform, const hkVector4& pivotAW, const hkVector4& pivotBW); /// Sets the spring up with body space information. /// \param pivotA bodyA's pivot point, specified in bodyA's space. /// \param pivotB bodyB's pivot point, specified in bodyB's space. /// \param restLength The length of the stiff spring when at rest inline void setInBodySpace(const hkVector4& pivotA, const hkVector4& pivotB, hkReal restLength); /// Gets the length of the stiff spring. inline hkReal getSpringLength() const; /// Sets the length of the stiff spring when at rest. inline void setSpringLength( hkReal length ); /// Check consistency of constraint. hkBool isValid() const; /// Get type from this constraint. virtual int getType() const; public: enum { SOLVER_RESULT_LIN_0 = 0, // linear constraint SOLVER_RESULT_MAX = 1 }; struct Runtime { HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_DYNAMICS, hkpStiffSpringConstraintData::Runtime ); class hkpSolverResults m_solverResults[1/*VC6 doesn't like the scoping for SOLVER_RESULT_MAX*/]; }; inline const Runtime* getRuntime( hkpConstraintRuntime* runtime ){ return reinterpret_cast<Runtime*>(runtime); } struct Atoms { HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_DYNAMICS, hkpStiffSpringConstraintData::Atoms ); HK_DECLARE_REFLECTION(); struct hkpSetLocalTranslationsConstraintAtom m_pivots; struct hkpStiffSpringConstraintAtom m_spring; Atoms(){} // get a pointer to the first atom const hkpConstraintAtom* getAtoms() const { return &m_pivots; } // get the size of all atoms (we can't use sizeof(*this) because of align16 padding) int getSizeOfAllAtoms() const { return hkGetByteOffsetInt(this, &m_spring+1); } Atoms(hkFinishLoadedObjectFlag f) : m_pivots(f), m_spring(f) {} }; HK_ALIGN16( struct Atoms m_atoms ); public: // Internal functions // hkpConstraintData interface implementations virtual void getConstraintInfo( ConstraintInfo& infoOut ) const; // hkpConstraintData interface implementations virtual void getRuntimeInfo( hkBool wantRuntime, hkpConstraintData::RuntimeInfo& infoOut ) const; public: hkpStiffSpringConstraintData(hkFinishLoadedObjectFlag f) : hkpConstraintData(f), m_atoms(f) {} }; #include <Physics/Dynamics/Constraint/Bilateral/StiffSpring/hkpStiffSpringConstraintData.inl> #endif // HK_DYNAMICS2_STIFF_SPRING_CONSTRAINT_H /* * Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20091222) * * Confidential Information of Havok. (C) Copyright 1999-2009 * Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok * Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership * rights, and intellectual property rights in the Havok software remain in * Havok and/or its suppliers. * * Use of this software for evaluation purposes is subject to and indicates * acceptance of the End User licence Agreement for this product. A copy of * the license is included with this software and is also available at www.havok.com/tryhavok. * */
[ [ [ 1, 128 ] ] ]
e326c391077b50c758343fc5a478c9c2ed8362ee
b14d5833a79518a40d302e5eb40ed5da193cf1b2
/cpp/extern/crypto++/5.2.1/shacal2.cpp
639a258222297da1cbdccc9a81f56ce6d75a3537
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-cryptopp" ]
permissive
andyburke/bitflood
dcb3fb62dad7fa5e20cf9f1d58aaa94be30e82bf
fca6c0b635d07da4e6c7fbfa032921c827a981d6
refs/heads/master
2016-09-10T02:14:35.564530
2011-11-17T09:51:49
2011-11-17T09:51:49
2,794,411
1
0
null
null
null
null
UTF-8
C++
false
false
3,932
cpp
// shacal2.cpp - by Kevin Springle, 2003 // // Portions of this code were derived from // Wei Dai's implementation of SHA-2 // // The original code and all modifications are in the public domain. #include "pch.h" #include "shacal2.h" #include "misc.h" NAMESPACE_BEGIN(CryptoPP) // SHACAL-2 function and round definitions #define S0(x) (rotrFixed(x,2)^rotrFixed(x,13)^rotrFixed(x,22)) #define S1(x) (rotrFixed(x,6)^rotrFixed(x,11)^rotrFixed(x,25)) #define s0(x) (rotrFixed(x,7)^rotrFixed(x,18)^(x>>3)) #define s1(x) (rotrFixed(x,17)^rotrFixed(x,19)^(x>>10)) #define Ch(x,y,z) (z^(x&(y^z))) #define Maj(x,y,z) ((x&y)|(z&(x|y))) /* R is the SHA-256 round function. */ /* This macro increments the k argument as a side effect. */ #define R(a,b,c,d,e,f,g,h,k) \ h+=S1(e)+Ch(e,f,g)+*k++;d+=h;h+=S0(a)+Maj(a,b,c); /* P is the inverse of the SHA-256 round function. */ /* This macro decrements the k argument as a side effect. */ #define P(a,b,c,d,e,f,g,h,k) \ h-=S0(a)+Maj(a,b,c);d-=h;h-=S1(e)+Ch(e,f,g)+*--k; void SHACAL2::Base::UncheckedSetKey(CipherDir dir, const byte *userKey, unsigned int keylen) { AssertValidKeyLength(keylen); word32 *rk = m_key; unsigned int i; GetUserKey(BIG_ENDIAN_ORDER, rk, m_key.size(), userKey, keylen); for (i = 0; i < 48; i++, rk++) { rk[16] = rk[0] + s0(rk[1]) + rk[9] + s1(rk[14]); rk[0] += K[i]; } for (i = 48; i < 64; i++, rk++) { rk[0] += K[i]; } } typedef BlockGetAndPut<word32, BigEndian> Block; void SHACAL2::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const { word32 a, b, c, d, e, f, g, h; const word32 *rk = m_key; /* * map byte array block to cipher state: */ Block::Get(inBlock)(a)(b)(c)(d)(e)(f)(g)(h); // Perform SHA-256 transformation. /* 64 operations, partially loop unrolled */ for (unsigned int j=0; j<64; j+=8) { R(a,b,c,d,e,f,g,h,rk); R(h,a,b,c,d,e,f,g,rk); R(g,h,a,b,c,d,e,f,rk); R(f,g,h,a,b,c,d,e,rk); R(e,f,g,h,a,b,c,d,rk); R(d,e,f,g,h,a,b,c,rk); R(c,d,e,f,g,h,a,b,rk); R(b,c,d,e,f,g,h,a,rk); } /* * map cipher state to byte array block: */ Block::Put(xorBlock, outBlock)(a)(b)(c)(d)(e)(f)(g)(h); } void SHACAL2::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const { word32 a, b, c, d, e, f, g, h; const word32 *rk = m_key + 64; /* * map byte array block to cipher state: */ Block::Get(inBlock)(a)(b)(c)(d)(e)(f)(g)(h); // Perform inverse SHA-256 transformation. /* 64 operations, partially loop unrolled */ for (unsigned int j=0; j<64; j+=8) { P(b,c,d,e,f,g,h,a,rk); P(c,d,e,f,g,h,a,b,rk); P(d,e,f,g,h,a,b,c,rk); P(e,f,g,h,a,b,c,d,rk); P(f,g,h,a,b,c,d,e,rk); P(g,h,a,b,c,d,e,f,rk); P(h,a,b,c,d,e,f,g,rk); P(a,b,c,d,e,f,g,h,rk); } /* * map cipher state to byte array block: */ Block::Put(xorBlock, outBlock)(a)(b)(c)(d)(e)(f)(g)(h); } // The SHACAL-2 round constants are identical to the SHA-256 round constants. const word32 SHACAL2::Base::K[64] = { 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 }; NAMESPACE_END
[ [ [ 1, 140 ] ] ]
b11c26900b129ec1193ac6b52cffe66dc9e3a84f
299a1b0fca9e1de3858a5ebeaf63be6dc3a02b48
/tags/051101/dingus/dingus/gfx/Mesh.h
02eb354701daf15129849e55412c26aa9af1803b
[]
no_license
BackupTheBerlios/dingus-svn
331d7546a6e7a5a3cb38ffb106e57b224efbf5df
1223efcf4c2079f58860d7fa685fa5ded8f24f32
refs/heads/master
2016-09-05T22:15:57.658243
2006-09-02T10:10:47
2006-09-02T10:10:47
40,673,143
0
0
null
null
null
null
UTF-8
C++
false
false
3,800
h
// -------------------------------------------------------------------------- // Dingus project - a collection of subsystems for game/graphics applications // -------------------------------------------------------------------------- #ifndef __GFX_MESH_H #define __GFX_MESH_H #include "VertexFormat.h" #include "../math/Vector3.h" #include "../math/AABox.h" #include "../kernel/Proxies.h" namespace dingus { class CMesh : public boost::noncopyable { public: enum eBufferType { BUF_STATIC = 0, BUF_SYSTEMMEM }; public: /** * A subset of a mesh. Mesh can have multiple subsets, eg. when portions * of it have different materials. Contains AABB of the subset. */ class CGroup { public: CGroup( int firstVert, int vertCount, int firstPrim, int primCount ) : mFirstVertex(firstVert), mVertexCount(vertCount), mFirstPrim(firstPrim), mPrimCount(primCount), mAABB() { } int getFirstVertex() const { return mFirstVertex; } int getVertexCount() const { return mVertexCount; } int getFirstPrim() const { return mFirstPrim; } int getPrimCount() const { return mPrimCount; } const CAABox& getAABB() const { return mAABB; } CAABox& getAABB() { return mAABB; } private: int mFirstVertex, mVertexCount; int mFirstPrim, mPrimCount; CAABox mAABB; }; typedef std::vector<CGroup> TGroupVector; public: CMesh(); ~CMesh(); void createResource( int vertCount, int idxCount, const CVertexFormat& vertFormat, int indexStride, CD3DVertexDecl& vertDecl, eBufferType bufferType ); void deleteResource(); bool isCreated() const { return !mVB.isNull() && !mIB.isNull(); } int getVertexCount() const { return mVertexCount; } int getIndexCount() const { return mIndexCount; } const CVertexFormat& getVertexFormat() const { return mVertexFormat; } int getVertexStride() const { return mVertexStride; } int getIndexStride() const { return mIndexStride; } CD3DVertexDecl& getVertexDecl() const { return *mVertexDecl; } const CD3DVertexBuffer& getVB() const { return mVB; } CD3DVertexBuffer& getVB() { return mVB; } const CD3DIndexBuffer& getIB() const { return mIB; } CD3DIndexBuffer& getIB() { return mIB; } const void* lockVBRead() const; void unlockVBRead() const; void* lockVBWrite(); void unlockVBWrite(); const void* lockIBRead() const; void unlockIBRead() const; void* lockIBWrite(); void unlockIBWrite(); /// Creates D3DX mesh from this mesh. May be useful for tools. ID3DXMesh* createD3DXMesh() const; /** * Get triangle vertex indices. * Index buffer must be locked for reading! */ void getTriIndices( const void* lockedIB, int tri, int& idx0, int& idx1, int& idx2 ) const; void computeAABBs(); const CAABox& getTotalAABB() const { return mTotalAABB; } CAABox& getTotalAABB() { return mTotalAABB; } int getGroupCount() const { return mGroups.size(); } const CGroup& getGroup( int i ) const { assert(i>=0&&i<getGroupCount()); return mGroups[i]; } CGroup& getGroup( int i ) { assert(i>=0&&i<getGroupCount()); return mGroups[i]; } void reserveGroups( int count ) { mGroups.reserve(count); } void addGroup( const CGroup& g ) { mGroups.push_back(g); } private: // buffers type eBufferType mBufferType; // vertex/index count int mVertexCount; int mIndexCount; // formats/strides CVertexFormat mVertexFormat; int mVertexStride; // in bytes, depends on format int mIndexStride; CD3DVertexDecl* mVertexDecl; // VB/IB CD3DVertexBuffer mVB; CD3DIndexBuffer mIB; // groups TGroupVector mGroups; // total AABB CAABox mTotalAABB; // for assertions enum eLock { NOLOCK, LOCK_READ, LOCK_WRITE }; mutable eLock mVBLock; mutable eLock mIBLock; }; }; // namespace #endif
[ "nearaz@73827abb-88f4-0310-91e6-a2b8c1a3e93d" ]
[ [ [ 1, 121 ] ] ]