tags 318998 patch thanks On Mon, Jul 18, 2005 at 08:18:53AM -0700, Matt Kraai wrote: > Package: armagetron > Version: 0.2.7.0-1 > Severity: serious > > armagetron fails to build with some C++ errors:
Attached is a patch that fixes the build problems. With it Armagetron compiles cleanly, and the produced packages seem to work well. There were several occasions where member attributes and functions had to be qualified by adding "this->", I'm not sure this is really intended by the gcc guys, since it means eg. that you can't initialize such members in an initializer lists (at least afaics). An example of this can be seen in src/engine/eVoter.cpp (first hunk). If someone knows if this is really intended or not, it would be nice if you could clarify this, and clone the bug to gcc-4.0 if appropriate. Cheers, Christian Aichinger
diff -Nur armagetron-0.2.7.0/src/engine/eGrid.h armagetron/src/engine/eGrid.h --- armagetron-0.2.7.0/src/engine/eGrid.h 2004-06-04 18:20:57.000000000 +0200 +++ armagetron/src/engine/eGrid.h 2005-08-07 21:58:40.000000000 +0200 @@ -131,9 +131,9 @@ const tList<eCamera>& Cameras() const{return cameras;} - const tList<eGameObject>& GameObjects() const{return gameObjects;} - const tList<eGameObject>& GameObjectsInteresting() const{return gameObjectsInteresting;} - const tList<eGameObject>& GameObjectsInactive() const{return gameObjectsInactive;} + const tList<class eGameObject>& GameObjects() const{return gameObjects;} + const tList<class eGameObject>& GameObjectsInteresting() const{return gameObjectsInteresting;} + const tList<class eGameObject>& GameObjectsInactive() const{return gameObjectsInactive;} int NumberOfCameras(); @@ -148,10 +148,10 @@ // REAL CameraHeight(int i){return eCamera::HeightNum(i);} - void AddGameObjectInteresting (eGameObject *o); - void RemoveGameObjectInteresting (eGameObject *o); - void AddGameObjectInactive (eGameObject *o); - void RemoveGameObjectInactive (eGameObject *o); + void AddGameObjectInteresting (class eGameObject *o); + void RemoveGameObjectInteresting (class eGameObject *o); + void AddGameObjectInactive (class eGameObject *o); + void RemoveGameObjectInactive (class eGameObject *o); typedef void WallProcessor ( eWall* w ); // function prototype for wall query functions void ProcessWallsInRange ( WallProcessor* proc, @@ -198,9 +198,9 @@ tList<eFace, false, true> faces; // objects - tList<eGameObject> gameObjects; - tList<eGameObject> gameObjectsInactive; - tList<eGameObject> gameObjectsInteresting; + tList<class eGameObject> gameObjects; + tList<class eGameObject> gameObjectsInactive; + tList<class eGameObject> gameObjectsInteresting; // cameras tList<eCamera> cameras; diff -Nur armagetron-0.2.7.0/src/engine/eVoter.cpp armagetron/src/engine/eVoter.cpp --- armagetron-0.2.7.0/src/engine/eVoter.cpp 2004-06-04 18:20:57.000000000 +0200 +++ armagetron/src/engine/eVoter.cpp 2005-08-07 22:14:05.000000000 +0200 @@ -69,8 +69,9 @@ friend class eMenuItemVote; public: // constructors/destructor - eVoteItem( void ): creationTime_( tSysTimeFloat() ), user_( 0 ), id_( ++se_votingItemID ), menuItem_( 0 ) + eVoteItem( void ): creationTime_( tSysTimeFloat() ), user_( 0 ), id_( ++se_votingItemID ) { + this->menuItem_ = 0; items_.Add( this ); }; @@ -329,7 +330,7 @@ tArray< tCONTROLLED_PTR( eVoter ) > voters_[2]; // array of voters approving or disapproving of the vote static tList< eVoteItem > items_; // list of vote items unsigned short id_; // running id of voting item - eMenuItemVote *menuItem_; // menu item + class eMenuItemVote *menuItem_; // menu item eVoteItem& operator=( const eVoteItem& ); eVoteItem( const eVoteItem& ); diff -Nur armagetron-0.2.7.0/src/engine/eWall.h armagetron/src/engine/eWall.h --- armagetron-0.2.7.0/src/engine/eWall.h 2004-06-04 18:20:57.000000000 +0200 +++ armagetron/src/engine/eWall.h 2005-08-07 21:40:11.000000000 +0200 @@ -89,7 +89,7 @@ eWallView view[MAX_VIEWERS]; protected: - tCHECKED_PTR(eWallHolder) holder_; + tCHECKED_PTR(class eWallHolder) holder_; tJUST_CONTROLLED_PTR<eGrid> grid; REAL len; int flipped; diff -Nur armagetron-0.2.7.0/src/network/nConfig.cpp armagetron/src/network/nConfig.cpp --- armagetron-0.2.7.0/src/network/nConfig.cpp 2004-06-04 18:20:57.000000000 +0200 +++ armagetron/src/network/nConfig.cpp 2005-08-07 23:25:55.000000000 +0200 @@ -49,7 +49,7 @@ //con << "got conf message for " << name << "\n"; - int i; + int i=0; for(tConfItemBase *item = s_ConfItemAnchor; item ; item = item->Next()){ nConfItemBase *netitem = dynamic_cast<nConfItemBase*> (item); diff -Nur armagetron-0.2.7.0/src/network/nConfig.h armagetron/src/network/nConfig.h --- armagetron-0.2.7.0/src/network/nConfig.h 2004-06-04 18:20:57.000000000 +0200 +++ armagetron/src/network/nConfig.h 2005-08-07 21:47:36.000000000 +0200 @@ -76,36 +76,36 @@ public: nConfItem(const char *title,const char *help,T& t) :tConfItem<T>(t), - tConfItemBase(title, help, na){} + tConfItemBase(title, help, this->na){} virtual ~nConfItem(){} virtual void NetReadVal(nMessage &m){ T dummy=0; m >> dummy; - if (sn_compare(dummy,*target)){ + if (sn_compare(dummy,*(this->target))){ if (printChange) { tOutput o; o.SetTemplateParameter(1, title); - o.SetTemplateParameter(2, *target); + o.SetTemplateParameter(2, *(this->target)); o.SetTemplateParameter(3, dummy); o << "$nconfig_value_changed"; con << con.ColorString(1,.3,.3) << o; } - *target=dummy; + *(this->target)=dummy; changed=true; } } virtual void NetWriteVal(nMessage &m){ - m << *target; + m << *(this->target); } void Set( const T& newval ) { - bool changed = ( newval != *target ); - *target = newval; + bool changed = ( newval != *(this->target) ); + *(this->target) = newval; if ( changed ) { diff -Nur armagetron-0.2.7.0/src/network/nNetwork.cpp armagetron/src/network/nNetwork.cpp --- armagetron-0.2.7.0/src/network/nNetwork.cpp 2005-08-07 21:36:20.000000000 +0200 +++ armagetron/src/network/nNetwork.cpp 2005-08-07 23:24:00.000000000 +0200 @@ -30,6 +30,7 @@ #include "nSimulatePing.h" #include "nConfig.h" #include "nNetwork.h" +#include "nNetObject.h" #include "tConsole.h" #include "tDirectories.h" #include "nNet.h" @@ -701,6 +702,10 @@ static int max_nMessages=0; #endif +class nNetObject *nMessage::nNetObject_ObjectDangerous(int i) { + return nNetObject::ObjectDangerous(i); +} + nMessage::nMessage(unsigned short*& buffer,short sn_myNetID, int lenLeft ) :descriptor(ntohs(*(buffer++))),messageID(ntohs(*(buffer++))), senderID(sn_myNetID),readOut(0){ diff -Nur armagetron-0.2.7.0/src/network/nNetwork.h armagetron/src/network/nNetwork.h --- armagetron-0.2.7.0/src/network/nNetwork.h 2004-06-18 05:53:03.000000000 +0200 +++ armagetron/src/network/nNetwork.h 2005-08-07 23:36:38.000000000 +0200 @@ -278,6 +278,11 @@ friend class nNetObject; friend class nWaitForAck; + + // We need this hack because for nNetObject:: to work, nNetObject has to be + // a complete type. Since we can't guarantee that here, we wrap this up and + // put it into nNetwork.cpp + class nNetObject *nNetObject_ObjectDangerous(int i); // void AddRef(); // void Release(); @@ -429,7 +434,7 @@ Read(id); if ( 0 != id ) - p = dynamic_cast<T*> ( nNetObject::ObjectDangerous(id) ); + p = dynamic_cast<T*> ( nNetObject_ObjectDangerous(id) ); else p = NULL; @@ -452,7 +457,7 @@ Read(id); if ( 0 != id ) - p = dynamic_cast<T*> ( nNetObject::ObjectDangerous(id) ); + p = dynamic_cast<T*> ( nNetObject_ObjectDangerous(id) ); else p = NULL; diff -Nur armagetron-0.2.7.0/src/network/nPriorizing.h armagetron/src/network/nPriorizing.h --- armagetron-0.2.7.0/src/network/nPriorizing.h 2004-06-04 18:20:57.000000000 +0200 +++ armagetron/src/network/nPriorizing.h 2005-08-07 22:30:42.000000000 +0200 @@ -80,7 +80,7 @@ nType type_; // type of this task REAL priority_; // something terrible happens if this task is not executed within 1/priority_ seconds REAL waiting_; // time this task is already waiting ( plus small offset ) - nBandwidthTaskPriorizer* priorizer_; // the arbitrator taking care of this task + class nBandwidthTaskPriorizer* priorizer_; // the arbitrator taking care of this task }; // bandwidth priorizer: selects bandwidth taks @@ -90,8 +90,8 @@ typedef tHeap< nBandwidthTask > nTaskHeap; typedef nBandwidthTask::nType nType; - nTaskHeap& Tasks( nType t ) - { + nTaskHeap& Tasks( nType t ) { + tASSERT( 0 <= t && t < nBandwidthTask::Type_Count ); return tasks_[ t ]; diff -Nur armagetron-0.2.7.0/src/tools/tList.h armagetron/src/tools/tList.h --- armagetron-0.2.7.0/src/tools/tList.h 2004-06-04 18:20:58.000000000 +0200 +++ armagetron/src/tools/tList.h 2005-08-07 20:54:04.000000000 +0200 @@ -97,8 +97,8 @@ public: ~tList(){ - for(int i=Len()-1;i>=0;i--) - (reinterpret_cast<int *>(operator()(i)))[offset]=-1; + for(int i=this->Len()-1;i>=0;i--) + (reinterpret_cast<int *>(this->operator()(i)))[offset]=-1; } tList(int size=0):tArray<T*, MALLOC>(size){} @@ -107,8 +107,8 @@ offset=&idnum-(reinterpret_cast<int *>(t)); if (idnum<0){ // tEventQueue relies on the fact that we put t in - idnum=Len(); // the last place. - operator[](idnum)=t; + idnum=this->Len(); // the last place. + this->operator[](idnum)=t; if ( REFERENCE ) { tReferencer< T >::AddReference( t ); @@ -138,18 +138,18 @@ #endif // the check for Len() is done, since this may be // called on an allready descructed list. - if ( Len() > idnum+1 ) + if ( this->Len() > idnum+1 ) { - T *other=operator()(Len()-1); + T *other=operator()(this->Len()-1); tASSERT( other ); - operator()(idnum)=other; + this->operator()(idnum)=other; int &other_id=(reinterpret_cast<int *>(other))[offset]; - tASSERT( other_id == Len()-1 ); + tASSERT( other_id == this->Len()-1 ); other_id=idnum; } - operator[](Len()-1) = NULL; + operator[](this->Len()-1) = NULL; - SetLen(Len()-1); + SetLen(this->Len()-1); if ( REFERENCE ) { diff -Nur armagetron-0.2.7.0/src/tools/tLocale.h armagetron/src/tools/tLocale.h --- armagetron-0.2.7.0/src/tools/tLocale.h 2004-06-04 18:20:58.000000000 +0200 +++ armagetron/src/tools/tLocale.h 2005-08-07 20:56:44.000000000 +0200 @@ -109,8 +109,8 @@ public: tOutputItemBase(tOutput& o); virtual ~tOutputItemBase(); - virtual void Print(tString& target) const = NULL; - virtual void Clone(tOutput& o) const = NULL; + virtual void Print(tString& target) const = 0; + virtual void Clone(tOutput& o) const = 0; }; diff -Nur armagetron-0.2.7.0/src/tools/tSafePTR.h armagetron/src/tools/tSafePTR.h --- armagetron-0.2.7.0/src/tools/tSafePTR.h 2004-06-04 18:20:58.000000000 +0200 +++ armagetron/src/tools/tSafePTR.h 2005-08-07 20:38:42.000000000 +0200 @@ -47,7 +47,7 @@ ~tCheckedPTRBase(); tCheckedPTRBase& operator=(void *x){target=x; return *this;} -// void * operator->() const {return target;} + void * operator->() const {return target;} // void & operator*() const {return *target;} //operator void *() const {return target;} operator bool() const{return target!=NULL;} @@ -411,7 +411,7 @@ if ( this->GetRefcount() != 1 ) st_Breakpoint(); - refCtr_ = -1000; + this->refCtr_ = -1000; } }; diff -Nur armagetron-0.2.7.0/src/tron/gCycle.cpp armagetron/src/tron/gCycle.cpp --- armagetron-0.2.7.0/src/tron/gCycle.cpp 2004-06-19 04:16:22.000000000 +0200 +++ armagetron/src/tron/gCycle.cpp 2005-08-07 21:54:08.000000000 +0200 @@ -1150,7 +1150,7 @@ skewDot-=lr*1000*animts; if (crash_sparks && animts>0) { - gPlayerWall *tmpplayerWall; + gPlayerWall *tmpplayerWall = NULL; // shut gcc up if(fl.ehit) tmpplayerWall=dynamic_cast<gPlayerWall*>(fl.ehit->GetWall()); if(fr.ehit) tmpplayerWall=dynamic_cast<gPlayerWall*>(fr.ehit->GetWall()); @@ -1173,7 +1173,7 @@ skewDot-=lr*100*animts; if (crash_sparks && animts>0) { - gPlayerWall *tmpplayerWall; + gPlayerWall *tmpplayerWall = NULL; if(fl.ehit) tmpplayerWall=dynamic_cast<gPlayerWall*>(fl.ehit->GetWall()); if(fr.ehit) tmpplayerWall=dynamic_cast<gPlayerWall*>(fr.ehit->GetWall()); diff -Nur armagetron-0.2.7.0/src/tron/gCycle.h armagetron/src/tron/gCycle.h --- armagetron-0.2.7.0/src/tron/gCycle.h 2004-06-19 04:15:19.000000000 +0200 +++ armagetron/src/tron/gCycle.h 2005-08-07 21:43:19.000000000 +0200 @@ -201,9 +201,9 @@ private: gEnemyInfluence enemyInfluence; - tCHECKED_PTR(gNetPlayerWall) currentWall; + tCHECKED_PTR(class gNetPlayerWall) currentWall; // the eWall we are currently making - tCHECKED_PTR(gNetPlayerWall) lastWall; + tCHECKED_PTR(class gNetPlayerWall) lastWall; // unsigned short currentWallID; @@ -270,8 +270,8 @@ virtual bool Alive()const {return alive>=1;} const eTempEdge* Edge(); - const gPlayerWall* CurrentWall(); - const gPlayerWall* LastWall(); + const class gPlayerWall* CurrentWall(); + const class gPlayerWall* LastWall(); #ifndef DEDICATED virtual void Render(const eCamera *cam); diff -Nur armagetron-0.2.7.0/src/tron/gMenus.cpp armagetron/src/tron/gMenus.cpp --- armagetron-0.2.7.0/src/tron/gMenus.cpp 2004-06-22 12:26:19.000000000 +0200 +++ armagetron/src/tron/gMenus.cpp 2005-08-07 22:02:54.000000000 +0200 @@ -1140,7 +1140,7 @@ } } - eCoord pcpos = (0,0); + eCoord pcpos(0,0); if (p->Object() && p->Object()->Alive()) { pcpos = p->Object()->Position(); }
signature.asc
Description: Digital signature