blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 5
146
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
7
| license_type
stringclasses 2
values | repo_name
stringlengths 6
79
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 4
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.07k
426M
โ | star_events_count
int64 0
27
| fork_events_count
int64 0
12
| gha_license_id
stringclasses 3
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 6
values | src_encoding
stringclasses 26
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 1
class | length_bytes
int64 20
6.28M
| extension
stringclasses 20
values | content
stringlengths 20
6.28M
| authors
sequencelengths 1
16
| author_lines
sequencelengths 1
16
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
89f95642bf3472fe288ae19e9c8dfed1d56ebbc1 | 2b80036db6f86012afcc7bc55431355fc3234058 | /src/server/SyncpathController.hpp | 6eb4a3ffe722992ef9df31b5da45cc7fe8235a5b | [
"BSD-3-Clause"
] | permissive | leezhongshan/musikcube | d1e09cf263854bb16acbde707cb6c18b09a0189f | e7ca6a5515a5f5e8e499bbdd158e5cb406fda948 | refs/heads/master | 2021-01-15T11:45:29.512171 | 2011-02-25T14:09:21 | 2011-02-25T14:09:21 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 3,356 | hpp | //////////////////////////////////////////////////////////////////////////////
//
// License Agreement:
//
// The following are Copyright ยฉ 2007, mC2 Team
//
// Sources and Binaries of: mC2, win32cpp
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
//////////////////////////////////////////////////////////////////////////////
// Forward declare
namespace musik { namespace server {
class SyncpathView;
class SyncpathModel;
class SyncpathListController;
} }
namespace musik { namespace core {
class Indexer;
} }
namespace win32cpp{
class Window;
class Button;
}
//////////////////////////////////////////////////////////////////////////////
#include <win32cpp/Types.hpp>
#include <win32cpp/WindowGeometry.hpp>
#include <boost/shared_ptr.hpp>
namespace musik { namespace server{
//////////////////////////////////////////////////////////////////////////////
class SyncpathController : public win32cpp::EventHandler
{
public:
SyncpathController(SyncpathView& syncpathView,musik::core::Indexer *indexer);
private:
void OnViewCreated(win32cpp::Window* window);
void OnViewResized(win32cpp::Window* window, win32cpp::Size size);
SyncpathView& syncpathView;
void OnAddPath(win32cpp::Button* button);
void OnRemovePath(win32cpp::Button* button);
typedef boost::shared_ptr<SyncpathListController> SyncpathListControllerRef;
SyncpathListControllerRef syncpathListController;
public:
musik::core::Indexer *indexer;
};
//////////////////////////////////////////////////////////////////////////////
} } // musik::server
| [
"onnerby@6a861d04-ae47-0410-a6da-2d49beace72e"
] | [
[
[
1,
87
]
]
] |
ad2a1ecbe1a81e80c19614709f7b92f446fe4561 | 5ac13fa1746046451f1989b5b8734f40d6445322 | /minimangalore/Nebula2/code/contrib/nluaserver/src/lua/lgc.cc | 6f8e36e79df463a59492af393078f65af41c98aa | [] | no_license | moltenguy1/minimangalore | 9f2edf7901e7392490cc22486a7cf13c1790008d | 4d849672a6f25d8e441245d374b6bde4b59cbd48 | refs/heads/master | 2020-04-23T08:57:16.492734 | 2009-08-01T09:13:33 | 2009-08-01T09:13:33 | 35,933,330 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,010 | cc | /*
** $Id: lgc.cc 567 2004-03-26 00:39:30Z enlight $
** Garbage Collector
** See Copyright Notice in lua.h
*/
#include <string.h>
#define lgc_c
#include "lua/lua.h"
#include "lua/ldebug.h"
#include "lua/ldo.h"
#include "lua/lfunc.h"
#include "lua/lgc.h"
#include "lua/lmem.h"
#include "lua/lobject.h"
#include "lua/lstate.h"
#include "lua/lstring.h"
#include "lua/ltable.h"
#include "lua/ltm.h"
typedef struct GCState {
GCObject *tmark; /* list of marked objects to be traversed */
GCObject *wk; /* list of traversed key-weak tables (to be cleared) */
GCObject *wv; /* list of traversed value-weak tables */
GCObject *wkv; /* list of traversed key-value weak tables */
global_State *g;
} GCState;
/*
** some userful bit tricks
*/
#define setbit(x,b) ((x) |= (1<<(b)))
#define resetbit(x,b) ((x) &= cast(lu_byte, ~(1<<(b))))
#define testbit(x,b) ((x) & (1<<(b)))
#define unmark(x) resetbit((x)->gch.marked, 0)
#define ismarked(x) ((x)->gch.marked & ((1<<4)|1))
#define stringmark(s) setbit((s)->tsv.marked, 0)
#define isfinalized(u) (!testbit((u)->uv.marked, 1))
#define markfinalized(u) resetbit((u)->uv.marked, 1)
#define KEYWEAKBIT 1
#define VALUEWEAKBIT 2
#define KEYWEAK (1<<KEYWEAKBIT)
#define VALUEWEAK (1<<VALUEWEAKBIT)
#define markobject(st,o) { checkconsistency(o); \
if (iscollectable(o) && !ismarked(gcvalue(o))) reallymarkobject(st,gcvalue(o)); }
#define condmarkobject(st,o,c) { checkconsistency(o); \
if (iscollectable(o) && !ismarked(gcvalue(o)) && (c)) \
reallymarkobject(st,gcvalue(o)); }
#define markvalue(st,t) { if (!ismarked(valtogco(t))) \
reallymarkobject(st, valtogco(t)); }
static void reallymarkobject (GCState *st, GCObject *o) {
lua_assert(!ismarked(o));
setbit(o->gch.marked, 0); /* mark object */
switch (o->gch.tt) {
case LUA_TUSERDATA: {
markvalue(st, gcotou(o)->uv.metatable);
break;
}
case LUA_TFUNCTION: {
gcotocl(o)->c.gclist = st->tmark;
st->tmark = o;
break;
}
case LUA_TTABLE: {
gcotoh(o)->gclist = st->tmark;
st->tmark = o;
break;
}
case LUA_TTHREAD: {
gcototh(o)->gclist = st->tmark;
st->tmark = o;
break;
}
case LUA_TPROTO: {
gcotop(o)->gclist = st->tmark;
st->tmark = o;
break;
}
default: lua_assert(o->gch.tt == LUA_TSTRING);
}
}
static void marktmu (GCState *st) {
GCObject *u;
for (u = st->g->tmudata; u; u = u->gch.next) {
unmark(u); /* may be marked, if left from previous GC */
reallymarkobject(st, u);
}
}
/* move `dead' udata that need finalization to list `tmudata' */
size_t luaC_separateudata (lua_State *L) {
size_t deadmem = 0;
GCObject **p = &G(L)->rootudata;
GCObject *curr;
GCObject *collected = NULL; /* to collect udata with gc event */
GCObject **lastcollected = &collected;
while ((curr = *p) != NULL) {
lua_assert(curr->gch.tt == LUA_TUSERDATA);
if (ismarked(curr) || isfinalized(gcotou(curr)))
p = &curr->gch.next; /* don't bother with them */
else if (fasttm(L, gcotou(curr)->uv.metatable, TM_GC) == NULL) {
markfinalized(gcotou(curr)); /* don't need finalization */
p = &curr->gch.next;
}
else { /* must call its gc method */
deadmem += sizeudata(gcotou(curr)->uv.len);
*p = curr->gch.next;
curr->gch.next = NULL; /* link `curr' at the end of `collected' list */
*lastcollected = curr;
lastcollected = &curr->gch.next;
}
}
/* insert collected udata with gc event into `tmudata' list */
*lastcollected = G(L)->tmudata;
G(L)->tmudata = collected;
return deadmem;
}
static void removekey (Node *n) {
setnilvalue(gval(n)); /* remove corresponding value ... */
if (iscollectable(gkey(n)))
setttype(gkey(n), LUA_TNONE); /* dead key; remove it */
}
static void traversetable (GCState *st, Table *h) {
int i;
int weakkey = 0;
int weakvalue = 0;
const TObject *mode;
markvalue(st, h->metatable);
lua_assert(h->lsizenode || h->node == st->g->dummynode);
mode = gfasttm(st->g, h->metatable, TM_MODE);
if (mode && ttisstring(mode)) { /* is there a weak mode? */
weakkey = (strchr(svalue(mode), 'k') != NULL);
weakvalue = (strchr(svalue(mode), 'v') != NULL);
if (weakkey || weakvalue) { /* is really weak? */
GCObject **weaklist;
h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */
h->marked |= cast(lu_byte, (weakkey << KEYWEAKBIT) |
(weakvalue << VALUEWEAKBIT));
weaklist = (weakkey && weakvalue) ? &st->wkv :
(weakkey) ? &st->wk :
&st->wv;
h->gclist = *weaklist; /* must be cleared after GC, ... */
*weaklist = valtogco(h); /* ... so put in the appropriate list */
}
}
if (!weakvalue) {
i = h->sizearray;
while (i--)
markobject(st, &h->array[i]);
}
i = sizenode(h);
while (i--) {
Node *n = gnode(h, i);
if (!ttisnil(gval(n))) {
lua_assert(!ttisnil(gkey(n)));
condmarkobject(st, gkey(n), !weakkey);
condmarkobject(st, gval(n), !weakvalue);
}
}
}
static void traverseproto (GCState *st, Proto *f) {
int i;
stringmark(f->source);
for (i=0; i<f->sizek; i++) { /* mark literal strings */
if (ttisstring(f->k+i))
stringmark(tsvalue(f->k+i));
}
for (i=0; i<f->sizeupvalues; i++) /* mark upvalue names */
stringmark(f->upvalues[i]);
for (i=0; i<f->sizep; i++) /* mark nested protos */
markvalue(st, f->p[i]);
for (i=0; i<f->sizelocvars; i++) /* mark local-variable names */
stringmark(f->locvars[i].varname);
lua_assert(luaG_checkcode(f));
}
static void traverseclosure (GCState *st, Closure *cl) {
if (cl->c.isC) {
int i;
for (i=0; i<cl->c.nupvalues; i++) /* mark its upvalues */
markobject(st, &cl->c.upvalue[i]);
}
else {
int i;
lua_assert(cl->l.nupvalues == cl->l.p->nups);
markvalue(st, hvalue(&cl->l.g));
markvalue(st, cl->l.p);
for (i=0; i<cl->l.nupvalues; i++) { /* mark its upvalues */
UpVal *u = cl->l.upvals[i];
if (!u->marked) {
markobject(st, &u->value);
u->marked = 1;
}
}
}
}
static void checkstacksizes (lua_State *L, StkId max) {
int used = L->ci - L->base_ci; /* number of `ci' in use */
if (4*used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci)
luaD_reallocCI(L, L->size_ci/2); /* still big enough... */
else condhardstacktests(luaD_reallocCI(L, L->size_ci));
used = max - L->stack; /* part of stack in use */
if (4*used < L->stacksize && 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize)
luaD_reallocstack(L, L->stacksize/2); /* still big enough... */
else condhardstacktests(luaD_reallocstack(L, L->stacksize));
}
static void traversestack (GCState *st, lua_State *L1) {
StkId o, lim;
CallInfo *ci;
markobject(st, gt(L1));
lim = L1->top;
for (ci = L1->base_ci; ci <= L1->ci; ci++) {
lua_assert(ci->top <= L1->stack_last);
lua_assert(ci->state & (CI_C | CI_HASFRAME | CI_SAVEDPC));
if (lim < ci->top)
lim = ci->top;
}
for (o = L1->stack; o < L1->top; o++)
markobject(st, o);
for (; o <= lim; o++)
setnilvalue(o);
checkstacksizes(L1, lim);
}
static void propagatemarks (GCState *st) {
while (st->tmark) { /* traverse marked objects */
switch (st->tmark->gch.tt) {
case LUA_TTABLE: {
Table *h = gcotoh(st->tmark);
st->tmark = h->gclist;
traversetable(st, h);
break;
}
case LUA_TFUNCTION: {
Closure *cl = gcotocl(st->tmark);
st->tmark = cl->c.gclist;
traverseclosure(st, cl);
break;
}
case LUA_TTHREAD: {
lua_State *th = gcototh(st->tmark);
st->tmark = th->gclist;
traversestack(st, th);
break;
}
case LUA_TPROTO: {
Proto *p = gcotop(st->tmark);
st->tmark = p->gclist;
traverseproto(st, p);
break;
}
default: lua_assert(0);
}
}
}
static int valismarked (const TObject *o) {
if (ttisstring(o))
stringmark(tsvalue(o)); /* strings are `values', so are never weak */
return !iscollectable(o) || testbit(o->value.gc->gch.marked, 0);
}
/*
** clear collected keys from weaktables
*/
static void cleartablekeys (GCObject *l) {
while (l) {
Table *h = gcotoh(l);
int i = sizenode(h);
lua_assert(h->marked & KEYWEAK);
while (i--) {
Node *n = gnode(h, i);
if (!valismarked(gkey(n))) /* key was collected? */
removekey(n); /* remove entry from table */
}
l = h->gclist;
}
}
/*
** clear collected values from weaktables
*/
static void cleartablevalues (GCObject *l) {
while (l) {
Table *h = gcotoh(l);
int i = h->sizearray;
lua_assert(h->marked & VALUEWEAK);
while (i--) {
TObject *o = &h->array[i];
if (!valismarked(o)) /* value was collected? */
setnilvalue(o); /* remove value */
}
i = sizenode(h);
while (i--) {
Node *n = gnode(h, i);
if (!valismarked(gval(n))) /* value was collected? */
removekey(n); /* remove entry from table */
}
l = h->gclist;
}
}
static void freeobj (lua_State *L, GCObject *o) {
switch (o->gch.tt) {
case LUA_TPROTO: luaF_freeproto(L, gcotop(o)); break;
case LUA_TFUNCTION: luaF_freeclosure(L, gcotocl(o)); break;
case LUA_TUPVAL: luaM_freelem(L, gcotouv(o)); break;
case LUA_TTABLE: luaH_free(L, gcotoh(o)); break;
case LUA_TTHREAD: {
lua_assert(gcototh(o) != L && gcototh(o) != G(L)->mainthread);
luaE_freethread(L, gcototh(o));
break;
}
case LUA_TSTRING: {
luaM_free(L, o, sizestring(gcotots(o)->tsv.len));
break;
}
case LUA_TUSERDATA: {
luaM_free(L, o, sizeudata(gcotou(o)->uv.len));
break;
}
default: lua_assert(0);
}
}
static int sweeplist (lua_State *L, GCObject **p, int limit) {
GCObject *curr;
int count = 0; /* number of collected items */
while ((curr = *p) != NULL) {
if (curr->gch.marked > limit) {
unmark(curr);
p = &curr->gch.next;
}
else {
count++;
*p = curr->gch.next;
freeobj(L, curr);
}
}
return count;
}
static void sweepstrings (lua_State *L, int all) {
int i;
for (i=0; i<G(L)->strt.size; i++) { /* for each list */
G(L)->strt.nuse -= sweeplist(L, &G(L)->strt.hash[i], all);
}
}
static void checkSizes (lua_State *L, size_t deadmem) {
/* check size of string hash */
if (G(L)->strt.nuse < cast(ls_nstr, G(L)->strt.size/4) &&
G(L)->strt.size > MINSTRTABSIZE*2)
luaS_resize(L, G(L)->strt.size/2); /* table is too big */
/* check size of buffer */
if (luaZ_sizebuffer(&G(L)->buff) > LUA_MINBUFFER*2) { /* buffer too big? */
size_t newsize = luaZ_sizebuffer(&G(L)->buff) / 2;
luaZ_resizebuffer(L, &G(L)->buff, newsize);
}
G(L)->GCthreshold = 2*G(L)->nblocks - deadmem; /* new threshold */
}
static void do1gcTM (lua_State *L, Udata *udata) {
const TObject *tm = fasttm(L, udata->uv.metatable, TM_GC);
if (tm != NULL) {
setobj2s(L->top, tm);
setuvalue(L->top+1, udata);
L->top += 2;
luaD_call(L, L->top - 2, 0);
}
}
void luaC_callGCTM (lua_State *L) {
lu_byte oldah = L->allowhook;
L->allowhook = 0; /* stop debug hooks during GC tag methods */
L->top++; /* reserve space to keep udata while runs its gc method */
while (G(L)->tmudata != NULL) {
GCObject *o = G(L)->tmudata;
Udata *udata = gcotou(o);
G(L)->tmudata = udata->uv.next; /* remove udata from `tmudata' */
udata->uv.next = G(L)->rootudata; /* return it to `root' list */
G(L)->rootudata = o;
setuvalue(L->top - 1, udata); /* keep a reference to it */
unmark(o);
markfinalized(udata);
do1gcTM(L, udata);
}
L->top--;
L->allowhook = oldah; /* restore hooks */
}
void luaC_sweep (lua_State *L, int all) {
if (all) all = 256; /* larger than any mark */
sweeplist(L, &G(L)->rootudata, all);
sweepstrings(L, all);
sweeplist(L, &G(L)->rootgc, all);
}
/* mark root set */
static void markroot (GCState *st, lua_State *L) {
global_State *g = st->g;
markobject(st, defaultmeta(L));
markobject(st, registry(L));
traversestack(st, g->mainthread);
if (L != g->mainthread) /* another thread is running? */
markvalue(st, L); /* cannot collect it */
}
static size_t mark (lua_State *L) {
size_t deadmem;
GCState st;
GCObject *wkv;
st.g = G(L);
st.tmark = NULL;
st.wkv = st.wk = st.wv = NULL;
markroot(&st, L);
propagatemarks(&st); /* mark all reachable objects */
cleartablevalues(st.wkv);
cleartablevalues(st.wv);
wkv = st.wkv; /* keys must be cleared after preserving udata */
st.wkv = NULL;
st.wv = NULL;
deadmem = luaC_separateudata(L); /* separate userdata to be preserved */
marktmu(&st); /* mark `preserved' userdata */
propagatemarks(&st); /* remark, to propagate `preserveness' */
cleartablekeys(wkv);
/* `propagatemarks' may resuscitate some weak tables; clear them too */
cleartablekeys(st.wk);
cleartablevalues(st.wv);
cleartablekeys(st.wkv);
cleartablevalues(st.wkv);
return deadmem;
}
void luaC_collectgarbage (lua_State *L) {
size_t deadmem = mark(L);
luaC_sweep(L, 0);
checkSizes(L, deadmem);
luaC_callGCTM(L);
}
void luaC_link (lua_State *L, GCObject *o, lu_byte tt) {
o->gch.next = G(L)->rootgc;
G(L)->rootgc = o;
o->gch.marked = 0;
o->gch.tt = tt;
}
| [
"BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c"
] | [
[
[
1,
498
]
]
] |
b987180329d41ee02414b6c18e708504f59cb719 | 2c1e5a69ca68fe185cc04c5904aa104b0ba42e32 | /src/game/ASpriteInstance.cpp | d240eec7d3ac2e166123b0f83621607827ce3db0 | [] | no_license | dogtwelve/newsiderpg | e3f8284a7cd9938156ef8d683dca7bcbd928c593 | 303566a034dca3e66cf0f29cf9eaea1d54d63e4a | refs/heads/master | 2021-01-10T13:03:31.986204 | 2010-06-27T05:36:33 | 2010-06-27T05:36:33 | 46,550,247 | 0 | 1 | null | null | null | null | UHC | C++ | false | false | 19,519 | cpp | #include "ASpriteInstance.h"
#include "ASprite.h"
/*int ASpriteInstance::x;
int ASpriteInstance::y;
int ASpriteInstance::_posX;
int ASpriteInstance::_posY;*/
#include "Macro.h"
ASpriteInstance::ASpriteInstance(ASprite* spr, int posX, int posY, ASpriteInstance* parent)
{
CameraX=0;
CameraY=0;
m_lastX = m_posX = posX;
m_lastY = m_posY = posY;
// m_flags = 0;
m_pal = 0;
m_sprite = spr;
m_nState = 0;
m_nCrtModule = 0;
m_nCrtFrame = 0;
m_nCrtAnimation = 0;
m_rect = GL_NEW int[4];
m_bLoop = true;
// m_parent = parent;
}
ASpriteInstance::~ASpriteInstance()
{
SAFE_DEL_ARRAY(m_rect);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void ASpriteInstance::SetModule(int id)
{//SangHo - ๊ทธ๋ฆฌ๊ธฐ ์์ฑ์ Module๋ก ๋ฐ๊ฟ์ค๋ค
//ํ๋์ด ๋ฐ๋๋ฉด ๊ธฐ์กด์ ๋ง์ง๋ง ์ขํ๋ ์ด๊ธฐํ ์์ผ์ค๋ค
m_lastAniX=0;
m_lastAniZ=0;
m_nState = 2;
m_nCrtAnimation = -2;//SangHo - -2 ์ผ ๊ฒฝ์ฐ Animation ์๋ํ์ง์๋๋ค
m_nCrtModule = id;
//m_nCrtFrame = -1;//SangHo - -1 ์ผ ๊ฒฝ์ฐ Frame ์๋ํ์ง์๋๋ค
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void ASpriteInstance::SetFrame(int id)
{//SangHo - ๊ทธ๋ฆฌ๊ธฐ ์์ฑ์ Frame๋ก ๋ฐ๊ฟ์ค๋ค
//ํ๋์ด ๋ฐ๋๋ฉด ๊ธฐ์กด์ ๋ง์ง๋ง ์ขํ๋ ์ด๊ธฐํ ์์ผ์ค๋ค
m_lastAniX=0;
m_lastAniZ=0;
m_nState = 1;
m_nCrtAnimation = -2;//SangHo - -2 ์ผ ๊ฒฝ์ฐ Animation ์๋ํ์ง์๋๋ค
m_nCrtModule = -1;//SangHo - -1 ์ผ ๊ฒฝ์ฐ Module ์๋ํ์ง์๋๋ค
m_nCrtFrame = id;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
bool ASpriteInstance::SetAnim(int id)
{//SangHo - ๊ทธ๋ฆฌ๊ธฐ ์์ฑ์ Animation๋ก ๋ฐ๊ฟ์ค๋ค
//if(!m_bLoop)
//{
//m_bAnimIsOver = false;
//ํ๋์ด ๋ฐ๋๋ฉด ๊ธฐ์กด์ ๋ง์ง๋ง ์ขํ๋ ์ด๊ธฐํ ์์ผ์ค๋ค
m_lastAniX=0;
m_lastAniZ=0;
m_nState = 0;
m_nCrtModule = id;
m_nCrtFrame = 0;
m_nCrtAnimation = -1;//SangHo - 0๋์ -1์ธ ์ด์ ๋ Paint ์ ์ ํญ์ ํค๊ฐ์ ๋ํ ์
๋ฐ์ดํธ๋ฅผ ์ํํด์ผ ํ๋ฏ๋ก ์ฒซํ๋ ์์ ๋ชป์ฐ๋ ๊ตฌ์กฐ์ ํ๊ณ๋๋ฌธ
is_aniDone = false;
return true;
//}
//else
//{
// if (id != m_nCrtModule)
// {
// //m_bAnimIsOver = false;
// m_nCrtModule = id;
// m_nCrtFrame = 0;
// m_nCrtAnimation = 0;
// is_aniDone = false;
// return true;
// }
//}
//return false;
}
//void ASpriteInstance::SetAniLoop(bool _loop)
void ASpriteInstance::RewindAnim(int id)
{//SangHo - id Anim ์ผ๋ก ๊ต์ฒดํ ์ด๊ธฐํ
//m_bAnimIsOver = false;
m_nCrtModule = id;
m_nCrtFrame = 0;
m_nCrtAnimation = 0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void ASpriteInstance::SetToLastFrame()
{//SangHo - Anim์ ๋ง์ง๋ง ์ธ๋ฑ์ค๊ฐ์ผ๋ก ์ด๋
m_nCrtFrame = m_sprite->GetAFrames(m_nCrtModule) - 1;
m_nCrtAnimation = m_sprite->GetAFrameTime(m_nCrtModule, m_nCrtFrame) - 1;
}
void ASpriteInstance::setAnimStop( )
{//SangHo - Anim์ ์ฌ์์ค๋จํ ์ธ๋ฑ์ค ์ด๊ธฐํ
is_aniDone = true;
m_nCrtFrame = 0;
}
void ASpriteInstance::setCamera(int _CameraX, int _CameraY)
{//SangHo - Anim์ ์ฌ์์ค๋จํ ์ธ๋ฑ์ค ์ด๊ธฐํ
CameraX = _CameraX;
CameraY = _CameraY;
}
bool ASpriteInstance::IsAnimEnded()
{//SangHo - Anim๊ฐ ํ์ฌ ์ฌ์์ค์ธ์ง ์๋์ง๋ฅผ ์๋ ค์ค๋ค
if(is_aniDone)
{
return true;
}
//if (m_bReverse)
//{
// if (m_nCrtFrame != 0)
// {
// return false;
// }
//}
else if (m_nCrtFrame != m_sprite->GetAFrames(m_nCrtModule) - 1)
{
return false;
}
int time = m_sprite->GetAFrameTime(m_nCrtModule, m_nCrtFrame);
return ((time == 0) || (m_nCrtAnimation == time - 1));
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void ASpriteInstance::Get_AFrameXZ(int* tmpXZ){//๊ทธ๋ฆฌ๊ธฐ ์ ์ ์ขํ ํ์ธ์ด ํ์ํ ๋
m_sprite->Get_AFrameXY(tmpXZ , m_nCrtModule, m_nCrtFrame, m_posX + m_lastAniX, 0, m_flags, 0, 0);
}
void ASpriteInstance::PaintSprite(CGraphics* g,int flags)//SangHo - flags๊ฐ์ ๋ฃ์ง์์๊ฒฝ์ฐ 0์ผ๋ก ๊ฐ์ฃผํ๋ค
{
m_flags = flags;
PaintSprite(g);
}
void ASpriteInstance::PaintSprite(CGraphics* g,int posX,int posY,int flags)//SangHo - flags๊ฐ์ ๋ฃ์ง์์๊ฒฝ์ฐ 0์ผ๋ก ๊ฐ์ฃผํ๋ค
{
m_posX = posX;
m_posY = posY;
m_flags = flags;
PaintSprite(g);
}
void ASpriteInstance::PaintSprite(CGraphics* g)//SangHo - flags๊ฐ์ ๋ฐ๋ผ ์ข์ฐ์ํ๋ฐ์ ๋๋ 90๋ ํ์ ์ ์ง์ํ๋ค
{//CameraX,CameraY ๋ ๋งต ๋ฐฐ๊ฒฝ ์คํฌ๋กค์ ๋ฐ๋ฅธ ๋ณด์ ์์น
//const static byte FLAG_FLIP_X = 0x01;
//const static byte FLAG_FLIP_Y = 0x02;
//const static byte FLAG_ROT_90 = 0x04;
// m_flags = flags;
//m_bAnimIsOver = false;
if (m_sprite == NULL)
return;
//if ((m_flags & FLAG_DONTDRAW) != 0)
//{
// return;
//}
//if ((m_layer & 4) != 0)
//{
// return;
//}
m_sprite->changePal(m_pal);
m_sprite->SetBlendCustom(s_Blend.blendCustom,s_Blend.overWrite,s_Blend.Blend_Kind,s_Blend.Blend_Percent);
if (m_nCrtAnimation >= -1)//-2 ์ผ ๊ฒฝ์ฐ์ ์๋๋ฉ์ด์
์ด ์๋ ํ๋ ์๋๋ ๋ชจ๋์ ๊ทธ๋ฆฐ๋ค
{
m_sprite->PaintAFrame(g, m_nCrtModule, m_nCrtFrame,CameraX+ m_posX + m_lastAniX, CameraY+ (m_posY + m_posZ) + m_lastAniZ, m_flags, 0, 0);
if(!b_MoveLock){
m_posX-=m_sprite->m_nowAniX - m_lastAniX;
m_posZ-=m_sprite->m_nowAniZ - m_lastAniZ;
//๊ฐฑ์ ์ด ๋๋ ์ขํ์ ์ ํ๋ ์ ์ขํ๋ฅผ ๋บ๊ฐ๋งํผ์ ๋ํด์ค๋ค
m_lastAniX = m_sprite->m_nowAniX;
m_lastAniZ = m_sprite->m_nowAniZ;
m_stopFlag = m_sprite->m_nowFlag;
}
}
else if (m_nCrtModule >= 0) // m_nCrtModule --> module
{
// ์ต์ปค๋ ์์๋ก ์ฐ์
m_sprite->PaintModule(g, m_nCrtModule, CameraX+ m_posX, CameraY+ (m_posY + m_posZ), m_flags, g->BOTTOM | g->HCENTER );
}
else if (m_nCrtFrame >= 0) // m_nCrtFrame --> frame
{
m_sprite->PaintFrame(g, m_nCrtFrame,CameraX+ m_posX, CameraY+ (m_posY + m_posZ), m_flags, 0, 0);
}
//m_bAnimIsOver = IsAnimEnded();
m_lastX =m_posX; //SangHo - ์ธ์คํด์ค์ ํ ์ขํ๋ฅผ ๋ฐ์ํ๋ค. - ๋ชธํต์ฒดํฌ๋ฅผ ์ํด์(์ ์ขํ๋ก ์ฐ์ธ๋ค)
m_lastY =m_posY; //SangHo - ์ธ์คํด์ค์ ํ ์ขํ๋ฅผ ๋ฐ์ํ๋ค. - ๋ชธํต์ฒดํฌ๋ฅผ ์ํด์(์ ์ขํ๋ก ์ฐ์ธ๋ค)
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//SangHo - ๊ตฌ์กฐ์ ๋ฌธ์ ํด๊ฒฐ์ํด ๋ค์์ ์ (2008.12.19)
bool ASpriteInstance::UpdateSpriteAnim()
{//SangHo - Animation์ ํ์ฌ๊ฐ์ 1์ฆ๊ฐ์ํจ๋ค.
//return true - ์ ๋๋ฉ์ด์
์ฌ์์ค
//return false - ์ ๋๋ฉ์ด์
์ข
๋ฃ
int _m_time = 0;//์ด Time ๊ฐ (๋๋ ์ด์์น ๋ํด๊ฐ์ 0)
int _m_frame = 0;//์ด ํ๋ ์๊ฐ (ํ๋ ์ ๋งฅ์ค๊ฐ)
_m_time = m_sprite->GetAFrameTime(m_nCrtModule, m_nCrtFrame); // ํด๋น ํ๋ ์์ Time๊ฐ
_m_frame = m_sprite->GetAFrames(m_nCrtModule);//m_nCrtModule ๋ ์ ๋๋ฉ์ด์
๋๋ฒ
{//๋ฌด๊ฒฐ์ฑ ์ฒดํฌ
if (m_sprite == NULL) return true;
if (m_nCrtAnimation < -1) return true;//์
๋ฐ์ดํธ ์ํ์ time ๊ฐ์ ๋ฌด์กฐ๊ฑด ++ ์ํค๋ฏ๋ก ์ด๊ธฐ๊ฐ์ -1, ๋ฃจํํ๋ 0์ผ๋ก ๋์๊ฐ๋ค
if ((m_flags & FLAG_PAUSED) != 0) return true;//์ผ์์ ์ง์ ๋ฌด์กฐ๊ฑด return
}
//{//์์ธ๊ฐ ํต์ผํ ์ฒ๋ฆฌ
// if (m_nCrtAnimation < 0)
// m_nCrtAnimation=0;
//}
{//ํ๋ ์์ Time ๊ฐ์ ์ฒดํฌํ๋ค ----- Time ๊ฐ๋งํผ ๋๋ ์ด ํ์ ๋ค์ ํ๋ ์์ผ๋ก ๋์ด๊ฐ๋ค
m_nCrtAnimation++; //์ธ์คํด์ค์ time ๊ฐ 1์ฆ๊ฐ
if (m_nCrtAnimation < _m_time) //ํ๋ ์์ ํ์๊ฐ๋ณด๋ค ์๋ค๋ฉด 1์ฆ๊ฐ ํ๊ณ ํ๋ฒ๋ ๊ทธ๋ฆผ
if (m_nCrtAnimation == (_m_time-1) && m_nCrtFrame == (_m_frame -1) ){//&&!m_bLoop) //๋ง์ง๋งTime ์ผ๋ ๋ค์์ผ๋ก ์ฆ๊ฐํ ํ๋ ์์ด ์๋ค๋ฉด false ๊ฐ ๋์ผํ๋ค
return false;
}else
return true;
}
{//์ ๋์ ํ๋ ์ ๊ฐ์ ์ฒดํฌํ๋ค ----- ๋ง์ง๋ง ํ๋ ์์ผ ๊ฒฝ์ฐ (๋๋ก์์ข
๋ฃ, ๋ฃจํ) ์ฌ๋ถ ํ๋จ
if (m_nCrtFrame < (_m_frame -1)){ //ํ๋ ์ ๊ฐฏ์(-1) ๋ณด๋ค ํ์ฌ ํ๋ ์์ธ๋ฑ์ค๊ฐ ์๋ค๋ฉด ํ๋ ์์ธ๋ฑ์ค๋ฅผ 1์ฆ๊ฐ ์ํจ๋ค
m_nCrtAnimation=0;//ํ๋ ์์ ํ์๊ฐ ์ด๊ธฐํ
m_nCrtFrame++;//๋ค์ํ๋ ์์ผ๋ก
{//๋ง์ฝ ๋์ด๊ฐ ํ๋ ์์ด ๋ง์ง๋ง ํ๋ ์ & time 1 ์ด๋ฉด ๋ฏธ๋ฆฌ ์ฒดํฌ๋ฅผ ํด์ค์ผ ํ๋ค-์๊ทธ๋ฌ๋ฉด ๋ง์ง๋ง ํ๋ ์์ ํ๋ฒ๋ ๊ทธ๋ฆฐ๋ค
_m_time = m_sprite->GetAFrameTime(m_nCrtModule, m_nCrtFrame); // ํด๋น ํ๋ ์์ Time๊ฐ
if((m_nCrtFrame == (_m_frame -1) && _m_time == 1 )&&!m_bLoop)
return false;
else
return true;
}
}else{//์
๋ฐ์ดํธ ๋ง์ง๋ง ๊ฐ ๋๋ฌ
if(m_bLoop){//๋ฃจํ์ ๋๋ฉ์ด์
์ผ ๊ฒฝ์ฐ
m_nCrtAnimation=0;//ํ๋ ์์ ํ์๊ฐ ์ด๊ธฐํ
m_nCrtFrame = 0;//์ฒซํ๋ ์์ผ๋ก
m_lastAniX=0;
m_lastAniZ=0;
//if(Move)UpdateTempXZ(APPLY_X|APPLY_Z);//๋ฃจํ๊ฐ ๋๋ฉด ์ต์ข
์ขํ๋ฅผ ๋ฐ์ํด์ผํ๋ค
return true;
}else{//1ํ์ฑ ์ ๋๋ฉ์ด์
์ผ ๊ฒฝ์ฐ
return false;//////////////////////////// ์๋๋ฉ์ด์
์ข
๋ฃ ////////////////////////////
}
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
int ASpriteInstance::GetCurrentAFrameOff(bool bY)
{//SangHo - ํ์ฌ Off๊ฐ ๊ตฌํ๋ ๋ถ๋ถ์ด๊ธดํ๋ ํ์ฉ์์๋ถ๋ถ์ ๋ชจ๋ฅด๊ฒ ์
int off = (m_sprite->_anims_af_start[m_nCrtModule] + m_nCrtFrame) * 5;
if (bY)
{
return m_sprite->_aframes[off + 3];
}
return m_sprite->_aframes[off + 2];
}
int ASpriteInstance::GetLastAFrameOff(bool bY)
{//SangHo - ๋ง์ง๋ง Off๊ฐ ๊ตฌํ๋ ๋ถ๋ถ์ด๊ธดํ๋ ํ์ฉ์์๋ถ๋ถ์ ๋ชจ๋ฅด๊ฒ ์
int lastAFrame = m_sprite->GetAFrames(m_nCrtModule) - 1;
int off = (m_sprite->_anims_af_start[m_nCrtModule] + lastAFrame) * 5;
if (bY)
{
return m_sprite->_aframes[off + 3];
}
return m_sprite->_aframes[off + 2];
}
////////////////////////////////////////////////////////////////////////////////////////////////////
int* ASpriteInstance::GetRect(bool bColRect)
{//SangHo - LCD๊ธฐ์ค์ ์ข,์,๋๋น,๋์ด 4๊ฐ์ธ์๊ฐ์ ๋ฆฌํดํ๋ค.
if (m_rect == NULL)
{
m_rect = GL_NEW int[4];
}
int posX = m_posX;
int posY = m_posY;
if (m_sprite != NULL)
{
if (m_nCrtModule >= 0)
{
if (m_nCrtAnimation >= 0)
{
m_sprite->GetAFrameRect(m_rect, m_nCrtModule, m_nCrtFrame, posX, posY, m_flags, 0, 0);//bColRect
}
else
{
m_sprite->GetModuleRect(m_rect, m_nCrtModule, posX, posY);
}
}
else if (m_nCrtFrame >= 0)
{
m_sprite->GetFrameRect(m_rect, m_nCrtFrame, posX, posY, m_flags, 0, 0);//bColRect
}
}
return m_rect;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
int* ASpriteInstance::GetAbsoluteRect(bool bColRect)
{//SangHo - ์์ ๊ธฐ์ค์ ์ข,์,๋๋น,๋์ด 4๊ฐ์ธ์๊ฐ์ ๋ฆฌํดํ๋ค.
if (m_rect == NULL)
{
m_rect = GL_NEW int[4];
}
if (m_sprite != NULL)
{
/*if (bColRect && m_sprite->_frames_coll == NULL)
{
return NULL;
}*/
if (m_nCrtAnimation >= 0)
{
m_sprite->GetAFrameRect(m_rect, m_nCrtModule, m_nCrtFrame, 0, 0, m_flags, 0, 0);//bColRect
}
else if (m_nCrtModule >= 0)
{
m_sprite->GetModuleRect(m_rect, m_nCrtModule, 0, 0);
}
else if (m_nCrtFrame >= 0)
{
m_sprite->GetFrameRect(m_rect, m_nCrtFrame, 0, 0, m_flags, 0, 0);//bColRect
}
}
return m_rect;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
int* ASpriteInstance::GetFModuleRect(int module,int posX, int posY, int flags, int hx, int hy)
{//SangHo - ํ์ฌ ์ธ์คํด์ค๊ฐ ๊ทธ๋ฆฌ๊ณ ์๋ Animation Frame ์ module๋ฒ์งธ ๋ชจ๋์ ์ขํ๋ฅผ ๋ฆฌํดํ๋ค(์์ ๊ธฐ์ค, ํ์ดํผ ํ๋ ์์ ํด๋น๋์ง์์)
if (m_rect == NULL)
{
m_rect = GL_NEW int[4];
}
//System.out.println("m_nCrtFrame::::::::::"+m_nCrtFrame);
//System.out.println("GetAnimFrame(m_nCrtModule,m_nCrtFrame):"+m_sprite->GetAnimFrame(m_nCrtModule,m_nCrtFrame));
if(m_sprite != NULL)
{
m_sprite->GetFModuleRect(m_rect,GetAnimFrame(),module,posX,posY,flags,hx,hy);
return m_rect;
}
return NULL;
}
int ASpriteInstance::GetAnimFrame()
{//SangHo - ํ์ฌ ์ธ์คํด์ค๊ฐ ๊ทธ๋ฆฌ๊ณ ์๋ Animation Frame ์ ๊ณ ์ Index ๊ฐ์ ๋ฆฌํดํ๋ค(Ani off๊ฐ ์๋)
if(m_sprite != NULL)
{
return m_sprite->GetAnimFrame(m_nCrtModule,m_nCrtFrame);
}
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
bool ASpriteInstance::IsRectCrossing(int rect1[], int rect2[])
{//SangHo - ๋ ๋ฉด์ ์ด ์ถฉ๋ํ์๋์ง๋ฅผ ํ๋จํ๋ค
if (rect1[0] > rect2[2]) return false;
if (rect1[2] < rect2[0]) return false;
if (rect1[1] > rect2[3]) return false;
if (rect1[3] < rect2[1]) return false;
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
bool ASpriteInstance::IsPointInRect(int x, int y, int rect[])
{//SangHo - ํ์ง์ ์ด ๋ฉด์ ์์ ๋ค์ด๊ฐ์๋์ง ์๋์ง๋ฅผ ์ฒดํฌํ๋ค
if (x < rect[0]) return false;
if (x > rect[2]) return false;
if (y < rect[1]) return false;
if (y > rect[3]) return false;
return true;
}
bool ASpriteInstance::SetBlendCustom(bool blendCustom, bool overWrite, int Blend_Kind,int Blend_Percent){
//SangHo - ๋ธ๋๋๋ฅผ ์ง์ ํ์๋ง์ ๊ทธ๋ฆฌ๋๊ฒ์ด ์๋๋ผ List ์ ๋ฃ์๋ค ์ ๋ ฌํ์ ํ๊บผ๋ฒ์ ๊ทธ๋ฆฌ๊ธฐ๋๋ฌธ์ ๊ฐ์ ์ ์ฅํ ํ์์ฑ์ด ์์
s_Blend.blendCustom = blendCustom;
s_Blend.overWrite = overWrite;
s_Blend.Blend_Kind = Blend_Kind;
s_Blend.Blend_Percent = Blend_Percent;
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// static int ZOOM_IN_X(int x) { return (((x)*ZOOM_X)/ZOOM_X_DIV); }
// static int ZOOM_IN_Y(int y) { return (((y)*ZOOM_Y)/ZOOM_Y_DIV); }
// static int ZOOM_OUT_X(int x) { return (((x)*ZOOM_X_DIV)/ZOOM_X); }
// static int ZOOM_OUT_Y(int y) { return (((y)*ZOOM_Y_DIV)/ZOOM_Y); }
//static int ZOOM_IN_FIXED_X(int x) { return ((((x)>>FIXED_PRECISION)*ZOOM_X)/ZOOM_X_DIV); }
//static int ZOOM_IN_FIXED_Y(int y) { return ((((y)>>FIXED_PRECISION)*ZOOM_Y)/ZOOM_Y_DIV); }
// [Sinh.2007/02/22] optimize for Triplets
// static int ZOOM_OUT_FIXED_X(int x) { return ((((x)<<FIXED_PRECISION)*ZOOM_X_DIV)/ZOOM_X); }
// static int ZOOM_OUT_FIXED_Y(int y) { return ((((y)<<FIXED_PRECISION)*ZOOM_Y_DIV)/ZOOM_Y); }
////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////โฝํ์์ค - SangHo/////////////////////////////////////////
///////////////////////////////////////////โฝํ์์ค - SangHo/////////////////////////////////////////
/*
int* ASpriteInstance::GetSpriteRect(int _m_posX, int _m_posY)
{//SangHo - _m_posX,_m_posY ์ ๊ธฐ์ค์ ์ผ๋ก ๊ฐ์ ๋ ์ข,์,๋๋น,๋์ด 4๊ฐ์ธ์๊ฐ์ ๋ฆฌํดํ๋ค.
if (m_rect == NULL)
{
m_rect = GL_NEW int[4];
}
if (m_sprite != NULL)
{
if (m_nCrtAnimation >= 0)
m_sprite->GetAFrameRect(m_rect, m_nCrtModule, m_nCrtFrame, _m_posX, _m_posY, m_flags, 0, 0);
else if (m_nCrtModule >= 0)
m_sprite->GetModuleRect(m_rect, m_nCrtModule, _m_posX, _m_posY);
else if (m_nCrtFrame >= 0)
m_sprite->GetFrameRect(m_rect, m_nCrtFrame, _m_posX, _m_posY, m_flags, 0, 0);
//m_rect[1] -= m_posZ;
//m_rect[3] -= m_posZ;
return m_rect;
}
return NULL;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void ASpriteInstance::PaintSprite_NO_ZOOM(CGraphics* g)
{//SangHo - PaintSprite๋ก ๋์ฒด
if (m_sprite == NULL)
return;
int posX = m_posX,
posY = m_posY;
for (ASpriteInstance* o = m_parent; o != NULL; o = o->m_parent)
{
posX += o->m_posX;
posY += o->m_posY;
}
posX = ( posX >>FIXED_PRECISION ) + SV_X;
posY = ( posY >>FIXED_PRECISION ) + SV_Y;
// System.out.println("PaintSprite("+posX+", "+posY+")...");
m_sprite->SetCurrentPalette(m_pal);
if (m_nCrtAnimation >= 0)
m_sprite->PaintAFrame(g, m_nCrtModule, m_nCrtFrame, posX, posY, m_flags, 0, 0);
else if (m_nCrtModule >= 0) // m_nCrtModule --> module
m_sprite->PaintModule(g, m_nCrtModule, posX, posY, m_flags);
else if (m_nCrtFrame >= 0) // m_nCrtFrame --> frame
m_sprite->PaintFrame(g, m_nCrtFrame, posX, posY, m_flags, 0, 0);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void ASpriteInstance::ApplyAnimOff()//์ขํ์ ๊ฐ์ค์น ๊ณ์ฐ์ ํ๋๋ถ๋ถ ์ธ๋ชจ์์ด๋ณด์
{
// if (bASSERT) DBG.ASSERT(m_sprite != NULL);
m_posX -= m_posOffX;
m_posY -= m_posOffY;
//////////
// m_sprite->GetAFrameOffset(&m_posOffX, &m_posOffY);
int off = (m_sprite->_anims_af_start[m_nCrtModule] + m_nCrtFrame) * 5;
// m_posOffX = ZOOM_OUT_FIXED_X(m_sprite->_aframes[off+2] << FIXED_PRECISION);
m_posOffX = (m_sprite->_aframes[off+2] << FIXED_PRECISION) * ZOOM_X_DIV / ZOOM_X;
if ((m_flags & FLAG_FLIP_X) != 0) m_posOffX = -m_posOffX;
// m_posOffY = ZOOM_OUT_FIXED_Y(m_sprite->_aframes[off+3] << FIXED_PRECISION);
m_posOffY = (m_sprite->_aframes[off+3] << FIXED_PRECISION) * ZOOM_Y_DIV / ZOOM_Y;
if ((m_flags & FLAG_FLIP_Y) != 0) m_posOffY = -m_posOffY;
//////////
m_posX += m_posOffX;
m_posY += m_posOffY;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void ASpriteInstance::OnScreenTest()
{//SangHo - ์ฌ์ฉํ์ง ์์
// _vis = 1 + 2 + 4 + 8;
int ox = 0, oy = 0;
for (ASpriteInstance* o = m_parent; o != NULL; o = o->m_parent)
{
ox += o->m_posX;
oy += o->m_posY;
}
int* rect = GetRect(false);
rect[0] += ox - (GV_W << FIXED_PRECISION);
rect[1] += oy - (GV_H << FIXED_PRECISION);
rect[2] += ox;
rect[3] += oy;
_vis = 0;
if (rect[0] < 0 && rect[2] >= 0 && rect[1] < 0 && rect[3] >= 0)
{
_vis = 1 + 2 + 4 + 8;
}
else
{
//...
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
bool ASpriteInstance::IsOnScreen(int style)
{//SangHo - ์ฌ์ฉํ์ง ์์
return ((_vis & style) != 0);
}
int ASpriteInstance::getAniFrameOffY(){
int off = (m_sprite->_anims_af_start[m_nCrtModule] + m_nCrtFrame) * 5;
int m_posOffY = (m_sprite->_aframes[off+3] << FIXED_PRECISION) * ZOOM_Y_DIV / ZOOM_Y;
if ((m_flags & FLAG_FLIP_Y) != 0) m_posOffY = -m_posOffY;
return m_posOffY;
}
*/ | [
"[email protected]"
] | [
[
[
1,
635
]
]
] |
48f31c586f643ff356bfb5a0c5e579667cb66df9 | f43c7dc0c3ca9031175fc3f13461a86b9c4ce667 | /dllsrc/syb_exec/syb_exec.cpp | 34717b67a18918e4c4967601093045af8295baee | [] | no_license | ebakker/aseisql | 998c8b10f4ba3499d53c2e74b2276620a694ef28 | faf31bf448dfb18b66b4f395188201989ccd3ced | refs/heads/master | 2021-01-18T20:19:41.247243 | 2009-11-09T21:45:48 | 2009-11-09T21:45:48 | 36,292,766 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 35,544 | cpp |
#include "syb_exec.h"
//#include <locale.h>
extern "C"{
DBG(FILE *flog=NULL);
long public_datetime_format=1;
long MAXBUFSIZE=32767;
SQLCONTEXT *public_sqlctx=NULL;
IPB_Session *g_IPB_Session = NULL;
bool FatalError(char * msg, char*parm1=NULL, char*parm2=NULL){
mstring s=mstring();
s.sprintf( msg ,parm1, parm2);
MessageBox(0,s.c_str(),APP_NAME" Fatal error.",MB_OK|MB_ICONSTOP);
return false;
}
/*********************************************************
* Function to call event in powerbuilder object by name
* example to call:
* WCHAR * str = L"Huray!";
* TriggerEvent(pbo[0],"callback",555,(long)str);
********************************************************/
bool TriggerEvent(pbobject *object,char * event,long wparm, long lparm, long * ret) {
PBCallInfo ci;
pbclass clz = g_IPB_Session->GetClass(object[0]);
pbmethodID mid = g_IPB_Session->GetMethodID(clz, event, PBRT_EVENT, "LLL");
if(mid == kUndefinedMethodID) return FatalError("Can't find event named \"%40s\"",event);
g_IPB_Session->InitCallInfo(clz, mid, &ci);
ci.pArgs->GetAt(0)->SetLong(wparm);
ci.pArgs->GetAt(1)->SetLong(lparm);
g_IPB_Session->TriggerEvent(object[0], mid, &ci);
if(ret)ret[0] = ci.returnValue->GetLong();
g_IPB_Session->FreeCallInfo(&ci);
return true;
}
LRESULT SendData(SQLCONTEXT*ctx,UINT Msg, WPARAM wParam, LPARAM lParam){
if(!ctx){
mstring s=mstring();
s.sprintf( "Error initializing SQLCONTEXT.\nmsg=%i wparam=%i lparam=%i\n" ,Msg, wParam, lParam);
if(Msg==PEM_SQL_MESSAGE){
//let's ignore sql messages when context not initialized
//this is because
//in windows vista the sql messages could be sent after select finished.
//in debug mode let's dosplay error message...
#ifdef MYDEBUG
SQLMESSAGE*m=(SQLMESSAGE*)lParam;
s.append("Sql message: ");
s.append(m->text);
#else
return 0;
#endif
}
FatalError(s.c_str());
return 0;
}
if(ctx->hwnd){
return SendMessage(ctx->hwnd, Msg, wParam, lParam);
}else if(ctx->callback){
long ret=0;
switch(Msg){
case PEM_RESULTSET:
TriggerEvent(ctx->callback,"sqlexec_resultset", wParam, lParam, &ret);
break;
case PEM_END_ROW:
TriggerEvent(ctx->callback,"sqlexec_row_end", wParam, lParam, &ret);
break;
case PEM_INSERT_ROW:
TriggerEvent(ctx->callback,"sqlexec_row_start", wParam, lParam, &ret);
break;
case PEM_SET_FIELD:
TriggerEvent(ctx->callback,"sqlexec_field_value", wParam, lParam, &ret);
break;
case PEM_FLD_INFO:
TriggerEvent(ctx->callback,"sqlexec_field_info", wParam, lParam, &ret);
break;
case PEM_LOG_MESSAGE:
DBG(TriggerEvent(ctx->callback,"sqlexec_debug", wParam, lParam, &ret));
break;
case PEM_DIRECTORY:
TriggerEvent(ctx->callback,"sqlexec_directory", wParam, lParam, &ret);
break;
case PEM_SQL_MESSAGE:
TriggerEvent(ctx->callback,"sqlexec_sql_message", wParam, lParam, &ret);
break;
case PEM_RES_INFO:
TriggerEvent(ctx->callback,"sqlexec_res_info", wParam, lParam, &ret);
break;
case PEM_DIR_INFO:
TriggerEvent(ctx->callback,"sqlexec_dir_info", wParam, lParam, &ret);
break;
}
return ret;
}
FatalError("SQLCONTEXT contains no handlers.");
return 0;
}
CS_RETCODE ERR(SQLCONTEXT*ctx, char * msg, int i){
if(msg){
char*buf=new char[strlen(msg)+20];
sprintf(buf,msg,i);
SendData(ctx,PEM_LOG_MESSAGE,LOG_MSG_INFO,(LPARAM)buf);
delete []buf;
}
return CS_FAIL;
}
//sends notification to intervace about new row incoming
//returns false if user want to cancel data transfer
BOOL ROW(SQLCONTEXT*ctx, CS_COMMAND *cmd, long row){
CS_INT code=SendData(ctx,PEM_INSERT_ROW,row,0);
switch(code){
case 0:
return true;
case CS_CANCEL_ALL:
ct_cancel(NULL, cmd, CS_CANCEL_ALL);
return false;
}
ct_cancel(NULL, cmd, CS_CANCEL_CURRENT);
return false;
}
char*rtrim(char*c){
char*ns=c;
char*space=" \t\r\n";
for(int i=0;c[i];i++)
if(!strchr(space,c[i]))
ns=c+i+1;
ns[0]=0;
return c;
}
void SQLERR(SQLCONTEXT*ctx, long msgnumber, long severity, char *proc, long line, char *text ){
SQLMESSAGE m;
memset(&m,0,sizeof(SQLMESSAGE) );
m.msgnumber=msgnumber;
m.severity=severity;
m.proc=proc;
m.line=line;
m.text=text;
m.text[CS_MAX_MSG-1]=0;
m.proc[CS_MAX_NAME-1]=0;
rtrim(m.text);
rtrim(m.proc);
SendData(ctx,PEM_SQL_MESSAGE,sizeof(SQLMESSAGE),(LPARAM)&m);
}
void * old_srv_msg_callback=NULL;
void * old_cli_msg_callback=NULL;
CS_RETCODE CS_PUBLIC ex_servermsg_cb(CS_CONTEXT*context, CS_CONNECTION*connection, CS_SERVERMSG*srvmsg){
SQLERR(public_sqlctx, srvmsg->msgnumber, srvmsg->severity, srvmsg->proc, srvmsg->line, srvmsg->text );
return CS_SUCCEED;
}
CS_RETCODE CS_PUBLIC clientmsg_callback(CS_CONTEXT*ctx, CS_CONNECTION*con, CS_CLIENTMSG*cmsg){
SQLERR(public_sqlctx, cmsg->msgnumber, cmsg->severity, "", 0, cmsg->msgstring );
return CS_SUCCEED;
}
CS_RETCODE install_message_callback(SQLCONTEXT*sct,CS_COMMAND *cmd){
CS_CONNECTION *connection;
LOG(sct,"installing server message callback...");
//get connection
RET_ON_FAIL(ct_cmd_props(cmd,CS_GET,CS_PARENT_HANDLE,&connection,CS_UNUSED,NULL),sct,"install_message_callback: ct_cmd_props() failed");
//get old callback message
RET_ON_FAIL(ct_callback(NULL, connection, CS_GET, CS_SERVERMSG_CB,(void*)&old_srv_msg_callback),sct,"install_message_callback: ct_callback(CS_GET) failed");
DBG(fprintf(flog,"old_srv_msg_callback :%X\n",old_srv_msg_callback));
//set the new one
if(ct_callback(NULL, connection, CS_SET, CS_SERVERMSG_CB,(void*)ex_servermsg_cb)!=CS_SUCCEED){
ERR(sct,"install_message_callback: ct_callback(CS_SET) failed");
old_srv_msg_callback=NULL;
return CS_FAIL;
}
LOG(sct,"server message callback installed");
return CS_SUCCEED;
}
CS_RETCODE return_message_callback(SQLCONTEXT*sct,CS_COMMAND *cmd){
CS_CONNECTION *connection;
LOG(sct,"uninstalling server message callback...");
//get connection
RET_ON_FAIL(ct_cmd_props(cmd,CS_GET,CS_PARENT_HANDLE,&connection,CS_UNUSED,NULL),sct,"return_message_callback: ct_cmd_props() failed");
//return the old cb
if(ct_callback(NULL, connection, CS_SET, CS_SERVERMSG_CB,(void*)old_srv_msg_callback)!=CS_SUCCEED){
ERR(sct,"return_message_callback: ct_callback(CS_SET) failed");
return CS_FAIL;
}
old_srv_msg_callback=NULL;
LOG(sct,"server message callback uninstalled");
return CS_SUCCEED;
}
CS_RETCODE install_cli_message_callback(SQLCONTEXT*sct,CS_COMMAND *cmd){
CS_CONNECTION *connection;
LOG(sct,"installing client message callback...");
//get connection
RET_ON_FAIL(ct_cmd_props(cmd,CS_GET,CS_PARENT_HANDLE,&connection,CS_UNUSED,NULL),sct,"install_cli_message_callback: ct_cmd_props() failed");
//get old callback message
RET_ON_FAIL(ct_callback(NULL, connection, CS_GET, CS_CLIENTMSG_CB,
(CS_VOID *)&old_cli_msg_callback),sct,
"install_cli_message_callback: ct_callback(CS_GET) failed");
DBG(fprintf(flog,"old_cli_msg_callback :%X\n",old_cli_msg_callback));
//set the new one
if(ct_callback(NULL, connection, CS_SET, CS_CLIENTMSG_CB,(void*)clientmsg_callback)!=CS_SUCCEED){
ERR(sct,"install_cli_message_callback: ct_callback(CS_SET) failed");
old_cli_msg_callback=NULL;
return CS_FAIL;
}
LOG(sct,"client message callback installed");
return CS_SUCCEED;
}
CS_RETCODE return_cli_message_callback(SQLCONTEXT* sct,CS_COMMAND *cmd){
CS_CONNECTION *connection;
LOG(sct,"uninstalling client message callback...");
//get connection
RET_ON_FAIL(ct_cmd_props(cmd,CS_GET,CS_PARENT_HANDLE,&connection,CS_UNUSED,NULL),sct,"return_message_callback: ct_cmd_props() failed");
//return the old cb
if(ct_callback(NULL, connection, CS_SET, CS_CLIENTMSG_CB,(void*)old_cli_msg_callback)!=CS_SUCCEED){
ERR(sct,"return_cli_message_callback: ct_callback(CS_SET) failed");
return CS_FAIL;
}
old_cli_msg_callback=NULL;
LOG(sct,"client message callback uninstalled");
return CS_SUCCEED;
}
char* DisplayType(CS_DATAFMT*column){
static char buf[50];
switch ((int) column->datatype){
case CS_CHAR_TYPE:
sprintf(buf,"char(%i)",column->maxlength);
break;
case CS_VARCHAR_TYPE:
sprintf(buf,"varchar(%i)",column->maxlength);
break;
case CS_TEXT_TYPE:
sprintf(buf,"text");
break;
case CS_IMAGE_TYPE:
sprintf(buf,"image");
break;
case CS_BINARY_TYPE:
sprintf(buf,"binary");
break;
case CS_VARBINARY_TYPE:
sprintf(buf,"varbinary");
break;
case CS_BIT_TYPE:
sprintf(buf,"bit");
break;
case CS_TINYINT_TYPE:
sprintf(buf,"tinyint");
break;
case CS_SMALLINT_TYPE:
sprintf(buf,"smallint");
break;
case CS_INT_TYPE:
sprintf(buf,"int");
break;
case CS_REAL_TYPE:
sprintf(buf,"real");
break;
case CS_FLOAT_TYPE:
sprintf(buf,"float");
break;
case CS_MONEY_TYPE:
sprintf(buf,"money");
break;
case CS_MONEY4_TYPE:
sprintf(buf,"smallmoney");
break;
case CS_DATETIME_TYPE:
sprintf(buf,"datetime");
break;
case CS_DATETIME4_TYPE:
sprintf(buf,"smalldatedime");
break;
case CS_NUMERIC_TYPE:
sprintf(buf,"numeric(%i,%i)",column->precision,column->scale);
break;
case CS_DECIMAL_TYPE:
sprintf(buf,"decimal(%i,%i)",column->precision,column->scale);
break;
case CS_UNICHAR_TYPE:
sprintf(buf,"unichar(%i)",column->maxlength/2);
break;
case CS_DATE_TYPE:
sprintf(buf,"date");
break;
case CS_TIME_TYPE:
sprintf(buf,"time");
break;
/* case CS_UNITEXT_TYPE:
sprintf(buf,"unitext");
break;
case CS_BIGINT_TYPE:
sprintf(buf,"bigint");
break;
case CS_USMALLINT_TYPE:
sprintf(buf,"usmallint");
break;
case CS_UINT_TYPE:
sprintf(buf,"uint");
break;
case CS_UBIGINT_TYPE:
sprintf(buf,"ubigint");
break;
case CS_XML_TYPE:
sprintf(buf,"xml");
break;
*/ default:
sprintf(buf,"type_%i",column->datatype);
break;
}
return buf;
}
//Initializes the dataformat and columndata to receive the fetched data as characters if autoconvert works well
//if not then leave format as is
void InitColData(CS_DATAFMT*column,COLUMNDATA*coldata){
//this routime must init
// coldata->charlen number of characters (unicode?) for displaying data on client
// coldata->bytelen number of bytes needed to fetch data (utf8)
// coldata->data initialize memory to receive fetched data and to convert it to char
// column->maxlength if destination type = CHAR then equals to coldata->bytelen otherwise keep the original value
// datafmt.datatype = CS_CHAR_TYPE;
// datafmt.format = CS_FMT_NULLTERM;
switch (column->datatype){
case CS_CHAR_TYPE:
case CS_VARCHAR_TYPE:
case CS_LONGCHAR_TYPE:
case CS_TEXT_TYPE:
coldata->bytelen =MIN(column->maxlength, MAXBUFSIZE)+1;
coldata->charlen =coldata->bytelen;
column->maxlength=coldata->bytelen;
column->datatype = CS_CHAR_TYPE;
column->format = CS_FMT_NULLTERM;
break;
case CS_UNICHAR_TYPE:
coldata->bytelen =MIN((column->maxlength/2)*3, MAXBUFSIZE)+1; //suppose that one unichar could be presented with 3 multibyte chars
coldata->charlen =MIN((column->maxlength/2), MAXBUFSIZE)+1;
column->maxlength=coldata->bytelen;
column->datatype = CS_CHAR_TYPE;
column->format = CS_FMT_NULLTERM;
break;
case CS_IMAGE_TYPE:
case CS_BINARY_TYPE:
case CS_LONGBINARY_TYPE:
case CS_VARBINARY_TYPE:
coldata->bytelen =MIN((2 * column->maxlength) + 2, MAXBUFSIZE)+1;
coldata->charlen =coldata->bytelen;
column->maxlength=coldata->bytelen;
column->datatype = CS_CHAR_TYPE;
column->format = CS_FMT_NULLTERM;
break;
case CS_BIT_TYPE:
case CS_TINYINT_TYPE:
coldata->bytelen =3+1;
coldata->charlen =coldata->bytelen;
column->maxlength=coldata->bytelen;
column->datatype = CS_CHAR_TYPE;
column->format = CS_FMT_NULLTERM;
break;
case CS_SMALLINT_TYPE:
coldata->bytelen =6+1;
coldata->charlen =coldata->bytelen;
column->maxlength=coldata->bytelen;
column->datatype = CS_CHAR_TYPE;
column->format = CS_FMT_NULLTERM;
break;
case CS_INT_TYPE:
coldata->bytelen =11+1;
coldata->charlen =coldata->bytelen;
column->maxlength=coldata->bytelen;
column->datatype = CS_CHAR_TYPE;
column->format = CS_FMT_NULLTERM;
break;
case CS_REAL_TYPE:
case CS_FLOAT_TYPE:
coldata->bytelen =20+1;
coldata->charlen =coldata->bytelen;
//column->maxlength=coldata->bytelen;
//column->datatype = CS_CHAR_TYPE;//use native
//column->format = CS_FMT_NULLTERM;
break;
case CS_MONEY_TYPE:
case CS_MONEY4_TYPE:
coldata->bytelen =24+1;
coldata->charlen =coldata->bytelen;
column->maxlength=coldata->bytelen;
column->datatype = CS_CHAR_TYPE;
column->format = CS_FMT_NULLTERM;
break;
case CS_TIME_TYPE:
coldata->bytelen =16+1;
coldata->charlen =coldata->bytelen;
column->maxlength=coldata->bytelen;
if(public_datetime_format==DATETIME_FORMAT_NATIVE){
//use native
column->datatype = CS_CHAR_TYPE;
column->format = CS_FMT_NULLTERM;
}
break;
case CS_DATETIME4_TYPE:
case CS_DATETIME_TYPE:
coldata->bytelen =max(sizeof(CS_DATETIME),30+1);
coldata->charlen =coldata->bytelen;
column->maxlength=coldata->bytelen;
if(public_datetime_format==DATETIME_FORMAT_NATIVE){
//use native
column->datatype = CS_CHAR_TYPE;
column->format = CS_FMT_NULLTERM;
}
break;
case CS_DATE_TYPE:
coldata->bytelen =max(sizeof(CS_DATETIME),16+1);
coldata->charlen =coldata->bytelen;
column->maxlength=coldata->bytelen;
if(public_datetime_format==DATETIME_FORMAT_NATIVE){
//use native
column->datatype = CS_CHAR_TYPE;
column->format = CS_FMT_NULLTERM;
}
break;
case CS_NUMERIC_TYPE:
case CS_DECIMAL_TYPE:
coldata->bytelen =column->precision+3;
coldata->charlen =coldata->bytelen;
column->maxlength=coldata->bytelen;
column->datatype = CS_CHAR_TYPE;
column->format = CS_FMT_NULLTERM;
break;
default:
coldata->bytelen =MIN(column->maxlength, MAXBUFSIZE)+1;
coldata->charlen =coldata->bytelen;
column->maxlength=coldata->bytelen;
column->datatype = CS_CHAR_TYPE;
column->format = CS_FMT_NULLTERM;
break;
}
coldata->type=column->datatype;
coldata->data=(char*)malloc( MAX(column->maxlength,coldata->bytelen)+2 );
}
CS_CONTEXT * getContext(CS_COMMAND*cmd){
static CS_CONTEXT * ctx=NULL;
CS_CONNECTION * con=NULL;
if(!ctx){
ct_cmd_props(cmd,CS_GET,CS_PARENT_HANDLE,&con,CS_UNUSED,NULL);
ct_con_props(con,CS_GET,CS_PARENT_HANDLE,&ctx,CS_UNUSED,NULL);
}
return ctx;
}
//function that makes conversion to string of all nonstring fields.
void ToString( CS_COMMAND*cmd, COLUMNDATA*coldata ){
//CS_CHAR tmpbuf[100];
CS_FLOAT f;
CS_REAL r;
CS_DATEREC daterec;
if(coldata->type!=CS_CHAR_TYPE){
if(coldata->ind!=-1){
//if not char then let's do the conversion
if(coldata->type==CS_FLOAT_TYPE){
f=((CS_FLOAT*)coldata->data)[0];
sprintf(coldata->data,"%.18g",f);
}else if(coldata->type==CS_REAL_TYPE){
f=((CS_REAL*)coldata->data)[0];
sprintf(coldata->data,"%.18g",f);
}else if(coldata->type==CS_DATE_TYPE){
cs_dt_crack(getContext(cmd), coldata->type, coldata->data, &daterec);
sprintf(coldata->data,"%04i-%02i-%02i",daterec.dateyear, daterec.datemonth+1, daterec.datedmonth);
}else if(coldata->type==CS_TIME_TYPE){
cs_dt_crack(getContext(cmd), coldata->type, coldata->data, &daterec);
if(public_datetime_format==DATETIME_FORMAT_SQL_S){
sprintf(coldata->data,"%02i:%02i:%02i",daterec.datehour, daterec.dateminute, daterec.datesecond);
}else{
sprintf(coldata->data,"%02i:%02i:%02i.%03i",daterec.datehour, daterec.dateminute, daterec.datesecond, daterec.datemsecond);
}
}else if(coldata->type==CS_DATETIME_TYPE || coldata->type==CS_DATETIME4_TYPE){
cs_dt_crack(getContext(cmd), coldata->type, coldata->data, &daterec);
if(public_datetime_format==DATETIME_FORMAT_SQL_S){
sprintf(coldata->data,"%04i-%02i-%02i %02i:%02i:%02i",daterec.dateyear, daterec.datemonth+1, daterec.datedmonth, daterec.datehour, daterec.dateminute, daterec.datesecond);
}else{
// if(public_date_format==DATE_FORMAT_SQL && public_time_format==TIME_FORMAT_FULL_MS)
sprintf(coldata->data,"%04i-%02i-%02i %02i:%02i:%02i.%03i",daterec.dateyear, daterec.datemonth+1, daterec.datedmonth, daterec.datehour, daterec.dateminute, daterec.datesecond, daterec.datemsecond);
}
}else{
sprintf(coldata->data,"???");
}
}
}else{
if(coldata->ind!=-1 && coldata->data[coldata->len]!=0 ){
//!!!feature of sybase: if we are connected to the unicode server with nonunicode charset,
//and there are some chars that could not be converted, sybase will not add null terminated char!!!
//probably we should add this check after all ct_fetch
coldata->data[coldata->len]=0;
}
}
}
//receives a calcel code
//CS_CANCEL_CURRENT , CS_CANCEL_ATTN , CS_CANCEL_ALL , or 0
//returns true if canceled , false if zero code received
BOOL FetchCancel(CS_COMMAND *cmd,CS_INT code){
switch(code){
case 0:
return false;
case CS_CANCEL_ALL:
ct_cancel(NULL, cmd, CS_CANCEL_ALL);
return true;
default:
ct_cancel(NULL, cmd, CS_CANCEL_CURRENT);
return true;
}
}
CS_STATIC CS_RETCODE CS_INTERNAL FetchComputeResults(SQLCONTEXT*sct,CS_COMMAND *cmd){
CS_RETCODE retcode;
CS_INT num_cols;
CS_INT i;
CS_INT j;
CS_INT rows_read;
CS_INT disp_len;
// CS_INT outlen;
CS_INT compinfo;
char *operation;
CS_DATAFMT datafmt;
COLUMNDATA *coldata=NULL;
RET_ON_FAIL(ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL),sct,"FetchComputeResults: ct_res_info() failed")
if (num_cols <= 0){
ERR(sct,"FetchComputeResults: ct_res_info() returned zero columns");
return CS_FAIL;
}
if( !ROW(sct,cmd,1) ){
return CS_SUCCEED;
}
coldata=(COLUMNDATA*)malloc(num_cols * sizeof (COLUMNDATA));
if (coldata == NULL){
ERR(sct,"FetchComputeResults: malloc() failed");
return CS_FAIL;
}
memset( coldata, 0, num_cols * sizeof (COLUMNDATA) );
for (i = 0; i < num_cols; i++){
retcode = ct_compute_info(cmd, CS_COMP_OP, (i + 1), &compinfo, CS_UNUSED, NULL);
if (retcode != CS_SUCCEED){
ERR(sct,"FetchComputeResults: ct_compute_info() failed");
break;
}
switch(compinfo){
case CS_OP_SUM: operation="SUM";break;
case CS_OP_AVG: operation="AVG";break;
case CS_OP_MIN: operation="MIN";break;
case CS_OP_MAX: operation="MAX";break;
case CS_OP_COUNT:operation="COUNT";break;
default: operation="???";
}
retcode = ct_compute_info(cmd, CS_COMP_COLID, (i + 1), &compinfo, CS_UNUSED, NULL);
if (retcode != CS_SUCCEED){
ERR(sct,"FetchComputeResults: ct_compute_info() failed");
break;
}
FLD(sct,compinfo,operation);
retcode = ct_describe(cmd, (i + 1), &datafmt);
if (retcode != CS_SUCCEED){
ERR(sct,"FetchComputeResults: ct_describe() failed");
break;
}
InitColData(&datafmt,&coldata[i]);
retcode = ct_bind(cmd, i+1, &datafmt,coldata[i].data, &coldata[i].len,&coldata[i].ind);
if (retcode != CS_SUCCEED){
ERR(sct,"FetchComputeResults: ct_bind() failed");
break;
}
}
ROWEND(sct,1);
if (retcode != CS_SUCCEED){
for (i = 0; i < num_cols; i++){
if(coldata[i].data)free(coldata[i].data);
coldata[i].data=NULL;
}
free(coldata);
return retcode;
}
/*
** Fetch the rows. Loop while ct_fetch() returns CS_SUCCEED or
** CS_ROW_FAIL
*/
while (((retcode = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED,
&rows_read)) == CS_SUCCEED) || (retcode == CS_ROW_FAIL))
{
if (retcode == CS_ROW_FAIL){
ERR(sct, "Error fetching row.");
}
if(rows_read==1){
if( !ROW(sct,cmd,2) ){
retcode=CS_SUCCEED;
break;
}
for (i = 0; i < num_cols; i++){
ToString(cmd,&coldata[i]);
retcode = ct_compute_info(cmd, CS_COMP_COLID, (i + 1), &compinfo, CS_UNUSED, NULL);
if (retcode != CS_SUCCEED){
ERR(sct,"FetchComputeResults: ct_compute_info() failed");
break;
}
FLD(sct,compinfo,(coldata[i].ind==-1?0:coldata[i].data));
}
ROWEND(sct,2);
}
}
for (i = 0; i < num_cols; i++){
if(coldata[i].data)free(coldata[i].data);
coldata[i].data=NULL;
}
free(coldata);
switch ((int)retcode){
case CS_END_DATA:
LOG(sct, "All done processing rows.");
retcode = CS_SUCCEED;
break;
case CS_FAIL:
ERR(sct,"FetchComputeResults: ct_fetch() failed");
return retcode;
default:
ERR(sct,"FetchComputeResults: ct_fetch() returned an expected retcode");
return retcode;
}
return retcode;
}
CS_RETCODE FetchData(SQLCONTEXT*sct,CS_COMMAND *cmd,int res_type,bool append){
CS_RETCODE retcode;
CS_INT num_cols;
CS_INT i;
CS_INT j;
CS_INT row_count = 0;
CS_INT rows_read;
CS_INT disp_len;
CS_DATAFMT datafmt;
COLUMNDATA *coldata=NULL;
char fname[MAX_FLD_NAME];
CS_BOOL has_br_info=false;
CS_INT br_tabnum;
char br_tabname[CS_OBJ_NAME+5];
LOG(sct, "FetchData enter.");
RET_ON_FAIL(ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL),sct,"FetchData: ct_res_info() failed")
if (num_cols <= 0){
ERR(sct,"FetchData: ct_res_info() returned zero columns");
return CS_FAIL;
}
//notify about new resultset
if(!append && res_type!=RS_TYPE_RET)RES(sct,res_type,num_cols);
//check if there is a browse information, then dispatch it
if(!append && res_type==RS_TYPE_DAT){
ct_res_info(cmd, CS_BROWSE_INFO, &has_br_info, CS_UNUSED, NULL);
if(has_br_info){
RET_ON_FAIL(ct_br_table(cmd, CS_UNUSED, CS_TABNUM, &br_tabnum, CS_UNUSED, NULL),sct,"FetchData: ct_br_table(CS_TABNUM) failed");
if(br_tabnum>0){
retcode=ct_br_table(cmd, 1, CS_TABNAME, br_tabname, CS_OBJ_NAME+5, NULL);
if(retcode==CS_SUCCEED){
if(br_tabnum>1)strcat(br_tabname,"...");
INFO(sct,RS_INFO_BR_TABLE,br_tabname);
}
}
}
}
coldata=(COLUMNDATA*)malloc(num_cols * sizeof (COLUMNDATA));
if (coldata == NULL){
ERR(sct,"FetchData: malloc() failed");
return CS_FAIL;
}
memset( coldata, 0, num_cols * sizeof (COLUMNDATA) );
for (i = 0; i < num_cols; i++){
retcode = ct_describe(cmd, (i + 1), &datafmt);
if (retcode != CS_SUCCEED){
ERR(sct,"FetchData: ct_describe() failed");
break;
}
strcpy(fname,DisplayType(&datafmt));
InitColData(&datafmt, &coldata[i]);
sprintf(fname+strlen(fname),"?%i?%s",coldata[i].charlen,datafmt.name);
if(!append && res_type!=RS_TYPE_RET)FLD_INFO(sct,i+1,fname);
retcode = ct_bind(cmd, i+1, &datafmt,coldata[i].data, &coldata[i].len,&coldata[i].ind);
if (retcode != CS_SUCCEED){
ERR(sct,"FetchData: ct_bind() failed");
break;
}
}
if(!append && res_type!=RS_TYPE_RET)ROWEND(sct,0);
if (retcode != CS_SUCCEED){
for (i = 0; i < num_cols; i++){
if(coldata[i].data)free(coldata[i].data);
coldata[i].data=NULL;
}
free(coldata);
return retcode;
}
/*
** Fetch the rows. Loop while ct_fetch() returns CS_SUCCEED or
** CS_ROW_FAIL
*/
while (((retcode = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED,
&rows_read)) == CS_SUCCEED) || (retcode == CS_ROW_FAIL))
{
row_count = row_count + rows_read;
if (retcode == CS_ROW_FAIL){
ERR(sct, "Error fetching row %i.",row_count);
}
if(rows_read==1){
if(res_type==RS_TYPE_RET){
INFO(sct,RS_INFO_RET,(coldata[0].ind==-1?0:coldata[0].data));
}else{
if( !ROW(sct,cmd,row_count) ){
retcode=CS_SUCCEED;
break;
}
for (i = 0; i < num_cols; i++){
ToString(cmd, &coldata[i]);
FLD(sct,i+1,(coldata[i].ind==-1?0:coldata[i].data));
}
ROWEND(sct,row_count);
}
}
}
for (i = 0; i < num_cols; i++){
if(coldata[i].data)free(coldata[i].data);
coldata[i].data=NULL;
}
free(coldata);
switch ((int)retcode){
case CS_END_DATA:
LOG(sct, "All done processing rows.");
retcode = CS_SUCCEED;
break;
case CS_FAIL:
ERR(sct,"FetchData: ct_fetch() failed");
return retcode;
default:
ERR(sct,"FetchData: ct_fetch() returned an expected retcode");
return retcode;
}
return retcode;
}
CS_RETCODE SendRowCount(SQLCONTEXT* sct,CS_COMMAND *cmd,char * info){
CS_INT outlen,rowcount;
CS_RETCODE ret;
char c[100];
ret=ct_res_info(cmd, CS_ROW_COUNT, &rowcount, sizeof(rowcount), &outlen);
// sprintf(c,"%i %s",rowcount,info);
if(rowcount < 0)return ret; //don't show -1 lines affected
sprintf(c,"%i",rowcount);
INFO(sct,RS_INFO_ROWS,c);
return ret;
}
CS_RETCODE HandleResults(SQLCONTEXT* sct,CS_COMMAND *cmd){
CS_RETCODE retcode;
CS_INT res_type;
BOOL append=false;
while( (retcode=ct_results(cmd, &res_type))==CS_SUCCEED ){
switch(res_type){
case CS_CMD_SUCCEED:
LOG(sct,"ct_results: result_type=CS_CMD_SUCCEED");
//SendRowCount(sct,cmd,"CS_CMD_SUCCEED");
break;
case CS_CMD_DONE:
append=false;
LOG(sct,"ct_results: result_type=CS_CMD_DONE");
SendRowCount(sct,cmd,"CS_CMD_DONE");
break;
case CS_CMD_FAIL:
ERR(sct,"ct_results: result_type=CS_CMD_FAIL");
SendRowCount(sct,cmd,"CS_CMD_FAIL");
ct_cancel(NULL, cmd, CS_CANCEL_ALL);
return CS_FAIL;
case CS_STATUS_RESULT:
LOG(sct,"ct_results: result_type=CS_STATUS_RESULT");
FetchData(sct,cmd,RS_TYPE_RET,false);
break;
case CS_PARAM_RESULT:
LOG(sct,"ct_results: result_type=CS_PARAM_RESULT");
FetchData(sct,cmd,RS_TYPE_OUT,false);
break;
case CS_ROW_RESULT:
LOG(sct,"ct_results: result_type=CS_ROW_RESULT");
FetchData(sct,cmd,RS_TYPE_DAT,append);
break;
case CS_COMPUTE_RESULT:
append=true;
LOG(sct,"ct_results: result_type=CS_COMPUTE_RESULT");
FetchComputeResults(sct,cmd);
break;
default:
ERR(sct,"ct_results returned unexpected result type: %i",res_type);
return CS_FAIL;
}
}
if(retcode!=CS_END_RESULTS){
ERR(sct,"ct_results() returns unexpected code: %i",retcode);
return CS_FAIL;
}
return CS_SUCCEED;
}
CS_RETCODE _sql_execute(SQLCONTEXT* sct,CS_COMMAND *cmd,char * query){
RET_ON_FAIL(ct_command(cmd,CS_LANG_CMD,query,CS_NULLTERM,CS_UNUSED),sct,"ct_command(CS_LANG_CMD) failed");
RET_ON_FAIL(ct_send(cmd),sct,"ct_send() failed");
RET_ON_FAIL(HandleResults(sct,cmd),sct,"HandleResults() failed");
return CS_SUCCEED;
}
CS_RETCODE _sql_dbgrpc_control(SQLCONTEXT* sct,CS_COMMAND *cmd,CS_INT spid, char * parm){
CS_DATAFMT datafmt;
RET_ON_FAIL(ct_command(cmd, CS_RPC_CMD, "$dbgrpc_control", CS_NULLTERM, CS_NO_RECOMPILE),sct,"_sql_dbgrpc_control: ct_command() failed");
memset(&datafmt, 0, sizeof (datafmt));
// datafmt.name[0]=0;
// datafmt.namelen = CS_NULLTERM;
datafmt.datatype = CS_INT_TYPE;
datafmt.maxlength = CS_UNUSED;
datafmt.status = CS_INPUTVALUE;
RET_ON_FAIL(ct_param(cmd, &datafmt, (CS_VOID *)&spid,CS_SIZEOF(CS_INT), CS_UNUSED ),sct,"_sql_dbgrpc_control: ct_param(CS_INT) failed");
memset(&datafmt, 0, sizeof (datafmt));
// datafmt.name[0]=0;
// datafmt.namelen = 0;
datafmt.datatype = CS_CHAR_TYPE;
datafmt.maxlength = CS_NULLTERM;
datafmt.status = CS_INPUTVALUE;
RET_ON_FAIL(ct_param(cmd, &datafmt, parm, CS_NULLTERM, ( (parm&&parm[0])?1:-1) ),sct,"_sql_dbgrpc_control: ct_param(char) failed");
RET_ON_FAIL(ct_send(cmd),sct,"ct_send() failed");
RET_ON_FAIL(HandleResults(sct,cmd),sct,"HandleResults() failed");
return CS_SUCCEED;
}
BOOL APIENTRY DllMain( HANDLE hModule, DWORD reason, LPVOID lpReserved){
return TRUE;
}
void sqlctx_init(SQLCONTEXT * sct,HWND hwnd,pbobject *callback){
sct->hwnd=hwnd;
sct->callback=callback;
public_sqlctx=sct;
}
void sqlctx_finit(SQLCONTEXT * sql){
public_sqlctx=NULL;
}
//-----------------------------------------------------------------------------
// Main exported function
//
int __stdcall sql_execute(CS_CONNECTION *connection,char * query,HWND hwnd){
CS_RETCODE retcode;
CS_COMMAND *cmd;
SQLCONTEXT sct;
DBG(flog = fopen("syb_exec.log","at"));
DBG(fprintf(flog,"sql_execute enter\n"));
if(!connection)return 0;
sqlctx_init(&sct,hwnd,NULL);
retcode=ct_cmd_alloc(connection, &cmd);
if ( retcode==CS_SUCCEED ){
install_cli_message_callback(&sct,cmd);
install_message_callback(&sct,cmd);
retcode=_sql_execute(&sct,cmd,query);
return_message_callback(&sct,cmd);
return_cli_message_callback(&sct,cmd);
ct_cmd_drop(cmd);
}else{
ERR(&sct,"sql_execute: ct_cmd_alloc() failed");
}
sqlctx_finit(&sct);
DBG(fprintf(flog,"sql_execute exit\n"));
DBG(fflush(flog));
DBG(fclose(flog));
return (retcode == CS_SUCCEED) ? 1 : 0;
}
//-----------------------------------------------------------------------------
// Main exported function 2
//
int __stdcall sql_execute2(CS_CONNECTION *connection,char * query,pbobject * callback){
CS_RETCODE retcode;
CS_COMMAND *cmd;
SQLCONTEXT sct;
DBG(flog = fopen("syb_exec.log","at"));
DBG(fprintf(flog,"sql_execute2 enter\n"));
if(!connection)return 0;
sqlctx_init(&sct,NULL,callback);
retcode=ct_cmd_alloc(connection, &cmd);
if ( retcode==CS_SUCCEED ){
install_cli_message_callback(&sct,cmd);
install_message_callback(&sct,cmd);
retcode=_sql_execute(&sct,cmd,query);
return_message_callback(&sct,cmd);
return_cli_message_callback(&sct,cmd);
ct_cmd_drop(cmd);
}else{
ERR(&sct,"sql_execute2: ct_cmd_alloc() failed");
}
DBG(fprintf(flog,"sql_execute2 exit\n"));
DBG(fflush(flog));
DBG(fclose(flog));
sqlctx_finit(&sct);
return (retcode == CS_SUCCEED) ? 1 : 0;
}
//returns true if client library supports version specified by parameter
int __stdcall sql_ctversion(int ver){
CS_RETCODE retcode;
CS_CONTEXT *ctx;
// Get a context handle to use.
retcode = cs_ctx_alloc(ver, &ctx);
if (retcode == CS_SUCCEED){
cs_ctx_drop(ctx);
}else{
remove("sybinit.err");
}
return (retcode == CS_SUCCEED) ? 1 : 0;
}
int __stdcall sql_dbgrpc_control(CS_CONNECTION *connection,int spid, char * parm,HWND hwnd){
CS_RETCODE retcode;
CS_COMMAND *cmd;
SQLCONTEXT sct;
DBG(flog = fopen("syb_exec.log","at"));
DBG(fprintf(flog,"sql_dbgrpc_control enter\n"));
if(!connection)return 0;
sqlctx_init(&sct,hwnd,NULL);
retcode=ct_cmd_alloc(connection, &cmd);
if ( retcode==CS_SUCCEED ){
install_cli_message_callback(&sct,cmd);
install_message_callback(&sct,cmd);
retcode=_sql_dbgrpc_control(&sct,cmd, spid, parm);
return_message_callback(&sct,cmd);
return_cli_message_callback(&sct,cmd);
ct_cmd_drop(cmd);
}else{
ERR(&sct,"sql_dbgrpc_control: ct_cmd_alloc() failed");
}
DBG(fprintf(flog,"sql_dbgrpc_control exit\n"));
DBG(fflush(flog));
DBG(fclose(flog));
sqlctx_finit(&sct);
return (retcode == CS_SUCCEED) ? 1 : 0;
}
//-------------------------------------------------------------------
//---------------------- UTF8 check -----------------------
//-------------------------------------------------------------------
// taken from ftp://www.unicode.org/Public/PROGRAMS/CVTUTF
static const unsigned char trailingBytesForUTF8[256] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
};
//determines if the sequence of chars represents legal utf8 character
bool isLegalUTF8Char(const unsigned char *source, int length) {
unsigned char a;
const unsigned char *srcptr = source+length;
switch (length) {
default: return false;
// Everything else falls through when "true"
case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
case 2: if ((a = (*--srcptr)) > 0xBF) return false;
switch (*source) {
// no fall-through in this inner switch
case 0xE0: if (a < 0xA0) return false; break;
case 0xED: if (a > 0x9F) return false; break;
case 0xF0: if (a < 0x90) return false; break;
case 0xF4: if (a > 0x8F) return false; break;
default: if (a < 0x80) return false;
}
case 1: if (*source >= 0x80 && *source < 0xC2) return false;
}
if (*source > 0xF4) return false;
return true;
}
long __stdcall isLegalUTF8(const unsigned char *s,DWORD len,bool defaultUTF8) {
bool hasMultibyteChars=false;
DWORD i = 0, charBytes = 0;
if(len>2){
//if there is utf8 bom then skip it
if(s[0]==0xEF && s[1]==0xBB && s[2]==0xBF){
i=3;
}
}
while(i<len){
charBytes = trailingBytesForUTF8[s[i]] + 1;
if(charBytes>1){
hasMultibyteChars=true;
}
if ( !isLegalUTF8Char(s+i, charBytes) ) {
return false;
}
i+=charBytes;
}
if(hasMultibyteChars || defaultUTF8)return true;
return false;
}
bool __stdcall sql_property_set(int prop, int value){
switch(prop){
case PROP_FORMAT_DATETIME:
public_datetime_format=value;
break;
default:
return false;
}
return true;
}
int __stdcall sql_cancel_all(CS_CONNECTION *connection){
return (int)ct_cancel(connection, NULL, CS_CANCEL_ALL);
}
}//extern "C"
/**************************************************************************
-=========== PBNATIVE TO SEND RESPONCE TO PB NONVISUAL OBJECT ==========-
**************************************************************************/
PBXEXPORT LPCTSTR PBXCALL PBX_GetDescription(){
static const TCHAR desc[] = {
"class cppdummy from nonvisualobject\n"
"function long dummy()\n"
"end class\n"
};
return desc;
}
class CppDummy : public IPBX_NonVisualObject {
enum { mDummy = 0 };
public:
CppDummy(){}
~CppDummy(){}
void Destroy(){ delete this; }
PBXRESULT Invoke (IPB_Session *session, pbobject obj, pbmethodID mid, PBCallInfo *ci ) {
switch(mid) {
case mDummy:
ci->returnValue->SetLong(0);
break;
default:
return PBX_E_INVALID_METHOD_ID;
}
return PBX_OK;
}
};
PBXEXPORT PBXRESULT PBXCALL PBX_CreateNonVisualObject (
IPB_Session*pbsession, pbobject pbobj, LPCTSTR className, IPBX_NonVisualObject **obj ) {
if ( !strcmp((char*)className,"cppdummy") ){
*obj = new CppDummy();
} else {
*obj = NULL;
return PBX_E_NO_SUCH_CLASS;
}
return PBX_OK;
}
PBXEXPORT PBXRESULT PBXCALL PBX_Notify ( IPB_Session* pbsession, pbint reasonForCall ) {
//store PB session to make a callback to PB Object later
g_IPB_Session=pbsession;
switch(reasonForCall) {
case kAfterDllLoaded:
case kBeforeDllUnloaded:
break;
}
return PBX_OK;
}
| [
"[email protected]@9f3282c0-2842-11de-b858-7de967f63ef5"
] | [
[
[
1,
1190
]
]
] |
b6f1507368a62696e0a726d557826e747be8da9c | ce1b0d027c41f70bc4cfa13cb05f09bd4edaf6a2 | / edge2d --username [email protected]/Plugins/IrrSoundSystem/IrrKlang/include/ISoundEffectControl.h | 195d3238f5917280b4233e8af43a2e8d516769f8 | [] | 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 | 14,224 | h | // Copyright (C) 2002-2007 Nikolaus Gebhardt
// This file is part of the "irrKlang" library.
// For conditions of distribution and use, see copyright notice in irrKlang.h
#ifndef __I_SOUND_EFFECT_CONTROL_H_INCLUDED__
#define __I_SOUND_EFFECT_CONTROL_H_INCLUDED__
#include "IVirtualUnknown.h"
#include "vector3d.h"
namespace irr
{
namespace audio
{
//! Interface to control the active sound effects (echo, reverb,...) of an ISound object, a playing sound.
/** Sound effects such as chorus, distorsions, echo, reverb and similar can
be controlled using this. An instance of this interface can be obtained via
ISound::getSoundEffectControl(). The sound containing this interface has to be started via
ISoundEngine::play2D() or ISoundEngine::play3D() with the flag enableSoundEffects=true,
otherwise no acccess to this interface will be available.
For the DirectSound driver, these are effects available since DirectSound8. For most
effects, sounds should have a sample rate of 44 khz and should be at least
150 milli seconds long for optimal quality when using the DirectSound driver.
Note that the interface pointer is only valid as long as
the ISound pointer is valid. If the ISound pointer gets dropped (IVirtualUnknown::drop()),
the ISoundEffects may not be used any more. */
class ISoundEffectControl
{
public:
//! Disables all active sound effects
virtual void disableAllEffects() = 0;
//! Enables the chorus sound effect or adjusts its values.
/** Chorus is a voice-doubling effect created by echoing the
original sound with a slight delay and slightly modulating the delay of the echo.
If this sound effect is already enabled, calling this only modifies the parameters of the active effect.
\param fWetDryMix Ratio of wet (processed) signal to dry (unprocessed) signal. Minimal Value:0, Maximal Value:100.0f;
\param fDepth Percentage by which the delay time is modulated by the low-frequency oscillator, in hundredths of a percentage point. Minimal Value:0, Maximal Value:100.0f;
\param fFeedback Percentage of output signal to feed back into the effect's input. Minimal Value:-99, Maximal Value:99.0f;
\param fFrequency Frequency of the LFO. Minimal Value:0, Maximal Value:10.0f;
\param sinusWaveForm True for sinus wave form, false for triangle.
\param fDelay Number of milliseconds the input is delayed before it is played back. Minimal Value:0, Maximal Value:20.0f;
\param lPhase Phase differential between left and right LFOs. Possible values:
-180, -90, 0, 90, 180
\return Returns true if successful. */
virtual bool enableChorusSoundEffect(f32 fWetDryMix = 50,
f32 fDepth = 10,
f32 fFeedback = 25,
f32 fFrequency = 1.1,
bool sinusWaveForm = true,
f32 fDelay = 16,
s32 lPhase = 90) = 0;
//! removes the sound effect from the sound
virtual void disableChorusSoundEffect() = 0;
//! returns if the sound effect is active on the sound
virtual bool isChorusSoundEffectEnabled() = 0;
//! Enables the Compressor sound effect or adjusts its values.
/** Compressor is a reduction in the fluctuation of a signal above a certain amplitude.
If this sound effect is already enabled, calling this only modifies the parameters of the active effect.
\param fGain Output gain of signal after Compressor. Minimal Value:-60, Maximal Value:60.0f;
\param fAttack Time before Compressor reaches its full value. Minimal Value:0.01, Maximal Value:500.0f;
\param fRelease Speed at which Compressor is stopped after input drops below fThreshold. Minimal Value:50, Maximal Value:3000.0f;
\param fThreshold Point at which Compressor begins, in decibels. Minimal Value:-60, Maximal Value:0.0f;
\param fRatio Compressor ratio. Minimal Value:1, Maximal Value:100.0f;
\param fPredelay Time after lThreshold is reached before attack phase is started, in milliseconds. Minimal Value:0, Maximal Value:4.0f;
\return Returns true if successful. */
virtual bool enableCompressorSoundEffect( f32 fGain = 0,
f32 fAttack = 10,
f32 fRelease = 200,
f32 fThreshold = -20,
f32 fRatio = 3,
f32 fPredelay = 4) = 0;
//! removes the sound effect from the sound
virtual void disableCompressorSoundEffect() = 0;
//! returns if the sound effect is active on the sound
virtual bool isCompressorSoundEffectEnabled() = 0;
//! Enables the Distortion sound effect or adjusts its values.
/** Distortion is achieved by adding harmonics to the signal in such a way that,
If this sound effect is already enabled, calling this only modifies the parameters of the active effect.
as the level increases, the top of the waveform becomes squared off or clipped.
\param fGain Amount of signal change after distortion. Minimal Value:-60, Maximal Value:0;
\param fEdge Percentage of distortion intensity. Minimal Value:0, Maximal Value:100;
\param fPostEQCenterFrequency Center frequency of harmonic content addition. Minimal Value:100, Maximal Value:8000;
\param fPostEQBandwidth Width of frequency band that determines range of harmonic content addition. Minimal Value:100, Maximal Value:8000;
\param fPreLowpassCutoff Filter cutoff for high-frequency harmonics attenuation. Minimal Value:100, Maximal Value:8000;
\return Returns true if successful. */
virtual bool enableDistortionSoundEffect(f32 fGain = -18,
f32 fEdge = 15,
f32 fPostEQCenterFrequency = 2400,
f32 fPostEQBandwidth = 2400,
f32 fPreLowpassCutoff = 8000) = 0;
//! removes the sound effect from the sound
virtual void disableDistortionSoundEffect() = 0;
//! returns if the sound effect is active on the sound
virtual bool isDistortionSoundEffectEnabled() = 0;
//! Enables the Echo sound effect or adjusts its values.
/** An echo effect causes an entire sound to be repeated after a fixed delay.
If this sound effect is already enabled, calling this only modifies the parameters of the active effect.
\param fWetDryMix Ratio of wet (processed) signal to dry (unprocessed) signal. Minimal Value:0, Maximal Value:100.0f;
\param fFeedback Percentage of output fed back into input. Minimal Value:0, Maximal Value:100.0f;
\param fLeftDelay Delay for left channel, in milliseconds. Minimal Value:1, Maximal Value:2000.0f;
\param fRightDelay Delay for right channel, in milliseconds. Minimal Value:1, Maximal Value:2000.0f;
\param lPanDelay Value that specifies whether to swap left and right delays with each successive echo. Minimal Value:0, Maximal Value:1;
\return Returns true if successful. */
virtual bool enableEchoSoundEffect(f32 fWetDryMix = 50,
f32 fFeedback = 50,
f32 fLeftDelay = 500,
f32 fRightDelay = 500,
s32 lPanDelay = 0) = 0;
//! removes the sound effect from the sound
virtual void disableEchoSoundEffect() = 0;
//! returns if the sound effect is active on the sound
virtual bool isEchoSoundEffectEnabled() = 0;
//! Enables the Flanger sound effect or adjusts its values.
/** Flange is an echo effect in which the delay between the original
signal and its echo is very short and varies over time. The result is
sometimes referred to as a sweeping sound. The term flange originated
with the practice of grabbing the flanges of a tape reel to change the speed.
If this sound effect is already enabled, calling this only modifies the parameters of the active effect.
\param fWetDryMix Ratio of wet (processed) signal to dry (unprocessed) signal. Minimal Value:0, Maximal Value:100.0f;
\param fDepth Percentage by which the delay time is modulated by the low-frequency oscillator, in hundredths of a percentage point. Minimal Value:0, Maximal Value:100.0f;
\param fFeedback Percentage of output signal to feed back into the effect's input. Minimal Value:-99, Maximal Value:99.0f;
\param fFrequency Frequency of the LFO. Minimal Value:0, Maximal Value:10.0f;
\param triangleWaveForm True for triangle wave form, false for square.
\param fDelay Number of milliseconds the input is delayed before it is played back. Minimal Value:0, Maximal Value:20.0f;
\param lPhase Phase differential between left and right LFOs. Possible values:
-180, -90, 0, 90, 180
\return Returns true if successful. */
virtual bool enableFlangerSoundEffect(f32 fWetDryMix = 50,
f32 fDepth = 100,
f32 fFeedback = -50,
f32 fFrequency = 0.25f,
bool triangleWaveForm = true,
f32 fDelay = 2,
s32 lPhase = 0) = 0;
//! removes the sound effect from the sound
virtual void disableFlangerSoundEffect() = 0;
//! returns if the sound effect is active on the sound
virtual bool isFlangerSoundEffectEnabled() = 0;
//! Enables the Gargle sound effect or adjusts its values.
/** The gargle effect modulates the amplitude of the signal.
If this sound effect is already enabled, calling this only modifies the parameters of the active effect.
\param rateHz Rate of modulation, in Hertz. Minimal Value:1, Maximal Value:1000
\param sinusWaveForm True for sinus wave form, false for triangle.
\return Returns true if successful. */
virtual bool enableGargleSoundEffect(s32 rateHz = 20, bool sinusWaveForm = true) = 0;
//! removes the sound effect from the sound
virtual void disableGargleSoundEffect() = 0;
//! returns if the sound effect is active on the sound
virtual bool isGargleSoundEffectEnabled() = 0;
//! Enables the Interactive 3D Level 2 reverb sound effect or adjusts its values.
/** An implementation of the listener properties in the I3DL2 specification. Source properties are not supported.
If this sound effect is already enabled, calling this only modifies the parameters of the active effect.
\param lRoom Attenuation of the room effect, in millibels (mB). Interval: [-10000, 0] Default: -1000 mB
\param lRoomHF Attenuation of the room high-frequency effect. Interval: [-10000, 0] default: 0 mB
\param flRoomRolloffFactor Rolloff factor for the reflected signals. Interval: [0.0, 10.0] default: 0.0
\param flDecayTime Decay time, in seconds. Interval: [0.1, 20.0] default: 1.49s
\param flDecayHFRatio Ratio of the decay time at high frequencies to the decay time at low frequencies. Interval: [0.1, 2.0] default: 0.83
\param lReflections Attenuation of early reflections relative to lRoom. Interval: [-10000, 1000] default: -2602 mB
\param flReflectionsDelay Delay time of the first reflection relative to the direct path in seconds. Interval: [0.0, 0.3] default: 0.007 s
\param lReverb Attenuation of late reverberation relative to lRoom, in mB. Interval: [-10000, 2000] default: 200 mB
\param flReverbDelay Time limit between the early reflections and the late reverberation relative to the time of the first reflection. Interval: [0.0, 0.1] default: 0.011 s
\param flDiffusion Echo density in the late reverberation decay in percent. Interval: [0.0, 100.0] default: 100.0 %
\param flDensity Modal density in the late reverberation decay, in percent. Interval: [0.0, 100.0] default: 100.0 %
\param flHFReference Reference high frequency, in hertz. Interval: [20.0, 20000.0] default: 5000.0 Hz
\return Returns true if successful. */
virtual bool enableI3DL2ReverbSoundEffect(s32 lRoom = -1000,
s32 lRoomHF = -100,
f32 flRoomRolloffFactor = 0,
f32 flDecayTime = 1.49f,
f32 flDecayHFRatio = 0.83f,
s32 lReflections = -2602,
f32 flReflectionsDelay = 0.007f,
s32 lReverb = 200,
f32 flReverbDelay = 0.011f,
f32 flDiffusion = 100.0f,
f32 flDensity = 100.0f,
f32 flHFReference = 5000.0f ) = 0;
//! removes the sound effect from the sound
virtual void disableI3DL2ReverbSoundEffect() = 0;
//! returns if the sound effect is active on the sound
virtual bool isI3DL2ReverbSoundEffectEnabled() = 0;
//! Enables the ParamEq sound effect or adjusts its values.
/** Parametric equalizer amplifies or attenuates signals of a given frequency.
If this sound effect is already enabled, calling this only modifies the parameters of the active effect.
\param fCenter Center frequency, in hertz, The default value is 8000. Minimal Value:80, Maximal Value:16000.0f
\param fBandwidth Bandwidth, in semitones, The default value is 12. Minimal Value:1.0f, Maximal Value:36.0f
\param fGain Gain, default value is 0. Minimal Value:-15.0f, Maximal Value:15.0f
\return Returns true if successful. */
virtual bool enableParamEqSoundEffect(f32 fCenter = 8000,
f32 fBandwidth = 12,
f32 fGain = 0) = 0;
//! removes the sound effect from the sound
virtual void disableParamEqSoundEffect() = 0;
//! returns if the sound effect is active on the sound
virtual bool isParamEqSoundEffectEnabled() = 0;
//! Enables the Waves Reverb sound effect or adjusts its values.
/** \param fInGain Input gain of signal, in decibels (dB). Min/Max: [-96.0,0.0] Default: 0.0 dB.
If this sound effect is already enabled, calling this only modifies the parameters of the active effect.
\param fReverbMix Reverb mix, in dB. Min/Max: [-96.0,0.0] Default: 0.0 dB
\param fReverbTime Reverb time, in milliseconds. Min/Max: [0.001,3000.0] Default: 1000.0 ms
\param fHighFreqRTRatio High-frequency reverb time ratio. Min/Max: [0.001,0.999] Default: 0.001
\return Returns true if successful. */
virtual bool enableWavesReverbSoundEffect(f32 fInGain = 0,
f32 fReverbMix = 0,
f32 fReverbTime = 1000,
f32 fHighFreqRTRatio = 0.001f) = 0;
//! removes the sound effect from the sound
virtual void disableWavesReverbSoundEffect() = 0;
//! returns if the sound effect is active on the sound
virtual bool isWavesReverbSoundEffectEnabled() = 0;
};
} // end namespace audio
} // end namespace irr
#endif
| [
"[email protected]@539dfdeb-0f3d-0410-9ace-d34ff1985647"
] | [
[
[
1,
246
]
]
] |
3619ec6759526fbfa1d60c9654e494b69aec0b53 | 21da454a8f032d6ad63ca9460656c1e04440310e | /src/wcpp/wscom/main/wscComponentRegistrar.h | 7e5daa838d722d68df2081c55c63b6a858e8e872 | [] | 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 | 2,055 | h | #pragma once
#include <wcpp/lang/wscObject.h>
#include "wsiComponentRegistrarEx.h"
class wsiDirectoryServiceProvider;
class wscComponentRegistrar : public wsiComponentRegistrar
{
WS_IMPL_QUERY_INTERFACE_BEGIN( wscComponentRegistrar )
WS_IMPL_QUERY_INTERFACE_BODY( wsiComponentRegistrar )
WS_IMPL_QUERY_INTERFACE_END()
public:
static const ws_char * const s_class_name;
public:
wscComponentRegistrar(void);
~wscComponentRegistrar(void);
protected:
WS_METHOD( ws_result, AutoRegister )( wsiFile * aSpec );
WS_METHOD( ws_result, AutoUnregister )( wsiFile * aSpec );
WS_METHOD( ws_result, RegisterFactory )( const ws_cid & aClass, wsiString * aClassName, wsiString * aContractID, wsiFactory * aFactory );
WS_METHOD( ws_result, UnregisterFactory )( const ws_cid & aClass, wsiFactory * aFactory );
WS_METHOD( ws_result, RegisterFactoryLocation )( const ws_cid & aClass, wsiString * aClassName, wsiString * aContractID, wsiFile * aFile, wsiString * aLoaderStr, wsiString * aType);
WS_METHOD( ws_result, UnregisterFactoryLocation )( const ws_cid & aClass, wsiFile * aFile );
WS_METHOD( ws_boolean, IsCIDRegistered )( const ws_cid & aClass );
WS_METHOD( ws_boolean, IsContractIDRegistered )( wsiString * aContractID );
WS_METHOD( ws_result, EnumerateCIDs )( wsiSimpleEnumerator ** rEnum );
WS_METHOD( ws_result, EnumerateContractIDs )( wsiSimpleEnumerator ** rEnum );
WS_METHOD( ws_result, CIDToContractID )( const ws_cid & aClass, wsiString ** rContractID );
WS_METHOD( ws_result, ContractIDToCID )( wsiString * aContractID, ws_cid & rClass );
void _StartComponentRegistrar(void);
void _StopComponentRegistrar(void);
private:
ws_result AutoRegisterDir( wsiFile * aSpec );
ws_result AutoRegisterFile( wsiFile * aSpec );
private:
ws_boolean m_started;
ws_boolean m_stopped;
};
| [
"xukun0217@98f29a9a-77f1-11de-91f8-ab615253d9e8"
] | [
[
[
1,
51
]
]
] |
e763337828c98cbc09044d66fc67b079118d17e7 | 584d088c264ac58050ed0757b08d032b6c7fc83b | /oldGUI/Video_D3D9.h | b3e1d72744329c42bc58fcdc4dfc3005be544a3e | [] | no_license | littlewingsoft/lunaproject | a843ca37c04bdc4e1e4e706381043def1789ab39 | 9102a39deaad74b2d73ee0ec3354f37f6f85702f | refs/heads/master | 2020-05-30T15:21:20.515967 | 2011-02-04T18:41:43 | 2011-02-04T18:41:43 | 32,302,109 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 11,325 | h | // D3D.h: interface for the CD3D class.
//
//////////////////////////////////////////////////////////////////////
#pragma once
#pragma comment(lib, "dxguid.lib" )
#pragma comment(lib, "dxerr9.lib" )
#pragma comment(lib, "d3d9.lib" )
#pragma comment(lib, "d3dx9.lib" )
#include <cassert>
#include <d3dx9.h>
#include <TCHAR.h>
#pragma warning(disable: 4786)
#include <string>
#include <map>
using namespace std;
typedef basic_string<TCHAR> tstring;
#define DEF_WINWIDTH 800
#define DEF_WINHEIGHT 600
#ifndef STRICT
#define STRICT
#endif
#define WIN32_LEAN_AND_MEAN
/*
#ifndef DIRECT3D_VERSION
#define DIRECT3D_VERSION 0x0801
#endif
*/
#define DX_PI ((FLOAT) 3.141592654f)
#define DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f))
#define DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI))
//ํํฝ์
์ ํ๋ฐฑ๋น์จ 31 53 16
#define DRGBA(r,g,b,a) ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
#define DRGB(r,g,b) ((D3DCOLOR)(((0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
#define GETA(rgb) ((BYTE)((rgb)>>24))
#define GETR(rgb) ((BYTE)((rgb)>>16))
#define GETG(rgb) ((BYTE)(((WORD)(rgb)) >> 8))
#define GETB(rgb) ((BYTE)(rgb))
#define GETRGB(rgb) ((DWORD)(rgb<<8) )
struct RES_ANI;
struct UNION_ARGB
{
union {
struct {
DWORD _B:8;
DWORD _G:8;
DWORD _R:8;
DWORD _A:8;
};
DWORD _ARGB;
};
UNION_ARGB(BYTE A,BYTE R, BYTE G, BYTE B)
{
_A=A;
_R=R;
_G=G;
_B=B;
}
//UNION_ARGB(){}
UNION_ARGB( DWORD clr )
{
_ARGB = clr;
}
void operator = (DWORD argb)
{
_ARGB = argb;
}
};
//UNION_ARGB aaa = 0xffaabbcc;
//aaa = 0xaaaaaaaa;
//UNION_ARGB ttt = aaa;
#define D3D_MIRRORNONE 0 // ์๋ฐ๊ฟ
#define D3D_MIRRORLEFTRIGHT 1 // ์ข์ฐ๋ฅผ ๋ฐ๊ฟ
#define D3D_MIRRORUPDOWN 2 // ์์๋๋ฅผ ๋ฐ๊ฟ
#define FC __fastcall
/*
#define MAX_TEXTURE 640
#define MAX_DRAWPARAM 792
#define MAX_LAYERCNT 7
*/
#define D3D_MAX_FAR_LAYER0 0 // ๋งจ๋ค, ๋ด๋์์ ๋จผ์ชฝ๋ฐฉํฅ์ผ๋ก์ ์ต๊ณ ๋ ๋ ์ด์ด
#define D3D_MAX_FAR_LAYER1 1
#define D3D_MAX_FAR_LAYER2 2
#define D3D_Y_SORT_LAYER0 3 // y์ถ ์ ๋ ฌ์ด ํ์ํ ๋ ์ด์ด
#define D3D_INTERFACE_LAYER0 4 // GUI ๋ค..
#define D3D_INTERFACE_LAYER1 5 //
#define D3D_INTERFACE_LAYER2 6 // ํฌ์ปค์ค ์ฌ๋ผ๊ฐ GUI
enum D3DCONST
{
D3D_NORMALSTATE=0,D3D_GASANSTATE=1,D3D_ALPHASTATE=2 ,
MAX_TEXTURE= 640, MAX_DRAWPARAM= 792,MAX_LAYERCNT=7,
};
class IDrawObj
{
public:
IDrawObj(){}
~IDrawObj(){}
virtual void Draw() = 0;
};
class CBltSprite : public IDrawObj
{
protected :
int m_TextureIndex; // ํ
์ค์ณ์ ์ธ๋ฑ์ค
RECT m_srcRt; // ์๋ณธ์์ ๋ผ์ด์ฌ ์ฌ๊ฐํ๊ฐ
RECT m_destRt;
D3DCOLOR m_Color; // ์ํ์ ๋ชจ๋๋ ์ดํ
ํ๋ ๊ฐ
// D3DXVECTOR2 m_Scaling; // ํ๋๋ฐ ์ถ์๋ฅผ ํ ๊ฐ
// D3DXVECTOR2 m_Center; // ํ์ ,์ด๋์ ์ฐ์ผ ์ค์ ์ ๊ฐ ๊ธฐ๋ณธ์ 0,0 ์
// float m_Rotation; // ํ์ ๊ฐ
// D3DXVECTOR2 m_Translation; // ์ด๋ํ๋๊ฐ
DWORD m_hState; // ๊ทธ๋ฆฌ๊ธฐ ์ํ ํธ๋ค๊ฐ
public:
static int BltSpriteCnt;
inline float GetSortY(void){ return (float)m_destRt.bottom; /*m_Translation.y;*/ }//m_SortY
CBltSprite(){}
~CBltSprite(){}
//
//void BltSprite( int TxtNum, RECT& SrcRect, RECT& DestRect );
//void BltSprite( int TxtNum, float x,float y,D3DCONST RenderMODE = D3D_NORMALSTATE );
//void BltSprite( int TxtNum, RECT& SrcRect, RECT& DestRect,D3DCOLOR Clr,D3DCONST RenderMODE = D3D_NORMALSTATE );
//void BltSprite( int TxtNum, RECT &SrcRect, RECT& DestRect,float rad,
// POINT rcenter, D3DCOLOR Clr, D3DCONST RenderMODE = D3D_NORMALSTATE );
// void BltSprite( int TxtNum, const RECT& SrcRect, const RECT & DestRect,
// DWORD dwFlags, D3DCOLOR Modulate, float rad, POINT *pCenter, D3DCONST RenderMODE /*D3D_NORMALSTATE*/ ); //= D3D_NORMALSTATE
void BltSprite( int TxtNum, const RECT& SrcRect, const RECT & DestRect, D3DCOLOR Modulate, D3DCONST RenderMODE /*D3D_NORMALSTATE*/ ); //= D3D_NORMALSTATE
//////////////////// abstract Func
void Draw();
};
///////////////////////////////////// Sprite Declare End
class CBltText: public IDrawObj
{
protected:
RECT m_BoundRect;
D3DCOLOR m_Clr;
TCHAR m_StrBuff[256];
DWORD m_Flag ;
public:
static int BltTextCnt;
CBltText(){}
~CBltText(){}
void BltText( int x, int y, D3DCOLOR rgbFontColour, const TCHAR* pText );
void BltText( RECT& rt, D3DCOLOR rgbFontColour, const TCHAR* pText );
void Draw();
};
///////////////////////////////////// Font Declare End
struct SIMPLETEXTURE
{
LPDIRECT3DTEXTURE9 lpTexture;
int RefCnt;
void Release();
};
#define rhw
struct SpriteVertex
{
#ifdef rhw
enum {D3DFVF_SPRITEVERTEX = (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1) };
D3DXVECTOR4 Pos;
D3DCOLOR Clr;
float tu,tv;
#else
D3DXVECTOR3 Pos;
enum {D3DFVF_SPRITEVERTEX = D3DFVF_XYZ };
#endif
};
class CD3D
{
public:
bool IsTransparentColor(int TextureID, int x, int y,DWORD ClrKey=0x00000000 );
D3DXMATRIX m_matTex;
D3DXMATRIX m_matMoveScale;
SpriteVertex m_vtx[4];
void ReleaseANI(int TexID);
CD3D();
virtual ~CD3D();
void ApplyStateBlock( DWORD Block )
{
HRESULT hr = m_hStateBlock[ Block ]->Apply(); assert( hr == D3D_OK);
}
void ClearAllParam(void);
void Present(void);
int GetTextureCNT(void);
TCHAR* GetD3DErr(HRESULT hr );
HWND GethWnd(){ return m_hWnd; }
int ScreenShot( const TCHAR* fName ); // ํ์ฌ ํ๋ฉด์ ์ค์ท์ผ๋ก ์ ์ฅํด์ค
void SetGamma( long Gamma ); // Gamma 0~255
void FillScreen( D3DCOLOR Clr= D3DCOLOR_XRGB(0,128,255) );
void ReleaseAll(void);
HRESULT InitD3D(int wWidth, int wHeight, bool bFull );
void InitFont( const TCHAR* pFontFace, int nHeight=12,
bool fBold=false, bool fItalic=false, bool fUnderlined=false );
// inline LPD3DXSPRITE GetSprite(){ return m_Sprite; }
inline LPDIRECT3DDEVICE9& GetDevice(){ return m_D3DDevice; }
int LoadAni( const TCHAR* fName, RES_ANI& pObj );
int RegistWindow( TCHAR* lpSz, HICON hIcon, WNDPROC WndProc );
int GetWinWidth() { return m_WinWidth; }
int GetWinHeight(){ return m_WinHeight; }
inline LPDIRECT3DTEXTURE9& GetTexture(int Index){ return m_Texture[Index].lpTexture; }
inline SIZE GetActualImgSize(int Index){ return m_ActualImgSize[Index]; }
bool IsFull(void){ return m_bFull; }
HRESULT Resize3DEnvironment();
HRESULT ToggleScreen(bool bFull );
HRESULT MakeStateBlock();
void DeleteAllStateBlock();
//inline HRESULT Draw( int Index, const RECT* pSrcRect, const D3DXVECTOR2* pScaling,
// const D3DXVECTOR2* pRotationCenter, float Rotation,
// const D3DXVECTOR2* pTranslation, D3DCOLOR Color );
inline HRESULT Draw(int Index, const RECT& srcRt, const RECT& destRt, D3DCOLOR Color );
protected:
// D3DMATRIX* BuildMatrix( D3DMATRIX* pOut, D3DXVECTOR2* pCenter, D3DXVECTOR2* scaling, float angle );
// void TransformVertices(D3DTLVERTEX vertices[], D3DXVECTOR2* pCenter, D3DXVECTOR2* pScaling,float angle);
// void PolyBlit(int Index, RECT* pSrc, D3DXVECTOR2* pScaling=NULL,
// D3DXVECTOR2* pCenter=NULL, float Rotate=0.0f,D3DXVECTOR2* Trans=NULL, D3DCOLOR colour = 0xffFFFFFF );
public:
void BltSprite( BYTE Layer, int TxtNum, float x,float y,D3DCONST RenderMODE = D3D_NORMALSTATE );
void BltSprite( BYTE Layer, int TxtNum, RECT *pSrcRect , const RECT&pDestRec );
void BltSprite( BYTE Layer, int TxtNum, RECT *pSrcRect ,const RECT &pDestRect, D3DCOLOR Clr,D3DCONST RenderMODE = D3D_NORMALSTATE);
// void BltSprite( BYTE Layer, int TxtNum,RECT *pSrcRect ,const RECT& pDestRect, float rad, POINT rcenter,
// D3DCOLOR Clr, D3DCONST RenderMODE = D3D_NORMALSTATE );
// void BltSpriteEx( BYTE Layer, int TxtNum, RECT *pDestRect, RECT *pSrcRect,
// DWORD dwFlags, D3DCOLOR Modulate, float rad, POINT *pCenter );
void CreateSurfaceFromFile(LPDIRECT3DSURFACE9* ppSurface, SIZE* pSize,
const TCHAR* szFileName, D3DCOLOR colourKey = 0xFFFF00FF);
void CreateTextureFromSurface(LPDIRECT3DSURFACE9 pSurface, RECT* pSrcRect,
LPDIRECT3DTEXTURE9* ppTexture);
inline void FillRect(RECT *pRect, D3DCOLOR fillColor);
/* inline int GetTexutreINDEX( TCHAR* tName)
{
if( TextureMap[ tName ] != NULL )
return TextureMap[ tName ]->TexID;
return NULL;
}*/
HRESULT Texture2Texture( LPDIRECT3DTEXTURE9 Dest, LPDIRECT3DTEXTURE9 Src);
HRESULT Texture2Texture( int DestIndex, POINT&DestPt, int SrcIndex );
/////////////////////////////////////////////////
//DX ํฐํธ ๊ด๋ จ ๋ชฝ๋
/////////////////////////////////////////////////
void BltText( BYTE Layer,int x, int y, D3DCOLOR rgbFontColour, const TCHAR* pText );
void BltText( BYTE Layer,RECT& rt, D3DCOLOR rgbFontColour, const TCHAR* pText );
HFONT GetGDIFont(void){ return m_hFont; }
void DrawText(RECT& rt, D3DCOLOR rgbFontColour,DWORD Flag, const TCHAR* pText );
void DrawText_CalcRECT( int x, int y, RECT&rt, const TCHAR* pText );
//์คํธ๋ง์ ํ
์ค์ณ์์ฌ๋ฆผ.์ธ๊ณฝ,๊ธ์จ์๊น.=0x00000000
int Str2Texture( TCHAR* szStr,D3DCOLOR OutLineClr, D3DCOLOR FrontClr, D3DCOLOR BackGroundClr=0x00000000 );
int Str2Texture_backup( TCHAR* szStr,D3DCOLOR OutLineClr, D3DCOLOR FrontClr, D3DCOLOR BackGroundClr=0x00000000 );
// int pStr2Texture_dev(TCHAR* szStr,D3DCOLOR OutLineClr,D3DCOLOR FrontClr, D3DCOLOR BackGroundClr ); //
// int (CD3D::*Str2Texture)(TCHAR* szStr,D3DCOLOR OutLineClr,D3DCOLOR FrontClr, D3DCOLOR BackGroundClr );
bool IsDeviceLost( void) ;
protected:
bool m_bDeviceLost;
D3DDISPLAYMODE m_D3DDisplayMode;
// ๊ทธ๋ฆฌ๊ธฐ ํด๋์ค๋ 256๊ฐ์ฉ ๋ฏธ๋ฆฌ ์ก์๋
CBltSprite m_BltSprite[ MAX_DRAWPARAM ];
CBltText m_BltText [ MAX_DRAWPARAM ];
IDrawObj* m_DrawObj [ MAX_LAYERCNT ][ MAX_DRAWPARAM ];
int m_DrawObjCnt[ MAX_LAYERCNT ];
// DWORD m_hStateBlock[ 3 ];
IDirect3DStateBlock9* m_hStateBlock[ 3 ];
D3DVIEWPORT9 m_ViewPort;
void quick_sort( CBltSprite** Arr, int Size ); // ๊ตฌ์กฐ์ฒด ๋ฒ์ ผ
int WriteTGAFile(const TCHAR* filename, short int width, short int height, unsigned char* imageData);
int LoadIMG( const TCHAR* fName, RES_ANI& pAni );
int LoadTGA( const TCHAR* fName, RES_ANI& pAni );
int m_DrawParamCnt[ MAX_LAYERCNT ];
int m_WinWidth;
int m_WinHeight;
int m_AvailTextureCnt;
bool m_bFull;
HWND m_hWnd;
LPDIRECT3D9 m_D3D;
LPDIRECT3DDEVICE9 m_D3DDevice;
SIMPLETEXTURE m_Texture [ MAX_TEXTURE ]; // ์ฐธ์กฐ ์นด์ดํธ ์ถ๊ฐ..
SIZE m_ActualImgSize[ MAX_TEXTURE ];
// LPD3DXSPRITE m_Sprite;
LPD3DXFONT m_DxFont;
HFONT m_hFont;
D3DPRESENT_PARAMETERS m_d3dpp;
public:
bool CreateBlankTexture(int¶mIndex, int Width,int Height );
void LoadStream(int & Index,const string&imgstream );
void ReleaseTexture(int Index);
//RES_ANI* GetResAni( const TCHAR* fName );
RES_ANI* GetResAni( const TCHAR* fName );
};
extern CD3D g_D3D;
extern LPDIRECT3DDEVICE9 g_p3Dev;
#include <ddraw.h>
void GetVideMem(DWORD & Total, DWORD & Free);
| [
"jungmoona@2e9c511a-93cf-11dd-bb0a-adccfa6872b9"
] | [
[
[
1,
364
]
]
] |
1127ea0d3f6ae26cfa95fbf240bfb034b5a7b4e1 | c6f4fe2766815616b37beccf07db82c0da27e6c1 | /camera.cpp | a50c24eb53439bc0e2c0345f66fbe721c17ceb89 | [] | no_license | fragoulis/gpm-sem1-spacegame | c600f300046c054f7ab3cbf7193ccaad1503ca09 | 85bdfb5b62e2964588f41d03a295b2431ff9689f | refs/heads/master | 2023-06-09T03:43:53.175249 | 2007-12-13T03:03:30 | 2007-12-13T03:03:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,606 | cpp | #include <windows.h>
#include <gl/glu.h>
#include "Camera.h"
#include "QuatRotation.h"
using namespace tlib;
/**
* Constructor
*/
Camera::Camera()
{
// Position camera at (0,0,1)
getPos().xyz( 0.0f, 0.0f, 1.0f );
// Initialize orientation component
OCQuatRotation *cOrientation = new OCQuatRotation;
// look at (0,0,0)
cOrientation->setView( Vector3f(0.0f,0.0f,-1.0f) );
cOrientation->setUp( Vector3f(0.0f,1.0f,0.0f) );
cOrientation->setRight( Vector3f(1.0f,0.0f,0.0f) );
setComponent( cOrientation );
}
Camera::~Camera()
{}
// ----------------------------------------------------------------------------
void Camera::apply()
{
// Get viewing and up vectors
OCOrientation3D *cOri = (OCOrientation3D*)getComponent("orientation");
const Vector3f& vCenter = getPos() + cOri->getView();
const Vector3f& vUp = cOri->getUp();
gluLookAt( getPos().x(), getPos().y(), getPos().z(),
vCenter.x(), vCenter.y(), vCenter.z(),
vUp.x(), vUp.y(), vUp.z() );
}
// ----------------------------------------------------------------------------
void Camera::write( std::ostream &cout )
{
// Get viewing and up vectors
OCOrientation3D *cOri = (OCOrientation3D*)getComponent("orientation");
cout << "Eye" << getPos() << std::endl;
cout << "View" << cOri->getView() << std::endl;
cout << "Up" << cOri->getUp() << std::endl;
}
// ----------------------------------------------------------------------------
void Camera::update()
{} | [
"john.fragkoulis@201bd241-053d-0410-948a-418211174e54"
] | [
[
[
1,
54
]
]
] |
f8f7cb54488b8662f2d5be2b36fcdea838661cc6 | 9c62af23e0a1faea5aaa8dd328ba1d82688823a5 | /rl/branches/newton20/engine/rules/include/StrafeMovement.h | 782f3fa9c1eccdc7a96254e9947923f98f02bf04 | [
"ClArtistic",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | jacmoe/dsa-hl-svn | 55b05b6f28b0b8b216eac7b0f9eedf650d116f85 | 97798e1f54df9d5785fb206c7165cd011c611560 | refs/heads/master | 2021-04-22T12:07:43.389214 | 2009-11-27T22:01:03 | 2009-11-27T22:01:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,574 | h | /* This source file is part of Rastullahs Lockenpracht.
* Copyright (C) 2003-2008 Team Pantheon. http://www.team-pantheon.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Clarified Artistic License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Clarified Artistic License for more details.
*
* You should have received a copy of the Clarified Artistic License
* along with this program; if not you can get it here
* http://www.jpaulmorrison.com/fbp/artistic2.htm.
*/
#ifndef __StrafeMovement_H__
#define __StrafeMovement_H__
#include "WalkMovement.h"
namespace rl
{
class StrafeMovement : public WalkMovement
{
public:
StrafeMovement(CreatureController *creature);
virtual CreatureController::MovementType getId() const {return CreatureController::MT_SEITWAERTS_GEHEN;}
virtual CreatureController::MovementType getFallBackMovement() const {return CreatureController::MT_STEHEN;}
virtual bool calculateBaseVelocity(Ogre::Real &velocity);
virtual bool isDirectionPossible(Ogre::Vector3 &direction) const;
virtual bool run(Ogre::Real elapsedTime, Ogre::Vector3 direction, Ogre::Vector3 rotation);
virtual void setAnimation(Ogre::Real elapsedTime);
protected:
bool mLeft;
Creature::AnimationSpeedPair mAnim1;
};
}
#endif
| [
"melven@4c79e8ff-cfd4-0310-af45-a38c79f83013"
] | [
[
[
1,
42
]
]
] |
4d0b53a482c90dd265b437118ba4418b10d65bdf | 10c14a95421b63a71c7c99adf73e305608c391bf | /gui/painting/qdrawhelper_sse3dnow.cpp | 325071e7a296c7ba53ffb82c3cae7beafa0c42b8 | [] | no_license | eaglezzb/wtlcontrols | 73fccea541c6ef1f6db5600f5f7349f5c5236daa | 61b7fce28df1efe4a1d90c0678ec863b1fd7c81c | refs/heads/master | 2021-01-22T13:47:19.456110 | 2009-05-19T10:58:42 | 2009-05-19T10:58:42 | 33,811,815 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,216 | cpp | /****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information ([email protected])
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at [email protected].
** $QT_END_LICENSE$
**
****************************************************************************/
#include <private/qdrawhelper_x86_p.h>
#if defined(QT_HAVE_3DNOW) && defined(QT_HAVE_SSE)
#include <private/qdrawhelper_sse_p.h>
#include <mm3dnow.h>
QT_BEGIN_NAMESPACE
struct QSSE3DNOWIntrinsics : public QSSEIntrinsics
{
static inline void end() {
_m_femms();
}
};
CompositionFunctionSolid qt_functionForModeSolid_SSE3DNOW[numCompositionFunctions] = {
comp_func_solid_SourceOver<QSSE3DNOWIntrinsics>,
comp_func_solid_DestinationOver<QSSE3DNOWIntrinsics>,
comp_func_solid_Clear<QSSE3DNOWIntrinsics>,
comp_func_solid_Source<QSSE3DNOWIntrinsics>,
0,
comp_func_solid_SourceIn<QSSE3DNOWIntrinsics>,
comp_func_solid_DestinationIn<QSSE3DNOWIntrinsics>,
comp_func_solid_SourceOut<QSSE3DNOWIntrinsics>,
comp_func_solid_DestinationOut<QSSE3DNOWIntrinsics>,
comp_func_solid_SourceAtop<QSSE3DNOWIntrinsics>,
comp_func_solid_DestinationAtop<QSSE3DNOWIntrinsics>,
comp_func_solid_XOR<QSSE3DNOWIntrinsics>,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // svg 1.2 modes
rasterop_solid_SourceOrDestination<QSSE3DNOWIntrinsics>,
rasterop_solid_SourceAndDestination<QSSE3DNOWIntrinsics>,
rasterop_solid_SourceXorDestination<QSSE3DNOWIntrinsics>,
rasterop_solid_NotSourceAndNotDestination<QSSE3DNOWIntrinsics>,
rasterop_solid_NotSourceOrNotDestination<QSSE3DNOWIntrinsics>,
rasterop_solid_NotSourceXorDestination<QSSE3DNOWIntrinsics>,
rasterop_solid_NotSource<QSSE3DNOWIntrinsics>,
rasterop_solid_NotSourceAndDestination<QSSE3DNOWIntrinsics>,
rasterop_solid_SourceAndNotDestination<QSSE3DNOWIntrinsics>
};
CompositionFunction qt_functionForMode_SSE3DNOW[numCompositionFunctions] = {
comp_func_SourceOver<QSSE3DNOWIntrinsics>,
comp_func_DestinationOver<QSSE3DNOWIntrinsics>,
comp_func_Clear<QSSE3DNOWIntrinsics>,
comp_func_Source<QSSE3DNOWIntrinsics>,
0,
comp_func_SourceIn<QSSE3DNOWIntrinsics>,
comp_func_DestinationIn<QSSE3DNOWIntrinsics>,
comp_func_SourceOut<QSSE3DNOWIntrinsics>,
comp_func_DestinationOut<QSSE3DNOWIntrinsics>,
comp_func_SourceAtop<QSSE3DNOWIntrinsics>,
comp_func_DestinationAtop<QSSE3DNOWIntrinsics>,
comp_func_XOR<QSSE3DNOWIntrinsics>
};
void qt_blend_color_argb_sse3dnow(int count, const QSpan *spans, void *userData)
{
qt_blend_color_argb_x86<QSSE3DNOWIntrinsics>(count, spans, userData,
(CompositionFunctionSolid*)qt_functionForModeSolid_SSE3DNOW);
}
void qt_memfill32_sse3dnow(quint32 *dest, quint32 value, int count)
{
return qt_memfill32_sse_template<QSSE3DNOWIntrinsics>(dest, value, count);
}
void qt_bitmapblit16_sse3dnow(QRasterBuffer *rasterBuffer, int x, int y,
quint32 color,
const uchar *src,
int width, int height, int stride)
{
return qt_bitmapblit16_sse_template<QSSE3DNOWIntrinsics>(rasterBuffer, x,y,
color, src, width,
height, stride);
}
QT_END_NAMESPACE
#endif // QT_HAVE_3DNOW && QT_HAVE_SSE
| [
"zhangyinquan@0feb242a-2539-11de-a0d7-251e5865a1c7"
] | [
[
[
1,
122
]
]
] |
21c0299ddd237706063bf90ae0d0be310339b53d | 028d79ad6dd6bb4114891b8f4840ef9f0e9d4a32 | /src/drivers/dominos.cpp | 159d7f461b66439eaa012852dd39ea065b6991a6 | [] | 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 | 6,570 | cpp | #include "../machine/dominos.cpp"
#include "../vidhrdw/dominos.cpp"
/***************************************************************************
Atari Dominos Driver
Memory Map:
0000-03FF RAM
0400-07FF DISPLAY RAM
0800-0BFF R SWITCH
0C00-0FFF R SYNC
0C00-0C0F W ATTRACT
0C10-0C1F W TUMBLE
0C30-0C3F W LAMP2
0C40-0C4F W LAMP1
3000-37FF Program ROM1
3800-3FFF Program ROM2
(F800-FFFF) Program ROM2 - only needed for the 6502 vectors
If you have any questions about how this driver works, don't hesitate to
ask. - Mike Balfour ([email protected])
***************************************************************************/
#include "driver.h"
#include "vidhrdw/generic.h"
/* machine/dominos.c */
READ_HANDLER( dominos_port_r );
READ_HANDLER( dominos_sync_r );
WRITE_HANDLER( dominos_attract_w );
WRITE_HANDLER( dominos_tumble_w );
WRITE_HANDLER( dominos_lamp2_w );
WRITE_HANDLER( dominos_lamp1_w );
/* vidhrdw/dominos.c */
extern void dominos_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
static struct MemoryReadAddress readmem[] =
{
{ 0x0000, 0x03ff, MRA_RAM }, /* RAM */
{ 0x0400, 0x07ff, MRA_RAM }, /* RAM */
{ 0x0800, 0x083f, dominos_port_r }, /* SWITCH */
{ 0x0840, 0x087f, input_port_3_r }, /* SWITCH */
{ 0x0900, 0x093f, dominos_port_r }, /* SWITCH */
{ 0x0940, 0x097f, input_port_3_r }, /* SWITCH */
{ 0x0a00, 0x0a3f, dominos_port_r }, /* SWITCH */
{ 0x0a40, 0x0a7f, input_port_3_r }, /* SWITCH */
{ 0x0b00, 0x0b3f, dominos_port_r }, /* SWITCH */
{ 0x0b40, 0x0b7f, input_port_3_r }, /* SWITCH */
{ 0x0c00, 0x0fff, dominos_sync_r }, /* SYNC */
{ 0x3000, 0x3fff, MRA_ROM }, /* ROM1-ROM2 */
{ 0xfff0, 0xffff, MRA_ROM }, /* ROM2 for 6502 vectors */
{ -1 } /* end of table */
};
static struct MemoryWriteAddress writemem[] =
{
{ 0x0000, 0x03ff, MWA_RAM },
{ 0x0400, 0x07ff, videoram_w, &videoram, &videoram_size }, /* DISPLAY */
{ 0x0c00, 0x0c0f, dominos_attract_w }, /* ATTRACT */
{ 0x0c10, 0x0c1f, dominos_tumble_w }, /* TUMBLE */
{ 0x0c30, 0x0c3f, dominos_lamp2_w }, /* LAMP2 */
{ 0x0c40, 0x0c4f, dominos_lamp1_w }, /* LAMP1 */
{ 0x0c80, 0x0cff, MWA_NOP }, /* TIMER RESET */
{ 0x3000, 0x3fff, MWA_ROM }, /* ROM1-ROM2 */
{ -1 } /* end of table */
};
INPUT_PORTS_START( dominos )
PORT_START /* DSW - fake port, gets mapped to Dominos ports */
PORT_DIPNAME( 0x03, 0x01, "Points To Win" )
PORT_DIPSETTING( 0x03, "6" )
PORT_DIPSETTING( 0x02, "5" )
PORT_DIPSETTING( 0x01, "4" )
PORT_DIPSETTING( 0x00, "3" )
PORT_DIPNAME( 0x0C, 0x08, "Cost" )
PORT_DIPSETTING( 0x0C, "2 players/coin" )
PORT_DIPSETTING( 0x08, "1 coin/player" )
PORT_DIPSETTING( 0x04, "2 coins/player" )
PORT_DIPSETTING( 0x00, "2 coins/player" ) /* not a typo */
PORT_START /* IN0 - fake port, gets mapped to Dominos ports */
PORT_BIT (0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_PLAYER2)
PORT_BIT (0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_PLAYER2)
PORT_BIT (0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_PLAYER2)
PORT_BIT (0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_PLAYER2)
PORT_BIT (0xF0, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_START /* IN1 - fake port, gets mapped to Dominos ports */
PORT_BIT (0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY )
PORT_BIT (0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY )
PORT_BIT (0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY )
PORT_BIT (0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY )
PORT_BIT (0x10, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT (0x20, IP_ACTIVE_LOW, IPT_START2 )
PORT_BITX(0x40, IP_ACTIVE_LOW, IPT_SERVICE | IPF_TOGGLE, "Self Test", KEYCODE_F2, IP_JOY_NONE )
PORT_START /* IN2 */
PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_START /* IN3 */
PORT_BIT ( 0x0F, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT ( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* ATTRACT */
PORT_BIT ( 0x20, IP_ACTIVE_HIGH, IPT_VBLANK ) /* VRESET */
PORT_BIT ( 0x40, IP_ACTIVE_HIGH, IPT_VBLANK ) /* VBLANK* */
PORT_BIT ( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* Alternating signal? */
INPUT_PORTS_END
static struct GfxLayout charlayout =
{
8,8, /* 8*8 characters */
64, /* 64 characters */
1, /* 1 bit per pixel */
{ 0 }, /* no separation in 1 bpp */
{ 4, 5, 6, 7, 0x200*8 + 4, 0x200*8 + 5, 0x200*8 + 6, 0x200*8 + 7 },
{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
8*8 /* every char takes 8 consecutive bytes */
};
static struct GfxDecodeInfo gfxdecodeinfo[] =
{
{ REGION_GFX1, 0, &charlayout, 0x00, 0x02 }, /* offset into colors, # of colors */
{ -1 } /* end of array */
};
static unsigned char palette[] =
{
0x80,0x80,0x80, /* LT GREY */
0x00,0x00,0x00, /* BLACK */
0xff,0xff,0xff, /* WHITE */
0x55,0x55,0x55, /* DK GREY */
};
static unsigned short colortable[] =
{
0x00, 0x01,
0x00, 0x02
};
static void init_palette(unsigned char *game_palette, unsigned short *game_colortable,const unsigned char *color_prom)
{
memcpy(game_palette,palette,sizeof(palette));
memcpy(game_colortable,colortable,sizeof(colortable));
}
static struct MachineDriver machine_driver_dominos =
{
/* basic machine hardware */
{
{
CPU_M6502,
750000, /* 750 Khz ???? */
readmem,writemem,0,0,
interrupt,1
}
},
60, DEFAULT_REAL_60HZ_VBLANK_DURATION, /* frames per second, vblank duration */
1, /* single CPU, no need for interleaving */
0,
/* video hardware */
32*8, 28*8, { 0*8, 32*8-1, 0*8, 28*8-1 },
gfxdecodeinfo,
sizeof(palette) / sizeof(palette[0]) / 3, sizeof(colortable) / sizeof(colortable[0]),
init_palette,
VIDEO_TYPE_RASTER,
0,
generic_vh_start,
generic_vh_stop,
dominos_vh_screenrefresh,
/* sound hardware */
0,0,0,0
};
/***************************************************************************
Game ROMs
***************************************************************************/
ROM_START( dominos )
ROM_REGION( 0x10000, REGION_CPU1 ) /* 64k for code */
ROM_LOAD( "7352-02.d1", 0x3000, 0x0800, 0x738b4413 )
ROM_LOAD( "7438-02.e1", 0x3800, 0x0800, 0xc84e54e2 )
ROM_RELOAD( 0xf800, 0x0800 )
ROM_REGION( 0x800, REGION_GFX1 | REGIONFLAG_DISPOSE )
ROM_LOAD( "7439-01.p4", 0x0000, 0x0200, 0x4f42fdd6 )
ROM_LOAD( "7440-01.r4", 0x0200, 0x0200, 0x957dd8df )
ROM_END
GAMEX( 1977, dominos, 0, dominos, dominos, 0, ROT0, "Atari", "Dominos", GAME_NO_SOUND )
| [
"[email protected]"
] | [
[
[
1,
204
]
]
] |
64c0c3b6758ecd34bc8377843edb9cec608d269a | 1d2705c9be9ee0f974c224eb794f2f8a9e9a3d50 | /xpr/task_dispatcher_t.hpp | 836bc2e751b730109b9caea306a0d1a46027b5fb | [] | no_license | llvllrbreeze/alcorapp | dfe2551f36d346d73d998f59d602c5de46ef60f7 | 3ad24edd52c19f0896228f55539aa8bbbb011aac | refs/heads/master | 2021-01-10T07:36:01.058011 | 2008-12-16T12:51:50 | 2008-12-16T12:51:50 | 47,865,136 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,831 | hpp | #ifndef task_dispatcher_T_HPP_INCLUDED
#define task_dispatcher_T_HPP_INCLUDED
//---------------------------------------------------------------------------
#include "xpr_tags_inc.h"
//---------------------------------------------------------------------------
#include "alcor/core/client_base_t.hpp"
//---------------------------------------------------------------------------
#include "alcor/core/config_parser_t.hpp"
//---------------------------------------------------------------------------
namespace all { namespace xpr {
//---------------------------------------------------------------------------
class task_dispatcher_t : public all::core::client_base_t
{
public:
///
task_dispatcher_t(const std::string& ini);
///
void send_event(int);
private:
///
void connected_cb();
///
void updatetask(core::net_packet_ptr_t);
};
//-------------------------------------------------------+
inline task_dispatcher_t::task_dispatcher_t(const std::string& inifile)
{
all::core::config_parser_t ini;
if ( ini.load(core::tags::ini, inifile) )
{
all::core::ip_address_t server_address;
server_address.hostname = ini.get<std::string>("server.hostname", "127.0.0.1");
server_address.port = ini.get<int>("server.port", 55055);
set_server_addr(server_address);
}
else
{
}
add_command_handler
("updatetask", boost::bind(&task_dispatcher_t::updatetask, this, _1));
set_connect_callback(boost::bind(&task_dispatcher_t::connected_cb, this));
}
//-------------------------------------------------------+
///
inline void task_dispatcher_t::send_event(int evt)
{
core::net_packet_ptr_t packet(new core::net_packet_t());
packet->int_to_buf(evt);
send_command("taskset", packet);
}
//-------------------------------------------------------+
///
inline void task_dispatcher_t::updatetask(core::net_packet_ptr_t)
{
}
//-------------------------------------------------------+
///
inline void task_dispatcher_t::connected_cb()
{
}
////-------------------------------------------------------+
/////
//inline void task_dispatcher_t::send_roi(int r, int c , int h , int w, int scala)
//{
// core::net_packet_ptr_t packet(new core::net_packet_t());
//
// packet->int_to_buf(r);
// packet->int_to_buf(c);
// packet->int_to_buf(h);
// packet->int_to_buf(w);
// packet->int_to_buf(scala);
//
// send_command("setuproi", packet);
//
// }
//-------------------------------------------------------+
//-------------------------------------------------------+
//---------------------------------------------------------------------------
}}
//---------------------------------------------------------------------------
#endif //task_dispatcher_T_HPP_INCLUDED | [
"andrea.carbone@1ffd000b-a628-0410-9a29-793f135cad17"
] | [
[
[
1,
89
]
]
] |
26942c1de50f13e1376244631238335a0abf0c34 | fcf03ead74f6dc103ec3b07ffe3bce81c820660d | /Multimedia/ICLCodec/PNGCodec.cpp | 5191b69c1a3b7e9c5aec629232ca73d850d2b168 | [] | no_license | huellif/symbian-example | 72097c9aec6d45d555a79a30d576dddc04a65a16 | 56f6c5e67a3d37961408fc51188d46d49bddcfdc | refs/heads/master | 2016-09-06T12:49:32.021854 | 2010-10-14T06:31:20 | 2010-10-14T06:31:20 | 38,062,421 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 25,474 | cpp | // PngCodec.CPP
//
// Copyright (c) 1999-2005 Symbian Software Ltd. All rights reserved.
//
#include <fbs.h>
#include "ImageUtils.h"
#include "PngCodec.h"
// Constants.
const TInt KTwipsPerMeter = 56693;
//
// TPngImageInformation: PNG image information
//
// Initialise default PNG image information
TPngImageInformation::TPngImageInformation()
{
iSize.SetSize(0,0);
iBitDepth = 0;
iColorType = EGrayscale;
iCompressionMethod = EDeflateInflate32K;
iFilterMethod = EAdaptiveFiltering;
iInterlaceMethod = ENoInterlace;
iPalettePresent = EFalse;
#if defined(_DEBUG)
// as an optimisation, we are going to set iPalette to all zeros, instead of setting
// each element to KRgbBlack. This assumes that KRbgBlack is itself zero.
ASSERT(sizeof(TRgb)==sizeof(TUint32)); // ie no new fields
ASSERT(KRgbBlack.Value()==0); // ie the one value is zero
#endif // defined(_DEBUG)
Mem::FillZ(iPalette, KPngMaxPLTESize*sizeof(TRgb));
iBackgroundPresent = EFalse;
iBackgroundColor = KRgbWhite;
iPhysicalPresent = EFalse;
iPhysicalUnits = EUnknownUnits;
iPhysicalSize.SetSize(0,0);
iTransparencyPresent = EFalse;
Mem::Fill(iTransparencyValue,KPngMaxPLTESize,0xff);
}
//
// CPngReadCodec: reads a PNG image
//
CPngReadCodec::~CPngReadCodec()
{
delete iDecoder;
delete iDecompressor;
}
// Called by framework when a Convert operation begins
void CPngReadCodec::InitFrameL(TFrameInfo& /*aFrameInfo*/, CFrameImageData& /*aFrameImageData*/,
TBool aDisableErrorDiffusion, CFbsBitmap& aDestination, CFbsBitmap* aDestinationMask)
{
CFbsBitmap& newFrame = aDestination;
TPoint& pos = Pos();
pos.SetXY(0,0);
iChunkBytesRemaining = 0;
// Use the supplied image processor
CImageProcessor* imageProc = ImageProcessorUtility::NewImageProcessorL(newFrame, iImageInfo.iSize, ERgb, aDisableErrorDiffusion);
SetImageProcessor(imageProc);
imageProc->PrepareL(newFrame,iImageInfo.iSize);
CImageProcessor* maskProc = NULL;
SetMaskProcessor(NULL);
// If transparency is being used, create a bitmap mask as well
if ((iImageInfo.iTransparencyPresent || (iImageInfo.iColorType & TPngImageInformation::EAlphaChannelUsed))
&& aDestinationMask)
{
maskProc = ImageProcessorUtility::NewImageProcessorL(*aDestinationMask, iImageInfo.iSize, ERgb, aDisableErrorDiffusion);
SetMaskProcessor(maskProc);
maskProc->PrepareL(*aDestinationMask,iImageInfo.iSize);
// set mask to black so that unknown parts on streamed image are not drawn
ClearBitmapL(*aDestinationMask, KRgbBlack);
}
// Create a helper to read the scan lines
delete iDecoder;
iDecoder = NULL;
iDecoder = CPngReadSubCodec::NewL(imageProc,maskProc,iImageInfo);
// And a unzipper to decompress image data
if (!iDecompressor)
iDecompressor = CEZDecompressor::NewL(*this);
else
iDecompressor->ResetL(*this);
if (maskProc==NULL)
{
// if no mask, clear destination for sensible behaviour on streamed partial images
TRgb background = iImageInfo.iBackgroundPresent ? iImageInfo.iBackgroundColor : KRgbWhite;
ClearBitmapL(aDestination, background);
}
}
// Called by framework to initialise image frame header
void CPngReadCodec::InitFrameHeader(TFrameInfo& aFrameSettings, CFrameImageData& /* aFrameImageData */)
{
ASSERT(aFrameSettings.CurrentFrameState() == TFrameInfo::EFrameInfoUninitialised);
iFrameInfo = &aFrameSettings;
iFrameInfo->SetCurrentFrameState(TFrameInfo::EFrameInfoProcessingFrameHeader);
}
// Called by framework to process a header for a frame
TFrameState CPngReadCodec::ProcessFrameHeaderL(TBufPtr8& aData)
{
const TUint8* startDataPtr = aData.Ptr();
const TUint8* dataPtr = startDataPtr;
const TUint8* dataPtrLimit = startDataPtr + aData.Length();
// Process the mandatory PNG header chunk: sets up iImageInfo
if (iFrameInfo->CurrentFrameState() == TFrameInfo::EFrameInfoProcessingFrameHeader)
{
if (dataPtr + KPngChunkLengthSize + KPngChunkIdSize + KPngIHDRChunkSize + KPngChunkCRCSize > dataPtrLimit)
User::Leave(KErrUnderflow);
TInt chunkLength = PtrReadUtil::ReadBigEndianUint32Inc(dataPtr);
TPtrC8 chunkId(dataPtr,KPngChunkIdSize);
if (chunkLength != KPngIHDRChunkSize || chunkId != KPngIHDRChunkId)
User::Leave(KErrNotFound);
dataPtr += KPngChunkIdSize;
DoProcessIHDRL(dataPtr,chunkLength);
dataPtr += KPngIHDRChunkSize + KPngChunkCRCSize;
}
// Process any optional PNG header chunks
TRAPD(err, DoProcessInfoL(dataPtr, dataPtrLimit));
if (err != KErrNone)
{
if (err == KErrNotFound)
return EFrameComplete;
User::Leave(err); // A real error occured
}
// Having read the header, can initialise the frame information
aData.Shift(dataPtr - startDataPtr);
iFrameInfo->iFrameCoordsInPixels.SetRect(TPoint(0,0),iImageInfo.iSize);
iFrameInfo->iOverallSizeInPixels = iImageInfo.iSize;
if (iImageInfo.iPhysicalPresent && iImageInfo.iPhysicalUnits == TPngImageInformation::EMeters)
iFrameInfo->iFrameSizeInTwips = iImageInfo.iPhysicalSize;
else
iFrameInfo->iFrameSizeInTwips.SetSize(0,0);
iFrameInfo->iBitsPerPixel = iImageInfo.iBitDepth;
if (iImageInfo.iColorType & TPngImageInformation::EColorUsed)
iFrameInfo->iBitsPerPixel *= 3;
iFrameInfo->iDelay = 0;
iFrameInfo->iFlags = TFrameInfo::ECanDither;
if (iImageInfo.iColorType & (TPngImageInformation::EPaletteUsed | TPngImageInformation::EColorUsed))
iFrameInfo->iFlags |= TFrameInfo::EColor;
if (iImageInfo.iColorType & TPngImageInformation::EAlphaChannelUsed)
{
iFrameInfo->iFlags |= TFrameInfo::ETransparencyPossible;
iFrameInfo->iFlags |= TFrameInfo::EAlphaChannel;
}
else if (iImageInfo.iTransparencyPresent)
iFrameInfo->iFlags |= TFrameInfo::ETransparencyPossible;
switch (iFrameInfo->iBitsPerPixel)
{
case 1:
iFrameInfo->iFrameDisplayMode = EGray2;
break;
case 2:
iFrameInfo->iFrameDisplayMode = EGray4;
break;
case 4:
iFrameInfo->iFrameDisplayMode = (iFrameInfo->iFlags & TFrameInfo::EColor) ? EColor16 : EGray16;
break;
case 8:
iFrameInfo->iFrameDisplayMode = (iFrameInfo->iFlags & TFrameInfo::EColor) ? EColor256 : EGray256;
break;
case 12:
iFrameInfo->iFrameDisplayMode = EColor4K;
break;
case 16:
iFrameInfo->iFrameDisplayMode = EColor64K;
break;
case 24:
iFrameInfo->iFrameDisplayMode = EColor16M;
break;
default:
User::Leave(KErrCorrupt);
}
if (iImageInfo.iBackgroundPresent)
iFrameInfo->iBackgroundColor = iImageInfo.iBackgroundColor;
iFrameInfo->SetCurrentFrameState(TFrameInfo::EFrameInfoProcessingComplete);
return EFrameComplete;
}
// Called by the framework to process frame data
TFrameState CPngReadCodec::ProcessFrameL(TBufPtr8& aSrc)
{
CImageProcessor*const imageProc = ImageProcessor();
CImageProcessor*const maskProc = MaskProcessor();
TUint8* startDataPtr = const_cast<TUint8*>(aSrc.Ptr());
TUint8* dataPtr = startDataPtr;
const TUint8* dataPtrLimit = dataPtr + aSrc.Length();
while (dataPtr < dataPtrLimit)
{
// If at the end of a PNG chunk
if (iChunkBytesRemaining == 0)
{
if (iChunkId == KPngIDATChunkId) // Need to skip IDAT chunk CRCs
{
if (dataPtr + KPngChunkCRCSize + KPngChunkLengthSize + KPngChunkIdSize > dataPtrLimit)
break;
dataPtr += KPngChunkCRCSize;
}
else
{
if (dataPtr + KPngChunkLengthSize + KPngChunkIdSize > dataPtrLimit)
break;
}
iChunkBytesRemaining = PtrReadUtil::ReadBigEndianUint32Inc(const_cast<const TUint8*&>(dataPtr));
iChunkId = TPtr8(dataPtr,KPngChunkIdSize,KPngChunkIdSize);
dataPtr += KPngChunkIdSize;
}
// Process an image data chunk
if (iChunkId == KPngIDATChunkId)
DoProcessDataL(const_cast<const TUint8*&>(dataPtr),dataPtrLimit);
// Process an END chunk -- frame is complete
else if (iChunkId == KPngIENDChunkId)
{
iDecompressor->InflateL();
imageProc->FlushPixels();
if (maskProc)
maskProc->FlushPixels();
return EFrameComplete;
}
else
// Skip other chunks
{
TInt bytesLeft = dataPtrLimit - dataPtr;
if (bytesLeft >= iChunkBytesRemaining + KPngChunkCRCSize)
{
dataPtr += iChunkBytesRemaining + KPngChunkCRCSize;
iChunkBytesRemaining = 0;
}
else
{
dataPtr += bytesLeft;
iChunkBytesRemaining -= bytesLeft;
}
}
}
aSrc.Shift(dataPtr - startDataPtr);
return EFrameIncomplete;
}
// Process any optional PNG header chunks
void CPngReadCodec::DoProcessInfoL(const TUint8*& aDataPtr,const TUint8* aDataPtrLimit)
{
FOREVER
{
if (aDataPtr + KPngChunkLengthSize + KPngChunkIdSize > aDataPtrLimit) // Check there is enough data to read the chunk length
User::Leave(KErrUnderflow);
TInt chunkLength = PtrReadUtil::ReadBigEndianUint32Inc(aDataPtr);
TPtrC8 chunkId (&aDataPtr[0],KPngChunkIdSize);
if (chunkId == KPngIDATChunkId)
{
aDataPtr -= KPngChunkLengthSize; // Rewind to start of chunkLength
break;
}
if (aDataPtr + KPngChunkIdSize + chunkLength + KPngChunkCRCSize > aDataPtrLimit) // Check there is enough data to read the whole chunk
{
aDataPtr -= KPngChunkLengthSize; // Rewind to start of chunkLength
User::Leave(KErrUnderflow);
}
aDataPtr += KPngChunkIdSize;
if (chunkId == KPngPLTEChunkId)
DoProcessPLTEL(aDataPtr,chunkLength);
else if (chunkId == KPngbKGDChunkId)
DoProcessbKGDL(aDataPtr,chunkLength);
else if (chunkId == KPngpHYsChunkId)
DoProcesspHYsL(aDataPtr,chunkLength);
else if (chunkId == KPngtRNSChunkId)
DoProcesstRNSL(aDataPtr,chunkLength);
else if (chunkId == KPngIHDRChunkId || chunkId == KPngIENDChunkId)
User::Leave(KErrCorrupt);
aDataPtr += chunkLength;
PtrReadUtil::ReadBigEndianUint32Inc(aDataPtr); // Skip crc value
}
}
// Process the mandatory PNG header chunk
void CPngReadCodec::DoProcessIHDRL(const TUint8* aDataPtr,TInt aChunkLength)
{
if (aChunkLength != KPngIHDRChunkSize)
User::Leave(KErrCorrupt);
iImageInfo.iSize.iWidth = PtrReadUtil::ReadBigEndianUint32Inc(aDataPtr);
iImageInfo.iSize.iHeight = PtrReadUtil::ReadBigEndianUint32Inc(aDataPtr);
iImageInfo.iBitDepth = aDataPtr[0];
iImageInfo.iColorType = TPngImageInformation::TColorType(aDataPtr[1]);
iImageInfo.iCompressionMethod = TPngImageInformation::TCompressionMethod(aDataPtr[2]);
iImageInfo.iFilterMethod = TPngImageInformation::TFilterMethod(aDataPtr[3]);
iImageInfo.iInterlaceMethod = TPngImageInformation::TInterlaceMethod(aDataPtr[4]);
// Check is one of the PNG formats we support
if (iImageInfo.iSize.iWidth < 1 || iImageInfo.iSize.iHeight < 1
|| iImageInfo.iCompressionMethod != TPngImageInformation::EDeflateInflate32K
|| iImageInfo.iFilterMethod != TPngImageInformation::EAdaptiveFiltering
|| (iImageInfo.iInterlaceMethod != TPngImageInformation::ENoInterlace &&
iImageInfo.iInterlaceMethod != TPngImageInformation::EAdam7Interlace))
User::Leave(KErrCorrupt);
}
// Process a PNG PLTE (palette) chunk
void CPngReadCodec::DoProcessPLTEL(const TUint8* aDataPtr,TInt aChunkLength)
{
if (aChunkLength % 3 != 0)
User::Leave(KErrCorrupt);
iImageInfo.iPalettePresent = ETrue;
const TUint8* dataPtrLimit = aDataPtr + aChunkLength;
TRgb* palettePtr = iImageInfo.iPalette;
while (aDataPtr < dataPtrLimit)
{
*palettePtr++ = TRgb(aDataPtr[0],aDataPtr[1],aDataPtr[2]);
aDataPtr += 3;
}
}
// Process a PNG bKGD (background color) chunk
void CPngReadCodec::DoProcessbKGDL(const TUint8* aDataPtr,TInt aChunkLength)
{
iImageInfo.iBackgroundPresent = ETrue;
if (iImageInfo.iColorType == TPngImageInformation::EIndexedColor) // 3
{
if (aChunkLength < 1)
User::Leave(KErrCorrupt);
iImageInfo.iBackgroundColor = iImageInfo.iPalette[aDataPtr[0]];
}
else if (iImageInfo.iColorType & TPngImageInformation::EMonochrome) // 0 & 4
{
if (aChunkLength < 2)
User::Leave(KErrCorrupt);
TInt grayLevel = PtrReadUtil::ReadBigEndianInt16(aDataPtr);
ASSERT(iImageInfo.iBitDepth<8);
grayLevel <<= (7-iImageInfo.iBitDepth);
iImageInfo.iBackgroundColor = TRgb::Gray256(grayLevel);
}
else if (iImageInfo.iColorType & TPngImageInformation::EColorUsed) // 2 & 6
{
if (aChunkLength < 6)
User::Leave(KErrCorrupt);
TInt red = PtrReadUtil::ReadBigEndianInt16(&aDataPtr[0]);
TInt green = PtrReadUtil::ReadBigEndianInt16(&aDataPtr[2]);
TInt blue = PtrReadUtil::ReadBigEndianInt16(&aDataPtr[4]);
ASSERT (iImageInfo.iBitDepth<8);
const TInt offset = 7-iImageInfo.iBitDepth;
red <<= offset;
green <<= offset;
blue <<= offset;
iImageInfo.iBackgroundColor = TRgb(red,green,blue);
}
}
// Process a PNG pHYs (Physical pixel dimensions) chunk
void CPngReadCodec::DoProcesspHYsL(const TUint8* aDataPtr,TInt aChunkLength)
{
if (aChunkLength != KPngpHYsChunkSize)
User::Leave(KErrCorrupt);
iImageInfo.iPhysicalUnits = TPngImageInformation::TPhysicalUnits(aDataPtr[8]);
if (iImageInfo.iPhysicalUnits == TPngImageInformation::EMeters)
{
iImageInfo.iPhysicalPresent = ETrue;
TInt horzPixelsPerMeter = PtrReadUtil::ReadBigEndianUint32Inc(aDataPtr);
TInt vertPixelsPerMeter = PtrReadUtil::ReadBigEndianUint32Inc(aDataPtr);
if (horzPixelsPerMeter > 0)
iImageInfo.iPhysicalSize.iWidth = iImageInfo.iSize.iWidth * KTwipsPerMeter / horzPixelsPerMeter;
if (vertPixelsPerMeter > 0)
iImageInfo.iPhysicalSize.iHeight = iImageInfo.iSize.iHeight * KTwipsPerMeter / vertPixelsPerMeter;
}
}
// Process a PNG tRNS (Transparency) chunk
void CPngReadCodec::DoProcesstRNSL(const TUint8* aDataPtr,TInt aChunkLength)
{
iImageInfo.iTransparencyPresent = ETrue;
if (iImageInfo.iColorType == TPngImageInformation::EIndexedColor) // 3
{
if (aChunkLength < 1)
User::Leave(KErrCorrupt);
Mem::Copy(iImageInfo.iTransparencyValue,aDataPtr,aChunkLength);
}
else if (iImageInfo.iColorType == TPngImageInformation::EGrayscale) // 0
{
if (aChunkLength < 2)
User::Leave(KErrCorrupt);
iImageInfo.iTransparentGray = TUint16((aDataPtr[0] << 8) | aDataPtr[1]);
}
else if (iImageInfo.iColorType == TPngImageInformation::EDirectColor) // 2
{
if (aChunkLength < 6)
User::Leave(KErrCorrupt);
iImageInfo.iTransparentRed = TUint16((aDataPtr[0] << 8) | aDataPtr[1]);
iImageInfo.iTransparentGreen = TUint16((aDataPtr[2] << 8) | aDataPtr[3]);
iImageInfo.iTransparentBlue = TUint16((aDataPtr[4] << 8) | aDataPtr[5]);
}
}
// Process a PNG image data
void CPngReadCodec::DoProcessDataL(const TUint8*& aDataPtr,const TUint8* aDataPtrLimit)
{
// Data is passed to the decompressor
TInt bytesToProcess = Min(aDataPtrLimit - aDataPtr,iChunkBytesRemaining);
iDataDes.Set(aDataPtr,bytesToProcess);
iDecompressor->SetInput(iDataDes);
while (iDecompressor->AvailIn() > 0)
iDecompressor->InflateL();
aDataPtr += bytesToProcess;
iChunkBytesRemaining -= bytesToProcess;
}
// From MEZBufferManager: manage decompressor stream
void CPngReadCodec::InitializeL(CEZZStream& aZStream)
{
aZStream.SetOutput(iDecoder->FirstBuffer());
}
void CPngReadCodec::NeedInputL(CEZZStream& /*aZStream*/)
{
}
void CPngReadCodec::NeedOutputL(CEZZStream& aZStream)
{
aZStream.SetOutput(iDecoder->DecodeL());
}
void CPngReadCodec::FinalizeL(CEZZStream& /*aZStream*/)
{
iDecoder->DecodeL();
}
//
// CPngWriteCodec: writes a PNG image
//
CPngWriteCodec::CPngWriteCodec(TInt aBpp, TBool aColor, TBool aPaletted, TInt aCompressionLevel)
: iCompressionLevel(aCompressionLevel), iCompressorPtr(NULL, 0)
{
// Set bpp
iImageInfo.iBitsPerPixel = aBpp;
switch (aBpp)
{
case 1:
iImageInfo.iBitDepth = 1;
break;
case 2:
iImageInfo.iBitDepth = 2;
break;
case 4:
iImageInfo.iBitDepth = 4;
break;
case 8:
case 24:
iImageInfo.iBitDepth = 8;
break;
default:
break;
}
// Set color type
if (aColor && aPaletted)
iImageInfo.iColorType = TPngImageInformation::EIndexedColor;
else if (aColor)
iImageInfo.iColorType = TPngImageInformation::EDirectColor;
else
iImageInfo.iColorType = TPngImageInformation::EGrayscale;
}
CPngWriteCodec::~CPngWriteCodec()
{
delete iCompressor;
delete iEncoder;
}
// Called by framework at start of conversion operation
void CPngWriteCodec::InitFrameL(TBufPtr8& aDst, const CFbsBitmap& aSource)
{
if (aDst.Length() == 0)
User::Leave(KErrArgument); // Not enough length for anything
SetSource(&aSource);
iDestStartPtr = const_cast<TUint8*>(aDst.Ptr());
iDestPtr = iDestStartPtr;
iDestPtrLimit = iDestPtr + aDst.MaxLength();
// Set image information
const SEpocBitmapHeader& header = aSource.Header();
iImageInfo.iSize = header.iSizeInPixels;
switch (iImageInfo.iBitDepth)
{
case 1:
case 2:
case 4:
if (iImageInfo.iColorType == TPngImageInformation::EDirectColor)
{
// Bit depths 1, 2 and 4 don't support RGB colour (color mode 2)
// Must use paletted colour or greyscale
User::Leave(KErrNotSupported);
break;
}
// fall through to case 8
case 8:
break;
default:
User::Leave(KErrNotSupported); // unsupported bit depth
break;
}
iImageInfo.iCompressionMethod = TPngImageInformation::EDeflateInflate32K;
iImageInfo.iFilterMethod = TPngImageInformation::EAdaptiveFiltering;
iImageInfo.iInterlaceMethod = TPngImageInformation::ENoInterlace;
// Create encoder
if (iEncoder)
{
delete iEncoder;
iEncoder = NULL;
}
iEncoder = CPngWriteSubCodec::NewL(iImageInfo, &aSource);
// Create compressor
if (iCompressor)
{
delete iCompressor;
iCompressor = NULL;
}
iCompressor = CEZCompressor::NewL(*this, iCompressionLevel);
// Initial encoder state
if (iImageInfo.iColorType == TPngImageInformation::EIndexedColor)
iEncoderState = EPngWritePLTE;
else
iEncoderState = EPngDeflate;
iCallAgain = ETrue; // to make sure we call DeflateL
// Write header
User::LeaveIfError(WriteHeaderChunk(aDst));
}
// Called by the framework to process frame data
TFrameState CPngWriteCodec::ProcessFrameL(TBufPtr8& aDst)
{
if (aDst.Length() == 0)
User::Leave(KErrArgument); // Not enough length for anything
TFrameState state = EFrameIncomplete;
iDestStartPtr = const_cast<TUint8*>(aDst.Ptr());
iDestPtr = iDestStartPtr;
iDestPtrLimit = iDestPtr + aDst.MaxLength();
// Set return buffer length to 0 initially
aDst.SetLength(0);
while (aDst.Length() == 0 && state != EFrameComplete)
{
// Loop round until we have some data to return or
// the image is encoded
switch (iEncoderState)
{
case EPngWritePLTE:
WritePLTEChunk(aDst);
break;
case EPngDeflate:
DeflateEncodedDataL(aDst, state);
break;
case EPngWriteIDAT:
WriteIDATChunk(aDst);
break;
case EPngFlush:
FlushCompressedDataL(aDst, state);
break;
case EPngEndChunk:
WriteEndChunk(aDst);
state = EFrameComplete;
break;
default:
break;
}
}
return state;
}
// Write a compressed image data chunk
void CPngWriteCodec::DeflateEncodedDataL(TBufPtr8& aDst, TFrameState& /*aState*/)
{
// Set ptr for compressed data
const TInt dataLength = aDst.MaxLength() - KPngChunkLengthSize - KPngChunkIdSize - KPngChunkCRCSize;
ASSERT(dataLength > 0);
iCompressorPtr.Set(iDestPtr + KPngChunkIdSize + KPngChunkLengthSize, dataLength, dataLength);
// Initialise input/output for compressor
iCompressor->SetInput(iEncoder->EncodeL(iScanline));
iScanline++;
iCompressor->SetOutput(iCompressorPtr);
while ((iEncoderState == EPngDeflate) && iCallAgain)
iCallAgain = iCompressor->DeflateL();
// Write the IDAT chunk
WriteIDATChunk(aDst);
iEncoderState = EPngFlush;
}
void CPngWriteCodec::FlushCompressedDataL(TBufPtr8& aDst, TFrameState& /*aState*/)
{
if (iCallAgain)
{
iCallAgain = iCompressor->DeflateL();
WriteIDATChunk(aDst);
}
else
{
iEncoderState = EPngEndChunk;
}
}
// Write a PLTE chunk
void CPngWriteCodec::WritePLTEChunk(TBufPtr8& aDst)
{
ASSERT(iEncoder->Palette() &&
(iImageInfo.iColorType == TPngImageInformation::EIndexedColor ||
iImageInfo.iColorType == TPngImageInformation::EDirectColor ||
iImageInfo.iColorType == TPngImageInformation::EAlphaDirectColor)); // allowed color types for PLTE chunk
// Get palette entries
CPalette* palette = iEncoder->Palette();
ASSERT(palette);
const TInt count = palette->Entries();
TUint8* ptr = iDestPtr + KPngChunkIdSize + KPngChunkLengthSize;
TInt length = count * 3;
TPtr8 data(ptr, length, length);
for (TInt i=0; i < count; i++)
{
TRgb rgb = palette->GetEntry(i);
*ptr = TUint8(rgb.Red());
ptr++;
*ptr = TUint8(rgb.Green());
ptr++;
*ptr = TUint8(rgb.Blue());
ptr++;
}
// Write PLTE chunk
WritePngChunk(iDestPtr, KPngPLTEChunkId, data, length);
ASSERT(length % 3 == 0); // length must be divisible by 3
aDst.SetLength(length);
iEncoderState = EPngDeflate;
}
// Write a data chunk
void CPngWriteCodec::WriteIDATChunk(TBufPtr8& aDst)
{
TPtrC8 ptr(iCompressor->OutputDescriptor());
if (ptr.Length())
{
TInt length = 0;
WritePngChunk(iDestPtr, KPngIDATChunkId, ptr, length);
aDst.SetLength(length);
// New output can write to the same compressor ptr
iCompressor->SetOutput(iCompressorPtr);
}
if (iCallAgain)
iEncoderState = EPngFlush;
}
// Write an END chunk
void CPngWriteCodec::WriteEndChunk(TBufPtr8& aDst)
{
// Write IEND chunk
TInt length = 0;
WritePngChunk(iDestPtr, KPngIENDChunkId, KNullDesC8, length);
aDst.SetLength(length);
}
// Write a header chunk
TInt CPngWriteCodec::WriteHeaderChunk(TBufPtr8& aDst)
{
// Write signature
Mem::Copy(iDestPtr, &KPngSignature[0], KPngFileSignatureLength);
iDestPtr += KPngFileSignatureLength;
// Write IHDR chunk
TBuf8<KPngIHDRChunkSize> buffer;
TUint8* ptr = const_cast<TUint8*>(buffer.Ptr());
// Set length of data
buffer.SetLength(KPngIHDRChunkSize);
// Chunk data
// width (4 bytes)
if ((iImageInfo.iSize.iWidth == 0) ||
(static_cast<TUint>(iImageInfo.iSize.iWidth) > KPngMaxImageSize))
{
return KErrArgument; // invalid width
}
PtrWriteUtil::WriteBigEndianInt32(ptr, iImageInfo.iSize.iWidth);
ptr += 4;
// height (4 bytes)
if ((iImageInfo.iSize.iHeight == 0) ||
(static_cast<TUint>(iImageInfo.iSize.iHeight) > KPngMaxImageSize))
{
return KErrArgument; // invalid height
}
PtrWriteUtil::WriteBigEndianInt32(ptr, iImageInfo.iSize.iHeight);
ptr += 4;
// bit depth (1 byte)
PtrWriteUtil::WriteInt8(ptr, iImageInfo.iBitDepth);
ptr++;
// colour type (1 byte)
PtrWriteUtil::WriteInt8(ptr, iImageInfo.iColorType);
ptr++;
// compression method (1 byte)
PtrWriteUtil::WriteInt8(ptr, iImageInfo.iCompressionMethod);
ptr++;
// filter method (1 byte)
PtrWriteUtil::WriteInt8(ptr, iImageInfo.iFilterMethod);
ptr++;
// interlace method (1 byte)
PtrWriteUtil::WriteInt8(ptr, iImageInfo.iInterlaceMethod);
ptr++;
TInt length = 0;
WritePngChunk(iDestPtr, KPngIHDRChunkId, buffer, length);
aDst.SetLength(KPngFileSignatureLength + length);
return KErrNone;
}
// Chunk writing helper function
void CPngWriteCodec::WritePngChunk(TUint8*& aDestPtr, const TDesC8& aChunkId, const TDesC8& aData, TInt& aLength)
{
// Chunk length (4 bytes)
PtrWriteUtil::WriteBigEndianInt32(aDestPtr, aData.Length());
aDestPtr += KPngChunkLengthSize;
TUint8* crcPtr = aDestPtr; // start position for calculating CRC
// Chunk type (4 bytes)
Mem::Copy(aDestPtr, aChunkId.Ptr(), KPngChunkIdSize);
aDestPtr += KPngChunkIdSize;
// Chunk data (0...n bytes)
Mem::Copy(aDestPtr, aData.Ptr(), aData.Length());
aDestPtr += aData.Length();
// CRC (4 bytes)
TUint32 crc = KPngCrcMask;
GetCrc(crc, crcPtr, KPngChunkIdSize + aData.Length());
crc ^= KPngCrcMask;
PtrWriteUtil::WriteBigEndianInt32(aDestPtr, crc);
aDestPtr += KPngChunkCRCSize;
// Length of chunk
aLength = KPngChunkLengthSize + KPngChunkIdSize + aData.Length() + KPngChunkCRCSize;
}
// from MEZBufferManager, manage data compressor
void CPngWriteCodec::InitializeL(CEZZStream& /*aZStream*/)
{
}
void CPngWriteCodec::NeedInputL(CEZZStream& aZStream)
{
// Give compressor more data from encoder
aZStream.SetInput(iEncoder->EncodeL(iScanline));
if (iCompressor->AvailIn() != 0)
iScanline++;
}
void CPngWriteCodec::NeedOutputL(CEZZStream& /*aZStream*/)
{
// Signal to write an IDAT chunk
iEncoderState = EPngWriteIDAT;
}
void CPngWriteCodec::FinalizeL(CEZZStream& /*aZStream*/)
{
}
// Calculate CRC for PNG chunks
void CPngWriteCodec::GetCrc(TUint32& aCrc, const TUint8* aPtr, const TInt aLength)
{
if (!iCrcTableCalculated)
CalcCrcTable();
TUint32 code = aCrc;
for (TInt i=0; i < aLength; i++)
code = iCrcTable[(code ^ aPtr[i]) & 0xff] ^ (code >> 8);
aCrc = code;
}
void CPngWriteCodec::CalcCrcTable()
{
for (TInt i=0; i < KPngCrcTableLength; i++)
{
TUint32 code = static_cast<TUint32>(i);
for (TInt j = 0; j < 8; j++)
{
if (code & 1)
code = 0xedb88320 ^ (code >> 1);
else
code = code >> 1;
}
iCrcTable[i] = code;
}
iCrcTableCalculated = ETrue;
}
| [
"liuxk99@bdc341c6-17c0-11de-ac9f-1d9250355bca"
] | [
[
[
1,
865
]
]
] |
d40cfdaacd4f068652345c9e8c92b0a24f3cdf65 | c3c30da69cde409b86319bdd8ec30e9918d589b0 | /Transform.h | 5d181948b199772194fba1ca37f8563666ad1e4d | [] | no_license | aaronbee/CS184-Pinball | 8cd2087de0c9567b007842118d8ca1ae7ab95718 | bca5ea49863dc71b5a065331f2cc722a85a78026 | refs/heads/master | 2020-05-19T23:04:10.264264 | 2010-04-01T07:01:31 | 2010-04-01T07:01:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 677 | h | // Transform.h: interface for the Transform class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_Transform_H__C38D00E4_6A44_4E5D_9394_36D0650369D0__INCLUDED_)
#define AFX_Transform_H__C38D00E4_6A44_4E5D_9394_36D0650369D0__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "nv/nv_math.h"
#include "nv/nv_algebra.h"
class Transform
{
public:
Transform();
virtual ~Transform();
static void left(float degrees, vec3& eye, vec3& up);
static void up(float degrees, vec3& eye, vec3& up);
};
#endif // !defined(AFX_Transform_H__C38D00E4_6A44_4E5D_9394_36D0650369D0__INCLUDED_)
| [
"[email protected]"
] | [
[
[
1,
24
]
]
] |
8067a0a442f6a069d957ed041c13349047f03994 | 867f5533667cce30d0743d5bea6b0c083c073386 | /jingxian-network/src/jingxian/networks/commands/DisconnectCommand.cpp | bcd72ab6307502ffa024776cd217ba9a5a1e4641 | [] | no_license | mei-rune/jingxian-project | 32804e0fa82f3f9a38f79e9a99c4645b9256e889 | 47bc7a2cb51fa0d85279f46207f6d7bea57f9e19 | refs/heads/master | 2022-08-12T18:43:37.139637 | 2009-12-11T09:30:04 | 2009-12-11T09:30:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,053 | cpp |
# include "pro_config.h"
# include "jingxian/networks/commands/DisconnectCommand.h"
# include "jingxian/networks/networking.h"
_jingxian_begin
DisconnectCommand::DisconnectCommand(ConnectedSocket* connectedSocket, tstring reason)
: connectedSocket_(connectedSocket)
, reason_(reason)
{
}
DisconnectCommand::~DisconnectCommand()
{
}
void DisconnectCommand::on_complete(size_t bytes_transferred
, bool success
, void *completion_key
, errcode_t error)
{
connectedSocket_->onDisconnected(*this, error, reason_);
delete connectedSocket_;
}
bool DisconnectCommand::execute()
{
if (networking::disconnectEx(connectedSocket_->handle()
, this
, 0
, 0))
return true;
if (WSA_IO_PENDING == ::WSAGetLastError())
return true;
return false;
}
_jingxian_end
| [
"runner.mei@0dd8077a-353d-11de-b438-597f59cd7555"
] | [
[
[
1,
41
]
]
] |
b026b6d89a5fdde89d9fe5723da94a86577f44e6 | ea613c6a4d531be9b5d41ced98df1a91320c59cc | /7-Zip/CPP/7zip/Archive/Iso/IsoIn.cpp | 0475006ca32435d17850dc7423c031966dfae9e2 | [] | no_license | f059074251/interested | 939f938109853da83741ee03aca161bfa9ce0976 | b5a26ad732f8ffdca64cbbadf9625dd35c9cdcb2 | refs/heads/master | 2021-01-15T14:49:45.217066 | 2010-09-16T10:42:30 | 2010-09-16T10:42:30 | 34,316,088 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,079 | cpp | // Archive/IsoIn.cpp
#include "StdAfx.h"
#include "IsoIn.h"
#include "../../Common/StreamUtils.h"
namespace NArchive {
namespace NIso {
Byte CInArchive::ReadByte()
{
if (m_BufferPos >= BlockSize)
m_BufferPos = 0;
if (m_BufferPos == 0)
{
size_t processedSize = BlockSize;
if (ReadStream(_stream, m_Buffer, &processedSize) != S_OK)
throw 1;
if (processedSize != BlockSize)
throw 1;
}
Byte b = m_Buffer[m_BufferPos++];
_position++;
return b;
}
void CInArchive::ReadBytes(Byte *data, UInt32 size)
{
for (UInt32 i = 0; i < size; i++)
data[i] = ReadByte();
}
void CInArchive::Skip(size_t size)
{
while (size-- != 0)
ReadByte();
}
void CInArchive::SkipZeros(size_t size)
{
while (size-- != 0)
{
Byte b = ReadByte();
if (b != 0)
throw 1;
}
}
UInt16 CInArchive::ReadUInt16Spec()
{
UInt16 value = 0;
for (int i = 0; i < 2; i++)
value |= ((UInt16)(ReadByte()) << (8 * i));
return value;
}
UInt16 CInArchive::ReadUInt16()
{
Byte b[4];
ReadBytes(b, 4);
UInt32 value = 0;
for (int i = 0; i < 2; i++)
{
if (b[i] != b[3 - i])
throw 1;
value |= ((UInt16)(b[i]) << (8 * i));
}
return (UInt16)value;
}
UInt32 CInArchive::ReadUInt32Le()
{
UInt32 value = 0;
for (int i = 0; i < 4; i++)
value |= ((UInt32)(ReadByte()) << (8 * i));
return value;
}
UInt32 CInArchive::ReadUInt32Be()
{
UInt32 value = 0;
for (int i = 0; i < 4; i++)
{
value <<= 8;
value |= ReadByte();
}
return value;
}
UInt32 CInArchive::ReadUInt32()
{
Byte b[8];
ReadBytes(b, 8);
UInt32 value = 0;
for (int i = 0; i < 4; i++)
{
if (b[i] != b[7 - i])
throw 1;
value |= ((UInt32)(b[i]) << (8 * i));
}
return value;
}
UInt32 CInArchive::ReadDigits(int numDigits)
{
UInt32 res = 0;
for (int i = 0; i < numDigits; i++)
{
Byte b = ReadByte();
if (b < '0' || b > '9')
{
if (b == 0) // it's bug in some CD's
b = '0';
else
throw 1;
}
UInt32 d = (UInt32)(b - '0');
res *= 10;
res += d;
}
return res;
}
void CInArchive::ReadDateTime(CDateTime &d)
{
d.Year = (UInt16)ReadDigits(4);
d.Month = (Byte)ReadDigits(2);
d.Day = (Byte)ReadDigits(2);
d.Hour = (Byte)ReadDigits(2);
d.Minute = (Byte)ReadDigits(2);
d.Second = (Byte)ReadDigits(2);
d.Hundredths = (Byte)ReadDigits(2);
d.GmtOffset = (signed char)ReadByte();
}
void CInArchive::ReadBootRecordDescriptor(CBootRecordDescriptor &d)
{
ReadBytes(d.BootSystemId, sizeof(d.BootSystemId));
ReadBytes(d.BootId, sizeof(d.BootId));
ReadBytes(d.BootSystemUse, sizeof(d.BootSystemUse));
}
void CInArchive::ReadRecordingDateTime(CRecordingDateTime &t)
{
t.Year = ReadByte();
t.Month = ReadByte();
t.Day = ReadByte();
t.Hour = ReadByte();
t.Minute = ReadByte();
t.Second = ReadByte();
t.GmtOffset = (signed char)ReadByte();
}
void CInArchive::ReadDirRecord2(CDirRecord &r, Byte len)
{
r.ExtendedAttributeRecordLen = ReadByte();
if (r.ExtendedAttributeRecordLen != 0)
throw 1;
r.ExtentLocation = ReadUInt32();
r.DataLength = ReadUInt32();
ReadRecordingDateTime(r.DateTime);
r.FileFlags = ReadByte();
r.FileUnitSize = ReadByte();
r.InterleaveGapSize = ReadByte();
r.VolSequenceNumber = ReadUInt16();
Byte idLen = ReadByte();
r.FileId.SetCapacity(idLen);
ReadBytes((Byte *)r.FileId, idLen);
int padSize = 1 - (idLen & 1);
// SkipZeros(1 - (idLen & 1));
Skip(1 - (idLen & 1)); // it's bug in some cd's. Must be zeros
int curPos = 33 + idLen + padSize;
if (curPos > len)
throw 1;
int rem = len - curPos;
r.SystemUse.SetCapacity(rem);
ReadBytes((Byte *)r.SystemUse, rem);
}
void CInArchive::ReadDirRecord(CDirRecord &r)
{
Byte len = ReadByte();
// Some CDs can have incorrect value len = 48 ('0') in VolumeDescriptor.
// But maybe we must use real "len" for other records.
len = 34;
ReadDirRecord2(r, len);
}
void CInArchive::ReadVolumeDescriptor(CVolumeDescriptor &d)
{
d.VolFlags = ReadByte();
ReadBytes(d.SystemId, sizeof(d.SystemId));
ReadBytes(d.VolumeId, sizeof(d.VolumeId));
SkipZeros(8);
d.VolumeSpaceSize = ReadUInt32();
ReadBytes(d.EscapeSequence, sizeof(d.EscapeSequence));
d.VolumeSetSize = ReadUInt16();
d.VolumeSequenceNumber = ReadUInt16();
d.LogicalBlockSize = ReadUInt16();
d.PathTableSize = ReadUInt32();
d.LPathTableLocation = ReadUInt32Le();
d.LOptionalPathTableLocation = ReadUInt32Le();
d.MPathTableLocation = ReadUInt32Be();
d.MOptionalPathTableLocation = ReadUInt32Be();
ReadDirRecord(d.RootDirRecord);
ReadBytes(d.VolumeSetId, sizeof(d.VolumeSetId));
ReadBytes(d.PublisherId, sizeof(d.PublisherId));
ReadBytes(d.DataPreparerId, sizeof(d.DataPreparerId));
ReadBytes(d.ApplicationId, sizeof(d.ApplicationId));
ReadBytes(d.CopyrightFileId, sizeof(d.CopyrightFileId));
ReadBytes(d.AbstractFileId, sizeof(d.AbstractFileId));
ReadBytes(d.BibFileId, sizeof(d.BibFileId));
ReadDateTime(d.CTime);
ReadDateTime(d.MTime);
ReadDateTime(d.ExpirationTime);
ReadDateTime(d.EffectiveTime);
d.FileStructureVersion = ReadByte(); // = 1
SkipZeros(1);
ReadBytes(d.ApplicationUse, sizeof(d.ApplicationUse));
SkipZeros(653);
}
static const Byte kSig_CD001[5] = { 'C', 'D', '0', '0', '1' };
static const Byte kSig_NSR02[5] = { 'N', 'S', 'R', '0', '2' };
static const Byte kSig_NSR03[5] = { 'N', 'S', 'R', '0', '3' };
static const Byte kSig_BEA01[5] = { 'B', 'E', 'A', '0', '1' };
static const Byte kSig_TEA01[5] = { 'T', 'E', 'A', '0', '1' };
static inline bool CheckSignature(const Byte *sig, const Byte *data)
{
for (int i = 0; i < 5; i++)
if (sig[i] != data[i])
return false;
return true;
}
void CInArchive::SeekToBlock(UInt32 blockIndex)
{
if (_stream->Seek((UInt64)blockIndex * VolDescs[MainVolDescIndex].LogicalBlockSize, STREAM_SEEK_SET, &_position) != S_OK)
throw 1;
m_BufferPos = 0;
}
void CInArchive::ReadDir(CDir &d, int level)
{
if (!d.IsDir())
return;
SeekToBlock(d.ExtentLocation);
UInt64 startPos = _position;
bool firstItem = true;
for (;;)
{
UInt64 offset = _position - startPos;
if (offset >= d.DataLength)
break;
Byte len = ReadByte();
if (len == 0)
continue;
CDir subItem;
ReadDirRecord2(subItem, len);
if (firstItem && level == 0)
IsSusp = subItem.CheckSusp(SuspSkipSize);
if (!subItem.IsSystemItem())
d._subItems.Add(subItem);
firstItem = false;
}
for (int i = 0; i < d._subItems.Size(); i++)
ReadDir(d._subItems[i], level + 1);
}
void CInArchive::CreateRefs(CDir &d)
{
if (!d.IsDir())
return;
for (int i = 0; i < d._subItems.Size(); i++)
{
CRef ref;
CDir &subItem = d._subItems[i];
subItem.Parent = &d;
ref.Dir = &d;
ref.Index = i;
Refs.Add(ref);
CreateRefs(subItem);
}
}
void CInArchive::ReadBootInfo()
{
if (!_bootIsDefined)
return;
if (memcmp(_bootDesc.BootSystemId, kElToritoSpec, sizeof(_bootDesc.BootSystemId)) != 0)
return;
const Byte *p = (const Byte *)_bootDesc.BootSystemUse;
UInt32 blockIndex = p[0] | ((UInt32)p[1] << 8) | ((UInt32)p[2] << 16) | ((UInt32)p[3] << 24);
SeekToBlock(blockIndex);
Byte b = ReadByte();
if (b != NBootEntryId::kValidationEntry)
return;
{
CBootValidationEntry e;
e.PlatformId = ReadByte();
if (ReadUInt16Spec() != 0)
throw 1;
ReadBytes(e.Id, sizeof(e.Id));
/* UInt16 checkSum = */ ReadUInt16Spec();
if (ReadByte() != 0x55)
throw 1;
if (ReadByte() != 0xAA)
throw 1;
}
b = ReadByte();
if (b == NBootEntryId::kInitialEntryBootable || b == NBootEntryId::kInitialEntryNotBootable)
{
CBootInitialEntry e;
e.Bootable = (b == NBootEntryId::kInitialEntryBootable);
e.BootMediaType = ReadByte();
e.LoadSegment = ReadUInt16Spec();
e.SystemType = ReadByte();
if (ReadByte() != 0)
throw 1;
e.SectorCount = ReadUInt16Spec();
e.LoadRBA = ReadUInt32Le();
if (ReadByte() != 0)
throw 1;
BootEntries.Add(e);
}
else
return;
}
HRESULT CInArchive::Open2()
{
Clear();
RINOK(_stream->Seek(kStartPos, STREAM_SEEK_CUR, &_position));
m_BufferPos = 0;
BlockSize = kBlockSize;
for (;;)
{
Byte sig[7];
ReadBytes(sig, 7);
Byte ver = sig[6];
if (!CheckSignature(kSig_CD001, sig + 1))
{
return S_FALSE;
/*
if (sig[0] != 0 || ver != 1)
break;
if (CheckSignature(kSig_BEA01, sig + 1))
{
}
else if (CheckSignature(kSig_TEA01, sig + 1))
{
break;
}
else if (CheckSignature(kSig_NSR02, sig + 1))
{
}
else
break;
SkipZeros(0x800 - 7);
continue;
*/
}
// version = 2 for ISO 9660:1999?
if (ver > 2)
throw S_FALSE;
if (sig[0] == NVolDescType::kTerminator)
{
break;
// Skip(0x800 - 7);
// continue;
}
switch(sig[0])
{
case NVolDescType::kBootRecord:
{
_bootIsDefined = true;
ReadBootRecordDescriptor(_bootDesc);
break;
}
case NVolDescType::kPrimaryVol:
case NVolDescType::kSupplementaryVol:
{
// some ISOs have two PrimaryVols.
CVolumeDescriptor vd;
ReadVolumeDescriptor(vd);
if (sig[0] == NVolDescType::kPrimaryVol)
{
// some burners write "Joliet" Escape Sequence to primary volume
memset(vd.EscapeSequence, 0, sizeof(vd.EscapeSequence));
}
VolDescs.Add(vd);
break;
}
default:
break;
}
}
if (VolDescs.IsEmpty())
return S_FALSE;
for (MainVolDescIndex = VolDescs.Size() - 1; MainVolDescIndex > 0; MainVolDescIndex--)
if (VolDescs[MainVolDescIndex].IsJoliet())
break;
// MainVolDescIndex = 0; // to read primary volume
const CVolumeDescriptor &vd = VolDescs[MainVolDescIndex];
if (vd.LogicalBlockSize != kBlockSize)
return S_FALSE;
(CDirRecord &)_rootDir = vd.RootDirRecord;
ReadDir(_rootDir, 0);
CreateRefs(_rootDir);
ReadBootInfo();
return S_OK;
}
HRESULT CInArchive::Open(IInStream *inStream)
{
_stream = inStream;
UInt64 pos;
RINOK(_stream->Seek(0, STREAM_SEEK_CUR, &pos));
RINOK(_stream->Seek(0, STREAM_SEEK_END, &_archiveSize));
RINOK(_stream->Seek(pos, STREAM_SEEK_SET, &_position));
HRESULT res = S_FALSE;
try { res = Open2(); }
catch(...) { Clear(); res = S_FALSE; }
_stream.Release();
return res;
}
void CInArchive::Clear()
{
Refs.Clear();
_rootDir.Clear();
VolDescs.Clear();
_bootIsDefined = false;
BootEntries.Clear();
SuspSkipSize = 0;
IsSusp = false;
}
}}
| [
"[email protected]@8d1da77e-e9f6-11de-9c2a-cb0f5ba72f9d"
] | [
[
[
1,
452
]
]
] |
a5e558b22f3d2a613a440e868d1b413af24161f7 | 68bfdfc18f1345d1ff394b8115681110644d5794 | /Examples/Example01/Include.h | 32c9b0521f2ad7269d714ff543c6757b918690ee | [] | no_license | y-gupta/glwar3 | 43afa1efe475d937ce0439464b165c745e1ec4b1 | bea5135bd13f9791b276b66490db76d866696f9a | refs/heads/master | 2021-05-28T12:20:41.532727 | 2010-12-09T07:52:12 | 2010-12-09T07:52:12 | 32,911,819 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,401 | h | #pragma once
//+-----------------------------------------------------------------------------
//| Prevents stupid warning messages
//+-----------------------------------------------------------------------------
#pragma warning(disable:4311)
#pragma warning(disable:4312)
#pragma warning(disable:4005)
//+-----------------------------------------------------------------------------
//| Windows included files
//+-----------------------------------------------------------------------------
#include <windows.h>
#include <commctrl.h>
#include <cctype>
#include <cmath>
#include <ctime>
//+-----------------------------------------------------------------------------
//| OpenGL ES included files
//+-----------------------------------------------------------------------------
#include "esUtil.h"
//+-----------------------------------------------------------------------------
//| STL included files
//+-----------------------------------------------------------------------------
#include <algorithm>
#include <fstream>
#include <sstream>
#include <string>
#include <limits>
#include <vector>
#include <list>
#include <map>
#include <set>
//+-----------------------------------------------------------------------------
//| Removes stupid macros
//+-----------------------------------------------------------------------------
#undef min
#undef max | [
"sihan6677@deb3bc48-0ee2-faf5-68d7-13371a682d83"
] | [
[
[
1,
44
]
]
] |
2032921a80056841b55061b6da6778471426067b | a0155e192c9dc2029b231829e3db9ba90861f956 | /MailFilter/Main/MFVirusScan.h | 2ec644b6358123d3b03f3cfd3f2ee652eb5aac75 | [] | no_license | zeha/mailfilter | d2de4aaa79bed2073cec76c93768a42068cfab17 | 898dd4d4cba226edec566f4b15c6bb97e79f8001 | refs/heads/master | 2021-01-22T02:03:31.470739 | 2010-08-12T23:51:35 | 2010-08-12T23:51:35 | 81,022,257 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 797 | h | /*
+
+ MFVirusScan.h
+ Copyright 2004 Christian Hofstaedtler.
*/
typedef enum mimeEncodingType {
mimeEncodingBase64, mimeEncodingQuotedPrintable, mimeEncodingUUEncode
} mimeEncodingType;
long MFVS_DecodeAttachment(const char* szScanFile, FILE* mailFile, mimeEncodingType encodingType);
long MFUtil_EncodeFile(const char* szInFile, const char* szOutFile, mimeEncodingType encodingType);
long MFVS_MakeScanPath (char* buffer, unsigned int buflen);
long MFVS_CheckAttachment(const char* szAttFile, const char* szAttachmentFilename, MailFilter_MailData* m);
long MFVS_CheckZIPFile(const char* szAttFile, std::string szZipFilename, MailFilter_MailData* m);
long MFVS_CheckWinmailDat(const char* szAttFile, std::string szTNEFFilename, MailFilter_MailData* m);
/* eof */
| [
"[email protected]"
] | [
[
[
1,
21
]
]
] |
dd9af0564018911e9328a0e907fe1fdfb4a7ccfb | f89e32cc183d64db5fc4eb17c47644a15c99e104 | /pcsx2-rr/pcsx2/Dmac.h | 856e4c30ff5c42c09273b66abc0d7c07b6b86f20 | [] | no_license | mauzus/progenitor | f99b882a48eb47a1cdbfacd2f38505e4c87480b4 | 7b4f30eb1f022b08e6da7eaafa5d2e77634d7bae | refs/heads/master | 2021-01-10T07:24:00.383776 | 2011-04-28T11:03:43 | 2011-04-28T11:03:43 | 45,171,114 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,748 | h | /* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2010 PCSX2 Dev Team
*
* PCSX2 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 Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 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 PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
// Useful enums for some of the fields.
enum pce_values
{
PCE_NOTHING = 0,
PCE_RESERVED,
PCE_DISABLED,
PCE_ENABLED
};
enum tag_id
{
TAG_CNTS = 0,
TAG_REFE = 0, // Transfer Packet According to ADDR field, clear STR, and end
TAG_CNT, // Transfer QWC following the tag.
TAG_NEXT, // Transfer QWC following tag. TADR = ADDR
TAG_REF, // Transfer QWC from ADDR field
TAG_REFS, // Transfer QWC from ADDR field (Stall Control)
TAG_CALL, // Transfer QWC following the tag, save succeeding tag
TAG_RET, // Transfer QWC following the tag, load next tag
TAG_END // Transfer QWC following the tag
};
enum mfd_type
{
NO_MFD = 0,
MFD_RESERVED,
MFD_VIF1,
MFD_GIF
};
enum sts_type
{
NO_STS = 0,
STS_SIF0,
STS_fromSPR,
STS_fromIPU
};
enum std_type
{
NO_STD = 0,
STD_VIF1,
STD_GIF,
STD_SIF1
};
enum LogicalTransferMode
{
NORMAL_MODE = 0,
CHAIN_MODE,
INTERLEAVE_MODE,
UNDEFINED_MODE
};
//
// --- DMA ---
//
// Doing double duty as both the top 32 bits *and* the lower 32 bits of a chain tag.
// Theoretically should probably both be in a u64 together, but with the way the
// code is layed out, this is easier for the moment.
union tDMA_TAG {
struct {
u32 QWC : 16;
u32 _reserved2 : 10;
u32 PCE : 2;
u32 ID : 3;
u32 IRQ : 1;
};
struct {
u32 ADDR : 31;
u32 SPR : 1;
};
u32 _u32;
tDMA_TAG(u32 val) { _u32 = val; }
u16 upper() const { return (_u32 >> 16); }
u16 lower() const { return (u16)_u32; }
wxString tag_to_str() const
{
switch(ID)
{
case TAG_REFE: return wxsFormat(L"REFE %08X", _u32); break;
case TAG_CNT: return L"CNT"; break;
case TAG_NEXT: return wxsFormat(L"NEXT %08X", _u32); break;
case TAG_REF: return wxsFormat(L"REF %08X", _u32); break;
case TAG_REFS: return wxsFormat(L"REFS %08X", _u32); break;
case TAG_CALL: return L"CALL"; break;
case TAG_RET: return L"RET"; break;
case TAG_END: return L"END"; break;
default: return L"????"; break;
}
}
void reset() { _u32 = 0; }
};
#define DMA_TAG(value) ((tDMA_TAG)(value))
union tDMA_CHCR {
struct {
u32 DIR : 1; // Direction: 0 - to memory, 1 - from memory. VIF1 & SIF2 only.
u32 _reserved1 : 1;
u32 MOD : 2; // Logical transfer mode. Normal, Chain, or Interleave (see LogicalTransferMode enum)
u32 ASP : 2; // ASP1 & ASP2; Address stack pointer. 0, 1, or 2 addresses.
u32 TTE : 1; // Tag Transfer Enable. 0 - Disable / 1 - Enable.
u32 TIE : 1; // Tag Interrupt Enable. 0 - Disable / 1 - Enable.
u32 STR : 1; // Start. 0 while stopping DMA, 1 while it's running.
u32 _reserved2 : 7;
u32 TAG : 16; // Maintains upper 16 bits of the most recently read DMAtag.
};
u32 _u32;
tDMA_CHCR( u32 val) { _u32 = val; }
bool test(u32 flags) const { return !!(_u32 & flags); }
void set(u32 value) { _u32 = value; }
void set_flags(u32 flags) { _u32 |= flags; }
void clear_flags(u32 flags) { _u32 &= ~flags; }
void reset() { _u32 = 0; }
u16 upper() const { return (_u32 >> 16); }
u16 lower() const { return (u16)_u32; }
wxString desc() const { return wxsFormat(L"Chcr: 0x%x", _u32); }
tDMA_TAG tag() { return (tDMA_TAG)_u32; }
};
#define CHCR(value) ((tDMA_CHCR)(value))
union tDMA_SADR {
struct {
u32 ADDR : 14;
u32 reserved2 : 18;
};
u32 _u32;
tDMA_SADR(u32 val) { _u32 = val; }
void reset() { _u32 = 0; }
wxString desc() const { return wxsFormat(L"Sadr: 0x%x", _u32); }
tDMA_TAG tag() const { return (tDMA_TAG)_u32; }
};
union tDMA_QWC {
struct {
u16 QWC;
u16 _unused;
};
u32 _u32;
tDMA_QWC(u32 val) { _u32 = val; }
void reset() { _u32 = 0; }
wxString desc() const { return wxsFormat(L"QWC: 0x%04x", QWC); }
tDMA_TAG tag() const { return (tDMA_TAG)_u32; }
};
struct DMACh {
tDMA_CHCR chcr;
u32 _null0[3];
u32 madr;
u32 _null1[3];
u16 qwc; u16 pad;
u32 _null2[3];
u32 tadr;
u32 _null3[3];
u32 asr0;
u32 _null4[3];
u32 asr1;
u32 _null5[11];
u32 sadr;
void chcrTransfer(tDMA_TAG* ptag)
{
chcr.TAG = ptag[0].upper();
}
void qwcTransfer(tDMA_TAG* ptag)
{
qwc = ptag[0].QWC;
}
bool transfer(const char *s, tDMA_TAG* ptag);
void unsafeTransfer(tDMA_TAG* ptag);
tDMA_TAG *getAddr(u32 addr, u32 num, bool write);
tDMA_TAG *DMAtransfer(u32 addr, u32 num);
tDMA_TAG dma_tag();
wxString cmq_to_str() const;
wxString cmqt_to_str() const;
};
enum INTCIrqs
{
INTC_GS = 0,
INTC_SBUS,
INTC_VBLANK_S,
INTC_VBLANK_E,
INTC_VIF0,
INTC_VIF1,
INTC_VU0,
INTC_VU1,
INTC_IPU,
INTC_TIM0,
INTC_TIM1,
INTC_TIM2,
INTC_TIM3,
INTC_SFIFO,
INTVU0_WD
};
enum dmac_conditions
{
DMAC_STAT_SIS = (1<<13), // stall condition
DMAC_STAT_MEIS = (1<<14), // mfifo empty
DMAC_STAT_BEIS = (1<<15), // bus error
DMAC_STAT_SIM = (1<<29), // stall mask
DMAC_STAT_MEIM = (1<<30) // mfifo mask
};
//DMA interrupts & masks
enum DMAInter
{
BEISintr = 0x00008000,
VIF0intr = 0x00010001,
VIF1intr = 0x00020002,
GIFintr = 0x00040004,
IPU0intr = 0x00080008,
IPU1intr = 0x00100010,
SIF0intr = 0x00200020,
SIF1intr = 0x00400040,
SIF2intr = 0x00800080,
SPR0intr = 0x01000100,
SPR1intr = 0x02000200,
SISintr = 0x20002000,
MEISintr = 0x40004000
};
union tDMAC_QUEUE
{
struct
{
u16 VIF0 : 1;
u16 VIF1 : 1;
u16 GIF : 1;
u16 IPU0 : 1;
u16 IPU1 : 1;
u16 SIF0 : 1;
u16 SIF1 : 1;
u16 SIF2 : 1;
u16 SPR0 : 1;
u16 SPR1 : 1;
u16 SIS : 1;
u16 MEIS : 1;
u16 BEIS : 1;
};
u16 _u16;
tDMAC_QUEUE(u16 val) { _u16 = val; }
void reset() { _u16 = 0; }
bool empty() const { return (_u16 == 0); }
};
static __fi const wxChar* ChcrName(u32 addr)
{
switch (addr)
{
case D0_CHCR: return L"Vif 0";
case D1_CHCR: return L"Vif 1";
case D2_CHCR: return L"GIF";
case D3_CHCR: return L"Ipu 0";
case D4_CHCR: return L"Ipu 1";
case D5_CHCR: return L"Sif 0";
case D6_CHCR: return L"Sif 1";
case D7_CHCR: return L"Sif 2";
case D8_CHCR: return L"SPR 0";
case D9_CHCR: return L"SPR 1";
default: return L"???";
}
}
// Believe it or not, making this const can generate compiler warnings in gcc.
static __fi int ChannelNumber(u32 addr)
{
switch (addr)
{
case D0_CHCR: return 0;
case D1_CHCR: return 1;
case D2_CHCR: return 2;
case D3_CHCR: return 3;
case D4_CHCR: return 4;
case D5_CHCR: return 5;
case D6_CHCR: return 6;
case D7_CHCR: return 7;
case D8_CHCR: return 8;
case D9_CHCR: return 9;
default:
{
pxFailDev("Invalid DMA channel number");
return 51; // some value
}
}
}
union tDMAC_CTRL {
struct {
u32 DMAE : 1; // 0/1 - disables/enables all DMAs
u32 RELE : 1; // 0/1 - cycle stealing off/on
u32 MFD : 2; // Memory FIFO drain channel (mfd_type)
u32 STS : 2; // Stall Control source channel (sts type)
u32 STD : 2; // Stall Control drain channel (std_type)
u32 RCYC : 3; // Release cycle (8/16/32/64/128/256)
u32 _reserved1 : 21;
};
u32 _u32;
tDMAC_CTRL(u32 val) { _u32 = val; }
bool test(u32 flags) const { return !!(_u32 & flags); }
void set_flags(u32 flags) { _u32 |= flags; }
void clear_flags(u32 flags) { _u32 &= ~flags; }
void reset() { _u32 = 0; }
wxString desc() const { return wxsFormat(L"Ctrl: 0x%x", _u32); }
};
union tDMAC_STAT {
struct {
u32 CIS : 10;
u32 _reserved1 : 3;
u32 SIS : 1;
u32 MEIS : 1;
u32 BEIS : 1;
u32 CIM : 10;
u32 _reserved2 : 3;
u32 SIM : 1;
u32 MEIM : 1;
u32 _reserved3 : 1;
};
u32 _u32;
u16 _u16[2];
tDMAC_STAT(u32 val) { _u32 = val; }
bool test(u32 flags) const { return !!(_u32 & flags); }
void set_flags(u32 flags) { _u32 |= flags; }
void clear_flags(u32 flags) { _u32 &= ~flags; }
void reset() { _u32 = 0; }
wxString desc() const { return wxsFormat(L"Stat: 0x%x", _u32); }
bool TestForInterrupt() const
{
return ((_u16[0] & _u16[1]) != 0) || BEIS;
}
};
union tDMAC_PCR {
struct {
u32 CPC : 10;
u32 _reserved1 : 6;
u32 CDE : 10;
u32 _reserved2 : 5;
u32 PCE : 1;
};
u32 _u32;
tDMAC_PCR(u32 val) { _u32 = val; }
bool test(u32 flags) const { return !!(_u32 & flags); }
void set_flags(u32 flags) { _u32 |= flags; }
void clear_flags(u32 flags) { _u32 &= ~flags; }
void reset() { _u32 = 0; }
wxString desc() const { return wxsFormat(L"Pcr: 0x%x", _u32); }
};
union tDMAC_SQWC {
struct {
u32 SQWC : 8;
u32 _reserved1 : 8;
u32 TQWC : 8;
u32 _reserved2 : 8;
};
u32 _u32;
tDMAC_SQWC(u32 val) { _u32 = val; }
bool test(u32 flags) const { return !!(_u32 & flags); }
void set_flags(u32 flags) { _u32 |= flags; }
void clear_flags(u32 flags) { _u32 &= ~flags; }
void reset() { _u32 = 0; }
wxString desc() const { return wxsFormat(L"Sqwc: 0x%x", _u32); }
};
union tDMAC_RBSR {
struct {
u32 RMSK : 31;
u32 _reserved1 : 1;
};
u32 _u32;
tDMAC_RBSR(u32 val) { _u32 = val; }
void reset() { _u32 = 0; }
wxString desc() const { return wxsFormat(L"Rbsr: 0x%x", _u32); }
};
union tDMAC_RBOR {
struct {
u32 ADDR : 31;
u32 _reserved1 : 1;
};
u32 _u32;
tDMAC_RBOR(u32 val) { _u32 = val; }
void reset() { _u32 = 0; }
wxString desc() const { return wxsFormat(L"Rbor: 0x%x", _u32); }
};
// --------------------------------------------------------------------------------------
// tDMAC_ADDR
// --------------------------------------------------------------------------------------
// This struct is used for several DMA address types, including some that do not have
// effective SPR bit (the bit is ignored for all addresses that are not "allowed" to access
// the scratchpad, including STADR, toSPR.MADR, fromSPR.MADR, etc.).
//
union tDMAC_ADDR
{
struct {
u32 ADDR : 31; // Transfer memory address
u32 SPR : 1; // Memory/SPR Address (only effective for MADR and TADR of non-SPR DMAs)
};
u32 _u32;
tDMAC_ADDR() {}
tDMAC_ADDR(u32 val) { _u32 = val; }
void clear() { _u32 = 0; }
void AssignADDR(uint addr)
{
ADDR = addr;
if (SPR) ADDR &= (Ps2MemSize::Scratch-1);
}
void IncrementQWC(uint incval = 1)
{
ADDR += incval;
if (SPR) ADDR &= (Ps2MemSize::Scratch-1);
}
wxString ToString(bool sprIsValid=true) const
{
return pxsFmt((sprIsValid && SPR) ? L"0x%04X(SPR)" : L"0x%08X", ADDR);
}
wxCharBuffer ToUTF8(bool sprIsValid=true) const
{
return FastFormatAscii().Write((sprIsValid && SPR) ? "0x%04X(SPR)" : "0x%08X", ADDR).c_str();
}
};
struct DMACregisters
{
tDMAC_CTRL ctrl;
u32 _padding[3];
tDMAC_STAT stat;
u32 _padding1[3];
tDMAC_PCR pcr;
u32 _padding2[3];
tDMAC_SQWC sqwc;
u32 _padding3[3];
tDMAC_RBSR rbsr;
u32 _padding4[3];
tDMAC_RBOR rbor;
u32 _padding5[3];
tDMAC_ADDR stadr;
u32 _padding6[3];
};
// Currently guesswork.
union tINTC_STAT {
struct {
u32 interrupts : 10;
u32 _placeholder : 22;
};
u32 _u32;
tINTC_STAT(u32 val) { _u32 = val; }
bool test(u32 flags) const { return !!(_u32 & flags); }
void set_flags(u32 flags) { _u32 |= flags; }
void clear_flags(u32 flags) { _u32 &= ~flags; }
void reset() { _u32 = 0; }
wxString desc() const { return wxsFormat(L"Stat: 0x%x", _u32); }
};
union tINTC_MASK {
struct {
u32 int_mask : 10;
u32 _placeholder:22;
};
u32 _u32;
tINTC_MASK(u32 val) { _u32 = val; }
bool test(u32 flags) const { return !!(_u32 & flags); }
void set_flags(u32 flags) { _u32 |= flags; }
void clear_flags(u32 flags) { _u32 &= ~flags; }
void reset() { _u32 = 0; }
wxString desc() const { return wxsFormat(L"Mask: 0x%x", _u32); }
};
struct INTCregisters
{
tINTC_STAT stat;
u32 _padding1[3];
tINTC_MASK mask;
u32 _padding2[3];
};
#define intcRegs ((INTCregisters*)(eeHw+0xF000))
static DMACregisters& dmacRegs = (DMACregisters&)eeHw[0xE000];
// Various useful locations
static DMACh& vif0ch = (DMACh&)eeHw[0x8000];
static DMACh& vif1ch = (DMACh&)eeHw[0x9000];
static DMACh& gifch = (DMACh&)eeHw[0xA000];
static DMACh& spr0ch = (DMACh&)eeHw[0xD000];
static DMACh& spr1ch = (DMACh&)eeHw[0xD400];
extern void throwBusError(const char *s);
extern void setDmacStat(u32 num);
extern tDMA_TAG *SPRdmaGetAddr(u32 addr, bool write);
extern tDMA_TAG *dmaGetAddr(u32 addr, bool write);
extern void hwIntcIrq(int n);
extern void hwDmacIrq(int n);
extern bool hwMFIFOWrite(u32 addr, const u128* data, uint size_qwc);
extern bool hwDmacSrcChainWithStack(DMACh& dma, int id);
extern bool hwDmacSrcChain(DMACh& dma, int id);
template< uint page > u32 dmacRead32( u32 mem );
template< uint page > extern bool dmacWrite32( u32 mem, mem32_t& value );
| [
"koeiprogenitor@bfa1b011-20a7-a6e3-c617-88e5d26e11c5"
] | [
[
[
1,
562
]
]
] |
1e206c2d43bf843bf9a8340ccde07c7f0b8ad0da | d397b0d420dffcf45713596f5e3db269b0652dee | /src/Axe/AdapterSession.cpp | fe217ca6bbebb95df5c51e173f8b1e4e9a09bec5 | [] | no_license | irov/Axe | 62cf29def34ee529b79e6dbcf9b2f9bf3709ac4f | d3de329512a4251470cbc11264ed3868d9261d22 | refs/heads/master | 2021-01-22T20:35:54.710866 | 2010-09-15T14:36:43 | 2010-09-15T14:36:43 | 85,337,070 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,126 | cpp | # include "pch.hpp"
# include <Axe/AdapterSession.hpp>
# include <Axe/Adapter.hpp>
# include <Axe/ArchiveInvocation.hpp>
# include <Axe/ArchiveDispatcher.hpp>
namespace Axe
{
//////////////////////////////////////////////////////////////////////////
AdapterSession::AdapterSession( const SocketPtr & _socket, const ConnectionCachePtr & _connectionCache, const AdapterPtr & _adapter )
: Session(_socket, _connectionCache)
, m_adapter(_adapter)
{
}
//////////////////////////////////////////////////////////////////////////
void AdapterSession::dispatchMessage( ArchiveDispatcher & _ar, std::size_t _size )
{
std::size_t servantId;
std::size_t methodId;
std::size_t requestId;
_ar.read( servantId );
_ar.readSize( methodId );
_ar.readSize( requestId );
m_adapter->dispatchMethod( servantId, methodId, requestId, _ar, this );
}
//////////////////////////////////////////////////////////////////////////
void AdapterSession::permissionVerify( ArchiveDispatcher & _ar, std::size_t _size )
{
this->beginConnect( true );
this->process();
this->run();
}
} | [
"yuriy_levchenko@b35ac3e7-fb55-4080-a4c2-184bb04a16e0"
] | [
[
[
1,
38
]
]
] |
df5bcabc6fbaf2c2dc701dad58d9cf455f03a808 | 847cccd728e768dc801d541a2d1169ef562311cd | /src/GfxSystem/ScreenToWorldConverter.h | 4c529927a5887d063b88ba110a222d038be6faea | [] | no_license | aadarshasubedi/Ocerus | 1bea105de9c78b741f3de445601f7dee07987b96 | 4920b99a89f52f991125c9ecfa7353925ea9603c | refs/heads/master | 2021-01-17T17:50:00.472657 | 2011-03-25T13:26:12 | 2011-03-25T13:26:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 365 | h | /// @file
/// Makes the conversion from the screen space to the game world space.
#ifndef ScreenToWorldConverter_h__
#define ScreenToWorldConverter_h__
#include "Base.h"
namespace GfxSystem
{
/// Makes the conversion from the screen space to the game world space.
namespace ScreenToWorldConverter
{
}
}
#endif // ScreenToWorldConverter_h__ | [
"[email protected]"
] | [
[
[
1,
18
]
]
] |
e4dfb350329e43347c2f3c201910a96b1fa025a2 | 66b1bdab27d837d2f12e7d040de5ae876ddfcd6c | /playground/performance/staticlibrary/staticlibfunc.cpp | d82b12f2b399fc4b4f91fd6673add1e45559011a | [] | no_license | x-martian/xf10036 | 743f1a2074d5fcb7e66c95be7c3f4279963dd0d1 | 82e7940acd7b7e8db7b118eacab892082e293ef5 | refs/heads/master | 2016-09-05T19:58:07.233316 | 2010-02-02T22:16:22 | 2010-02-02T22:16:22 | 35,009,632 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,203 | cpp | typedef unsigned char BYTE;
// This is an example of an exported function.
void fninterpolator(void* imageArray, int iw, int ih, int il, void* disp, void* lut)
{
int w = 300;
int h = 300;
double* interp = new double[iw+1];
// set value at each pixel, use linear interpolation
short* lo;
short* hi;
BYTE v = 0;
int l = 0;
do {
BYTE* pv = (BYTE*)disp;
for (int j=0; j<h; ++j) {
short* p0 = (short*)imageArray+iw*ih*l;
double* mid = interp;
double x = double((2*j+1)*ih-h)/double(2*h);
if (x>0.0) {
int index = x;
x -= index;
lo = p0+index*iw;
hi = lo+iw;
} else {
x += 1.0;
hi = p0;
if (hi>imageArray)
lo = hi - iw;
else
lo = (short*)imageArray + iw*(ih*il);
}
double y = 1.0-x;
for (int m=0; m<iw; ++m) {
*mid = *lo*y+*hi*x;
++mid; ++lo; ++hi;
}
*mid = *interp; // repeat the first point at the end
for (int i=0; i<w; ++i) {
x = double((2*i+1)*iw-w)/double(2*w);
if (x>0.0)
{
int index = x;
x -= index;
double s = *(interp+index)*(1-x)+*(interp+index+1)*x;
v = *((BYTE*)lut+(int)s);
*pv = v;
++pv;
}
}
}
} while (++l <= il);
return;
}
| [
"xf10036@7d216c18-c956-11de-a675-93be1f20d5c2"
] | [
[
[
1,
55
]
]
] |
1527eb5283f540cabac1092f243f49ba600440f3 | 1cf1543cd5460621f530f730a4f3969cfa74197c | /Buffer.h | 2acac8c31c95c41f7e916d2d34482cc9e6842807 | [] | no_license | derpepe/sysprog | 042048d0c8f30fb26f0fb79a024530f67a852ca9 | 2fa6fb3b7c7f53b3fa8ff6aeb74d8d3e3331ba61 | refs/heads/master | 2021-01-18T14:01:45.742680 | 2010-02-23T22:23:25 | 2010-02-23T22:23:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 403 | h | #pragma once
#include <iostream>
#include <iomanip> // for std::setw
#include <fstream>
#include "Token.h"
class Buffer
{
public:
Buffer(std::string inputFile, std::string outputFile);
~Buffer();
char getChar();
void ungetChar();
bool endoffile;
void writeTokenToFile(Token *myToken);
private:
std::filebuf *myInputBuffer;
std::ifstream myInputFile;
}; | [
"[email protected]"
] | [
[
[
1,
24
]
]
] |
822175eb68f0510c0d80a101aac20385219b160c | 8bb0a1d6c74f3a17d90c64d9ee40ae5153d15acb | / cs191-nds-project/splash_screen/CS191_Project/source/main.cpp | 2d15e88713efdb3324b2b9897ab004c1e66f7ad9 | [] | no_license | btuduri/cs191-nds-project | 9b12382316c0a59d4e48acd7f40ed55c5c4cde41 | 146b2218cc53f960a034d053238a4cf111726279 | refs/heads/master | 2020-03-30T19:13:10.122474 | 2008-05-19T02:26:19 | 2008-05-19T02:26:19 | 32,271,764 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 158 | cpp |
//#include "ProjectLib.h"
#include "CApp.h"
//#include "Extern.h"
//#include "Error.h"
int main(void) {
CApp app;
app.run();
return 0;
}
| [
"kingofcode@67d8362a-e844-0410-8493-f333cf7aaa27"
] | [
[
[
1,
13
]
]
] |
7c60ae0f6eaa3383de5966a127fe4848a903b6eb | 35c06332e5cbdf18538ecf22dc2de43910508e42 | /smartalbum/Relight.h | b4802673f999825a72256bf37a3367bcaa1071a2 | [] | no_license | Dandelion0124/smartalbum | dd24400359c5302b1489caf603efb3cb9803c993 | dbeca19ecbf302c1d03d7ad39c1c3045c4bfd69a | refs/heads/master | 2021-01-11T05:52:58.285637 | 2009-01-05T05:59:45 | 2009-01-05T05:59:45 | 49,498,431 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 233 | h | #pragma once
class CBmp;
class CRelight
{
public:
CRelight(void);
public:
~CRelight(void);
private:
void exposoure();
void sub_histogram(int sub_width, int sub_length);
void patch_analysis_relight(CBmp* pBmp);
};
| [
"wanglpqpq@d3b2af04-d0e3-11dd-bfda-f1b6ccb9c726"
] | [
[
[
1,
14
]
]
] |
03e6cc25a377494a6392f612a3e33a1778a3e749 | c0bd82eb640d8594f2d2b76262566288676b8395 | /src/shared/Config/Config.cpp | f23aea6b43e29b463ba665522e1aeb14fac6c0e5 | [
"FSFUL"
] | permissive | vata/solution | 4c6551b9253d8f23ad5e72f4a96fc80e55e583c9 | 774fca057d12a906128f9231831ae2e10a947da6 | refs/heads/master | 2021-01-10T02:08:50.032837 | 2007-11-13T22:01:17 | 2007-11-13T22:01:17 | 45,352,930 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,618 | cpp | // (c) Abyss Group
#include "ConfigEnv.h"
ConfigMgr Config;
ConfigFile::ConfigFile() : mConf(0)
{
}
ConfigFile::~ConfigFile()
{
if (mConf)
delete mConf;
}
bool ConfigFile::SetSource(const char *file, bool ignorecase)
{
mConf = new DOTCONFDocument(ignorecase ?
DOTCONFDocument::CASEINSENSETIVE :
DOTCONFDocument::CASESENSETIVE);
if (mConf->setContent(file) == -1)
{
delete mConf;
mConf = 0;
return false;
}
return true;
}
bool ConfigFile::GetString(const char* name, std::string *value)
{
if(!mConf)
return false;
DOTCONFDocumentNode *node = (DOTCONFDocumentNode *)mConf->findNode(name);
if(!node || !node->getValue())
return false;
*value = node->getValue();
return true;
}
std::string ConfigFile::GetStringDefault(const char* name, const char* def)
{
if(!mConf)
return std::string(def);
DOTCONFDocumentNode *node = (DOTCONFDocumentNode *)mConf->findNode(name);
if(!node || !node->getValue())
return std::string(def);
return std::string(node->getValue());
}
bool ConfigFile::GetBool(const char* name, bool *value)
{
if(!mConf)
return false;
DOTCONFDocumentNode *node = (DOTCONFDocumentNode *)mConf->findNode(name);
if(!node || !node->getValue())
return false;
const char* str = node->getValue();
if(strcmp(str, "true") == 0 || strcmp(str, "TRUE") == 0 ||
strcmp(str, "yes") == 0 || strcmp(str, "YES") == 0 ||
strcmp(str, "1") == 0)
{
*value = true;
}
else
*value = false;
return true;
}
bool ConfigFile::GetBoolDefault(const char* name, const bool def)
{
bool val;
return GetBool(name, &val) ? val : def;
}
bool ConfigFile::GetInt(const char* name, int *value)
{
if(!mConf)
return false;
DOTCONFDocumentNode *node = (DOTCONFDocumentNode *)mConf->findNode(name);
if(!node || !node->getValue())
return false;
*value = atoi(node->getValue());
return true;
}
bool ConfigFile::GetFloat(const char* name, float *value)
{
if(!mConf)
return false;
DOTCONFDocumentNode *node = (DOTCONFDocumentNode *)mConf->findNode(name);
if(!node || !node->getValue())
return false;
*value = atof(node->getValue());
return true;
}
int ConfigFile::GetIntDefault(const char* name, const int def)
{
int val;
return GetInt(name, &val) ? val : def;
}
float ConfigFile::GetFloatDefault(const char* name, const float def)
{
float val;
return (GetFloat(name, &val) ? val : def);
}
int ConfigFile::GetIntVA(int def, const char* name, ...)
{
va_list ap;
va_start(ap, name);
char str[150];
vsprintf(str, name, ap);
va_end(ap);
int val;
return GetInt(str, &val) ? val : def;
}
float ConfigFile::GetFloatVA(float def, const char* name, ...)
{
va_list ap;
va_start(ap, name);
char str[150];
vsprintf(str, name, ap);
va_end(ap);
float val;
return GetFloat(str, &val) ? val : def;
}
std::string ConfigFile::GetStringVA(const char* def, const char * name, ...)
{
va_list ap;
va_start(ap, name);
char str[150];
vsprintf(str, name, ap);
va_end(ap);
if(!mConf)
return std::string(def);
DOTCONFDocumentNode *node = (DOTCONFDocumentNode *)mConf->findNode(str);
if(!node || !node->getValue())
return std::string(def);
return std::string(node->getValue());
}
| [
"[email protected]"
] | [
[
[
1,
173
]
]
] |
eea75d64fef0b97ba32f04d1b621282a2b51860a | 30e4267e1a7fe172118bf26252aa2eb92b97a460 | /code/pkg_Core/Interface/Utility/Ix_StringConvert.h | a29ba23eea5bb5676f1cf4186d300b0090b32727 | [
"Apache-2.0"
] | permissive | thinkhy/x3c_extension | f299103002715365160c274314f02171ca9d9d97 | 8a31deb466df5d487561db0fbacb753a0873a19c | refs/heads/master | 2020-04-22T22:02:44.934037 | 2011-01-07T06:20:28 | 2011-01-07T06:20:28 | 1,234,211 | 2 | 0 | null | null | null | null | GB18030 | C++ | false | false | 4,696 | h | // Copyright 2008-2011 Zhang Yun Gui, [email protected]
// https://sourceforge.net/projects/x3c/
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*! \file Ix_StringConvert.h
* \brief ๅฎไนๆๆฌ่ฝฌๆขๅฎ็จๆไฝ็ๆฅๅฃ Ix_StringConvert
* \author Zhang Yun Gui, C++ Plugin Framework
* \date 2010.12.28
*/
#ifndef X3_UTIL_ISTRINGCONVERT_H_
#define X3_UTIL_ISTRINGCONVERT_H_
#include <ClsID_TextUtil.h>
//! ๆๆฌ่ฝฌๆขๅฎ็จๆไฝ็ๆฅๅฃ
/*!
\interface Ix_StringConvert
\ingroup _GROUP_UTILITY_
\see CLSID_TextUtil, StringConvert(), ConvStr.h
*/
interface Ix_StringConvert
{
//! ๅปๆๆๅญไธค็ซฏ็็ฉบ็ฝๅญ็ฌฆ๏ผๅ่ง็ฉบๆ ผใๅ
จ่ง็ฉบๆ ผใๆข่ก็ฌฆ๏ผ
/*!
\param[in,out] text ๅพ
่ฝฌๆข็ๅญ็ฌฆไธฒ
\param[in] targets ่ฆๅปๆๅญ็ฌฆ็ๅญ็ฌฆ้ๅ๏ผไธบNULLๅๅไธบ้ป่ฎค็็ฉบ็ฝๅญ็ฌฆ
\return ๆฏๅฆๆนๅไบๆๆฌ
*/
virtual bool TrimSpace(std::wstring& text, LPCWSTR targets = NULL) = 0;
//! ๅปๆๆๅญๅผๅคด็็ฉบ็ฝๅญ็ฌฆ๏ผๅ่ง็ฉบๆ ผใๅ
จ่ง็ฉบๆ ผใๆข่ก็ฌฆ๏ผ
/*!
\param[in,out] text ๅพ
่ฝฌๆข็ๅญ็ฌฆไธฒ
\param[in] targets ่ฆๅปๆๅญ็ฌฆ็ๅญ็ฌฆ้ๅ๏ผไธบNULLๅๅไธบ้ป่ฎค็็ฉบ็ฝๅญ็ฌฆ
\return ๆฏๅฆๆนๅไบๆๆฌ
*/
virtual bool TrimLeft(std::wstring& text, LPCWSTR targets = NULL) = 0;
//! ๅปๆๆๅญๆซๅฐพ็็ฉบ็ฝๅญ็ฌฆ๏ผๅ่ง็ฉบๆ ผใๅ
จ่ง็ฉบๆ ผใๆข่ก็ฌฆ๏ผ
/*!
\param[in,out] text ๅพ
่ฝฌๆข็ๅญ็ฌฆไธฒ
\param[in] targets ่ฆๅปๆๅญ็ฌฆ็ๅญ็ฌฆ้ๅ๏ผไธบNULLๅๅไธบ้ป่ฎค็็ฉบ็ฝๅญ็ฌฆ
\return ๆฏๅฆๆนๅไบๆๆฌ
*/
virtual bool TrimRight(std::wstring& text, LPCWSTR targets = NULL) = 0;
//! ๅปๆ้ๆณๅญ็ฌฆ
/*! ๅปๆASCII็ ๅฐไบ0x20็ๅญ็ฌฆ๏ผๅถ่กจ็ฌฆใๆข่ก็ฌฆๅๅ่ฝฆ็ฌฆ้คๅค๏ผ
\param[in,out] text ๅพ
ๆฃๆต่ฝฌๆข็ๅญ็ฌฆไธฒ
\param[in] targets ่ฆๅปๆๅญ็ฌฆ็ๅญ็ฌฆ้ๅ๏ผไธบNULLๅๅไธบๅฐไบ0x20็ๅญ็ฌฆ
\return ๆฏๅฆๆนๅไบๆๆฌ
*/
virtual bool RemoveInvalidChars(std::wstring& text, LPCWSTR targets = NULL) = 0;
//! ๆฟๆขๆๆฌ๏ผๅฐๆพๅฐ็ๆๆๅญไธฒๆฟๆขไธบๆฐ็ๅ
ๅฎน
/*!
\param[in,out] text ๅพ
ๆฟๆข็ๅญ็ฌฆไธฒ
\param[in] match ๅน้
ๅ
ๅฎน
\param[in] newtext ๅฏนๅน้
ๅฐ็ๅ
ๅฎนๆขไธบ่ฏฅ้กนๅ
ๅฎน
\return ๆฏๅฆๆนๅไบๆๆฌ
*/
virtual bool ReplaceAll(std::wstring& text,
const std::wstring& match,
const std::wstring& newtext) = 0;
//! ๅฐไธไธชๆๆฌไธญ็็นๅฎๅญ็ฌฆๆฟๆขไธบๅฏนๅบ็ๅ
ถไปๅญ็ฌฆ
/*! ๅจtextไธญๆฅๆพmatchไธญ็ไปปไฝๅญ็ฌฆ๏ผๅฏนๆพๅฐ็ๅญ็ฌฆๆฟๆขไธบcharsไธญๅฏนๅบๅบๅท็ๅญ็ฌฆ
\param[in,out] text ๅพ
ๆฟๆข็ๅญ็ฌฆไธฒ
\param[in] match ๅน้
ๅ
ๅฎน๏ผๅช่ฆๅๅ
ถไธญไปปไฝไธไธชๅญ็ฌฆ็ธๅๅฐฑ็ฎๅน้
ๆๅ
\param[in] chars ่ฆๆฟๆขๆ็ๆฐๅญ็ฌฆ็้ๅ๏ผๅญ็ฌฆๆฐๅฟ
้กปๅmatch็ธๅ
\return ๆฏๅฆๆนๅไบๆๆฌ
*/
virtual bool ReplaceChar(std::wstring& text,
const std::wstring& match,
const std::wstring& chars) = 0;
//! ๅฐๅ
จ่งๅญ็ฌฆ่ฝฌๆขไธบๅ่งๅญ็ฌฆ
/*!
\param[in,out] text ๅพ
่ฝฌๆข็ๅญ็ฌฆไธฒ
\param[in] punct ๆฏๅฆ่ฟๅๆ ็น็ฌฆๅทไนไธ่ตท่ฝฌๆข
\return ๆฏๅฆๆนๅไบๆๆฌ
*/
virtual bool ToDBC(std::wstring& text, bool punct = false) = 0;
//! UNICODEไธฒ่ฝฌๆขไธบANSIไธฒ
/*!
\param text ่ฆ่ฝฌๆข็ๅ
ๅฎน๏ผไธบUNICODEไธฒ๏ผๅณUTF16็ผ็
\param codepage ่ฆ่ฟๅๅช็ง็ผ็ ็ANSI็ผ็ ไธฒ๏ผ
ไพๅฆ CP_UTF8 ่กจ็คบUTF-8ๆ ผๅผ็ผ็ ๏ผ้ป่ฎคไธบCP_ACP
\return ANSI็ผ็ ไธฒ
*/
virtual std::string ToAnsi(const std::wstring& text, UINT codepage = CP_ACP) = 0;
//! ANSIไธฒ่ฝฌๆขไธบUNICODEไธฒ
/*!
\param text ่ฆ่ฝฌๆข็ๅ
ๅฎน๏ผไธบANSIไธฒ๏ผๅ
ถ็ผ็ ไธบcodepage
\param codepage textไธบๅช็ง็ผ็ ๏ผไพๅฆ CP_UTF8 ่กจ็คบUTF-8ๆ ผๅผ็ผ็ ๏ผ้ป่ฎคไธบCP_ACP
\return UNICODEไธฒ๏ผๅณUTF16็ผ็
*/
virtual std::wstring ToUnicode(const std::string& text, UINT codepage = CP_ACP) = 0;
};
//! ๅพๅฐๆๆฌ่ฝฌๆขๆไฝๅฏน่ฑก
/*!
\ingroup _GROUP_UTILITY_
*/
inline Cx_Interface<Ix_StringConvert> StringConvert()
{
Cx_Interface<Ix_StringConvert> pIFUtility(CLSID_TextUtil);
ASSERT(pIFUtility.IsNotNull());
return pIFUtility;
}
#endif // X3_UTIL_ISTRINGCONVERT_H_
| [
"rhcad1@71899303-b18e-48b3-b26e-8aaddbe541a3"
] | [
[
[
1,
125
]
]
] |
b543f6ed9c8a72b9a599e0f6a1f58aee76ff1d0e | 9aebe48109c7058adf08684b77fb3f193a4c6686 | /test/srv/pers-client.cpp | 9547f2a32c5bc31edde83e014d867fc15ab1b108 | [] | no_license | y4bt4/all-in-one | c18a159243dc2c656dadca227aaa346cc2da5d70 | c58041d438b9bf98334c6587e281f25f3849bbeb | refs/heads/master | 2021-01-20T12:00:30.010552 | 2011-04-20T10:07:58 | 2011-04-20T10:07:58 | 1,576,467 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,652 | cpp | #include <iostream>
#include <string>
#include "MyTime.h"
#include <stdlib.h>
#include <stdio.h>
int mk_connect(const char *host,int port);
int send_message(int create_socket,const char* message,int size_message);
int recv_message(int create_socket, char** response,int* size_response);
std::string request(const std::string req);
std::string login;
std::string endl("\n");
int live = 1;
int tosrv = -1;
int port;
int main ( int argc, char* argv[] ) {
if(argc < 4){
std::cerr << argv[0] << " <port> <login> <interval>" << endl;
return 1;
}
port = atoi(argv[1]);
login = argv[2];
int timeout = atoi(argv[3]);
std::string answer = request("login "+login);
std::cout << answer << std::endl;
int next = time(0) + timeout;
int count = 0;
char bn[64];
while(live){
int now = time(0);
if(now >= next){
sprintf(bn,"my counter %d",count);
answer = request(bn);
std::cout << answer << std::endl;
next = now + timeout;
count++;
}
answer = request("check");
std::cout << answer << std::endl;
}
printf("Real Exit\n");
return 0;
}
std::string request(const std::string req) {
std::string reply;
std::string msg = login + ": " + req + " / " + timestamp() + endl;
if(tosrv == -1){
tosrv = mk_connect("127.0.0.1",port);
}
if(tosrv == 0){
live = 0;
return "";
}
char* buf;
int size;
int r = send_message(tosrv,msg.data(),msg.size());
if(!r){
live = 0;
return "";
}
r = recv_message(tosrv, &buf, &size);
if(r>0){
reply.assign(buf,size);
}else if(!r){
printf("Exit\n");
live = 0;
}
free(buf);
return reply;
}
| [
"[email protected]"
] | [
[
[
1,
78
]
]
] |
4b9fd69e1ad6f8e1cbc35caa90eaba55ec3af176 | 7281e279195f3ccaa92f043ebf2a73d96717e179 | /stereocamera.cpp | 18d6ff37d2264a50210af2172075be53ed826aef | [] | no_license | pockman/opencvstereovision | 09335019cf0a6072d92e3b5c5c2aa8d4a2615c23 | 008ceb0661cf3840ff4d09a9bb5fb7d98fd94385 | refs/heads/master | 2021-01-10T06:15:38.111384 | 2010-06-03T21:43:33 | 2010-06-03T21:43:33 | 44,314,552 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,581 | cpp | #include "stereocamera.h"
StereoCamera::StereoCamera()
{
for(int lr=0;lr<2;lr++){
captures[lr] = 0;
frames[lr] = 0;
framesGray[lr] = 0;
}
ready = false;
}
StereoCamera::~StereoCamera()
{
for(int lr=0;lr<2;lr++){
cvReleaseImage(&frames[lr]);
cvReleaseImage(&framesGray[lr]);
cvReleaseCapture(&captures[lr]);
}
}
int StereoCamera::setup(CvSize imageSize){
this->imageSize = imageSize;
captures[0] = cvCaptureFromCAM(CV_CAP_DSHOW + 0);
captures[1] = cvCaptureFromCAM(CV_CAP_DSHOW + 1);
if( captures[0] && captures[1]){
for(int i=0;i<2;i++){
cvSetCaptureProperty(captures[i] ,CV_CAP_PROP_FRAME_WIDTH,imageSize.width);
cvSetCaptureProperty(captures[i] ,CV_CAP_PROP_FRAME_HEIGHT,imageSize.height);
}
ready = true;
return RESULT_OK;
}else{
ready = false;
return RESULT_FAIL;
}
}
int StereoCamera::capture(){
frames[0] = cvQueryFrame(captures[0]);
frames[1] = cvQueryFrame(captures[1]);
return (captures[0] && captures[1]) ? RESULT_OK : RESULT_FAIL;
}
IplImage* StereoCamera::getFramesGray(int lr){
if(!frames[lr]) return 0;
if(frames[lr]->depth == 1){
framesGray[lr] = frames[lr];
return frames[lr];
}else{
if(0 == framesGray[lr]) framesGray[lr] = cvCreateImage(cvGetSize(frames[lr]),IPL_DEPTH_8U,1);
cvCvtColor(frames[lr],framesGray[lr],CV_BGR2GRAY);
return framesGray[lr];
}
}
| [
"sergiubaluta@87be4954-6699-11de-a84c-2f1c77ec4fbd"
] | [
[
[
1,
62
]
]
] |
a72d81df05ce5d88e06c08a6775ba63657d2e55d | dba70d101eb0e52373a825372e4413ed7600d84d | /RendererComplement/source/RenderTarget.cpp | 8c303a900f8df7aecf661a9d991a03d9074dee08 | [] | no_license | nustxujun/simplerenderer | 2aa269199f3bab5dc56069caa8162258e71f0f96 | 466a43a1e4f6e36e7d03722d0d5355395872ad86 | refs/heads/master | 2021-03-12T22:38:06.759909 | 2010-10-02T03:30:26 | 2010-10-02T03:30:26 | 32,198,944 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 873 | cpp | #include "RenderTarget.h"
namespace RCP
{
RenderTarget::RenderTarget(unsigned int width, unsigned int height, unsigned int colourDepth):
mWidth(width),mHeight(height),mColourDepth(colourDepth),MemoryBuffer(NULL,0,true)
{
mSize = width * height * colourDepth;
mPos = mData = new unsigned char[mSize];
mEnd = mData + mSize;
memset(mData,0,mSize);
setAutoFree(true);
}
RenderTarget::~RenderTarget()
{
}
unsigned int RenderTarget::getWidth()const
{
return mWidth;
}
unsigned int RenderTarget::getHeight()const
{
return mHeight;
}
unsigned int RenderTarget::getColourDepth()const
{
return mColourDepth;
}
void RenderTarget::swap(RenderTarget& rt)
{
MemoryBuffer::swap(rt);
std::swap(mWidth,rt.mWidth);
std::swap(mHeight,rt.mHeight);
std::swap(mColourDepth,rt.mColourDepth);
}
} | [
"[email protected]@c2606ca0-2ebb-fda8-717c-293879e69bc3"
] | [
[
[
1,
45
]
]
] |
ff486847dbe7ef37366f993de9697bb197518d97 | e8c9bfda96c507c814b3378a571b56de914eedd4 | /engineTest/SubjectAgent.cpp | 7dd4da56e1effb3ee5ab6ac8da70c6fc427dc5ce | [] | no_license | VirtuosoChris/quakethecan | e2826f832b1a32c9d52fb7f6cf2d972717c4275d | 3159a75117335f8e8296f699edcfe87f20d97720 | refs/heads/master | 2021-01-18T09:20:44.959838 | 2009-04-20T13:32:36 | 2009-04-20T13:32:36 | 32,121,382 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,885 | cpp | #include "SubjectAgent.h"
#include "InputHandler.h"
#include <cmath>
using namespace irr;
using namespace irr::core;
//extern bool ENABLE_DEBUG_OUTPUT;
inline double degreesToRadians(double degrees){
return 2*3.14159*degrees/360;
}
//SubjectAgent::SubjectAgent(irr::scene::IAnimatedMeshSceneNode* a, irr::core::vector3df p):Agent(a,p){
//moving = false;
//}
SubjectAgent::SubjectAgent (Model m, irr::core::vector3df p, irr::scene::ISceneManager* mgr):Agent(m,p,mgr){
moving = false;
//feelerParticles = new std::vector<scene::IBillboardSceneNode*>(s1d->getNumFeelers());
//if(s1d->getNumFeelers()!=3)exit(1);
for(int i = 0; i < s1d->getNumFeelers();i++){
//
irr::scene::IBillboardTextSceneNode* a = mgr->addBillboardTextSceneNode(0,L"INF");
feelerParticles.push_back(a);
//mgr->addBillboardTextSceneNode(0,L"ZOMG");
//mgr->addBillboardSceneNode()
//a->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
// feelerParticles[i]->setMaterialTexture(0,driver->getTexture("../media/particle.bmp"));
//a->setMaterialFlag(video::EMF_LIGHTING, false);
a->setMaterialFlag(video::EMF_ZBUFFER,false);
a->setSize(core::dimension2d<f32>(20.0f, 20.0f));
a->setVisible(false);
}
for(unsigned int i = 0; i < feelerParticles.size();i++){
//(*feelerParticles).at(i)->setVisible(false);
if(feelerParticles.at(i))
feelerParticles.at(i)->setVisible(false);
}
}
void SubjectAgent::update(irr::ITimer* timer){
Agent::update(timer);
static const irr::f32 SPEED = .3f;
static const float ROTATION_RATE = .10f;
int TIMEELAPSED =0; //ADJFHKJHFKJHFKJHF
InputHandler* ih= InputHandler::getInstance();
if(ih==NULL)return;
if(!mynodep)return;
if(timer==NULL)return;
irr::u32 ctime= 0;
TIMEELAPSED = (ctime = timer->getTime()) - LASTUPDATE;
LASTUPDATE = ctime;
irr::core::vector3df nodePos = mynodep->getPosition();
if(ih->isWKeyPressed()){
//MOVE_FORWARD
//orientation = mynodep->getRotation().Y;
//irr::core::vector3df
displacement = irr::core::vector3df((irr::f32)cos(degreesToRadians(orientation)), 0.0f, (irr::f32)sin(degreesToRadians(orientation)))* SPEED * (irr::f32)TIMEELAPSED;
//displacement.Z*=-1;
nodePos+=displacement;
mynodep->setPosition(nodePos);
mynodep->setAnimationSpeed(40);
if(!moving){moving=true;
mynodep->setMD2Animation(scene::EMAT_RUN);
}
position = mynodep->getPosition();
return;
}
if(ih->isAKeyPressed()){
mynodep->setAnimationSpeed(30);
//ROTATE_LEFT
orientation += ROTATION_RATE * TIMEELAPSED;
mynodep->setRotation(irr::core::vector3df(0.0f,(irr::f32)fabs(360.0f-orientation),0.0f));
//mynodep->setRotation(irr::core::vector3df(0.0f,1,0.0f));
if(!moving){moving=true;
mynodep->setMD2Animation(scene::EMAT_RUN);
}
//MOVE_LEFT
//nodePos += irr::core::vector3df((irr::f32)cos(orientation - 90.0f), 0.0f, (irr::f32)sin(orientation - 90.0f))* SPEED * (irr::f32)TIMEELAPSED;
//mynodep->setPosition(nodePos);
position = mynodep->getPosition();
return;
}
if(ih->isSKeyPressed()){
//MOVE_BACK
mynodep->setAnimationSpeed(25);
//orientation = mynodep->getRotation().Y;
//irr::core::vector3df
displacement = irr::core::vector3df((irr::f32)cos(degreesToRadians(orientation)), 0.0f, (irr::f32)sin(degreesToRadians(orientation)))* SPEED * (irr::f32)TIMEELAPSED;
//displacement.Z*=-1;
nodePos -= displacement/4;//irr::core::vector3df((irr::f32)-cos(orientation), 0.0f, (irr::f32)-sin(orientation))* SPEED * (irr::f32)TIMEELAPSED;
mynodep->setPosition(nodePos);
if(!moving){moving=true;
mynodep->setMD2Animation(scene::EMAT_RUN);
}
position = mynodep->getPosition();
return;
}
if(ih->isDKeyPressed()){
//ROTATE_RIGHT
orientation -= ROTATION_RATE * TIMEELAPSED;
mynodep->setRotation(irr::core::vector3df(0.0f,(irr::f32)fabs(360.0f-orientation),0.0f));
//STRAFE_RIGHT
//nodePos += irr::core::vector3df((irr::f32)cos(orientation + 90.0f), 0.0f, (irr::f32)sin(orientation + 90.0f))* SPEED * (irr::f32)TIMEELAPSED;
//mynodep->setPosition(nodePos);
mynodep->setAnimationSpeed(30);
if(!moving){moving=true;
mynodep->setMD2Animation(scene::EMAT_RUN);
}
position = mynodep->getPosition();
return;
}
if(moving){moving = false;
// if(!moving){moving=true;
mynodep->setMD2Animation(scene::EMAT_STAND);
// }
}
position = mynodep->getPosition();
}
void SubjectAgent::updateWallSensor(){
core::line3d<f32> line;
core::vector3df intersection;
core::triangle3df triangle;
core::vector3df orientVector;
orientVector = core::vector3df((float)cos(degreesToRadians(orientation)),0.0f,(float)sin(degreesToRadians(orientation)));
line.start = mynodep->getPosition();
line.end = line.start + orientVector * s1d->maxRange;
// billboard->setVisible(true);
//std::vector<Agent*> a;
//a = *agentList;
//(*agentList)[0] = NULL;
// a[0] = NULL;
double baseAngle = -.5f*s1d->getAngle();
baseAngle +=orientation;
double increment = s1d->getAngle() / (double)s1d->getNumFeelers();
// printf("ori%f\n", orientation);
//// printf("inc%f\n", increment);
// printf("getA%f\n", s1d->getAngle());
// printf("ba%f\n", baseAngle);
// printf("%f\n", 0.0f-90.0f/2.0);
//printf("%d\n",s1d->getNumFeelers());
for(int i = 0; i < s1d->getNumFeelers(); i++){
double angle = i * increment + baseAngle;
//printf("%f\n", angle);
core::vector3df feelerVector = core::vector3df((float)cos(degreesToRadians(angle)), 0.0f, (float)sin(degreesToRadians(angle)));
float t1 = 0.0f;
line.start = mynodep->getPosition();
line.end = line.start + feelerVector * s1d->maxRange;
//printf("s1dmr%d\n", s1d->maxRange();
if(smgr->getSceneCollisionManager()->getCollisionPoint(line, selector,intersection, triangle)){
if(feelerParticles.at(i)){
feelerParticles.at(i)->setPosition(intersection);
float t1 = (intersection.X - mynodep->getPosition().X);
t1 *= t1;
float t2 = (intersection.Z - mynodep->getPosition().Z);
t2*=t2;
s1d->feelerDistances[i] = sqrt( t2+ t1);
// printf("%f\n", s1d->feelerDistances[i]);
if(true){
feelerParticles.at(i)->setVisible(true);
feelerParticles.at(i)->setText(stringw(
(int)s1d->feelerDistances[i]
).c_str());
}else{
feelerParticles.at(i)->setVisible(false);
}
}
}
else{
//if(feelerParticles.at(i))feelerParticles.at(i)->setVisible(false);
s1d->feelerDistances[i] =s1d->maxRange;
}
}
// printf("//////////////////\n");
} | [
"cthomas.mail@f96ad80a-2d29-11de-ba44-d58fe8a9ce33"
] | [
[
[
1,
273
]
]
] |
b65afda968b23fae5b5d094cc4525a8eab6b3008 | b822313f0e48cf146b4ebc6e4548b9ad9da9a78e | /KylinSdk/Standard/stdpch.cpp | a2d29488c51ea21b4e2faa61fa58ca8d1a6e3d8a | [] | 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 | GB18030 | C++ | false | false | 268 | cpp | // stdafx.cpp : ๅชๅ
ๆฌๆ ๅๅ
ๅซๆไปถ็ๆบๆไปถ
// Standard.pch ๅฐไฝไธบ้ข็ผ่ฏๅคด
// stdafx.obj ๅฐๅ
ๅซ้ข็ผ่ฏ็ฑปๅไฟกๆฏ
#include "stdpch.h"
// TODO: ๅจ STDAFX.H ไธญ
// ๅผ็จไปปไฝๆ้็้ๅ ๅคดๆไปถ๏ผ่ไธๆฏๅจๆญคๆไปถไธญๅผ็จ
| [
"[email protected]"
] | [
[
[
1,
8
]
]
] |
b017172fef5c7e9da99d99734fcfd7f79ed8a190 | 11af1673bab82ca2329ef8b596d1f3d2f8b82481 | /source/game/WP_Bowcaster.cpp | 1a78cd0483e257dbae20898233a25ee64e439244 | [] | no_license | legacyrp/legacyojp | 8b33ecf24fd973bee5e7adbd369748cfdd891202 | d918151e917ea06e8698f423bbe2cf6ab9d7f180 | refs/heads/master | 2021-01-10T20:09:55.748893 | 2011-04-18T21:07:13 | 2011-04-18T21:07:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,486 | cpp | #include "g_weapons.h"
const int BOWCASTER_DAMAGE = 200; //80
const int BOWCASTER_VELOCITY = 2000; //2800
const int BOWCASTER_SPLASH_DAMAGE = 0; //0
const int BOWCASTER_SPLASH_RADIUS = 0; //0
const int BOWCASTER_SIZE = 2; //2
const float BOWCASTER_ALT_SPREAD = 5.0f; //5.0f
const float BOWCASTER_VEL_RANGE = 0.3f; //0.3f
const float BOWCASTER_CHARGE_UNIT = 200.0f; //200.0f
void WP_BowcasterAltFire( gentity_t *ent )
{
int damage = BOWCASTER_DAMAGE;
gentity_t *missile = CreateMissile( muzzle, forward, BOWCASTER_VELOCITY, 10000, ent, qfalse);
missile->classname = "bowcaster_proj";
missile->s.weapon = WP_BOWCASTER;
VectorSet( missile->r.maxs, BOWCASTER_SIZE, BOWCASTER_SIZE, BOWCASTER_SIZE );
VectorScale( missile->r.maxs, -1, missile->r.mins );
missile->damage = damage;
missile->dflags = DAMAGE_DEATH_KNOCKBACK;
missile->methodOfDeath = MOD_BOWCASTER;
missile->clipmask = MASK_SHOT | CONTENTS_LIGHTSABER;
missile->damageDecreaseTime = level.time + 300;
}
void WP_BowcasterMainFire( gentity_t *ent )
{
int damage = BOWCASTER_DAMAGE, count=1,dp=0;
float vel;
vec3_t angs, dir;
gentity_t *missile;
int i=0;
dp = (level.time - ent->client->ps.weaponChargeTime) / BOWCASTER_CHARGE_UNIT;
if ( dp < 1 )
{
dp = 1;
}
else if ( dp > BRYAR_MAX_CHARGE )
{
dp = BRYAR_MAX_CHARGE;
}
// create a range of different velocities
vel = BOWCASTER_VELOCITY * ( crandom() * BOWCASTER_VEL_RANGE + 1.0f );
vectoangles( forward, angs );
// add some slop to the alt-fire direction
angs[PITCH] += crandom() * BOWCASTER_ALT_SPREAD * 0.2f;
angs[YAW] += ((i+0.5f) * BOWCASTER_ALT_SPREAD - count * 0.5f * BOWCASTER_ALT_SPREAD );
AngleVectors( angs, dir, NULL, NULL );
missile = CreateMissile( muzzle, dir, vel, 10000, ent, qtrue );
missile->classname = "bowcaster_alt_proj";
missile->s.weapon = WP_BOWCASTER;
VectorSet( missile->r.maxs, BOWCASTER_SIZE, BOWCASTER_SIZE, BOWCASTER_SIZE );
VectorScale( missile->r.maxs, -1, missile->r.mins );
missile->damage = damage;
missile->dflags = DAMAGE_DEATH_KNOCKBACK;
missile->methodOfDeath = MOD_BOWCASTER;
missile->clipmask = MASK_SHOT | CONTENTS_LIGHTSABER;
missile->s.generic1 = dp;
ent->client->ps.userInt2=dp;
// we don't want it to bounce
missile->bounceCount = 0;
missile->damageDecreaseTime = level.time + 300;
}
void WP_FireBowcaster( gentity_t *ent, qboolean altFire )
{
WP_BowcasterMainFire( ent );
}
| [
"[email protected]@5776d9f2-9662-11de-ad41-3fcdc5e0e42d"
] | [
[
[
1,
86
]
]
] |
9d3dfd6c70718a05b2ebd37cf2ac9dced780a780 | 77aa13a51685597585abf89b5ad30f9ef4011bde | /dep/src/boost/boost/config/compiler/visualc.hpp | 8df4198558a81b8fc32d9a18c19d1d511b03bd31 | [] | no_license | Zic/Xeon-MMORPG-Emulator | 2f195d04bfd0988a9165a52b7a3756c04b3f146c | 4473a22e6dd4ec3c9b867d60915841731869a050 | refs/heads/master | 2021-01-01T16:19:35.213330 | 2009-05-13T18:12:36 | 2009-05-14T03:10:17 | 200,849 | 8 | 10 | null | null | null | null | UTF-8 | C++ | false | false | 6,496 | hpp | // (C) Copyright John Maddock 2001 - 2003.
// (C) Copyright Darin Adler 2001 - 2002.
// (C) Copyright Peter Dimov 2001.
// (C) Copyright Aleksey Gurtovoy 2002.
// (C) Copyright David Abrahams 2002 - 2003.
// (C) Copyright Beman Dawes 2002 - 2003.
// 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)
// See http://www.boost.org for most recent version.
// Microsoft Visual C++ compiler setup:
#define BOOST_MSVC _MSC_VER
// turn off the warnings before we #include anything
#pragma warning( disable : 4503 ) // warning: decorated name length exceeded
#if _MSC_VER < 1300 // 1200 == VC++ 6.0, 1200-1202 == eVC++4
# pragma warning( disable : 4786 ) // ident trunc to '255' chars in debug info
# define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS
# define BOOST_NO_VOID_RETURNS
# define BOOST_NO_EXCEPTION_STD_NAMESPACE
// disable min/max macro defines on vc6:
//
#endif
#if (_MSC_VER <= 1300) // 1300 == VC++ 7.0
# if !defined(_MSC_EXTENSIONS) && !defined(BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS) // VC7 bug with /Za
# define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS
# endif
# define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS
# define BOOST_NO_INCLASS_MEMBER_INITIALIZATION
# define BOOST_NO_PRIVATE_IN_AGGREGATE
# define BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
# define BOOST_NO_INTEGRAL_INT64_T
# define BOOST_NO_DEDUCED_TYPENAME
# define BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE
// VC++ 6/7 has member templates but they have numerous problems including
// cases of silent failure, so for safety we define:
# define BOOST_NO_MEMBER_TEMPLATES
// For VC++ experts wishing to attempt workarounds, we define:
# define BOOST_MSVC6_MEMBER_TEMPLATES
# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS
# define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
# define BOOST_NO_CV_VOID_SPECIALIZATIONS
# define BOOST_NO_FUNCTION_TEMPLATE_ORDERING
# define BOOST_NO_USING_TEMPLATE
# define BOOST_NO_SWPRINTF
# define BOOST_NO_TEMPLATE_TEMPLATES
# define BOOST_NO_SFINAE
# define BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS
# define BOOST_NO_IS_ABSTRACT
# define BOOST_NO_FUNCTION_TYPE_SPECIALIZATIONS
// TODO: what version is meant here? Have there really been any fixes in cl 12.01 (as e.g. shipped with eVC4)?
# if (_MSC_VER > 1200)
# define BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS
# endif
#endif
#if _MSC_VER < 1400
// although a conforming signature for swprint exists in VC7.1
// it appears not to actually work:
# define BOOST_NO_SWPRINTF
#endif
#if defined(UNDER_CE)
// Windows CE does not have a conforming signature for swprintf
# define BOOST_NO_SWPRINTF
#endif
#if _MSC_VER <= 1400 // 1400 == VC++ 8.0
# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS
#endif
#if _MSC_VER <= 1500 // 1500 == VC++ 9.0
# define BOOST_NO_TWO_PHASE_NAME_LOOKUP
#endif
#if _MSC_VER == 1500 // 1500 == VC++ 9.0
// A bug in VC9:
# define BOOST_NO_ADL_BARRIER
#endif
#ifndef _NATIVE_WCHAR_T_DEFINED
# define BOOST_NO_INTRINSIC_WCHAR_T
#endif
#if defined(_WIN32_WCE) || defined(UNDER_CE)
# define BOOST_NO_THREADEX
# define BOOST_NO_GETSYSTEMTIMEASFILETIME
# define BOOST_NO_SWPRINTF
#endif
//
// check for exception handling support:
#ifndef _CPPUNWIND
# define BOOST_NO_EXCEPTIONS
#endif
//
// __int64 support:
//
#if (_MSC_VER >= 1200)
# define BOOST_HAS_MS_INT64
#endif
#if (_MSC_VER >= 1310) && defined(_MSC_EXTENSIONS)
# define BOOST_HAS_LONG_LONG
#endif
#if (_MSC_VER >= 1400) && !defined(_DEBUG)
# define BOOST_HAS_NRVO
#endif
//
// disable Win32 API's if compiler extentions are
// turned off:
//
#ifndef _MSC_EXTENSIONS
# define BOOST_DISABLE_WIN32
#endif
#ifndef _CPPRTTI
# define BOOST_NO_RTTI
#endif
//
// all versions support __declspec:
//
#define BOOST_HAS_DECLSPEC
//
// prefix and suffix headers:
//
#ifndef BOOST_ABI_PREFIX
# define BOOST_ABI_PREFIX "boost/config/abi/msvc_prefix.hpp"
#endif
#ifndef BOOST_ABI_SUFFIX
# define BOOST_ABI_SUFFIX "boost/config/abi/msvc_suffix.hpp"
#endif
// TODO:
// these things are mostly bogus. 1200 means version 12.0 of the compiler. The
// artificial versions assigned to them only refer to the versions of some IDE
// these compilers have been shipped with, and even that is not all of it. Some
// were shipped with freely downloadable SDKs, others as crosscompilers in eVC.
// IOW, you can't use these 'versions' in any sensible way. Sorry.
# if defined(UNDER_CE)
# if _MSC_VER < 1200
// Note: these are so far off, they are not really supported
# elif _MSC_VER < 1300 // eVC++ 4 comes with 1200-1202
# define BOOST_COMPILER_VERSION evc4.0
# elif _MSC_VER == 1400
# define BOOST_COMPILER_VERSION evc8
# else
# if defined(BOOST_ASSERT_CONFIG)
# error "Unknown EVC++ compiler version - please run the configure tests and report the results"
# else
# pragma message("Unknown EVC++ compiler version - please run the configure tests and report the results")
# endif
# endif
# else
# if _MSC_VER < 1200
// Note: these are so far off, they are not really supported
# define BOOST_COMPILER_VERSION 5.0
# elif _MSC_VER < 1300
# define BOOST_COMPILER_VERSION 6.0
# elif _MSC_VER == 1300
# define BOOST_COMPILER_VERSION 7.0
# elif _MSC_VER == 1310
# define BOOST_COMPILER_VERSION 7.1
# elif _MSC_VER == 1400
# define BOOST_COMPILER_VERSION 8.0
# elif _MSC_VER == 1500
# define BOOST_COMPILER_VERSION 9.0
# else
# define BOOST_COMPILER_VERSION _MSC_VER
# endif
# endif
#define BOOST_COMPILER "Microsoft Visual C++ version " BOOST_STRINGIZE(BOOST_COMPILER_VERSION)
//
// versions check:
// we don't support Visual C++ prior to version 6:
#if _MSC_VER < 1200
#error "Compiler not supported or configured - please reconfigure"
#endif
//
// last known and checked version is 1500 (VC9):
#if (_MSC_VER > 1500)
# if defined(BOOST_ASSERT_CONFIG)
# error "Unknown compiler version - please run the configure tests and report the results"
# else
# pragma message("Unknown compiler version - please run the configure tests and report the results")
# endif
#endif
| [
"pepsi1x1@a6a5f009-272a-4b40-a74d-5f9816a51f88"
] | [
[
[
1,
199
]
]
] |
997ad5f6e89ca02b5faea403548b81e305e60083 | f55665c5faa3d79d0d6fe91fcfeb8daa5adf84d0 | /Depend/Loki-0.1.6/include/loki/flex/simplestringstorage.h | d3c8fb8bcdddf81bdec9d6d26de45dae9b920ed3 | [] | no_license | lxinhcn/starworld | 79ed06ca49d4064307ae73156574932d6185dbab | 86eb0fb8bd268994454b0cfe6419ffef3fc0fc80 | refs/heads/master | 2021-01-10T07:43:51.858394 | 2010-09-15T02:38:48 | 2010-09-15T02:38:48 | 47,859,019 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 7,927 | h | ////////////////////////////////////////////////////////////////////////////////
// flex_string
// Copyright (c) 2001 by Andrei Alexandrescu
// Permission to use, copy, modify, distribute and sell this software for any
// purpose is hereby granted without fee, provided that the above copyright
// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
// The author makes no representations about the
// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef SIMPLE_STRING_STORAGE_INC_
#define SIMPLE_STRING_STORAGE_INC_
// $Id: simplestringstorage.h 1008 2009-03-13 12:07:15Z jfbastien $
/* This is the template for a storage policy
////////////////////////////////////////////////////////////////////////////////
template <typename E, class A = @>
class StoragePolicy
{
typedef E value_type;
typedef @ iterator;
typedef @ const_iterator;
typedef A allocator_type;
typedef @ size_type;
StoragePolicy(const StoragePolicy& s);
StoragePolicy(const A&);
StoragePolicy(const E* s, size_type len, const A&);
StoragePolicy(size_type len, E c, const A&);
~StoragePolicy();
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
size_type size() const;
size_type max_size() const;
size_type capacity() const;
void reserve(size_type res_arg);
template <class ForwardIterator>
void append(ForwardIterator b, ForwardIterator e);
void resize(size_type newSize, E fill);
void swap(StoragePolicy& rhs);
const E* c_str() const;
const E* data() const;
A get_allocator() const;
};
////////////////////////////////////////////////////////////////////////////////
*/
#include <memory>
#include <algorithm>
#include <functional>
#include <cassert>
#include <limits>
#include <stdexcept>
////////////////////////////////////////////////////////////////////////////////
// class template SimpleStringStorage
// Allocates memory with malloc
////////////////////////////////////////////////////////////////////////////////
template <typename E, class A = std::allocator<E> >
class SimpleStringStorage
{
// The "public" below exists because MSVC can't do template typedefs
public:
struct Data
{
Data() : pEnd_(buffer_), pEndOfMem_(buffer_) { buffer_[0] = E(0); }
E* pEnd_;
E* pEndOfMem_;
E buffer_[1];
};
static const Data emptyString_;
typedef typename A::size_type size_type;
private:
Data* pData_;
void Init(size_type size, size_type capacity)
{
assert(size <= capacity);
if (capacity == 0)
{
pData_ = const_cast<Data*>(&emptyString_);
}
else
{
// 11-17-2000: comment added:
// No need to allocate (capacity + 1) to
// accommodate the terminating 0, because Data already
// has one one character in there
pData_ = static_cast<Data*>(
malloc(sizeof(Data) + capacity * sizeof(E)));
if (!pData_) throw std::bad_alloc();
pData_->pEnd_ = pData_->buffer_ + size;
pData_->pEndOfMem_ = pData_->buffer_ + capacity;
}
}
private:
// Warning - this doesn't initialize pData_. Used in reserve()
SimpleStringStorage()
{ }
public:
typedef E value_type;
typedef E* iterator;
typedef const E* const_iterator;
typedef A allocator_type;
typedef typename A::reference reference;
SimpleStringStorage(const SimpleStringStorage& rhs)
{
const size_type sz = rhs.size();
Init(sz, sz);
if (sz) flex_string_details::pod_copy(rhs.begin(), rhs.end(), begin());
}
SimpleStringStorage(const SimpleStringStorage& s,
flex_string_details::Shallow)
: pData_(s.pData_)
{
}
SimpleStringStorage(const A&)
{ pData_ = const_cast<Data*>(&emptyString_); }
SimpleStringStorage(const E* s, size_type len, const A&)
{
Init(len, len);
flex_string_details::pod_copy(s, s + len, begin());
}
SimpleStringStorage(size_type len, E c, const A&)
{
Init(len, len);
flex_string_details::pod_fill(begin(), end(), c);
}
SimpleStringStorage& operator=(const SimpleStringStorage& rhs)
{
const size_type sz = rhs.size();
reserve(sz);
flex_string_details::pod_copy(&*rhs.begin(), &*rhs.end(), begin());
pData_->pEnd_ = &*begin() + sz;
return *this;
}
~SimpleStringStorage()
{
assert(begin() <= end());
if (pData_ != &emptyString_) free(pData_);
}
iterator begin()
{ return pData_->buffer_; }
const_iterator begin() const
{ return pData_->buffer_; }
iterator end()
{ return pData_->pEnd_; }
const_iterator end() const
{ return pData_->pEnd_; }
size_type size() const
{ return pData_->pEnd_ - pData_->buffer_; }
size_type max_size() const
{ return size_t(-1) / sizeof(E) - sizeof(Data) - 1; }
size_type capacity() const
{ return pData_->pEndOfMem_ - pData_->buffer_; }
void reserve(size_type res_arg)
{
if (res_arg <= capacity())
{
// @@@ insert shrinkage here if you wish
return;
}
if (pData_ == &emptyString_)
{
Init(0, res_arg);
}
else
{
const size_type sz = size();
void* p = realloc(pData_,
sizeof(Data) + res_arg * sizeof(E));
if (!p) throw std::bad_alloc();
if (p != pData_)
{
pData_ = static_cast<Data*>(p);
pData_->pEnd_ = pData_->buffer_ + sz;
}
pData_->pEndOfMem_ = pData_->buffer_ + res_arg;
}
}
template <class InputIterator>
void append(InputIterator b, InputIterator e)
{
const size_type
sz = std::distance(b, e),
neededCapacity = size() + sz;
if (capacity() < neededCapacity)
{
static std::less_equal<const E*> le;
(void) le;
assert(!(le(begin(), &*b) && le(&*b, end()))); // no aliasing
reserve(neededCapacity);
}
std::copy(b, e, end());
pData_->pEnd_ += sz;
}
void resize(size_type newSize, E fill)
{
const int delta = int(newSize - size());
if (delta == 0) return;
if (delta > 0)
{
if (newSize > capacity())
{
reserve(newSize);
}
E* e = &*end();
flex_string_details::pod_fill(e, e + delta, fill);
}
pData_->pEnd_ = pData_->buffer_ + newSize;
}
void swap(SimpleStringStorage& rhs)
{
std::swap(pData_, rhs.pData_);
}
const E* c_str() const
{
if (pData_ != &emptyString_) *pData_->pEnd_ = E();
return pData_->buffer_;
}
const E* data() const
{ return pData_->buffer_; }
A get_allocator() const
{ return A(); }
};
template <typename E, class A>
const typename SimpleStringStorage<E, A>::Data
SimpleStringStorage<E, A>::emptyString_;
//{
// const_cast<E*>(SimpleStringStorage<E, A>::emptyString_.buffer_),
// const_cast<E*>(SimpleStringStorage<E, A>::emptyString_.buffer_),
// { E() }
//};
#endif // SIMPLE_STRING_STORAGE_INC_
| [
"albertclass@a94d7126-06ea-11de-b17c-0f1ef23b492c"
] | [
[
[
1,
285
]
]
] |
934b6b9084c853e6eae5231f879c02af2769b1ed | 6f8721dafe2b841f4eb27237deead56ba6e7a55b | /src/WorldOfAnguis/Units/Explosion/Explosion.h | 9a23c5a9982b90c9844c8f49a2d182caa9a4e630 | [] | no_license | worldofanguis/WoA | dea2abf6db52017a181b12e9c0f9989af61cfa2a | 161c7bb4edcee8f941f31b8248a41047d89e264b | refs/heads/master | 2021-01-19T10:25:57.360015 | 2010-02-19T16:05:40 | 2010-02-19T16:05:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 767 | h | /*
* ___ ___ __
* \ \ / / / \
* \ \ / / / \
* \ \ /\ / /___ / /\ \
* \ \/ \/ /| | / ____ \
* \___/\___/ |___|/__/ \__\
* World Of Anguis
*
*/
#pragma once
#include "Common.h"
#include "Units/Unit.h"
#include "Units/Player/Player.h"
class Explosion : public Unit
{
public:
Explosion(Player* Creator,int X,int Y,int R,int Damage,bool Visible = true);
~Explosion();
bool IsVisible() {return Visible;}
char* GetExplosionMap();
int GetRadius() {return radius;}
int GetDamage() {return Damage;}
Player* GetCreator() {return Creator;}
private:
int radius;
int Damage;
char* Map;
bool Visible;
Player* Creator;
}; | [
"[email protected]",
"[email protected]"
] | [
[
[
1,
15
],
[
17,
20
],
[
22,
23
],
[
25,
26
],
[
29,
33
],
[
36,
36
]
],
[
[
16,
16
],
[
21,
21
],
[
24,
24
],
[
27,
28
],
[
34,
35
]
]
] |
6d788720b65caf1956510f916a2d2019fafd1178 | a6d79692cbc9c2b4952d5844d3cf5ae4998ed7d4 | /Other/Source/ShellSwitcher/Splash.h | 5501ce5e526e0f0d1e717eaa690dc1149176256d | [] | no_license | crazy2be/litestepportable | 00735f7a3d0688d6379b4d63e25697d793914457 | 7e0948ee5ac14dc70e4dd5ca70354642176f6470 | refs/heads/master | 2020-04-26T01:17:19.326333 | 2009-03-29T22:12:15 | 2009-03-29T22:12:15 | 173,199,242 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 631 | h | // SPLASH.h: interface for the SPLASH class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_SPLASH_H__41182F11_BB6F_11D6_B0F5_00B0D01AD687__INCLUDED_)
#define AFX_SPLASH_H__41182F11_BB6F_11D6_B0F5_00B0D01AD687__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class SPLASH
{
public:
void Hide();
void Show();
void Init();
BOOL SHOWING;
SPLASH();
virtual ~SPLASH();
private:
UINT TimerID;
HWND hParentWindow;
HWND hSplashWnd;
};
#endif // !defined(AFX_SPLASH_H__41182F11_BB6F_11D6_B0F5_00B0D01AD687__INCLUDED_)
| [
"[email protected]"
] | [
[
[
1,
31
]
]
] |
9073e168750fac2107b796302d1c7d430c47841b | c7120eeec717341240624c7b8a731553494ef439 | /src/cplusplus/freezone-samp/src/core/utility/integer_expression_calc.cpp | 0c55ded25dab9ed26eb70cee2837b7a5b68e50df | [] | no_license | neverm1ndo/gta-paradise-sa | d564c1ed661090336621af1dfd04879a9c7db62d | 730a89eaa6e8e4afc3395744227527748048c46d | refs/heads/master | 2020-04-27T22:00:22.221323 | 2010-09-04T19:02:28 | 2010-09-04T19:02:28 | 174,719,907 | 1 | 0 | null | 2019-03-09T16:44:43 | 2019-03-09T16:44:43 | null | WINDOWS-1251 | C++ | false | false | 12,175 | cpp | #include "config.hpp"
#include "integer_expression_calc.hpp"
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_container.hpp>
#include <boost/spirit/include/phoenix_statement.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <iostream>
#include <string>
#include <vector>
using boost::phoenix::function;
using boost::phoenix::ref;
using boost::phoenix::size;
using boost::spirit::qi::unused_type;
namespace qi = boost::spirit::qi;
namespace ascii = boost::spirit::ascii;
# pragma warning(disable: 4800) // forcing value to bool 'true' or 'false' (performance warning)
///////////////////////////////////////////////////////////////////////////////
// The Virtual Machine
///////////////////////////////////////////////////////////////////////////////
enum byte_code {
op_neg, // negate the top stack entry
op_add, // add top two stack entries
op_sub, // subtract top two stack entries
op_mul, // multiply top two stack entries
op_div, // divide top two stack entries
op_rem, // remainde top two stack entries (ะพััะฐัะพะบ ะพั ะดะตะปะตะฝะธั)
op_not, // boolean negate the top stack entry
op_eq, // compare the top two stack entries for ==
op_neq, // compare the top two stack entries for !=
op_lt, // compare the top two stack entries for <
op_lte, // compare the top two stack entries for <=
op_gt, // compare the top two stack entries for >
op_gte, // compare the top two stack entries for >=
op_and, // logical and top two stack entries
op_or, // logical or top two stack entries
op_load, // load a variable
op_store, // store a variable
op_int, // push constant integer into the stack
op_true, // push constant 0 into the stack
op_false, // push constant 1 into the stack
op_jump_if, // jump to an absolute position in the code if top stack
// evaluates to false
op_jump // jump to an absolute position in the code
};
class vmachine {
public:
vmachine(unsigned stackSize = 4096)
:stack(stackSize)
,stack_ptr(stack.begin())
{
}
std::vector<int> const& get_stack() const {return stack;}
int top() const {return stack_ptr[-1]; }
void execute(std::vector<int> const& code, int nvars = 0) {
std::vector<int>::const_iterator pc = code.begin();
std::vector<int>::iterator locals = stack.begin();
stack_ptr = stack.begin() + nvars;
while (pc != code.end())
{
switch (*pc++)
{
case op_neg:
stack_ptr[-1] = -stack_ptr[-1];
break;
case op_not:
stack_ptr[-1] = !bool(stack_ptr[-1]);
break;
case op_add:
--stack_ptr;
stack_ptr[-1] += stack_ptr[0];
break;
case op_sub:
--stack_ptr;
stack_ptr[-1] -= stack_ptr[0];
break;
case op_mul:
--stack_ptr;
stack_ptr[-1] *= stack_ptr[0];
break;
case op_div:
--stack_ptr;
stack_ptr[-1] /= stack_ptr[0];
break;
case op_rem:
--stack_ptr;
stack_ptr[-1] %= stack_ptr[0];
break;
case op_eq:
--stack_ptr;
stack_ptr[-1] = bool(stack_ptr[-1] == stack_ptr[0]);
break;
case op_neq:
--stack_ptr;
stack_ptr[-1] = bool(stack_ptr[-1] != stack_ptr[0]);
break;
case op_lt:
--stack_ptr;
stack_ptr[-1] = bool(stack_ptr[-1] < stack_ptr[0]);
break;
case op_lte:
--stack_ptr;
stack_ptr[-1] = bool(stack_ptr[-1] <= stack_ptr[0]);
break;
case op_gt:
--stack_ptr;
stack_ptr[-1] = bool(stack_ptr[-1] > stack_ptr[0]);
break;
case op_gte:
--stack_ptr;
stack_ptr[-1] = bool(stack_ptr[-1] >= stack_ptr[0]);
break;
case op_and:
--stack_ptr;
stack_ptr[-1] = bool(stack_ptr[-1]) && bool(stack_ptr[0]);
break;
case op_or:
--stack_ptr;
stack_ptr[-1] = bool(stack_ptr[-1]) || bool(stack_ptr[0]);
break;
case op_load:
*stack_ptr++ = locals[*pc++];
break;
case op_store:
--stack_ptr;
locals[*pc++] = stack_ptr[0];
break;
case op_int:
*stack_ptr++ = *pc++;
break;
case op_true:
*stack_ptr++ = true;
break;
case op_false:
*stack_ptr++ = false;
break;
case op_jump:
pc = code.begin() + *pc;
break;
case op_jump_if:
if (!bool(stack_ptr[-1]))
pc = code.begin() + *pc;
else
++pc;
--stack_ptr;
break;
}
}
}
private:
std::vector<int> stack;
std::vector<int>::iterator stack_ptr;
};
///////////////////////////////////////////////////////////////////////////////
// A generic compiler that compiles 1 to 3 codes
///////////////////////////////////////////////////////////////////////////////
struct compile_op {
template <typename A, typename B = unused_type, typename C = unused_type>
struct result { typedef void type; };
compile_op(std::vector<int>& code):code(code) {
}
void operator()(int a) const {
code.push_back(a);
}
void operator()(int a, int b) const {
code.push_back(a);
code.push_back(b);
}
void operator()(int a, int b, int c) const {
code.push_back(a);
code.push_back(b);
code.push_back(c);
}
std::vector<int>& code;
};
///////////////////////////////////////////////////////////////////////////////
// Our error handler
///////////////////////////////////////////////////////////////////////////////
struct error_handler_
{
template <typename, typename, typename>
struct result { typedef void type; };
template <typename Iterator>
void operator()(
qi::info const& what
, Iterator err_pos, Iterator last) const
{
std::cout
<< "Error! Expecting "
<< what // what failed?
<< " here: \""
<< std::string(err_pos, last) // iterators to error-pos, end
<< "\""
<< std::endl
;
}
};
function<error_handler_> const error_handler = error_handler_();
///////////////////////////////////////////////////////////////////////////////
// Our expression grammar and compiler
///////////////////////////////////////////////////////////////////////////////
template <typename Iterator>
struct expression : qi::grammar<Iterator, ascii::space_type>
{
expression(std::vector<int>& code, qi::symbols<char, int>& vars) : expression::base_type(expr)
, code(code)
, vars(vars)
, op(code)
{
using qi::lexeme;
using qi::lit;
using qi::uint_;
using namespace qi::labels;
using qi::on_error;
using qi::fail;
using ascii::alnum;
expr =
equality_expr.alias()
;
equality_expr =
relational_expr
>> *( ("==" > relational_expr [op(op_eq)])
| ("!=" > relational_expr [op(op_neq)])
)
;
relational_expr =
logical_expr
>> *( ("<=" > logical_expr [op(op_lte)])
| ('<' > logical_expr [op(op_lt)])
| (">=" > logical_expr [op(op_gte)])
| ('>' > logical_expr [op(op_gt)])
)
;
logical_expr =
additive_expr
>> *( ("&&" > additive_expr [op(op_and)])
| ("||" > additive_expr [op(op_or)])
)
;
additive_expr =
multiplicative_expr
>> *( ('+' > multiplicative_expr [op(op_add)])
| ('-' > multiplicative_expr [op(op_sub)])
)
;
multiplicative_expr =
unary_expr
>> *( ('*' > unary_expr [op(op_mul)])
| ('/' > unary_expr [op(op_div)])
| ('%' > unary_expr [op(op_rem)])
)
;
unary_expr =
primary_expr
| ('!' > primary_expr [op(op_not)])
| ('-' > primary_expr [op(op_neg)])
| ('+' > primary_expr)
;
primary_expr =
uint_ [op(op_int, boost::spirit::_1)]
| variable
| lit("true") [op(op_true)]
| lit("false") [op(op_false)]
| '(' > expr > ')'
;
variable =
(
lexeme[
vars
>> !(alnum | '_') // make sure we have whole words
]
) [op(op_load, boost::spirit::_1)]
;
expr.name("expression");
equality_expr.name("equality-expression");
relational_expr.name("relational-expression");
logical_expr.name("logical-expression");
additive_expr.name("additive-expression");
multiplicative_expr.name("multiplicative-expression");
unary_expr.name("unary-expression");
primary_expr.name("primary-expression");
variable.name("variable");
on_error<fail>(expr, error_handler(boost::spirit::_4, boost::spirit::_3, boost::spirit::_2));
}
qi::rule<Iterator, ascii::space_type>
expr, equality_expr, relational_expr
, logical_expr, additive_expr, multiplicative_expr
, unary_expr, primary_expr, variable
;
std::vector<int>& code;
qi::symbols<char, int>& vars;
function<compile_op> op;
};
integer_expression_calc::integer_expression_calc(unsigned int vm_stack_size)
:vm_stack_size(vm_stack_size)
{
}
integer_expression_calc::~integer_expression_calc() {
}
bool integer_expression_calc::evaluate(std::string const& expr, int& rezult) {
typedef expression<std::string::const_iterator> expression_t;
vmachine mach(vm_stack_size); // Our virtual machine
std::vector<int> code; // Our VM code
boost::spirit::qi::symbols<char, int> vars; //
expression_t calc(code, vars); // Our grammar
std::string::const_iterator iter = expr.begin(), end = expr.end();
bool r = qi::phrase_parse(iter, end, calc, ascii::space);
if (r && iter == end) {
// ะะฐััะธะฝะณ ะฟัะพัะตะป ััะฟะตัะฝะพ, ะฟัะพะธะทะฒะพะดะธะผ ะฟะพะดััะตั ะธ ะฒะพะทัะฐัะฐะตะผ ัะตะทัะปััะฐั
mach.execute(code, 0);
rezult = mach.top();
return true;
}
return false;
}
| [
"dimonml@19848965-7475-ded4-60a4-26152d85fbc5"
] | [
[
[
1,
381
]
]
] |
f42e9415310c68a7eb931a3d736d5d71b14c5700 | 14a00dfaf0619eb57f1f04bb784edd3126e10658 | /lab5/QuadricDecimationMesh.cpp | 6a8bd5cb24a570161ce9a0b54ffac5dbb96879f4 | [] | no_license | SHINOTECH/modanimation | 89f842262b1f552f1044d4aafb3d5a2ce4b587bd | 43d0fde55cf75df9d9a28a7681eddeb77460f97c | refs/heads/master | 2021-01-21T09:34:18.032922 | 2010-04-07T12:23:13 | 2010-04-07T12:23:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,506 | cpp | /*************************************************************************************************
*
* Modeling and animation (TNM079) 2007
* Code base for lab assignments. Copyright:
* Gunnar Johansson ([email protected])
* Ken Museth ([email protected])
* Michael Bang Nielsen ([email protected])
* Ola Nilsson ([email protected])
* Andreas Sderstrm ([email protected])
*
*************************************************************************************************/
#include "QuadricDecimationMesh.h"
void QuadricDecimationMesh::initialize()
{
// Allocate memory for the quadric array
unsigned int numVerts = mVerts.size();
mQuadrics.reserve(numVerts);
std::streamsize width = std::cerr.precision(); // store stream precision
for (unsigned int i = 0; i < numVerts; i++) {
// Compute quadric for vertex i here
mQuadrics.push_back(createQuadricForVert(i));
// Calculate initial error, should be numerically close to 0
Vector3<float> v0 = mVerts[i].vec;
Vector4<float> v(v0.x(),v0.y(),v0.z(),1);
Matrix4x4<float> m = mQuadrics.back();
float error = v*(m*v);
std::cerr << std::scientific << std::setprecision(2) << error << " ";
}
std::cerr << std::setprecision(width) << std::fixed; // reset stream precision
// Run the initialize for the parent class to initialize the edge collapses
DecimationMesh::initialize();
}
/*! \lab2 Implement the computeCollapse here */
/*!
* \param[in,out] collapse The edge collapse object to (re-)compute, DecimationMesh::EdgeCollapse
*/
void QuadricDecimationMesh::computeCollapse(EdgeCollapse * collapse)
{
// Compute collapse->position and collapse->key here
// based on the quadrics at the edge endpoints
std::cerr << "computeCollapse in QuadricDecimationMesh not implemented.\n";
}
/*! After each edge collapse the vertex properties need need to be updated */
void QuadricDecimationMesh::updateVertexProperties(unsigned int ind)
{
DecimationMesh::updateVertexProperties(ind);
mQuadrics[ind] = createQuadricForVert(ind);
}
/*!
* \param[in] indx vertex index, points into HalfEdgeMesh::mVerts
*/
Matrix4x4<float> QuadricDecimationMesh::createQuadricForVert(unsigned int indx) const{
float q[4][4] = {{0,0,0,0},
{0,0,0,0},
{0,0,0,0},
{0,0,0,0}};
Matrix4x4<float> Q(q);
// The quadric for a vertex is the sum of all the quadrics for the adjacent faces
// Tip: Matrix4x4 has an operator +=
return Q;
}
/*!
* \param[in] indx face index, points into HalfEdgeMesh::mFaces
*/
Matrix4x4<float> QuadricDecimationMesh::createQuadricForFace(unsigned int indx) const{
// Calculate the quadric for a face here using the formula from Garland and Heckbert
return Matrix4x4<float>();
}
void QuadricDecimationMesh::draw()
{
DecimationMesh::draw();
drawQuadrics();
}
void QuadricDecimationMesh::drawQuadrics()
{
if (mQuadratic == NULL){
mQuadratic = gluNewQuadric();// Create A Pointer To The Quadric Object
gluQuadricNormals(mQuadratic, GLU_SMOOTH);// Create Smooth Normals
gluQuadricTexture(mQuadratic, GL_TRUE);// Create Texture Coords
}
else{
// Draw the quadrics here by applying the appropriate transform to a sphere.
// The quadrics are stored in the mQuadrics array.
// The sphere can be drawn by calling 'gluSphere(mQuadratic,radius, numSlices , numStacks)';
// Example: gluSphere(mQuadratic,1.0, 10 , 10)
}
}
| [
"onnepoika@da195381-492e-0410-b4d9-ef7979db4686"
] | [
[
[
1,
104
]
]
] |
43ee8df80b2299f61c6c1f9cd4f2cc9fe4dcb8ae | f177993b13e97f9fecfc0e751602153824dfef7e | /ImProSln/MyLib/LEADTOOL/Include/Filters/ILEncTheora.h | 796d36efc1fb058e61880855057ed580bc845371 | [] | no_license | svn2github/imtophooksln | 7bd7412947d6368ce394810f479ebab1557ef356 | bacd7f29002135806d0f5047ae47cbad4c03f90e | refs/heads/master | 2020-05-20T04:00:56.564124 | 2010-09-24T09:10:51 | 2010-09-24T09:10:51 | 11,787,598 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,373 | h |
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 7.00.0500 */
/* at Thu Nov 05 12:53:52 2009
*/
/* Compiler settings for .\ILEncTheora.idl:
Oicf, W1, Zp8, env=Win32 (32b run)
protocol : dce , ms_ext, c_ext, robust
error checks: allocation ref bounds_check enum stub_data
VC __declspec() decoration level:
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
DECLSPEC_UUID(), MIDL_INTERFACE()
*/
//@@MIDL_FILE_HEADING( )
#pragma warning( disable: 4049 ) /* more than 64k source lines */
/* verify that the <rpcndr.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 475
#endif
#include "rpc.h"
#include "rpcndr.h"
#ifndef __RPCNDR_H_VERSION__
#error this stub requires an updated version of <rpcndr.h>
#endif // __RPCNDR_H_VERSION__
#ifndef __ILEncTheora_h__
#define __ILEncTheora_h__
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
/* Forward Declarations */
#ifndef __ILMTheoraEncoder_FWD_DEFINED__
#define __ILMTheoraEncoder_FWD_DEFINED__
typedef interface ILMTheoraEncoder ILMTheoraEncoder;
#endif /* __ILMTheoraEncoder_FWD_DEFINED__ */
#ifndef __LMTheoraEncoder_FWD_DEFINED__
#define __LMTheoraEncoder_FWD_DEFINED__
#ifdef __cplusplus
typedef class LMTheoraEncoder LMTheoraEncoder;
#else
typedef struct LMTheoraEncoder LMTheoraEncoder;
#endif /* __cplusplus */
#endif /* __LMTheoraEncoder_FWD_DEFINED__ */
/* header files for imported files */
#include "oaidl.h"
#include "ocidl.h"
#ifdef __cplusplus
extern "C"{
#endif
#ifndef __LMTheoraEncoderLib_LIBRARY_DEFINED__
#define __LMTheoraEncoderLib_LIBRARY_DEFINED__
/* library LMTheoraEncoderLib */
/* [helpstring][version][uuid] */
#ifndef __ILMTheoraEncoder_H__
#define __ILMTheoraEncoder_H__
static const GUID CLSID_LMTheoraEncoder = { 0xE2B7DF5A, 0x38c5, 0x11d5, {0x91, 0xf6, 0x00, 0x10, 0x4b, 0xdb, 0x8f, 0xf9 }};
static const GUID LIBID_LMTheoraEncoderLib = { 0xE2B7DF59, 0x38c5, 0x11d5, {0x91, 0xf6, 0x00, 0x10, 0x4b, 0xdb, 0x8f, 0xf9 }};
static const GUID CLSID_LMTheoraEncoderProperty = { 0xE2B7DF5B, 0x38c5, 0x11d5, {0x91, 0xf6, 0x00, 0x10, 0x4b, 0xdb, 0x8f, 0xf9 }};
static const GUID CLSID_LMTheoraEncoderAbout = { 0xE2B7DF5C, 0x38c5, 0x11d5, {0x91, 0xf6, 0x00, 0x10, 0x4b, 0xdb, 0x8f, 0xf9 }};
static const GUID IID_ILMTheoraEncoder = { 0xE2B7DF5D, 0x38c5, 0x11d5, {0x91, 0xf6, 0x00, 0x10, 0x4b, 0xdb, 0x8f, 0xf9 }};
#endif
typedef /* [public][public][public] */
enum __MIDL___MIDL_itf_ILEncTheora_0000_0000_0001
{ THEORA_CONSTANT_BITRATE = 0,
THEORA_CONSTANT_QUALITY = ( THEORA_CONSTANT_BITRATE + 1 )
} eTHEORARATECONTROL;
EXTERN_C const IID LIBID_LMTheoraEncoderLib;
#ifndef __ILMTheoraEncoder_INTERFACE_DEFINED__
#define __ILMTheoraEncoder_INTERFACE_DEFINED__
/* interface ILMTheoraEncoder */
/* [unique][helpstring][uuid][local][object] */
EXTERN_C const IID IID_ILMTheoraEncoder;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("E2B7DF5D-38C5-11D5-91F6-00104BDB8FF9")
ILMTheoraEncoder : public IDispatch
{
public:
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE WriteToRegistry( void) = 0;
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ReadFromRegistry( void) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_RateControlMethod(
/* [retval][out] */ eTHEORARATECONTROL *pRateControl) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_RateControlMethod(
/* [in] */ eTHEORARATECONTROL RateControl) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_AverageBitrate(
/* [retval][out] */ long *pBitrate) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_AverageBitrate(
/* [in] */ long Bitrate) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_MaxQFactor(
/* [retval][out] */ long *pQFactor) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_MaxQFactor(
/* [in] */ long QFactor) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_QFactor(
/* [retval][out] */ long *pQFactor) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_QFactor(
/* [in] */ long QFactor) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_I_FrameDistance(
/* [retval][out] */ long *pI_FrameDistance) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_I_FrameDistance(
/* [in] */ long I_FrameDistance) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_OutputFrameRate(
/* [retval][out] */ double *pFrameRate) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_OutputFrameRate(
/* [in] */ double FrameRate) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_FastCompression(
/* [retval][out] */ VARIANT_BOOL *pFastCompression) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_FastCompression(
/* [in] */ VARIANT_BOOL FastCompression) = 0;
virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Sharpness(
/* [retval][out] */ long *pSharpness) = 0;
virtual /* [helpstring][id][propput] */ HRESULT STDMETHODCALLTYPE put_Sharpness(
/* [in] */ long Sharpness) = 0;
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ResetToDefaults( void) = 0;
};
#else /* C style interface */
typedef struct ILMTheoraEncoderVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
ILMTheoraEncoder * This,
/* [in] */ REFIID riid,
/* [iid_is][out] */
__RPC__deref_out void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
ILMTheoraEncoder * This);
ULONG ( STDMETHODCALLTYPE *Release )(
ILMTheoraEncoder * This);
HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )(
ILMTheoraEncoder * This,
/* [out] */ UINT *pctinfo);
HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )(
ILMTheoraEncoder * This,
/* [in] */ UINT iTInfo,
/* [in] */ LCID lcid,
/* [out] */ ITypeInfo **ppTInfo);
HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )(
ILMTheoraEncoder * This,
/* [in] */ REFIID riid,
/* [size_is][in] */ LPOLESTR *rgszNames,
/* [range][in] */ UINT cNames,
/* [in] */ LCID lcid,
/* [size_is][out] */ DISPID *rgDispId);
/* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )(
ILMTheoraEncoder * This,
/* [in] */ DISPID dispIdMember,
/* [in] */ REFIID riid,
/* [in] */ LCID lcid,
/* [in] */ WORD wFlags,
/* [out][in] */ DISPPARAMS *pDispParams,
/* [out] */ VARIANT *pVarResult,
/* [out] */ EXCEPINFO *pExcepInfo,
/* [out] */ UINT *puArgErr);
/* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *WriteToRegistry )(
ILMTheoraEncoder * This);
/* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *ReadFromRegistry )(
ILMTheoraEncoder * This);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_RateControlMethod )(
ILMTheoraEncoder * This,
/* [retval][out] */ eTHEORARATECONTROL *pRateControl);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_RateControlMethod )(
ILMTheoraEncoder * This,
/* [in] */ eTHEORARATECONTROL RateControl);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AverageBitrate )(
ILMTheoraEncoder * This,
/* [retval][out] */ long *pBitrate);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AverageBitrate )(
ILMTheoraEncoder * This,
/* [in] */ long Bitrate);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_MaxQFactor )(
ILMTheoraEncoder * This,
/* [retval][out] */ long *pQFactor);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_MaxQFactor )(
ILMTheoraEncoder * This,
/* [in] */ long QFactor);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_QFactor )(
ILMTheoraEncoder * This,
/* [retval][out] */ long *pQFactor);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_QFactor )(
ILMTheoraEncoder * This,
/* [in] */ long QFactor);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_I_FrameDistance )(
ILMTheoraEncoder * This,
/* [retval][out] */ long *pI_FrameDistance);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_I_FrameDistance )(
ILMTheoraEncoder * This,
/* [in] */ long I_FrameDistance);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_OutputFrameRate )(
ILMTheoraEncoder * This,
/* [retval][out] */ double *pFrameRate);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_OutputFrameRate )(
ILMTheoraEncoder * This,
/* [in] */ double FrameRate);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_FastCompression )(
ILMTheoraEncoder * This,
/* [retval][out] */ VARIANT_BOOL *pFastCompression);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_FastCompression )(
ILMTheoraEncoder * This,
/* [in] */ VARIANT_BOOL FastCompression);
/* [helpstring][id][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Sharpness )(
ILMTheoraEncoder * This,
/* [retval][out] */ long *pSharpness);
/* [helpstring][id][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Sharpness )(
ILMTheoraEncoder * This,
/* [in] */ long Sharpness);
/* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *ResetToDefaults )(
ILMTheoraEncoder * This);
END_INTERFACE
} ILMTheoraEncoderVtbl;
interface ILMTheoraEncoder
{
CONST_VTBL struct ILMTheoraEncoderVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define ILMTheoraEncoder_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define ILMTheoraEncoder_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define ILMTheoraEncoder_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define ILMTheoraEncoder_GetTypeInfoCount(This,pctinfo) \
( (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) )
#define ILMTheoraEncoder_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \
( (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) )
#define ILMTheoraEncoder_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \
( (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) )
#define ILMTheoraEncoder_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \
( (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) )
#define ILMTheoraEncoder_WriteToRegistry(This) \
( (This)->lpVtbl -> WriteToRegistry(This) )
#define ILMTheoraEncoder_ReadFromRegistry(This) \
( (This)->lpVtbl -> ReadFromRegistry(This) )
#define ILMTheoraEncoder_get_RateControlMethod(This,pRateControl) \
( (This)->lpVtbl -> get_RateControlMethod(This,pRateControl) )
#define ILMTheoraEncoder_put_RateControlMethod(This,RateControl) \
( (This)->lpVtbl -> put_RateControlMethod(This,RateControl) )
#define ILMTheoraEncoder_get_AverageBitrate(This,pBitrate) \
( (This)->lpVtbl -> get_AverageBitrate(This,pBitrate) )
#define ILMTheoraEncoder_put_AverageBitrate(This,Bitrate) \
( (This)->lpVtbl -> put_AverageBitrate(This,Bitrate) )
#define ILMTheoraEncoder_get_MaxQFactor(This,pQFactor) \
( (This)->lpVtbl -> get_MaxQFactor(This,pQFactor) )
#define ILMTheoraEncoder_put_MaxQFactor(This,QFactor) \
( (This)->lpVtbl -> put_MaxQFactor(This,QFactor) )
#define ILMTheoraEncoder_get_QFactor(This,pQFactor) \
( (This)->lpVtbl -> get_QFactor(This,pQFactor) )
#define ILMTheoraEncoder_put_QFactor(This,QFactor) \
( (This)->lpVtbl -> put_QFactor(This,QFactor) )
#define ILMTheoraEncoder_get_I_FrameDistance(This,pI_FrameDistance) \
( (This)->lpVtbl -> get_I_FrameDistance(This,pI_FrameDistance) )
#define ILMTheoraEncoder_put_I_FrameDistance(This,I_FrameDistance) \
( (This)->lpVtbl -> put_I_FrameDistance(This,I_FrameDistance) )
#define ILMTheoraEncoder_get_OutputFrameRate(This,pFrameRate) \
( (This)->lpVtbl -> get_OutputFrameRate(This,pFrameRate) )
#define ILMTheoraEncoder_put_OutputFrameRate(This,FrameRate) \
( (This)->lpVtbl -> put_OutputFrameRate(This,FrameRate) )
#define ILMTheoraEncoder_get_FastCompression(This,pFastCompression) \
( (This)->lpVtbl -> get_FastCompression(This,pFastCompression) )
#define ILMTheoraEncoder_put_FastCompression(This,FastCompression) \
( (This)->lpVtbl -> put_FastCompression(This,FastCompression) )
#define ILMTheoraEncoder_get_Sharpness(This,pSharpness) \
( (This)->lpVtbl -> get_Sharpness(This,pSharpness) )
#define ILMTheoraEncoder_put_Sharpness(This,Sharpness) \
( (This)->lpVtbl -> put_Sharpness(This,Sharpness) )
#define ILMTheoraEncoder_ResetToDefaults(This) \
( (This)->lpVtbl -> ResetToDefaults(This) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* __ILMTheoraEncoder_INTERFACE_DEFINED__ */
EXTERN_C const CLSID CLSID_LMTheoraEncoder;
#ifdef __cplusplus
class DECLSPEC_UUID("E2B7DF5A-38C5-11D5-91F6-00104BDB8FF9")
LMTheoraEncoder;
#endif
#endif /* __LMTheoraEncoderLib_LIBRARY_DEFINED__ */
/* Additional Prototypes for ALL interfaces */
/* end of Additional Prototypes */
#ifdef __cplusplus
}
#endif
#endif
| [
"ndhumuscle@fa729b96-8d43-11de-b54f-137c5e29c83a"
] | [
[
[
1,
409
]
]
] |
78f7d09b99d542c9d963082a30656cdcf2f9c61f | 00c36cc82b03bbf1af30606706891373d01b8dca | /OpenGUI/OpenGUI_Widget.h | 6e9e46d64f66c294bcda6e0deb50614b8acb74e6 | [
"BSD-3-Clause"
] | permissive | VB6Hobbyst7/opengui | 8fb84206b419399153e03223e59625757180702f | 640be732a25129a1709873bd528866787476fa1a | refs/heads/master | 2021-12-24T01:29:10.296596 | 2007-01-22T08:00:22 | 2007-01-22T08:00:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,852 | h | // OpenGUI (http://opengui.sourceforge.net)
// This source code is released under the BSD License
// See LICENSE.TXT for details
#ifndef B2B428BD_BA97_41F4_AF2E_EF32498FC240
#define B2B428BD_BA97_41F4_AF2E_EF32498FC240
#include "OpenGUI_PreRequisites.h"
#include "OpenGUI_Exports.h"
#include "OpenGUI_String.h"
#include "OpenGUI_Types.h"
#include "OpenGUI_Object.h"
#include "OpenGUI_ObjectAccessor.h"
#include "OpenGUI_Event.h"
#include "OpenGUI_Brush.h"
#include "OpenGUI_StrConv.h"
namespace OpenGUI {
class Renderer; //forward declaration
class WidgetCollection; //forward declaration
class Screen; //forward declaration
class Widget; //forward declaration
//! List of Widget pointers
typedef std::list<Widget*> WidgetPtrList;
//! Base class for all input processing, containable, and potentially visible GUI objects
/*!
\par Properties
- Name: setName(), getName()
- Enabled: setEnabled(), getEnabled()
\par Events Introduced
- \ref Event_Enabled "Enabled"
- \ref Event_Disabled "Disabled"
- \ref Event_Attached "Attached"
- \ref Event_Detached "Detached"
- \ref Event_Draw "Draw"
- \ref Event_Invalidated "Invalidated"
- \ref Event_CursorMoving "CursorMoving"
- \ref Event_CursorMove "CursorMove"
- \ref Event_CursorPressing "CursorPressing"
- \ref Event_CursorPress "CursorPress"
- \ref Event_CursorReleasing "CursorReleasing"
- \ref Event_CursorRelease "CursorRelease"
- \ref Event_CursorFocused "CursorFocused"
- \ref Event_CursorFocusLost "CursorFocusLost"
- \ref Event_KeyUp "KeyUp"
- \ref Event_KeyDown "KeyDown"
- \ref Event_KeyPressed "KeyPressed"
- \ref Event_KeyFocused "KeyFocused"
- \ref Event_KeyFocusLost "KeyFocusLost"
- \ref Event_Tick "Tick"
\see \ref EventList_Widget "Widget Events"
*/
class OPENGUI_API Widget : public Object {
friend class WidgetCollection; //we'll need this so containers can manage our handle to them
//friend class Screen; // Screen needs access to the protected input event triggers
public:
//! public constructor
Widget();
//! public destructor
virtual ~Widget();
//! returns the name of this Widget
const String& getName();
//! sets the name of this Widget
void setName( const String& name );
//! returns the enabled/disabled state of this Widget
bool getEnabled();
//! sets the enabled/disabled state of this Widget
void setEnabled( bool value );
//! invalidate any caches of this Widget's render output
/*! This will cause the Widget's Draw routine to be called on the next
update of the Screen this Widget is attached to. */
void invalidate();
//! invalidate this Widget, as well as any and all potential children
void flush();
//! Needs to be overridden by container widgets to invalidate self and call _doFlush() for all children
virtual void _doflush();
//! returns the collection this widget is held within
/*! Every displayable Widget is guaranteed to have a container.*/
WidgetCollection* getContainer() const;
//! Fills the given \c outList with pointers to all child Widgets that are under the given \c position
/*! The list is depth sorted, with top-most widgets at the top and bottom-most widgets at the bottom.
\param position The position to test in the same coordinates that \em this widget is defined in.
\param outList Filled with pointers to the Widgets that matched the query criteria
\param recursive \c TRUE to recurse into the matching children, asking the same question. \c FALSE to only test the direct children of this widget.
*/
void getChildrenAt( const FVector2& position, WidgetPtrList& outList, bool recursive = false );
//! Returns a pointer to the top-most child at the given \c position. Returns 0 if no child is found at the position.
/*! \param position The position to test in the same coordinates that \em this widget is defined in.
\param recursive \c TRUE to recurse into the matching child, asking the same question. \c FALSE to only test the direct children of this widget.
*/
Widget* getChildAt( const FVector2& position, bool recursive = false );
//! Returns a pointer to the widget at the given path, 0 if no widget is found
Widget* getPath( const String& path ) const;
//! \internal follows the given \c pathList, returning the ending location. The \c pathList is modified along the way
Widget* _getPath( StringList& pathList ) const;
//! Translates the given point from coordinates local to this Widget into Screen level coordinates
FVector2 pointToScreen( const FVector2& local_point );
//! Translates the given point from Screen level coordinates into coordinates local to this Widget
FVector2 pointFromScreen( const FVector2& screen_point );
//! Translate the given point from local coordinates to inside coordinates
virtual void _translatePointIn( FVector2& point );
//! Translate the given point from inside coordinates to local coordinates
virtual void _translatePointOut( FVector2& point );
//! \internal prepares the Brush for use, calls eventDraw, and then ensures restored Brush to initial state
virtual void _draw( Brush& brush );
//!\internal injects tick events to this widget
virtual void _tick( float seconds );
//! Returns \c true if this Widget has cursor focus within its Screen
bool hasCursorFocus();
//! Returns \c true if this Widget has key focus within its Screen
bool hasKeyFocus();
//Object Functions
virtual ObjectAccessorList* getAccessors();
virtual unsigned int getObjectType() const;
//! Returns true if the given point is inside this Widget
virtual bool isInside( const FVector2& position );
//! Informs this widget of cursor movement
void _injectCursorMove( Cursor_EventArgs& moveEvent );
//! Should inject the CursorMove event to all children
virtual void _sendToChildren_CursorMove( Cursor_EventArgs& moveEvent );
//! Informs this widget of cursor press
void _injectCursorPress( Cursor_EventArgs& pressEvent );
//! Should inject the CursorPress event to all children
virtual void _sendToChildren_CursorPress( Cursor_EventArgs& pressEvent );
//! Informs this widget of cursor release
void _injectCursorRelease( Cursor_EventArgs& releaseEvent );
//! Should inject the CursorRelease event to all children
virtual void _sendToChildren_CursorRelease( Cursor_EventArgs& releaseEvent );
//! Informs this widget of cursor focus acquisition
void _injectCursorFocused( Widget* next, Widget* prev );
//! Informs this widget of cursor focus loss
void _injectCursorFocusLost( Widget* next, Widget* prev );
//! Informs this widget of key down
void _injectKeyDown( Key_EventArgs& evtArgs );
//! Informs this widget of key press
void _injectKeyPressed( Key_EventArgs& evtArgs );
//! Informs this widget of key up
void _injectKeyUp( Key_EventArgs& evtArgs );
//! Informs this widget of key focus acquisition
void _injectKeyFocused( Widget* next, Widget* prev );
//! Informs this widget of key focus loss
void _injectKeyFocusLost( Widget* next, Widget* prev );
protected:
//!\name Event Triggers
//@{
//! Widget was attached to a container
void eventAttached( WidgetCollection* newContainer, Widget* widget );
//! Widget was removed from a container
void eventDetached( WidgetCollection* prevContainer, Widget* widget );
//! Draw this object's foreground using the given brush
void eventDraw( Brush& brush );
//! Widget was invalidated and will need to be redrawn next Screen::update()
void eventInvalidated();
//! Widget's state has changed to Enabled
void eventEnabled();
//! Widget's state has changed to Disabled
void eventDisabled();
//! Called for cursor movement before sending to children, giving the X,Y position of the cursor
bool eventCursorMoving( float xPos, float yPos );
//! Called for cursor movement, giving the X,Y position of the cursor
bool eventCursorMove( float xPos, float yPos );
//! Called for cursor press before sending to children, giving the X,Y position of the cursor
bool eventCursorPressing( float xPos, float yPos );
//! Called when the cursor button is pressed
bool eventCursorPress( float xPos, float yPos );
//! Called for cursor release before sending to children, giving the X,Y position of the cursor
bool eventCursorReleasing( float xPos, float yPos );
//! Called when the cursor button is released
bool eventCursorRelease( float xPos, float yPos );
//! Called when the cursor enters this Control
void eventCursorEnter();
//! Called when the cursor leaves this Control
void eventCursorLeave();
//! Called then this widget receives cursor focus
void eventCursorFocused( Widget* cur, Widget* prev );
//! Called then this widget loses cursor focus
void eventCursorFocusLost( Widget* cur, Widget* prev );
//! Called when the given \c character is released
bool eventKeyUp( char character );
//! Called when the given \c character is pressed down
bool eventKeyDown( char character );
//! Called when the given \c character is entered
bool eventKeyPressed( char character );
//! Called then this widget receives key focus
void eventKeyFocused( Widget* cur, Widget* prev );
//! Called then this widget loses key focus
void eventKeyFocusLost( Widget* cur, Widget* prev );
//! Called when the passage of time has been measured
void eventTick( float seconds );
//@}
//!\name Event Handlers
//@{
//! "Attached" event
virtual void onAttached( Object* sender, Attach_EventArgs& evtArgs );
//! "Detached" event
virtual void onDetached( Object* sender, Attach_EventArgs& evtArgs );
//! "Draw" event
virtual void onDraw( Object* sender, Draw_EventArgs& evtArgs );
//! "Invalidated" event
virtual void onInvalidated( Object* sender, EventArgs& evtArgs );
//! "Enabled" event
virtual void onEnabled( Object* sender, EventArgs& evtArgs );
//! "Disabled" event
virtual void onDisabled( Object* sender, EventArgs& evtArgs );
//! "CursorMoving" event
virtual void onCursorMoving( Object* sender, Cursor_EventArgs& evtArgs );
//! "CursorMove" event
virtual void onCursorMove( Object* sender, Cursor_EventArgs& evtArgs );
//! "CursorPressing" event
virtual void onCursorPressing( Object* sender, Cursor_EventArgs& evtArgs );
//! "CursorPress" event
virtual void onCursorPress( Object* sender, Cursor_EventArgs& evtArgs );
//! "CursorReleasing" event
virtual void onCursorReleasing( Object* sender, Cursor_EventArgs& evtArgs );
//! "CursorRelease" event
virtual void onCursorRelease( Object* sender, Cursor_EventArgs& evtArgs );
//! "CursorEnter" event
virtual void onCursorEnter( Object* sender, EventArgs& evtArgs );
//! "CursorLeave" event
virtual void onCursorLeave( Object* sender, EventArgs& evtArgs );
//! "CursorFocused" event
virtual void onCursorFocused( Object* sender, Focus_EventArgs& evtArgs );
//! "CursorFocusLost" event
virtual void onCursorFocusLost( Object* sender, Focus_EventArgs& evtArgs );
//! "Key_Up" event
virtual void onKeyUp( Object* sender, Key_EventArgs& evtArgs );
//! "Key_Down" event
virtual void onKeyDown( Object* sender, Key_EventArgs& evtArgs );
//! "Key_Pressed" event
virtual void onKeyPressed( Object* sender, Key_EventArgs& evtArgs );
//! "Key_Focused" event
virtual void onKeyFocused( Object* sender, Focus_EventArgs& evtArgs );
//! "Key_FocusLost" event
virtual void onKeyFocusLost( Object* sender, Focus_EventArgs& evtArgs );
//! "Tick" event
virtual void onTick( Object* sender, Tick_EventArgs& evtArgs );
//@}
//! returns the screen that this Widget is attached to, or 0 if not attached
Screen* getScreen() const;
//! returns a pointer to the parenting Object of this Widget, or 0 if there isn't one
Object* getParent() const;
//! grabs focus for this Widget for keyboard events
void grabKeyFocus();
//! releases focus for this Widget for keyboard events
void releaseKeyFocus();
//! grabs focus for this Widget for cursor events
void grabCursorFocus();
//! releases focus for this Widget for cursor events
void releaseCursorFocus();
//! \internal virtual implementation for getChildrenAt(). Hidden because overriding is almost always unnecessary
virtual void _getChildrenAt( const FVector2& position, WidgetPtrList& outList, bool recursive );
//! \internal virtual implementation for getChildAt(). Hidden because overriding is almost always unnecessary
virtual Widget* _getChildAt( const FVector2& position, bool recursive );
//! \internal returns the child with the given name. Virtual so that container widgets can redefine it to fit their storage type. Default returns 0 always
virtual Widget* _getChildByName( const String& childName ) const;
//! \internal called by a child when they have been invalidated. Default does nothing. Override me if you need more functionality
virtual void _invalidatedChild();
private:
WidgetCollection* mContainer; // <- managed by WidgetCollection. We should never touch this.
bool mValid; // used to prevent multiple calls to invalidate from constantly causing Invalidated events
bool mEnabled;
String mWidgetName;
bool m_CursorInside; // state variable used by _injectCursorMove()
void _detaching(); // called directly before the detach occurs (used for last minute cleanup)
void _attaching(); // called directly before the attach occurs
void _doPointToScreen( FVector2& local_point );
void _doPointFromScreen( FVector2& screen_point );
};
} //namespace OpenGUI{
#endif // B2B428BD_BA97_41F4_AF2E_EF32498FC240
| [
"zeroskill@2828181b-9a0d-0410-a8fe-e25cbdd05f59"
] | [
[
[
1,
313
]
]
] |
576e77e9bf8cb6cc42d1c77b199e9e7f5089fa90 | b14d5833a79518a40d302e5eb40ed5da193cf1b2 | /cpp/extern/xercesc++/2.6.0/src/xercesc/util/Platforms/OS390/Path390.hpp | 46eb8d8f2c864465adde2aead80c4a1c048d51a1 | [
"Apache-2.0"
] | permissive | andyburke/bitflood | dcb3fb62dad7fa5e20cf9f1d58aaa94be30e82bf | fca6c0b635d07da4e6c7fbfa032921c827a981d6 | refs/heads/master | 2016-09-10T02:14:35.564530 | 2011-11-17T09:51:49 | 2011-11-17T09:51:49 | 2,794,411 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,547 | hpp | /*
* Copyright 2002,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: Path390.hpp,v 1.2 2004/09/08 13:56:41 peiyongz Exp $
*/
#ifndef PATH390_HPP
#define PATH390_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class Path390
{
public:
// Constructors and Destructor
Path390();
~Path390();
Path390(char *s);
// Set a new path in the object. This will overlay any existing path and
// re-initialize the object.
void setPath(char *s);
// This performs a complete parse of the path. It returns the error code or 0
// if there was no error.
int fullParse();
// This returns the path in a format as required by fopen
char * getfopenPath();
// This returns the parameters in a format as required by fopen
char * getfopenParms();
// This returns the type of the path. See the constants defined below.
int getPathType();
// This returns the error code that was found during the parse
int getError();
// Returns whether the path is relative or absolute
bool isRelative();
// Returns whether or not type=record shows up in the path.
bool isRecordType();
private:
int _pathtype;
char * _orgpath;
int _orglen;
char * _resultpath;
bool _absolute;
bool _uriabsolute;
bool _dsnabsolute;
char * _curpos;
int _parsestate;
int _numperiods;
int _numsemicolons;
int _error;
char * _orgparms;
int _orgparmlen;
char * _lastsemi;
char * _lastslash;
char * _lastparen;
char * _parmStart;
char * _pathEnd;
char * _extStart;
int _typerecord;
// internal only methods:
void _determine_uri_abs();
void _determine_type();
void _determine_punct();
void _determine_parms();
void _parse_rest();
};
// Internal constants for the _parsestate variable:
#define PARSE_NONE 0
#define PARSE_ABSOLUTE_URI 1
#define PARSE_PATHTYPE 2
#define PARSE_PUNCT 3
#define PARSE_PARMS 4
#define PARSE_PARSED 5
// These are the possible error return codes:
#define NO_ERROR 0
#define ERROR_SEMICOLON_NOT_ALLOWED 101
#define ERROR_PERIOD_NOT_ALLOWED 102
#define ERROR_NO_PAREN_ALLOWED 103
#define ERROR_ABS_PATH_REQUIRED 104
#define ERROR_NO_EXTRA_PERIODS_ALLOWED 105
#define ERROR_MUST_BE_ABSOLUTE 106
#define ERROR_BAD_DD 107
#define ERROR_BAD_DSN2 108
#define ERROR_NO_EXTRA_SEMIS_ALLOWED 109
// Constants for the _pathtype variable and the return value from getPathType() method:
#define PATH390_HFS 1
#define PATH390_DSN1 2 // format is dsn:/chrisl/data/xml/member1.
#define PATH390_DSN2 3 // format is dsn://'chrisl.data.xml(member1)'
#define PATH390_DD 4
#define PATH390_OTHER 5
XERCES_CPP_NAMESPACE_END
#endif
| [
"[email protected]"
] | [
[
[
1,
125
]
]
] |
1e54c42df4b393017cd3893d198921d5fa5131d7 | 16d6176d43bf822ad8d86d4363c3fee863ac26f9 | /hw4-predhru/Image.cpp | afe569adf86d59826d6e9dbe2a80b190191629ae | [] | no_license | preethinarayan/cgraytracer | 7a0a16e30ef53075644700494b2f8cf2a0693fbd | 46a4a22771bd3f71785713c31730fdd8f3aebfc7 | refs/heads/master | 2016-09-06T19:28:04.282199 | 2008-12-10T00:02:32 | 2008-12-10T00:02:32 | 32,247,889 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 702 | cpp | #include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include "Image.h"
bool Image::setSize(char **args)
{
width = 600;
height = 400;
/* RGB allocation */
pixel = (int *)malloc(sizeof(int) * width *height * 3);
return true;
}
bool Image::writeImage()
{
FILE *fp;
assert(fp = fopen(output_file, "wt")) ;
fprintf(fp, "P3\n");
fprintf(fp, "%d %d ", width, height);
fprintf(fp, "255");
for(int i=0; i<height; i++)
for(int j=0; j<width; j++)
{
fprintf(fp, " %d %d %d", pixel[i*width*3 + j*3 + 0], pixel[i*width*3 + j*3 + 1], pixel[i*width*3 + j*3 + 2]);
}
fclose(fp);
return true;
}
Image::Image(void)
{
}
Image::~Image(void)
{
}
| [
"dhrumins@074c0a88-b503-11dd-858c-a3a1ac847323",
"[email protected]@074c0a88-b503-11dd-858c-a3a1ac847323"
] | [
[
[
1,
3
],
[
6,
6
],
[
8,
14
],
[
17,
29
],
[
31,
33
],
[
35,
37
],
[
39,
39
]
],
[
[
4,
5
],
[
7,
7
],
[
15,
16
],
[
30,
30
],
[
34,
34
],
[
38,
38
],
[
40,
41
]
]
] |
851abcda3875d90a168b0fd04ba8c75400ab5641 | 2fdbf2ba994ba3ed64f0e2dc75cd2dfce4936583 | /gpt/test.cpp | 7579cf4c088c8b4a5b535d6e7c3ba3c1b6af1c14 | [] | no_license | TERRANZ/terragraph | 36219a4e512e15a925769512a6b60637d39830bf | ea8c36070f532ad0a4af08e46b19f4ee1b85f279 | refs/heads/master | 2020-05-25T10:31:26.994233 | 2011-01-29T21:23:04 | 2011-01-29T21:23:04 | 1,047,237 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 109 | cpp | #include "test.h"
namespace {
/*$GPBS$$!globals!*/
// put global variables and funcs here
/*$GPBS$*/
} | [
"[email protected]"
] | [
[
[
1,
7
]
]
] |
b18a230d7d9a8aaa7e89fc515579e20f57e02319 | 43626054205d6048ec98c76db5641ce8e42b8237 | /source/CTempState.h | c8b2ce6d8b9698ab369c4ce7353b302d751f7766 | [] | no_license | Wazoobi/whitewings | b700da98b855a64442ad7b7c4b0be23427b0ee23 | a53fdb832cfb1ce8605209c9af47f36b01c44727 | refs/heads/master | 2021-01-10T19:33:22.924792 | 2009-08-05T18:30:07 | 2009-08-05T18:30:07 | 32,119,981 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,591 | h | //////////////////////////////////////////////////////////////////////////
// File Name : "CTempState.h"
//
// Author : Juno Madden (JM)
//
// Purpose : Spike Solution... ish
//////////////////////////////////////////////////////////////////////////
#pragma once
#include "IGameState.h"
#include "CGame.h"
#include "SGD Wrappers/CSGD_Direct3D.h"
#include "SGD Wrappers/CSGD_TextureManager.h"
#include "SGD Wrappers/CSGD_DirectInput.h"
#include "CFontManager.h"
#include "CSGD_ObjectFactory.h"
#include "CObjectManager.h"
#include "CLogger.h"
class CPlayer;
class CTempState : public IGameState
{
CSGD_Direct3D *m_pD3D;
CSGD_TextureManager *m_pTM;
CSGD_DirectInput *m_pDI;
CFontManager *m_pFM;
CSGD_ObjectFactory<string, CBase> *m_pOF;
CObjectManager *m_pOM;
CGame *pGame;
int m_nBackgroundID;
CPlayer *m_pPlayer;
vector<CLogger*> m_vLoggers;
CTempState(void);
~CTempState(void);
CTempState(const CTempState& );
CTempState& operator=(const CTempState& );
public:
//////////////////////////////////////////////////////////////////////////
// Function : Get Instance
//
// Purpose : Grants global access to the singleton.
//////////////////////////////////////////////////////////////////////////
static CTempState* GetInstance(void);
//////////////////////////////////////////////////////////////////////////
// Function : Enter
//
// Purpose : Enters into the state.
//////////////////////////////////////////////////////////////////////////
void Enter(void);
//////////////////////////////////////////////////////////////////////////
// Function : Exit
//
// Purpose : Leaves the state.
//////////////////////////////////////////////////////////////////////////
void Exit(void);
//////////////////////////////////////////////////////////////////////////
// Function : Input
//
// Purpose : Takes in input.
//////////////////////////////////////////////////////////////////////////
bool Input(void);
//////////////////////////////////////////////////////////////////////////
// Function : Updates
//
// Purpose : Updates data members based on time.
//////////////////////////////////////////////////////////////////////////
void Update(float fElapsedTime);
//////////////////////////////////////////////////////////////////////////
// Function : Render
//
// Purpose : Draws to the screen.
//////////////////////////////////////////////////////////////////////////
void Render(void);
}; | [
"Juno05@1cfc0206-7002-11de-8585-3f51e31374b7"
] | [
[
[
1,
89
]
]
] |
e925a24f27908e0c0a2b06c3dfe429b185bed808 | d38dd2b4c110cdc21724977a5e7546e32fee80a4 | /trace_ids/options.cpp | 6db600bc1724c866813a4a5a29622ab4c83dfd54 | [] | no_license | arm2arm/mstgraph | ae306f17e216dc5be06f79263a776f7cb9451f92 | b9b8c1af1a56fbfabc9f7ecc34dcb7af23e4fd4e | refs/heads/master | 2020-12-24T19:46:21.823308 | 2010-06-25T13:58:42 | 2010-06-25T13:58:42 | 56,456,768 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,103 | cpp |
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
#include <boost/tokenizer.hpp>
#include <boost/token_functions.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/foreach.hpp>
using namespace boost::program_options;
using boost::lexical_cast;
using boost::bad_lexical_cast;
#include "options.h"
#include <fstream>
#include <string>
bool is_file_exist(const std::string &filename)
{
std::ifstream fin(filename.c_str(), std::ios::in);
if(fin.is_open())
{
fin.close();
return true;
}
fin.close();
return false;
}
void COptions::ReadID(std::string file)
{
std::ifstream infile(file.c_str());
int val;
string f1, f2;
float A, P, AP;
if(is_file_exist(file))
{
//infile>>f1;
//infile>>f2;
while(infile>>val>>A>>P>>AP)
{
m_IDlist.insert(std::make_pair(val,TApData(A,P)));
}
}
else
std::cerr<<"WARNING::Cannot find ID file: "<<file<<std::endl;
}
COptions::COptions(int argc, char* argv[]):m_status(0)
{
m_status=EXIT_FAILURE;
try {
namespace po = boost::program_options;
//typedef string TIDlist;
typedef int TIDlist;
std::vector<TIDlist> IDlist;
po::options_description commands("Allowed options");
commands.add_options()
("snapshotList", po::value< vector<string> >(&m_snapshotList)->multitoken(), "Which snapshots to trace: ex. --snapshotList=snap_001 snap_002 snap_003 ")
("IDlist", po::value< vector<TIDlist> >(&IDlist)->multitoken(), "Which IDs to trace: ex. --IDlist=0 1 200 -340")
("IDflist", po::value< vector<string> >(&m_snapshotList)->multitoken(), "Which IDs to trace from file: ex. --IDfile=idFile.txt, where file has a integers inside the file")
("out-file", po::value< string>(&m_file_out)->default_value(string("intersect.idx")), "out file")
("type", po::value< int>(&m_type)->default_value(4), "particle type to track")
("help","print help")
;
variables_map vm;
store(parse_command_line(argc, argv, commands, po::command_line_style::unix_style ^ po::command_line_style::allow_short), vm);
// store(command_line_parser(argc, argv).options(commands).run(), vm);// this is the simplyfied interface of the parser
notify(vm);
// printInputs(vm);
if(vm.count("snapshotList")) {
//ostream_iterator<string> it(cout, "\n ");
cout << "snapshot list detected" << endl;
cout << "We will trace following snapshots:\n ";
for(std::vector<string>::iterator it=m_snapshotList.begin();it<m_snapshotList.end(); it++)
{
cout<<(*it);
if(is_file_exist(*it)){
cout<<"..exist."<<endl;
m_status=EXIT_SUCCESS;
}
else{
cout<<"does NOT exist."<<endl;
m_status=EXIT_FAILURE;
}
}
cout << endl << endl;
if(m_snapshotList.size()<2)
{
cout<<"Error: The minimum number of snapshots is 2.\nPlease enter at least 2 different snapshots."<<endl;
m_status=EXIT_FAILURE;
}
}
if(vm.count("IDlist")) {
ostream_iterator<TIDlist> it(cout, ", ");
cout << "ID list detected with:" << endl;
//cout << "These IDs we will trace: ";
BOOST_FOREACH(TIDlist val, IDlist)
{
m_IDlist.insert(std::make_pair(boost::lexical_cast<int>(val), TApData()));
};
cout<<"numID="<<m_IDlist.size()<<" entries.";
cout << endl << endl;
}
if(vm.count("IDflist")) {
ReadID(m_file_IDlist);
cout<<"numID="<<m_IDlist.size()<<" entries.";
cout << endl << endl;
}
if (vm.count("help")) {
cout << commands << "\n";
m_status=EXIT_FAILURE;
}
if(m_status==EXIT_FAILURE)
cout << commands << "\n";
}
catch (const std::exception& e) {
cout << e.what() << "\n";
m_status=EXIT_FAILURE;
}
}
/*void COptions::printInputs(variables_map vm)
{
int i=0;
variables_map::iterator it=vm.begin();
cout << "\n***List of commands detected: " << endl;
for(it;it!=vm.end();++it) {
cout <<"Command[" << i << "]: " << it->first << endl;
++i;
}
cout << endl;
}
*/ | [
"arm2arm@06a51f3c-712f-11de-a0a7-fb2681086dbc"
] | [
[
[
1,
143
]
]
] |
1d975305e6d8f1cd998924754da56be554c6bce1 | 215fd760efb591ab13e10c421686fef079d826e1 | /lib/p4api/include/p4/strdict.h | 75cc08e43cbedca1100b964d69990ed79f7d2a72 | [] | no_license | jairbubbles/P4.net | 2021bc884b9940f78e94b950e22c0c4e9ce8edca | 58bbe79b30593134a9306e3e37b0b1aab8135ed0 | refs/heads/master | 2020-12-02T16:21:15.361000 | 2011-02-15T19:28:31 | 2011-02-15T19:28:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,274 | h | /*
* Copyright 1995, 1996 Perforce Software. All rights reserved.
*
* This file is part of Perforce - the FAST SCM System.
*/
/*
* StrDict.h - a set/get dictionary interface
*
* Classes:
*
* StrDict - a GetVar/PutVar dictionary interface
*
* Methods:
*
*/
class Error;
class StrVarName : public StrRef {
public:
StrVarName( const char *buf, int length )
{
memcpy( varName, buf, length );
varName[ length ] = 0;
Set( varName, length );
}
StrVarName( const StrPtr &name, int x );
StrVarName( const StrPtr &name, int x, int y );
private:
char varName[64];
} ;
class StrDict {
public:
virtual ~StrDict();
// Handy wrappers
void CopyVars( StrDict &other );
void SetVar( const char *var );
void SetVar( const char *var, int value );
void SetVar( const char *var, const char *value );
void SetVar( const char *var, const StrPtr *value );
void SetVar( const char *var, const StrPtr &value );
void SetVar( const StrPtr &var, const StrPtr &value )
{ VSetVar( var, value ); }
void SetVarV( const char *arg );
void SetArgv( int argc, char *const *argv );
void SetVar( const StrPtr &var, int x, const StrPtr &val );
void SetVar( const char *var, int x, const StrPtr &val );
void SetVar( const char *var, int x, int y, const StrPtr &val );
StrPtr *GetVar( const char *var );
StrPtr *GetVar( const char *var, Error *e );
StrPtr *GetVar( const StrPtr &var, int x );
StrPtr *GetVar( const StrPtr &var, int x, int y );
StrPtr *GetVar( const StrPtr &var )
{ return VGetVar( var ); }
int GetVar( int x, StrRef &var, StrRef &val )
{ return VGetVarX( x, var, val ); }
void ReplaceVar( const char *var, const char *value );
void RemoveVar( const char *var );
void Clear()
{ VClear(); }
int Save( FILE * out );
int Load( FILE * out );
protected:
// Get/Set vars, provided by subclass
virtual StrPtr *VGetVar( const StrPtr &var ) = 0;
virtual void VSetVar( const StrPtr &var, const StrPtr &val );
virtual void VRemoveVar( const StrPtr &var );
virtual int VGetVarX( int x, StrRef &var, StrRef &val );
virtual void VSetError( const StrPtr &var, Error *e );
virtual void VClear();
} ;
| [
"[email protected]"
] | [
[
[
1,
91
]
]
] |
77554564ccad872622ec6cbe0ffe60069b411f95 | 57574cc7192ea8564bd630dbc2a1f1c4806e4e69 | /Poker/Servidor/Operacion.cpp | 4adca943c8847e40a510ed0f0fcf93bba350aec9 | [] | no_license | natlehmann/taller-2010-2c-poker | 3c6821faacccd5afa526b36026b2b153a2e471f9 | d07384873b3705d1cd37448a65b04b4105060f19 | refs/heads/master | 2016-09-05T23:43:54.272182 | 2010-11-17T11:48:00 | 2010-11-17T11:48:00 | 32,321,142 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,223 | cpp | #include "Operacion.h"
#include "ContextoJuego.h"
#include "RecursosServidor.h"
#include "PokerException.h"
#include "Respuesta.h"
#include "SincronizadorThreads.h"
Operacion::Operacion(int idCliente) {
this->setIdCliente(idCliente);
}
Operacion::~Operacion() {}
bool Operacion::ejecutar(Socket* socket){
bool resultado = false;
HANDLE mutexContexto = ContextoJuego::getInstancia()->getMutex();
// TODO: VERIFICAR TIMEOUT
if(WaitForSingleObject(mutexContexto, INFINITE)==WAIT_TIMEOUT) {
// TODO: handle time-out error
cout << "DIO TIMEOUT !!!! ID CLIENTE: " << this->getIdCliente() << endl;
}
try {
resultado = this->ejecutarAccion(socket);
SincronizadorThreads::getInstancia()->notificarFin(
ContextoJuego::getInstancia()->idClienteToIdJugador(this->getIdCliente()));
} catch(PokerException& e){
RecursosServidor::getLog()->escribir(&(e.getError()));
} catch(exception& e){
RecursosServidor::getLog()->escribir("Se produjo un error ejecutando la operacion. " + string(e.what()));
} catch(...){
RecursosServidor::getLog()->escribir("Se produjo un error ejecutando la operacion.");
}
ReleaseMutex(mutexContexto);
return resultado;
}
| [
"marianofl85@a9434d28-8610-e991-b0d0-89a272e3a296",
"[email protected]@a9434d28-8610-e991-b0d0-89a272e3a296"
] | [
[
[
1,
1
],
[
7,
7
],
[
11,
12
]
],
[
[
2,
6
],
[
8,
10
],
[
13,
44
]
]
] |
bd09d55f844bdd45686ded4b8a08e00b720e2086 | f4b649f3f48ad288550762f4439fcfffddc08d0e | /eRacer/Source/Graphics/Mesh.cpp | 56ad15aca7d082c29725bdaa92206ed9738d2adb | [] | no_license | Knio/eRacer | 0fa27c8f7d1430952a98ac2896ab8b8ee87116e7 | 65941230b8bed458548a920a6eac84ad23c561b8 | refs/heads/master | 2023-09-01T16:02:58.232341 | 2010-04-26T23:58:20 | 2010-04-26T23:58:20 | 506,897 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,071 | cpp | /**
* @file Mesh.cpp
* @brief Implementation of the Mesh class
*
* @date 07.02.2010
* @author: Ole Rehmsen
*/
#include "Mesh.h"
#include "GraphicsLayer.h"
#include "IO/IO.h"
namespace Graphics {
Mesh::Mesh()
: d3dMesh_(NULL),
materials_(NULL),
textures_(NULL),
initialized(false),
cached(false)
{
m_colorMtrlTint = D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f );
}
Mesh::Mesh(ID3DXMesh* mesh, D3DMATERIAL9 material, IDirect3DTexture9* texture, Vector4 meshCol ) :
d3dMesh_(mesh),
nMaterials_(1)
{
materials_ = new D3DMATERIAL9[1];
materials_[0] = material;
textures_ = new IDirect3DTexture9*[1];
textures_[0] = texture;
initialized = true;
cached = false;
localBounds.recompute(*d3dMesh_);
m_colorMtrlTint = D3DXCOLOR( meshCol.x, meshCol.y, meshCol.z, meshCol.w );
}
Mesh::~Mesh(){
if(initialized){
if(!cached){
delete [] materials_;
d3dMesh_->Release();
}
delete [] textures_;
}
}
void Mesh::Init(const CachedMesh& cachedMesh, const vector<IDirect3DTexture9*>& textures){
assert(!initialized);
assert(cachedMesh.IsValid());
assert(cachedMesh.nMaterials == textures.size());
d3dMesh_ = cachedMesh.d3dMesh;
nMaterials_ = cachedMesh.nMaterials;
materials_ = cachedMesh.materials;
textures_ = new IDirect3DTexture9*[cachedMesh.nMaterials];
for(unsigned int i = 0; i<textures.size(); i++)
textures_[i] = textures[i];
localBounds = cachedMesh.localBounds;
initialized = true;
cached = true;
}
void Mesh::Draw(IDirect3DDevice9* device) const{
if(!initialized)
return;
assert(NULL != device);
// Meshes are divided into subsets, one for each material. Render them in a loop
for(unsigned int i = 0; i<nMaterials_; i++){
device->SetMaterial( &materials_[i] );
// GraphicsLayer::GetInstance()->SetTexture(0, textures_[i]);
device->SetTexture(0, textures_[i]);
//make sure the mesh has been initialized at this point
assert(NULL != d3dMesh_);
d3dMesh_->DrawSubset(i);
}
}
}
| [
"[email protected]",
"[email protected]",
"[email protected]"
] | [
[
[
1,
9
],
[
11,
21
],
[
23,
24
],
[
26,
35
],
[
37,
37
],
[
39,
64
],
[
69,
76
],
[
79,
86
]
],
[
[
10,
10
],
[
65,
68
],
[
77,
78
],
[
87,
87
]
],
[
[
22,
22
],
[
25,
25
],
[
36,
36
],
[
38,
38
]
]
] |
1860399e5e55686912ac60a9407172f71ce5136f | 28aa891f07cc2240c771b5fb6130b1f4025ddc84 | /extern/oolua/include/lua_function.h | cbd08cba9f43dc1dc029348a51833e62d459b575 | [
"MIT"
] | permissive | Hincoin/mid-autumn | e7476d8c9826db1cc775028573fc01ab3effa8fe | 5271496fb820f8ab1d613a1c2355504251997fef | refs/heads/master | 2021-01-10T19:17:01.479703 | 2011-12-19T14:32:51 | 2011-12-19T14:32:51 | 34,730,620 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,725 | h | #ifndef LUA_FUNCTION_H_
# define LUA_FUNCTION_H_
///////////////////////////////////////////////////////////////////////////////
/// @file lua_function.h
/// @remarks Warning this file was generated, edits to it will not persist if
/// the file is regenerated.
/// @author Liam Devine
/// @email
/// See http://www.liamdevine.co.uk for contact details.
/// @licence
/// See licence.txt for more details. \n
///////////////////////////////////////////////////////////////////////////////
# include "lua_includes.h"
# include "fwd_push_pull.h"
# include "lua_ref.h"
namespace OOLUA
{
///////////////////////////////////////////////////////////////////////////////
/// Lua_function
/// Struct which is used to call a lua function.
/// @remarks
/// The Lua function can either be called by name(std::string) or with the
/// use a Lua reference which is stored in a Lua_func.
///////////////////////////////////////////////////////////////////////////////
struct Lua_function
{
template<typename FUNC>
bool operator()(FUNC const& func_name)
{
set_function(func_name);
return call(0);
}
template<typename FUNC,typename P1>
bool operator()(FUNC const& func_name,P1 p1)
{
set_function(func_name);
push2lua(m_lua,p1);
return call(1);
}
template<typename FUNC,typename P1,typename P2>
bool operator()(FUNC const& func_name,P1 p1,P2 p2)
{
set_function(func_name);
push2lua(m_lua,p1); push2lua(m_lua,p2);
return call(2);
}
template<typename FUNC,typename P1,typename P2,typename P3>
bool operator()(FUNC const& func_name,P1 p1,P2 p2,P3 p3)
{
set_function(func_name);
push2lua(m_lua,p1); push2lua(m_lua,p2); push2lua(m_lua,p3);
return call(3);
}
template<typename FUNC,typename P1,typename P2,typename P3,typename P4>
bool operator()(FUNC const& func_name,P1 p1,P2 p2,P3 p3,P4 p4)
{
set_function(func_name);
push2lua(m_lua,p1); push2lua(m_lua,p2); push2lua(m_lua,p3); push2lua(m_lua,p4);
return call(4);
}
template<typename FUNC,typename P1,typename P2,typename P3,typename P4,typename P5>
bool operator()(FUNC const& func_name,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5)
{
set_function(func_name);
push2lua(m_lua,p1); push2lua(m_lua,p2); push2lua(m_lua,p3); push2lua(m_lua,p4); push2lua(m_lua,p5);
return call(5);
}
template<typename FUNC,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6>
bool operator()(FUNC const& func_name,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6)
{
set_function(func_name);
push2lua(m_lua,p1); push2lua(m_lua,p2); push2lua(m_lua,p3); push2lua(m_lua,p4); push2lua(m_lua,p5); push2lua(m_lua,p6);
return call(6);
}
template<typename FUNC,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6,typename P7>
bool operator()(FUNC const& func_name,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6,P7 p7)
{
set_function(func_name);
push2lua(m_lua,p1); push2lua(m_lua,p2); push2lua(m_lua,p3); push2lua(m_lua,p4); push2lua(m_lua,p5); push2lua(m_lua,p6); push2lua(m_lua,p7);
return call(7);
}
template<typename FUNC,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6,typename P7,typename P8>
bool operator()(FUNC const& func_name,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6,P7 p7,P8 p8)
{
set_function(func_name);
push2lua(m_lua,p1); push2lua(m_lua,p2); push2lua(m_lua,p3); push2lua(m_lua,p4); push2lua(m_lua,p5); push2lua(m_lua,p6); push2lua(m_lua,p7); push2lua(m_lua,p8);
return call(8);
}
template<typename FUNC,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6,typename P7,typename P8,typename P9>
bool operator()(FUNC const& func_name,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6,P7 p7,P8 p8,P9 p9)
{
set_function(func_name);
push2lua(m_lua,p1); push2lua(m_lua,p2); push2lua(m_lua,p3); push2lua(m_lua,p4); push2lua(m_lua,p5); push2lua(m_lua,p6); push2lua(m_lua,p7); push2lua(m_lua,p8); push2lua(m_lua,p9);
return call(9);
}
template<typename FUNC,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6,typename P7,typename P8,typename P9,typename P10>
bool operator()(FUNC const& func_name,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6,P7 p7,P8 p8,P9 p9,P10 p10)
{
set_function(func_name);
push2lua(m_lua,p1); push2lua(m_lua,p2); push2lua(m_lua,p3); push2lua(m_lua,p4); push2lua(m_lua,p5); push2lua(m_lua,p6); push2lua(m_lua,p7); push2lua(m_lua,p8); push2lua(m_lua,p9); push2lua(m_lua,p10);
return call(10);
}
void bind_script(lua_State* const lua);
private:
bool call(int const& count);
void set_function(std::string const& func);
void set_function(Lua_func_ref const& func);
lua_State* m_lua;
};
}
#endif
| [
"luozhiyuan@ea6f400c-e855-0410-84ee-31f796524d81"
] | [
[
[
1,
116
]
]
] |
9922db60529941221af034bfc00c4ff6392fe1ab | 8d4f274d6b71556bbc9791568f6cc770957eb4c2 | /azkarpopupdialog.h | 72199448b10e1ffbd6043588a047dc32e28ed70c | [] | no_license | SudaNix/Al-Moazen | 5582ea41b5f129f900e73d1997453069d5b0f694 | 10a358435ae1c3f3af3a3239ba4dea3d5175454c | refs/heads/master | 2020-04-17T23:40:26.216423 | 2009-08-27T22:42:16 | 2009-08-27T22:42:16 | 290,362 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 713 | h | #ifndef AZKARPOPUPDIALOG_H
#define AZKARPOPUPDIALOG_H
#include <QDialog>
#include <phonon/mediaobject.h>
#include <phonon/audiooutput.h>
class QTextEdit;
class AzkarPopupDialog:public QDialog
{
Q_OBJECT
public:
AzkarPopupDialog(QWidget* =0);
~AzkarPopupDialog();
void display();
void displayAzkarAlsabah();
void displayAzkarAlmasa();
void displayAzkarAlmasaSound();
void displayAzkarAlsabahSound();
void setCloseAfter(int value);
protected:
void timerEvent(QTimerEvent*);
private:
QTextEdit* textEdit;
int timer;
int closeAfter;
Phonon::MediaObject* player;
Phonon::AudioOutput* audioOutput;
};
#endif // AZKARPOPUPDIALOG_H | [
"[email protected]"
] | [
[
[
1,
38
]
]
] |
cb8a393f5c7bd7047f9ce9386bc2fe1dc507f601 | 3699ee70db05a390ce86e64e09e779263510df6f | /branches/Char Server/charserver.h | fb2b02ceede19dc20f9294f684604e9c737c1d69 | [] | no_license | trebor57/osprosedev | 4fbe6616382ccd98e45c8c24034832850054a4fc | 71852cac55df1dbe6e5d6f4264a2a2e6fd3bb506 | refs/heads/master | 2021-01-13T01:50:47.003277 | 2008-05-14T17:48:29 | 2008-05-14T17:48:29 | 32,129,756 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,146 | h | /*
Open Source Rose Online Team - http://osroseon.to.md/
note: the Server is develop with erose source server + eich source
*/
#ifndef __ROSE_SERVERS__
#define __ROSE_SERVERS__
#include <time.h>
#include "../common/sockets.h"
#include "datatypes.h"
#define ClearItem(i) { i.durability=0; i.itemnum=0; i.itemtype=0; i.lifespan=0; i.refine=0; }
// Clent class
class CCharClient : public CClientSocket
{
public:
CCharClient ( ); // constructor
~CCharClient ( ); // destructor
// User information
UINT userid;
bool platinum;
char username[17];
char password[33];
UINT accesslevel;
UINT channel;
// Character information
char charname[17];
UINT clanid;
int clan_rank;
UINT level;
UINT job;
UINT charid;
bool isLoggedIn;
bool returnedfromWS;
bool logout;
vector<CFriendList*> FriendList;
};
// Server class
class CCharServer : public CServerSocket
{
public:
CCharServer ( string );
~CCharServer( );
CCharClient* CreateClientSocket( );
void DeleteClientSocket( CClientSocket* thisclient );
void LoadEncryption( );
void OnClientDisconnect( CClientSocket* thisclient );
bool OnServerReady( );
void LoadConfigurations( char* );
bool OnReceivePacket( CClientSocket* thisclient, CPacket* P );
// Extra functions
CChanels* GetChannelByID( UINT id );
CCharClient* GetClientByUserID( UINT id );
CCharClient* GetClientByID( UINT id );
CCharClient* GetClientByName( char *name );
CCharClient* GetClientByUserName( char *username );
CClans* GetClanByID( int id );
unsigned long int GetServerTime( );
// Community functions
bool ChangeMessengerStatus (CCharClient* thisclient, CCharClient* otherclient, int status);
bool pakMessengerManager ( CCharClient* thisclient, CPacket* P );
bool pakMessengerChat ( CCharClient* thisclient, CPacket* P );
// Clan Functions
bool SendClanInfo (CCharClient* thisclient);
bool ChangeClanStatus (CCharClient* thisclient, CCharClient* otherclient, int channel);
bool SendToClanMembers( int clanid,CPacket* pak );
bool UpdateClanWindow( int clanid );
bool pakClanMembers ( CCharClient* thisclient );
bool pakClanManager ( CCharClient* thisclient, CPacket* P );
bool pakClanChat ( CCharClient* thisclient, CPacket* P );
bool ClanLogout ( CCharClient* thisclient );
bool pakUploadCM ( CCharClient* thisclient, CPacket* P );
bool pakDownloadCM( CCharClient* thisclient, CPacket* P );
bool pakClanIconTime( CCharClient* thisclient, CPacket* P );
// General Packets
bool pakUpdateLevel( CCharClient* thisclient, CPacket* P );
bool pakDoIdentify( CCharClient* thisclient, CPacket* P );
bool pakGetCharacters( CCharClient* thisclient, CPacket* P );
bool pakRequestWorld( CCharClient* thisclient, CPacket* P );
bool pakCreateChar( CCharClient* thisclient, CPacket* P );
bool pakDeleteChar( CCharClient* thisclient, CPacket* P );
bool pakWSReady ( CCharClient* thisclient, CPacket* P );
bool pakWSCharSelect ( CCharClient* thisclient, CPacket* P );
bool pakLoginConnected ( CCharClient* thisclient, CPacket* P );
bool pakLoginDSClient( CCharClient* thisclient, CPacket* P );
bool pak7e5 ( CCharClient* thisclient, CPacket* P );
bool pakChatrooms ( CCharClient* thisclient, CPacket* P );
// Variables
string filename;
vector <CClans*> ClanList;
vector <CChanels*> ChannelList;
//Login
SOCKET lsock; // Socket to Login
char* lct; // Encryption table for login server
CDatabase* DB;
};
void StartSignal( );
void StopSignal( );
void HandleSignal( int num );
extern class CCharServer* GServer;
#endif
| [
"remichael@004419b5-314d-0410-88ab-2927961a341b"
] | [
[
[
1,
113
]
]
] |
114ce8f570eb94b15b2a1e5329c2ce8730dd3854 | 4275e8a25c389833c304317bdee5355ed85c7500 | /KylTek/LinkedList.h | 72f502af95eaea0b21ce9aaaa024d561a05c1f7a | [] | 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 | 2,833 | h | #pragma once
#ifndef LINKEDLIST_H_
#define LINKEDLIST_H_
/* - Linked Lists -
- Functions -
Constructor - creates the first node for the system
Destructor - Clears the list (deleting everything inside), then deletes itself
first (void) - returns the first node* in the list
add (object) - Adds a new object to the end of the list.
remove (node) - deletes the object at the specified node and moves the list back, returns the previous node, or the first node in list
clear (void) - deletes everything inside of the list
- usage syntax -
Node = list->first();
while(Node!=NULL){
object = Node->object;
object -> step(); //the objects reoccuring event
if (object->isDead) //deadflag set?
delete object;
Node = list->remove(Node);
Node = Node -> next;
}
*/
template <class _Ty>
struct Node{
Node* next;
Node* prev;
_Ty* object;
int sortID;
};
template <class _Ty>
class LinkedList{
private:
Node<_Ty>* firstnode;
Node<_Ty>* lastnode;
int size;
public:
LinkedList(){
Init();
}
~LinkedList(){
clear();
}
void Init(){
firstnode = new Node<_Ty>();
lastnode = firstnode;
size=0;
}
//Returns First Node
Node<_Ty>* first(){
return firstnode;
}
//Adds a new element to the array
void add(_Ty* _object){
if (_object!=NULL){
if (lastnode -> object != NULL){
lastnode->next = new Node<_Ty>();
lastnode->next->prev = lastnode;
lastnode = lastnode->next;
lastnode -> next = NULL;
lastnode -> object = _object;
}else{
lastnode -> object = _object;
}
size++;
}
}
int getSize(){
return size;
}
//Parses the node to be deleted
Node<_Ty>* remove(Node<_Ty>* _node){
if (_node == lastnode){
if (_node == firstnode){
delete lastnode;
firstnode = new Node<_Ty>;
lastnode = firstnode;
--size;
return firstnode;
}else{
lastnode = lastnode ->prev;
delete lastnode ->next;
lastnode ->next = NULL;
--size;
return lastnode;
}
}else if (_node == firstnode){
if (firstnode->next!=NULL){
firstnode = firstnode ->next;
delete firstnode ->prev;
firstnode ->prev = NULL;
--size;
return firstnode;
}else{
--size;
delete firstnode;
firstnode = new Node<_Ty>;
}
}else{
Node<_Ty>* returnnode = _node ->prev;
returnnode ->next = _node ->next;
returnnode ->next->prev = returnnode;
delete _node;
--size;
return returnnode;
}
return NULL;
}
//permantly deletes everything inside the array
void clear(){
Node<_Ty>* clear = firstnode;
while(clear!=NULL){
Node<_Ty>* remove = clear;
clear = clear->next;
delete remove;
}
firstnode = NULL;
lastnode = NULL;
clear = NULL;
size=0;
}
};
#endif | [
"Sean Stacey@localhost"
] | [
[
[
1,
136
]
]
] |
381caf919f0376d802b9b73ef0b7f3d483e015af | accd6e4daa3fc1103c86d245c784182e31681ea4 | /HappyHunter/Core/TexturePrinter.cpp | 160481a74aa2eb7cdb076f4a275eee375fcaa565 | [] | no_license | linfuqing/zero3d | d87ad6cf97069aea7861332a9ab8fc02b016d286 | cebb12c37fe0c9047fb5b8fd3c50157638764c24 | refs/heads/master | 2016-09-05T19:37:56.213992 | 2011-08-04T01:37:36 | 2011-08-04T01:37:36 | 34,048,942 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 7,605 | cpp | #include "StdAfx.h"
#include "TexturePrinter.h"
using namespace zerO;
CTexturePrinter::CTexturePrinter(void) :
CResource(RESOURCE_TEXTUREPRINTER),
m_pSavedRenderSurface(NULL),
m_pSavedDepthStencilSurface(NULL),
m_pDepthStencilSurface(NULL),
m_nCurrentTexture(-1)
{
}
CTexturePrinter::~CTexturePrinter(void)
{
Destroy();
}
zerO::UINT CTexturePrinter::AddTexture(zerO::UINT uWidth, zerO::UINT uHeight, D3DFORMAT Format)
{
LPTEXTURE pTexture;
DEBUG_NEW( pTexture, TEXTURE(uWidth, uHeight, Format) );
m_TextureList.push_back(pTexture);
return m_TextureList.size() - 1;
}
zerO::UINT CTexturePrinter::AddTexture(CTexture::RESET pfnReset)
{
LPTEXTURE pTexture;
DEBUG_NEW( pTexture, TEXTURE(pfnReset) );
m_TextureList.push_back(pTexture);
return m_TextureList.size() - 1;
}
void ResetTexture(
zerO::UINT& uWidth,
zerO::UINT& uHeight,
D3DFORMAT & Format)
{
uWidth = GAMEHOST.GetBackBufferSurfaceDesc().Width;
uHeight = GAMEHOST.GetBackBufferSurfaceDesc().Height;
Format = GAMEHOST.GetBackBufferSurfaceDesc().Format;
}
zerO::UINT CTexturePrinter::AddTexture()
{
return AddTexture(ResetTexture);
}
bool CTexturePrinter::Create()
{
if(m_pSavedRenderSurface || m_pSavedDepthStencilSurface || m_pDepthStencilSurface)
return false;
HRESULT hr;
hr = DEVICE.CreateDepthStencilSurface(
GAMEHOST.GetBackBufferSurfaceDesc().Width,
GAMEHOST.GetBackBufferSurfaceDesc().Height,
GAMEHOST.GetDeviceSettings().pp.AutoDepthStencilFormat,
GAMEHOST.GetBackBufferSurfaceDesc().MultiSampleType,
GAMEHOST.GetBackBufferSurfaceDesc().MultiSampleQuality,
FALSE,
&m_pDepthStencilSurface,
NULL );
if( SUCCEEDED(hr) )
{
hr = DEVICE.GetRenderTarget( 0, &m_pSavedRenderSurface );
if( FAILED(hr) )
{
DEBUG_WARNING(hr);
return false;
}
hr = DEVICE.GetDepthStencilSurface( &m_pSavedDepthStencilSurface );
if( FAILED(hr) )
{
DEBUG_WARNING(hr);
return false;
}
}
DEBUG_RELEASE(m_pDepthStencilSurface);
m_pDepthStencilSurface = NULL;
return true;
}
bool CTexturePrinter::Disable()
{
DEBUG_RELEASE(m_pSavedRenderSurface);
DEBUG_RELEASE(m_pSavedDepthStencilSurface);
DEBUG_RELEASE(m_pDepthStencilSurface);
m_pSavedRenderSurface = NULL;
m_pSavedDepthStencilSurface = NULL;
m_pDepthStencilSurface = NULL;
for(std::vector<LPTEXTURE>::iterator i = m_TextureList.begin(); i != m_TextureList.end(); i ++)
{
DEBUG_RELEASE( (*i)->pSurface );
(*i)->pSurface = NULL;
}
return true;
}
bool CTexturePrinter::Restore()
{
HRESULT hr;
RECT Rect;
DEBUG_RELEASE(m_pSavedRenderSurface);
DEBUG_RELEASE(m_pSavedDepthStencilSurface);
DEBUG_RELEASE(m_pDepthStencilSurface);
hr = DEVICE.CreateDepthStencilSurface(
GAMEHOST.GetBackBufferSurfaceDesc().Width,
GAMEHOST.GetBackBufferSurfaceDesc().Height,
GAMEHOST.GetDeviceSettings().pp.AutoDepthStencilFormat,
GAMEHOST.GetBackBufferSurfaceDesc().MultiSampleType,
GAMEHOST.GetBackBufferSurfaceDesc().MultiSampleQuality,
FALSE,
&m_pDepthStencilSurface,
NULL );
if( FAILED(hr) )
{
DEBUG_WARNING(hr);
return false;
}
hr = DEVICE.GetRenderTarget( 0, &m_pSavedRenderSurface );
if( FAILED(hr) )
{
DEBUG_WARNING(hr);
return false;
}
hr = DEVICE.GetDepthStencilSurface( &m_pSavedDepthStencilSurface );
if( FAILED(hr) )
{
DEBUG_WARNING(hr);
return false;
}
for(std::vector<LPTEXTURE>::iterator i = m_TextureList.begin(); i != m_TextureList.end(); i ++)
{
DEBUG_RELEASE( (*i)->pSurface );
hr = (*i)->Texture.GetTexture()->GetSurfaceLevel( 0, &( (*i)->pSurface ) );
if( FAILED(hr) )
{
DEBUG_WARNING(hr);
return false;
}
hr = (*i)->pSurface->GetDesc(&(*i)->Desc);
if( FAILED(hr) )
{
DEBUG_WARNING(hr);
return false;
}
Rect.left = 0;
Rect.top = 0;
Rect.right = (*i)->Desc.Width;
Rect.bottom = (*i)->Desc.Height;
hr = DEVICE.ColorFill( (*i)->pSurface, &Rect, 0 );
}
return true;
}
void CTexturePrinter::Begin()
{
DEVICE.SetDepthStencilSurface(m_pDepthStencilSurface);
}
void CTexturePrinter::End(ENDFLAG Flag)
{
if(TEST_FLAG(Flag, RENDER_SURFACE) && m_nCurrentTexture != - 1)
{
DEVICE.SetRenderTarget(0, m_pSavedRenderSurface);
m_nCurrentTexture = - 1;
}
if( TEST_FLAG(Flag, DEPTH_STENCIL_SURFACE) )
DEVICE.SetDepthStencilSurface(m_pSavedDepthStencilSurface);
}
void CTexturePrinter::Activate(zerO::UINT uTextureIndex, zerO::UINT32 uClearFlag, zerO::ARGBCOLOR Color)
{
if( uTextureIndex >= m_TextureList.size() )
return;
HRESULT hr = DEVICE.SetRenderTarget(0, m_TextureList[uTextureIndex]->pSurface);
if( FAILED(hr) )
{
DEBUG_WARNING(hr);
return;
}
if(uClearFlag)
{
hr = DEVICE.Clear(0, NULL, uClearFlag, Color, 1.0f, 0);
if( FAILED(hr) )
{
DEBUG_WARNING(hr);
return;
}
}
m_nCurrentTexture = uTextureIndex;
}
void CTexturePrinter::Draw(zerO::UINT uTextureIndex)
{
if( uTextureIndex >= m_TextureList.size() )
return;
LPTEXTURE pTexture = m_TextureList[uTextureIndex];
DEVICE.SetRenderState(D3DRS_ZENABLE, FALSE);
DEVICE.SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
DEVICE.SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
DEVICE.SetRenderTarget(0, pTexture->pSurface);
FLOAT fWidth = static_cast< float >(pTexture->Desc.Width ) - 0.5f;
FLOAT fHeight = static_cast< float >(pTexture->Desc.Height) - 0.5f;
VERTEX Vertices[4];
Vertices[0].Position = D3DXVECTOR4(- 0.5f, - 0.5f, 0.0f, 1.0f);
Vertices[0].UV = D3DXVECTOR2(0.0f, 0.0f);
Vertices[1].Position = D3DXVECTOR4(fWidth, - 0.5f, 0.0f, 1.0f);
Vertices[1].UV = D3DXVECTOR2(1.0f, 0.0f);
Vertices[2].Position = D3DXVECTOR4(- 0.5f, fHeight, 0.0f, 1.0f);
Vertices[2].UV = D3DXVECTOR2(0.0f, 1.0f);
Vertices[3].Position = D3DXVECTOR4(fWidth, fHeight, 0.0f, 1.0f);
Vertices[3].UV = D3DXVECTOR2(1.0f, 1.0f);
DEVICE.SetVertexShader(NULL);
DEVICE.SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
DEVICE.DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, Vertices, sizeof(VERTEX) );
DEVICE.SetRenderState(D3DRS_ZENABLE, TRUE);
DEVICE.SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
m_nCurrentTexture = uTextureIndex;
}
bool CTexturePrinter::Stretch(zerO::INT nDestinationIndex, zerO::INT nSourceIndex)
{
zerO::INT nTextureSize = m_TextureList.size();
if(nTextureSize <= nDestinationIndex || nTextureSize <= nSourceIndex)
{
DEBUG_WARNING("Erorr index.");
return false;
}
HRESULT hr = DEVICE.StretchRect(nSourceIndex < 0 ? m_pSavedRenderSurface : m_TextureList[nSourceIndex]->pSurface, NULL, nDestinationIndex < 0 ? m_pSavedRenderSurface : m_TextureList[nDestinationIndex]->pSurface, NULL, D3DTEXF_NONE);
if( FAILED(hr) )
{
DEBUG_WARNING(hr);
return false;
}
return true;
}
bool CTexturePrinter::RnederToTexture(zerO::INT nTextureIndex)
{
return Stretch(nTextureIndex, m_nCurrentTexture);
}
bool CTexturePrinter::Destroy()
{
DEBUG_RELEASE(m_pSavedRenderSurface);
DEBUG_RELEASE(m_pSavedDepthStencilSurface);
DEBUG_RELEASE(m_pDepthStencilSurface);
m_pSavedRenderSurface = NULL;
m_pSavedDepthStencilSurface = NULL;
m_pDepthStencilSurface = NULL;
for(std::vector<LPTEXTURE>::iterator i = m_TextureList.begin(); i != m_TextureList.end(); i ++)
{
DEBUG_RELEASE( (*i)->pSurface );
DEBUG_DELETE(*i);
}
m_TextureList.clear();
return true;
} | [
"[email protected]"
] | [
[
[
1,
324
]
]
] |
36c70dc40f43db9087d59467ab1150c6586fecae | 0dba4a3016f3ad5aa22b194137a72efbc92ab19e | /a2e/src/camera.h | 33c3bebb56251dcbc1134bb18f670c9048f3e517 | [] | no_license | BackupTheBerlios/albion2 | 11e89586c3a2d93821b6a0d3332c1a7ef1af6abf | bc3d9ba9cf7b8f7579a58bc190a4abb32b30c716 | refs/heads/master | 2020-12-30T10:23:18.448750 | 2007-01-26T23:58:42 | 2007-01-26T23:58:42 | 39,515,887 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,990 | h | /*
* 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 Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __CAMERA_H__
#define __CAMERA_H__
#include <iostream>
#include <cmath>
#include <SDL/SDL.h>
#include "msg.h"
#include "core.h"
#include "engine.h"
#include "event.h"
using namespace std;
#include "win_dll_export.h"
#define PIOVER180 0.01745329252
/*! @class camera
* @brief a2e camera functions
* @author flo
* @todo more functions
*
* the camera class
*/
class A2E_API camera
{
public:
camera(engine* e);
~camera();
void run();
void set_position(float x, float y, float z);
void set_rotation(float x, float y, float z);
vertex3* get_position();
vertex3* get_rotation();
void set_rotation_speed(float speed);
float get_rotation_speed();
void set_cam_speed(float speed);
float get_cam_speed();
void set_cam_input(bool state);
void set_mouse_input(bool state);
bool get_cam_input();
bool get_mouse_input();
void set_flip(bool state);
bool get_flip();
vertex3* get_direction();
protected:
msg* m;
core* c;
event* evt;
engine* e;
vertex3* position;
vertex3* rotation;
vertex3* direction;
float up_down;
float rotation_speed;
float cam_speed;
bool cam_input;
bool mouse_input;
bool flip;
};
#endif
| [
"[email protected]"
] | [
[
[
1,
88
]
]
] |
79ed0084d62e54a3ea6514c503d7e01c197b6f71 | 545c50f3a7928e445f74802e9c42a0ac2c8f57c4 | /Orientation.h | bfb6b329b4d6b90021c01b2ba4ce438c39b4d139 | [] | no_license | zcm/WVU-VectorDesign | f0094046988c839df098d669d24d789b871d9d42 | 5fcf9b622db7b10775e6f25faa598791de4909ec | refs/heads/master | 2021-07-09T19:21:05.684565 | 2010-04-23T18:47:23 | 2010-04-23T18:47:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,068 | h | #ifndef VECTOR_ORIENTATION_H
#define VECTOR_ORIENTATION_H
#ifdef WIN32
#include <windows.h>
#endif
//#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/freeglut.h>
#include <cv.h>
#include <highgui.h>
#include "Renderable.h"
#include "PixelPadder.h"
#include "ObjectDetector.h"
#include "ServerSocket.h"
#include "TCPSocket.h"
#include "NetworkException.h"
class Orientation : public Renderable
{
public:
Orientation();
Orientation(int deviceID);
Orientation(int deviceID, GLuint frameTexture);
~Orientation();
virtual void initialize();
virtual void initialize(int deviceID);
virtual void initialize(int deviceID, GLuint frameTexture);
virtual void setDevice(int deviceID);
virtual void pauseFaceDetection();
virtual void resumeFaceDetection();
virtual void uploadTexture(IplImage* img);
virtual void render() const;
virtual void idle(const int elapsed);
protected:
virtual void regenerateTexture();
virtual void configureTextureParameters() const;
virtual void restartCapture();
virtual void releaseCapture();
virtual void performRotation(const float vector[3]) const;
void calculateFaceVector(IplImage* img, CvBox2D& face_box);
void calculateFaceVector(IplImage* img, CvRect& face_rect);
void calculateFaceVector(IplImage* img, float fx, float fy, float fsize);
private:
int _deviceID, _timeSpentTracking;
bool _usingPadding, _useSubImagePadding;
float _aspectRatio, _paddingScaleFactor;
bool _useFaceDetection, _trackingEnabled;
bool _hosting, _clienting;
PixelPadder* _padder;
ObjectDetector* _detector;
CvRect _trackWindow;
CvHistogram* _hist;
CvCapture* _capture;
ServerSocket* _receiver;
TCPSocket* _caller;
GLuint _frameTex;
CvFont _font, _smallfont;
IplImage* _img;
IplImage* _chat;
IplImage* _backproject;
IplImage* _hsv;
IplImage* _hue;
IplImage* _mask;
float _faceVector[3];
};
#endif
| [
"[email protected]",
"ben@580bed88-caa2-44de-b298-61e134d9bb2a"
] | [
[
[
1,
3
],
[
5,
5
],
[
10,
13
],
[
16,
17
],
[
23,
51
],
[
53,
57
],
[
60,
62
],
[
64,
71
]
],
[
[
4,
4
],
[
6,
9
],
[
14,
15
],
[
18,
22
],
[
52,
52
],
[
58,
59
],
[
63,
63
]
]
] |
f263bf210108a5762acd538d8b45b175cc46b749 | 8fcfa439a6c1ea4753ace06b87d7d49f55bdd1e6 | /tgeInterpreter.cpp | 461b458fda880f5c20e99bc6c7901ee024a6b70c | [] | no_license | blacksqr/tge-cpp | bb3e0216830ace08d9381d14bd1916994009ba19 | e51f36dcc46790ccadab2f2dcaa0849970b57eb3 | refs/heads/master | 2021-01-10T14:14:34.381325 | 2010-03-22T12:37:36 | 2010-03-22T12:37:36 | 48,471,490 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,653 | cpp | #include "tgeInterpreter.h"
#include "tgeCmd.h"
#include <exception>
// Unnamed namespace
namespace
{
int _unknownCmdProc(
ClientData clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
tge::String name(Tcl_GetString(objv[1]));
tge::Interpreter* interpreter = static_cast<tge::Interpreter*>(clientData);
interpreter->_panic("Unknown command : " + name);
return tge::TGE_OK;
}
}
namespace tge
{
UnknownCmd* Interpreter::msUnknownCmd = NULL;
Interpreter::Interpreter(void) :
mInterp(Tcl_CreateInterp())
{
Tcl_CreateObjCommand(
mInterp,
"unknown",
_unknownCmdProc,
(void*)this,
NULL
);
// Set recursion limit to 50
Tcl_SetRecursionLimit(mInterp, 50);
}
Interpreter::~Interpreter(void)
{
// Tcl_DeleteInterp(mInterp);
}
Result Interpreter::eval(Obj* objPtr)
{
if (objPtr==NULL)
{
String errmsg;
errmsg.append("Evaluation of NULL Tcl Object exception. ").
append(" Interpreter::eval(Obj* objPtr) ");
throw tge::except(errmsg);
}
//
Result r((CmdStatus)Tcl_EvalObjEx(mInterp, objPtr->_getTclObj(), 0));
if (r.hasError())
{
throw tge::except(r.getErroMsg());
}
else
{
}
return r;
}
Result Interpreter::eval(const String& script)
{
Result r((CmdStatus)Tcl_Eval(mInterp, script.c_str()));
if (r.hasError())
{
throw tge::except(r.getErroMsg());
}
else
{
}
return r;
}
bool Interpreter::commandExists(const String& cmdName)
{
Tcl_CmdInfo inf;
int r = Tcl_GetCommandInfo(mInterp, cmdName.c_str(), &inf);
return (r!=0);
}
bool Interpreter::registerCmd(const String& name, Cmd* cmdObject)
{
if ( commandExists(name) )
{
_panic("Command " + name+" already registered.");
return false;
}
Tcl_Command tc = Tcl_CreateObjCommand(
mInterp,
name.c_str(),
_objCmdProc,
(void*)this,
NULL
);
cmdObject->_setInterp(this);
mInternalCmdList.insert(std::make_pair(name, cmdObject));
return true;
}
bool Interpreter::unregisterCmd(const String& name)
{
CmdMap::iterator it = mInternalCmdList.find(name);
if (it!=mInternalCmdList.end())
{
mInternalCmdList.erase(it);
}
return TCL_OK==Tcl_DeleteCommand(mInterp, name.c_str());
}
void Interpreter::setVar(const String& name, const Obj& obj)
{
// char * buf = Tcl_Alloc(obj._getTclObj()->length);
Tcl_Obj* to = Tcl_DuplicateObj(obj._getTclObj());
Tcl_IncrRefCount(to);
Tcl_SetVar2Ex(mInterp, name.c_str(), NULL, to , TCL_GLOBAL_ONLY);
}
Obj& Interpreter::getVar(const String& name)
{
static Obj obj;
Tcl_Obj* to = Tcl_GetVar2Ex(mInterp, name.c_str(), NULL, TCL_GLOBAL_ONLY);
obj.setInterp(this);
if (to==NULL)
{
String errmsg;
errmsg.append("Variable ").append(name).append(" not exits.");
throw tge::except( errmsg );
obj.setNull();
}
else
{
obj._setTclObj(to);
}
return obj;
}
void Interpreter::removeVar(const String& name)
{
Tcl_UnsetVar(mInterp, name.c_str(), TCL_GLOBAL_ONLY);
}
Cmd* Interpreter::getUnknownCmd(void)
{
if (NULL==msUnknownCmd)
{
msUnknownCmd = new UnknownCmd;
}
return msUnknownCmd;
}
void Interpreter::_panic(const String& msg, const String& wh ) throw (except)
{
// Tcl_Panic("Internal Error: %s", msg.c_str());
char szTmp[256];
sprintf(szTmp, "TGE Error : %s - [%s]", msg.c_str(), wh.c_str());
throw tge::except(szTmp);
}
Tcl_Interp* Interpreter::_interp(void)
{
return mInterp;
}
int Interpreter::_objCmdProc(
ClientData clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *const objv[])
{
String name(Tcl_GetString(objv[0]));
Interpreter* interpreter = static_cast<Interpreter*>(clientData);
Cmd* cmd = interpreter->mInternalCmdList[name];
if ( NULL == cmd)
{
cmd = getUnknownCmd();
}
// 1 ~ N as list
Obj arg1;
Obj arg2;
Obj obj;
arg1.setNull();
arg2.setNull();
obj.setNull();
size_t count = 0;
if (objc>1)
{
arg1._setTclObj(Tcl_DuplicateObj(objv[1]));
count = 0;
}
if (objc>2)
{
arg2._setTclObj(Tcl_DuplicateObj(objv[2]));
count = 0;
}
if (objc>3)
{
count = objc - 3;
// Here new list is a bottleneck!! TODO : optimise this in future
Tcl_Obj* nlist = Tcl_DuplicateObj ( Tcl_NewListObj(count, &objv[3]) );
obj._setTclObj(nlist);
}
assert(interp == interpreter->_interp()) ;
CmdStatus ccc = cmd->run(name, arg1, arg2, obj, count);
interpreter->mStatus = ccc;
return ccc;
}
} | [
"jeffreybian@99f00b9d-c5df-25c8-5ecf-577a790fa8fa"
] | [
[
[
1,
219
]
]
] |
85cdaf4c87626fbd69c59159798dd354b71432ff | d7910157c6f2b58f159ec8dc2634e0acfe6d678e | /qtdemo/letteritem.cpp | 8cba1733521d7f36e08f62083042f11f98d608a6 | [] | no_license | TheProjecter/qtdemo-plugin | 7699b19242aacea9c5b2c741e615e6b1e62c6c11 | 4db5ffe7e8607e01686117820ce1fcafb72eb311 | refs/heads/master | 2021-01-19T06:30:22.017229 | 2010-02-05T06:36:25 | 2010-02-05T06:36:25 | 43,904,026 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,555 | cpp | /****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation ([email protected])
**
** This file is part of the demonstration applications of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you have questions regarding the use of this file, please contact
** Nokia at [email protected].
** $QT_END_LICENSE$
**
****************************************************************************/
#include <cmath>
#include "letteritem.h"
#include "colors.h"
LetterItem::LetterItem(char letter, QGraphicsScene *scene, QGraphicsItem *parent) : DemoItem(scene, parent), letter(letter)
{
useSharedImage(QString(__FILE__) + letter);
}
LetterItem::~LetterItem()
{
}
QImage *LetterItem::createImage(const QMatrix &matrix) const
{
QRect scaledRect = matrix.mapRect(QRect(0, 0, 25, 25));
QImage *image = new QImage(scaledRect.width(), scaledRect.height(), QImage::Format_ARGB32_Premultiplied);
image->fill(0);
QPainter painter(image);
painter.scale(matrix.m11(), matrix.m22());
painter.setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
painter.setPen(Qt::NoPen);
if (Colors::useEightBitPalette){
painter.setBrush(QColor(102, 175, 54));
painter.drawEllipse(0, 0, 25, 25);
painter.setFont(Colors::tickerFont());
painter.setPen(QColor(255, 255, 255));
painter.drawText(10, 15, QString(this->letter));
}
else {
QLinearGradient brush(0, 0, 0, 25);
brush.setSpread(QLinearGradient::PadSpread);
brush.setColorAt(0.0, QColor(102, 175, 54, 200));
brush.setColorAt(1.0, QColor(102, 175, 54, 60));
painter.setBrush(brush);
painter.drawEllipse(0, 0, 25, 25);
painter.setFont(Colors::tickerFont());
painter.setPen(QColor(255, 255, 255, 255));
painter.drawText(10, 15, QString(this->letter));
}
return image;
}
| [
"douyongwang@152bb772-114e-11df-9f54-17e475596acb"
] | [
[
[
1,
85
]
]
] |
ee9b423449221ff6e14255b55fe87e68de5029aa | d2af4bec60dd35fc40f4784f378efcf5acd13522 | /Hooking Engine/H2/H2/hookmanager.h | bca273a0cba59d011e78ea6e939e806742c0424b | [] | no_license | sankio/H2Sandboxbackup | 6a07f335ae5e1897ef07bcf564d68850c843d1f6 | bd45cfb47a0c0522c568162641fe7886675a0f39 | refs/heads/master | 2021-01-10T22:06:17.940401 | 2011-06-24T11:57:22 | 2011-06-24T11:57:22 | 1,947,055 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 640 | h | #include <windows.h>
#include "hookedapi.h"
#include <DbgHelp.h>
#include <TlHelp32.h>
#define Hook_Specified_Module 0
#define Hook_All_Module 1
#define GetAddressOfInjectedFunction(cast, x, y) (cast) ( (DWORD_PTR)(x) - (DWORD_PTR)(y))
class HookManager {
MyHookedAPI *MyHookedAPIList;
public:
HookManager::HookManager();
PROC HookManager::HookInOneModule(HMODULE, LPCSTR, PROC, PROC);
void HookManager::HookInManyModule();
BOOL HookManager::AddHookList(LPCSTR ,LPCSTR , LPCSTR, PROC );
void HookManager::GetHookList();
BOOL HookManager::DoHook(int);
PROC HookManager::HookExportTable(LPCSTR, PROC, PROC);
}; | [
"[email protected]"
] | [
[
[
1,
20
]
]
] |
78349e8a1639386048e5ee784145b826af472752 | 8795dfb3d7f0561167d4b260d2022becec461728 | /fitnessdatastore.h | ae65f0dcec61ecc75de08da3e8f895f9a956a9d9 | [] | no_license | thesjg/SJGFitness | acf54ea4fb92a34290189d507c9f6ce0bbbf4f3d | a40172c33269072a8fe5f8bdd38374a9ca1f3dc6 | refs/heads/master | 2021-01-23T13:41:36.986013 | 2011-11-02T13:45:34 | 2011-11-02T13:45:34 | 2,694,955 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 257 | h | #ifndef FITNESSDATASTORE_H
#define FITNESSDATASTORE_H
#include <QObject>
class FitnessDataStore : public QObject
{
Q_OBJECT
public:
FitnessDataStore(QObject *parent);
~FitnessDataStore();
private:
};
#endif // FITNESSDATASTORE_H
| [
"[email protected]"
] | [
[
[
1,
18
]
]
] |
2be9a32b3cd39c54557e1e39fee252f6ef9302f5 | 545c50f3a7928e445f74802e9c42a0ac2c8f57c4 | /Socket.h | 64aae423ffe4627605b25da20b04c47662cc892c | [] | no_license | zcm/WVU-VectorDesign | f0094046988c839df098d669d24d789b871d9d42 | 5fcf9b622db7b10775e6f25faa598791de4909ec | refs/heads/master | 2021-07-09T19:21:05.684565 | 2010-04-23T18:47:23 | 2010-04-23T18:47:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 894 | h | #ifndef __TP_SOCKET_H__
#define __TP_SOCKET_H__
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <WinSock2.h>
#include <Ws2tcpip.h>
#include <WSPiApi.h>
#include <string>
#include "NetworkException.h"
using std::string;
class Socket
{ public:
Socket();
Socket(string const ip, string const port);
virtual void connectTo(string const ip, string const port);
virtual void connectSocket() = 0;
virtual int sendData(char const * const data, int length) = 0;
virtual int receiveData(char * const data, int length) = 0;
virtual void disconnect() = 0;
protected:
virtual void setIp(string const ip);
virtual void setPort(string const port);
virtual const string getIp();
virtual const string getPort();
private:
string _ip;
string _port;
WSADATA wsaData;
};
#endif
| [
"ben@580bed88-caa2-44de-b298-61e134d9bb2a",
"[email protected]"
] | [
[
[
1,
5
],
[
7,
9
],
[
11,
41
]
],
[
[
6,
6
],
[
10,
10
]
]
] |
f30c02d0988e703af398d658df63277a1caf4f84 | 77d0b0ac21a9afdf667099c3cad0f9bbb483dc25 | /include/about.h | 64aa5b167a5dfbb3724a0dca33a3ecbaf66b1741 | [] | no_license | martinribelotta/oneshot | 21e218bbdfc310bad4a531dcd401ad28625ead75 | 81bde2718b6dac147282cce8a1c945187b0b2ccf | refs/heads/master | 2021-05-27T23:29:43.732068 | 2010-05-24T04:36:10 | 2010-05-24T04:36:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 161 | h | #ifndef ONESHOT_ABOUT_H
#define ONESHOT_ABOUT_H
#include <iglu/twindow.h>
class AboutOneSHOT: public TWindow {
public:
AboutOneSHOT();
};
#endif
| [
"[email protected]"
] | [
[
[
1,
11
]
]
] |
3a057acfc022ca0a37f954e09b1ff990ec0acf90 | c2abb873c8b352d0ec47757031e4a18b9190556e | /src/vortex-client/ApplicationManager.h | 49f8b8ae27c55d256e176592709f8f95664cd50f | [] | no_license | twktheainur/vortex-ee | 70b89ec097cd1c74cde2b75f556448965d0d345d | 8b8aef42396cbb4c9ce063dd1ab2f44d95e994c6 | refs/heads/master | 2021-01-10T02:26:21.913972 | 2009-01-30T12:53:21 | 2009-01-30T12:53:21 | 44,046,528 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 408 | h | /*
* ChatManager.h
*
* Created on: Nov 22, 2008
* Author: twk
*/
#ifndef APPLICATIONMANAGER_H_
#define APPLICATIONMANAGER_H_
#include "../common/Thread.h"
#include "Application.h"
class Client;
class ApplicationManager: public Thread
{
private:
Application * application;
Client * cli;
public:
ApplicationManager(Client * cli);
void execute(void * arg);
};
#endif
| [
"twk.theainur@37e2baaa-b253-11dd-9381-bf584fb1fa83"
] | [
[
[
1,
25
]
]
] |
33d60245f6d710d20d1181e3341f4ea2ab27e89e | 27bde5e083cf5a32f75de64421ba541b3a23dd29 | /source/Util/Tuner.cpp | d6551d8939ae0213d1bb5cea9fab6c070c9037df | [] | no_license | jbsheblak/fatal-inflation | 229fc6111039aff4fd00bb1609964cf37e4303af | 5d6c0a99e8c4791336cf529ed8ce63911a297a23 | refs/heads/master | 2021-03-12T19:22:31.878561 | 2006-10-20T21:48:17 | 2006-10-20T21:48:17 | 32,184,096 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,433 | cpp | //---------------------------------------------------
// Name: Game : Tuner
// Desc: allows for tuning of variables
// Author: John Sheblak
// Contact: [email protected]
//---------------------------------------------------
#include "Tuner.h"
#include "../FileIO.h"
namespace Game
{
bool Tuner::LoadTuners( const char* szFile )
{
mTunerVariables.clear();
FILE* file = fopen( szFile, "r+t" );
if( !file )
return false;
std::string line;
while( FileUtils::GetNextLine( line, file ) )
{
TokenArray tokens;
Split( line, tokens, ' ' );
if( tokens.size() < 3 )
continue;
std::string tk0 = tokens[0];
std::string tk2 = tokens[2];
mTunerVariables[ tk0 ] = tk2;
}
fclose(file);
return true;
}
int32_t Tuner::GetInt( const char* name )
{
VariableMap::iterator itr;
if( (itr = mTunerVariables.find(name) ) != mTunerVariables.end() )
{
return atoi( itr->second.c_str() );
}
return 0;
}
F32 Tuner::GetFloat( const char* name )
{
VariableMap::iterator itr;
if( (itr = mTunerVariables.find(name) ) != mTunerVariables.end() )
{
return (F32)atof( itr->second.c_str() );
}
return 0;
}
uint32_t Tuner::GetUint( const char* name )
{
VariableMap::iterator itr;
if( (itr = mTunerVariables.find(name) ) != mTunerVariables.end() )
{
return (uint32_t)atoi( itr->second.c_str() );
}
return 0;
}
std::string Tuner::GetString( const char* name )
{
VariableMap::iterator itr;
if( (itr = mTunerVariables.find(name) ) != mTunerVariables.end() )
{
return itr->second;
}
return "";
}
Tuner* Tuner::GetTuner()
{
static Tuner sTuner;
return &sTuner;
}
void Tuner::Split( std::string str, TokenArray& tokenArray, char delim )
{
char buffer[256];
int c = 0;
for( uint32_t i = 0; i < str.length(); ++i )
{
//check for comments
if( i+1 < str.length() && str[i] == '/' && str[i+1] == '/' )
break;
if( str[i] == delim && c != 0 )
{
buffer[c] = '\0';
tokenArray.push_back( std::string(buffer) );
c = 0;
}
else if( str[i] != delim && str[i] != '\n' && str[i] != '\t' && str[i] != '\r' )
{
buffer[c] = str[i];
++c;
}
}
//do we need to push the end string?
if( c > 0 )
{
buffer[c] = '\0';
tokenArray.push_back( buffer );
}
}
}; //end Game
| [
"jbsheblak@5660b91f-811d-0410-8070-91869aa11e15"
] | [
[
[
1,
119
]
]
] |
f7e20ceab3b352e3ba051afcecf7819d9506abaf | b2d46af9c6152323ce240374afc998c1574db71f | /cursovideojuegos/theflostiproject/3rdParty/boost/libs/spirit/fusion/test/tuple_iterator_tests.cpp | b52b37e48e26a52237943794a077c5f10ebbddf1 | [
"BSL-1.0"
] | permissive | bugbit/cipsaoscar | 601b4da0f0a647e71717ed35ee5c2f2d63c8a0f4 | 52aa8b4b67d48f59e46cb43527480f8b3552e96d | refs/heads/master | 2021-01-10T21:31:18.653163 | 2011-09-28T16:39:12 | 2011-09-28T16:39:12 | 33,032,640 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,973 | cpp | /*=============================================================================
Copyright (c) 2001-2003 Joel de Guzman
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)
==============================================================================*/
#include <iostream>
#include <boost/test/minimal.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/spirit/fusion/sequence/tuple.hpp>
#include <boost/spirit/fusion/iterator/tuple_iterator.hpp>
#include <boost/spirit/fusion/iterator/deref.hpp>
#include <boost/spirit/fusion/iterator/next.hpp>
#include <boost/spirit/fusion/iterator/prior.hpp>
#include <boost/spirit/fusion/iterator/equal_to.hpp>
#include <boost/spirit/fusion/sequence/begin.hpp>
#include <boost/spirit/fusion/sequence/end.hpp>
#include <boost/spirit/fusion/sequence/tuple_element.hpp>
#include <boost/spirit/fusion/sequence/get.hpp>
//#include <boost/spirit/fusion/distance.hpp>
//#include <boost/spirit/fusion/advance.hpp>
//#include <boost/spirit/fusion/get_pointer.hpp>
//#include <boost/spirit/fusion/value_of.hpp>
//#include <boost/spirit/fusion/pointer_of.hpp>
//#include <boost/spirit/fusion/reference_of.hpp>
//#include <boost/spirit/fusion/is_readable.hpp>
//#include <boost/spirit/fusion/is_writable.hpp>
//#include <boost/spirit/fusion/category_of.hpp>
int
test_main(int, char*[])
{
using namespace boost::fusion;
using namespace boost;
/// Testing the tuple_iterator
{ // testing deref, next, prior, begin, end
char const* s = "Hello";
typedef tuple<int, char, double, char const*> tuple_type;
tuple_type t(1, 'x', 3.3, s);
tuple_iterator<0, tuple_type> i(t);
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
// ?%$# VC6 I don't know why this is needed! $$$LOOK$$$
next(i);
#endif
BOOST_TEST(*i == 1);
BOOST_TEST(*next(i) == 'x');
BOOST_TEST(*next(next(i)) == 3.3);
BOOST_TEST(*next(next(next(i))) == s);
next(next(next(next(i)))); // end
#ifdef FUSION_TEST_COMPILE_FAIL
next(next(next(next(next(i))))); // past the end: must not compile
#endif
BOOST_TEST(*prior(next(next(next(i)))) == 3.3);
BOOST_TEST(*prior(prior(next(next(next(i))))) == 'x');
BOOST_TEST(*prior(prior(prior(next(next(next(i)))))) == 1);
BOOST_TEST(*begin(t) == 1);
BOOST_TEST(*prior(end(t)) == s);
*i = 3;
BOOST_TEST(*i == 3);
BOOST_TEST(*i == get<0>(t));
}
{ // Testing const tuple and const tuple_iterator
char const* s = "Hello";
typedef tuple<int, char, double, char const*> const tuple_type;
tuple_type t(1, 'x', 3.3, s);
tuple_iterator<0, tuple_type> i(t);
BOOST_TEST(*i == 1);
BOOST_TEST(*next(i) == 'x');
BOOST_TEST(*begin(t) == 1);
BOOST_TEST(*prior(end(t)) == s);
#ifdef FUSION_TEST_COMPILE_FAIL
*i = 3; // must not compile
#endif
}
{ // Testing tuple equality
typedef tuple<int, char, double, char const*> tuple_type;
typedef tuple_iterator<0, tuple_type> ti1;
typedef tuple_iterator<0, tuple_type const> ti2;
BOOST_STATIC_ASSERT((meta::equal_to<ti1 const, ti1>::value));
BOOST_STATIC_ASSERT((meta::equal_to<ti1, ti1 const>::value));
BOOST_STATIC_ASSERT((meta::equal_to<ti1, ti2>::value));
BOOST_STATIC_ASSERT((meta::equal_to<ti1 const, ti2>::value));
BOOST_STATIC_ASSERT((meta::equal_to<ti1, ti2 const>::value));
BOOST_STATIC_ASSERT((meta::equal_to<ti1 const, ti2 const>::value));
}
//
// { // Testing distance
//
// typedef tuple<int, char, double, char const*> tuple_type;
// tuple_type t(1, 'x', 3.3, "Hello");
//
// BOOST_STATIC_ASSERT((result_of_distance<
// tuple_iterator<0, tuple_type>
// , tuple_iterator<4, tuple_type> >::type::value == 4));
//
// BOOST_TEST(distance(begin(t), end(t)).value == 4);
// }
//
// { // Testing advance
//
// typedef tuple<int, char, double, char const*> tuple_type;
// tuple_type t(1, 'x', 3.3, "Hello");
//
// BOOST_TEST(*advance<0>(begin(t)) == get<0>(t));
// BOOST_TEST(*advance<1>(begin(t)) == get<1>(t));
// BOOST_TEST(*advance<2>(begin(t)) == get<2>(t));
// BOOST_TEST(*advance<3>(begin(t)) == get<3>(t));
//
// BOOST_TEST(*advance<-1>(end(t)) == get<3>(t));
// BOOST_TEST(*advance<-2>(end(t)) == get<2>(t));
// BOOST_TEST(*advance<-3>(end(t)) == get<1>(t));
// BOOST_TEST(*advance<-4>(end(t)) == get<0>(t));
//
// BOOST_TEST(&*advance<0>(begin(t)) == &get<0>(t));
// BOOST_TEST(&*advance<1>(begin(t)) == &get<1>(t));
// BOOST_TEST(&*advance<2>(begin(t)) == &get<2>(t));
// BOOST_TEST(&*advance<3>(begin(t)) == &get<3>(t));
// }
//
#if !BOOST_WORKAROUND(__BORLANDC__, <= 0x551)
// #$%&@ Borland IS SO DUMB!!! #$%&@
{
typedef tuple<int, int> tuple_type;
typedef meta::begin<tuple_type>::type begin_type;
typedef meta::end<tuple_type>::type end_type;
typedef meta::next<begin_type>::type i1;
typedef meta::next<i1>::type i2;
BOOST_STATIC_ASSERT((is_same<end_type, i2>::value));
}
#endif
{ // Testing constructing tuples from iterators
tuple<int, char, double> t1(1, 'x', 3.3);
tuple<long, int, double> t2(begin(t1));
BOOST_TEST(get<0>(t2) == get<0>(t1));
BOOST_TEST(get<1>(t2) == get<1>(t1));
BOOST_TEST(get<2>(t2) == get<2>(t1));
tuple<char, double> t3(next(begin(t1)));
BOOST_TEST(get<0>(t3) == get<1>(t1));
BOOST_TEST(get<1>(t3) == get<2>(t1));
tuple<double> t4(prior(end(t1)));
BOOST_TEST(get<0>(t4) == get<2>(t1));
tuple<char, char, char, char, char, char, char, char, char> t5;
tuple<int, int, int, int, int, int, int, int, int> t6(begin(t5));
(void)t6;
}
{ // Testing tuple iterator value, reference, pointer, is_readable,
// is_writable, meta::deref, result_of_get_pointer
typedef tuple<int, char&> tuple_type;
typedef tuple_iterator<0, tuple_type> i0;
typedef tuple_iterator<1, tuple_type> i1;
typedef tuple_iterator<1, tuple_type const> i2;
BOOST_STATIC_ASSERT((
is_same<tuple_element<0, tuple_type>::type, int>::value));
BOOST_STATIC_ASSERT((
is_same<tuple_element<1, tuple_type>::type, char&>::value));
// BOOST_STATIC_ASSERT((
// is_same<category_of<i0>::type, random_access_traversal_tag>::value));
//
// BOOST_STATIC_ASSERT(is_readable<i0>::value);
// BOOST_STATIC_ASSERT(is_writable<i0>::value);
// BOOST_STATIC_ASSERT(is_readable<i2>::value);
// BOOST_STATIC_ASSERT(!is_writable<i2>::value);
BOOST_STATIC_ASSERT((is_same<meta::deref<i0>::type, int&>::value));
BOOST_STATIC_ASSERT((is_same<meta::deref<i1>::type, char&>::value));
// BOOST_STATIC_ASSERT((is_same<result_of_get_pointer<i0>::type, int*>::value));
// BOOST_STATIC_ASSERT((is_same<result_of_get_pointer<i1>::type, char*>::value));
//
// BOOST_STATIC_ASSERT((is_same<value_of<i0>::type, int>::value));
// BOOST_STATIC_ASSERT((is_same<value_of<i1>::type, char&>::value));
//
// BOOST_STATIC_ASSERT((is_same<reference_of<i0>::type, int&>::value));
// BOOST_STATIC_ASSERT((is_same<reference_of<i1>::type, char&>::value));
//
// BOOST_STATIC_ASSERT((is_same<pointer_of<i0>::type, int*>::value));
// BOOST_STATIC_ASSERT((is_same<pointer_of<i1>::type, char*>::value));
}
return 0;
}
| [
"ohernandezba@71d53fa2-cca5-e1f2-4b5e-677cbd06613a"
] | [
[
[
1,
212
]
]
] |
4f05dc7bc7c553ef027696ba1e17bcab4dafe484 | 26b6f15c144c2f7a26ab415c3997597fa98ba30a | /sdp/src/PhoneField.cpp | a5449dac8f75461d9397552f7ec21a07d64065b2 | [] | no_license | wangscript007/rtspsdk | fb0b52e63ad1671e8b2ded1d8f10ef6c3c63fddf | f5b095f0491e5823f50a83352945acb88f0b8aa0 | refs/heads/master | 2022-03-09T09:25:23.988183 | 2008-12-27T17:23:31 | 2008-12-27T17:23:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,927 | cpp | /*****************************************************************************
// SDP Parser Classes
//
// Phone Field Class
//
// revision of last commit:
// $Rev$
// author of last commit:
// $Author$
// date of last commit:
// $Date$
//
// created by Argenet {[email protected]}
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
******************************************************************************/
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Includes
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include "PhoneField.h"
using std::string;
namespace SDP {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// PhoneField class implementation
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Public methods
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PhoneField :: PhoneField()
: Field("p", "")
{
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PhoneField :: PhoneField(const string & value)
: Field("p", value)
{
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PhoneField :: PhoneField(const PhoneField & phoneField)
: Field(phoneField)
{
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PhoneField & PhoneField :: operator=(const PhoneField & phoneField)
{
Field::operator=(phoneField);
return *this;
}
} // namespace SDP
| [
"[email protected]",
"[email protected]"
] | [
[
[
1,
84
]
],
[
[
85,
85
]
]
] |
e8b090659885e8765f9d203e180a8965130c79dc | b5ab57edece8c14a67cc98e745c7d51449defcff | /Captain's Log/MainGame/Source/Managers/CCamera.cpp | c81138a2448e16500b7f2d727462cb203e4d99b7 | [] | no_license | tabu34/tht-captainslog | c648c6515424a6fcdb628320bc28fc7e5f23baba | 72d72a45e7ea44bdb8c1ffc5c960a0a3845557a2 | refs/heads/master | 2020-05-30T15:09:24.514919 | 2010-07-30T17:05:11 | 2010-07-30T17:05:11 | 32,187,254 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 535 | cpp | #include "precompiled_header.h"
#include "CCamera.h"
CCamera::CCamera()
{
m_fX = 0;
m_fY = 0;
m_VelX = 0;
m_VelY = 0;
}
RECT CCamera::GetCollisionRect()
{
RECT output;
output.left = (int)m_fX;
output.top = (int)m_fY;
output.right = output.left + CGame::GetInstance()->GetScreenWidth();
output.bottom = output.top + CGame::GetInstance()->GetScreenHeight();
return output;
}
void CCamera::Update( float fElapsedTime )
{
m_fX = m_fX + m_VelX * fElapsedTime;
m_fY = m_fY + m_VelY * fElapsedTime;
}
| [
"notserp007@34577012-8437-c882-6fb8-056151eb068d",
"dpmakin@34577012-8437-c882-6fb8-056151eb068d"
] | [
[
[
1,
3
],
[
12,
19
]
],
[
[
4,
11
],
[
20,
26
]
]
] |
7c649bc981bc7e50ec73abc6c291093a285c13a3 | 8fa4334746f35b9103750bb23ec2b8d38e93cbe9 | /coding/qt/forum/forum/const.cpp | 4cb973cd6dda8aba249488a835787ab1fb23ece5 | [] | no_license | zhzengj/testrepo | 620b22b2cf1e8ff10274a9d0c6491816cecaec3b | daf8bd55fd347220f07bfd7d15b02b01a516479b | refs/heads/master | 2016-09-11T00:50:57.846600 | 2011-10-16T07:59:48 | 2011-10-16T07:59:48 | 2,365,453 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 797 | cpp | /********************************************************************
created: 13:6:2011 21:18
file base: const.cpp
author: zhzengj
*********************************************************************/
#include "stdafx.h"
#include "const.h"
namespace ZJ
{
const wchar_t * XmlAccountId = L"account";
const wchar_t * XmlTianyaForumId = L"tianya";
//pub func
bool openXml(QDomDocument & doc, const QString & fileName)
{
QFile file(fileName);
QString errStr;
if (!file.open(QIODevice::ReadOnly))
{
qCritical() << "Open file failure\n";
return FALSE;
}
if (!doc.setContent(&file, &errStr))
{
file.close();
qCritical() << "xml set content failure : " << errStr << endl;
return FALSE;
}
file.close();
return TRUE;
}
} | [
"[email protected]"
] | [
[
[
1,
35
]
]
] |
c3b3c763eb0be3071b4d1d984ce017568fdf591b | 842997c28ef03f8deb3422d0bb123c707732a252 | /src/uslsext/USInterpolate.cpp | 2795e1e8bf57f8ad15cf18936d5881621d5b3195 | [] | no_license | bjorn/moai-beta | e31f600a3456c20fba683b8e39b11804ac88d202 | 2f06a454d4d94939dc3937367208222735dd164f | refs/heads/master | 2021-01-17T11:46:46.018377 | 2011-06-10T07:33:55 | 2011-06-10T07:33:55 | 1,837,561 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,236 | cpp | // Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved.
// http://getmoai.com
#include "pch.h"
#include <math.h>
#include <uslsext/USTrig.h>
#include <uslsext/USInterpolate.h>
//================================================================//
// USInterpolate
//================================================================//
//----------------------------------------------------------------//
float USInterpolate::Curve ( u32 mode, float t ) {
switch ( mode ) {
case kEaseIn:
t = t - 1.0f;
return 1.0f - ( t * t * t * t );
case kEaseOut:
return t * t * t * t;
case kFlat:
return ( t < 1.0f ) ? 0.0f : 1.0f;
case kLinear:
return t;
case kSharpEaseIn:
t = t - 1.0f;
return 1.0f - ( t * t * t * t * t * t * t * t );
case kSharpEaseOut:
return t * t * t * t * t * t;
case kSharpSmooth:
if ( t < 0.5f ) {
t = t * 2.0f;
return ( t * t ) * 0.5f;
}
t = ( t * 2.0f ) - 2.0f;
return ( 2.0f - ( t * t * t * t * t * t )) * 0.5f;
case kSmooth:
if ( t < 0.5f ) {
t = t * 2.0f;
return ( t * t * t * t ) * 0.5f;
}
t = ( t * 2.0f ) - 2.0f;
return ( 2.0f - ( t * t * t * t )) * 0.5f;
case kSoftEaseIn:
t = t - 1.0f;
return 1.0f - ( t * t );
case kSoftEaseOut:
return t * t;
case kSoftSmooth:
if ( t < 0.5f ) {
t = t * 2.0f;
return ( t * t ) * 0.5f;
}
t = ( t * 2.0f ) - 2.0f;
return ( 2.0f - ( t * t )) * 0.5f;
}
return 0.0f;
}
//----------------------------------------------------------------//
float USInterpolate::Interpolate ( u32 mode, float x0, float x1, float t ) {
if ( mode == kFlat ) {
return ( t < 1.0f ) ? x0 : x1;
}
float s = Curve ( mode, t );
return x0 + (( x1 - x0 ) * s );
}
//----------------------------------------------------------------//
float USInterpolate::Interpolate ( u32 mode, float x0, float x1, float t, float w ) {
float v0 = Interpolate ( mode, x0, x1, t );
if ( w == 1.0f ) {
return v0;
}
float v1 = Interpolate ( kLinear, x0, x1, t );
return Interpolate ( kLinear, v1, v0, w );
}
| [
"[email protected]",
"Patrick@agile.(none)"
] | [
[
[
1,
16
],
[
80,
86
],
[
89,
89
],
[
92,
93
],
[
95,
106
]
],
[
[
17,
79
],
[
87,
88
],
[
90,
91
],
[
94,
94
]
]
] |
34b68fbc012ec3f5848448f286cf79ccc7589420 | 95afbe3ce494b70bb76232bae55c002532902abd | /fr/recognition/recognizer/eigenfacerecognizer.h | 8ac9ad8625bb2122588b0aff5070faf7eaf9b700 | [] | no_license | bergmansj/sparks | fd701ddc6d863cfb774d6e4a202950e71724067e | 25e040edef405f49e86c12983d41c4f54f953e40 | refs/heads/master | 2016-09-06T09:40:43.940984 | 2011-07-29T16:37:39 | 2011-07-29T16:37:39 | 2,078,013 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,869 | h | #ifndef COGNITION_RECOGNIZER_EIGENFACERECOGNIZER_H
#define COGNITION_RECOGNIZER_EIGENFACERECOGNIZER_H
// Implementation based on http://code.google.com/p/visual-control/
// License is unknown, but open-source.
//Implementation based on http://www.cognotics.com/opencv/servo_2007_series/part_5/index.html
//by Robin Hewitt, many thanks for his great articles
//suppress warinings generated by the cvaux library that this class uses
#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_WARNINGS
#include <map>
#include <opencv/cv.h>
#include "recognizer.h"
namespace cognition
{
/*!
* \brief Implementation of the Eigenface face recognition algorithm
* it uses old style C functions of the OpenCV library, based on
* http://www.cognotics.com/opencv/servo_2007_series/part_5/index.html
* by Robin Hewitt.
*
* \todo upgrade internals to the OpenCV C++ api (cv::Mat and cv::PCA)
* \author Christophe Hesters 29-1-2011
*/
class EigenfaceRecognizer : public Recognizer
{
public:
EigenfaceRecognizer(void);
virtual ~EigenfaceRecognizer(void);
/*!
* \brief Adds a training image path to the training set of known images
* after you have added 2 or more images, call train to learn and
* set yourself up for recognition. All images must be the same size!
*
* \note warning! method does not check if the filename exists and the application
* can crash if it does not exist! this check should be added (in train?)!
*
* \param filename the path where to find the image (all of the same size!)
* \param name the name you want to attach to the image
* \return bool true if the path is added succesfully
*/
bool addTrainingImage(const std::string &filename, const std::string &name);
/*!
* \brief starts the learning process on all the known images that
* are added trough addTrainingImage. You can add more training images
* after training, but you have to call train again. While training
* you cannot use recognize()!
*
* \note make sure all image paths exist
*
* \return bool true if trained, false otherwise
*/
bool train();
/*!
* \brief does recognition on the face, and returns the most likely match.
* This face must grayscale and be exactly the same size as the training
* images.
*
* \param face the matrix containing the face
* \return string name of closest match in the set of training images
*/
std::string recognize(cv::Mat &face);
/*!
* \brief does recognition on the face, and returns the most likely match.
* This face must grayscale and be exactly the same size as the training
* images.
*
* \return size_t the number of registered training images
*/
std::size_t numTrainingImages(){ return trainingImages.size(); }
protected:
bool loadTrainingImages();
//principal component analysis
void doPCA();
void freeMemory(int fromIndex = -1);
int findNearestNeighbor(float *projectedTestImage);
typedef std::map<std::string, std::string> StringMap;
//filename - > name
StringMap trainingImages;
//index - > filename,name (since trainingImages can change)
typedef std::pair<std::string, std::string> StringPair;
std::vector<StringPair> recognitionDescriptor;
IplImage **images; //array of trained images
int numTrainedImages; //number of training images used
int numEigenvalues; //number of eigenvalues
IplImage **eigenVectors; //array of eigenvectors
IplImage *averageImage; //the average image of the training set
CvMat *eigenvalues; //eigenvalues matrix
CvMat *projectedTrainImage; //projected image matrix
};
}
#endif //COGNITION_RECOGNIZER_EIGENFACERECOGNIZER_H
| [
"[email protected]"
] | [
[
[
1,
109
]
]
] |
cf87f0f711ed4f12323af66bb494b663ec28227e | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/mpl/test/list.cpp | 8bb36b85cbade866b6b01224cdab83fef5463860 | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,880 | cpp |
// Copyright Aleksey Gurtovoy 2000-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/test/list.cpp,v $
// $Date: 2004/09/02 15:41:35 $
// $Revision: 1.4 $
#include <boost/mpl/list.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/aux_/test.hpp>
MPL_TEST_CASE()
{
typedef list0<> l0;
typedef list1<char> l1;
typedef list2<char,long> l2;
typedef list9<char,char,char,char,char,char,char,char,char> l9;
MPL_ASSERT_RELATION(size<l0>::value, ==, 0);
MPL_ASSERT_RELATION(size<l1>::value, ==, 1);
MPL_ASSERT_RELATION(size<l2>::value, ==, 2);
MPL_ASSERT_RELATION(size<l9>::value, ==, 9);
MPL_ASSERT(( empty<l0> ));
MPL_ASSERT_NOT(( empty<l1> ));
MPL_ASSERT_NOT(( empty<l2> ));
MPL_ASSERT_NOT(( empty<l9> ));
MPL_ASSERT(( is_same<front<l1>::type,char> ));
MPL_ASSERT(( is_same<front<l2>::type,char> ));
MPL_ASSERT(( is_same<front<l9>::type,char> ));
}
MPL_TEST_CASE()
{
typedef list2<char,long> l2;
typedef begin<l2>::type i1;
typedef next<i1>::type i2;
typedef next<i2>::type i3;
MPL_ASSERT(( is_same<deref<i1>::type,char> ));
MPL_ASSERT(( is_same<deref<i2>::type,long> ));
MPL_ASSERT(( is_same< i3, end<l2>::type > ));
}
MPL_TEST_CASE()
{
typedef list0<> l0;
typedef push_front<l0,char>::type l1;
MPL_ASSERT(( is_same<front<l1>::type,char> ));
typedef push_front<l1,long>::type l2;
MPL_ASSERT(( is_same<front<l2>::type,long> ));
}
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
] | [
[
[
1,
68
]
]
] |
79b4eec26c63e42b703c76a0451ac95f23cefb16 | 41371839eaa16ada179d580f7b2c1878600b718e | /UVa/Volume I/00104.cpp | bb7bee7f9de8c4e309cacd58b54df22532960a30 | [] | no_license | marinvhs/SMAS | 5481aecaaea859d123077417c9ee9f90e36cc721 | 2241dc612a653a885cf9c1565d3ca2010a6201b0 | refs/heads/master | 2021-01-22T16:31:03.431389 | 2009-10-01T02:33:01 | 2009-10-01T02:33:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,112 | cpp | /////////////////////////////////
// 00104 - Arbitrage
/////////////////////////////////
#include<cstdio>
#include<cstring>
unsigned int curr;
double t[20][20][21], temp;
char found, i, j, k, p[20][20][21], w;
bool sm = 0;
const char *NASE = "no arbitrage sequence exists";
void trace(char x, char y, char l){
if(l) trace(x,p[x][y][l],l-1),printf(" %u",y+1);
else printf("%u",x+1);
}
int main(void){
while(scanf("%u",&curr)!=EOF){
memset(p,0,sizeof(p));
for(i = 0; i < curr; t[i][i][1] = 1.00,i++)
for(j = 0; j < curr; j++){
for(k = 2; k <= curr; k++) t[i][j][k] = 0;
if(i != j)
scanf("%lf",&t[i][j][1]);
}
found = 0;
for(w = 2; w <= curr; w++){
for(k = 0; k < curr; k++){
for(i = 0; i < curr; i++){
for(j = 0; j < curr; j++)
if(t[i][j][w] < t[i][k][w-1]*t[k][j][1])
t[i][j][w] = t[i][k][w-1]*t[k][j][1],
p[i][j][w] = k;
if(t[i][i][w] > 1.01){
found = i; break;
}
}
if(found){
trace(found,found,w);
putchar('\n');
break;
}
}
if(found) break;
}
if(!found) puts(NASE);
}
return 0;
}
| [
"[email protected]"
] | [
[
[
1,
47
]
]
] |
eef7524893f0c116141b08ae1c2c00a8ceae0d0b | 36bf908bb8423598bda91bd63c4bcbc02db67a9d | /Include/CProgressBar.h | eae76287e878c96762f755a5a8bd95bb36d02e4f | [] | 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,712 | h | /*
CProgressBar.h
Classe base per il controllo a progresso (SDK).
Luca Piergentili, 24/08/00
[email protected]
*/
#ifndef _CPROGRESSBAR_H
#define _CPROGRESSBAR_H 1
#include "window.h"
class CProgressBar
{
public:
CProgressBar()
{
m_hWnd = (HWND)NULL;
m_nMin = m_nMax = 0;
}
virtual ~CProgressBar()
{
if(m_hWnd)
{
if(::IsWindow(m_hWnd))
::DestroyWindow(m_hWnd);
m_hWnd = (HWND)NULL;
}
}
inline BOOL Create(HWND hWnd,HINSTANCE hInstance,int x,int y,int nWidth,int nHeigth)
{
m_hWnd = ::CreateWindow( PROGRESS_CLASS,
"Position",
WS_CHILD | WS_VISIBLE,
x,y,nWidth,nHeigth,
hWnd,
(HMENU)NULL,
hInstance,
NULL
);
return(m_hWnd!=NULL);
}
inline BOOL Attach(HWND hWnd,UINT id)
{
m_hWnd = ::GetDlgItem(hWnd,id);
return(m_hWnd!=NULL);
}
inline void SetPos(int nPos)
{
if(m_hWnd!=(HWND)NULL)
::SendMessage(m_hWnd,PBM_SETPOS,nPos,0L);
}
inline void SetRange(int iMin = 0,int iMax = 10)
{
if(m_hWnd!=(HWND)NULL)
{
m_nMin = iMin;
m_nMax = iMax;
::SendMessage(m_hWnd,PBM_SETRANGE,0L,MAKELONG(m_nMin,m_nMax));
}
}
inline void SetStep(LONG iStep = 1L)
{
if(m_hWnd!=(HWND)NULL)
::SendMessage(m_hWnd,PBM_SETSTEP,iStep,0L);
}
inline void StepIt(void)
{
if(m_hWnd!=(HWND)NULL)
::SendMessage(m_hWnd,PBM_STEPIT,0L,0L);
}
inline void Show(void)
{
if(m_hWnd!=(HWND)NULL)
::ShowWindow(m_hWnd,SW_SHOW);
}
inline void Hide(void)
{
if(m_hWnd!=(HWND)NULL)
::ShowWindow(m_hWnd,SW_HIDE);
}
private:
HWND m_hWnd;
int m_nMin;
int m_nMax;
};
#endif // _CPROGRESSBAR_H
| [
"[email protected]"
] | [
[
[
1,
98
]
]
] |
bf0c4de4f28263dbf3f28fca58f4bd96719ba064 | 27d5670a7739a866c3ad97a71c0fc9334f6875f2 | /CPP/Targets/WayFinder/symbian-r6/PedestrianPositionControl.cpp | a56cd47f2d7c34c68d9ec7fb5f0c18fa64dec0bc | [
"BSD-3-Clause"
] | permissive | ravustaja/Wayfinder-S60-Navigator | ef506c418b8c2e6498ece6dcae67e583fb8a4a95 | 14d1b729b2cea52f726874687e78f17492949585 | refs/heads/master | 2021-01-16T20:53:37.630909 | 2010-06-28T09:51:10 | 2010-06-28T09:51:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,202 | cpp | /*
Copyright (c) 1999 - 2010, Vodafone Group Services Ltd
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the Vodafone Group Services Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "PedestrianPositionControl.h"
#include <gdi.h>
#include <aknsutils.h>
#include <gulcolor.h>
#include <aknutils.h>
#include <w32std.h>
CPedestrianPositionControl*
CPedestrianPositionControl::NewLC(CCoeControl* aParent,
const TRect& aRect,
const TSize& aCenterSize,
const TRgb& aColor,
const TRgb& aBgColor)
{
CPedestrianPositionControl* self = new (ELeave)
CPedestrianPositionControl(aColor, aBgColor);
CleanupStack::PushL(self);
self->ConstructL(aParent, aRect, aCenterSize);
return self;
}
CPedestrianPositionControl*
CPedestrianPositionControl::NewL(CCoeControl* aParent,
const TRect& aRect,
const TSize& aCenterSize,
const TRgb& aColor,
const TRgb& aBgColor)
{
CPedestrianPositionControl* self =
CPedestrianPositionControl::NewLC(aParent, aRect, aCenterSize,
aColor, aBgColor);
CleanupStack::Pop(self);
return self;
}
void CPedestrianPositionControl::ConstructL(CCoeControl* aParent,
const TRect& aRect,
const TSize& aCenterSize)
{
if (!aParent) {
// Create a window for this control
CreateWindowL();
} else {
// We got an valid parent, we should not be window owning
SetContainerWindowL(*aParent);
}
SetRect(aRect);
//iCenterRect = aRect;
//iCenterRect.Shrink(aRect.Height()/3, aRect.Width()/3);
iCenterRect = TRect(aRect.Center(), aCenterSize);
iCenterRect.Move(-(iCenterRect.Width() >>1 ),
-(iCenterRect.Height() >> 1));
if (!aParent) {
// Activate the window, which makes it ready to be drawn
ActivateL();
}
}
CPedestrianPositionControl::CPedestrianPositionControl(const TRgb& aColor,
const TRgb& aBgColor) :
iColor(TRgb(aColor.Internal(), aColor.Alpha())),
iBgColor(TRgb(aBgColor.Internal(), aBgColor.Alpha())),
iLineSize(TSize(1, 1))
{
}
CPedestrianPositionControl::~CPedestrianPositionControl()
{
}
void CPedestrianPositionControl::PositionChanged()
{
// Get the complete rect of this control
TRect rect = Rect();
TPoint dMove((rect.Width() >> 1) - (iCenterRect.Width() >> 1),
(rect.Height() >> 1) - (iCenterRect.Height() >> 1));
iCenterRect.SetRect(TPoint(rect.iTl + dMove), iCenterRect.Size());
}
void CPedestrianPositionControl::SizeChanged()
{
// Get the complete rect of this control
TRect rect = Rect();
}
void CPedestrianPositionControl::SetCenter(TPoint aCenter)
{
TRect rect = Rect();
TPoint dMove((rect.Width() >> 1), (rect.Height() >> 1));
this->SetPosition(aCenter - dMove);
}
void CPedestrianPositionControl::Draw(const TRect& /*aRect*/) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();
TRect rect(Rect());
gc.SetClippingRect(rect);
gc.SetPenColor(iColor);
gc.SetPenSize(iLineSize);
gc.SetBrushColor(iBgColor);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawEllipse(rect);
//rect.Shrink(5, 5);
//gc.SetBrushStyle(CGraphicsContext::ENullBrush);
//gc.DrawEllipse(rect);
gc.SetBrushColor(iColor);
//gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawEllipse(iCenterRect);
}
| [
"[email protected]"
] | [
[
[
1,
129
]
]
] |
f7242e718936e03522046c8db92873076c833b2b | 5f48a255bae33b09fdc35c56a09c175534f79ac0 | /CommandPlugin/CommandPlugin.cpp | a0885ddce47f44fda4df6bff9c8c97746f458168 | [] | no_license | reyoung/SimpleCppPluginSystem | 5f8e0a12f223ca29088585b8817259aa96d66944 | 357ffbb7a9d3efc98b09b42a47d687451a2d3bb6 | refs/heads/master | 2016-09-06T01:26:20.412191 | 2011-07-02T14:20:33 | 2011-07-02T14:20:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 933 | cpp | #include "CommandPlugin.h"
#include <iostream>
#include "CommandPool.h"
using namespace std;
CommandPlugin::CommandPlugin(void)
{
}
CommandPlugin::~CommandPlugin(void)
{
}
bool CommandPlugin::initialize( int argc,char** argv )
{
m_file = "Command.xml";
return true;
}
void CommandPlugin::invoke( std::map<std::string,Variant>* inout)
{
std::map<std::string,Variant>& retv = *inout;
if (retv.find("CMDConfigFilename")!=retv.end())
{
retv["CMDConfigFilename"]=getCMDConfigFileName();
}
}
void CommandPlugin::initialized()
{
map<string,Variant> param;
param["deserialize"] = m_file;
PluginManager::Invoke("SerializationPlugin",¶m);
CommandPool::cmdset = new CommandPool();
CommandPool::Instance()->m_data = param["deserialize"];
CommandPool::Instance()->pack();
}
std::string CommandPlugin::getCMDConfigFileName() const
{
return m_file;
}
DECLARE_PLUGIN(CommandPlugin); | [
"[email protected]"
] | [
[
[
1,
43
]
]
] |
eec8a528b29f71732cfef9fa1ce1b69585c71e3e | 5ac13fa1746046451f1989b5b8734f40d6445322 | /minimangalore/Nebula2/code/nebula2/src/character/ncharskinrenderer.cc | 5af60ad3f4e65a363b3a381d8da3e70ad175a25c | [] | no_license | moltenguy1/minimangalore | 9f2edf7901e7392490cc22486a7cf13c1790008d | 4d849672a6f25d8e441245d374b6bde4b59cbd48 | refs/heads/master | 2020-04-23T08:57:16.492734 | 2009-08-01T09:13:33 | 2009-08-01T09:13:33 | 35,933,330 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,497 | cc | //------------------------------------------------------------------------------
// ncharskinrenderer.cc
// (C) 2003 RadonLabs GmbH
//------------------------------------------------------------------------------
#include "character/ncharskinrenderer.h"
#include "gfx2/nshader2.h"
//------------------------------------------------------------------------------
/**
*/
nCharSkinRenderer::nCharSkinRenderer() :
initialized(false),
inBegin(false),
charSkeleton(0)
{
// empty
}
//------------------------------------------------------------------------------
/**
*/
nCharSkinRenderer::~nCharSkinRenderer()
{
// empty
}
//------------------------------------------------------------------------------
/**
This initialized the character skin renderer.
*/
bool
nCharSkinRenderer::Initialize(nMesh2* srcMesh)
{
n_assert(!this->initialized);
n_assert(srcMesh);
n_assert(srcMesh->HasAllVertexComponents(nMesh2::Weights | nMesh2::JIndices));
this->initialized = true;
this->refSrcMesh = srcMesh;
this->charSkeleton = 0;
return true;
}
//------------------------------------------------------------------------------
/**
*/
void
nCharSkinRenderer::Begin(const nCharSkeleton* skel)
{
n_assert(!this->inBegin);
n_assert(skel);
this->charSkeleton = skel;
this->inBegin = true;
nGfxServer2::Instance()->SetMesh(this->refSrcMesh, this->refSrcMesh);
}
//------------------------------------------------------------------------------
/**
*/
void
nCharSkinRenderer::End()
{
n_assert(this->inBegin);
this->inBegin = false;
}
//------------------------------------------------------------------------------
/**
*/
void
nCharSkinRenderer::Render(int meshGroupIndex, nCharJointPalette& jointPalette)
{
n_assert(inBegin);
this->RenderShaderSkinning(meshGroupIndex, jointPalette);
}
//------------------------------------------------------------------------------
/**
Render the skinned character with vertex shader skinning.
*/
void
nCharSkinRenderer::RenderShaderSkinning(int meshGroupIndex, nCharJointPalette& jointPalette)
{
static const int maxJointPaletteSize = 72;
static matrix44 jointArray[maxJointPaletteSize];
nGfxServer2* gfxServer = nGfxServer2::Instance();
// extract the current joint palette from the skeleton in the
// right format for the skinning shader
int paletteSize = jointPalette.GetNumJoints();
n_assert(paletteSize <= maxJointPaletteSize);
int paletteIndex;
for (paletteIndex = 0; paletteIndex < paletteSize; paletteIndex++)
{
const nCharJoint& joint = this->charSkeleton->GetJointAt(jointPalette.GetJointIndexAt(paletteIndex));
jointArray[paletteIndex] = joint.GetSkinMatrix44();
}
// transfer the joint palette to the current shader
nShader2* shd = gfxServer->GetShader();
n_assert(shd);
if (shd->IsParameterUsed(nShaderState::JointPalette))
{
shd->SetMatrixArray(nShaderState::JointPalette, jointArray, paletteSize);
}
// set current vertex and index range and draw mesh
const nMeshGroup& meshGroup = this->refSrcMesh->Group(meshGroupIndex);
gfxServer->SetVertexRange(meshGroup.GetFirstVertex(), meshGroup.GetNumVertices());
gfxServer->SetIndexRange(meshGroup.GetFirstIndex(), meshGroup.GetNumIndices());
gfxServer->DrawIndexedNS(nGfxServer2::TriangleList);
}
| [
"BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c"
] | [
[
[
1,
114
]
]
] |
011623929ad5c2b7b00c0281f4b04cae3acb3029 | b84a38aad619acf34c22ed6e6caa0f7b00ebfa0a | /Code/TootleCamera/TCameraManager.cpp | 8340eed6333594110a1c2b2dcbe18be68eff97b5 | [] | 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,455 | cpp | /*
* TCameraManager.cpp
* TootleCamera
*
* Created by Duane Bradbury on 27/01/2010.
* Copyright 2010 Tootle. All rights reserved.
*
*/
#include "TCameraManager.h"
#include "TLCamera.h"
#include <TootleAsset/TLAsset.h>
namespace TLCamera
{
TPtr<TCameraManager> g_pCameraManager = NULL; // The global camera manager
}
using namespace TLCamera;
SyncBool TCameraManager::Initialise()
{
// Initialise the low level device
return TLCamera::Initialise();
}
SyncBool TCameraManager::Shutdown()
{
TLDebug_Print("Cameramanager shutdown");
m_pCameraTexture = NULL;
return TLCamera::Shutdown();
}
void TCameraManager::ProcessMessage(TLMessaging::TMessage& Message)
{
// Process image data from the camera and update the camera texture
if(Message.GetMessageRef() == "image")
{
if(m_pCameraTexture.IsValid())
{
// Update the texture data
//m_pCameraTexture->ImportData(Message);
Bool bAlpha;
u32 uWidth, uHeight;
Message.ImportData("Alpha", bAlpha );
Message.ImportData("Width", uWidth );
Message.ImportData("Height", uHeight );
Type2<u16> ImageSize(uWidth, uHeight);
m_pCameraTexture->SetSize(ImageSize, bAlpha, TRUE);
TPtr<TBinaryTree>& pChild = Message.GetChild("TexData");
if(pChild.IsValid())
{
TBinary& ImageData = pChild->GetData();
m_pCameraTexture->SetTextureData(ImageSize, ImageData);
}
}
}
TManager::ProcessMessage(Message);
}
Bool TCameraManager::ConnectToCamera()
{
if(TLCamera::ConnectToCamera())
{
TLCamera::SubscribeToCamera(this);
return TRUE;
}
return FALSE;
}
Bool TCameraManager::DisconnectFromCamera()
{
if(TLCamera::DisconnectFromCamera())
{
//TLCamera::UnSubscribeFromCamera(this);
return TRUE;
}
return FALSE;
}
TRef TCameraManager::CreateCameraTexture()
{
m_pCameraTexture = TLAsset::CreateAsset("camtexture","texture");
if(!m_pCameraTexture)
return TRef();
// Set the texture to be loaded and initialise the image data
m_pCameraTexture->SetLoadingState( TLAsset::LoadingState_Loaded );
// OpenGL ES doesn;t like square textures so we need to use one bigger than what would actually like to display
// for now
//Type2<u16> texturesize(320,480);
Type2<u16> texturesize(512,512);
m_pCameraTexture->SetSize(texturesize, FALSE);
return m_pCameraTexture->GetAssetRef();
}
| [
"[email protected]"
] | [
[
[
1,
118
]
]
] |
34da3bb7d3cb3615536af41d20636a9184b4ed70 | 001a97b7d4dba30c022f7fe118161f69fa8bed24 | /Launchy_VC7/src/SkinChooser.h | 964989b3c436f0c143949a837c22e578b9bad926 | [] | no_license | svn2github/Launchy | 8d8e56727a9a1df600a42f349cbca3d51840c943 | 601356dbb4e9cdda87605cfff049b315a70b438f | refs/heads/master | 2023-09-03T11:37:28.828055 | 2010-11-10T01:14:44 | 2010-11-10T01:14:44 | 98,788,809 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,315 | h | /*
Launchy: Application Launcher
Copyright (C) 2005 Josh Karlin
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#pragma once
#include "afxwin.h"
// SkinChooser dialog
class SkinChooser : public CDialog
{
DECLARE_DYNAMIC(SkinChooser)
public:
SkinChooser(CWnd* pParent = NULL); // standard constructor
virtual ~SkinChooser();
// Dialog Data
enum { IDD = IDD_SKIN };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
BOOL OnInitDialog(void);
public:
CListBox skinlist;
public:
afx_msg void OnBnClickedOk();
public:
afx_msg void OnBnClickedCancel();
};
| [
"karlinjf@a198a55a-610f-0410-8134-935da841aa8c"
] | [
[
[
1,
49
]
]
] |
4593e1ddc0094242f9832e22da55531848b9086a | 3b2322c1adf5e6166259540e767ec67df0887c17 | /finite-state-machine/src/Player.cpp | 23b02fbe09883bae3d4421897386fe52a5a1a0fe | [] | no_license | aruwen/various-stefan-ebner | 750aac6e546ddb3e571ac468ecc26087843817d3 | 49eac46ed3a01131d711ea6feca77c32accb4733 | refs/heads/master | 2021-01-20T00:42:40.803881 | 2011-03-13T14:08:22 | 2011-03-13T14:08:22 | 32,136,593 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 736 | cpp | #include "Player.h"
const float Player::maxSpeed = 5.0;
Player::Player(float xPosition, float yPosition):
mPressedUp(false),
mPressedDown(false),
mPressedLeft(false),
mPressedRight(false)
{
mPosition = ofPoint(xPosition,yPosition,0.0);
mSpeed = ofPoint(0.0,0.0,0.0);
}
Player::~Player(void)
{
}
void Player::update()
{
ofPoint speed;
if (mPressedUp) speed += ofPoint(0.0,-maxSpeed,0.0);
if (mPressedDown) speed += ofPoint(0.0,+maxSpeed,0.0);
if (mPressedLeft) speed += ofPoint(-maxSpeed,0.0,0.0);
if (mPressedRight) speed += ofPoint(+maxSpeed,0.0,0.0);
mPosition += speed;
}
void Player::draw()
{
ofSetColor(255,255,255);
ofNoFill();
ofCircle(mPosition.x, mPosition.y, 10.0);
}
| [
"nightwolve@bb536436-bb54-8cee-38f9-046b9e77f541"
] | [
[
[
1,
35
]
]
] |
6589bbc3d5b43817088c2a2836c35cac7a4d409f | ac342d97dda23af771da4f257a12a2910aed8987 | /ftp.h | 2a5e47e4d5160bd620ef7962643077a877b2e8a3 | [] | no_license | kitech/mwget | 41cfb180c67d22fe3abe67a8c1ecfb2d71d762a4 | c7aafefd4061f70ec565778b313732792a276fc0 | refs/heads/master | 2020-05-28T13:23:32.333877 | 2011-11-16T03:32:21 | 2011-11-16T03:32:21 | 2,785,265 | 8 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 1,238 | h |
#ifndef FTP_H
#define FTP_H
#include "ksocket.h"
#include "headers.h"
#include "url.h"
#include "retrieve.h"
class FtpRetreiver : public Retriever
{
public:
FtpRetreiver ( int ts , const char * url ) ;
~FtpRetreiver ( ) ;
KSocket * GetDataSocket();
bool TaskValid( long bsize = 0 ) ;
bool TaskFinish();
protected:
private:
bool PrepairData() ;
bool InteractiveOnce( const char * cmd ) ;
bool SendCmd(const char * cmd );
bool RecvCmd( ) ;
bool PasvSend();
bool Login(const char * user, const char * pass ) ;
bool Logout( ) ;
bool TypeSend();
bool ListSend(const char * filename );
bool RestSend( long startpos );
bool RetrSend( const char * filename );
};
#ifdef __cplusplus
extern "C"{
#endif
bool ftp_file_valid(KSocket * csock , URL * furl , KSocket *dsock , long * size );
bool ftp_interactive_once(KSocket * csock , const char * cmd);
bool ftp_send_cmd(KSocket * csock , const char * cmd);
bool ftp_recv_cmd(KSocket * csock);
bool ftp_pasv_send(KSocket *csock , KSocket * dsock );
bool ftp_login(KSocket *csock ,const char * user , const char * pass );
bool ftp_logout(KSocket *csock);
#ifdef __cplusplus
}
#endif
#endif
| [
"[email protected]"
] | [
[
[
1,
66
]
]
] |
c257209e2776d5c69f5fce5b25e661a09322b158 | b2fa537cef03244de283e231932f22ee41aec051 | /src/agg/agg_scanline_storage_aa.h | b2d8cbfe75eb9fa5df4835f760c8ebfa79cf968c | [] | no_license | rebolsource/r3-hostkit | 2e0037119cde8a161e2f7994fd3842cc3891e9d5 | f331c6a46947e6e5afedc90f3d375bcd3f7ad8a1 | refs/heads/master | 2021-01-10T18:34:50.420402 | 2010-09-09T18:38:59 | 2010-09-10T11:59:58 | 813,301 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 27,056 | h | //----------------------------------------------------------------------------
// Anti-Grain Geometry - Version 2.3
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
//----------------------------------------------------------------------------
// Contact: [email protected]
// [email protected]
// http://www.antigrain.com
//----------------------------------------------------------------------------
//
// Adaptation for 32-bit screen coordinates has been sponsored by
// Liberty Technology Systems, Inc., visit http://lib-sys.com
//
// Liberty Technology Systems, Inc. is the provider of
// PostScript and PDF technology for software developers.
//
//----------------------------------------------------------------------------
#ifndef AGG_SCANLINE_STORAGE_AA_INCLUDED
#define AGG_SCANLINE_STORAGE_AA_INCLUDED
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "agg_array.h"
#include "agg_render_scanlines.h"
namespace agg
{
//----------------------------------------------scanline_cell_storage
template<class T> class scanline_cell_storage
{
struct extra_span
{
unsigned len;
T* ptr;
};
public:
typedef T value_type;
//---------------------------------------------------------------
~scanline_cell_storage()
{
remove_all();
}
//---------------------------------------------------------------
scanline_cell_storage() :
m_cells(128-2),
m_extra_storage()
{}
// Copying
//---------------------------------------------------------------
scanline_cell_storage(const scanline_cell_storage<T>& v) :
m_cells(v.m_cells),
m_extra_storage()
{
copy_extra_storage(v);
}
//---------------------------------------------------------------
const scanline_cell_storage<T>&
operator = (const scanline_cell_storage<T>& v)
{
remove_all();
m_cells = v.m_cells;
copy_extra_storage(v);
return *this;
}
//---------------------------------------------------------------
void remove_all()
{
int i;
for(i = m_extra_storage.size()-1; i >= 0; --i)
{
delete [] m_extra_storage[(unsigned)i].ptr;
}
m_extra_storage.remove_all();
m_cells.remove_all();
}
//---------------------------------------------------------------
int add_cells(const T* cells, unsigned num_cells)
{
int idx = m_cells.allocate_continuous_block(num_cells);
if(idx >= 0)
{
T* ptr = &m_cells[idx];
memcpy(ptr, cells, sizeof(T) * num_cells);
return idx;
}
extra_span s;
s.len = num_cells;
s.ptr = new T [num_cells];
memcpy(s.ptr, cells, sizeof(T) * num_cells);
m_extra_storage.add(s);
return -int(m_extra_storage.size());
}
//---------------------------------------------------------------
const T* operator [] (int idx) const
{
if(idx >= 0)
{
if((unsigned)idx >= m_cells.size()) return 0;
return &m_cells[(unsigned)idx];
}
unsigned i = unsigned(-idx - 1);
if(i >= m_extra_storage.size()) return 0;
return m_extra_storage[i].ptr;
}
//---------------------------------------------------------------
T* operator [] (int idx)
{
if(idx >= 0)
{
if((unsigned)idx >= m_cells.size()) return 0;
return &m_cells[(unsigned)idx];
}
unsigned i = unsigned(-idx - 1);
if(i >= m_extra_storage.size()) return 0;
return m_extra_storage[i].ptr;
}
private:
void copy_extra_storage(const scanline_cell_storage<T>& v)
{
unsigned i;
for(i = 0; i < v.m_extra_storage.size(); ++i)
{
const extra_span& src = v.m_extra_storage[i];
extra_span dst;
dst.len = src.len;
dst.ptr = new T [dst.len];
memcpy(dst.ptr, src.ptr, dst.len * sizeof(T));
m_extra_storage.add(dst);
}
}
pod_deque<T, 12> m_cells;
pod_deque<extra_span, 6> m_extra_storage;
};
//-----------------------------------------------scanline_storage_aa
template<class T> class scanline_storage_aa
{
public:
typedef T cover_type;
//---------------------------------------------------------------
struct span_data
{
int32 x;
int32 len; // If negative, it's a solid span, covers is valid
int covers_id; // The index of the cells in the scanline_cell_storage
};
//---------------------------------------------------------------
struct scanline_data
{
int y;
unsigned num_spans;
unsigned start_span;
};
//---------------------------------------------------------------
class embedded_scanline
{
public:
//-----------------------------------------------------------
class const_iterator
{
public:
struct span
{
int32 x;
int32 len; // If negative, it's a solid span, covers is valid
const T* covers;
};
const_iterator(const embedded_scanline& sl) :
m_storage(sl.m_storage),
m_span_idx(sl.m_scanline.start_span)
{
init_span();
}
const span& operator*() const { return m_span; }
const span* operator->() const { return &m_span; }
void operator ++ ()
{
++m_span_idx;
init_span();
}
private:
void init_span()
{
const span_data& s = m_storage->span_by_index(m_span_idx);
m_span.x = s.x;
m_span.len = s.len;
m_span.covers = m_storage->covers_by_index(s.covers_id);
}
const scanline_storage_aa* m_storage;
unsigned m_span_idx;
span m_span;
};
friend class const_iterator;
//-----------------------------------------------------------
embedded_scanline(const scanline_storage_aa& storage) :
m_storage(&storage)
{
init(0);
}
//-----------------------------------------------------------
void reset(int, int) {}
unsigned num_spans() const { return m_scanline.num_spans; }
int y() const { return m_scanline.y; }
const_iterator begin() const { return const_iterator(*this); }
//-----------------------------------------------------------
void init(unsigned scanline_idx)
{
m_scanline_idx = scanline_idx;
m_scanline = m_storage->scanline_by_index(m_scanline_idx);
}
private:
const scanline_storage_aa* m_storage;
scanline_data m_scanline;
unsigned m_scanline_idx;
};
//---------------------------------------------------------------
scanline_storage_aa() :
m_covers(),
m_spans(256-2), // Block increment size
m_scanlines(),
m_min_x( 0x7FFFFFFF),
m_min_y( 0x7FFFFFFF),
m_max_x(-0x7FFFFFFF),
m_max_y(-0x7FFFFFFF),
m_cur_scanline(0)
{
m_fake_scanline.y = 0;
m_fake_scanline.num_spans = 0;
m_fake_scanline.start_span = 0;
m_fake_span.x = 0;
m_fake_span.len = 0;
m_fake_span.covers_id = 0;
}
// Renderer Interface
//---------------------------------------------------------------
void prepare(unsigned)
{
m_covers.remove_all();
m_scanlines.remove_all();
m_spans.remove_all();
m_min_x = 0x7FFFFFFF;
m_min_y = 0x7FFFFFFF;
m_max_x = -0x7FFFFFFF;
m_max_y = -0x7FFFFFFF;
m_cur_scanline = 0;
}
//---------------------------------------------------------------
template<class Scanline> void render(const Scanline& sl)
{
scanline_data sl_this;
int y = sl.y();
if(y < m_min_y) m_min_y = y;
if(y > m_max_y) m_max_y = y;
sl_this.y = y;
sl_this.num_spans = sl.num_spans();
sl_this.start_span = m_spans.size();
typename Scanline::const_iterator span_iterator = sl.begin();
unsigned num_spans = sl_this.num_spans;
for(;;)
{
span_data sp;
sp.x = span_iterator->x;
sp.len = span_iterator->len;
int len = abs(int(sp.len));
sp.covers_id =
m_covers.add_cells(span_iterator->covers,
unsigned(len));
m_spans.add(sp);
int x1 = sp.x;
int x2 = sp.x + len - 1;
if(x1 < m_min_x) m_min_x = x1;
if(x2 > m_max_x) m_max_x = x2;
if(--num_spans == 0) break;
++span_iterator;
}
m_scanlines.add(sl_this);
}
//---------------------------------------------------------------
// Iterate scanlines interface
int min_x() const { return m_min_x; }
int min_y() const { return m_min_y; }
int max_x() const { return m_max_x; }
int max_y() const { return m_max_y; }
//---------------------------------------------------------------
bool rewind_scanlines()
{
m_cur_scanline = 0;
return m_scanlines.size() > 0;
}
//---------------------------------------------------------------
template<class Scanline> bool sweep_scanline(Scanline& sl)
{
sl.reset_spans();
for(;;)
{
if(m_cur_scanline >= m_scanlines.size()) return false;
const scanline_data& sl_this = m_scanlines[m_cur_scanline];
unsigned num_spans = sl_this.num_spans;
unsigned span_idx = sl_this.start_span;
do
{
const span_data& sp = m_spans[span_idx++];
const T* covers = covers_by_index(sp.covers_id);
if(sp.len < 0)
{
sl.add_span(sp.x, unsigned(-sp.len), *covers);
}
else
{
sl.add_cells(sp.x, sp.len, covers);
}
}
while(--num_spans);
++m_cur_scanline;
if(sl.num_spans())
{
sl.finalize(sl_this.y);
break;
}
}
return true;
}
//---------------------------------------------------------------
// Specialization for embedded_scanline
bool sweep_scanline(embedded_scanline& sl)
{
do
{
if(m_cur_scanline >= m_scanlines.size()) return false;
sl.init(m_cur_scanline);
++m_cur_scanline;
}
while(sl.num_spans() == 0);
return true;
}
//---------------------------------------------------------------
unsigned byte_size() const
{
unsigned i;
unsigned size = sizeof(int32) * 4; // min_x, min_y, max_x, max_y
for(i = 0; i < m_scanlines.size(); ++i)
{
size += sizeof(int32) * 3; // scanline size in bytes, Y, num_spans
const scanline_data& sl_this = m_scanlines[i];
unsigned num_spans = sl_this.num_spans;
unsigned span_idx = sl_this.start_span;
do
{
const span_data& sp = m_spans[span_idx++];
size += sizeof(int32) * 2; // X, span_len
if(sp.len < 0)
{
size += sizeof(T); // cover
}
else
{
size += sizeof(T) * unsigned(sp.len); // covers
}
}
while(--num_spans);
}
return size;
}
//---------------------------------------------------------------
static void write_int32(int8u* dst, int32 val)
{
dst[0] = ((const int8u*)&val)[0];
dst[1] = ((const int8u*)&val)[1];
dst[2] = ((const int8u*)&val)[2];
dst[3] = ((const int8u*)&val)[3];
}
//---------------------------------------------------------------
void serialize(int8u* data) const
{
unsigned i;
write_int32(data, min_x()); // min_x
data += sizeof(int32);
write_int32(data, min_y()); // min_y
data += sizeof(int32);
write_int32(data, max_x()); // max_x
data += sizeof(int32);
write_int32(data, max_y()); // max_y
data += sizeof(int32);
for(i = 0; i < m_scanlines.size(); ++i)
{
const scanline_data& sl_this = m_scanlines[i];
int8u* size_ptr = data;
data += sizeof(int32); // Reserve space for scanline size in bytes
write_int32(data, sl_this.y); // Y
data += sizeof(int32);
write_int32(data, sl_this.num_spans); // num_spans
data += sizeof(int32);
unsigned num_spans = sl_this.num_spans;
unsigned span_idx = sl_this.start_span;
do
{
const span_data& sp = m_spans[span_idx++];
const T* covers = covers_by_index(sp.covers_id);
write_int32(data, sp.x); // X
data += sizeof(int32);
write_int32(data, sp.len); // span_len
data += sizeof(int32);
if(sp.len < 0)
{
memcpy(data, covers, sizeof(T));
data += sizeof(T);
}
else
{
memcpy(data, covers, unsigned(sp.len) * sizeof(T));
data += sizeof(T) * unsigned(sp.len);
}
}
while(--num_spans);
write_int32(size_ptr, int32(unsigned(data - size_ptr)));
}
}
//---------------------------------------------------------------
const scanline_data& scanline_by_index(unsigned i) const
{
return (i < m_scanlines.size()) ? m_scanlines[i] : m_fake_scanline;
}
//---------------------------------------------------------------
const span_data& span_by_index(unsigned i) const
{
return (i < m_spans.size()) ? m_spans[i] : m_fake_span;
}
//---------------------------------------------------------------
const T* covers_by_index(int i) const
{
return m_covers[i];
}
private:
scanline_cell_storage<T> m_covers;
pod_deque<span_data, 10> m_spans;
pod_deque<scanline_data, 8> m_scanlines;
span_data m_fake_span;
scanline_data m_fake_scanline;
int m_min_x;
int m_min_y;
int m_max_x;
int m_max_y;
unsigned m_cur_scanline;
};
typedef scanline_storage_aa<int8u> scanline_storage_aa8; //--------scanline_storage_aa8
typedef scanline_storage_aa<int16u> scanline_storage_aa16; //--------scanline_storage_aa16
typedef scanline_storage_aa<int32u> scanline_storage_aa32; //--------scanline_storage_aa32
//------------------------------------------serialized_scanlines_adaptor_aa
template<class T> class serialized_scanlines_adaptor_aa
{
public:
typedef T cover_type;
//---------------------------------------------------------------------
class embedded_scanline
{
public:
typedef T cover_type;
//-----------------------------------------------------------------
class const_iterator
{
public:
struct span
{
int32 x;
int32 len; // If negative, it's a solid span, "covers" is valid
const T* covers;
};
const_iterator(const embedded_scanline& sl) :
m_ptr(sl.m_ptr),
m_dx(sl.m_dx)
{
init_span();
}
const span& operator*() const { return m_span; }
const span* operator->() const { return &m_span; }
void operator ++ ()
{
if(m_span.len < 0)
{
m_ptr += sizeof(T);
}
else
{
m_ptr += m_span.len * sizeof(T);
}
init_span();
}
private:
int read_int32()
{
int32 val;
((int8u*)&val)[0] = *m_ptr++;
((int8u*)&val)[1] = *m_ptr++;
((int8u*)&val)[2] = *m_ptr++;
((int8u*)&val)[3] = *m_ptr++;
return val;
}
void init_span()
{
m_span.x = read_int32() + m_dx;
m_span.len = read_int32();
m_span.covers = m_ptr;
}
const int8u* m_ptr;
span m_span;
int m_dx;
};
friend class const_iterator;
//-----------------------------------------------------------------
embedded_scanline() : m_ptr(0), m_y(0), m_num_spans(0) {}
//-----------------------------------------------------------------
void reset(int, int) {}
unsigned num_spans() const { return m_num_spans; }
int y() const { return m_y; }
const_iterator begin() const { return const_iterator(*this); }
private:
//-----------------------------------------------------------------
int read_int32()
{
int32 val;
((int8u*)&val)[0] = *m_ptr++;
((int8u*)&val)[1] = *m_ptr++;
((int8u*)&val)[2] = *m_ptr++;
((int8u*)&val)[3] = *m_ptr++;
return val;
}
public:
//-----------------------------------------------------------------
void init(const int8u* ptr, int dx, int dy)
{
m_ptr = ptr;
m_y = read_int32() + dy;
m_num_spans = unsigned(read_int32());
m_dx = dx;
}
private:
const int8u* m_ptr;
int m_y;
unsigned m_num_spans;
int m_dx;
};
public:
//--------------------------------------------------------------------
serialized_scanlines_adaptor_aa() :
m_data(0),
m_end(0),
m_ptr(0),
m_dx(0),
m_dy(0),
m_min_x(0x7FFFFFFF),
m_min_y(0x7FFFFFFF),
m_max_x(-0x7FFFFFFF),
m_max_y(-0x7FFFFFFF)
{}
//--------------------------------------------------------------------
serialized_scanlines_adaptor_aa(const int8u* data, unsigned size,
double dx, double dy) :
m_data(data),
m_end(data + size),
m_ptr(data),
m_dx(int(dx + 0.5)),
m_dy(int(dy + 0.5)),
m_min_x(0x7FFFFFFF),
m_min_y(0x7FFFFFFF),
m_max_x(-0x7FFFFFFF),
m_max_y(-0x7FFFFFFF)
{}
//--------------------------------------------------------------------
void init(const int8u* data, unsigned size, double dx, double dy)
{
m_data = data;
m_end = data + size;
m_ptr = data;
m_dx = int(dx + 0.5);
m_dy = int(dy + 0.5);
m_min_x = 0x7FFFFFFF;
m_min_y = 0x7FFFFFFF;
m_max_x = -0x7FFFFFFF;
m_max_y = -0x7FFFFFFF;
}
private:
//--------------------------------------------------------------------
int read_int32()
{
int32 val;
((int8u*)&val)[0] = *m_ptr++;
((int8u*)&val)[1] = *m_ptr++;
((int8u*)&val)[2] = *m_ptr++;
((int8u*)&val)[3] = *m_ptr++;
return val;
}
//--------------------------------------------------------------------
unsigned read_int32u()
{
int32u val;
((int8u*)&val)[0] = *m_ptr++;
((int8u*)&val)[1] = *m_ptr++;
((int8u*)&val)[2] = *m_ptr++;
((int8u*)&val)[3] = *m_ptr++;
return val;
}
public:
// Iterate scanlines interface
//--------------------------------------------------------------------
bool rewind_scanlines()
{
m_ptr = m_data;
if(m_ptr < m_end)
{
m_min_x = read_int32() + m_dx;
m_min_y = read_int32() + m_dy;
m_max_x = read_int32() + m_dx;
m_max_y = read_int32() + m_dy;
return true;
}
return false;
}
//--------------------------------------------------------------------
int min_x() const { return m_min_x; }
int min_y() const { return m_min_y; }
int max_x() const { return m_max_x; }
int max_y() const { return m_max_y; }
//--------------------------------------------------------------------
template<class Scanline> bool sweep_scanline(Scanline& sl)
{
sl.reset_spans();
for(;;)
{
if(m_ptr >= m_end) return false;
read_int32(); // Skip scanline size in bytes
int y = read_int32() + m_dy;
unsigned num_spans = read_int32();
do
{
int x = read_int32() + m_dx;
int len = read_int32();
if(len < 0)
{
sl.add_span(x, unsigned(-len), *m_ptr);
m_ptr += sizeof(T);
}
else
{
sl.add_cells(x, len, m_ptr);
m_ptr += len * sizeof(T);
}
}
while(--num_spans);
if(sl.num_spans())
{
sl.finalize(y);
break;
}
}
return true;
}
//--------------------------------------------------------------------
// Specialization for embedded_scanline
bool sweep_scanline(embedded_scanline& sl)
{
do
{
if(m_ptr >= m_end) return false;
unsigned byte_size = read_int32u();
sl.init(m_ptr, m_dx, m_dy);
m_ptr += byte_size - sizeof(int32);
}
while(sl.num_spans() == 0);
return true;
}
private:
const int8u* m_data;
const int8u* m_end;
const int8u* m_ptr;
int m_dx;
int m_dy;
int m_min_x;
int m_min_y;
int m_max_x;
int m_max_y;
};
typedef serialized_scanlines_adaptor_aa<int8u> serialized_scanlines_adaptor_aa8; //----serialized_scanlines_adaptor_aa8
typedef serialized_scanlines_adaptor_aa<int16u> serialized_scanlines_adaptor_aa16; //----serialized_scanlines_adaptor_aa16
typedef serialized_scanlines_adaptor_aa<int32u> serialized_scanlines_adaptor_aa32; //----serialized_scanlines_adaptor_aa32
}
#endif
| [
"[email protected]"
] | [
[
[
1,
814
]
]
] |
120563465537a2bb101c1a22407678a002d2a807 | b14d5833a79518a40d302e5eb40ed5da193cf1b2 | /cpp/extern/xercesc++/2.6.0/src/xercesc/validators/datatype/AnySimpleTypeDatatypeValidator.cpp | 861f372ab2276209ac3f84b30b9d2e9cdbc5cc0c | [
"Apache-2.0"
] | permissive | andyburke/bitflood | dcb3fb62dad7fa5e20cf9f1d58aaa94be30e82bf | fca6c0b635d07da4e6c7fbfa032921c827a981d6 | refs/heads/master | 2016-09-10T02:14:35.564530 | 2011-11-17T09:51:49 | 2011-11-17T09:51:49 | 2,794,411 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,499 | cpp | /*
* Copyright 2001,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Log: AnySimpleTypeDatatypeValidator.cpp,v $
* Revision 1.12 2004/09/08 13:56:52 peiyongz
* Apache License Version 2.0
*
* Revision 1.11 2004/01/29 11:51:22 cargilld
* Code cleanup changes to get rid of various compiler diagnostic messages.
*
* Revision 1.10 2003/12/17 00:18:38 cargilld
* Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
*
* Revision 1.9 2003/11/06 15:30:07 neilg
* first part of PSVI/schema component model implementation, thanks to David Cargill. This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse.
*
* Revision 1.8 2003/10/07 19:39:03 peiyongz
* Implementation of Serialization/Deserialization
*
* Revision 1.7 2003/10/01 01:09:35 knoaman
* Refactoring of some code to improve performance.
*
* Revision 1.6 2003/05/15 18:53:26 knoaman
* Partial implementation of the configurable memory manager.
*
* Revision 1.5 2003/01/13 20:16:51 knoaman
* [Bug 16024] SchemaSymbols.hpp conflicts C++ Builder 6 dir.h
*
* Revision 1.4 2002/12/18 14:17:55 gareth
* Fix to bug #13438. When you eant a vector that calls delete[] on its members you should use RefArrayVectorOf.
*
* Revision 1.3 2002/11/04 14:53:27 tng
* C++ Namespace Support.
*
* Revision 1.2 2002/02/14 15:17:31 peiyongz
* getEnumString()
*
* Revision 1.1.1.1 2002/02/01 22:22:40 peiyongz
* sane_include
*
* Revision 1.1 2001/08/24 17:12:01 knoaman
* Add support for anySimpleType.
* Remove parameter 'baseValidator' from the virtual method 'newInstance'.
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <xercesc/validators/datatype/AnySimpleTypeDatatypeValidator.hpp>
#include <xercesc/util/RuntimeException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
// AnySimpleTypeDatatypeValidator: Constructors and Destructor
// ---------------------------------------------------------------------------
AnySimpleTypeDatatypeValidator::AnySimpleTypeDatatypeValidator(MemoryManager* const manager)
: DatatypeValidator(0, 0, SchemaSymbols::XSD_RESTRICTION, DatatypeValidator::AnySimpleType, manager)
{
setWhiteSpace(DatatypeValidator::PRESERVE);
setFinite(true);
}
AnySimpleTypeDatatypeValidator::~AnySimpleTypeDatatypeValidator()
{
}
// ---------------------------------------------------------------------------
// AnySimpleTypeDatatypeValidator: Instance methods
// ---------------------------------------------------------------------------
DatatypeValidator* AnySimpleTypeDatatypeValidator::newInstance
(
RefHashTableOf<KVStringPair>* const facets
, RefArrayVectorOf<XMLCh>* const enums
, const int
, MemoryManager* const manager
)
{
// We own them, so we will delete them first
delete facets;
delete enums;
ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::DV_InvalidOperation, manager);
// to satisfy some compilers
return 0;
}
const RefArrayVectorOf<XMLCh>* AnySimpleTypeDatatypeValidator::getEnumString() const
{
return 0;
}
/***
* Support for Serialization/De-serialization
***/
IMPL_XSERIALIZABLE_TOCREATE(AnySimpleTypeDatatypeValidator)
void AnySimpleTypeDatatypeValidator::serialize(XSerializeEngine& serEng)
{
DatatypeValidator::serialize(serEng);
}
XERCES_CPP_NAMESPACE_END
/**
* End of file AnySimpleTypeDatatypeValidator.cpp
*/
| [
"[email protected]"
] | [
[
[
1,
127
]
]
] |
134fb5db2139e71009db604f1ec1391ca2de9eb8 | 48d325e5c8648382c8f790a5e8762b36ffd7c45a | /qtshoot/taskmanager.cpp | a4fe9d77f6d814ed98b268ddd37b8633a50dafc0 | [] | no_license | tomozh/qtshoot | 46184f4bf7ad9e36f4a358b862ec17e415a0ece0 | 332aaedc89c398cc9f79c908c77bd2dd6978ec44 | refs/heads/master | 2020-07-07T10:59:31.554012 | 2011-12-09T18:04:09 | 2011-12-09T18:04:09 | 2,948,875 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,299 | cpp | #include <typeinfo>
#include "taskchara.h"
#include "taskmanager.h"
TaskManager::TaskManager()
: m_myShipPos(0, 0)
{
}
TaskManager::~TaskManager()
{
foreach(Task* task, m_task)
delete task;
m_task.clear();
m_enemyTask.clear();
}
void TaskManager::addTask(Task* task)
{
m_task.append(task);
}
void TaskManager::addEnemyTask(TaskChara* task)
{
m_enemyTask.insert(task);
addTask(task);
}
void TaskManager::addMyTask(TaskChara* task)
{
m_myTask.insert(task);
addTask(task);
}
void TaskManager::oneFrame()
{
foreach(Task* task, m_task)
{
task->oneFrame();
}
collisionCheck();
Tasks::iterator it;
for(it = m_task.begin(); it != m_task.end(); it++)
{
if((*it)->isDeleted())
{
if(typeid(*it).before(typeid(TaskChara*)))
{
TaskChara* task = dynamic_cast<TaskChara*>(*it);
m_enemyTask.remove(task);
m_myTask.remove(task);
}
delete (*it);
it = m_task.erase(it);
it--;
}
}
}
void TaskManager::render(QPainter* painter)
{
foreach(Task* task, m_task)
{
task->render(painter);
}
}
int TaskManager::getTaskCount() const
{
return m_task.size();
}
void TaskManager::collisionCheck()
{
foreach(TaskChara* myTask, m_myTask)
{
foreach(TaskChara* enemy, m_enemyTask)
{
if(!myTask->isBullet() || !enemy->isBullet())
{
QSize size = (enemy->getSize() + myTask->getSize()) / 2;
QPointF diff = enemy->getPos() - myTask->getPos();
if(diff.x() < 0) diff.rx() = -diff.rx();
if(diff.y() < 0) diff.ry() = -diff.ry();
if((diff.x() <= size.width()) && (diff.y() <= size.height()))
{
enemy->addDamage(myTask->getPower());
myTask->addDamage(enemy->getPower());
}
}
}
}
}
void TaskManager::setMyShipPos(const QPointF& pos)
{
m_myShipPos = pos;
}
const QPointF& TaskManager::getMyShipPos() const
{
return m_myShipPos;
}
| [
"[email protected]",
"tomo@aspire.(none)"
] | [
[
[
1,
1
]
],
[
[
2,
111
]
]
] |
e1621f54287a0bbbe5067624b3dde843815e3a4e | c2153dcfa8bcf5b6d7f187e5a337b904ad9f91ac | /depends/ClanLib/src/Core/Text/string16.cpp | 60d638e1b96161829017f4cedc04ca9f3b8ba323 | [] | 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 | 13,731 | cpp | /*
** ClanLib SDK
** Copyright (c) 1997-2010 The ClanLib Team
**
** This software is provided 'as-is', without any express or implied
** warranty. In no event will the authors be held liable for any damages
** arising from the use of this software.
**
** Permission is granted to anyone to use this software for any purpose,
** including commercial applications, and to alter it and redistribute it
** freely, subject to the following restrictions:
**
** 1. The origin of this software must not be misrepresented; you must not
** claim that you wrote the original software. If you use this software
** in a product, an acknowledgment in the product documentation would be
** appreciated but is not required.
** 2. Altered source versions must be plainly marked as such, and must not be
** misrepresented as being the original software.
** 3. This notice may not be removed or altered from any source distribution.
**
** Note: Some of the libraries ClanLib may link to may have additional
** requirements or restrictions.
**
** File Author(s):
**
** Magnus Norddahl
*/
#include "precomp.h"
#include "API/Core/Text/string16.h"
#include "API/Core/Text/string_types.h"
#include "API/Core/Text/string_help.h"
#include "API/Core/System/memory_pool.h"
#ifndef WIN32
#include <cstring>
#endif
CL_String16::CL_String16()
: pool(0), data_capacity(local_string_length)
{
init();
}
CL_String16::CL_String16(const std::wstring &source)
: pool(0), data_capacity(local_string_length)
{
init();
append(source.data(), source.length());
}
CL_String16::CL_String16(const CL_String16 &source)
: pool(0), data_capacity(local_string_length)
{
init();
append(source);
}
CL_String16::CL_String16(const CL_StringData16 &source)
: pool(0), data_capacity(local_string_length)
{
init();
append(source);
}
CL_String16::CL_String16(const char *c_str)
: pool(0), data_capacity(local_string_length)
{
init();
append(c_str);
}
CL_String16::CL_String16(const char *c_str, size_type length)
: pool(0), data_capacity(local_string_length)
{
init();
append(c_str, length);
}
CL_String16::CL_String16(const wchar_t *wc_str)
: pool(0), data_capacity(local_string_length)
{
init();
append(wc_str);
}
CL_String16::CL_String16(const wchar_t *wc_str, size_type length)
: pool(0), data_capacity(local_string_length)
{
init();
append(wc_str, length);
}
CL_String16::CL_String16(size_type n, wchar_t c)
: pool(0), data_capacity(local_string_length)
{
init();
append(n, c);
}
void CL_String16::init()
{
local_string[0] = 0;
this->data_ptr = local_string;
}
CL_String16::~CL_String16()
{
if (data_capacity > local_string_length)
{
if (pool)
pool->free(this->data_ptr);
else
delete[] this->data_ptr;
}
}
CL_String16::operator CL_StringRef16() const
{
return CL_StringRef16(c_str(), length(), true);
}
const wchar_t *CL_String16::c_str() const
{
return data();
}
void CL_String16::clear()
{
resize(0);
}
void CL_String16::reserve(size_type size)
{
if (data_capacity >= size)
return;
wchar_t *old_data = this->data_ptr;
if (pool)
this->data_ptr = (wchar_t *) pool->alloc((size + 1) * sizeof(wchar_t));
else
this->data_ptr = new wchar_t[size+1];
memcpy(this->data_ptr, old_data, this->data_length * sizeof(wchar_t));
this->data_ptr[this->data_length] = 0;
data_capacity = size;
if (old_data != local_string)
{
if (pool)
pool->free(old_data);
else
delete[] old_data;
}
}
void CL_String16::resize(size_type n)
{
if (n > data_capacity)
reserve(n);
this->data_length = n;
this->data_ptr[this->data_length] = 0;
}
void CL_String16::resize(size_type n, wchar_t c)
{
size_type last_length = this->data_length;
resize(n);
for (size_type i = last_length; i < n; i++)
this->data_ptr[i] = c;
}
CL_String16 &CL_String16::assign(const CL_StringData16 &s)
{
size_type length = s.length();
if (this->data_capacity >= length)
{
// Allow assignment to self if new string is smaller than allocated buffer
memmove(this->data_ptr, s.data(), sizeof(wchar_t) * length);
resize(length);
}
else
{
resize(length);
memcpy(this->data_ptr, s.data(), sizeof(wchar_t) * length);
}
return *this;
}
CL_String16 &CL_String16::assign(const CL_StringData16 &s, size_type pos, size_type n)
{
assign(s.substr(pos, n));
return *this;
}
CL_String16 &CL_String16::assign(const wchar_t *s, size_type n)
{
if (this->data_capacity >= n)
{
memmove(this->data_ptr, s, sizeof(wchar_t) * n);
resize(n);
}
else
{
resize(n);
memcpy(this->data_ptr, s, sizeof(wchar_t) * this->data_length);
}
return *this;
}
CL_String16 &CL_String16::assign(const wchar_t *s)
{
size_type length = CL_StringRef16(s).length();
if (this->data_capacity >= length)
{
memmove(this->data_ptr, s, sizeof(wchar_t) * length);
resize(length);
}
else
{
resize(length);
memcpy(this->data_ptr, s, sizeof(wchar_t) * length);
}
return *this;
}
CL_String16 &CL_String16::assign(size_type n, wchar_t c)
{
resize(n);
for (size_type i = 0; i < n; i++)
this->data_ptr[i] = c;
return *this;
}
void CL_String16::insert(iterator pos, size_type num_copies, const wchar_t &item)
{
if (num_copies == 0)
return;
size_type insert_pos = (size_type) (pos - begin());
size_type n = length();
if (insert_pos > n)
insert_pos = n;
resize(n + num_copies);
wchar_t *d = data();
for (size_type j = 0; j < num_copies; j++)
d[insert_pos + j] = item;
for (size_type i = insert_pos + num_copies; i < n + num_copies - 1; i++)
d[i] = d[i+1];
}
CL_String16 &CL_String16::insert(size_type pos, const CL_StringData16 &s)
{
return insert(pos, s.data(), s.length());
}
CL_String16 &CL_String16::insert(size_type pos, const CL_StringData16 &s, size_type pos1, size_type length)
{
return insert(pos, s.data() + pos1, length);
}
CL_String16 &CL_String16::insert(size_type pos, const wchar_t *s)
{
return insert(pos, s, CL_StringRef16(s).length());
}
CL_String16 &CL_String16::insert(size_type pos, const wchar_t *s, size_type s_length)
{
size_type old_len = length();
if (pos == CL_StringData16::npos || pos > old_len)
pos = old_len;
resize(old_len + s_length);
wchar_t *d = data();
size_type i;
for (i = length(); i > pos + s_length; i--)
d[i-1] = d[i-1-s_length];
for (i = pos; i < pos + s_length; i++)
d[i] = s[i-pos];
return *this;
}
CL_String16 &CL_String16::insert(size_type pos, size_type n, wchar_t c)
{
size_type old_len = length();
if (pos == CL_StringData16::npos || pos > old_len)
pos = old_len;
resize(old_len + n);
wchar_t *d = data();
size_type i;
for (i = length(); i > pos + n; i--)
d[i-1] = d[i-1-n];
for (i = pos; i < pos + n; i++)
d[i] = c;
return *this;
}
CL_String16 &CL_String16::append(const CL_StringData16 &s)
{
return insert(length(), s);
}
CL_String16 &CL_String16::append(const CL_StringData16 &s, size_type pos, size_type n)
{
return insert(length(), s, pos, n);
}
CL_String16 &CL_String16::append(const char *s)
{
return append(CL_StringHelp::local8_to_ucs2(s));
}
CL_String16 &CL_String16::append(const char *s, size_type n)
{
return append(CL_StringHelp::local8_to_ucs2(CL_StringRef8(s, n, false)));
}
CL_String16 &CL_String16::append(const wchar_t *s)
{
return insert(length(), s);
}
CL_String16 &CL_String16::append(const wchar_t *s, size_type n)
{
return insert(length(), s, n);
}
CL_String16 &CL_String16::append(size_type n, wchar_t c)
{
return insert(length(), n, c);
}
void CL_String16::push_back(wchar_t c)
{
resize(length()+1, c);
}
CL_String16 &CL_String16::erase(size_type pos, size_type n)
{
if (pos > length())
return *this;
size_type left = length() - pos;
if (n == CL_StringData16::npos || n > left)
n = left;
erase(begin() + pos, begin() + pos + n);
return *this;
}
CL_String16 &CL_String16::replace(size_type pos, size_type n, const CL_StringData16 &s)
{
return replace(pos, n, s.data(), s.length());
}
CL_String16 &CL_String16::replace(size_type pos, size_type n, const CL_StringData16 &s, size_type pos1, size_type n1)
{
if (pos1 == CL_StringData16::npos || pos1 > s.length())
return *this;
if (pos1 + n1 > s.length())
n1 = s.length() - pos1;
return replace(pos, n, s.data() + pos1, n1);
}
CL_String16 &CL_String16::replace(size_type pos, size_type n, const wchar_t *s, size_type n1)
{
if (pos == CL_StringData16::npos || pos > length())
pos = length();
if (n == CL_StringData16::npos || pos + n > length())
n = length() - pos;
if (n1 == n)
{
memcpy(data() + pos, s, n * sizeof(wchar_t));
}
else if (n1 > n)
{
size_type rest_of_string = length() - pos - n;
resize(length() + n1 - n);
memmove(data() + pos + n1, data() + pos + n, rest_of_string * sizeof(wchar_t));
memcpy(data() + pos, s, n1 * sizeof(wchar_t));
}
else
{
size_type rest_of_string = length() - pos - n;
memcpy(data() + pos, s, n1 * sizeof(wchar_t));
memcpy(data() + pos + n1, data() + pos + n, rest_of_string * sizeof(wchar_t));
resize(length() + n1 - n);
}
return *this;
}
CL_String16 &CL_String16::replace(size_type pos, size_type n, const wchar_t *s)
{
return replace(pos, n, s, CL_StringRef16(s).length());
}
CL_String16 &CL_String16::replace(size_type pos, size_type n, size_type n1, wchar_t c)
{
if (pos == CL_StringData16::npos || pos > length())
pos = length();
if (n == CL_StringData16::npos || pos + n > length())
n = length() - pos;
if (n1 == n)
{
wchar_t *d = data() + pos;
for (size_type i = 0; i < n1; i++)
d[i] = c;
}
else if (n1 > n)
{
size_type rest_of_string = length() - pos - n;
resize(length() + n1 - n);
memmove(data() + pos + n1, data() + pos + n, rest_of_string * sizeof(wchar_t));
wchar_t *d = data() + pos;
for (size_type i = 0; i < n1; i++)
d[i] = c;
}
else
{
size_type rest_of_string = length() - pos - n;
wchar_t *d = data() + pos;
for (size_type i = 0; i < n1; i++)
d[i] = c;
memcpy(data() + pos + n1, data() + pos + n, rest_of_string * sizeof(wchar_t));
resize(length() + n1 - n);
}
return *this;
}
CL_String16 &CL_String16::replace(iterator first, iterator last, const CL_StringData16 &s)
{
return replace((size_type) (first - begin()), (size_type) (last-first), s);
}
CL_String16 &CL_String16::replace(iterator first, iterator last, const wchar_t *s, size_type n)
{
return replace((size_type) (first - begin()), (size_type) (last-first), s, n);
}
CL_String16 &CL_String16::replace(iterator first, iterator last, const wchar_t *s)
{
return replace((size_type) (first - begin()), (size_type) (last-first), s);
}
CL_String16 &CL_String16::replace(iterator first, iterator last, size_type n, wchar_t c)
{
return replace((size_type) (first - begin()), (size_type) (last-first), n, c);
}
CL_StringData16::size_type CL_String16::copy(wchar_t *buf, size_type n, size_type pos) const
{
if (pos == CL_StringData16::npos || pos > length())
return 0;
if (pos + n > length())
n = length() - pos;
memcpy(buf, data(), n * sizeof(wchar_t));
return n;
}
CL_String16 &CL_String16::operator =(const CL_String16 &source)
{
return assign(source);
}
CL_String16 &CL_String16::operator =(const CL_StringData16 &source)
{
return assign(source);
}
CL_String16 &CL_String16::operator =(const char *c_str)
{
clear();
return append(c_str);
}
CL_String16 &CL_String16::operator =(const wchar_t *c_str)
{
clear();
return append(c_str);
}
CL_String16 &CL_String16::operator +=(const CL_StringData16 &s)
{
return append(s);
}
CL_String16 &CL_String16::operator +=(const char *c_str)
{
return append(c_str);
}
CL_String16 &CL_String16::operator +=(const wchar_t *c_str)
{
return append(c_str);
}
CL_String16 &CL_String16::operator +=(wchar_t c)
{
return append(1, c);
}
/////////////////////////////////////////////////////////////////////////////
CL_String16 operator+(const CL_StringData16 &s1, const CL_StringData16 &s2)
{
CL_String16 result;
result.reserve(s1.length() + s2.length());
result.append(s1);
result.append(s2);
return result;
}
CL_String16 operator+(const char *s1, const CL_StringData16 &s2)
{
CL_String16 result;
CL_StringRef16 ref_s1(s1);
result.reserve(ref_s1.length() + s2.length());
result.append(ref_s1);
result.append(s2);
return result;
}
CL_String16 operator+(const wchar_t *s1, const CL_StringData16 &s2)
{
CL_String16 result;
CL_StringRef16 ref_s1(s1);
result.reserve(ref_s1.length() + s2.length());
result.append(ref_s1);
result.append(s2);
return result;
}
CL_String16 operator+(const CL_StringData16 &s1, const char *s2)
{
CL_String16 result;
CL_StringRef16 ref_s2(s2);
result.reserve(ref_s2.length() + s1.length());
result.append(s1);
result.append(ref_s2);
return result;
}
CL_String16 operator+(const CL_StringData16 &s1, const wchar_t *s2)
{
CL_String16 result;
CL_StringRef16 ref_s2(s2);
result.reserve(ref_s2.length() + s1.length());
result.append(s1);
result.append(ref_s2);
return result;
}
CL_String16 operator+(wchar_t c, const CL_StringData16 &s2)
{
CL_String16 result;
result.reserve(1 + s2.length());
result.push_back(c);
result.append(s2);
return result;
}
CL_String16 operator+(const CL_StringData16 &s1, wchar_t c)
{
CL_String16 result;
result.reserve(1 + s1.length());
result.append(s1);
result.push_back(c);
return result;
}
| [
"[email protected]@c628178a-a759-096a-d0f3-7c7507b30227"
] | [
[
[
1,
566
]
]
] |
5a318c78bf2d0c0724731b4937e9777cb65f5fc6 | 5ac13fa1746046451f1989b5b8734f40d6445322 | /minimangalore/Nebula2/code/mangalore/physics/materialtable.cc | a29b3eb4436bfc964b683d1eeafcc70c50ff62c5 | [] | no_license | moltenguy1/minimangalore | 9f2edf7901e7392490cc22486a7cf13c1790008d | 4d849672a6f25d8e441245d374b6bde4b59cbd48 | refs/heads/master | 2020-04-23T08:57:16.492734 | 2009-08-01T09:13:33 | 2009-08-01T09:13:33 | 35,933,330 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,617 | cc | //------------------------------------------------------------------------------
// physics/materialtable.cc
// (C) 2003 RadonLabs GmbH
//------------------------------------------------------------------------------
#include "physics/materialtable.h"
#include "xml/nxmlspreadsheet.h"
namespace Physics
{
int MaterialTable::materialCount;
nArray<struct MaterialTable::material> MaterialTable::materials;
nArray<struct MaterialTable::interaction> MaterialTable::interactions;
//------------------------------------------------------------------------------
/**
Materials used in ODE
Unit defintions are:
Density: t/m^3
Force (MegaNewton): t*m/s^2
Momentum: t*m/s
Moment of intertia: t*m^2
Moment of momentum: t*m^2/s
Moment of force: N*m
Pressure (MegaPascal): MN/m^2
Weight (MegaNewton): t*m/s^2
Work (MegaJoule): MN*m
Energy (MegaJoule): MN*m
Note: I'm not really sure that this is right... ;-)
*/
void
MaterialTable::Setup()
{
nXmlSpreadSheet materialDb;
materialDb.SetFilename("data:tables/materials.xml");
materialDb.Open();
n_assert(materialDb.IsOpen());
/* load tables */
nXmlTable* matTable = materialDb.FindTable("materials");
n_assert(0 != matTable);
materialCount = matTable->NumRows() - 2;
/* allocate memory */
materials.SetFixedSize(materialCount);
interactions.SetFixedSize(materialCount * materialCount);
/* load materials and material properties */
for (int row = 2; row < matTable->NumRows(); ++row)
{
struct material& material = materials[row - 2];
material.name = matTable->Cell(row, "Name").AsString();
material.density = matTable->Cell(row, "Density").AsFloat();
}
/* load friction data */
nXmlTable* frictionTable = materialDb.FindTable("friction");
n_assert(0 != frictionTable);
n_assert(frictionTable->NumRows() == materialCount + 2);
n_assert(frictionTable->NumColumns() == materialCount + 1);
for (int row = 2; row < frictionTable->NumRows(); ++row)
{
MaterialType mat1 = StringToMaterialType(frictionTable->Cell(row, 0).AsString());
for (int col = row - 2 + 1; col < frictionTable->NumColumns(); ++col)
{
MaterialType mat2 = StringToMaterialType(frictionTable->Cell(0, col).AsString());
interactions[mat1 * materialCount + mat2].friction = frictionTable->Cell(row, col).AsFloat();
interactions[mat2 * materialCount + mat1].friction = frictionTable->Cell(row, col).AsFloat();
}
}
/* load bounce data */
nXmlTable* bounceTable = materialDb.FindTable("bouncyness");
n_assert(0 != frictionTable);
n_assert(bounceTable->NumRows() == materialCount + 2);
n_assert(bounceTable->NumColumns() == materialCount + 1);
for (int row = 2; row < bounceTable->NumRows(); ++row)
{
MaterialType mat1 = StringToMaterialType(bounceTable->Cell(row, 0).AsString());
for (int col = row - 2 + 1; col < bounceTable->NumColumns(); ++col)
{
MaterialType mat2 = StringToMaterialType(bounceTable->Cell(0, col).AsString());
interactions[mat1 * materialCount + mat2].bouncyness = bounceTable->Cell(row, col).AsFloat();
interactions[mat2 * materialCount + mat1].bouncyness = bounceTable->Cell(row, col).AsFloat();
}
}
/* load sound data */
nXmlTable* soundTable = materialDb.FindTable("sound");
if (0 != soundTable)
{
n_assert(soundTable->NumRows() == materialCount + 2);
n_assert(soundTable->NumColumns() == materialCount + 1);
for (int row = 2; row < soundTable->NumRows(); ++row)
{
MaterialType mat1 = StringToMaterialType(soundTable->Cell(row, 0).AsString());
for (int col = row - 2 + 1; col < soundTable->NumColumns(); ++col)
{
MaterialType mat2 = StringToMaterialType(soundTable->Cell(0, col).AsString());
if (soundTable->Cell(row, col).AsString() != "")
{
interactions[mat1 * materialCount + mat2].collSound = soundTable->Cell(row, col).AsString();
interactions[mat2 * materialCount + mat1].collSound = soundTable->Cell(row, col).AsString();
}
else
{
interactions[mat1 * materialCount + mat2].collSound.Clear();
interactions[mat2 * materialCount + mat1].collSound.Clear();
}
}
}
}
}
//------------------------------------------------------------------------------
/**
*/
nString
MaterialTable::MaterialTypeToString(MaterialType t)
{
if (-1 == t)
{
return "InvalidMaterial";
}
else
{
n_assert(t >= 0 && t < materialCount);
return materials[t].name;
}
}
//------------------------------------------------------------------------------
/**
*/
MaterialType
MaterialTable::StringToMaterialType(const nString& str)
{
for (int i = 0; i < materialCount; ++i)
{
if (materials[i].name == str)
{
return i;
}
}
return -1;
}
//------------------------------------------------------------------------------
/**
*/
float
MaterialTable::GetDensity(MaterialType t)
{
n_assert(t >= 0 && t < materialCount);
return materials[t].density;
}
//------------------------------------------------------------------------------
/**
*/
float
MaterialTable::GetFriction(MaterialType t0, MaterialType t1)
{
n_assert(t0 >= 0 && t0 < materialCount);
n_assert(t1 >= 0 && t1 < materialCount);
return interactions[t0 * materialCount + t1].friction;
}
//------------------------------------------------------------------------------
/**
*/
float
MaterialTable::GetBounce(MaterialType t0, MaterialType t1)
{
n_assert(t0 >= 0 && t0 < materialCount);
n_assert(t1 >= 0 && t1 < materialCount);
return interactions[t0 * materialCount + t1].bouncyness;
}
//------------------------------------------------------------------------------
/**
*/
const nString&
MaterialTable::GetCollisionSound(MaterialType t0, MaterialType t1)
{
n_assert(t0 >= 0 && t0 < materialCount);
n_assert(t1 >= 0 && t1 < materialCount);
return interactions[t0 * materialCount + t1].collSound;
}
} // namespace Physics
| [
"BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c"
] | [
[
[
1,
200
]
]
] |
f6c790cb6aaa28266e6bfbd555f4a1afb380fb86 | c5534a6df16a89e0ae8f53bcd49a6417e8d44409 | /trunk/Samples/AIAD/Character.cpp | 2546a25407d676899906f1cdafe6012f13f52745 | [] | no_license | svn2github/ngene | b2cddacf7ec035aa681d5b8989feab3383dac012 | 61850134a354816161859fe86c2907c8e73dc113 | refs/heads/master | 2023-09-03T12:34:18.944872 | 2011-07-27T19:26:04 | 2011-07-27T19:26:04 | 78,163,390 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 50,624 | cpp | /*
---------------------------------------------------------------------------
This source file is part of nGENE Tech.
Copyright (c) 2006- Wojciech Toman
This program is free software.
File: Character.cpp
Version: 0.01
---------------------------------------------------------------------------
*/
#include "Character.h"
#include "PlayerCharacter.h"
using nGENE::byte;
#include "nGENE.h"
#include "App.h"
// Initialize static members
uint CPUCharacter::s_nEnemiesCount = 0;
uint Projectile::s_nProjectilesCount = 0;
uint PickupItem::s_nItemsCount = 0;
uint Explosion::s_nExplosionsCount = 0;
uint Decorator::s_nDecoratorsCount = 0;
uint DebrisPart::s_nDebrisCount = 0;
TypeInfo CPUCharacter::Type(L"CPUActor", &AIActor::Type);
Character::Character():
m_pVisual(NULL),
m_pActiveWeapon(NULL),
m_bMovable(true),
m_bShielded(false)
{
}
//----------------------------------------------------------------------
Character::~Character()
{
}
//----------------------------------------------------------------------
void Character::move(const Vector2& _dir)
{
if(!m_pVisual)
return;
m_pVisual->translate(_dir.x, 0.0f, _dir.y);
}
//----------------------------------------------------------------------
void Character::addItem(const Item& _item)
{
m_Equipment.push_back(_item);
}
//----------------------------------------------------------------------
Projectile::~Projectile()
{
PhysicsWorld* pWorld = m_pPhysics->getPhysicsWorld();
pWorld->removePhysicsActor(m_pPhysics);
SceneManager* pSM = m_pVisual->getCreator();
Node* pParent = m_pVisual->getParent();
pParent->removeChild(m_pVisual);
m_pVisual = NULL;
}
//----------------------------------------------------------------------
Vector3& Decorator::getPosition()
{
return m_pVisual->getPositionLocal();
}
//----------------------------------------------------------------------
Decorator::~Decorator()
{
Node* pParent = m_pVisual->getParent();
pParent->removeChild(m_pVisual);
m_pVisual = NULL;
}
//----------------------------------------------------------------------
void Decorator::init(SceneManager* _manager, Vector3& _position)
{
float y = -1.0f;
m_pVisual = new NodeVisible();
m_pVisual->setCreator(_manager);
m_pVisual->init();
INTERSECTION_DESC intersectDesc;
Point origin;
Ray ray;
Vector3 direction(0.0f, -2000.0f, 0.0f);
NodeTerrain* pTerrain = App::getSingleton().getTerrain();
TERRAIN_DESC& terrainDesc = pTerrain->getTerrainDesc();
Matrix4x4 matTerrain = pTerrain->getTransform();
float step = terrainDesc.step;
float halfStep = step * 0.5f;
float width = float(terrainDesc.columns) * terrainDesc.step * 0.5f;
float height = float(terrainDesc.rows) * terrainDesc.step * 0.5f;
int halfCols = terrainDesc.columns >> 1;
int halfRows = terrainDesc.rows >> 1;
float xDiff = width + pTerrain->getPositionLocal().x;
float zDiff = height + pTerrain->getPositionLocal().z;
int pointPerTileX = terrainDesc.columns / terrainDesc.tiles_x;
int pointPerTileZ = terrainDesc.rows / terrainDesc.tiles_z;
uint iter = 0;
while(y < 3.3f && iter < 5)
{
float x = _position.x + 16.0f;
float z = _position.z - 4096.0f;
int nx = (int)floor(x / step) + halfCols;
int nz = (int)floor(z / step) + halfRows;
origin.set(x + xDiff, 1000.0f, z + zDiff);
ray.set(origin, direction);
ray.moveToObjectSpace(matTerrain);
uint index = (nz / pointPerTileZ) * terrainDesc.tiles_x + (nx / pointPerTileX);
Surface* terrainSurf = pTerrain->getSurface(index);
while(!ray.intersectSurface(*terrainSurf, intersectDesc));
y = ray.getIntersectionPoint().y + matTerrain._m42 + 0.4f;
if(y < 3.3f)
{
_position.set(14.0f + Maths::perlinNoiseGenerator(rand() % 100, rand() % 100, rand() % 100) * 10.0f,
-12,
App::getSingleton().getScrollStage() + 12.0f + Maths::perlinNoiseGenerator(rand() % 100, rand() % 100, rand() % 100) * 7.0f + 7.0f);
}
++iter;
}
if(iter == 5)
y = -12.0f;
m_pVisual->setPosition(_position.x, y, _position.z);
NodeVisible* pDecorator = App::getSingleton().getDecorator();
for(uint i = 0; i < App::getSingleton().getDecorator()->getSurfacesNum(); ++i)
{
Surface* pSurface = pDecorator->getSurface(i);
m_pVisual->addSurface(pSurface->getName(), *pSurface);
}
m_pVisual->setRotation(pDecorator->getRotation());
m_pVisual->setScale(pDecorator->getScale().x);
wstringstream name;
name << L"Decorator_" << s_nDecoratorsCount;
m_stName = name.str();
_manager->getRootNode()->addChild(name.str(), m_pVisual);
++s_nDecoratorsCount;
}
//----------------------------------------------------------------------
void Explosion::init(SceneManager* _manager, Vector3& _position,
Character* _character)
{
ParticleEmitter fire;
fire.setParticlesMaxCount(70);
fire.setSpawnRate(30);
fire.setPosition(Vector3(0.0, 0.0f, 0.0f));
fire.setVelocity(Vector3(0.0f, 0.0f, 0.0f));
fire.setVelocitySpread(Vector3(1.5f, 1.5f, 1.5f));
fire.setAccelerationSpread(Vector3(0.2f, 0.2f, 0.2f));
fire.setAcceleration(Vector3(0.0f, 0.0f, 0.0f));
fire.setSize(1.0f);
fire.setSizeSpread(0.025f);
fire.setGrowth(1.0f);
fire.setGrowthSpread(0.2f);
fire.setLifeTime(1500.0f);
fire.setLifeTimeSpread(0.0f);
fire.setFadeSpeed(2.5f);
fire.setAngularVelocity(Maths::PI / 18.0f);
fire.setAngularVelocitySpread(0.02f);
fire.setSpawnOnce(true);
ParticleEmitter smoke;
smoke.setParticlesMaxCount(90);
smoke.setSpawnRate(30);
smoke.setPosition(Vector3(0.0, 0.0f, 0.0f));
smoke.setVelocity(Vector3(0.0f, 0.0f, 0.0f));
smoke.setVelocitySpread(Vector3(0.5f, 0.5f, 0.5f));
smoke.setAccelerationSpread(Vector3(0.3f, 0.3f, 0.3f));
smoke.setAcceleration(Vector3(0.0f, 0.5f, 0.0f));
smoke.setSize(1.0f);
smoke.setSizeSpread(0.025f);
smoke.setGrowth(0.8f);
smoke.setGrowthSpread(0.2f);
smoke.setLifeTime(4000.0f);
smoke.setLifeTimeSpread(0.0f);
smoke.setFadeSpeed(2.5f);
smoke.setAngularVelocity(Maths::PI / 4.0f);
smoke.setAngularVelocitySpread(0.06f);
smoke.setSpawnOnce(true);
smoke.setWarmUpTime(700);
Colour target = Colour::COLOUR_WHITE;
target.setAlpha(1);
smoke.setColour(target);
target = Colour::COLOUR_BLACK;
target.setAlpha(100);
smoke.addParticleColour(target, 0.4f);
//target = Colour::COLOUR_BLACK;
target = Colour::COLOUR_WHITE;
target.setAlpha(150);
smoke.addParticleColour(target, 0.7f);
//target = Colour::COLOUR_WHITE;
//target.setRGBA(100, 100, 100);
target.setAlpha(0);
smoke.setTargetColour(target);
wstringstream name;
name << L"Explosion_" << ++s_nExplosionsCount;
m_stName = name.str();
// Create particle system
m_pPS = _manager->createParticleSystem();
m_pPS->setPosition(_position);
m_pPS->addParticleEmitter(fire, L"fire_emitter");
m_pPS->addParticleEmitter(smoke, L"smoke_emitter");
if(_character->isMovable())
{
// Create falling debris
m_pDebris = new NodeVisible();
m_pDebris->setCreator(_manager);
m_pDebris->init();
NodeVisible* pEnemy = App::getSingleton().getDebris();
Material* matDebris = MaterialManager::getSingleton().getLibrary(L"game")->getMaterial(L"debris");
for(uint i = 0; i < pEnemy->getSurfacesNum(); ++i)
{
Surface* pSurface = pEnemy->getSurface(i);
m_pDebris->addSurface(pSurface->getName(), *pSurface);
}
m_pDebris->setPosition(_character->getPosition());
m_pPS->setPosition(0.0f, 0.0f, 0.0f);
m_pDebris->addChild(name.str(), m_pPS);
name << L"_Debris" << endl;
_manager->getRootNode()->addChild(name.str(), m_pDebris);
PhysicsWorld* pWorld = Physics::getSingleton().getWorld(0);
PhysicsMaterial* physMat = pWorld->getPhysicsMaterial(L"Debris");
m_pActor = pWorld->createPhysicsActor(L"Box", Vector3(0.8f, 0.4f, 0.8f),
PhysicsActor::BT_DYNAMIC, false, Vector3(0.0f, 0.0f, -1.5f));
m_pActor->attachNode((NodeVisible*)m_pDebris);
m_pActor->setShapeMaterial(0, *physMat);
m_pActor->setMass(1.0f);
m_pActor->setCollidable(DEBRIS);
pWorld->addPhysicsActor(name.str(), m_pActor);
/*Vector3 vecDir(rand() % 20 - 10, rand() % 20 - 8, rand() % 20 - 13);
vecDir.normalize();
FORCE_DESC force = {vecDir, (rand() % 5 + 1) * 70};
force.fValue *= 0.05f;
m_pActor->applyTorque(force);*/
}
else
_manager->getRootNode()->addChild(name.str(), m_pPS);
Material* matFire = MaterialManager::getSingleton().getLibrary(L"default")->getMaterial(L"fire");
Surface* pSurface = m_pPS->getSurface(L"fire_emitter");
pSurface->setMaterial(matFire);
Material* matSmoke = MaterialManager::getSingleton().getLibrary(L"default")->getMaterial(L"smoke");
pSurface = m_pPS->getSurface(L"smoke_emitter");
pSurface->setMaterial(matSmoke);
// Play sound
NodeSound* pSound = App::getSingleton().getSound();
pSound->setPosition(_position);
pSound->getSound()->play();
// Create light
name << "_light" << endl;
Renderer& renderer = Renderer::getSingleton();
m_pLight = _manager->createLight(LT_POINT);
m_pLight->setDrawDebug(false);
m_pLight->setCastShadows(false);
m_pLight->setColour(Colour::COLOUR_ORANGE);
m_pLight->setRadius(2.0f);
m_pLight->setIntensity(5.0f);
if(_character->isMovable())
{
m_pDebris->addChild(name.str(), m_pLight);
}
else
m_pPS->addChild(name.str(), m_pLight);
renderer.addLight(m_pLight);
m_nPrev = Engine::getSingleton().getTimer().getMilliseconds();
m_nPassed = 0;
m_Part1.init(_manager, _position);
m_Part2.init(_manager, _position);
m_Part3.init(_manager, _position);
/*m_Part4.init(_manager, _position);
m_Part5.init(_manager, _position);
m_Part6.init(_manager, _position);*/
m_bMovable = _character->isMovable();
}
//----------------------------------------------------------------------
void Explosion::update()
{
uint now = Engine::getSingleton().getTimer().getMilliseconds();
uint diff = now - m_nPrev;
m_nPassed += diff;
if(m_nPassed <= 400)
{
float radius = Maths::lerp(0.0f, 4.0f, (float)m_nPassed / 400.0f);
float intensity = Maths::lerp(0.0f, 5.0f, (float)m_nPassed / 400.0f);
if(!m_bMovable)
{
radius *= 0.5f;
intensity *= 0.5f;
}
m_pLight->setRadius(radius);
m_pLight->setIntensity(intensity);
}
else if(m_nPassed >= 800 && m_nPassed <= 6300)
{
float radius = Maths::lerp(4.0f, 0.0f, (float)(m_nPassed - 800) / 5500.0f);
float intensity = Maths::lerp(5.0f, 0.1f, (float)(m_nPassed - 800) / 5500.0f);
if(!m_bMovable)
{
radius *= 0.5f;
intensity *= 0.5f;
}
m_pLight->setRadius(radius);
m_pLight->setIntensity(intensity);
}
if(m_nPassed < 300)
{
if(App::getSingleton().getExplosionsNum() == 1)
{
MaterialLibrary* pMatLib = MaterialManager::getSingleton().getLibrary(L"default");
pMatLib->getMaterial(L"radialBlur")->setEnabled(true);
}
float blurStrength = Maths::lerp(0.0f, 1.4f, (float)m_nPassed / 300.0f);
MaterialLibrary* pMatLib = MaterialManager::getSingleton().getLibrary(L"default");
pMatLib->getMaterial(L"radialBlur")->getActiveRenderTechnique()->getRenderPass(0).getPixelShader()->getShader()->getConstant("blur_strength")->setDefaultValue(&blurStrength);
}
else if(m_nPassed > 400 && m_nPassed < 700)
{
float blurStrength = Maths::lerp(1.4f, 0.0f, (float)(m_nPassed - 400) / 300.0f);
MaterialLibrary* pMatLib = MaterialManager::getSingleton().getLibrary(L"default");
pMatLib->getMaterial(L"radialBlur")->getActiveRenderTechnique()->getRenderPass(0).getPixelShader()->getShader()->getConstant("blur_strength")->setDefaultValue(&blurStrength);
}
else if(m_nPassed > 700 && App::getSingleton().getExplosionsNum() == 1)
{
//MaterialLibrary* pMatLib = MaterialManager::getSingleton().getLibrary(L"default");
//pMatLib->getMaterial(L"radialBlur")->setEnabled(false);
}
m_nPrev = now;
}
//----------------------------------------------------------------------
Explosion::~Explosion()
{
SceneManager* pSM = m_pPS->getCreator();
if(m_pDebris)
{
Renderer::getSingleton().removeLight(m_pLight);
PhysicsWorld* pWorld = m_pActor->getPhysicsWorld();
pWorld->removePhysicsActor(m_pActor);
Node* pParent = m_pDebris->getParent();
pParent->removeChild(m_pDebris);
m_pDebris = NULL;
}
else
{
Renderer::getSingleton().removeLight(m_pLight);
Node* pParent = m_pPS->getParent();
pParent->removeChild(m_pPS);
m_pPS = NULL;
}
}
//----------------------------------------------------------------------
DebrisPart::~DebrisPart()
{
PhysicsWorld* pWorld = m_pActor->getPhysicsWorld();
pWorld->removePhysicsActor(m_pActor);
Node* pParent = m_pVisual->getParent();
pParent->removeChild(m_pVisual);
m_pVisual = NULL;
}
//----------------------------------------------------------------------
void DebrisPart::init(SceneManager* _manager, Vector3& _position)
{
m_pVisual = _manager->createBox(0.25f, 0.3f, 0.1f);
m_pVisual->setPosition(_position);
wstringstream name;
name << L"DebrisPart_" << s_nDebrisCount++ << endl;
_manager->getRootNode()->addChild(name.str(), m_pVisual);
Material* matDebris = MaterialManager::getSingleton().getLibrary(L"game")->getMaterial(L"enemyShip");
Surface* pSurface = m_pVisual->getSurface(L"Base");
pSurface->setMaterial(matDebris);
PhysicsWorld* pWorld = Physics::getSingleton().getWorld(0);
PhysicsMaterial* physMat = pWorld->getPhysicsMaterial(L"Debris");
m_pActor = pWorld->createPhysicsActor(L"Box", Vector3(0.5f, 0.6f, 0.2f),
PhysicsActor::BT_DYNAMIC, false, Vector3(0.0f, 0.0f, 0.0f));
m_pActor->attachNode((NodeVisible*)m_pVisual);
m_pActor->setShapeMaterial(0, *physMat);
m_pActor->setMass(1.0f);
m_pActor->setCollidable(DEBRIS);
pWorld->addPhysicsActor(name.str(), m_pActor);
Vector3 vecDir(rand() % 20 - 10, rand() % 20 - 8, rand() % 20 - 13);
vecDir.normalize();
FORCE_DESC force = {vecDir, (rand() % 5 + 1) * 70};
m_pActor->applyForce(force);
force.fValue *= 0.25f;
m_pActor->applyTorque(force);
}
//----------------------------------------------------------------------
bool Explosion::isDisposed() const
{
return m_pPS->getParticleEmitter(0)->hasFinished() &&
m_pPS->getParticleEmitter(1)->hasFinished();
}
//----------------------------------------------------------------------
Vector3& Projectile::getPosition()
{
return m_pVisual->getPositionLocal();
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
//----------------------------------------------------------------------
CPUCharacter::~CPUCharacter()
{
}
//----------------------------------------------------------------------
void CPUCharacter::cleanup()
{
PhysicsWorld* pWorld = m_pActor->getPhysicsWorld();
pWorld->removePhysicsActor(m_pActor);
SceneManager* pSM = m_pVisual->getCreator();
Node* pParent = m_pVisual->getParent();
pParent->removeChild(m_pVisual);
m_pVisual = NULL;
}
//----------------------------------------------------------------------
void CPUCharacter::init(SceneManager* _manager, PhysicsWorld* _world,
PhysicsMaterial* _material, bool _movable,
Vector3& _position, Vector3& _size,
NodeVisible* _enemy, Vector3& _offset,
MOVEMENT_TYPE _movement,
float _amplitue, float _frequency, float _speedMult)
{
m_nCurrentHP = 20;
m_nMaxHP = 20;
m_bMovable = _movable;
m_vecStartPos = _position;
m_MovementType = _movement;
m_fAmplitude = _amplitue;
m_fFreq = _frequency;
m_fVelocity *= _speedMult;
m_pVisual = new NodeVisible();
m_pVisual->setCreator(_manager);
m_pVisual->init();
if(_movable)
m_pVisual->setPosition(_position.x, 12.0f, _position.z);
else
{
INTERSECTION_DESC intersectDesc;
Point origin;
Ray ray;
Vector3 direction(0.0f, -2000.0f, 0.0f);
NodeTerrain* pTerrain = App::getSingleton().getTerrain();
TERRAIN_DESC& terrainDesc = pTerrain->getTerrainDesc();
Matrix4x4 matTerrain = pTerrain->getTransform();
float step = terrainDesc.step;
float halfStep = step * 0.5f;
float width = float(terrainDesc.columns) * terrainDesc.step * 0.5f;
float height = float(terrainDesc.rows) * terrainDesc.step * 0.5f;
int halfCols = terrainDesc.columns >> 1;
int halfRows = terrainDesc.rows >> 1;
float xDiff = width + pTerrain->getPositionLocal().x;
float zDiff = height + pTerrain->getPositionLocal().z;
// @todo check why i have to use something like that? i mean this - 1024?
float z = _position.z - 4096.0f;
float x = _position.x + 16.0f;
int pointPerTileX = terrainDesc.columns / terrainDesc.tiles_x;
int pointPerTileZ = terrainDesc.rows / terrainDesc.tiles_z;
int nx = (int)floor(x / step) + halfCols;
int nz = (int)floor(z / step) + halfRows;
origin.set(x + xDiff, 1000.0f, z + zDiff);
ray.set(origin, direction);
ray.moveToObjectSpace(matTerrain);
uint index = (nz / pointPerTileZ) * terrainDesc.tiles_x + (nx / pointPerTileX);
Surface* terrainSurf = pTerrain->getSurface(index);
while(!ray.intersectSurface(*terrainSurf, intersectDesc));
float y = ray.getIntersectionPoint().y + matTerrain._m42 + 0.75f;
m_pVisual->setPosition(_position.x, y, _position.z);
}
NodeVisible* pEnemy = NULL;
if(_movable)
pEnemy = _enemy;
else
pEnemy = App::getSingleton().getGun();
for(uint i = 0; i < pEnemy->getSurfacesNum(); ++i)
{
Surface* pSurface = pEnemy->getSurface(i);
if(!pSurface->getMaterialPtr())
continue;
m_pVisual->addSurface(pSurface->getName(), *pSurface);
m_pBase = &pSurface->getMaterial();
}
m_pVisual->setRotation(pEnemy->getRotation());
wstringstream name;
name << L"Enemy_" << s_nEnemiesCount;
_manager->getRootNode()->addChild(name.str(), m_pVisual);
Vector3 vecSize;
if(_movable)
vecSize.set(_size);
else
vecSize.set(2.0f, 1.5f, 1.5f);
m_pActor = _world->createPhysicsActor(L"Box", vecSize,
PhysicsActor::BT_KINEMATIC, false);
m_pActor->attachNode((NodeVisible*)m_pVisual);
m_pActor->setShapeMaterial(0, *_material);
m_pActor->setMass(1.0f);
m_pActor->setCollidable(ENEMY);
m_pActor->getShape(0)->setLocalPos(_offset);
_world->addPhysicsActor(name.str(), m_pActor);
m_stName = name.str();
/*NodePrefab* pBox = _manager->createBox(_size);
name << L"DebrisPart_aaa" << endl;
m_pVisual->addChild(name.str(), pBox);
Material* matDebris = MaterialManager::getSingleton().getLibrary(L"game")->getMaterial(L"shield");
Surface* pSurface = pBox->getSurface(L"Base");
pSurface->setMaterial(matDebris);*/
if(!_movable)
{
/*NodeVisible* pBox = _manager->createBox(2.0f, 1.5f, 1.5f);
pBox->setPosition(m_pVisual->getPositionLocal());
name << L"_BOX" << endl;
_manager->getRootNode()->addChild(name.str(), pBox);
Material* matDebris = MaterialManager::getSingleton().getLibrary(L"game")->getMaterial(L"debris");
uint i = 0;
Surface* pSurface = pBox->getSurface(i);
pSurface->setMaterial(matDebris);*/
}
++s_nEnemiesCount;
// Create AI
m_StateMoving.setCharacter(this);
m_StateDead.setCharacter(this);
m_StateMoving.addTransition(&m_StateDead, ET_NOHITPOINTS);
m_FSM.setActiveState(&m_StateMoving);
m_Brain.setFSM(&m_FSM);
setBrain(&m_Brain);
m_fShootDelta = rand() % FastFloat::floatToInt(m_fShootFrequency * 0.3f);
m_nPrevTime = Engine::getSingleton().getTimer().getMilliseconds();
}
//----------------------------------------------------------------------
void CPUCharacter::onHit(uint _damagePoints)
{
if(isShielded())
return;
if(_damagePoints >= m_nCurrentHP)
{
m_nCurrentHP = 0;
AIEvent evt;
evt.receiver = this;
evt.messageID = ET_NOHITPOINTS;
AIManager::getSingleton().handleEvent(evt);
}
else
{
m_nCurrentHP -= _damagePoints;
m_bHit = true;
for(uint i = 0; i < m_pVisual->getSurfacesNum(); ++i)
{
m_pVisual->getSurface(i)->setMaterial(MaterialManager::getSingleton().getLibrary(L"game")->getMaterial(L"enemyHit"));
}
m_nHitPassed = 0;
App::getSingleton().getEnemyHitSound()->getSound()->play();
}
}
//----------------------------------------------------------------------
void CPUCharacter::setPosition(Vector3& _pos)
{
m_pVisual->setPosition(_pos);
}
//----------------------------------------------------------------------
Vector3& Character::getPosition()
{
return m_pVisual->getPositionLocal();
}
//----------------------------------------------------------------------
Vector3& PickupItem::getPosition()
{
return m_pVisual->getPositionLocal();
}
//----------------------------------------------------------------------
void CPUCharacter::update()
{
dword now = Engine::getSingleton().getTimer().getMilliseconds();
float diff = (float)(now - m_nPrevTime) * App::getSingleton().getSpeedRate();
AIActor::update();
makeMovement(diff);
if(!App::getSingleton().isPlayerDead())
makeShot(diff);
if(m_bHit)
{
m_nHitPassed += diff;
if(m_nHitPassed >= 250)
{
m_bHit = false;
for(uint i = 0; i < m_pVisual->getSurfacesNum(); ++i)
{
m_pVisual->getSurface(i)->setMaterial(m_pBase);
}
}
}
m_nPrevTime = now;
}
//----------------------------------------------------------------------
void CPUCharacter::makeMovement(float _delta)
{
if(!m_bMovable)
return;
Vector3 pos = m_pVisual->getPositionLocal();
if(m_MovementType == MT_BASIC)
{
pos.z -= m_fVelocity * (_delta * 0.001f);
}
else if(m_MovementType == MT_PATH_SIN)
{
pos.z -= m_fVelocity * 0.25f * (_delta * 0.001f);
m_fMovementPassed += _delta;
pos.x = m_vecStartPos.x + Maths::fsin(m_fFreq * (m_fMovementPassed * m_fVelocity * 0.25f * 0.001f + m_vecStartPos.x)) * m_fAmplitude;
}
else if(m_MovementType == MT_PATH_COS)
{
pos.z -= m_fVelocity * 0.25f * (_delta * 0.001f);
m_fMovementPassed += _delta;
pos.x = m_vecStartPos.x + Maths::fcos(m_fFreq * (m_fMovementPassed * m_fVelocity * 0.25f * 0.001f + m_vecStartPos.x)) * m_fAmplitude;
}
else if(m_MovementType == MT_PATH_CHAIN)
{
pos.z -= m_fVelocity * 0.25f * (_delta * 0.001f);
m_fMovementPassed += _delta;
pos.x = m_vecStartPos.x + Maths::fcos(m_fFreq * (m_fMovementPassed * m_fVelocity * 0.25f * 0.001f + m_vecStartPos.x + m_vecStartPos.z * 0.05f)) * m_fAmplitude;
}
m_pVisual->setPosition(pos);
}
//----------------------------------------------------------------------
void CPUCharacter::makeShot(float _delta)
{
if(!m_pActiveWeapon)
return;
m_fShootDelta += _delta;
if(m_fShootDelta >= m_fShootFrequency)
{
m_pActiveWeapon->use(m_pVisual->getPositionLocal(), true, m_bMovable);
m_fShootDelta = 0.0f;
}
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
//----------------------------------------------------------------------
void StateMoving::update()
{
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
//----------------------------------------------------------------------
void StateDead::onEnter()
{
// Calculate combo effect
App::getSingleton().calculateCombo();
// Give player points
uint nCombo = App::getSingleton().getCombo();
if(!nCombo)
nCombo = 1;
PlayerCharacter::getSingleton().addPoints(10 * nCombo);
// Generate a power-up/bonus
uint probability = rand() % 100;
if(probability < 30)
{
App::getSingleton().generateItem(m_pCharacter->getPosition());
}
// Generate boom :P
App::getSingleton().generateExplosion(m_pCharacter->getPosition(), m_pCharacter);
// And finally dispose character
m_pCharacter->dispose();
}
//----------------------------------------------------------------------
void StateDead::update()
{
}
//----------------------------------------------------------------------
AIActor* CPUActorFactory::createAIActor(IBrain* _brain)
{
return new CPUCharacter(_brain);
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
//----------------------------------------------------------------------
void TwoShotsWeapon::use(Vector3& _position, bool _enemyShot, bool _movable)
{
if(!_enemyShot)
{
if(!m_bInfiniteAmmo && !m_nAmmoLeft)
{
App::getSingleton().getSwitchSound()->getSound()->play();
App::getSingleton().getHUD()->setNoAmmoImageEnabled(true);
App::getSingleton().getHUD()->setMessage(L"No Ammo!", Colour::COLOUR_RED);
return;
}
else if(m_nAmmoLeft)
--m_nAmmoLeft;
}
Projectile* pProjectile = new Projectile();
Vector3 vecPos = _position - Vector3(0.25f, 0.0f, 0.0f);
pProjectile->init(m_pSM, m_pWorld, m_pMaterial, vecPos, _enemyShot, _movable);
pProjectile = new Projectile();
vecPos = _position + Vector3(0.25f, 0.0f, 0.0f);
pProjectile->init(m_pSM, m_pWorld, m_pMaterial, vecPos, _enemyShot, _movable);
if(!_enemyShot)
App::getSingleton().getShotSound()->getSound()->play();
}
//----------------------------------------------------------------------
void ThreeShotsWeapon::use(Vector3& _position, bool _enemyShot, bool _movable)
{
if(!_enemyShot)
{
if(!m_bInfiniteAmmo && !m_nAmmoLeft)
{
App::getSingleton().getSwitchSound()->getSound()->play();
App::getSingleton().getHUD()->setNoAmmoImageEnabled(true);
App::getSingleton().getHUD()->setMessage(L"No Ammo!", Colour::COLOUR_RED);
return;
}
else if(m_nAmmoLeft)
--m_nAmmoLeft;
}
Projectile* pProjectile = new Projectile();
Vector3 vecPos = _position - Vector3(0.15f, 0.0f, 0.0f);
Vector3 vecDir(-0.15f, 0.0f, 1.0f);
pProjectile->init(m_pSM, m_pWorld, m_pMaterial, vecPos, _enemyShot, _movable, vecDir);
pProjectile = new Projectile();
vecPos = _position + Vector3(0.15f, 0.0f, 0.0f);
vecDir.x = 0.15f;
pProjectile->init(m_pSM, m_pWorld, m_pMaterial, vecPos, _enemyShot, _movable, vecDir);
pProjectile = new Projectile();
vecPos = _position;
pProjectile->init(m_pSM, m_pWorld, m_pMaterial, vecPos, _enemyShot, _movable);
if(!_enemyShot)
App::getSingleton().getShotSound()->getSound()->play();
}
//----------------------------------------------------------------------
void BombWeapon::use(Vector3& _position, bool _enemyShot, bool _movable)
{
if(!_enemyShot)
{
if(!m_bInfiniteAmmo && !m_nAmmoLeft)
{
App::getSingleton().getSwitchSound()->getSound()->play();
App::getSingleton().getHUD()->setNoAmmoImageEnabled(true);
App::getSingleton().getHUD()->setMessage(L"No Ammo!", Colour::COLOUR_RED);
return;
}
else if(m_nAmmoLeft)
--m_nAmmoLeft;
}
Projectile* pProjectile = new BombProjectile();
Vector3 vecPos = _position - Vector3(0.0f, 0.1f, 0.0f);
pProjectile->init(m_pSM, m_pWorld, m_pMaterial, vecPos, _enemyShot, _movable);
}
//----------------------------------------------------------------------
void MissileWeapon::use(Vector3& _position, bool _enemyShot, bool _movable)
{
if(!_enemyShot)
{
if(!m_bInfiniteAmmo && !m_nAmmoLeft)
{
App::getSingleton().getSwitchSound()->getSound()->play();
App::getSingleton().getHUD()->setNoAmmoImageEnabled(true);
App::getSingleton().getHUD()->setMessage(L"No Ammo!", Colour::COLOUR_RED);
return;
}
else if(m_nAmmoLeft)
--m_nAmmoLeft;
}
Projectile* pProjectile = new MissileProjectile();
Vector3 vecPos = _position + Vector3(0.0f, -0.1f, 0.5f);
pProjectile->init(m_pSM, m_pWorld, m_pMaterial, vecPos, _enemyShot, _movable);
App::getSingleton().getMissileSound()->getSound()->play();
}
//----------------------------------------------------------------------
void BasicWeapon::use(Vector3& _position, bool _enemyShot, bool _movable)
{
if(!_enemyShot)
{
if(!m_bInfiniteAmmo && !m_nAmmoLeft)
{
App::getSingleton().getSwitchSound()->getSound()->play();
App::getSingleton().getHUD()->setNoAmmoImageEnabled(true);
App::getSingleton().getHUD()->setMessage(L"No Ammo!", Colour::COLOUR_RED);
return;
}
else if(m_nAmmoLeft)
--m_nAmmoLeft;
}
Projectile* pProjectile = new Projectile();
pProjectile->init(m_pSM, m_pWorld, m_pMaterial, _position, _enemyShot, _movable);
if(!_enemyShot)
App::getSingleton().getShotSound()->getSound()->play();
}
//----------------------------------------------------------------------
void MissileProjectile::init(SceneManager* _manager, PhysicsWorld* _world,
PhysicsMaterial* _material, Vector3& _position, bool _enemyShot,
bool _movable, Vector3 _dir)
{
CPUCharacter* pEnemy = App::getSingleton().getNearestEnemy();
if(!pEnemy)
return;
m_pEnemy = pEnemy;
m_stEnemyName = pEnemy->getName();
m_pVisual = _manager->createCapsule(10, 10, 0.06f, 0.3f);
m_pVisual->setPosition(_position);
m_pVisual->setRotation(Vector3::UNIT_X, Maths::PI_HALF);
Surface* pSurface = m_pVisual->getSurface(L"Base");
pSurface->setMaterial(MaterialManager::getSingleton().getLibrary(L"game")->getMaterial(L"projectile"));
wstringstream name;
if(_enemyShot)
name << L"E_Projectile_" << s_nProjectilesCount;
else
name << L"Projectile_" << s_nProjectilesCount;
m_stName = name.str();
_manager->getRootNode()->addChild(name.str(), m_pVisual);
Vector3 vecDir = pEnemy->getPosition() - _position;
vecDir.normalize();
m_vecPrevDir = vecDir;
m_pPhysics = _world->createPhysicsActor(L"Capsule", Vector3(0.06f, 0.3f, 0.0f),
PhysicsActor::BT_DYNAMIC, false, vecDir * 10);
m_pPhysics->attachNode((NodeVisible*)m_pVisual);
m_pPhysics->setShapeMaterial(0, *_material);
m_pPhysics->setMass(1.0f);
if(_enemyShot)
m_pPhysics->setCollidable(0, ENEMY_PROJECTILE);
else
m_pPhysics->setCollidable(0, PROJECTILE);
_world->addPhysicsActor(name.str(), m_pPhysics);
m_vecPrevPos = _position;
App::getSingleton().addProjectile(m_stName, this);
ParticleEmitter fire;
fire.setParticlesMaxCount(25);
fire.setSpawnRate(5);
fire.setPosition(Vector3(0.0, 0.0f, 0.0f));
fire.setVelocity(Vector3(0.0f, 0.0f, 0.0f));
fire.setVelocitySpread(Vector3(0.5f, 0.5f, 0.5f));
fire.setAccelerationSpread(Vector3(0.1f, 0.1f, 0.1f));
fire.setAcceleration(Vector3(0.0f, -0.1f, 0.0f));
fire.setSize(1.0f);
fire.setSizeSpread(0.025f);
fire.setGrowth(0.9f);
fire.setGrowthSpread(0.15f);
fire.setLifeTime(500.0f);
fire.setLifeTimeSpread(0.0f);
fire.setFadeSpeed(2.5f);
fire.setAngularVelocity(Maths::PI / 36.0f);
fire.setAngularVelocitySpread(0.02f);
name << L"_fire";
// Create particle system
m_pPS = _manager->createParticleSystem();
m_pPS->setPosition(0.0f, 0.0f, 0.0f);
m_pPS->addParticleEmitter(fire, L"fire_emitter");
m_pVisual->addChild(name.str(), m_pPS);
Material* matFire = MaterialManager::getSingleton().getLibrary(L"default")->getMaterial(L"fire");
pSurface = m_pPS->getSurface(L"fire_emitter");
pSurface->setMaterial(matFire);
// Create light
name << "_light" << endl;
Renderer& renderer = Renderer::getSingleton();
m_pLight = _manager->createLight(LT_POINT);
m_pLight->setDrawDebug(false);
m_pLight->setCastShadows(false);
m_pLight->setColour(Colour::COLOUR_ORANGE);
m_pLight->setRadius(2.0f);
m_pLight->setIntensity(2.0f);
m_pVisual->addChild(name.str(), m_pLight);
renderer.addLight(m_pLight);
++s_nProjectilesCount;
}
//----------------------------------------------------------------------
MissileProjectile::~MissileProjectile()
{
Renderer::getSingleton().removeLight(m_pLight);
}
//----------------------------------------------------------------------
void Projectile::update(Real _delta)
{
if(!m_bEnemy)
return;
Vector3 pos = m_pVisual->getPositionLocal();
pos += (m_vecVelocity * _delta);
m_pVisual->setPosition(pos);
}
//----------------------------------------------------------------------
void MissileProjectile::update(Real _delta)
{
if(m_pEnemy && App::getSingleton().hasEnemy(m_stEnemyName))
{
Vector3 vecDir = m_pEnemy->getPosition() - m_pVisual->getPositionLocal();
vecDir.normalize();
m_pPhysics->setVelocity(vecDir * 3);
m_vecPrevDir = vecDir;
vecDir.y = 0.0f;
Vector3 unitz = Vector3::UNIT_Z;
float dp = vecDir.dotProduct(unitz);
float len = (vecDir.length() * unitz.length()) + 0.0001f;
float angle = (acos(dp / len));
Quaternion quatRot1(Vector3::UNIT_X, Maths::PI_HALF);
if(vecDir.x > 0.0f)
angle *= -1.0f;
Quaternion quatRot2(Vector3::UNIT_Z, angle);
m_pPhysics->setRotationWorld(quatRot1 * quatRot2);
}
else
{
m_pEnemy = App::getSingleton().getNearestEnemy();
m_stEnemyName = m_pEnemy->getName();
}
}
//----------------------------------------------------------------------
void LightningWeapon::use(Vector3& _position, bool _enemyShot, bool _movable)
{
if(!_enemyShot)
{
if(!m_bInfiniteAmmo && !m_nAmmoLeft)
{
App::getSingleton().getSwitchSound()->getSound()->play();
App::getSingleton().getHUD()->setNoAmmoImageEnabled(true);
App::getSingleton().getHUD()->setMessage(L"No Ammo!", Colour::COLOUR_RED);
return;
}
else if(m_nAmmoLeft)
--m_nAmmoLeft;
}
if(m_Bolt.getNumberOfRunsLeft() && m_Bolt.isEnabled())
return;
m_Bolt.setStartPoint(_position);
m_Bolt.setNumberOfRuns(10);
CPUCharacter* pEnemy = App::getSingleton().getNearestEnemy();
if(pEnemy)
{
m_Bolt.setEndPoint(pEnemy->getPosition());
pEnemy->onHit(10);
m_stEnemyName = pEnemy->getName();
m_Bolt.setEnabled(true);
App::getSingleton().getElectricitySound()->getSound()->play();
}
m_pEnemy = pEnemy;
}
//----------------------------------------------------------------------
void LightningWeapon::init(SceneManager* _manager, PhysicsWorld* _world, PhysicsMaterial* _material)
{
m_pSM = _manager;
m_pWorld = _world;
m_pMaterial = _material;
m_pEnemy = NULL;
m_Bolt.setCreator(_manager);
m_Bolt.init();
m_Bolt.setMinBranchLength(0.35f);
m_Bolt.setPosition(0.0f, 0.0f, 0.0f);
m_Bolt.setEndPoint(Vector3(0.0f, 0.0f, 0.0f));
m_Bolt.setBranchesNum(30);
m_Bolt.setOffset(4.5f);
m_Bolt.setColour(Colour(100, 100, 255));
m_Bolt.setStartPoint(Vector3(-70.0f, 70.0f, 0.0f));
m_Bolt.setPause(50);
m_Bolt.setWidth(0.035f);
m_Bolt.setBolt2Alpha(0.35f);
m_Bolt.setSegmentsNum(6);
m_Bolt.setUpdateFrequency(100);
m_Bolt.setBranchSpread(0.5f);
m_Bolt.setMaxFlash(0.0f);
m_Bolt.setEnabled(false);
_manager->getRootNode()->addChild(L"Bolt", m_Bolt);
m_stType = L"lightning";
m_bInfiniteAmmo = false;
m_nAmmoLeft = 20;
m_nClipSize = 20;
}
//----------------------------------------------------------------------
void LightningWeapon::update()
{
Vector3 start = PlayerCharacter::getSingleton().getPosition();
start += Vector3(0.0f, 0.0f, 0.5f);
m_Bolt.setStartPoint(start);
if(m_pEnemy && App::getSingleton().hasEnemy(m_stEnemyName))
{
Vector3 vecEnemyPos = m_pEnemy->getPosition();
Vector3 vecDir = vecEnemyPos - start;
float fLength = vecDir.length();
float fOffset = 3.5f;
if(fLength <= 7.0f)
fOffset = Maths::lerp(0.5f, fOffset, fLength / 7.0f);
m_Bolt.setEndPoint(vecEnemyPos);
m_Bolt.setOffset(fOffset);
}
else
{
m_pEnemy = NULL;
m_Bolt.setEnabled(false);
if(PlayerCharacter::getSingleton().getActiveWeapon() == this)
App::getSingleton().getElectricitySound()->getSound()->stop();
}
if(m_Bolt.hasFinished())
{
if(PlayerCharacter::getSingleton().getActiveWeapon() == this)
App::getSingleton().getElectricitySound()->getSound()->stop();
}
}
//----------------------------------------------------------------------
void BombProjectile::init(SceneManager* _manager, PhysicsWorld* _world,
PhysicsMaterial* _material, Vector3& _position, bool _enemyShot,
bool _movable, Vector3 _dir)
{
m_pVisual = _manager->createCapsule(10, 10, 0.1f, 0.25f);
m_pVisual->setPosition(_position);
m_pVisual->setRotation(Vector3::UNIT_X, Maths::PI_HALF);
Surface* pSurface = m_pVisual->getSurface(L"Base");
pSurface->setMaterial(MaterialManager::getSingleton().getLibrary(L"game")->getMaterial(L"projectile"));
wstringstream name;
if(_enemyShot)
name << L"E_Projectile_" << s_nProjectilesCount;
else
name << L"Projectile_" << s_nProjectilesCount;
m_stName = name.str();
_manager->getRootNode()->addChild(name.str(), m_pVisual);
Vector3 vecVelocity(0.0f, 0.0f, 0.2f * PlayerCharacter::getSingleton().getController()->getVelocity());
m_pPhysics = _world->createPhysicsActor(L"Capsule", Vector3(0.2f, 0.5f, 0.0f),
PhysicsActor::BT_DYNAMIC, false, vecVelocity);
m_pPhysics->attachNode((NodeVisible*)m_pVisual);
m_pPhysics->setShapeMaterial(0, *_material);
m_pPhysics->setMass(1.0f);
if(_enemyShot)
m_pPhysics->setCollidable(0, ENEMY_PROJECTILE);
else
m_pPhysics->setCollidable(0, PROJECTILE);
_world->addPhysicsActor(name.str(), m_pPhysics);
App::getSingleton().addProjectile(m_stName, this);
++s_nProjectilesCount;
}
//----------------------------------------------------------------------
void Projectile::init(SceneManager* _manager, PhysicsWorld* _world,
PhysicsMaterial* _material, Vector3& _position, bool _enemyShot,
bool _movable, Vector3 _dir)
{
m_pVisual = _manager->createSphere(10, 10, 0.05f);
m_pVisual->setPosition(_position);
Surface* pSurface = m_pVisual->getSurface(L"Base");
pSurface->setMaterial(MaterialManager::getSingleton().getLibrary(L"game")->getMaterial(L"projectile"));
wstringstream name;
if(_enemyShot)
name << L"E_Projectile_" << s_nProjectilesCount;
else
name << L"Projectile_" << s_nProjectilesCount;
m_stName = name.str();
_manager->getRootNode()->addChild(name.str(), m_pVisual);
if(_enemyShot)
{
m_pPhysics = _world->createPhysicsActor(L"Box", Vector3(0.5f, 0.5f, 0.5f),
PhysicsActor::BT_KINEMATIC);
}
else
{
m_pPhysics = _world->createPhysicsActor(L"Box", Vector3(0.1f, 0.1f, 0.1f),
PhysicsActor::BT_DYNAMIC);
}
m_pPhysics->attachNode((NodeVisible*)m_pVisual);
m_pPhysics->setShapeMaterial(0, *_material);
m_pPhysics->setMass(1.0f);
if(_enemyShot)
m_pPhysics->setCollidable(0, ENEMY_PROJECTILE);
else
m_pPhysics->setCollidable(0, PROJECTILE);
_world->addPhysicsActor(name.str(), m_pPhysics);
_dir.normalize();
FORCE_DESC force = {_dir, 1000.0f};
if(_enemyShot)
{
if(_movable)
force.fValue *= -1.0f;
else
{
Vector3 vecDir = PlayerCharacter::getSingleton().getPosition() -
_position;
vecDir.normalize();
force.vecDirection = vecDir;
}
}
if(!_enemyShot)
m_pPhysics->setVelocity(force.vecDirection * force.fValue * 0.01f);
else
m_vecVelocity = force.vecDirection * force.fValue * 0.005f;
m_bEnemy = _enemyShot;
App::getSingleton().addProjectile(m_stName, this);
++s_nProjectilesCount;
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
//----------------------------------------------------------------------
void PickupItem::init(SceneManager* _manager, PhysicsWorld* _world,
PhysicsMaterial* _material, Vector3& _position,
wstring& _type)
{
m_stType = _type;
m_pVisual = _manager->createSphere(12, 12, 0.2f);
Vector3 vecPos = _position;
vecPos.y = PlayerCharacter::getSingleton().getPosition().y;
m_pVisual->setPosition(vecPos);
Surface* pSurface = m_pVisual->getSurface(L"Base");
pSurface->setMaterial(MaterialManager::getSingleton().getLibrary(L"game")->getMaterial(L"powerup"));
wstringstream name;
name << L"Item_" << s_nItemsCount;
_manager->getRootNode()->addChild(name.str(), m_pVisual);
m_pActor = _world->createPhysicsActor(L"Sphere", Vector3(0.2f, 0.2f, 0.2f),
PhysicsActor::BT_KINEMATIC, false);
m_pActor->attachNode((NodeVisible*)m_pVisual);
m_pActor->setShapeMaterial(0, *_material);
m_pActor->setMass(1.0f);
m_pActor->setCollidable(ITEM);
_world->addPhysicsActor(name.str(), m_pActor);
m_stName = name.str();
name << L"_light";
m_pLight = _manager->createLight(LT_POINT);
m_pLight->setDrawDebug(false);
m_pLight->setCastShadows(false);
m_pLight->setColour(Colour::COLOUR_BLUE);
m_pLight->setRadius(3.0f);
m_pLight->setIntensity(4.0f);
m_pLight->setPosition(0.0f, 0.5f, 0.0f);
m_pVisual->addChild(name.str(), m_pLight);
Renderer::getSingleton().addLight(m_pLight);
++s_nItemsCount;
}
//----------------------------------------------------------------------
PickupItem::~PickupItem()
{
Renderer::getSingleton().removeLight(m_pLight);
PhysicsWorld* pWorld = m_pActor->getPhysicsWorld();
pWorld->removePhysicsActor(m_pActor);
SceneManager* pSM = m_pVisual->getCreator();
Node* pParent = m_pVisual->getParent();
pParent->removeChild(m_pVisual);
m_pVisual = NULL;
}
//----------------------------------------------------------------------
void PickupItem::pick()
{
App::getSingleton().getPowerUpSound()->getSound()->play();
if(m_pItem && !m_bWeapon)
{
m_pItem->onUse();
PlayerCharacter::getSingleton().addItem(m_pItem);
}
else if(m_pWeapon && m_bWeapon)
{
PlayerCharacter::getSingleton().addWeapon(m_pWeapon);
}
dispose();
}
//----------------------------------------------------------------------
void HealItem::pick()
{
PlayerCharacter::getSingleton().heal(20);
PickupItem::pick();
}
//----------------------------------------------------------------------
void MoreHealthItem::pick()
{
PlayerCharacter& player = PlayerCharacter::getSingleton();
player.setMaxHP(player.getMaxHP() + 10);
player.setCurrentHP(player.getMaxHP());
PickupItem::pick();
}
//----------------------------------------------------------------------
void PointsItem::pick()
{
PlayerCharacter::getSingleton().addPoints(500);
PickupItem::pick();
}
//----------------------------------------------------------------------
void ShieldUsableItem::onUse()
{
UsableItem::onUse();
PlayerCharacter& player = PlayerCharacter::getSingleton();
if(player.isShielded())
return;
SceneManager* sm = Engine::getSingleton().getSceneManager(0);
if(sm->getNode(L"ShieldNode"))
{
Node* pVisual = sm->getNode(L"ShieldNode");
pVisual->setEnabled(true);
}
else
{
NodeVisible* pVisual = sm->createSphere(32, 32, 0.95f);
Surface* pSurface = pVisual->getSurface(L"Base");
pSurface->setMaterial(MaterialManager::getSingleton().getLibrary(L"game")->getMaterial(L"shield"));
sm->getNode(L"PlayerNode")->addChild(L"ShieldNode", pVisual);
}
player.setShielded(true);
}
//----------------------------------------------------------------------
void ShieldUsableItem::onEnd()
{
UsableItem::onEnd();
SceneManager* sm = Engine::getSingleton().getSceneManager(0);
Node* pVisual = sm->getNode(L"ShieldNode");
// We don't destroy as we may need it later on
pVisual->setEnabled(false);
PlayerCharacter& player = PlayerCharacter::getSingleton();
player.setShielded(false);
}
//----------------------------------------------------------------------
bool ShieldUsableItem::update()
{
if(UsableItem::update())
return true;
ShaderConstant* pConstant = MaterialManager::getSingleton().getLibrary(L"game")->getMaterial(L"shield")->getActiveRenderTechnique()->getRenderPass(0).getPixelShader()->getConstant("colour");
float values[4];
memcpy(values, (float*)pConstant->getValues(), 4 * sizeof(float));
float alpha = 1.0f;
if(m_nPassed <= 1500.0f)
{
alpha = Maths::lerp(0.0f, 1.0f, (float)m_nPassed / 1500.0f);
}
else if(m_nPassed > 8500)
{
alpha = Maths::lerp(1.0f, 0.0f, (float)(m_nPassed - 8500) / 1500.0f);
}
values[3] = alpha;
pConstant->setValues(values);
return false;
}
//----------------------------------------------------------------------
void AgilityUsableItem::onUse()
{
UsableItem::onUse();
PlayerCharacter& player = PlayerCharacter::getSingleton();
player.setAgility(3.0f);
}
//----------------------------------------------------------------------
void AgilityUsableItem::onEnd()
{
UsableItem::onEnd();
PlayerCharacter& player = PlayerCharacter::getSingleton();
player.setAgility(1.5f);
}
//----------------------------------------------------------------------
bool AgilityUsableItem::update()
{
if(UsableItem::update())
return true;
return false;
}
//----------------------------------------------------------------------
void SlowMotionUsableItem::onUse()
{
UsableItem::onUse();
App::getSingleton().setSloMo(true);
}
//----------------------------------------------------------------------
void SlowMotionUsableItem::onEnd()
{
UsableItem::onEnd();
App::getSingleton().setSloMo(false);
}
//----------------------------------------------------------------------
bool SlowMotionUsableItem::update()
{
if(UsableItem::update())
return true;
MaterialLibrary* pMatLib = MaterialManager::getSingleton().getLibrary(L"default");
PlayerCharacter& player = PlayerCharacter::getSingleton();
float fLevel = (float)player.getCurrentHP() / (float)player.getMaxHP();
if(m_nPassed <= 1000.0f)
{
fLevel = Maths::lerp(1.0f - fLevel, 1.0f, (float)m_nPassed / 1000.0f);
}
else if(m_nPassed >= 9000)
{
fLevel = Maths::lerp(1.0f, 1.0f - fLevel, (float)(m_nPassed - 9000) / 1000.0f);
}
else
fLevel = 1.0f;
pMatLib->getMaterial(L"selectiveColouring")->getActiveRenderTechnique()->getRenderPass(0).getPixelShader()->getShader()->getConstant("level")->setDefaultValue(&fLevel);
return false;
}
//----------------------------------------------------------------------
void TwoLightningWeapon::use(Vector3& _position, bool _enemyShot, bool _movable)
{
if(!_enemyShot)
{
if(!m_bInfiniteAmmo && !m_nAmmoLeft)
{
App::getSingleton().getSwitchSound()->getSound()->play();
App::getSingleton().getHUD()->setNoAmmoImageEnabled(true);
App::getSingleton().getHUD()->setMessage(L"No Ammo!", Colour::COLOUR_RED);
return;
}
else if(m_nAmmoLeft)
--m_nAmmoLeft;
}
if(m_Bolt1.getNumberOfRunsLeft() && m_Bolt1.isEnabled())
return;
m_Bolt1.setStartPoint(_position);
m_Bolt1.setNumberOfRuns(10);
if(m_Bolt2.getNumberOfRunsLeft() && m_Bolt2.isEnabled())
return;
m_Bolt2.setStartPoint(_position);
m_Bolt2.setNumberOfRuns(10);
App::getSingleton().getNearestEnemies(&m_pEnemy1, &m_pEnemy2);
if(m_pEnemy1)
{
m_Bolt1.setEndPoint(m_pEnemy1->getPosition());
m_pEnemy1->onHit(10);
m_stEnemyName1 = m_pEnemy1->getName();
m_Bolt1.setEnabled(true);
App::getSingleton().getElectricitySound()->getSound()->play();
}
if(m_pEnemy2)
{
m_Bolt2.setEndPoint(m_pEnemy2->getPosition());
m_pEnemy2->onHit(10);
m_stEnemyName2 = m_pEnemy2->getName();
m_Bolt2.setEnabled(true);
App::getSingleton().getElectricitySound()->getSound()->play();
}
}
//----------------------------------------------------------------------
void TwoLightningWeapon::init(SceneManager* _manager, PhysicsWorld* _world, PhysicsMaterial* _material)
{
m_pSM = _manager;
m_pWorld = _world;
m_pMaterial = _material;
m_pEnemy1 = NULL;
m_pEnemy2 = NULL;
m_Bolt1.setCreator(_manager);
m_Bolt1.init();
m_Bolt1.setMinBranchLength(0.35f);
m_Bolt1.setPosition(0.0f, 0.0f, 0.0f);
m_Bolt1.setEndPoint(Vector3(0.0f, 0.0f, 0.0f));
m_Bolt1.setBranchesNum(30);
m_Bolt1.setOffset(4.5f);
m_Bolt1.setColour(Colour(255, 100, 200));
m_Bolt1.setStartPoint(Vector3(-70.0f, 70.0f, 0.0f));
m_Bolt1.setPause(50);
m_Bolt1.setWidth(0.04f);
m_Bolt1.setBolt2Alpha(0.35f);
m_Bolt1.setSegmentsNum(6);
m_Bolt1.setUpdateFrequency(100);
m_Bolt1.setBranchSpread(0.5f);
m_Bolt1.setMaxFlash(0.0f);
m_Bolt1.setEnabled(false);
_manager->getRootNode()->addChild(L"TwoBolt_1", m_Bolt1);
m_Bolt2.setCreator(_manager);
m_Bolt2.init();
m_Bolt2.setMinBranchLength(0.35f);
m_Bolt2.setPosition(0.0f, 0.0f, 0.0f);
m_Bolt2.setEndPoint(Vector3(0.0f, 0.0f, 0.0f));
m_Bolt2.setBranchesNum(30);
m_Bolt2.setOffset(4.5f);
m_Bolt2.setColour(Colour(255, 100, 200));
m_Bolt2.setStartPoint(Vector3(-70.0f, 70.0f, 0.0f));
m_Bolt2.setPause(50);
m_Bolt2.setWidth(0.04f);
m_Bolt2.setBolt2Alpha(0.35f);
m_Bolt2.setSegmentsNum(6);
m_Bolt2.setUpdateFrequency(100);
m_Bolt2.setBranchSpread(0.5f);
m_Bolt2.setMaxFlash(0.0f);
m_Bolt2.setEnabled(false);
_manager->getRootNode()->addChild(L"TwoBolt_2", m_Bolt2);
m_stType = L"two_lightning";
m_bInfiniteAmmo = false;
m_nAmmoLeft = 15;
m_nClipSize = 10;
}
//----------------------------------------------------------------------
void TwoLightningWeapon::update()
{
Vector3 start = PlayerCharacter::getSingleton().getPosition();
start += Vector3(0.0f, 0.0f, 0.5f);
m_Bolt1.setStartPoint(start);
if(m_pEnemy1 && App::getSingleton().hasEnemy(m_stEnemyName1))
{
Vector3 vecEnemyPos = m_pEnemy1->getPosition();
Vector3 vecDir = vecEnemyPos - start;
float fLength = vecDir.length();
float fOffset = 3.5f;
if(fLength <= 7.0f)
fOffset = Maths::lerp(0.5f, fOffset, fLength / 7.0f);
m_Bolt1.setEndPoint(vecEnemyPos);
m_Bolt1.setOffset(fOffset);
}
else
{
m_pEnemy1 = NULL;
m_Bolt1.setEnabled(false);
if(PlayerCharacter::getSingleton().getActiveWeapon() == this)
App::getSingleton().getElectricitySound()->getSound()->stop();
}
m_Bolt2.setStartPoint(start);
if(m_pEnemy2 && App::getSingleton().hasEnemy(m_stEnemyName2))
{
Vector3 vecEnemyPos = m_pEnemy2->getPosition();
Vector3 vecDir = vecEnemyPos - start;
float fLength = vecDir.length();
float fOffset = 3.5f;
if(fLength <= 7.0f)
fOffset = Maths::lerp(0.5f, fOffset, fLength / 7.0f);
m_Bolt2.setEndPoint(vecEnemyPos);
m_Bolt2.setOffset(fOffset);
}
else
{
m_pEnemy2 = NULL;
m_Bolt2.setEnabled(false);
if(PlayerCharacter::getSingleton().getActiveWeapon() == this)
App::getSingleton().getElectricitySound()->getSound()->stop();
}
if(m_Bolt1.hasFinished() && m_Bolt2.hasFinished())
{
if(PlayerCharacter::getSingleton().getActiveWeapon() == this)
App::getSingleton().getElectricitySound()->getSound()->stop();
}
}
//---------------------------------------------------------------------- | [
"Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57"
] | [
[
[
1,
1667
]
]
] |
a0c002cd0d3339f36f84f60da825b6900ca79f00 | 4be39d7d266a00f543cf89bcf5af111344783205 | /PortableFileSystemWatcher/PortableFileSystemWatcher/Win32ApiWrapper.hpp | 7f75a57fa28212df9959a6999891aa6efa3601b9 | [] | no_license | nkzxw/lastigen-haustiere | 6316bb56b9c065a52d7c7edb26131633423b162a | bdf6219725176ae811c1063dd2b79c2d51b4bb6a | refs/heads/master | 2021-01-10T05:42:05.591510 | 2011-02-03T14:59:11 | 2011-02-03T14:59:11 | 47,530,529 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,166 | hpp | #ifndef Win32ApiWrapper_h__
#define Win32ApiWrapper_h__
#include <string>
#include "windows.h"
namespace Win32ApiWrapper
{
//WINBASEAPI BOOL WINAPI CreateDirectoryA(__in LPCSTR lpPathName, /*__in_opt*/ LPSECURITY_ATTRIBUTES lpSecurityAttributes );
int CreateDirectory ( const std::string& pathName, LPSECURITY_ATTRIBUTES securityAttributes )
{
return ::CreateDirectoryA(pathName.c_str(), securityAttributes);
}
void* CreateFile ( const std::string& lpFileName, unsigned long dwDesiredAccess, unsigned long dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, unsigned long dwCreationDisposition, unsigned long dwFlagsAndAttributes, void* hTemplateFile )
{
#ifdef UNICODE
//#define CreateFile CreateFileW
return ::CreateFileW( lpFileName.c_str(), dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile );
#else
return ::CreateFileA( lpFileName.c_str(), dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile );
#endif // !UNICODE
}
}
#endif // Win32ApiWrapper_h__ | [
"fpelliccioni@c29dda52-a065-11de-a33f-1de61d9b9616"
] | [
[
[
1,
39
]
]
] |
f8d084483746a7a39be02fe585c3dad477d5e6c4 | 188058ec6dbe8b1a74bf584ecfa7843be560d2e5 | /FLVGServer/VODFilesFormView.h | f1cea90785255273c0a458f306413342b88ad368 | [] | no_license | mason105/red5cpp | 636e82c660942e2b39c4bfebc63175c8539f7df0 | fcf1152cb0a31560af397f24a46b8402e854536e | refs/heads/master | 2021-01-10T07:21:31.412996 | 2007-08-23T06:29:17 | 2007-08-23T06:29:17 | 36,223,621 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,322 | h | #if !defined(AFX_VODFILESFORMVIEW_H__82772901_DB8C_4C59_8A30_8BADBDCD49B6__INCLUDED_)
#define AFX_VODFILESFORMVIEW_H__82772901_DB8C_4C59_8A30_8BADBDCD49B6__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// VODFilesFormView.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CVODFilesFormView form view
#ifndef __AFXEXT_H__
#include <afxext.h>
#endif
#include "XDLShellTree.h"
#include "XDLShellList.h"
class CVODFilesFormView : public CXTMainFormView
{
protected:
CVODFilesFormView(); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(CVODFilesFormView)
// Form Data
public:
//{{AFX_DATA(CVODFilesFormView)
enum { IDD = IDD_DIALOG_VODFILES };
CXTButton m_btnPrevPath;
CXTComboBoxEx m_comboAddressBar;
//}}AFX_DATA
BOOL m_bInitialized;
XDLS_Setting *m_pSetting;
// Attributes
public:
CXDLShellTree m_shellTree;
inline CXDLShellTree& GetTreeCtrl() {
return m_shellTree;
}
CXDLShellList m_shellList;
inline CXDLShellList& GetListCtrl() {
return m_shellList;
}
// Operations
public:
void RecalcLayout();
void InitSetting(XDLS_Setting *pSetting);
void Server_Run();
void Server_Stop();
void Wnd_Active(BOOL bActive);
void OnTimerWork(UINT nID);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CVODFilesFormView)
public:
virtual void OnInitialUpdate();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
virtual ~CVODFilesFormView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
//{{AFX_MSG(CVODFilesFormView)
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnBtnPrevPathClicked();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_VODFILESFORMVIEW_H__82772901_DB8C_4C59_8A30_8BADBDCD49B6__INCLUDED_)
| [
"soaris@46205fef-a337-0410-8429-7db05d171fc8"
] | [
[
[
1,
86
]
]
] |
1f866cb3f8bc3f8487a8978615bc7494c1e4fd4d | 57574cc7192ea8564bd630dbc2a1f1c4806e4e69 | /Poker/Comun/DomTreeFactory.cpp | 2b26460a259a0165ab1fcc8132bd95e7aeb8c72d | [] | no_license | natlehmann/taller-2010-2c-poker | 3c6821faacccd5afa526b36026b2b153a2e471f9 | d07384873b3705d1cd37448a65b04b4105060f19 | refs/heads/master | 2016-09-05T23:43:54.272182 | 2010-11-17T11:48:00 | 2010-11-17T11:48:00 | 32,321,142 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,940 | cpp |
#include "DomTreeFactory.h"
#include "DomTree.h"
#include "Elemento.h"
#include "ArrayUtil.h"
#include "MensajesUtil.h"
#include "ParserException.h"
#include "DomTreeFactoryInstance.h"
#include "RecursosAplicacion.h"
#include "Properties.h"
// Inicializacion de Miembros estaticos
map<string, DomTreeFactoryInstance> DomTreeFactory::configuraciones;
string DomTreeFactory::defaultConfig = "";
SDL_sem* DomTreeFactory::semaforo = SDL_CreateSemaphore(1);
DomTreeFactory::DomTreeFactory(void)
{
}
DomTreeFactory* DomTreeFactory::config(string nombreConfig){
DomTreeFactory* resultado = NULL;
//SDL_SemWait(DomTreeFactory::semaforo);
/*
if (DomTreeFactory::configuraciones.empty()) {
DomTreeFactory::inicializar();
}
*/
map<string, DomTreeFactoryInstance>::iterator it = DomTreeFactory::configuraciones.find(nombreConfig);
if (it != DomTreeFactory::configuraciones.end()) {
resultado = &(it->second);
}
//SDL_SemPost(DomTreeFactory::semaforo);
if (resultado == NULL) {
throw ParserException("La configuracion del parser " + nombreConfig + " no es valida.", "V");
}
return resultado;
}
void DomTreeFactory::finalizar() {
SDL_DestroySemaphore(DomTreeFactory::semaforo);
}
void DomTreeFactory::inicializar(){
Properties* prop = RecursosAplicacion::getParserConfigProperties();
string configs = prop->get("parser.configs");
list<string> listaConfigs = MensajesUtil::split(configs);
for (list<string>::iterator it = listaConfigs.begin(); it != listaConfigs.end(); it++) {
DomTreeFactoryInstance instance(*it);
string elementos = prop->get("parser." + (*it) + ".elementos");
list<string> listaElementos = MensajesUtil::split(elementos);
instance.setElementos(listaElementos);
map<string,string> hijosPorElemento;
map<string,string> attPorElemento;
for (list<string>::iterator itElem = listaElementos.begin();
itElem != listaElementos.end(); itElem++) {
string hijos = prop->get("parser." + (*it) + "." + (*itElem) + ".hijos");
hijosPorElemento.insert(pair<string,string>((*itElem), hijos));
string atributos = prop->get("parser." + (*it) + "." + (*itElem) + ".atributos");
attPorElemento.insert(pair<string,string>((*itElem), atributos));
}
instance.setHijosPorElemento(hijosPorElemento);
instance.setAttPorElemento(attPorElemento);
DomTreeFactory::configuraciones.insert(pair<string,DomTreeFactoryInstance>((*it), instance));
}
DomTreeFactory::defaultConfig = prop->get("parser.default.config");
}
Elemento* DomTreeFactory::crearElemento(string nombre) {
if (DomTreeFactory::configuraciones.empty()) {
DomTreeFactory::inicializar();
}
return DomTreeFactory::config(DomTreeFactory::defaultConfig)->elemento(nombre);
}
// Este metodo debe ser redefinido en las subclases
Elemento* DomTreeFactory::elemento(string nombre){
return NULL;
}
| [
"natlehmann@a9434d28-8610-e991-b0d0-89a272e3a296",
"[email protected]@a9434d28-8610-e991-b0d0-89a272e3a296"
] | [
[
[
1,
7
],
[
19,
23
],
[
51,
52
],
[
54,
54
],
[
58,
58
],
[
60,
60
],
[
62,
62
],
[
66,
66
],
[
69,
69
],
[
72,
72
],
[
75,
75
],
[
79,
79
],
[
82,
82
],
[
84,
85
],
[
88,
89
],
[
94,
94
],
[
97,
99
],
[
103,
103
]
],
[
[
8,
18
],
[
24,
50
],
[
53,
53
],
[
55,
57
],
[
59,
59
],
[
61,
61
],
[
63,
65
],
[
67,
68
],
[
70,
71
],
[
73,
74
],
[
76,
78
],
[
80,
81
],
[
83,
83
],
[
86,
87
],
[
90,
93
],
[
95,
96
],
[
100,
102
],
[
104,
105
]
]
] |
82429dc568bcd5960ad7f5be7aa1e98b03591040 | 7985054c887810f37345f6508f1a7d4fdc65b81b | /Development/Core/ObjectMgr.h | ac08f8e432d7749f1b77ec6e791da9c2bea68b9e | [] | no_license | ghostuser846/venicelight | 95e625a8e9cb8dd3d357318c931ee9247420c28d | cdc5dfac8fbaa82d3d5eeb7d21a64c3e206b7ee2 | refs/heads/master | 2021-01-01T06:44:51.163612 | 2009-06-01T02:09:27 | 2009-06-01T02:09:27 | 37,787,439 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,188 | h | /*
* Copyright (C) 2005-2008 SREmu <http://www.sremu.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _SREMU_OBJECTMGR_H
#define _SREMU_OBJECTMGR_H
#include "../Common.h"
// Internal Class Declarations
class ObjectMgr;
// External Class Declarations
class GameSocket;
class ObjectMgr
{
public:
std::map<unsigned int, GameSocket*> Players;
std::map<unsigned int, GameSocket*>::iterator pIter;
};
extern ObjectMgr Objects;
#endif // _SREMU_OBJECTMGR_H | [
"dayanfernandez@c3741f72-2d1a-11de-9401-6341fb89ae7c"
] | [
[
[
1,
41
]
]
] |
7b980b2e55199041b8b311101a87c7e19fd11f73 | c95a83e1a741b8c0eb810dd018d91060e5872dd8 | /Game/ServerApp/SelectConfigDlg.h | 550146abc64a2c9ccad75f8090cbcee7ca24635b | [] | no_license | rickyharis39/nolf2 | ba0b56e2abb076e60d97fc7a2a8ee7be4394266c | 0da0603dc961e73ac734ff365bfbfb8abb9b9b04 | refs/heads/master | 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,530 | h | #if !defined(AFX_SELECTCONFIGDLG_H__F3DCDFB1_C80A_41BE_AD06_F1577BE6E79B__INCLUDED_)
#define AFX_SELECTCONFIGDLG_H__F3DCDFB1_C80A_41BE_AD06_F1577BE6E79B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SelectConfigDlg.h : header file
//
#include "Resource.h"
/////////////////////////////////////////////////////////////////////////////
// CSelectConfigDlg dialog
class CSelectConfigDlg : public CDialog
{
// Construction
public:
CSelectConfigDlg(CWnd* pParent = NULL); // standard constructor
// Returns the selected config.
CString GetSelectedConfig( ) { return m_sConfig; }
// Dialog Data
//{{AFX_DATA(CSelectConfigDlg)
enum { IDD = IDD_SELECTCONFIG };
CButton m_OKCtrl;
CComboBox m_ConfigCtrl;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSelectConfigDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Adds all the config files to the combobox.
BOOL AddConfigFilesToControl( );
// Generated message map functions
//{{AFX_MSG(CSelectConfigDlg)
virtual BOOL OnInitDialog();
virtual void OnOK();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
CString m_sConfig;
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SELECTCONFIGDLG_H__F3DCDFB1_C80A_41BE_AD06_F1577BE6E79B__INCLUDED_)
| [
"[email protected]"
] | [
[
[
1,
58
]
]
] |
b6910cf477b35639ed25871090629b7b908fc9f3 | 2fb8c63d1ee7108c00bc9af656cd6ecf7174ae1b | /src/comp/lzham_null_threading.h | 28a201d476fa1e84197782b46a49df2780bfeb9e | [
"MIT"
] | permissive | raedwulf/liblzham | 542aca151a21837c14666f1d16957e61ba9c095d | 01ce0ec2d78f4fda767122baa02ba612ed966440 | refs/heads/master | 2021-01-10T19:58:22.981658 | 2011-08-24T11:55:26 | 2011-08-24T11:55:26 | 2,227,012 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,556 | h | // File: lzham_task_pool_null.h
// See Copyright Notice and license at the end of include/lzham.h
#pragma once
namespace lzham
{
class semaphore
{
LZHAM_NO_COPY_OR_ASSIGNMENT_OP(semaphore);
public:
inline semaphore(long initialCount = 0, long maximumCount = 1, const char* pName = NULL)
{
initialCount, maximumCount, pName;
}
inline ~semaphore()
{
}
inline void release(long releaseCount = 1, long *pPreviousCount = NULL)
{
releaseCount, pPreviousCount;
}
inline bool wait(uint32 milliseconds = UINT32_MAX)
{
milliseconds;
return true;
}
};
class task_pool
{
public:
inline task_pool() { }
inline task_pool(uint num_threads) { num_threads; }
inline ~task_pool() { }
inline bool init(uint num_threads) { num_threads; return true; }
inline void deinit();
inline uint get_num_threads() const { return 0; }
inline uint get_num_outstanding_tasks() const { return 0; }
// C-style task callback
typedef void (*task_callback_func)(uint64 data, void* pData_ptr);
inline bool queue_task(task_callback_func pFunc, uint64 data = 0, void* pData_ptr = NULL)
{
pFunc(data, pData_ptr);
return true;
}
class executable_task
{
public:
virtual void execute_task(uint64 data, void* pData_ptr) = 0;
};
// It's the caller's responsibility to delete pObj within the execute_task() method, if needed!
inline bool queue_task(executable_task* pObj, uint64 data = 0, void* pData_ptr = NULL)
{
pObj->execute_task(data, pData_ptr);
return true;
}
template<typename S, typename T>
inline bool queue_object_task(S* pObject, T pObject_method, uint64 data = 0, void* pData_ptr = NULL)
{
(pObject->*pObject_method)(data, pData_ptr);
return true;
}
template<typename S, typename T>
inline bool queue_multiple_object_tasks(S* pObject, T pObject_method, uint64 first_data, uint num_tasks, void* pData_ptr = NULL)
{
for (uint i = 0; i < num_tasks; i++)
{
(pObject->*pObject_method)(first_data + i, pData_ptr);
}
return true;
}
void join() { }
};
inline void lzham_sleep(unsigned int milliseconds)
{
milliseconds;
}
} // namespace lzham
| [
"[email protected]"
] | [
[
[
1,
92
]
]
] |
e47a98495ed9a825daa0d1544c267cca12764016 | 8534420818cbc7db514760f820b5bd4614289a63 | /wxSphinxCommonFactory/wxFolderFactory.cpp | 723552328de266a49d7848706740514deb80add0 | [] | no_license | BishopGIS/wxsphinx | b0a9dc4ba77d6d61f1a34e9cb8ad11298d6ed3ca | 16a825fa6993dc310e60c10e7e40d7948edc38bb | refs/heads/master | 2020-05-18T10:40:37.840592 | 2010-01-08T19:08:57 | 2010-01-08T19:08:57 | 32,631,398 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,913 | cpp | /******************************************************************************
* Project: Sphinx Search local file system index utility
* Purpose: wxFolderFactory class.
* Author: Bishop (aka Barishnikov Dmitriy), [email protected]
******************************************************************************
* Copyright (C) 2009 Bishop
*
* 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 "wxFolderFactory.h"
#include <wx/filename.h>
#include <wx/dir.h>
#include "../wxSphinxCommon/wxContainer.h"
IMPLEMENT_DYNAMIC_CLASS(wxFolderFactory, wxObject)
wxFolderFactory::wxFolderFactory(void)
{
}
wxFolderFactory::~wxFolderFactory(void)
{
}
bool wxFolderFactory::GetChildren(wxArrayString* pFileNames, wxObjectArray* pObjArray)
{
for(size_t i = 0; i < pFileNames->GetCount(); i++)
{
wxString path = pFileNames->Item(i);
if(wxFileName::DirExists(path))
{
//wxString name;
//wxFileName::SplitPath(path, NULL, NULL, &name, NULL);
wxSphinxContainer* pFolder = new wxSphinxContainer(path, GetClassInfo()->GetClassName(), m_pCatalog);
pObjArray->push_back(static_cast<wxSphinxObject*>(pFolder));
pFileNames->RemoveAt(i);
i--;
}
}
return true;
}
| [
"bishop.gis@dbcdddfc-c008-11de-ac5a-05e7513655e2"
] | [
[
[
1,
53
]
]
] |
0ebfc9ffa1eb918db48b2b5baee986239f7823d4 | e743f7cb85ebc6710784a39e2941e277bd359508 | /directmidi/CInstrument.cpp | 1bb3e5ff7c763f5e2a8e5b100bb66cc115a1e440 | [] | no_license | aidinabedi/directmidi4unity | 8c982802de97855fcdaab36709c6b1c8eb0b2e52 | 8c3e33e7b44c3fe248e0718e4b8f9e2260d9cd8f | refs/heads/master | 2021-01-20T15:30:16.131068 | 2009-12-03T08:37:36 | 2009-12-03T08:37:36 | 90,773,445 | 1 | 0 | null | null | null | null | WINDOWS-1250 | C++ | false | false | 4,838 | cpp | /*
____ _ ____ _____ _____ ______ __ __ _ ____ _
| _ \ | || _ \| __// __//_ _/ | \/ || || _ \ | |
| |_| || || |> /| _| | <__ | | | |\/| || || |_| || |
|____/ |_||_|\_\|____\\____/ |_| |_| |_||_||____/ |_|
////////////////////////////////////////////////////////////////////////
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
Copyright (c) 2002-2004 by Carlos Jimรฉnez de Parga
All rights reserved.
For any suggestion or failure report, please contact me by:
e-mail: [email protected]
Note: I would appreciate very much if you could provide a brief description of your project,
as well as any report on bugs or errors. This will help me improve the code for the benefit of your
application and the other users
///////////////////////////////////////////////////////////////////////
Version: 2.3b
Module : CInstrument.cpp
Purpose: Code implementation for CInstrument class
Created: CJP / 02-08-2002
History: CJP / 20-02-2004
Date format: Day-month-year
Update: 20/09/2002
1. Improved class destructors
2. Check member variables for NULL values before performing an operation
3. Restructured the class system
4. Better method to enumerate and select MIDI ports
5. Adapted the external thread to a pure virtual function
6. SysEx reception and sending enabled
7. Added flexible conversion functions
8. Find out how to activate the Microsoft software synth.
9. Added DLS support
Update: 25/03/2003
10. Added exception handling
11. Fixed bugs with channel groups
12. Redesigned class hierarchy
13. DirectMidi wrapped in the directmidi namespace
14. UNICODE/MBCS support for instruments and ports
15. Added DELAY effect to software synthesizer ports
16. Project released under GNU (General Public License) terms
Update: 03/10/2003
17. Redesigned class interfaces
18. Safer input port termination thread
19. New CMasterClock class
20. DLS files can be loaded from resources
21. DLS instruments note range support
22. New CSampleInstrument class added to the library
23. Direct download of samples to wave-table memory
24. .WAV file sample format supported
25. New methods added to the output port class
26. Fixed small bugs
Update: 20/02/2004
27. Added new DirectMusic classes for Audio handling
28. Improved CMidiPort class with internal buffer run-time resizing
29. 3D audio positioning
*/
#include "CMidiPart.h"
using namespace directmidi;
// Class constructor, initializes member variables
CInstrument::CInstrument()
{
m_pDownLoadedInstrument = NULL;
m_pInstrument = NULL;
m_pPort = NULL;
m_dwPatchInCollection = 0;
m_dwPatchInMidi = 0;
m_strInstName[0] = _T('\0');
m_NoteRange.dwLowNote = 0;
m_NoteRange.dwHighNote = 127;
}
// Class destructor
CInstrument::~CInstrument()
{
// Release the reference to the interface that contains information about
// the downloaded instrument
// Unloads the instrument from the port memory
if ((m_pPort) && (m_pDownLoadedInstrument))
m_pPort->UnloadInstrument(m_pDownLoadedInstrument);
SAFE_RELEASE(m_pDownLoadedInstrument);
SAFE_RELEASE(m_pInstrument);
}
// Sets the destination of the instrument in a synthesizer MIDI program
HRESULT CInstrument::SetPatch(DWORD dwdstPatchMidi)
{
HRESULT hr = DM_FAILED;
TCHAR strMembrFunc [] = _T("CInstrument::SetPach()");
if (m_pInstrument)
{
if (FAILED(hr = m_pInstrument->SetPatch(dwdstPatchMidi)))
throw CDMusicException(strMembrFunc,hr,__LINE__);
m_dwPatchInMidi = dwdstPatchMidi;
} else throw CDMusicException(strMembrFunc,hr,__LINE__);
return S_OK;
}
// Returns the note range
void CInstrument::GetNoteRange(LPDWORD pdwLowNote,LPDWORD pdwHighNote)
{
*pdwLowNote = m_NoteRange.dwLowNote;
*pdwHighNote = m_NoteRange.dwHighNote;
}
// Sets the note range
void CInstrument::SetNoteRange(DWORD dwLowNote,DWORD dwHighNote)
{
m_NoteRange.dwLowNote = dwLowNote;
m_NoteRange.dwHighNote = dwHighNote;
}
| [
"[email protected]"
] | [
[
[
1,
171
]
]
] |
e626b8f7377fb066bde544a5a3f0fd575fdad027 | 97f1be9ac088e1c9d3fd73d76c63fc2c4e28749a | /3dc/win95/ANIMCHNK.HPP | 37d72a23874db9ef7fbb7199ea9362b3309e0347 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | SR-dude/AvP-Wine | 2875f7fd6b7914d03d7f58e8f0ec4793f971ad23 | 41a9c69a45aacc2c345570ba0e37ec3dc89f4efa | refs/heads/master | 2021-01-23T02:54:33.593334 | 2011-09-17T11:10:07 | 2011-09-17T11:10:07 | 2,375,686 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,664 | hpp | #ifndef _animchnk_hpp
#define _animchnk_hpp
#include "chunk.hpp"
#include "Chnktype.hpp"
struct TEXANIM;
class Animation_Chunk : public Chunk
{
public :
Animation_Chunk(Chunk_With_Children* parent,const char*,size_t);
Animation_Chunk(Chunk_With_Children* parent);
~Animation_Chunk();
virtual BOOL output_chunk (HANDLE &hand);
virtual size_t size_chunk();
virtual void fill_data_block(char* data_start);
int NumPolys; //with animation in this shape
TEXANIM** AnimList;
};
#define txa_flag_nointerptofirst 0x80000000
struct FrameList
{
~FrameList();
FrameList(TEXANIM*);
#if InterfaceEngine
FrameList(TEXANIM* p,FrameList* templ);
#endif
FrameList(TEXANIM* p,FrameList* fl,int* conv);
int Speed;
int Flags;
int NumFrames;
int CurFrame;
TEXANIM* parent;
int* Textures;
int* UVCoords;
int spare1,spare2;
#if InterfaceEngine
void CopyToSID(int shape,int poly);
void CopyFromSID(int shape,int poly);
void AddFrame();
void RemoveFrame();
#endif
};
#define AnimFlag_NotPlaying 0x00000001
struct TEXANIM
{
TEXANIM(TEXANIM*);
TEXANIM();
~TEXANIM();
#if InterfaceEngine
TEXANIM(int s,int p,int id);
//construct a TEXANIM using templ as a template.
TEXANIM(int s,int p,TEXANIM* templ);
#endif
int shape;
int poly;
int NumVerts;
int ID;
int NumSeq;//number of sequences
int CurSeq;
int AnimFlags;
int Identifier;
FrameList** Seq;
#if InterfaceEngine
void ChangeFrame(int newseq,int newframe);
void AddSeq();
void RemoveSeq();
void CopySeq(int seq_num);
#endif
void CopyAnimData(TEXANIM* ta,int* conv);
};
#endif
| [
"a_jagers@ANTHONYJ.(none)"
] | [
[
[
1,
88
]
]
] |
7a37969495d951a7ed7ea0ec7695b55d611e065e | b2b5c3694476d1631322a340c6ad9e5a9ec43688 | /Baluchon/FrameBox.cpp | ddbf94188c32774537224948d26079fc0f71a149 | [] | no_license | jpmn/rough-albatross | 3c456ea23158e749b029b2112b2f82a7a5d1fb2b | eb2951062f6c954814f064a28ad7c7a4e7cc35b0 | refs/heads/master | 2016-09-05T12:18:01.227974 | 2010-12-19T08:03:25 | 2010-12-19T08:03:25 | 32,195,707 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,284 | cpp | #include "FrameBox.h"
#include "RectangularFacet.h"
#include "MathUtility.h"
using namespace baluchon::utilities;
namespace baluchon { namespace core { namespace services { namespace positioning {
FrameBox::FrameBox(BoxPrism* box, CvScalar color) {
mColor = color;
RectangularFacet* fFront = box->getFrontFacet();
RectangularFacet* fSide = box->getSideFacet();
RectangularFacet* fTop = box->getTopFacet();
CvPoint ptTopLeft;
CvPoint ptTop;
CvPoint ptTopRight;
CvPoint ptBottomRight;
CvPoint ptBottom;
CvPoint ptBottomLeft;
CvPoint ptCenter;
// Contours
if (fTop->getTopRightVertex().x > fTop->getBottomRightVertex().x) {
ptTopLeft = MathUtility::intersect(fFront->getBottomLeftVertex(), fFront->getTopLeftVertex(), fTop->getBottomLeftVertex(), fTop->getTopLeftVertex());
//ptTopLeft = MathUtility::middle(fFront->getTopLeftVertex(), fTop->getBottomLeftVertex());
ptTop = fTop->getTopLeftVertex();
ptTopRight = MathUtility::intersect(fSide->getBottomRightVertex(), fSide->getTopRightVertex(), fTop->getTopRightVertex(), fTop->getTopLeftVertex());
//ptTopRight = MathUtility::middle(fSide->getTopRightVertex(), fTop->getTopRightVertex());
ptBottomRight = fSide->getBottomRightVertex();
ptBottom = MathUtility::intersect(fFront->getBottomLeftVertex(), fFront->getBottomRightVertex(), fSide->getBottomLeftVertex(), fSide->getBottomRightVertex());
//ptBottom = MathUtility::middle(fFront->getBottomRightVertex(), fSide->getBottomLeftVertex());
ptBottomLeft = fFront->getBottomLeftVertex();
ptCenter = MathUtility::middle(fFront->getTopRightVertex(), fTop->getBottomRightVertex());
ptCenter = MathUtility::middle(ptCenter, fSide->getTopLeftVertex());
}
else {
ptTopLeft = MathUtility::intersect(fFront->getBottomLeftVertex(), fFront->getTopLeftVertex(), fTop->getTopLeftVertex(), fTop->getTopRightVertex());
//ptTopLeft = MathUtility::middle(fFront->getTopLeftVertex(), fTop->getTopLeftVertex());
ptTop = fTop->getTopRightVertex();
ptTopRight = MathUtility::intersect(fSide->getBottomRightVertex(), fSide->getTopRightVertex(), fTop->getBottomRightVertex(), fTop->getTopRightVertex());
//ptTopRight = MathUtility::middle(fSide->getTopRightVertex(), fTop->getBottomRightVertex());
ptBottomRight = fSide->getBottomRightVertex();
ptBottom = MathUtility::intersect(fFront->getBottomLeftVertex(), fFront->getBottomRightVertex(), fSide->getBottomLeftVertex(), fSide->getBottomRightVertex());
//ptBottom = MathUtility::middle(fFront->getBottomRightVertex(), fSide->getBottomLeftVertex());
ptBottomLeft = fFront->getBottomLeftVertex();
ptCenter = MathUtility::middle(fFront->getTopRightVertex(), fTop->getBottomLeftVertex());
ptCenter = MathUtility::middle(ptCenter, fSide->getTopLeftVertex());
}
mListPoints.push_back(ptTopLeft);
mListPoints.push_back(ptTop);
mListPoints.push_back(ptTopRight);
mListPoints.push_back(ptBottomRight);
mListPoints.push_back(ptBottom);
mListPoints.push_back(ptBottomLeft);
mListPoints.push_back(ptCenter);
}
FrameBox::~FrameBox(void) {
}
void FrameBox::accept(IVisitor* v) {
v->visit(this);
}
vector<CvPoint> FrameBox::getListPoints() {
return mListPoints;
}
}}}};
| [
"jpmorin196@bd4f47a5-da4e-a94a-6a47-2669d62bc1a5"
] | [
[
[
1,
90
]
]
] |
fd2458ff1023fe1f75c6e38e09a8db8f8f5c9b80 | 23052e5d5bff5c1237d102a12a6b4a8591c79974 | /sim.h | c2b88f0a9278d7cad0c46adddff857e9ca84be7a | [] | no_license | PoRTiLo/ims | c7ad0df4f193cbc8bc5509cdf23d13e4694cb4b9 | a4c02efd31fb258dad089e0f95b2752fef6dd73c | refs/heads/master | 2020-05-17T03:14:46.679835 | 2009-12-18T00:02:14 | 2009-12-18T00:02:14 | 335,484 | 0 | 0 | null | null | null | null | ISO-8859-2 | C++ | false | false | 12,331 | h | /*
* --------------IMS-----------------
*
* Project: Implementace diskr. simulรกtoru zaloลพenรฉho na ลรญzenรญ UDรLOSTMI (opak procesnฤ orientovanรฉho pลรญstupu)
* File: sim.h
* Author: Jaroslav Sendler, xsendl00, [email protected]
* Duลกan Kovaฤiฤ, xkovac21, [email protected]
*
* Encoding: ISO-8859-2
*
* Description:
*/
#include <fstream>
#include <queue>
#include <deque>
#include <string>
#include "sgen.h"
using namespace std;
/************************** event ****************************************/
class sEvent //trieda sEvent
{
public:
sEvent(); //konstruktor, meno defaultne, priorita zakladna,cas nulovy
sEvent(string start); //konstruktor, meno start, priorita zakladna, cas nulovy
sEvent(string start, double now); //konstruktor, meno start, priorita zakladna, cas now
sEvent(string start, double now, int prio); //konstruktor, meno start, priorita prio, cas now
~sEvent(); //destruktor
void setName(string id);
string name; //meno
double time; //cas udalosti
int priority; //prioriorita
int type;
};
/************************** queue *****************************************/
class sQueue //trieda sQueue
{
public:
sQueue(); //konstruktor, meno defaultne
sQueue(string id); //konstruktor, meno id
~sQueue(); //destruktor
string name; //meno
void push(sEvent event); //vloz event do fronty
void pop(); //vyber event z fronty
sEvent front(); //vrati prvy prvok fronty
sEvent back(); //vrati posledny prvok fronty
bool isEmpty(); //zisti ci je fronta prazdna
void setName(string id);
int size(); //zisti velkost
int getTotalNum(); //zisti pocet ludi co presli frontou
double getTimeUsed(); //zisti cas po ktory bola fornta pouzivana
double getTimeStart();
double getAvarageLength(); //zisti priemernu dlzku fornty
private:
double curNum; //pomocna premmenan pre priemernu dlzku
int counter; //pocitadlo pristupov
bool first; //rozlisuje prvy pristup pre detekovanie zaciatku pouzivania
double start; //zaciatocny cas pouzivania
double timeUsed; //cas po ktory bola fronta pouzivana
deque<sEvent> queueEvents; //fronta
};
/******************************************* calendar unit ********************/
class sCalUnit { //trieda sCalUnit - prvok kalendara udalosti
public:
sCalUnit(sEvent *event=0); //konstruktor
~sCalUnit(){}; //destruktor
sCalUnit* contiguous; //pointer na dalsi prvok
sCalUnit* previous; //pointer na predchadzajuci prvok
sEvent* event; //pointer na event
};
/****************************** calendar *************************************/
/**
* Trida sCalendar je implementovana pomoci obousmerneho linearniho zretezeneho
* seznameu s hlavickou.
*/
class sCalendar { //trieda sCalendar
sCalUnit *head; //hlavicka
int count; //pocet prvku v seznamu
private:
void dbCopy(const sCalendar& t);
void dbInit(); //inicializace kalendare
public:
sCalendar() { dbInit(); } //konstruktor kalendare
sCalendar(const sCalendar& t); //vytvoreni kalendare
~sCalendar(); //destruktor kalendare
void dbDelete(sEvent* event); //zruseni udalosti
void dbDelete(); //zruseni vsech udalosti
int dbGetCount() const; //pocet udaloi v kalendari
void dbInsertEvent(sEvent event); //pridani udalosti do kalendare
sCalUnit* dbSearch(sEvent* event) const; //vrati pozice prvku pred ktery se ma vlozit
sCalUnit* dbGetFirst() const; //vrati ukazatel na prvni prvek kalendare
sEvent dbGetNextEvent(); //vrati ukazatel na dalsi Udalost kalendare(prvni)
void dbShow() const; //zobrazeni obsahu kalendare
bool dbIsEmpty() const; //kontrola zda je kalendar przadny
};
class sFascility //trieda sFascility
{
public:
sFascility(); //konstruktor, meno defaultne
sFascility(string id); //konstruktor, meno id
~sFascility(); //destruktor
string name; //meno
bool free; //zariadenie je volne defaultne
sEvent currentEvent;
void setName(string id);
void seize(sEvent a); //zabere zariadenie
void release(); //opusti zariadenie
private:
sQueue fascQueue; //fronta pre udalosti ak je zariadenie obsadene
sQueue removedQueue; //fronta vyhodenych eventov
};
class sStorage //trieda sStorage
{
public:
sStorage(); //konstruktor, meno default, kapacita 1
sStorage(int capacity); //konstruktor, meno default, kapacita capacity
sStorage(int capacity, string id); //konstruktor, meno id, kapacita capacity
~sStorage(); //destruktor
string name; //meno
void setCapacity(int capacity);
void setName(string id);
void take(sEvent event); //zobere polozku zo skladu - change
void bringBack(double time); //vrati polozku do skladu
int getStorageSize(); //zisti velkost skladu
int getStoregeLeft(); //zisti pocet poloziek v sklade
double getTimeUsed(); //zisti dobu pouzivania skladu
double getUsagePerUnit(int i); //zisti dobu pouzivania ked bolo v sklade prave i poloziek
bool isEmpty(); //zisti ci je sklad prazdny
private:
int left; //zasoba v sklade
int full; //maximalny obsah skladu
sQueue storQueue; //fronta pre udalosti ak je sklad prazdny
double *currentTime; //pointer na pole s casmi pre vypocet getUsagePerUnit()
double *takenByEvents; //pointer na pole s casmi pre vypocet getUsagePerUnit()
double timeUsed; //zaciatok pouzivania skladu
double timeTotal; //cas pouzivania skladu
bool first; //detekuje prvy zasah do skladu
};
class sSimulation //trieda sSimulation
{
public:
sSimulation(); //konstruktor, meno defaultne
sSimulation(string id); //konstruktor, meno id
~sSimulation(); //destruktor
string name; //meno
sGen gen; //generator pseudonahodnych cisel
sCalendar calendar; //kalendar udalosti
void setName(string id);
void start(double length); //start simulacie, zaciatok v case 0, koniec v case length
void start(double begin,double end); //start simulacie, zaciatok v case begin, koniec v case end
bool isRunning(); //zisti ci simulacia bezi
double startTime; //start time
double finishTime; //finish time
double currentTime; //current time
protected:
bool running; //zisti ci simulacia bezi
};
class sStats //trieda sStats
{
public:
sStats(); //konstruktor, simulacia nedefinovana, musi sa definovat!
sStats(sSimulation* a); //konstruktor, simulacia a
~sStats(); //destruktor
void registerSimulation(sSimulation*); //zaregistruje simulaciu
void registerObject(sStorage*); //zaregistruje sklad pre vypis jeho statistik
void registerObject(sFascility*); //zaregistruje zariadenie pre vypis jeho statisti
void registerObject(sQueue*); //zaregistruje frontu pre vypis jeho statisti
void print(); //vytlaci statistiku
void setOutputToFile(string name); //presmeruje standartny vystup do suboru, na konci programu je nutne zavolat SerOutputDefault pre spravne uzavretie suboru
void setOutputDefault(); //presmeruje vystup na zakladny
private:
queue<sStorage*> sStatsQueuesStorage; //fronta registrovanych skladov
queue<sFascility*> sStatsQueuesFascility; //fronta registrovanych zariadeni
queue<sQueue*> sStatsQueuesQueue; //fronta registrovanych front
bool registered; //ci je zadana simulacia
bool fopened; //ci je otvoreny subor
ofstream file; //subor do ktroreho sa vypisuje
streambuf* sbuf; //pomocna premenna pre vypis do suboru
sSimulation* sim; //simulacia
};
| [
"[email protected]"
] | [
[
[
1,
209
]
]
] |
7dbd876e79b5d21698f3039a3a3b07f9316f2535 | ce262ae496ab3eeebfcbb337da86d34eb689c07b | /SEApplications/SE_DX10_Application/SEDX10Application/SEConsoleApplication.h | 5e4fe87da4c08c60dd02ba655cb1b3e005b3222d | [] | no_license | pizibing/swingengine | d8d9208c00ec2944817e1aab51287a3c38103bea | e7109d7b3e28c4421c173712eaf872771550669e | refs/heads/master | 2021-01-16T18:29:10.689858 | 2011-06-23T04:27:46 | 2011-06-23T04:27:46 | 33,969,301 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,675 | h | // Swing Engine Version 1 Source Code
// Most of techniques in the engine are mainly based on David Eberly's
// Wild Magic 4 open-source code.The author of Swing Engine learned a lot
// from Eberly's experience of architecture and algorithm.
// Several sub-systems are totally new,and others are re-implimented or
// re-organized based on Wild Magic 4's sub-systems.
// Copyright (c) 2007-2010. All Rights Reserved
//
// Eberly's permission:
// Geometric Tools, Inc.
// http://www.geometrictools.com
// Copyright (c) 1998-2006. All Rights Reserved
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or (at
// your option) any later version. The license is available for reading at
// the location:
// http://www.gnu.org/copyleft/lgpl.html
#ifndef Swing_ConsoleAppliCation_H
#define Swing_ConsoleAppliCation_H
#include "SEApplication.h"
namespace Swing
{
//----------------------------------------------------------------------------
// ่ฏดๆ:
// ไฝ่
:Sun Che
// ๆถ้ด:20080809
//----------------------------------------------------------------------------
class SEConsoleApplication : public SEApplication
{
public:
SEConsoleApplication(void);
virtual ~SEConsoleApplication(void);
// ๅบ็จ็จๅบ่ด่ดฃๅฎ็ฐๅ
ฅๅฃๅฝๆฐ,่ฟๅๅผไธบexit code.
virtual int Main(int iArgCount, char** apcArgument) = 0;
protected:
// ้ฉๅญๅฝๆฐ่ฐ็จๅ
ฅๅฃๅฝๆฐMain.
static int Run(int iArgCount, char** apcArgument);
};
}
#endif
| [
"[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac"
] | [
[
[
1,
50
]
]
] |
5ec5ecfffbf6eedb8704785b33e95c52aff0460f | 6fd162d2cade2db745e68f11d7e9722a3855f033 | /Include/S3UT/S3UTmesh.h | 70a72dae53ea7c2a177b0574b33ce50a22afd928 | [] | no_license | SenichiFSeiei/oursavsm | 8f418325bc9883bcb245e139dbd0249e72c18d78 | 379e77cab67b3b1423a4c6f480b664f79b03afa9 | refs/heads/master | 2021-01-10T21:00:52.797565 | 2010-04-27T13:18:19 | 2010-04-27T13:18:19 | 41,737,615 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,353 | h | //----------------------------------------------------------------------------------
// File: S3UTMesh.h
// Author: Baoguang Yang
//
// Copyright (c) 2009 S3Graphics Corporation. All rights reserved.
//
// Contains code manipulating various kinds of meshes, including .x, .sdkmesh
//
//----------------------------------------------------------------------------------
#pragma once
#ifndef S3UTMESH_H
#define S3UTMESH_H
#define MAX_STATIC_OBJ 100
#include <sdkmesh_old.h>
#include "AnimationMesh.h"
class S3UTMesh : public CDXUTMesh10
{
public:
S3UTMesh();
void set_parameters( bool render_warrior,
bool render_static_obj,
bool render_windmill,
bool render_floor = true )
{
m_bRenderWarrior = render_warrior;
m_bRenderStaticObjs = render_static_obj;
m_bRenderWindmill = render_windmill;
m_bRenderFloor = render_floor;
}
void render_fence( bool swh )
{
m_bRenderFence = swh;
}
void render_fan( bool swh )
{
m_bRenderFan = swh;
}
void set_biases( float *biases, int n )
{
for( int i = 0; i < n; ++i )
{
m_fBiases[ i ] = biases[i];
}
m_nBiasCounter = 0;
m_pWarriorMesh->set_biases( biases, n );
}
void increase_bias_counter( int cnt )
{
m_nBiasCounter += cnt;
m_pWarriorMesh->increase_bias_counter( cnt );
}
HRESULT Create(ID3D10Device *pDev10, LPCTSTR szFileName, D3D10_INPUT_ELEMENT_DESC* playout, UINT cElements, bool bOptimize=true);
//main interface of the mesh class in my design
HRESULT Create(
WCHAR *pWarriorMeshName,
WCHAR *pWarriorAnimName,
LPCTSTR szWindmillBaseName,
LPCTSTR szWindmillFanName,
LPCTSTR szPlaneMeshName,
LPCTSTR *szStaticObjFileNames,
UINT num_static_meshes,
D3D10_INPUT_ELEMENT_DESC *pSuitLayout,
D3D10_INPUT_ELEMENT_DESC *pBodyLayout,
D3D10_INPUT_ELEMENT_DESC* pStaticMeshLayout,
ID3D10Device *pDev10
);
// Methods to load and render with normal maps, functions of based mesh are hidden for objects of S3UTMesh class.
HRESULT CreateWithNormalMaps(ID3D10Device *pDev10, LPCTSTR szFileName, D3D10_INPUT_ELEMENT_DESC* playout, UINT cElements, bool bOptimize=true, const char*szNormalSuffix="_nm");
void Render( ID3D10Device *pDev );
void Render( ID3D10Device *pDev,
ID3D10EffectTechnique *pTechnique,
ID3D10EffectShaderResourceVariable* ptxDiffuse = NULL,
ID3D10EffectVectorVariable* pvDiffuse = NULL,
ID3D10EffectVectorVariable* pvSpecular = NULL,
DWORD dwSubset = (DWORD)-1,
ID3D10EffectShaderResourceVariable* ptxNormal = NULL);
void Render(UINT max_bone_matrices,
float scale,
ID3D10Effect* pEffect,
ID3D10EffectTechnique* pSuitTechnique,
ID3D10EffectTechnique* pBodyTechnique,
ID3D10EffectTechnique* pTechnique,
ID3D10EffectTechnique* pSceneTechnique,
D3DXMATRIX* p_view_proj_matrix,
ID3D10Device* pDev,
double fTime, float fElapsedTime, void* pUserContext,bool use_bias = false);
void RenderInstanced( ID3D10Device *pDev,
ID3D10EffectTechnique *pTechnique,
UINT uiInstanceCount,
ID3D10EffectShaderResourceVariable* ptxDiffuse = NULL,
ID3D10EffectVectorVariable* pvDiffuse = NULL,
ID3D10EffectVectorVariable* pvSpecular = NULL );
void Destroy();
private:
D3DXVECTOR3 m_vBox[2]; ///< bounding box for the mesh
// Vars to to hold loaded normal maps if used.
ID3D10Texture2D **m_ppNormalTextures;
ID3D10ShaderResourceView **m_ppNormalSRVs;
AnimationMesh *m_pWarriorMesh;
bool m_bRenderWarrior;
bool m_bRenderStaticObjs;
bool m_bRenderWindmill;//including the fan and the fence
bool m_bRenderFan;//take effect only when m_bRenderWindmill is true
bool m_bRenderFence;//take effect only when m_bRenderWindmill is true
bool m_bRenderFloor;
CDXUTMesh10 m_StaticMeshes[MAX_STATIC_OBJ];
UINT m_nNumStaticMesh;
CDXUTSDKMesh m_WindmillBaseMesh;
CDXUTSDKMesh m_WindmillFanMesh;
float m_fBiases[MAX_STATIC_OBJ]; //POTENTIALLY DANGEROUS
int m_nBiasCounter;
};
#endif // S3UTMESH_H
| [
"[email protected]"
] | [
[
[
1,
128
]
]
] |
069d69e5a4c55ce0d83171701253e78a775bfa3b | 1e976ee65d326c2d9ed11c3235a9f4e2693557cf | /InfoPane.cpp | c9139b4d53d282eb59628b09d4c8251234934dcc | [] | no_license | outcast1000/Jaangle | 062c7d8d06e058186cb65bdade68a2ad8d5e7e65 | 18feb537068f1f3be6ecaa8a4b663b917c429e3d | refs/heads/master | 2020-04-08T20:04:56.875651 | 2010-12-25T10:44:38 | 2010-12-25T10:44:38 | 19,334,292 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,319 | cpp | ๏ปฟ// /*
// *
// * Copyright (C) 2003-2010 Alexandros Economou
// *
// * This file is part of Jaangle (http://www.jaangle.com)
// *
// * This Program is free software; you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation; either version 2, or (at your option)
// * any later version.
// *
// * This Program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with GNU Make; see the file COPYING. If not, write to
// * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
// * http://www.gnu.org/copyleft/gpl.html
// *
// */
#include "stdafx.h"
#include "TeenSpirit.h"
#include "InfoPane.h"
#include "MediaPlayer.h"
#include "PrgAPI.h"
#include "ShortcutManager.h"
#include "SQLManager.h"
#include "StringSerializerHelper.h"
InfoPane::InfoPane():
m_bSyncWithPlayer(TRUE),
m_bSyncWithSections(TRUE),
m_bSyncWithTracks(TRUE),
m_pOptionsMenu(NULL),
m_pShowItemsMenu(NULL),
m_pVideoContainer(NULL),
m_hwndParent(0),
m_bAutomaticallyShowVideo(TRUE)
{
}
InfoPane::~InfoPane()
{
PrgAPI* pAPI = PRGAPI();
//pAPI->SetOption(OPT_VIEWER_SyncWithPlayer, m_bSyncWithPlayer);
if (m_infoCtrl.m_hWnd != NULL)
m_infoCtrl.DestroyWindow();
delete m_pOptionsMenu;
delete m_pShowItemsMenu;
delete m_pVideoContainer;
}
BOOL InfoPane::Init(HWND hwndParent)
{
m_hwndParent = hwndParent;
if (m_infoCtrl.GetSafeHwnd() != NULL)
return TRUE;
if (m_infoCtrl.Create(CWnd::FromHandle(hwndParent), 550))
{
//SetButton(IDC_OPTIONS, NULL, PRGAPI()->GetIcon(ICO_Options16), 16, 16, TRUE);
//m_infoCtrl.Create(this, 902);
//SetMainControl(&m_infoCtrl);
HWND hwnd = m_infoCtrl.GetWindowForFocus();
if (hwnd != NULL)
PRGAPI()->GetShortcutManager()->RegisterShortcutForFocus(VK_F5, hwnd);
OnStateChanged(SM_MediaChanged);
//m_infoCtrl.ShowWindow(SW_SHOW);
return TRUE;
}
return FALSE;
}
void InfoPane::UnInit()
{
if (m_infoCtrl.GetSafeHwnd())
{
HWND hwnd = m_infoCtrl.GetWindowForFocus();
if (hwnd != NULL)
PRGAPI()->GetShortcutManager()->UnRegisterShortcutForFocus(hwnd);
PRGAPI()->GetStateManager()->UnRegisterStateChangeListener(*this);
m_infoCtrl.DestroyWindow();
}
}
BOOL InfoPane::Show()
{
if (m_infoCtrl.GetSafeHwnd())
{
if (m_infoCtrl.IsWindowVisible())
return TRUE;
PRGAPI()->GetStateManager()->RegisterStateChangeListener(*this);
FullTrackRecordCollection& col = PRGAPI()->GetStateManager()->GetState().GetTrackList();
if (col.size() > 0)
{
m_infoCtrl.SetActiveItem(col[0]);
m_infoCtrl.SetStyle(IT_Album);
}
m_infoCtrl.ShowWindow(SW_SHOW);
m_infoCtrl.Refresh();
return TRUE;
}
return FALSE;
}
void InfoPane::Hide()
{
if (m_infoCtrl.GetSafeHwnd())
m_infoCtrl.ShowWindow(SW_HIDE);
}
void InfoPane::MovePane(INT x, INT y, INT cx, INT cy)
{
m_infoCtrl.MoveWindow(x, y, cx, cy, FALSE);
if (m_pVideoContainer != NULL)
m_pVideoContainer->MoveWindow(x, y, cx, cy, FALSE);
}
LPCTSTR InfoPane::GetTitle(UINT captionNum)
{
PrgAPI* pAPI = PRGAPI();
switch (captionNum % 3)
{
case 0:
return pAPI->GetString(IDS_SPECIALINFO);
case 1:
{
const std::vector<InfoItemTypeEnum>& items = m_infoCtrl.GetShowingItems();
if (items.size() == 0)
_sntprintf(m_stringBuffer, 500, _T("%s: -"), pAPI->GetString(IDS_SHOW));
else
{
_sntprintf(m_stringBuffer, 500, _T("%s: "), pAPI->GetString(IDS_SHOW));
for (UINT i = 0; i < items.size(); i++)
{
if (i > 0)
_tcscat(m_stringBuffer, _T(", "));
_tcscat(m_stringBuffer, pAPI->GetStringForInfoItemType(items[i]));
}
}
return m_stringBuffer;
}
break;
case 2:
_sntprintf(m_stringBuffer, 500, _T("%s: [F5]"), pAPI->GetString(IDS_FOCUS));
return m_stringBuffer;
}
return NULL;
}
BOOL InfoPane::GetButtonInfo(PaneButtonInfo& bInfo, UINT idx)
{
switch (idx)
{
case BT_Options:
bInfo.hIcon = PRGAPI()->GetIcon(ICO_Options16);
bInfo.iconSize = 16;
bInfo.text = NULL;
return TRUE;
break;
}
return FALSE;
}
BOOL InfoPane::OnButton(UINT idx)
{
switch (idx)
{
case MI_SyncWithPlayer:
m_bSyncWithPlayer = !m_bSyncWithPlayer;
break;
case MI_SyncWithSectionChanger:
m_bSyncWithSections = !m_bSyncWithSections;
break;
case MI_SyncWithTracksChanger:
m_bSyncWithTracks = !m_bSyncWithTracks;
break;
case MI_AutomaticallyShowVideo:
m_bAutomaticallyShowVideo = !m_bAutomaticallyShowVideo;
OnStateChanged(SM_MediaChanged);
break;
default:
if (idx > MI_ShowItemsStart && idx <= MI_ShowItemsEnd)
{
InfoItemTypeEnum iit = (InfoItemTypeEnum) (idx - MI_ShowItemsStart);
m_infoCtrl.EnableInfoType(iit, !m_infoCtrl.IsInfoTypeEnabled(iit));
m_infoCtrl.Refresh();
}
else
return FALSE;
}
return TRUE;
}
const LPCTSTR cInfoPane_Header = _T("Header");
const LPCTSTR cInfoPane_SyncWithPlayer = _T("SyncWithPlayer");
const LPCTSTR cInfoPane_SyncWithSections = _T("SyncWithSections");
const LPCTSTR cInfoPane_SyncWithTracks = _T("SyncWithTracks");
const LPCTSTR cInfoPane_AutomaticallyShowVideo = _T("AutomaticallyShowVideo");
const LPCTSTR cInfoPane_EnableInfoItem = _T("EnableInfoItem");
void InfoPane::GetBoolValue(IPaneState& paneState, LPCTSTR value, BOOL& bValue)
{
INT intValue = paneState.GetIntSetting(value);
if (intValue != -1)
bValue = (intValue != 0);
}
BOOL InfoPane::LoadState(IPaneState& paneState)
{
LPCTSTR sValue = paneState.GetLPCTSTRSetting(cInfoPane_Header);
if (_tcsicmp(sValue, InfoPaneInfo.Name) != 0)
return FALSE;
GetBoolValue(paneState, cInfoPane_SyncWithPlayer, m_bSyncWithPlayer);
GetBoolValue(paneState, cInfoPane_SyncWithSections, m_bSyncWithSections);
GetBoolValue(paneState, cInfoPane_SyncWithTracks, m_bSyncWithTracks);
GetBoolValue(paneState, cInfoPane_AutomaticallyShowVideo, m_bAutomaticallyShowVideo);
TCHAR bf[500];
for (INT i = IIT_Unknown + 1; i < IIT_Last; i++)
{
_sntprintf(bf, 500, _T("%s_%d"), cInfoPane_EnableInfoItem, i);
INT value = paneState.GetIntSetting(bf);
if (value != -1)
m_infoCtrl.EnableInfoType((InfoItemTypeEnum)i, value > 0);
}
return TRUE;
}
BOOL InfoPane::SaveState(IPaneState& paneState)
{
paneState.SetLPCTSTRSetting(cInfoPane_Header, InfoPaneInfo.Name);
paneState.SetIntSetting(cInfoPane_SyncWithPlayer, m_bSyncWithPlayer);
paneState.SetIntSetting(cInfoPane_SyncWithSections, m_bSyncWithSections);
paneState.SetIntSetting(cInfoPane_SyncWithTracks, m_bSyncWithTracks);
paneState.SetIntSetting(cInfoPane_AutomaticallyShowVideo, m_bAutomaticallyShowVideo);
TCHAR bf[500];
for (INT i = IIT_Unknown + 1; i < IIT_Last; i++)
{
BOOL bEnable = FALSE;
_sntprintf(bf, 500, _T("%s_%d"), cInfoPane_EnableInfoItem, i);
paneState.SetIntSetting(bf, m_infoCtrl.IsInfoTypeEnabled((InfoItemTypeEnum)i));
}
return TRUE;
}
void InfoPane::ApplyTranslation(ITranslation& translation)
{
if (m_pOptionsMenu != NULL)
{
m_pShowItemsMenu->Destroy();
m_pOptionsMenu->Destroy();
}
}
BOOL InfoPane::OnStateChanged(UINT stateMessages)
{
BOOL bHandled = TRUE;
switch (stateMessages)
{
case SM_CurrentSectionChanged:
{
if (m_bSyncWithSections)
{
PrgAPI* pAPI = PRGAPI();
TSState& state = pAPI->GetStateManager()->GetState();
m_infoCtrl.SetStyle(IT_Unknown);
FullTrackRecordCollection& col = state.GetTrackList();
if (col.size() > 0)
{
m_infoCtrl.SetActiveItem(col[0]);
m_infoCtrl.SetStyle(state.activeItemType);
m_infoCtrl.Refresh(100);
}
}
}
break;
case SM_CurrentTrackChanged:
if (m_bSyncWithTracks)
{
PrgAPI* pAPI = PRGAPI();
TSState& state = pAPI->GetStateManager()->GetState();
FullTrackRecordSP rec;
if (pAPI->GetSQLManager()->GetFullTrackRecordByID(rec, state.trackListTrackID))
{
m_infoCtrl.SetStyle(IT_Track);
m_infoCtrl.SetActiveItem(rec);
m_infoCtrl.Refresh(100);
}
}
break;
case SM_MediaChanged:
if (m_bSyncWithPlayer)
{
PrgAPI* pAPI = PRGAPI();
MediaPlayer* pMP = pAPI->GetMediaPlayer();
INT pos = pMP->GetPlayListPos();
if (pos >= 0 && pos < (INT)pMP->GetPlayListCount())
{
MediaPlayListItem mpli;
if (pMP->GetPlayListItem(mpli, pos))
{
FullTrackRecordSP rec;
if (pAPI->GetSQLManager()->GetFullTrackRecordByLocation(rec, mpli.url))
{
m_infoCtrl.SetStyle(IT_Track);
m_infoCtrl.SetActiveItem(rec);
m_infoCtrl.Refresh(100);
}
}
}
}
if (m_bAutomaticallyShowVideo)
{
MediaPlayer* pMP = PRGAPI()->GetMediaPlayer();
if (pMP->IsVideo())
{
//=== It is a video. Check if there is a viewer attached to the player
if (pMP->GetVideoContainerHWND() == NULL)
{
//=== Media Player DO NOT have a video viewer attached
//=== DECISION: We will attach our Viewer
ASSERT(m_pVideoContainer == NULL);
m_pVideoContainer = new CVideoContainer;
if (m_pVideoContainer->Create( NULL, NULL, WS_VISIBLE | WS_CHILD, CRect(0,0,0,0), CWnd::FromHandle(m_hwndParent), 920, NULL))
{
m_pVideoContainer->Init(pMP);
CRect rc;
m_infoCtrl.GetWindowRect(&rc);
ScreenToClient(m_hwndParent, &rc.TopLeft());
ScreenToClient(m_hwndParent, &rc.BottomRight());
m_pVideoContainer->MoveWindow(&rc);
m_infoCtrl.ShowWindow(SW_HIDE);
}
else
{
//=== FAILED for some reason
ASSERT(0);
delete m_pVideoContainer;
m_pVideoContainer = NULL;
}
}
else
{
//=== Media Player has already a video viewer attached
if (m_pVideoContainer == NULL)
{
//=== It is not ours...
//=== DECISION: Do nothing ... leave the InfoControl...
}
else
{
//=== It should be OUR player (playing from a previous track)
//=== Decision: Do nothing... let it continue play
}
}
}
else
{
//=== It is not a video
//=== Clear the videoContainer
if (m_pVideoContainer != NULL)
{
m_pVideoContainer->DestroyWindow();
delete m_pVideoContainer;
m_pVideoContainer = NULL;
m_infoCtrl.ShowWindow(SW_SHOW);
}
}
}
else
{
//=== It is not a video
//=== Clear the videoContainer
if (m_pVideoContainer != NULL)
{
m_pVideoContainer->DestroyWindow();
delete m_pVideoContainer;
m_pVideoContainer = NULL;
m_infoCtrl.ShowWindow(SW_SHOW);
}
}
break;
case SM_InfoChanged:
case SM_PictureChanged:
m_infoCtrl.Refresh();
break;
default:
bHandled = FALSE;
}
return bHandled;
}
ITSMenu* InfoPane::GetMenu(UINT idx)
{
if (idx == BT_Options)
{
PrgAPI* pAPI = PRGAPI();
if (m_pOptionsMenu == 0)
{
m_pShowItemsMenu = pAPI->CreatePopupMenu();
m_pOptionsMenu = pAPI->CreatePopupMenu();
}
if (m_pOptionsMenu->GetInternalHandler() == 0)
{
m_pShowItemsMenu->Create();
for (INT i = IIT_Unknown + 1; i < IIT_Last; i++)
{
switch (i)
{
case IIT_GenrePicture:
case IIT_YearPicture:
case IIT_CollectionPicture:
case IIT_MonthPicture:
break;
default:
m_pShowItemsMenu->AppendMenu(ITSMenu::MIT_String, MI_ShowItemsStart + i, (LPTSTR)pAPI->GetStringForInfoItemType((InfoItemTypeEnum)i));
}
}
m_pOptionsMenu->Create();
m_pOptionsMenu->AppendMenu(ITSMenu::MIT_Menu, (UINT) m_pShowItemsMenu->GetInternalHandler(), (LPTSTR)pAPI->GetString(IDS_SHOW));
m_pOptionsMenu->AppendMenu(ITSMenu::MIT_Separator, NULL, NULL);
m_pOptionsMenu->AppendMenu(ITSMenu::MIT_String, MI_SyncWithPlayer, (LPTSTR)pAPI->GetString(IDS_SYNCWITHPLAYER));
m_pOptionsMenu->AppendMenu(ITSMenu::MIT_String, MI_SyncWithSectionChanger, (LPTSTR)pAPI->GetString(IDS_SYNCWITHSECTIONS));
m_pOptionsMenu->AppendMenu(ITSMenu::MIT_String, MI_SyncWithTracksChanger, (LPTSTR)pAPI->GetString(IDS_SYNCWITHTRACKS));
m_pOptionsMenu->AppendMenu(ITSMenu::MIT_Separator, NULL, NULL);
m_pOptionsMenu->AppendMenu(ITSMenu::MIT_String, MI_AutomaticallyShowVideo, (LPTSTR)pAPI->GetString(IDS_VIDEO));
};
for (INT i = IIT_Unknown + 1; i < IIT_Last; i++)
{
m_pShowItemsMenu->CheckMenuItem(MI_ShowItemsStart + i,
MF_BYCOMMAND |
(m_infoCtrl.IsInfoTypeEnabled(InfoItemTypeEnum(i)) ? MF_CHECKED : MF_UNCHECKED)
);
}
m_pOptionsMenu->CheckMenuItem(MI_SyncWithPlayer, MF_BYCOMMAND | (m_bSyncWithPlayer ? MF_CHECKED : MF_UNCHECKED));
m_pOptionsMenu->CheckMenuItem(MI_SyncWithSectionChanger, MF_BYCOMMAND | (m_bSyncWithSections ? MF_CHECKED : MF_UNCHECKED));
m_pOptionsMenu->CheckMenuItem(MI_SyncWithTracksChanger, MF_BYCOMMAND | (m_bSyncWithTracks ? MF_CHECKED : MF_UNCHECKED));
m_pOptionsMenu->CheckMenuItem(MI_AutomaticallyShowVideo, MF_BYCOMMAND | (m_bAutomaticallyShowVideo ? MF_CHECKED : MF_UNCHECKED));
return m_pOptionsMenu;
}
return NULL;
}
//BOOL InfoPane::OnCommand(WPARAM wParam, LPARAM lParam)
//{
// TRACEST(_T("CViewerPane::OnCommand"), wParam);
// PrgAPI* pAPI = PRGAPI();
// switch (wParam)
// {
// case IDC_OPTIONS:
// {
// m_OptionsMenu.CheckMenuItem(IDS_SYNCWITHPLAYER, m_bSyncWithPlayer ? MF_CHECKED : MF_UNCHECKED);
// RECT rc;
// GetDlgItem(wParam)->GetWindowRect(&rc);
// m_OptionsMenu.TrackPopupMenu(TPM_LEFTALIGN, rc.left + ((rc.right - rc.left) / 2), rc.bottom, this);
// return 0;
// }
// break;
// case IDS_SYNCWITHPLAYER:
// m_bSyncWithPlayer = !m_bSyncWithPlayer;
// break;
// default:
// return CTeenSpiritPane::OnCommand(wParam, lParam);
// }
// return 0;
//}
//BEGIN_MESSAGE_MAP(InfoPane, CTeenSpiritPane)
// ON_WM_SIZE()
//END_MESSAGE_MAP()
//
//void InfoPane::OnSize(UINT nType, int cx, int cy)
//{
// CTeenSpiritPane::OnSize(nType, cx, cy);
// if (m_infoCtrl.m_hWnd != 0)
// m_infoCtrl.MoveWindow(0,0,cx,cy,TRUE);
//}
| [
"outcast1000@dc1b949e-fa36-4f9e-8e5c-de004ec35678"
] | [
[
[
1,
502
]
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.