コード例 #1
0
Region*
Palette::NewRegionNamed(std::string nm, int sid_low, int sid_high) {
	Region* r = newRegionNamed(nm);
	NosuchAssert(r);
	r->setTypeAndSid(Region::SURFACE,sid_low,sid_high);
	return r;
}
コード例 #2
0
void
Outlines_SharedMemHeader::check_sanity() {
	int nused = 0;
	if (buff_inuse[0])
		nused++;
	if (buff_inuse[1])
		nused++;
	if (buff_inuse[2])
		nused++;

	bool ptr_used[3];
	ptr_used[0] = false;
	ptr_used[1] = false;
	ptr_used[2] = false;
	if (buff_being_constructed != BUFF_UNSET) {
		ptr_used[buff_being_constructed] = true;
	}
	if (buff_displayed_last_time != BUFF_UNSET) {
		ptr_used[buff_displayed_last_time] = true;
	}
	if (buff_to_display_next != BUFF_UNSET) {
		ptr_used[buff_to_display_next] = true;
	}

	int nptrused = 0;
	if (ptr_used[0])
		nptrused++;
	if (ptr_used[1])
		nptrused++;
	if (ptr_used[2])
		nptrused++;

	NosuchAssert(nused != nptrused);
}
コード例 #3
0
Region*
Palette::NewButtonNamed(std::string nm, int sid_low, int sid_high, std::string patch) {
	Region* r = newRegionNamed(nm);
	NosuchAssert(r);
	r->setTypeAndSid(Region::BUTTON,sid_low,sid_high);
	r->setButtonPatch(patch);
	return r;
}
コード例 #4
0
ファイル: Region.cpp プロジェクト: phonexhsu/VizBench
void
Region::getCursors(std::list<Cursor*>& cursors ) {
	for ( std::list<Cursor*>::iterator i = _cursors.begin(); i!=_cursors.end(); i++ ) {
		Cursor* c = *i;
		NosuchAssert(c);
		cursors.push_back(c);
	}
}
コード例 #5
0
void Palette::changeSoundSet(int selected) {
	int sb = soundBank();

	NosuchAssert(selected>=0 && selected<NUM_SOUNDSETS);
	NosuchAssert(sb>=0 && sb<=NUM_SOUNDSETS);

	if ( SoundBank[sb][selected][0] == "" ) {
		NosuchErrorOutput("No sounds in soundbank %d !?",sb);
		return;
	}

	setRegionSound(1,SoundBank[sb][selected][0]);
	setRegionSound(2,SoundBank[sb][selected][1]);
	setRegionSound(3,SoundBank[sb][selected][2]);
	setRegionSound(4,SoundBank[sb][selected][3]);
	NosuchDebug(1,"CHANGED SOUND SET to number %d",selected);
	CurrentSoundSet = selected;
}
コード例 #6
0
ファイル: Region.cpp プロジェクト: phonexhsu/VizBench
void
Region::initSound() {
	if ( isSurface() ) {
		std::string snd = SoundBank[0][0][0];
		NosuchAssert(snd!="");
		params.sound = snd;
		UpdateSound();
	}
}
コード例 #7
0
static cJSON* jsonGet(cJSON *j, std::string nm, int jtype) {
	NosuchAssert(j);
	cJSON *c = cJSON_GetObjectItem(j,nm.c_str());
	if ( c && c->type == jtype ) {
		return c;
	} else {
		return NULL;
	}
}
コード例 #8
0
void
Region::initSound() {
	if ( isRegion() ) {
		std::string snd = SoundBank[0][0][0];
		NosuchAssert(snd!="");
		_regionParams->sound.set(snd);
		UpdateSound();
	}
}
コード例 #9
0
int
Outlines_SharedMemHeader::addPoint(buff_index b, float x, float y, float z) {
	NosuchAssert(b != BUFF_UNSET);
	int pnum = numpoints[b];
	PointMem* p = point(b, pnum);
	p->x = x;
	p->y = y;
	p->z = z;
	numpoints[b]++;
	return pnum;
}
コード例 #10
0
ファイル: Region.cpp プロジェクト: phonexhsu/VizBench
void Region::accumulateSpritesForCursor(Cursor* c) {
	spritelist_lock_write();
	for ( std::list<Sprite*>::iterator i = sprites.begin(); i!=sprites.end(); i++) {
		Sprite* s = *i;
		NosuchAssert(s);
		if ( s->state.sidnum == c->sidnum() && s->state.sidsource == c->sidsource() ) {
			s->accumulate(c);
		}
	}
	spritelist_unlock();
}
コード例 #11
0
double methodNeedDouble(std::string meth,cJSON *j,std::string nm) {
	NosuchAssert(j);
	cJSON *c = cJSON_GetObjectItem(j,nm.c_str());
	if ( ! c ) {
		throw NosuchException("Missing %s argument on %s method",nm.c_str(),meth.c_str());
	}
	if ( c->type != cJSON_Number ) {
		throw NosuchException("Unexpected type for %s argument to %s method, expecting double",nm.c_str(),meth.c_str());
	}
	return (double)(c->valuedouble);
}
コード例 #12
0
std::string methodNeedString(std::string meth,cJSON *j,std::string nm) {
	NosuchAssert(j);
	cJSON *c = cJSON_GetObjectItem(j,nm.c_str());
	if ( ! c ) {
		throw NosuchException("Missing %s argument on %s method",nm.c_str(),meth.c_str());
	}
	if ( c->type != cJSON_String ) {
		throw NosuchException("Unexpected type for %s argument to %s method, expecting string",nm.c_str(),meth.c_str());
	}
	return c->valuestring;
}
コード例 #13
0
double Region::MaxSpaceCursorDepth() {
	double maxval = 0;
	for ( std::list<SpaceCursor*>::iterator i = _palettecursors.begin(); i!=_palettecursors.end(); i++ ) {
		SpaceCursor* c = *i;
		NosuchAssert(c);
		double d = c->depth();
		if ( d > maxval )
			maxval = d;
	}
	return maxval;
}
コード例 #14
0
ファイル: Region.cpp プロジェクト: phonexhsu/VizBench
void Region::draw() {

	spritelist->draw();
#if 0
	spritelist_lock_read();
	for ( std::list<Sprite*>::iterator i = sprites.begin(); i!=sprites.end(); i++ ) {
		Sprite* s = *i;
		NosuchAssert(s);
		s->draw(b,this);
	}
	spritelist_unlock();
#endif
}
コード例 #15
0
SpaceCursor* Region::getSpaceCursor(int sidnum, std::string sidsource) {
	SpaceCursor* retc = NULL;

	for ( std::list<SpaceCursor*>::iterator i = _palettecursors.begin(); i!=_palettecursors.end(); i++ ) {
		SpaceCursor* c = *i;
		NosuchAssert(c);
		if (c->sid == sidnum && c->source == sidsource) {
			retc = c;
			break;
		}
	}
	return retc;
}
コード例 #16
0
double Region::AverageSpaceCursorDepth() {
	double totval = 0;
	int totnum = 0;
	for ( std::list<SpaceCursor*>::iterator i = _palettecursors.begin(); i!=_palettecursors.end(); i++ ) {
		SpaceCursor* c = *i;
		NosuchAssert(c);
		totval += c->depth();
		totnum++;
	}
	if ( totnum == 0 ) {
		return -1;
	} else {
		return totval / totnum;
	}
}
コード例 #17
0
ファイル: Region.cpp プロジェクト: phonexhsu/VizBench
double Region::MaxCursorDepth() {
	double maxval = 0;
	if ( ! cursorlist_lock_read() ) {
		NosuchDebug("Region::MaxCursorDepth returns -1, unable to lock cursorlist");
		return -1;
	}
	for ( std::list<Cursor*>::iterator i = _cursors.begin(); i!=_cursors.end(); i++ ) {
		Cursor* c = *i;
		NosuchAssert(c);
		double d = c->curr_depth;
		if ( d > maxval )
			maxval = d;
	}
	cursorlist_unlock();
	return maxval;
}
コード例 #18
0
NosuchDaemon::~NosuchDaemon()
{
    daemon_shutting_down = true;
    if ( _network_thread_created ) {
        // pthread_detach(_network_thread);
        pthread_join(_network_thread,NULL);
    }

    NosuchAssert(_httpserver != NULL);

    delete _httpserver;
    _httpserver = NULL;

    if ( _oscinput ) {
        _oscinput->UnListen();
        delete _oscinput;
        _oscinput = NULL;
    }
}
コード例 #19
0
ファイル: Region.cpp プロジェクト: phonexhsu/VizBench
double Region::AverageCursorDepth() {
	double totval = 0;
	int totnum = 0;
	if ( ! cursorlist_lock_read() ) {
		NosuchDebug("Region::AverageCursorDepth returns -1, unable to lock cursorlist");
		return -1;
	}
	for ( std::list<Cursor*>::iterator i = _cursors.begin(); i!=_cursors.end(); i++ ) {
		Cursor* c = *i;
		NosuchAssert(c);
		totval += c->curr_depth;
		totnum++;
	}
	cursorlist_unlock();
	if ( totnum == 0 ) {
		return -1;
	} else {
		return totval / totnum;
	}
}
コード例 #20
0
ファイル: Region.cpp プロジェクト: phonexhsu/VizBench
Cursor* Region::getCursor(int sidnum, std::string sidsource) {
	Cursor* retc = NULL;

	if ( ! cursorlist_lock_read() ) {
		NosuchDebug("Region::getCursor returns NULL, unable to lock cursorlist");
		return NULL;
	}
	for ( std::list<Cursor*>::iterator i = _cursors.begin(); i!=_cursors.end(); i++ ) {
		Cursor* c = *i;
		NosuchAssert(c);
		if (c->sidnum() == sidnum && c->sidsource() == sidsource) {
			retc = c;
			break;
		}
	}
	cursorlist_unlock();

	// if ( retc == NULL ) {
	// NosuchDebug("DIDN'T FIND getCursor for sid=%s",sid.c_str());
	// }
	return retc;
}
コード例 #21
0
ファイル: Region.cpp プロジェクト: phonexhsu/VizBench
void Region::checkCursorUp(int millinow) {
	
	if ( ! cursorlist_lock_write() ) {
		NosuchDebug("Region::checkCursorUp, unable to lock cursorlist");
		return;
	}
	for ( std::list<Cursor*>::iterator i = _cursors.begin(); i!=_cursors.end(); ) {
		Cursor* c = *i;
		NosuchAssert(c);
		int dt = millinow - c->touched();
		if (dt > 4) {
			// NosuchDebug("checkCursorUp, dt>4 = %d",dt);
			cursorUp(c);
			i = _cursors.erase(i);
			// XXX - should c be deleted?
			delete c;
		} else {
			i++;
		}
	}
	cursorlist_unlock();
}
コード例 #22
0
ファイル: Region.cpp プロジェクト: phonexhsu/VizBench
void Region::advanceTo(int tm) {
	
	spritelist->advanceTo(tm);
#if 0
	spritelist_lock_write();

	for ( std::list<Sprite*>::iterator i = sprites.begin(); i!=sprites.end(); ) {
		Sprite* s = *i;
		NosuchAssert(s);
		s->advanceTo(tm);
		if ( s->state.killme ) {
			i = sprites.erase(i);
			// NosuchDebug("Should be deleting Sprite s=%d",(int)s);
			delete s;
		} else {
			i++;
		}
	}

	spritelist_unlock();
#endif
	
	if ( last_tm > 0 && isSurface() ) {
		int dt = leftover_tm + tm - last_tm;
		if ( dt > fire_period ) {
			// NosuchDebug("Region %d calling behave->periodicFire now=%d",this->id,Palette::now);
			if ( Palette::selector_check && (_graphicBehaviour->isSelectorDown() || _musicBehaviour->isSelectorDown()) ) {
				NosuchDebug(2,"NOT calling behaviour->advanceTo because Selector is down");
			} else {
				_graphicBehaviour->advanceTo(tm);
				_musicBehaviour->advanceTo(tm);
			}
			dt -= fire_period;
		}
		leftover_tm = dt % fire_period;
	}
	last_tm = tm;
}
コード例 #23
0
int
Outlines_SharedMemHeader::addOutline(buff_index b,
int rid, int sid, float x, float y, float z, float area, int npoints) {

	NosuchAssert(b != BUFF_UNSET);

	int cnum = numoutlines[b];
	OutlineMem* om = outline(b, cnum);

	// NOTE: region id's in the shared memory are shifted down by 1
	om->region = rid - 1;
	om->sid = sid;
	om->x = x;
	om->y = y;
	om->z = z;
	om->area = area;
	om->npoints = npoints;
	om->index_of_firstpoint = numpoints[b];

	numoutlines[b]++;

	return cnum;
}
コード例 #24
0
Channel::Channel(Palette* p, int i) {

	NosuchAssert( i >= 0 && i <= 15);

	// spritelist = new VizSpriteList();
	id = i;

	_midiBehaviour = NULL;
	_midiBehaviourName = "";

	_palette = p;
#ifdef LOOPSTUFF
	_loop = NULL;
	_looping = false;
#endif

	NosuchLockInit(&_channel_mutex,"channel");
	// spritelist_rwlock = PTHREAD_RWLOCK_INITIALIZER;
	// int rc1 = pthread_rwlock_init(&spritelist_rwlock, NULL);
	// if ( rc1 ) {
	// 	NosuchDebug("Failure on pthread_rwlock_init!? rc=%d",rc1);
	// }
	// NosuchDebug(2,"spritelist_rwlock has been initialized");
}
コード例 #25
0
void
Outlines_SharedMemHeader::clear_lists(buff_index buffnum) {
	NosuchAssert(buffnum != BUFF_UNSET);
	numoutlines[buffnum] = 0;
	numpoints[buffnum] = 0;
}
コード例 #26
0
int Palette::setRegionSound(std::string region, std::string nm) {
	Region* r = GetRegionNamed(region);
	NosuchAssert(r);
	return setRegionSound(r,nm);
}
コード例 #27
0
int Palette::setRegionSound(int rid, std::string nm) {
	Region* r = getRegion(rid);
	NosuchAssert(r);
	return setRegionSound(r,nm);
}