#include <gWall.h>
Public Types | |
enum | gWallRenderMode { gWallRenderMode_Lines = 1, gWallRenderMode_Quads = 2, gWallRenderMode_All = 3 } |
Public Member Functions | |
virtual void | InitAfterCreation () |
gNetPlayerWall (gCycle *c, const eCoord &beg, const eCoord &dir, REAL tBeg, REAL dbeg) | |
void | Update (REAL tEnd, const eCoord &pend) |
void | CopyIntoGrid (eGrid *grid, bool force=false) |
void | RealWallReceived (gNetPlayerWall *realwall) |
void | Checkpoint () |
marks the current distance and time for more accurate interpolation | |
gNetPlayerWall (nMessage &m) | |
eCoord | Vec () |
returns the vector from the beginning to the end of the wall | |
tArray< gPlayerWallCoord > & | Coords () |
void | SetEndTime (REAL et) |
void | SetEndPos (REAL ep) |
int | IndexAlpha (REAL a) const |
int | IndexPos (REAL d) const |
REAL | Time (REAL a) const |
REAL | Pos (REAL a) const |
REAL | Alpha (REAL pos) const |
bool | IsDangerousAnywhere (REAL time) const |
bool | IsDangerousApartFromHoles (REAL a, REAL time) const |
bool | IsDangerous (REAL a, REAL time) const |
gExplosion * | Holer (REAL a, REAL time) const |
void | BlowHole (REAL dbeg, REAL dend, gExplosion *holer) |
REAL | BegPos () const |
REAL | EndPos () const |
REAL | BegTime () const |
REAL | EndTime () const |
const eCoord & | EndPoint (int i) const |
virtual void | Render (const eCamera *cam) |
void | RenderList (bool list, gWallRenderMode mode=gWallRenderMode_All) |
virtual void | RenderNormal (const eCoord &x1, const eCoord &x2, REAL ta, REAL te, REAL r, REAL g, REAL b, REAL a, gWallRenderMode mode) |
virtual void | RenderBegin (const eCoord &x1, const eCoord &x2, REAL ta, REAL te, REAL ra, REAL rb, REAL r, REAL g, REAL b, REAL a) |
virtual bool | ActionOnQuit () |
virtual bool | ClearToTransmit (int user) const |
virtual void | WriteSync (nMessage &m) |
virtual void | ReadSync (nMessage &m) |
virtual void | WriteCreate (nMessage &m) |
virtual nDescriptor & | CreatorDescriptor () const |
virtual void | PrintName (tString &s) const |
virtual bool | SyncIsNew (nMessage &m) |
eTempEdge * | Edge () |
gPlayerWall * | Wall () |
gCycle * | Cycle () const |
gCycleMovement * | CycleMovement () const |
bool | Preliminary () const |
bool | InGrid () const |
void | Check () const |
bool | HasDisplayList () |
bool | CanHaveDisplayList () |
void | ClearDisplayList (int inhibitThis=2, int inhibitCycle=0) |
clears the display list | |
Static Public Member Functions | |
static void | s_CopyIntoGrid () |
static void | Clear () |
Protected Member Functions | |
virtual | ~gNetPlayerWall () |
void | ReleaseData () |
Private Member Functions | |
tCONTROLLED_PTR (gCycle) cycle_ | |
tCONTROLLED_PTR (eTempEdge) edge_ | |
void | CreateEdge () |
void | InitArray () |
void | MyInitAfterCreation () |
void | real_CopyIntoGrid (eGrid *grid) |
void | PartialCopyIntoGrid (eGrid *grid) |
void | real_Update (REAL tEnd, const eCoord &pend, bool force) |
Private Attributes | |
int | id |
int | griddedid |
gPlayerWall * | lastWall_ |
eCoord | dir |
the last wall that was dropped into the grid by PartialCopyIntoGrid() | |
REAL | dbegin |
eCoord | beg |
eCoord | end |
REAL | tBeg |
REAL | tEnd |
unsigned short | inGrid |
REAL | gridding |
bool | preliminary:1 |
REAL | obsoleted_ |
tArray< gPlayerWallCoord > | coords_ |
rDisplayList | displayList_ |
Friends | |
class | gCycle |
Definition at line 151 of file gWall.h.
should the whole wall be rendered or just the line/quad segnemts? indivisual segments will be rendered without the glBegin/End block.
Definition at line 236 of file gWall.h.
00237 { 00238 gWallRenderMode_Lines = 1, 00239 gWallRenderMode_Quads = 2, 00240 gWallRenderMode_All = 3 00241 };
gNetPlayerWall::gNetPlayerWall | ( | gCycle * | c, | |
const eCoord & | beg, | |||
const eCoord & | dir, | |||
REAL | tBeg, | |||
REAL | dbeg | |||
) |
Definition at line 1572 of file gWall.cpp.
References dir, gridding, MyInitAfterCreation(), nCLIENT, obsoleted_, preliminary, and sn_GetNetState().
01576 :nNetObject(cyc->Owner()), 01577 id(-1),griddedid(-1), 01578 cycle_(cyc),lastWall_(NULL),dir(d),dbegin(dbeg), 01579 beg(begi),end(begi),tBeg(tBegi),tEnd(tBegi), 01580 inGrid(false){ 01581 dir=dir; // Don't normalize: *REAL(1/sqrt(dir.NormSquared())); 01582 preliminary=(sn_GetNetState()==nCLIENT); 01583 obsoleted_=-100; 01584 gridding=1E+20; 01585 MyInitAfterCreation();
gNetPlayerWall::gNetPlayerWall | ( | nMessage & | m | ) |
Definition at line 1945 of file gWall.cpp.
References beg, dbegin, dir, end, gridding, InitArray(), nNetObject::Object(), obsoleted_, preliminary, nMessage::Read(), and tBeg.
01947 :nNetObject(m), 01948 id(-1),griddedid(-1), 01949 cycle_(NULL),edge_(NULL), lastWall_(NULL), 01950 dir(0,0),dbegin(0), 01951 beg(0,0),end(0,0), 01952 tBeg(0),tEnd(0), 01953 inGrid(0) 01954 { 01955 unsigned short cid; 01956 gridding=1E+20; 01957 m.Read(cid); 01958 cycle_=static_cast<gCycle *>(Object(cid)); 01959 01960 m >> beg; 01961 end=beg; 01962 m >> dir; 01963 m >> dbegin; 01964 01965 m >> tBeg; 01966 { 01967 int preliminary; 01968 m >> preliminary; 01969 this->preliminary = preliminary; 01970 } 01971 01972 obsoleted_=-100; 01973 01974 this->InitArray();
gNetPlayerWall::~gNetPlayerWall | ( | ) | [protected, virtual] |
Definition at line 2024 of file gWall.cpp.
References ClearDisplayList(), and ReleaseData().
02026 { 02027 ReleaseData(); 02028 ClearDisplayList();
gNetPlayerWall::tCONTROLLED_PTR | ( | gCycle | ) | [private] |
gNetPlayerWall::tCONTROLLED_PTR | ( | eTempEdge | ) | [private] |
void gNetPlayerWall::CreateEdge | ( | ) | [private] |
Definition at line 1477 of file gWall.cpp.
References beg, end, NULL, and tNEW.
Referenced by MyInitAfterCreation(), and ReadSync().
01479 { 01480 if ( this->edge_ ) 01481 return; 01482 01483 if (this->cycle_) 01484 { 01485 gPlayerWall* w = tNEW(gPlayerWall)(this, 01486 this->cycle_); 01487 01488 this->edge_=tNEW(eTempEdge)(beg, 01489 end, 01490 w ); 01491 } 01492 else 01493 { 01494 this->edge_ = NULL; 01495 return; 01496 }
void gNetPlayerWall::InitArray | ( | ) | [private] |
Definition at line 1504 of file gWall.cpp.
References beg, coords_, dbegin, end, REAL, tArray< T, MALLOC >::SetLen(), sqrt(), tBeg, and tEnd.
Referenced by gNetPlayerWall(), and MyInitAfterCreation().
01506 { 01507 REAL ep = dbegin+sqrt((beg-end).NormSquared()); 01508 REAL sp = dbegin; 01509 01510 if ( ep < sp ) 01511 { 01512 ep = sp; 01513 } 01514 01515 if ( tEnd < tBeg ) 01516 { 01517 tEnd = tBeg; 01518 } 01519 01520 coords_.SetLen(2); 01521 coords_[0].Pos = sp; 01522 coords_[0].Time = tBeg; 01523 coords_[0].IsDangerous = true; 01524 coords_[1].Pos = ep; 01525 coords_[1].Time = tEnd; 01526 coords_[1].IsDangerous = true;
void gNetPlayerWall::MyInitAfterCreation | ( | void | ) | [private] |
Definition at line 1528 of file gWall.cpp.
References tList< T, MALLOC, REFERENCE >::Add(), beg, rDisplayList::Clear(), coords_, CreateEdge(), displayList_, end, griddedid, InitArray(), tListItem< gNetPlayerWall >::Insert(), GrowingArrayBase::Len(), MAX_VIEWERS, eWall::Remove(), eWall::SetVisHeight(), st_Breakpoint(), tASSERT, and Wall().
Referenced by gNetPlayerWall(), and InitAfterCreation().
01530 { 01531 #ifndef DEDICATED 01532 // put yourself into rendering list 01533 if ( cycle_ ) 01534 { 01535 Insert( cycle_->displayList_.wallList_ ); 01536 } 01537 #endif 01538 01539 //w= 01540 #ifdef DEBUG 01541 if (!finite(end.x) || !finite(end.y)) 01542 st_Breakpoint(); 01543 01544 if (!finite(beg.x) || !finite(beg.y)) 01545 st_Breakpoint(); 01546 #endif 01547 01548 if ( coords_.Len() < 2 ) 01549 { 01550 InitArray(); 01551 } 01552 01553 CreateEdge(); 01554 01555 id=-1; 01556 griddedid=-1; 01557 sg_netPlayerWalls.Add(this,id); 01558 01559 if ( !Wall() ) 01560 return; 01561 tASSERT( Wall()->Splittable() ); 01562 01563 for (int i=MAX_VIEWERS-1;i>=0;i--) 01564 Wall()->SetVisHeight(i,0); 01565 01566 Wall()->Remove(); 01567 01568 displayList_.Clear(2);
void gNetPlayerWall::real_CopyIntoGrid | ( | eGrid * | grid | ) | [private] |
Definition at line 1744 of file gWall.cpp.
References tList< T, MALLOC, REFERENCE >::Add(), eGrid::Check(), ClearDisplayList(), griddedid, gPlayerWall::Insert(), NULL, preliminary, ReleaseData(), tList< T, MALLOC, REFERENCE >::Remove(), tASSERT, and Wall().
Referenced by CopyIntoGrid(), gCycle::Die(), RealWallReceived(), and s_CopyIntoGrid().
01745 { 01746 // con << "Gridding " << ID() << " : "; 01747 //con << "from " << *e->Point(0) << " to " << *e->Point(1) << '\n'; 01748 01749 tJUST_CONTROLLED_PTR< gNetPlayerWall > keep( this ); 01750 01751 #ifdef DEBUG 01752 grid->Check(); 01753 #endif 01754 01755 if (griddedid<0){ 01756 if ( this->cycle_ ) 01757 { 01758 tASSERT( static_cast< bool >(this->edge_) ); 01759 tASSERT(Wall()); 01760 tASSERT(Wall()->Splittable()); 01761 01762 if (preliminary){ 01763 //delete this; // get rid of it 01764 tControlledPTR< nNetObject > bounce( this ); 01765 01766 sg_netPlayerWalls.Remove(this,id); 01767 sg_netPlayerWallsGridded.Add(this,griddedid); 01768 Wall()->Insert(); 01769 this->ReleaseData(); 01770 ClearDisplayList(); 01771 } 01772 else{ 01773 sg_netPlayerWallsGridded.Add(this,griddedid); 01774 sg_netPlayerWalls.Remove(this,id); 01775 if ( this->edge_ ){ 01776 Wall()->Insert(); 01777 this->edge_->CopyIntoGrid(this->cycle_->Grid()); 01778 this->edge_ = NULL; 01779 } 01780 } 01781 } 01782 } 01783 01784 #ifdef DEBUG 01785 grid->Check(); 01786 #endif 01787
void gNetPlayerWall::PartialCopyIntoGrid | ( | eGrid * | grid | ) | [private] |
Definition at line 1789 of file gWall.cpp.
References gPlayerWall::begDist_, eGrid::Check(), end, gPlayerWall::endDist_, griddedid, gPlayerWall::Insert(), lastWall_, NULL, preliminary, eWall::Remove(), tNEW, and Wall().
01790 { 01791 // con << "Gridding " << ID() << " : "; 01792 //con << "from " << *e->Point(0) << " to " << *e->Point(1) << '\n'; 01793 01794 tJUST_CONTROLLED_PTR< gNetPlayerWall > keep( this ); 01795 01796 #ifdef DEBUG 01797 grid->Check(); 01798 #endif 01799 01800 if (griddedid<0 && bool(this->cycle_) && !preliminary ){ 01801 01802 // just copy the current edge into the grid 01803 if ( this->edge_ ){ 01804 lastWall_ = Wall(); 01805 Wall()->Insert(); 01806 this->edge_->CopyIntoGrid(grid); 01807 this->edge_ = NULL; 01808 } 01809 01810 // and create a new one just at the end bit 01811 gPlayerWall* w = tNEW(gPlayerWall)(this, 01812 this->cycle_); 01813 this->edge_=tNEW(eTempEdge)(end, 01814 end, 01815 w ); 01816 01817 // insert it into the list of not yet gridded walls 01818 w->Remove(); 01819 01820 // hack the beginning distance to be the same as the starting distance 01821 w->begDist_ = w->endDist_; 01822 } 01823 01824 // add a new segment as a copy of the current one 01825 // int newCoord = coords_.Len(); 01826 // coords_[newCoord]=coords_[newCoord-1]; 01827 01828 #ifdef DEBUG 01829 grid->Check(); 01830 #endif 01831
void gNetPlayerWall::real_Update | ( | REAL | tEnd, | |
const eCoord & | pend, | |||
bool | force | |||
) | [private] |
Definition at line 1623 of file gWall.cpp.
References beg, gPlayerWall::begDist_, eWall::CalcLen(), gPlayerWall::Check(), Checkpoint(), coords_, dbegin, dir, eCoord, end, gPlayerWall::endDist_, EndPos(), IsDangerous(), lastWall_, GrowingArrayBase::Len(), Pos(), REAL, SetEndPos(), SetEndTime(), tArray< T, MALLOC >::SetLen(), st_Breakpoint(), tBeg, tEnd, and Wall().
Referenced by ReadSync(), and Update().
01625 { 01626 // duplicate last coords entry if its dangerousness disagrees with the previous entry. 01627 if ( coords_.Len() >= 2 && coords_[ coords_.Len()-2 ].IsDangerous != coords_[ coords_.Len()-1 ].IsDangerous ) 01628 { 01629 Checkpoint(); 01630 } 01631 01632 tEnd=Tend; 01633 end=pend; 01634 01635 // make sure the wall points forward 01636 REAL forward = eCoord::F( end-beg, dir )/dir.NormSquared(); 01637 if ( forward < 0 ) 01638 { 01639 end = beg; 01640 tEnd = tBeg; 01641 } 01642 01643 #ifdef DEBUG 01644 if (!finite(end.x) || !finite(end.y)) 01645 st_Breakpoint(); 01646 #endif 01647 01648 eCoord odir=dir.Turn(0,1); 01649 REAL x=eCoord::F(odir,(end-beg))/dir.NormSquared(); 01650 beg=beg+odir*x; 01651 01652 if (bool( this->edge_ ) && this->edge_->Point(0) && this->edge_->Point(1)){ 01653 this->edge_->Coord(1) = end; 01654 if ( !lastWall_ ) 01655 this->edge_->Coord(0) = beg; 01656 } 01657 01658 // determine the correct end position 01659 REAL endPos = 0; 01660 //if ( bool( this->cycle_ ) && !force ) 01661 //{ 01662 // endPos = this->cycle_->GetDistance(); 01663 //} 01664 //else 01665 { 01666 endPos = dbegin + eCoord::F(dir, end - beg )/dir.NormSquared(); 01667 } 01668 01669 // delete coords_ entries that lie after the last one according to their distance; they're invalidated. 01670 { 01671 int len = coords_.Len(); 01672 while ( len >= 3 && coords_[len-2].IsDangerous == coords_[len-1].IsDangerous && coords_[len-2].Pos > endPos ) 01673 { 01674 coords_[len-2] = coords_[len-1]; 01675 coords_.SetLen(len - 1); 01676 len = coords_.Len(); 01677 } 01678 } 01679 01680 // set end position and time 01681 SetEndTime(tEnd); 01682 SetEndPos(endPos); 01683 01684 01685 gPlayerWall *w = Wall(); 01686 01687 if ( w ) 01688 { 01689 w->CalcLen(); 01690 if ( !lastWall_ ) 01691 w->begDist_ = dbegin; 01692 w->endDist_ = EndPos(); 01693 #ifdef DEBUG 01694 w->Check(); 01695 #endif 01696 }
void gNetPlayerWall::InitAfterCreation | ( | void | ) | [virtual] |
Reimplemented from nNetObject.
Definition at line 1498 of file gWall.cpp.
References nNetObject::InitAfterCreation(), and MyInitAfterCreation().
01500 { 01501 nNetObject::InitAfterCreation(); 01502 MyInitAfterCreation();
void gNetPlayerWall::Update | ( | REAL | tEnd, | |
const eCoord & | pend | |||
) |
Definition at line 1611 of file gWall.cpp.
References CHECKWALL, inGrid, nCLIENT, preliminary, real_Update(), and sn_GetNetState().
01613 { 01614 CHECKWALL; 01615 01616 if (!inGrid && ( preliminary || sn_GetNetState() != nCLIENT ) ) 01617 { 01618 real_Update( Tend, pend, false ); 01619 } 01620 01621 CHECKWALL;
void gNetPlayerWall::CopyIntoGrid | ( | eGrid * | grid, | |
bool | force = false | |||
) |
Definition at line 1711 of file gWall.cpp.
References gridding, inGrid, nCLIENT, obsoleted_, nConnectionInfo::ping, preliminary, REAL, real_CopyIntoGrid(), nNetObject::RequestSync(), se_GameTime(), sn_Connections, sn_GetNetState(), and tEnd.
Referenced by ReadSync().
01712 { 01713 tJUST_CONTROLLED_PTR< gNetPlayerWall > keep( this ); 01714 01715 if (!inGrid && (force || 01716 (sn_GetNetState()!=nCLIENT || preliminary))){ 01717 inGrid=true; 01718 gridding=REAL(se_GameTime()+1.0); 01719 if (sn_GetNetState()==nCLIENT) 01720 { 01721 // leave the wall lingering around for some time on the client 01722 gridding=se_GameTime()+40*sn_Connections[0].ping+10; 01723 01724 // unless it is already obsoleted by a final wall or IS a final wall. Delete/grid it immediately then. 01725 if ( obsoleted_ > tEnd - .003f || !preliminary ) 01726 { 01727 if ( grid ) 01728 real_CopyIntoGrid( grid ); 01729 else 01730 gridding=REAL(se_GameTime()+.000001); 01731 } 01732 } 01733 else 01734 { 01735 // copy it into the grid at the next opportunity for server/standalone mode 01736 RequestSync(); 01737 if ( grid ) 01738 real_CopyIntoGrid( grid ); 01739 else 01740 gridding=REAL(se_GameTime()+.000001); 01741 } 01742 }
void gNetPlayerWall::s_CopyIntoGrid | ( | ) | [static] |
Definition at line 1833 of file gWall.cpp.
References con, griddedid, gridding, inGrid, GrowingArrayBase::Len(), real_CopyIntoGrid(), se_GameTime(), and sg_netPlayerWalls.
Referenced by s_Timestep().
01835 { 01836 #ifdef DEBUG 01837 static int maxw=20; 01838 if (sg_netPlayerWalls.Len()>maxw) 01839 con << "Many walls: " << (maxw=sg_netPlayerWalls.Len()) << '\n'; 01840 #endif 01841 01842 for (int i=sg_netPlayerWalls.Len()-1;i>=0;i--){ 01843 gNetPlayerWall *w=sg_netPlayerWalls(i); 01844 if (w->inGrid && w->griddedid<0 && se_GameTime()>w->gridding) 01845 w->real_CopyIntoGrid(w->cycle_->Grid()); 01846 }
void gNetPlayerWall::RealWallReceived | ( | gNetPlayerWall * | realwall | ) |
Definition at line 1848 of file gWall.cpp.
References dir, EPS, gridding, obsoleted_, nNetObject::Owner(), nConnectionInfo::ping, preliminary, REAL, real_CopyIntoGrid(), se_GameTime(), sn_Connections, sn_myNetID, sr_predictObjects, tASSERT, tBeg, and tEnd.
Referenced by ReadSync().
01850 { 01851 if (this->cycle_ ) 01852 { 01853 tASSERT( realWall ); 01854 tASSERT( preliminary && !realWall->preliminary ); 01855 01856 // accelerate gridding if the real wall is newer than this 01857 if ( tBeg + tEnd < 2 * realWall->tEnd ) 01858 { 01859 REAL maxGridding=se_GameTime() + 2*sn_Connections[0].ping; 01860 if ( gridding > maxGridding ) 01861 gridding = maxGridding; 01862 } 01863 01864 // calculate the overlap between the real wall and this wall 01865 REAL overlap = 0; 01866 { 01867 REAL tEndThis = tEnd; 01868 // cut from the end if we're in prediction mode and this is an enemy wall 01869 if ( sr_predictObjects && this->cycle_->currentWall == this && Owner() != sn_myNetID ) 01870 { 01871 tEndThis -= this->cycle_->Lag(); 01872 } 01873 01874 REAL tBegMin = tBeg; 01875 REAL tBegMax = realWall->tBeg; 01876 if ( tBegMin > tBegMax ) 01877 { 01878 tBegMin = realWall->tBeg; 01879 tBegMax = tBeg; 01880 } 01881 01882 REAL tEndMin = tEndThis; 01883 01884 REAL tEndMax = realWall->tEnd; 01885 if ( tEndMin > tEndMax ) 01886 { 01887 tEndMin = realWall->tEnd; 01888 tEndMax = tEndThis; 01889 } 01890 01891 REAL denominator = tEndMax - tBegMin; 01892 if ( denominator > 0 ) 01893 overlap = ( tEndMin - tBegMax ) / denominator; 01894 } 01895 01896 // no overlap if directions don't match 01897 if ( overlap > 0 && fabs( dir * realWall->dir ) > 10 * EPS ) 01898 overlap = 0; 01899 01900 // no good overlap? Go home. 01901 if ( overlap < .8 ) 01902 return; 01903 01904 // mark current walls as to be deleted immediately after the cycle does no longer need it 01905 obsoleted_ = realWall->tEnd; 01906 01907 // copy non-current walls into the grid immediately 01908 if (this->cycle_->currentWall!=this ) 01909 { 01910 // replace pointer in cycle 01911 if (this->cycle_->lastWall==this) 01912 { 01913 this->cycle_->lastWall=realWall; 01914 01915 /* 01916 // close seams (does not help, deactivated) 01917 if ( this->cycle_->currentWall && this->cycle_->currentWall->preliminary ) 01918 { 01919 this->cycle_->currentWall->tBeg = realWall->tEnd; 01920 this->cycle_->currentWall->coords_[0].Time = realWall->tEnd; 01921 this->cycle_->currentWall->dbegin = realWall->EndPos(); 01922 } 01923 */ 01924 } 01925 01926 // delete this wall, it is no longer needed 01927 this->real_CopyIntoGrid( this->cycle_->Grid() ); 01928 } 01929 }
void gNetPlayerWall::Checkpoint | ( | ) |
marks the current distance and time for more accurate interpolation
Definition at line 1698 of file gWall.cpp.
References CHECKWALL, coords_, and GrowingArrayBase::Len().
Referenced by real_Update().
01700 { 01701 CHECKWALL; 01702 01703 // copy the last coordinate entry 01704 int len = coords_.Len(); 01705 01706 // temporary is required to compensate for growing array nightmare 01707 coords_[len] = gPlayerWallCoord( coords_[len-1] ); 01708 01709 CHECKWALL;
eCoord gNetPlayerWall::Vec | ( | ) |
tArray<gPlayerWallCoord>& gNetPlayerWall::Coords | ( | ) | [inline] |
Definition at line 194 of file gWall.h.
Referenced by cWidget::Map::DrawWalls().
00194 { return coords_; }
void gNetPlayerWall::ReleaseData | ( | ) | [protected] |
Definition at line 1993 of file gWall.cpp.
References griddedid, NULL, and tList< T, MALLOC, REFERENCE >::Remove().
Referenced by ActionOnQuit(), Clear(), real_CopyIntoGrid(), and ~gNetPlayerWall().
01995 { 01996 if (this->cycle_){ 01997 if (this->cycle_->currentWall==this) 01998 this->cycle_->currentWall=NULL; 01999 if (this->cycle_->lastWall==this) 02000 this->cycle_->lastWall=NULL; 02001 if (this->cycle_->lastNetWall==this) 02002 this->cycle_->lastNetWall=NULL; 02003 } 02004 02005 // tDESTROY(w); 02006 02007 if (this->edge_) 02008 { 02009 if ( this->edge_->Wall() ) 02010 this->edge_->Wall()->Insert(); 02011 02012 this->edge_ = NULL; // w will be deleted with e 02013 // tDESTROY_PTR(p1); 02014 // tDESTROY_PTR(p2); 02015 } 02016 02017 this->cycle_=NULL; 02018 this->edge_=NULL; 02019 //w=NULL; 02020 02021 sg_netPlayerWalls.Remove(this,id); 02022 sg_netPlayerWallsGridded.Remove(this,griddedid);
void gNetPlayerWall::SetEndTime | ( | REAL | et | ) |
Definition at line 1240 of file gWall.cpp.
References BegTime(), CHECKWALL, coords_, GrowingArrayBase::Len(), REAL, and Time().
Referenced by real_Update().
01241 { 01242 CHECKWALL; 01243 01244 REAL BegTime = coords_( coords_.Len() -2 ).Time; 01245 if ( t < BegTime ) 01246 { 01247 t = BegTime; 01248 } 01249 01250 coords_(coords_.Len()-1).Time = t; 01251 01252 CHECKWALL; 01253
void gNetPlayerWall::SetEndPos | ( | REAL | ep | ) |
Definition at line 1255 of file gWall.cpp.
References BegPos(), CHECKWALL, coords_, GrowingArrayBase::Len(), Pos(), and REAL.
Referenced by real_Update().
01256 { 01257 CHECKWALL; 01258 01259 REAL BegPos = coords_( coords_.Len() -2 ).Pos; 01260 if ( ep < BegPos ) 01261 { 01262 ep = BegPos; 01263 } 01264 01265 coords_(coords_.Len()-1).Pos = ep; 01266 01267 CHECKWALL;
int gNetPlayerWall::IndexAlpha | ( | REAL | a | ) | const |
Definition at line 2280 of file gWall.cpp.
References CHECKWALL, d, IndexPos(), Pos(), and REAL.
Referenced by Holer(), IsDangerous(), and Time().
int gNetPlayerWall::IndexPos | ( | REAL | d | ) | const |
Definition at line 2260 of file gWall.cpp.
References CHECKWALL, coords_, GrowingArrayBase::Len(), Pos(), and st_Breakpoint().
Referenced by BlowHole(), and IndexAlpha().
02262 { 02263 CHECKWALL; 02264 02265 02266 // get the first coord with smaller alpha than a 02267 int i = coords_.Len() - 2; 02268 while ( i >= 1 && coords_(i).Pos >= d) 02269 --i; 02270 02271 #ifdef DEBUG 02272 if (!( i >= 0 && i < coords_.Len() - 1 )) 02273 { 02274 st_Breakpoint(); 02275 } 02276 #endif 02277 02278 return i;
Definition at line 2289 of file gWall.cpp.
References CHECKWALL, coords_, good(), IndexAlpha(), Pos(), gPlayerWallCoord::Pos, REAL, tASSERT, and gPlayerWallCoord::Time.
Referenced by BlowHole(), Check(), EndTime(), and SetEndTime().
02291 { 02292 tASSERT( good( a ) ); 02293 02294 CHECKWALL; 02295 02296 const gPlayerWallCoord* coord = &coords_(IndexAlpha(a)); 02297 REAL div = ( coord[1].Pos - coord[0].Pos ); 02298 REAL alpha = 0.0f; 02299 if ( div > 0 ) 02300 { 02301 alpha = ( Pos(a) - coord[0].Pos ) / div; 02302 } 02303 02304 REAL ret = coord[0].Time + alpha*(coord[1].Time-coord[0].Time); 02305 02306 tASSERT( good( ret ) ); 02307 02308 return ret;
Definition at line 2310 of file gWall.cpp.
References BegPos(), CHECKWALL, EndPos(), good(), REAL, and tASSERT.
Referenced by Check(), EndPos(), IndexAlpha(), IndexPos(), IsDangerousApartFromHoles(), real_Update(), SetEndPos(), sg_KillFutureWall(), and Time().
02312 { 02313 CHECKWALL; 02314 02315 tASSERT( good( a ) ); 02316 02317 REAL ret = BegPos() + a * ( EndPos() - BegPos() ); 02318 02319 tASSERT( good( ret ) ); 02320 02321 return ret;
Definition at line 2323 of file gWall.cpp.
References a, BegPos(), CHECKWALL, EndPos(), REAL, and tASSERT.
Referenced by BlowHole(), and RenderList().
02325 { 02326 CHECKWALL; 02327 02328 REAL diff = ( EndPos() - BegPos() ); 02329 REAL a = pos - BegPos(); 02330 02331 if ( diff > 0 ) 02332 a /= diff; 02333 02334 tASSERT ( -.001 < a ); 02335 tASSERT ( 1.001 > a ); 02336 02337 return a;
bool gNetPlayerWall::IsDangerousAnywhere | ( | REAL | time | ) | const |
Definition at line 2339 of file gWall.cpp.
References BegPos(), CHECKWALL, EndPos(), REAL, tASSERT, gCycle::WallsLength(), and gCycle::WallsStayUpDelay().
02341 { 02342 CHECKWALL; 02343 02344 if ( !cycle_ ) 02345 return false; 02346 02347 // is the player dead? 02348 if ( gCycle::WallsStayUpDelay() >= 0 ) 02349 { 02350 if ( !cycle_->Alive() && time - cycle_->deathTime > .2f + gCycle::WallsStayUpDelay() ) 02351 return false; 02352 } 02353 02354 // is the wall behind the wall end? 02355 if ( gCycle::WallsLength() > 0 ) 02356 { 02357 tASSERT( cycle_->MaxWallsLength() >= cycle_->ThisWallsLength() ); 02358 REAL maxDist = cycle_->GetDistance() - cycle_->MaxWallsLength(); 02359 if ( maxDist > EndPos() && maxDist > BegPos() ) 02360 { 02361 return false; 02362 } 02363 } 02364 02365 return true;
Definition at line 2367 of file gWall.cpp.
References CHECKWALL, dt, Pos(), REAL, gCycle::WallsLength(), and gCycle::WallsStayUpDelay().
Referenced by Holer(), and IsDangerous().
02369 { 02370 CHECKWALL; 02371 02372 // test for disappearing after death 02373 if ( gCycle::WallsStayUpDelay() >= 0.0f ) 02374 { 02375 // walls disappeear after death 02376 if (!cycle_ || !cycle_->Alive() && cycle_->deathTime+ gCycle::WallsStayUpDelay()+0.2f<=time) 02377 return false; 02378 } 02379 02380 // the time from the last simulation to the time the query shall be made; 02381 // cycleDistance is valid at cycle_->lastTime, we need it at time. 02382 REAL dt = ( time - cycle_->lastTime ); 02383 02384 // the distance value at the spot we hit 02385 REAL wallDistance = Pos( a ); 02386 02387 // test for finite wall lenght 02388 if ( gCycle::WallsLength() > 0 ) 02389 { 02390 // the distance the cycle traveled so far 02391 REAL cycleDistance = cycle_->GetDistance(); 02392 02393 // extrapolate it, taking rubber slowdown into account 02394 if ( cycle_->Alive() ) 02395 { 02396 // cycle movement 02397 cycleDistance += cycle_->WallEndSpeed() * dt; 02398 } 02399 02400 if ( wallDistance + cycle_->ThisWallsLength() < cycleDistance ) 02401 return false; // hit was after the wall length 02402 } 02403 02404 // check whether it is an extrapolated bit 02405 { 02406 // the distance the cycle traveled so far 02407 REAL cycleDistance = cycle_->GetDistance(); 02408 02409 // extrapolate it if the test time lies in the cycle's future. 02410 if ( cycle_->Alive() && dt > 0 ) 02411 { 02412 // cycle movement 02413 cycleDistance += cycle_->Speed() * cycle_->rubberSpeedFactor * dt; 02414 } 02415 02416 // is the wall ahead of the cycle? 02417 if ( wallDistance > cycleDistance ) 02418 return false; 02419 } 02420 02421 return true;
Definition at line 2423 of file gWall.cpp.
References CHECKWALL, coords_, IndexAlpha(), gPlayerWallCoord::IsDangerous, and IsDangerousApartFromHoles().
Referenced by BlowHole(), real_Update(), and RenderList().
02425 { 02426 CHECKWALL; 02427 02428 if ( !IsDangerousApartFromHoles( a, time ) ) 02429 { 02430 return false; 02431 } 02432 02433 const gPlayerWallCoord* coord = &coords_(IndexAlpha(a)); 02434 return coord->IsDangerous;
gExplosion * gNetPlayerWall::Holer | ( | REAL | a, | |
REAL | time | |||
) | const |
Definition at line 2437 of file gWall.cpp.
References CHECKWALL, coords_, gPlayerWallCoord::holer, IndexAlpha(), and IsDangerousApartFromHoles().
02439 { 02440 CHECKWALL; 02441 02442 // it does not count as a hole if the wall has expired already 02443 // for other reasons 02444 if ( !IsDangerousApartFromHoles( a, time ) ) 02445 { 02446 return false; 02447 } 02448 02449 const gPlayerWallCoord* coord = &coords_(IndexAlpha(a)); 02450 return coord->holer;
void gNetPlayerWall::BlowHole | ( | REAL | dbeg, | |
REAL | dend, | |||
gExplosion * | holer | |||
) |
Definition at line 2480 of file gWall.cpp.
References Alpha(), BegPos(), CHECKWALL, ClearDisplayList(), coords_, EndPos(), IndexPos(), IsDangerous(), GrowingArrayBase::Len(), nCLIENT, nSERVER, preliminary, REAL, nNetObject::RequestSync(), tArray< T, MALLOC >::SetLen(), sn_GetNetState(), tASSERT, and Time().
Referenced by sg_KillFutureWall().
02482 { 02483 CHECKWALL; 02484 02485 #ifndef DEDICATED 02486 ClearDisplayList(60); 02487 #endif 02488 02489 #ifdef DEBUG 02490 /* 02491 for ( int i = 0; i < coords_.Len(); ++i ) 02492 { 02493 std::cout << "[" << coords_(i).IsDangerous << ',' << coords_(i).Pos << "]"; 02494 } 02495 02496 static int count=0; 02497 ++count; 02498 02499 std::cout << " hole " << count << " : " << beg << ',' << end << '(' << BegPos() << ',' << EndPos() << ")\n"; 02500 */ 02501 #endif 02502 02503 // don't touch anything if the server concluded it is his business 02504 if ( sn_GetNetState() != nSERVER && sg_ServerSentHoles && !preliminary ) 02505 { 02506 return; 02507 } 02508 02509 #ifdef DEBUG 02510 tASSERT (coords_.Len() < 1000 ); 02511 #endif 02512 02513 // find the last index that will stay before the hole: 02514 int begind = IndexPos( beg ); 02515 02516 // skip ahead if the holing would create redunant non-dangerous blocks 02517 while ( begind >= 1 && !coords_[begind].IsDangerous ) 02518 { 02519 beg = coords_[begind].Pos; 02520 begind--; 02521 } 02522 02523 // find the last index in the hole: 02524 int endind = IndexPos( end ); 02525 02526 // skip ahead if the holing would create redunant non-dangerous blocks 02527 while ( endind < coords_.Len() - 2 && !coords_[endind].IsDangerous ) 02528 { 02529 endind++; 02530 end = coords_[endind].Pos; 02531 } 02532 02533 if ( beg < BegPos() ) 02534 { 02535 begind = -1; 02536 02537 beg = BegPos(); 02538 } 02539 02540 if ( end > EndPos() ) 02541 { 02542 if ( bool(cycle_) && ( EndPos() < cycle_->GetDistance()-10 || this != cycle_->currentWall ) ) 02543 endind = coords_.Len() - 1; 02544 02545 end = EndPos(); 02546 } 02547 02548 // out of range 02549 if ( end < beg ) 02550 { 02551 return; 02552 } 02553 02554 if ( sn_GetNetState() != nCLIENT ) 02555 { 02556 this->RequestSync(); 02557 } 02558 02559 // find the alpha at the hole begin and end: 02560 REAL begalph = Alpha( beg ); 02561 REAL endalph = Alpha( end ); 02562 02563 // find the time at the hole begin and end: 02564 REAL begtime = Time( begalph ); 02565 REAL endtime = Time( endalph ); 02566 02567 int insert = begind + 2 - endind; 02568 02569 #ifdef DEBUG 02570 tASSERT (insert < 40 ); 02571 #endif 02572 02573 // remove positions inside the hole: 02574 if ( insert < 0 ) 02575 { 02576 for ( int i = begind+1; i - insert < coords_.Len(); ++i ) 02577 coords_(i) = coords_( i - insert ); 02578 coords_.SetLen( coords_.Len() + insert ); 02579 } 02580 02581 // make room for the new points of the hole: 02582 else if ( insert > 0 ) 02583 { 02584 coords_.SetLen( coords_.Len() + insert ); 02585 02586 for ( int i = coords_.Len() - 1; i >= begind + insert && i >= insert ; --i ) 02587 coords_( i ) = coords_( i - insert ); 02588 } 02589 02590 // clamp times 02591 { 02592 if ( begind >= 0 ) 02593 { 02594 REAL beforetime = coords_(begind).Time; 02595 if ( begtime < beforetime ) 02596 { 02597 begtime = beforetime; 02598 } 02599 } 02600 02601 if ( begind +3 < coords_.Len() ) 02602 { 02603 REAL afttime = coords_(begind + 3).Time; 02604 if ( endtime > afttime ) 02605 { 02606 endtime = afttime; 02607 } 02608 } 02609 } 02610 02611 // enter the hole 02612 coords_(begind+1).IsDangerous = false; 02613 coords_(begind+1).Time = begtime; 02614 coords_(begind+1).holer = holer; 02615 coords_(begind+1).Pos = beg; 02616 coords_(begind+2).Time = endtime; 02617 coords_(begind+2).Pos = end; 02618 02619 #ifdef DEBUG 02620 /* 02621 for ( int i = 0; i < coords_.Len(); ++i ) 02622 { 02623 std::cout << "[" << coords_(i).IsDangerous << ',' << coords_(i).Pos << "]"; 02624 } 02625 std::cout << "\n"; 02626 */ 02627 #endif 02628 02629 CHECKWALL;
REAL gNetPlayerWall::BegPos | ( | ) | const |
Definition at line 2459 of file gWall.cpp.
References CHECKWALL, and coords_.
Referenced by Alpha(), BlowHole(), cWidget::Map::DrawWalls(), IsDangerousAnywhere(), Pos(), gCycleWallsDisplayListManager::RenderAll(), and SetEndPos().
REAL gNetPlayerWall::EndPos | ( | ) | const |
Definition at line 2452 of file gWall.cpp.
References CHECKWALL, coords_, GrowingArrayBase::Len(), and Pos().
Referenced by Alpha(), BlowHole(), cWidget::Map::DrawWalls(), IsDangerousAnywhere(), Pos(), real_Update(), and gCycleWallsDisplayListManager::RenderAll().
REAL gNetPlayerWall::BegTime | ( | ) | const |
REAL gNetPlayerWall::EndTime | ( | ) | const |
const eCoord& gNetPlayerWall::EndPoint | ( | int | i | ) | const [inline] |
Definition at line 220 of file gWall.h.
Referenced by cWidget::Map::DrawWalls(), and RenderList().
00221 { 00222 switch ( i ) 00223 { 00224 case 0: 00225 return beg; 00226 case 1: 00227 default: 00228 return end; 00229 } 00230 }
void gNetPlayerWall::Render | ( | const eCamera * | cam | ) | [virtual] |
Definition at line 826 of file gWall.cpp.
References RenderList().
Referenced by gCycleWallsDisplayListManager::RenderAll().
00827 { 00828 if (!cycle_) 00829 return; 00830 RenderList(true);
void gNetPlayerWall::RenderList | ( | bool | list, | |
gWallRenderMode | mode = gWallRenderMode_All | |||
) |
Definition at line 859 of file gWall.cpp.
References a, Alpha(), b, rDisplayList::Call(), gCycleWallsDisplayListManager::CannotHaveList(), ClearDisplayList(), coords_, dbegin, displayList_, eCoord, EndPoint(), gBEG_LEN, gWallRenderMode_All, IsDangerous(), GrowingArrayBase::Len(), gPlayerWallCoord::Pos, REAL, RenderBegin(), RenderNormal(), se_GameTime(), SEGLEN, sr_CheckGLError(), Swap(), gCycle::WallsLength(), and x.
Referenced by Render(), and gCycleWallsDisplayListManager::RenderAll().
00860 { 00861 if ( !cycle_ ) 00862 { 00863 return; 00864 } 00865 00866 #ifdef DEBUG_X 00867 if ( cycle_->Player()->GetName().StartsWith("B") && dbegin < .1 ) 00868 { 00869 int x; 00870 x = 1; 00871 } 00872 #endif 00873 // clear list if walls are vanishing 00874 // or if the wall end was reached 00875 // or this is the cycle's first wall 00876 if ( gCycleWallsDisplayListManager::CannotHaveList( dbegin, cycle_ ) || 00877 this == cycle_->currentWall ) 00878 { 00879 ClearDisplayList(2); 00880 } 00881 00882 if ( !displayList_.Call() ) 00883 { 00884 //static gPerformanceCounter counter; 00885 //counter.Count(); 00886 00887 rDisplayListFiller filler( displayList_ ); 00888 00889 REAL r,g,b; 00890 if (cycle_){ 00891 r=cycle_->trailColor_.r; 00892 g=cycle_->trailColor_.g; 00893 b=cycle_->trailColor_.b; 00894 } 00895 else 00896 r=g=b=1; 00897 00898 eCoord P1=EndPoint(0); 00899 eCoord P2=EndPoint(1); 00900 00901 { 00902 eCoord vec = P2-P1; 00903 REAL xs = vec.x*vec.x; 00904 REAL ys = vec.y*vec.y; 00905 REAL intensity = .7 + .3 * xs/(xs+ys); 00906 r *= intensity; 00907 g *= intensity; 00908 b *= intensity; 00909 } 00910 00911 REAL a=1; 00912 00913 #define SEGLEN 2.5 00914 //REAL ta=startTime*3; 00915 //REAL te=endTime*3; 00916 for ( int i = coords_.Len()-2; i>=0; --i ) 00917 { 00918 const gPlayerWallCoord* coord = &coords_(i); 00919 00920 if ( !coord[0].IsDangerous ) 00921 continue; 00922 00923 REAL pa = coord[0].Pos; 00924 REAL pe = coord[1].Pos; 00925 00926 REAL aa = Alpha( pa ); 00927 REAL ae = Alpha( pe ); 00928 00929 eCoord p1 = P1 + ( P2 - P1 ) * aa; 00930 eCoord p2 = P1 + ( P2 - P1 ) * ae; 00931 00932 REAL ta=pa/SEGLEN; 00933 REAL te=pe/SEGLEN; 00934 //REAL shift=REAL(floor((ta+te)/20)*10); 00935 00936 //REAL time=ArmageTronTimer*3; 00937 REAL time; 00938 if (cycle_) 00939 { 00940 if ( cycle_->currentWall ) 00941 time = cycle_->currentWall->EndPos()/SEGLEN; 00942 else 00943 time=cycle_->GetDistance()/SEGLEN; 00944 if ( !cycle_->Alive() ) 00945 time += se_GameTime() - cycle_->deathTime; 00946 } 00947 else 00948 time=0; 00949 00950 //ta-=shift; 00951 //te-=shift; 00952 //time-=shift; 00953 00954 if (ta>te){ 00955 Swap(ta,te); 00956 Swap(p1,p2); 00957 Swap(pa,pe); 00958 } 00959 00960 // cut the end of the wall 00961 if ( bool(cycle_) && gCycle::WallsLength() > 0 ) 00962 { 00963 REAL cut = (cycle_->GetDistance() - cycle_->ThisWallsLength() - pe) / ( pa - pe ); 00964 if ( cut < 0 ) 00965 continue; 00966 if ( cut < 1 ) 00967 { 00968 p1 = p2 + (p1-p2)*cut; 00969 ta = te + (ta-te)*cut; 00970 } 00971 } 00972 00973 if (te+gBEG_LEN<=time){ 00974 RenderNormal(p1,p2,ta,te,r,g,b,a,renderMode); 00975 sr_CheckGLError(); 00976 } 00977 00978 else{ // complicated 00979 // can't squeeze that into a display list 00980 ClearDisplayList(); 00981 00982 if (ta+gBEG_LEN>=time){ 00983 sr_CheckGLError(); 00984 RenderBegin(p1,p2,ta,te, 00985 1+(ta-time)/gBEG_LEN, 00986 1+(te-time)/gBEG_LEN, 00987 r,g,b,a); 00988 sr_CheckGLError(); 00989 } 00990 else{ 00991 sr_CheckGLError(); 00992 REAL s=((time-gBEG_LEN)-ta)/(te-ta); 00993 eCoord pm=p1+(p2-p1)*s; 00994 RenderBegin(pm,p2, 00995 ta+(te-ta)*s,te,0, 00996 1+(te-time)/gBEG_LEN, 00997 r,g,b,a); 00998 RenderNormal(p1,pm,ta,ta+(te-ta)*s,r,g,b,a, gWallRenderMode_All ); 00999 sr_CheckGLError(); 01000 } 01001 } 01002 } 01003 }
void gNetPlayerWall::RenderNormal | ( | const eCoord & | x1, | |
const eCoord & | x2, | |||
REAL | ta, | |||
REAL | te, | |||
REAL | r, | |||
REAL | g, | |||
REAL | b, | |||
REAL | a, | |||
gWallRenderMode | mode | |||
) | [virtual] |
Definition at line 1026 of file gWall.cpp.
References BeginLines(), BeginQuads(), dt, gWallRenderMode_All, gWallRenderMode_Lines, gWallRenderMode_Quads, REAL, tListItemBase::Remove(), RenderEnd(), se_GameTime(), sr_DepthOffset(), rTextureGroups::TEX_WALL, rTextureGroups::TextureMode, upperlinecolor(), and gCycle::WallsStayUpDelay().
Referenced by RenderList().
01027 { 01028 REAL hfrac=1; 01029 01030 if (bool(cycle_) && !cycle_->Alive() && gCycle::WallsStayUpDelay() >= 0 ){ 01031 REAL dt=(se_GameTime()-cycle_->deathTime-gCycle::WallsStayUpDelay())*2; 01032 01033 if (dt>1) 01034 { 01035 // remove from rendering lists 01036 Remove(); 01037 return; 01038 } 01039 01040 if (dt>=0) 01041 { 01042 REAL ca=REAL(.5/(dt+.5)); 01043 REAL alpha=1-dt; 01044 if (alpha>1) alpha=1; 01045 hfrac=1-dt; 01046 01047 r+=ca; 01048 b+=ca; 01049 g+=ca; 01050 01051 a*=alpha; 01052 } 01053 } 01054 REAL h=1; 01055 01056 01057 if (hfrac>0){ 01058 if ( ( mode & gWallRenderMode_Lines ) ){ 01059 01060 // draw additional upper line 01061 if ( mode == gWallRenderMode_All ) 01062 { 01063 sr_DepthOffset(true); 01064 if ( rTextureGroups::TextureMode[rTextureGroups::TEX_WALL] != 0 ) 01065 { 01066 RenderEnd(); 01067 glDisable(GL_TEXTURE_2D); 01068 } 01069 } 01070 01071 BeginLines(); 01072 upperlinecolor(r,g,b,a); 01073 glVertex3f(p1.x,p1.y,h*hfrac); 01074 upperlinecolor(r,g,b,a); 01075 glVertex3f(p2.x,p2.y,h*hfrac); 01076 01077 // in the other modes, the caller is responsible for 01078 // calling RenderEnd() and resetting the states. 01079 if ( mode == gWallRenderMode_All ) 01080 { 01081 RenderEnd(); 01082 sr_DepthOffset(false); 01083 if ( rTextureGroups::TextureMode[rTextureGroups::TEX_WALL] != 0 ) 01084 glEnable(GL_TEXTURE_2D); 01085 } 01086 } 01087 01088 //glColor4f(r,g,b,a); 01089 01090 #ifdef XDEBUG 01091 REAL extrarise = 0; 01092 if ( this->id >= 0 ) 01093 { 01094 extrarise = 1; 01095 } 01096 #else 01097 static const REAL extrarise = 0; 01098 #endif 01099 if ( mode & gWallRenderMode_Quads ) 01100 { 01101 BeginQuads(); 01102 01103 glColor3f(r,g,b); 01104 glTexCoord2f(ta,hfrac); 01105 glVertex3f(p1.x,p1.y,extrarise); 01106 01107 glColor3f(r,g,b); 01108 glTexCoord2f(ta,0); 01109 glVertex3f(p1.x,p1.y,extrarise + h*hfrac); 01110 01111 glColor3f(r,g,b); 01112 glTexCoord2f(te,0); 01113 glVertex3f(p2.x,p2.y,extrarise + h*hfrac); 01114 01115 glColor3f(r,g,b); 01116 glTexCoord2f(te,hfrac); 01117 glVertex3f(p2.x,p2.y,extrarise); 01118 01119 // in the other modes, the caller is responsible for 01120 // calling RenderEnd(). 01121 if ( mode == gWallRenderMode_All ) 01122 { 01123 RenderEnd(); 01124 } 01125 } 01126 }
void gNetPlayerWall::RenderBegin | ( | const eCoord & | x1, | |
const eCoord & | x2, | |||
REAL | ta, | |||
REAL | te, | |||
REAL | ra, | |||
REAL | rb, | |||
REAL | r, | |||
REAL | g, | |||
REAL | b, | |||
REAL | a | |||
) | [virtual] |
Definition at line 1137 of file gWall.cpp.
References afunc(), BeginLineStrip(), BeginQuadStrip(), cfunc(), dt, eCoord, gCYCLE_LEN, H, hfunc(), REAL, RenderEnd(), se_GameTime(), segs, sfunc(), sr_CheckGLError(), sr_DepthOffset(), rTextureGroups::TEX_WALL, rTextureGroups::TextureMode, upperlinecolor(), gCycle::WallsStayUpDelay(), and xfunc().
Referenced by RenderList().
01138 { 01139 if ( !cycle_ ) 01140 { 01141 return; 01142 } 01143 01144 REAL hfrac=1; 01145 01146 eCoord p2 = pp2; 01147 01148 if (re > 1){ 01149 if (re > 2) 01150 return; 01151 01152 REAL ratio = (1-ra)/(re-ra); 01153 p2 = p1 + (pp2-p1)*ratio; 01154 te = ta + (te-ta)*ratio; 01155 re= 1; 01156 } 01157 01158 if (bool(cycle_) && !cycle_->Alive()){ 01159 REAL dt=(se_GameTime()-cycle_->deathTime-gCycle::WallsStayUpDelay())*2; 01160 if (dt>1) dt=1; 01161 if (dt>0) 01162 { 01163 REAL ca=REAL(.5/(dt+.5)); 01164 REAL alpha=1-dt; 01165 if (alpha>1) alpha=1; 01166 hfrac=1-dt; 01167 01168 r+=ca; 01169 b+=ca; 01170 g+=ca; 01171 } 01172 //a*=alpha; 01173 } 01174 01175 REAL h=1; 01176 01177 eCoord ppos=cycle_->PredictPosition() - cycle_->dir*REAL(gCYCLE_LEN); 01178 01179 if ( hfrac>0 ){ 01180 sr_DepthOffset(true); 01181 //REAL H=h*hfrac; 01182 #define segs 5 01183 upperlinecolor(r,g,b,a);//a*afunc(rat)); 01184 01185 if ( rTextureGroups::TextureMode[rTextureGroups::TEX_WALL] != 0 ) 01186 glDisable(GL_TEXTURE_2D); 01187 01188 BeginLineStrip(); 01189 01190 for (int i=0;i<=segs;i++){ 01191 REAL frag=i/float(segs); 01192 REAL rat=ra+frag*(re-ra); 01193 REAL x=(p1.x+frag*(p2.x-p1.x))*(1-xfunc(rat))+ppos.x*xfunc(rat); 01194 REAL y=(p1.y+frag*(p2.y-p1.y))*(1-xfunc(rat))+ppos.y*xfunc(rat); 01195 01196 REAL H=h*hfrac*hfunc(rat); 01197 upperlinecolor(r,g,b,a*afunc(rat)); 01198 glVertex3f(x+H*cycle_->skew*sfunc(rat)*cycle_->dir.y, 01199 y-H*cycle_->skew*sfunc(rat)*cycle_->dir.x, 01200 H);//+se_cameraZ*.005); 01201 } 01202 RenderEnd(); 01203 01204 sr_DepthOffset(false); 01205 if ( rTextureGroups::TextureMode[rTextureGroups::TEX_WALL] != 0 ) 01206 glEnable(GL_TEXTURE_2D); 01207 } 01208 01209 sr_CheckGLError(); 01210 BeginQuadStrip(); 01211 01212 //REAL H=h*hfrac; 01213 01214 //ppos=ePlayer->pos-ePlayer->dir*gCYCLE__LEN; 01215 01216 for (int i=0;i<=segs;i++){ 01217 REAL frag=i/float(segs); 01218 REAL rat=ra+frag*(re-ra); 01219 REAL x=(p1.x+frag*(p2.x-p1.x))*(1-xfunc(rat))+ppos.x*xfunc(rat); 01220 REAL y=(p1.y+frag*(p2.y-p1.y))*(1-xfunc(rat))+ppos.y*xfunc(rat); 01221 01222 // bottom 01223 glColor4f(r+cfunc(rat),g+cfunc(rat),b+cfunc(rat),a*afunc(rat)); 01224 glTexCoord2f(ta+(te-ta)*frag,hfrac); 01225 glVertex3f(x,y,0); 01226 01227 // top 01228 01229 //glTexCoord2f(ta+(te-ta)*frag,hfrac*(1-hfunc(rat))); 01230 glTexCoord2f(ta+(te-ta)*frag,0); 01231 REAL H=h*hfrac*hfunc(rat); 01232 glVertex3f(x+H*cycle_->skew*sfunc(rat)*cycle_->dir.y, 01233 y-H*cycle_->skew*sfunc(rat)*cycle_->dir.x, 01234 H); 01235 } 01236 RenderEnd(); 01237 sr_CheckGLError();
bool gNetPlayerWall::ActionOnQuit | ( | ) | [virtual] |
Reimplemented from nNetObject.
Definition at line 2030 of file gWall.cpp.
References nSERVER, ReleaseData(), sn_GetNetState(), and nNetObject::TakeOwnership().
02032 { 02033 if ( sn_GetNetState() == nSERVER ) 02034 { 02035 TakeOwnership(); 02036 return false; 02037 } 02038 else 02039 { 02040 ReleaseData(); 02041 02042 return true; 02043 }
bool gNetPlayerWall::ClearToTransmit | ( | int | user | ) | const [virtual] |
Reimplemented from nNetObject.
Definition at line 2045 of file gWall.cpp.
References nNetObject::ClearToTransmit(), con, nNetObject::DoDebugPrint(), GridIsReady(), nNetObject::ID(), and inGrid.
02046 { 02047 #ifdef DEBUG 02048 if (nNetObject::DoDebugPrint() && bool( this->cycle_ ) ) 02049 { 02050 if (!GridIsReady(user)) 02051 con << "Not transfering gNetPlayerWall " << ID() 02052 << " for user " << user << " because the grid is not ready yet.\n"; 02053 else if (!this->cycle_) 02054 con << "Not transfering gNetPlayerWall " << ID() 02055 << " for user " << user << " because it has no cycle!\n"; 02056 else if (!this->cycle_->HasBeenTransmitted(user)) 02057 { 02058 tString s; 02059 s << "No transfering gNetPlayerWall " << ID() 02060 << " for user " << user << " because "; 02061 this->cycle_->PrintName(s); 02062 s << " has not been transmitted.\n"; 02063 con << s; 02064 } 02065 } 02066 #endif 02067 02068 return GridIsReady(user) && nNetObject::ClearToTransmit(user) 02069 && bool(this->cycle_) && this->cycle_->HasBeenTransmitted(user) && inGrid;
void gNetPlayerWall::WriteSync | ( | nMessage & | m | ) | [virtual] |
Reimplemented from nNetObject.
Definition at line 2071 of file gWall.cpp.
References beg, coords_, end, inGrid, gPlayerWallCoord::IsDangerous, GrowingArrayBase::Len(), gPlayerWallCoord::Pos, tBeg, tEnd, gPlayerWallCoord::Time, nMessage::Write(), and nNetObject::WriteSync().
02072 { 02073 nNetObject::WriteSync(m); 02074 02075 if (inGrid){ 02076 m << end; // the far end of the eWall 02077 m << tEnd; // the endTime 02078 } 02079 else{ 02080 m << beg; 02081 m << tBeg; 02082 } 02083 m.Write(inGrid); 02084 02085 if ( coords_.Len() > 2 || !coords_(0).IsDangerous || !coords_(1).IsDangerous ) 02086 { 02087 unsigned short len = coords_.Len(); 02088 m.Write( len ); 02089 for ( int i = len-1; i>=0; --i ) 02090 { 02091 const gPlayerWallCoord& coord = coords_(i); 02092 m << coord.IsDangerous; 02093 m << coord.Pos; 02094 m << coord.Time; 02095 } 02096 }
void gNetPlayerWall::ReadSync | ( | nMessage & | m | ) | [virtual] |
Reimplemented from nNetObject.
Definition at line 2106 of file gWall.cpp.
References gPlayerWall::Check(), ClearDisplayList(), coords_, CopyIntoGrid(), CreateEdge(), eCoord, nMessage::End(), griddedid, inGrid, gPlayerWallCoord::IsDangerous, GrowingArrayBase::Len(), NULL, gPlayerWallCoord::Pos, preliminary, nMessage::Read(), nNetObject::ReadSync(), REAL, real_Update(), RealWallReceived(), tArray< T, MALLOC >::SetLen(), tBeg, gPlayerWallCoord::Time, and Wall().
02107 { 02108 nNetObject::ReadSync(m); 02109 02110 ClearDisplayList(); 02111 02112 REAL tEnd_new; 02113 eCoord end_new; 02114 02115 m >> end_new; 02116 m >> tEnd_new; 02117 02118 if ( tEnd_new < tBeg ) 02119 { 02120 tEnd_new = tBeg; 02121 } 02122 02123 unsigned short new_inGrid; 02124 m.Read(new_inGrid); 02125 02126 if ( griddedid < 0 ) 02127 CreateEdge(); 02128 02129 if ( ! m.End() ) 02130 { 02131 unsigned short len; 02132 m.Read( len ); 02133 02134 coords_.SetLen( len ); 02135 02136 for ( int i = len-1; i>=0; --i ) 02137 { 02138 gPlayerWallCoord& coord = coords_(i); 02139 m >> coord.IsDangerous; 02140 m >> coord.Pos; 02141 m >> coord.Time; 02142 } 02143 02144 sg_ServerSentHoles = true; 02145 } 02146 02147 real_Update(tEnd_new,end_new, true); 02148 02149 if (Wall() && new_inGrid && !inGrid) 02150 { 02151 /* 02152 if ( ( beg - end ).NormSquared() > 0.01f ) 02153 { 02154 gExplosion::OnNewWall( Wall() ); 02155 } 02156 */ 02157 02158 CopyIntoGrid( NULL, true ); 02159 02160 if (!preliminary) 02161 { 02162 // inform preliminary walls 02163 for (int i=sg_netPlayerWalls.Len()-1;i>=0;i--) 02164 { 02165 gNetPlayerWall *o=sg_netPlayerWalls[i]; 02166 if ( o != this && o->preliminary && o->cycle_ == this->cycle_ ) 02167 { 02168 o->RealWallReceived( this ); 02169 } 02170 } 02171 02172 // test whether this wall is newer than the last received wall in the cycle 02173 if ( ( 0 != this->cycle_ ) && ( !this->cycle_->lastNetWall || this->cycle_->lastNetWall->tBeg < this->tBeg ) ) 02174 { 02175 this->cycle_->lastNetWall = this; 02176 } 02177 } 02178 } 02179 else 02180 { 02181 // st_Breakpoint(); 02182 } 02183 02184 #ifdef DEBUG 02185 if ( Wall() ) 02186 Wall()->Check(); 02187 #endif
void gNetPlayerWall::WriteCreate | ( | nMessage & | m | ) | [virtual] |
Reimplemented from nNetObject.
Definition at line 1932 of file gWall.cpp.
References beg, dbegin, dir, preliminary, tASSERT, tBeg, nMessage::Write(), and nNetObject::WriteCreate().
01934 { 01935 tASSERT( this->cycle_ ); 01936 01937 nNetObject::WriteCreate(m); 01938 m.Write(this->cycle_->ID()); 01939 m << beg; 01940 m << dir; 01941 m << dbegin; 01942 m << tBeg; 01943 m << static_cast<int>(preliminary);
nDescriptor & gNetPlayerWall::CreatorDescriptor | ( | void | ) | const [virtual] |
Implements nNetObject.
Definition at line 2191 of file gWall.cpp.
References gNetPlayerWall_init.
02193 { 02194 return gNetPlayerWall_init;
void gNetPlayerWall::PrintName | ( | tString & | s | ) | const [virtual] |
Reimplemented from nNetObject.
Definition at line 2196 of file gWall.cpp.
References id.
02198 { 02199 s << "gNetPlayerWall nr. " << id; 02200 if ( this->cycle_ ) 02201 { 02202 s << " owned by "; 02203 this->cycle_->PrintName( s ); 02204 }
bool gNetPlayerWall::SyncIsNew | ( | nMessage & | m | ) | [virtual] |
Reimplemented from nNetObject.
Definition at line 2098 of file gWall.cpp.
References nNetObject::SyncIsNew().
02100 { 02101 // return (nNetObject::SyncIsNew(m) && !inGrid); 02102 return nNetObject::SyncIsNew(m);
eTempEdge* gNetPlayerWall::Edge | ( | ) | [inline] |
gPlayerWall * gNetPlayerWall::Wall | ( | ) |
Definition at line 1982 of file gWall.cpp.
References NULL.
Referenced by Clear(), MyInitAfterCreation(), PartialCopyIntoGrid(), ReadSync(), real_CopyIntoGrid(), and real_Update().
01983 { 01984 if (this->edge_) 01985 { 01986 eWall *w = this->edge_->Wall(); 01987 01988 return reinterpret_cast<gPlayerWall *>(w); 01989 } 01990 else 01991 return NULL;
gCycle* gNetPlayerWall::Cycle | ( | ) | const [inline] |
Definition at line 265 of file gWall.h.
Referenced by gCycle::Die(), cWidget::Map::DrawWalls(), and sg_KillFutureWall().
gCycleMovement * gNetPlayerWall::CycleMovement | ( | ) | const |
bool gNetPlayerWall::Preliminary | ( | ) | const [inline] |
Definition at line 268 of file gWall.h.
Referenced by gCycle::Die(), and gCycleExtrapolator::EdgeIsDangerous().
00268 {return preliminary;}
bool gNetPlayerWall::InGrid | ( | ) | const [inline] |
void gNetPlayerWall::Clear | ( | void | ) | [static] |
Definition at line 2210 of file gWall.cpp.
References griddedid, id, gPlayerWall::Insert(), GrowingArrayBase::Len(), ReleaseData(), tList< T, MALLOC, REFERENCE >::Remove(), sg_netPlayerWalls, sg_netPlayerWallsGridded, and Wall().
Referenced by exit_game_objects().
02212 { 02213 // if( nCLIENT == sn_GetNetState() ) 02214 // return; 02215 02216 int i; 02217 for (i=sg_netPlayerWalls.Len()-1;i>=0;i--){ 02218 // sg_netPlayerWalls(i)->owner=sn_myNetID; 02219 //delete sg_netPlayerWalls(i); 02220 gNetPlayerWall* w = sg_netPlayerWalls(i); 02221 tControlledPTR< nNetObject > bounce( w ); 02222 w->ReleaseData(); 02223 02224 sg_netPlayerWalls.Remove( w, w->id ); 02225 02226 if ( w->edge_ ) 02227 w->edge_->Wall()->Insert(); 02228 02229 } 02230 for (i=sg_netPlayerWallsGridded.Len()-1;i>=0;i--){ 02231 // sg_netPlayerWallsGridded(i)->owner=sn_myNetID; 02232 gNetPlayerWall* w = sg_netPlayerWallsGridded(i); 02233 tControlledPTR< nNetObject > bounce( w ); 02234 w->ReleaseData(); 02235 02236 sg_netPlayerWallsGridded.Remove( w, w->griddedid ); 02237 }
void gNetPlayerWall::Check | ( | ) | const |
Definition at line 2240 of file gWall.cpp.
References coords_, GrowingArrayBase::Len(), Pos(), tASSERT, and Time().
02242 { 02243 #ifdef DEBUG 02244 int i; 02245 for ( i = coords_.Len() -2 ; i>=0; --i ) 02246 { 02247 gPlayerWallCoord* coords = &( coords_( i ) ); 02248 tASSERT( coords[0].Pos <= coords[1].Pos ); 02249 tASSERT( coords[0].Time <= coords[1].Time ); 02250 } 02251 02252 for ( i = coords_.Len() -1 ; i>=0; --i ) 02253 { 02254 gPlayerWallCoord* coords = &( coords_( i ) ); 02255 tASSERT( finite( coords[0].Pos ) ); 02256 tASSERT( finite( coords[0].Time ) ); 02257 } 02258 #endif
bool gNetPlayerWall::HasDisplayList | ( | ) | [inline] |
Definition at line 275 of file gWall.h.
References gCycle::displayList_.
00276 { 00277 return displayList_.IsSet(); 00278 }
bool gNetPlayerWall::CanHaveDisplayList | ( | ) | [inline] |
Definition at line 280 of file gWall.h.
References gCycle::displayList_.
Referenced by ClearDisplayList(), and gCycleWallsDisplayListManager::RenderAll().
00281 { 00282 return !displayList_.IsInhibited(); 00283 }
void gNetPlayerWall::ClearDisplayList | ( | int | inhibitThis = 2 , |
|
int | inhibitCycle = 0 | |||
) |
clears the display list
Definition at line 1317 of file gWall.cpp.
References CanHaveDisplayList(), rDisplayList::Clear(), and displayList_.
Referenced by BlowHole(), ReadSync(), real_CopyIntoGrid(), gCycleWallsDisplayListManager::RenderAll(), RenderList(), and ~gNetPlayerWall().
01319 { 01320 #ifndef DEDICATED 01321 if ( CanHaveDisplayList() && cycle_ && inhibitCycle >= 0 ) 01322 { 01323 cycle_->displayList_.Clear( inhibitCycle ); 01324 } 01325 displayList_.Clear( inhibitThis ); 01326 #endif
int gNetPlayerWall::id [private] |
Reimplemented from nNetObject.
Definition at line 153 of file gWall.h.
Referenced by Clear(), and PrintName().
int gNetPlayerWall::griddedid [private] |
Definition at line 153 of file gWall.h.
Referenced by Clear(), MyInitAfterCreation(), PartialCopyIntoGrid(), ReadSync(), real_CopyIntoGrid(), ReleaseData(), and s_CopyIntoGrid().
gPlayerWall* gNetPlayerWall::lastWall_ [private] |
eCoord gNetPlayerWall::dir [private] |
the last wall that was dropped into the grid by PartialCopyIntoGrid()
Definition at line 159 of file gWall.h.
Referenced by gNetPlayerWall(), real_Update(), RealWallReceived(), and WriteCreate().
REAL gNetPlayerWall::dbegin [private] |
Definition at line 160 of file gWall.h.
Referenced by gNetPlayerWall(), InitArray(), real_Update(), RenderList(), and WriteCreate().
eCoord gNetPlayerWall::beg [private] |
Definition at line 161 of file gWall.h.
Referenced by CreateEdge(), gNetPlayerWall(), InitArray(), MyInitAfterCreation(), real_Update(), WriteCreate(), and WriteSync().
eCoord gNetPlayerWall::end [private] |
Definition at line 161 of file gWall.h.
Referenced by CreateEdge(), gNetPlayerWall(), InitArray(), MyInitAfterCreation(), PartialCopyIntoGrid(), real_Update(), and WriteSync().
REAL gNetPlayerWall::tBeg [private] |
Definition at line 162 of file gWall.h.
Referenced by gNetPlayerWall(), InitArray(), ReadSync(), real_Update(), RealWallReceived(), WriteCreate(), and WriteSync().
REAL gNetPlayerWall::tEnd [private] |
Definition at line 162 of file gWall.h.
Referenced by CopyIntoGrid(), InitArray(), real_Update(), RealWallReceived(), and WriteSync().
unsigned short gNetPlayerWall::inGrid [private] |
Definition at line 164 of file gWall.h.
Referenced by ClearToTransmit(), CopyIntoGrid(), ReadSync(), s_CopyIntoGrid(), Update(), and WriteSync().
REAL gNetPlayerWall::gridding [private] |
Definition at line 165 of file gWall.h.
Referenced by CopyIntoGrid(), gNetPlayerWall(), RealWallReceived(), and s_CopyIntoGrid().
bool gNetPlayerWall::preliminary [private] |
Definition at line 166 of file gWall.h.
Referenced by BlowHole(), CopyIntoGrid(), gNetPlayerWall(), PartialCopyIntoGrid(), ReadSync(), real_CopyIntoGrid(), RealWallReceived(), Update(), and WriteCreate().
REAL gNetPlayerWall::obsoleted_ [private] |
Definition at line 167 of file gWall.h.
Referenced by CopyIntoGrid(), gNetPlayerWall(), and RealWallReceived().
tArray<gPlayerWallCoord> gNetPlayerWall::coords_ [private] |
Definition at line 288 of file gWall.h.
Referenced by BegPos(), BegTime(), BlowHole(), Check(), Checkpoint(), EndPos(), EndTime(), Holer(), IndexPos(), InitArray(), IsDangerous(), MyInitAfterCreation(), ReadSync(), real_Update(), RenderList(), SetEndPos(), SetEndTime(), Time(), and WriteSync().
rDisplayList gNetPlayerWall::displayList_ [private] |
Definition at line 290 of file gWall.h.
Referenced by ClearDisplayList(), MyInitAfterCreation(), and RenderList().