void ast_ser_list(const ast_node_t ast,int(*func)(int,void*),void*param) { /* FIXME shouldn't happen */ if(isAtom(ast)) { ast_serialize(ast,func,param); return; } if(getCar(ast)) { ast_serialize(getCar(ast),func,param); } if(getCdr(ast)) { func(' ',param); ast_ser_list(getCdr(ast),func,param); } }
sPtr Pair::copystate(sPtr n) { ((Pair*)n)->setCar(getCar()->dupe()); ((Pair*)n)->setCdr(getCdr()->dupe()); return Expression::copystate(n); }
string Pair::toString(bool isFirst) { string s(""); if (isFirst) { switch(getDirection()) { case HDIR: s += "("; break; case VDIR: s += "["; break; case ZDIR: s += "{"; break; } } sPtr mycar; mycar = getCar(); s += mycar->toString(mycar->isType(XT_PAIR)); if (getCdr()->isType(XT_NULL)) { switch(getDirection()) { case HDIR: s += ")"; break; case VDIR: s += "]"; break; case ZDIR: s += "}"; break; } } else { s += " "; s += getCdr()->toString(); } return s; }
ast_node_t find_nterm(const ast_node_t ruleset,const char*ntermid) { ast_node_t root=getCar(ruleset); ast_node_t n=getCdr(root); /* skip tag */ assert(!TINYAP_STRCMP(Value(getCar((ast_node_t )root)),STR_Grammar)); /* and be sure it made sense */ // dump_node(n); // printf("\n"); while(n&&((!TINYAP_STRCMP(node_tag(getCar(n)), STR_Comment))||TINYAP_STRCMP(node_tag(getCdr(getCar(n))),ntermid))) { /* skip operator tag to fetch rule name */ // debug_writeln("skip rule "); // dump_node(getCar(n)); n=getCdr(n); } if(n) { // debug_writeln("FIND_NODE SUCCESSFUL\n"); // dump_node(getCar(n)); return getCar(n); } return NULL; }
void Player::frameEvent(float time) { for (int i = 0; i < NUM_POWERUP_BOARDS; i++) { // this method will return quickly if the powerup in question is already disabled if ( mPowerupStates[i].timeElapsed(mPowerupBars[i], time) ) { reLayoutPowerupBoards(); } } // Remove any powerups that have expired for( int i = 0; i < POWERUP_COUNT; i ++ ) { if( getCar() == NULL ) continue; if( powerupTimers[i] != 0 && RakNet::GreaterThan( RakNet::GetTimeMS(), powerupTimers[i] ) ) { switch( i ) { case POWERUP_MASS: getCar()->resetMass(); getCar()->resetEngineForce(); break; case POWERUP_SPEED: getCar()->resetEngineForce(); break; } powerupTimers[i] = 0; } } if( this == GameCore::mPlayerPool->getLocalPlayer() && getPlayerState() != PLAYER_STATE_SPECTATE && mLastKiller != NULL && RakNet::GreaterThan( RakNet::GetTimeMS(), mTimeLastKilled+3000 ) ) { setPlayerState( PLAYER_STATE_SPECTATE ); GameCore::mPlayerPool->setSpectating( mLastKiller->getPlayerGUID() ); mLastKiller = NULL; } }
int Pair::getHeight(GraphicsContext *grcon) { int h = 0; if (collapsed) { assert(false); return 0; } else { if (getDirtyness() & VDIR) { dbg.trace("%d: recalculating height for pair\n"); if (direction == VDIR) { int bmarg = 0; int cmarg = 0; if (getCar()->isType(XT_PAIR)) { bmarg = boxmarg * 2; } if (!getCdr()->isType(XT_NULL)) { cmarg = cdrmarg; } h += getCar()->getHeight(grcon); if (!getCdr()->isType(XT_NULL)) { h += getCdr()->getHeight(grcon); } h += cmarg; h += bmarg; setDirtyness(getDirtyness() & (HDIR|ZDIR)); cached_height = h; return cached_height; } else { setDirtyness(getDirtyness() & (HDIR|ZDIR)); cached_height = max( (getCar()->getHeight(grcon) + (getCar()->isType(XT_PAIR) ? (boxmarg * 2) : 0)), getCdr()->getHeight(grcon) ); return cached_height; } } else { dbg.trace("%d: using cached height for pair\n"); return cached_height; } } }
int Pair::getWidth(GraphicsContext *grcon) { int w = 0; if (collapsed) { assert(false); return 0; } else { if (getDirtyness() & HDIR) { dbg.trace("%d: recalculating width for pair\n"); if (direction == HDIR) { int bmarg = 0; int cmarg = 0; if (getCar()->isType(XT_PAIR)) { bmarg = boxmarg * 2; } if (!getCdr()->isType(XT_NULL)) { cmarg = cdrmarg; } w += getCar()->getWidth(grcon); if (!getCdr()->isType(XT_NULL)) { w += getCdr()->getWidth(grcon); } w += cmarg; w += bmarg; setDirtyness(getDirtyness() & (VDIR|ZDIR)); cached_width = w; return cached_width; } else { setDirtyness(getDirtyness() & (VDIR|ZDIR)); cached_width = max( (getCar()->getWidth(grcon) + (getCar()->isType(XT_PAIR) ? (boxmarg * 2) : 0)), getCdr()->getWidth(grcon) ); return cached_width; } } else { dbg.trace("%d: using cached width for pair\n"); return cached_width; } } }
void Player::collisionTickCallback(Ogre::Vector3 &hitPoint, Ogre::Real damage, unsigned int damageSection, int crashType, Player *causedByPlayer) { #else void Player::collisionTickCallback(Ogre::Vector3 hitPoint, Ogre::Real &damage, int& damageSection, int &crashType, Player *&causedByPlayer) { #endif bool isFront = ((damageSection == 0) || (damageSection == 1)); TeamID tid = (GameCore::mGameplay->getGameMode() == FFA_MODE) ? NO_TEAM : getTeam(); float shrapnelPlaneOffset = (getCarType() == CAR_SMALL) ? -0.75f : ((getCarType() == CAR_BANGER) ? -0.85f : -1.25f); float shrapnelCount = damage / 10.0f; float shrapnelMaxSpeed = damage / 20.0f; if(damage > 40.f) getCar()->removeCarPart(damageSection); switch(crashType) { case 1: #ifdef PARTICLE_EFFECT_SPARKS GameCore::mClientGraphics->generateSparks(hitPoint, Ogre::Vector3(1, 0.6f, 1)); #endif break; case 2: #ifdef PARTICLE_EFFECT_SHRAPNEL GameCore::mClientGraphics->generateShrapnel(hitPoint, tid, shrapnelCount, shrapnelMaxSpeed, shrapnelPlaneOffset); #endif { // 300 is a little louder than 400 :P (not perfect yet as it will need tuning with the final fps) float intensity = damage / 350.f; intensity = intensity < 0 ? 0 : ( intensity > 1 ? 1 : intensity ); if (causedByPlayer && causedByPlayer->getCar()) causedByPlayer->getCar()->triggerCrashSoundAt(hitPoint, intensity); } break; case 3: GameCore::mClientGraphics->mMeshDeformer->collisonDeform(this->getCar()->mBodyNode, hitPoint, damage * 0.04, isFront); #ifdef PARTICLE_EFFECT_SHRAPNEL GameCore::mClientGraphics->generateShrapnel(hitPoint, tid, shrapnelCount, shrapnelMaxSpeed, shrapnelPlaneOffset); #endif { // 300 is a little louder than 400 :P (not perfect yet as it will need tuning with the final fps) float intensity = damage / 230.f; intensity = intensity < 0 ? 0 : ( intensity > 1 ? 1 : intensity ); if (causedByPlayer && causedByPlayer->getCar()) causedByPlayer->getCar()->triggerCrashSoundAt(hitPoint, intensity); } break; default: // error break; } }
bool GfDriver::matchesTypeAndCategory(const std::string& strType, const std::string& strCarCatId) const { return (strType.empty() || getType() == strType) && (strCarCatId.empty() || getCar()->getCategoryId() == strCarCatId); }
Delta Pair::draw(GraphicsContext *grcon) { // if it's a pair, then // 1. if it's an imagepair, you just draw the car, then draw the cdr. // 2. if not, you have to do some special stuff. // what special stuff do I need to draw? // - put space in between siblings, but not after last sibling // - draw margin around all stuff inside a whole list // - draw a box around every list Delta d; Point p; dbg.trace("%d: drawing pair\n"); p = grcon->popOrigin(); if (collapsed) { assert(false); return d; } else if (imagepair) { dbg.trace("%d: this pair is an image, drawing without margins.\n"); Delta dcar, dcdr; // the origin of the car of a pair // is always the same as the origin of the cdr of the pair. // the origin we pass to the cdr of the pair // depends on whether the pair is H or V. // if H, it's origin.x + width(car) // if V, it's origin.y + height(car) grcon->pushOrigin(p); dcar = getCar()->draw(grcon); dbg.trace("%d: dcar = %d,%d\n"); if (direction == HDIR) { p.x += dcar.dx; } else if (direction == VDIR) { p.y += dcar.dy; } else { // no-op for ZDIR } grcon->pushOrigin(p); dcdr = getCdr()->draw(grcon); dbg.trace("%d: dcdr = %d,%d\n"); // if I am a horizontal list, // then my delta x is width(car) + width(cdr) // and my delta y is (max(height(car), height(cdr)) switch(direction) { case HDIR: d.dx = dcar.dx + dcdr.dx; d.dy = max(dcar.dy, dcdr.dy); break; case VDIR: d.dx = max(dcar.dx, dcdr.dx); d.dy = dcar.dy + dcdr.dy; break; case ZDIR: d.dx = max(dcar.dx, dcdr.dx); d.dy = max(dcar.dy, dcdr.dy); break; } } else { dbg.trace("%d: this pair is not an image, drawing with margins.\n"); Delta dcar, dcdr; int cmarg; cmarg = (getCdr()->isType(XT_NULL)) ? 0 : cdrmarg; // we can't call isType because types may not be resolved. // but we don't have to determine type: // if it's unknown, it's NOT a pair. if (!getCar()->isType(XT_UNKNOWN) && getCar()->isType(XT_PAIR)) { dbg.trace("%d: The car of this pair is a list head. We have to draw a box around it.\n"); // car is a list. We have to draw the box. int w, h; Point p2; w = getCar()->getWidth(grcon) + 2 * boxmarg; h = getCar()->getHeight(grcon) + 2 * boxmarg; p2.x = p.x + boxmarg; p2.y = p.y + boxmarg; if (getCar()->getSelected()) { grcon->drawSelectedRect(p.x, p.y, w, h); } else { grcon->drawUnselectedRect(p.x, p.y, w, h, ((Pair*)getCar())->getDirection()); } grcon->pushOrigin(p2); dcar = getCar()->draw(grcon); dcar.dx += 2 * boxmarg; dcar.dy += 2 * boxmarg; } else { grcon->pushOrigin(p); dcar = getCar()->draw(grcon); } dbg.trace("%d: dcar= %d,%d\n"); if (direction == HDIR) { p.x += dcar.dx + cmarg; } else if (direction == VDIR) { p.y += dcar.dy + cmarg; } else { // no-op for ZDIR } if (!getCdr()->isType(XT_NULL)) { grcon->pushOrigin(p); dcdr = getCdr()->draw(grcon); dbg.trace("%d: dcdr= %d,%d\n"); } switch(direction) { case HDIR: d.dx = dcar.dx + dcdr.dx + cmarg; d.dy = max(dcar.dy, dcdr.dy); break; case VDIR: d.dx = max(dcar.dx, dcdr.dx); d.dy = dcar.dy + dcdr.dy + cmarg; break; case ZDIR: d.dx = max(dcar.dx, dcdr.dx); d.dy = max(dcar.dy, dcdr.dy); break; } dbg.trace("%d: d = %d,%d\n"); } return d; }
sPtr Pair::getCachedChild() { if (!cachedchild) { return getCar(); } else return cachedchild; }