From: hellcatv <hel...@us...> - 2005-08-18 18:38:22
|
Update of /cvsroot/vegastrike/vegastrike/src/cmd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23322/cmd Modified Files: bolt.cpp bolt.h bolt_generic.cpp bolt_server.cpp collide.cpp mount.cpp unit_generic.cpp Log Message: faster bolts Index: bolt.cpp =================================================================== RCS file: /cvsroot/vegastrike/vegastrike/src/cmd/bolt.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -r1.44 -r1.45 *** bolt.cpp 24 Mar 2005 09:13:42 -0000 1.44 --- bolt.cpp 18 Aug 2005 18:37:58 -0000 1.45 *************** *** 30,40 **** } for (i=0;i<balls.size();i++) { ! for (unsigned int j=0;j<balls[i].size();j++) { ! delete balls[i][j]; } } for (i=0;i<bolts.size();i++) { ! for (unsigned int j=0;j<bolts[i].size();j++) { ! delete bolts[i][j]; } } --- 30,40 ---- } for (i=0;i<balls.size();i++) { ! for (int j=balls[i].size()-1;j>=0;j--) { ! balls[i][j].Destroy(j); } } for (i=0;i<bolts.size();i++) { ! for (unsigned int j=bolts[i].size()-1;j>=0;j--) { ! bolts[i][j].Destroy(j); } } *************** *** 69,110 **** } ! Bolt::Bolt (const weapon_info & typ, const Matrix &orientationpos, const Vector & shipspeed, Unit * owner): col (typ.r,typ.g,typ.b,typ.a), cur_position (orientationpos.p), ShipSpeed (shipspeed) { VSCONSTRUCT2('t') bolt_draw *q= _Universe->activeStarSystem()->bolts; prev_position= cur_position; this->owner = owner; ! type = typ.type; ! damage = typ.Damage+typ.PhaseDamage; ! if (damage) ! percentphase=(unsigned char) (255.*typ.PhaseDamage/damage); ! else ! percentphase=0; ! longrange = typ.Longrange; ! radius = typ.Radius; ! speed = typ.Speed/(type==weapon_info::BOLT?typ.Length:typ.Radius);//will scale it by length long! ! range = typ.Range/(type==weapon_info::BOLT?typ.Length:typ.Radius); curdist = 0; CopyMatrix (drawmat,orientationpos); ! if (type==weapon_info::BOLT) { ! ScaleMatrix (drawmat,Vector (typ.Radius,typ.Radius,typ.Length)); ! // if (q->boltmesh==NULL) { ! // CreateBoltMesh(); ! // } ! decal = q->boltdecals->AddTexture (typ.file.c_str(),MIPMAP); if (decal>=(int)q->bolts.size()) { ! q->bolts.push_back (vector <Bolt *>()); ! int blargh = q->boltdecals->AddTexture (typ.file.c_str(),MIPMAP); if (blargh>=(int)q->bolts.size()) { ! q->bolts.push_back (vector <Bolt *>()); } q->cachedecals.push_back (blargh); } ! q->bolts[decal].push_back (this); } else { ! ScaleMatrix (drawmat,Vector (typ.Radius,typ.Radius,typ.Radius)); decal=-1; for (unsigned int i=0;i<q->animationname.size();i++) { ! if (typ.file==q->animationname[i]) { decal=i; } --- 69,98 ---- } ! Bolt::Bolt (const weapon_info * typ, const Matrix &orientationpos, const Vector & shipspeed, Unit * owner): cur_position (orientationpos.p), ShipSpeed (shipspeed) { VSCONSTRUCT2('t') bolt_draw *q= _Universe->activeStarSystem()->bolts; prev_position= cur_position; this->owner = owner; ! this->type = typ; curdist = 0; CopyMatrix (drawmat,orientationpos); ! if (typ->type==weapon_info::BOLT) { ! ScaleMatrix (drawmat,Vector (typ->Radius,typ->Radius,typ->Length)); ! decal = q->boltdecals->AddTexture (typ->file.c_str(),MIPMAP); if (decal>=(int)q->bolts.size()) { ! q->bolts.push_back (vector <Bolt>()); ! int blargh = q->boltdecals->AddTexture (typ->file.c_str(),MIPMAP); if (blargh>=(int)q->bolts.size()) { ! q->bolts.push_back (vector <Bolt>()); } q->cachedecals.push_back (blargh); } ! q->bolts[decal].push_back (*this); } else { ! ScaleMatrix (drawmat,Vector (typ->Radius,typ->Radius,typ->Radius)); decal=-1; for (unsigned int i=0;i<q->animationname.size();i++) { ! if (typ->file==q->animationname[i]) { decal=i; } *************** *** 112,126 **** if (decal==-1) { decal = q->animations.size(); ! q->animationname.push_back (typ.file); ! q->animations.push_back (new Animation (typ.file.c_str(), true,.1,MIPMAP,false));//balls have their own orientation q->animations.back()->SetPosition (cur_position); ! q->balls.push_back (vector <Bolt *> ()); } ! q->balls[decal].push_back (this); } - #ifdef PERBOLTSOUND - sound = AUDCreateSound (typ.sound,false); - AUDAdjustSound (sound,cur_position,shipspeed+drawmat.getR().Scale(speed)); - #endif } --- 100,110 ---- if (decal==-1) { decal = q->animations.size(); ! q->animationname.push_back (typ->file); ! q->animations.push_back (new Animation (typ->file.c_str(), true,.1,MIPMAP,false));//balls have their own orientation q->animations.back()->SetPosition (cur_position); ! q->balls.push_back (vector <Bolt> ()); } ! q->balls[decal].push_back (*this); } } *************** *** 142,147 **** GFXEnable (TEXTURE0); GFXAlphaTest (GREATER,.1); ! vector <vector <Bolt *> >::iterator i; ! vector <Bolt *>::iterator j; vector <Animation *>::iterator k = q->animations.begin(); for (i=q->balls.begin();i!=q->balls.end();i++,k++) { --- 126,131 ---- GFXEnable (TEXTURE0); GFXAlphaTest (GREATER,.1); ! vector <vector <Bolt> >::iterator i; ! vector <Bolt>::iterator j; vector <Animation *>::iterator k = q->animations.begin(); for (i=q->balls.begin();i!=q->balls.end();i++,k++) { *************** *** 151,172 **** for (j=i->begin();j!=i->end();j++) {//don't update time more than once Vector p,q,r; _Universe->AccessCamera()->GetOrientation(p,q,r); ! BlendTrans ((*j)->drawmat,(*j)->cur_position,(*j)->prev_position); Matrix tmp; ! VectorAndPositionToMatrix(tmp,p,q,r,(*j)->drawmat.p); //result[12]=(*j)->drawmat[12]; //result[13]=(*j)->drawmat[13]; //result[13]=(*j)->drawmat[14]; // cur->SetPosition (result[12],result[13],result[14]); ! cur->SetDimensions ((*j)->radius,(*j)->radius); // cur->DrawNow(result); GFXLoadMatrixModel (tmp ); ! #ifdef PERBOLTSOUND ! #ifdef PERFRAMESOUND ! if ((*j)->sound!=-1) ! AUDAdjustSound ((*j)->sound,Vector ((*j)->drawmat[12],(*j)->drawmat[13],(*j)->drawmat[14]),(*j)->ShipSpeed+(*j)->speed*Vector ((*j)->drawmat[8],(*j)->drawmat[9],(*j)->drawmat[10])); ! #endif ! #endif ! GFXColorf ((*j)->col); cur->DrawNoTransform(false,true); } --- 135,152 ---- for (j=i->begin();j!=i->end();j++) {//don't update time more than once Vector p,q,r; + Bolt * bolt=&*j; + const weapon_info * type = bolt->type; _Universe->AccessCamera()->GetOrientation(p,q,r); ! BlendTrans (bolt->drawmat,bolt->cur_position,bolt->prev_position); Matrix tmp; ! VectorAndPositionToMatrix(tmp,p,q,r,bolt->drawmat.p); //result[12]=(*j)->drawmat[12]; //result[13]=(*j)->drawmat[13]; //result[13]=(*j)->drawmat[14]; // cur->SetPosition (result[12],result[13],result[14]); ! cur->SetDimensions (bolt->type->Radius,bolt->type->Radius); // cur->DrawNow(result); GFXLoadMatrixModel (tmp ); ! GFXColor4f (type->r,type->g,type->b,type->a); cur->DrawNoTransform(false,true); } *************** *** 180,186 **** GFXBlendMode (ONE,ZERO); } ! if (q->boltmesh) { ! q->boltmesh->LoadDrawState(); ! q->boltmesh->BeginDrawState(); int decal=0; for (i=q->bolts.begin();i!=q->bolts.end();decal++,i++) { --- 160,168 ---- GFXBlendMode (ONE,ZERO); } ! GFXVertexList * qmesh=q->boltmesh; ! if (qmesh) { ! ! qmesh->LoadDrawState(); ! qmesh->BeginDrawState(); int decal=0; for (i=q->bolts.begin();i!=q->bolts.end();decal++,i++) { *************** *** 189,200 **** dec->MakeActive(); for (j=i->begin();j!=i->end();j++) { ! BlendTrans ((*j)->drawmat,(*j)->cur_position,(*j)->prev_position); ! GFXLoadMatrixModel ((*j)->drawmat); ! GFXColorf ((*j)->col); ! q->boltmesh->Draw(); } } } ! q->boltmesh->EndDrawState(); } GFXEnable (LIGHTING); --- 171,183 ---- dec->MakeActive(); for (j=i->begin();j!=i->end();j++) { ! BlendTrans ((*j).drawmat,(*j).cur_position,(*j).prev_position); ! GFXLoadMatrixModel ((*j).drawmat); ! const weapon_info * wt=(*j).type; ! GFXColor4f (wt->r,wt->g,wt->b,wt->a); ! qmesh->Draw(); } } } ! qmesh->EndDrawState(); } GFXEnable (LIGHTING); *************** *** 206,248 **** GFXColor4f(1,1,1,1); } ! Bolt::~Bolt () { VSDESTRUCT2 bolt_draw *q = _Universe->activeStarSystem()->bolts; ! vector <vector <Bolt *> > *target; ! if (type==weapon_info::BOLT) { ! target = &q->bolts; q->boltdecals->DelTexture (decal); } else { - target = &q->balls; - } - vector <Bolt *>::iterator tmp= std::find ((*target)[decal].begin(),(*target)[decal].end(),this); - if (tmp!=(*target)[decal].end()) { - (*target)[decal].erase(tmp); - } else { - //might as well look for potential faults! Doesn't cost us time - VSFileSystem::vs_fprintf (stderr,"Bolt Fault! Not found in draw queue! Attempting to recover\n"); - for (vector <vector <Bolt *> > *srch = &q->bolts;srch!=NULL;srch=&q->balls) { - for (unsigned int mdecal=0;mdecal<(*srch).size();mdecal++) { - vector <Bolt *>::iterator mtmp= (*srch)[mdecal].begin(); - while (mtmp!=(*srch)[mdecal].end()) { - std::find ((*srch)[mdecal].begin(),(*srch)[mdecal].end(),this); - if (mtmp!=(*srch)[mdecal].end()) { - (*srch)[mdecal].erase (mtmp); - VSFileSystem::vs_fprintf (stderr,"Bolt Fault Recovered\n"); - } - } - } - if (srch==&q->balls) { - break; - } - } } ! #ifdef PERBOLTSOUND ! if (sound!=-1) { ! AUDStopPlaying(sound); ! AUDDeleteSound (sound); ! } ! #endif } --- 189,204 ---- GFXColor4f(1,1,1,1); } + extern void BoltDestroyGeneric(Bolt * whichbolt, int index, int decal, bool isBall); ! void Bolt::Destroy (int index) { VSDESTRUCT2 bolt_draw *q = _Universe->activeStarSystem()->bolts; ! bool isBall=true; ! if (type->type==weapon_info::BOLT) { q->boltdecals->DelTexture (decal); + isBall=false; } else { } ! BoltDestroyGeneric(this, index,decal,isBall); } Index: bolt.h =================================================================== RCS file: /cvsroot/vegastrike/vegastrike/src/cmd/bolt.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** bolt.h 3 Oct 2002 19:12:49 -0000 1.10 --- bolt.h 18 Aug 2005 18:37:58 -0000 1.11 *************** *** 10,31 **** class Unit; class Bolt { ! GFXColor col; Matrix drawmat; QVector cur_position; QVector prev_position;//beams don't change heading. - weapon_info::WEAPON_TYPE type;//beam or bolt; - unsigned char percentphase;//0 is 0% is phased damage, 255 is 100% - int decal;//which image it uses Unit *owner; ! float damage, curdist,longrange; ! float speed, range,radius; ! Vector ShipSpeed; bool Collide (Unit * target); public: ! Bolt(const weapon_info &type, const Matrix &orientationpos, const Vector & ShipSpeed, Unit *owner);//makes a bolt ! ~Bolt(); static void Draw(); ! bool Update();///www.cachunkcachunk.com ! bool Collide(); }; class bolt_draw { --- 10,37 ---- class Unit; class Bolt { ! private: ! const weapon_info* type;//beam or bolt; Matrix drawmat; QVector cur_position; + Vector ShipSpeed; QVector prev_position;//beams don't change heading. Unit *owner; ! float curdist; ! int decal;//which image it uses bool Collide (Unit * target); public: ! bool operator == (const Bolt & b) const{ ! ! return owner==b.owner ! &&curdist==b.curdist ! &&cur_position==b.cur_position ! &&prev_position==b.prev_position; ! } ! Bolt(const weapon_info *type, const Matrix &orientationpos, const Vector & ShipSpeed, Unit *owner);//makes a bolt ! void Destroy(int index); static void Draw(); ! bool Update(int index); ! bool Collide(int index); ! void noop()const{} }; class bolt_draw { *************** *** 35,40 **** vector <string> animationname; vector <Animation *> animations; ! vector <vector <Bolt *> > bolts; ! vector <vector <Bolt *> > balls; vector <int> cachedecals; bolt_draw(); --- 41,46 ---- vector <string> animationname; vector <Animation *> animations; ! vector <vector <Bolt> > bolts; ! vector <vector <Bolt> > balls; vector <int> cachedecals; bolt_draw(); Index: bolt_generic.cpp =================================================================== RCS file: /cvsroot/vegastrike/vegastrike/src/cmd/bolt_generic.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** bolt_generic.cpp 6 May 2005 09:24:20 -0000 1.3 --- bolt_generic.cpp 18 Aug 2005 18:37:58 -0000 1.4 *************** *** 15,50 **** extern double interpolation_blend_factor; ! bool Bolt::Update () { curdist +=speed*SIMULATION_ATOM; prev_position = cur_position; ! cur_position+=((ShipSpeed+drawmat.getR()*speed).Cast()*SIMULATION_ATOM); ! if (curdist>range) { ! delete this;//risky return false; } - #ifdef PERBOLTSOUND - if (!AUDIsPlaying(sound)) { - AUDDeleteSound (sound); - sound=-1; - } else { - #ifndef PERFRAMESOUND - if ((*j)->sound!=-1) - AUDAdjustSound ((*j)->sound,cur_position,(*j)->ShipSpeed+(*j)->speed*Vector ((*j)->drawmat[8],(*j)->drawmat[9],(*j)->drawmat[10])); - #endif - - } - #endif return true; } void bolt_draw::UpdatePhysics () { ! vector <vector <Bolt *> > *tmp = &bolts; for (int l=0;l<2;l++) { ! for (vector <vector <Bolt *> >::iterator i= tmp->begin();i!=tmp->end();i++) { ! for (unsigned int j=0;j<i->size();j++) { ///warning these require active star system to be set appropriately ! if (!(*i)[j]->Update()) { j--;//deleted itself ! } else if ((*i)[j]->Collide()) { j--;//deleted itself! } --- 15,41 ---- extern double interpolation_blend_factor; ! bool Bolt::Update (int index) { ! const weapon_info *type=this->type; ! float speed=type->Speed; curdist +=speed*SIMULATION_ATOM; prev_position = cur_position; ! cur_position+=((ShipSpeed+drawmat.getR()*speed/((type->type==weapon_info::BALL)*type->Radius+(type->type!=weapon_info::BALL)*type->Length)).Cast()*SIMULATION_ATOM); ! if (curdist>type->Range) { ! this->Destroy(index);//risky return false; } return true; } void bolt_draw::UpdatePhysics () { ! vector <vector <Bolt> > *tmp = &bolts; for (int l=0;l<2;l++) { ! for (vector <vector <Bolt> >::iterator i= tmp->begin();i!=tmp->end();i++) { ! for (int j=0;j<i->size();j++) { ! Bolt * b=&((*i)[j]); ///warning these require active star system to be set appropriately ! if (!b->Update(j)) { j--;//deleted itself ! } else if (b->Collide(j)) { j--;//deleted itself! } *************** *** 72,83 **** Unit * affectedSubUnit; if ((affectedSubUnit =target->queryBSP (prev_position,cur_position,normal,distance))) {//ignore return - // QVector pos; - // double dis=distance; - // if ((affectedSubUnit = target->BeamInsideCollideTree(prev_position,cur_position,pos,normal,dis))) { - // distance=dis; QVector tmp = (cur_position-prev_position).Normalize(); tmp = tmp.Scale(distance); ! distance = curdist/range; ! GFXColor coltmp (col); /* coltmp.r+=.5; coltmp.g+=.5; --- 63,70 ---- Unit * affectedSubUnit; if ((affectedSubUnit =target->queryBSP (prev_position,cur_position,normal,distance))) {//ignore return QVector tmp = (cur_position-prev_position).Normalize(); tmp = tmp.Scale(distance); ! distance = curdist/this->type->Range; ! GFXColor coltmp (this->type->r,this->type->g,this->type->b,this->type->a); /* coltmp.r+=.5; coltmp.g+=.5; *************** *** 86,93 **** if (coltmp.g>1)coltmp.g=1; if (coltmp.b>1)coltmp.b=1;*/ ! float appldam = ((float(255-percentphase)/255)*damage);; ! float phasdam =((float(percentphase)/255)*damage); //if (damage>0) { This was needed back in the "I don't share code" ApplyDamage days ! target->ApplyDamage ((prev_position+tmp).Cast(),normal, appldam* ((1-distance)+distance*longrange),affectedSubUnit,coltmp,(Unit*)owner, phasdam* ((1-distance)+distance*longrange)); //}else if (damage<0) { //target->leach (1,phasdam<0?-phasdam:1,appldam<0?-appldam:1); --- 73,86 ---- if (coltmp.g>1)coltmp.g=1; if (coltmp.b>1)coltmp.b=1;*/ ! //float appldam = type->Damage; ! //float phasdam =type->PhaseDamage; //if (damage>0) { This was needed back in the "I don't share code" ApplyDamage days ! target->ApplyDamage ((prev_position+tmp).Cast(), ! normal, ! this->type->Damage* ((1-distance)+distance*this->type->Longrange), ! affectedSubUnit, ! coltmp, ! (Unit*)owner, ! this->type->PhaseDamage* ((1-distance)+distance*this->type->Longrange)); //}else if (damage<0) { //target->leach (1,phasdam<0?-phasdam:1,appldam<0?-appldam:1); *************** *** 99,100 **** --- 92,133 ---- + void BoltDestroyGeneric (Bolt * whichbolt, int index, int decal, bool isBall) { + VSDESTRUCT2 + bolt_draw *q = _Universe->activeStarSystem()->bolts; + vector <vector <Bolt> > *target; + if (!isBall) { + target = &q->bolts; + } else { + target = &q->balls; + } + vector<Bolt> * vec=&(*target)[decal]; + + if (&(*vec)[index]==whichbolt) { + (*vec)[index]=vec->back();//just a memcopy, yo + vec->pop_back();//pop that back up + }else { + VSFileSystem::vs_fprintf (stderr,"Bolt Fault Nouveau! Not found in draw queue! Attempting to recover\n"); + vector <Bolt>::iterator tmp= std::find ((*target)[decal].begin(),(*target)[decal].end(),*whichbolt); + if (tmp!=(*target)[decal].end()) { + (*target)[decal].erase(tmp); + } else { + //might as well look for potential faults! Doesn't cost us time + VSFileSystem::vs_fprintf (stderr,"Bolt Fault! Not found in draw queue! Attempting to recover\n"); + for (vector <vector <Bolt> > *srch = &q->bolts;srch!=NULL;srch=&q->balls) { + for (unsigned int mdecal=0;mdecal<(*srch).size();mdecal++) { + vector <Bolt>::iterator mtmp= (*srch)[mdecal].begin(); + while (mtmp!=(*srch)[mdecal].end()) { + std::find ((*srch)[mdecal].begin(),(*srch)[mdecal].end(),*whichbolt); + if (mtmp!=(*srch)[mdecal].end()) { + (*srch)[mdecal].erase (mtmp); + VSFileSystem::vs_fprintf (stderr,"Bolt Fault Recovered\n"); + } + } + } + if (srch==&q->balls) { + break; + } + } + } + } + } Index: bolt_server.cpp =================================================================== RCS file: /cvsroot/vegastrike/vegastrike/src/cmd/bolt_server.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** bolt_server.cpp 1 Oct 2003 10:05:17 -0000 1.3 --- bolt_server.cpp 18 Aug 2005 18:37:58 -0000 1.4 *************** *** 17,27 **** unsigned int i; for (i=0;i<balls.size();i++) { ! for (unsigned int j=0;j<balls[i].size();j++) { ! delete balls[i][j]; } } for (i=0;i<bolts.size();i++) { ! for (unsigned int j=0;j<bolts[i].size();j++) { ! delete bolts[i][j]; } } --- 17,27 ---- unsigned int i; for (i=0;i<balls.size();i++) { ! for (int j=balls[i].size()-1;j>=0;j--) { ! balls[i][j].Destroy(j); } } for (i=0;i<bolts.size();i++) { ! for (int j=balls[i].size()-1;j>=0;j--) { ! bolts[i][j].Destroy(j); } } *************** *** 48,52 **** } ! Bolt::Bolt (const weapon_info & typ, const Matrix &orientationpos, const Vector & shipspeed, Unit * owner): col (typ.r,typ.g,typ.b,typ.a), cur_position (orientationpos.p), ShipSpeed (shipspeed) { VSCONSTRUCT2('t') bolt_draw *q= _Universe->activeStarSystem()->bolts; --- 48,52 ---- } ! Bolt::Bolt (const weapon_info * typ, const Matrix &orientationpos, const Vector & shipspeed, Unit * owner):cur_position (orientationpos.p), ShipSpeed (shipspeed) { VSCONSTRUCT2('t') bolt_draw *q= _Universe->activeStarSystem()->bolts; *************** *** 54,72 **** this->owner = owner; this->decal = 0; ! type = typ.type; ! damage = typ.Damage+typ.PhaseDamage; ! if (damage) ! percentphase=(unsigned char) (255.*typ.PhaseDamage/damage); ! else ! percentphase=0; ! longrange = typ.Longrange; ! radius = typ.Radius; ! speed = typ.Speed/(type==weapon_info::BOLT?typ.Length:typ.Radius);//will scale it by length long! ! range = typ.Range/(type==weapon_info::BOLT?typ.Length:typ.Radius); curdist = 0; CopyMatrix (drawmat,orientationpos); ! if (type==weapon_info::BOLT) { ! ScaleMatrix (drawmat,Vector (typ.Radius,typ.Radius,typ.Length)); // if (q->boltmesh==NULL) { // CreateBoltMesh(); --- 54,63 ---- this->owner = owner; this->decal = 0; ! this->type = typ; curdist = 0; CopyMatrix (drawmat,orientationpos); ! if (type->type==weapon_info::BOLT) { ! ScaleMatrix (drawmat,Vector (typ->Radius,typ->Radius,typ->Length)); // if (q->boltmesh==NULL) { // CreateBoltMesh(); *************** *** 85,89 **** */ } else { ! ScaleMatrix (drawmat,Vector (typ.Radius,typ.Radius,typ.Radius)); /* decal=-1; --- 76,80 ---- */ } else { ! ScaleMatrix (drawmat,Vector (typ->Radius,typ->Radius,typ->Radius)); /* decal=-1; *************** *** 107,142 **** void Bolt::Draw () { } ! Bolt::~Bolt () { ! VSDESTRUCT2 ! bolt_draw *q = _Universe->activeStarSystem()->bolts; ! vector <vector <Bolt *> > *target; ! if (type==weapon_info::BOLT) { ! target = &q->bolts; ! //q->boltdecals->DelTexture (decal); ! } else { ! target = &q->balls; ! } ! vector <Bolt *>::iterator tmp= std::find ((*target)[decal].begin(),(*target)[decal].end(),this); ! if (tmp!=(*target)[decal].end()) { ! (*target)[decal].erase(tmp); ! } else { ! //might as well look for potential faults! Doesn't cost us time ! VSFileSystem::vs_fprintf (stderr,"Bolt Fault! Not found in draw queue! Attempting to recover\n"); ! for (vector <vector <Bolt *> > *srch = &q->bolts;srch!=NULL;srch=&q->balls) { ! for (unsigned int mdecal=0;mdecal<(*srch).size();mdecal++) { ! vector <Bolt *>::iterator mtmp= (*srch)[mdecal].begin(); ! while (mtmp!=(*srch)[mdecal].end()) { ! std::find ((*srch)[mdecal].begin(),(*srch)[mdecal].end(),this); ! if (mtmp!=(*srch)[mdecal].end()) { ! (*srch)[mdecal].erase (mtmp); ! VSFileSystem::vs_fprintf (stderr,"Bolt Fault Recovered\n"); ! } ! } ! } ! if (srch==&q->balls) { ! break; ! } ! } ! ! } } --- 98,103 ---- void Bolt::Draw () { } ! extern void BoltDestroyGeneric(Bolt * whichbolt, int index, int decal, bool isBall); ! void Bolt::Destroy(int index) { ! BoltDestroyGeneric(this,index,decal,type->type!=weapon_info::BOLT); } Index: collide.cpp =================================================================== RCS file: /cvsroot/vegastrike/vegastrike/src/cmd/collide.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** collide.cpp 2 Dec 2003 17:37:25 -0000 1.15 --- collide.cpp 18 Aug 2005 18:37:58 -0000 1.16 *************** *** 121,125 **** return seed<(M/100); } ! bool Bolt::Collide () { UnitCollection *candidates[2]; bool use_huge_list=usehuge_table(); --- 121,125 ---- return seed<(M/100); } ! bool Bolt::Collide (int index) { UnitCollection *candidates[2]; bool use_huge_list=usehuge_table(); *************** *** 137,141 **** _Universe->activeStarSystem()->collidetable->c.AddHugeToActive(un); } ! delete this; return true; } --- 137,141 ---- _Universe->activeStarSystem()->collidetable->c.AddHugeToActive(un); } ! Destroy(index); return true; } Index: mount.cpp =================================================================== RCS file: /cvsroot/vegastrike/vegastrike/src/cmd/mount.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -r1.44 -r1.45 *** mount.cpp 12 May 2005 03:50:24 -0000 1.44 --- mount.cpp 18 Aug 2005 18:37:58 -0000 1.45 *************** *** 223,230 **** break; case weapon_info::BOLT: ! new Bolt (*type, mat, velocity, owner);//FIXME turrets! Velocity break; case weapon_info::BALL: ! new Bolt (*type,mat, velocity, owner);//FIXME:turrets won't work break; case weapon_info::PROJECTILE: --- 223,230 ---- break; case weapon_info::BOLT: ! Bolt (type, mat, velocity, owner).noop();//FIXME turrets! Velocity break; case weapon_info::BALL: ! Bolt (type,mat, velocity, owner).noop();//FIXME:turrets won't work break; case weapon_info::PROJECTILE: Index: unit_generic.cpp =================================================================== RCS file: /cvsroot/vegastrike/vegastrike/src/cmd/unit_generic.cpp,v retrieving revision 1.380 retrieving revision 1.381 diff -C2 -r1.380 -r1.381 *** unit_generic.cpp 17 Aug 2005 01:31:15 -0000 1.380 --- unit_generic.cpp 18 Aug 2005 18:37:58 -0000 1.381 *************** *** 1376,1380 **** tmpcos = dist*dist - tmpcos*tmpcos; if( tmpcos >0) ! tmpcos = targ->rSize()/sqrt( tmpcos);//one over distance perpendicular away from straight ahead times the size...high is good WARNING POTENTIAL DIV/0 else tmpcos = 1; --- 1376,1380 ---- tmpcos = dist*dist - tmpcos*tmpcos; if( tmpcos >0) ! tmpcos = targ->rSize()/sqrtf( tmpcos);//one over distance perpendicular away from straight ahead times the size...high is good WARNING POTENTIAL DIV/0 else tmpcos = 1; *************** *** 1390,1394 **** dist=0; } ! return tmpcos; } --- 1390,1402 ---- dist=0; } ! float tmpsin=sqrtf(1-tmpcos*tmpcos); ! float turnangle = SIMULATION_ATOM*(SIMULATION_ATOM*.5*(limits.yaw+limits.pitch)+sqrtf(AngularVelocity.i*AngularVelocity.i+AngularVelocity.j*AngularVelocity.j)); ! float osin=sin(turnangle); ! float ocos=cos(turnangle); ! float cos1=ocos*tmpcos-tmpsin*osin; ! float cos2=ocos*tmpcos+tmpsin*osin;// sin could be opposite ! float ret=tmpmax(cos1,cos2); ! ! return tmpmax(tmpcos,ret); } |