]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - contrib/bobtoolz/DTreePlanter.h
my own uncrustify run
[xonotic/netradiant.git] / contrib / bobtoolz / DTreePlanter.h
index fec8910f4509dd246ca5c2775d7987c344b64f5c..1d198ae63dddfed5b3f27278a01609c70ba526eb 100644 (file)
@@ -1,21 +1,21 @@
 /*
-BobToolz plugin for GtkRadiant
-Copyright (C) 2001 Gordon Biggans
+   BobToolz plugin for GtkRadiant
+   Copyright (C) 2001 Gordon Biggans
 
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Lesser General Public License for more details.
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
 
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 
 #ifndef __DTREE_H__
 #define __DTREE_H__
@@ -38,174 +38,177 @@ typedef struct treeModel_s {
 #define MAX_TP_MODELS 256
 
 class DTreePlanter {
-  MouseEventHandlerId m_mouseDown;
-  SignalHandlerId m_destroyed;
+MouseEventHandlerId m_mouseDown;
+SignalHandlerId m_destroyed;
 public:
-       SignalHandlerResult mouseDown(const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers);
-  typedef Member3<DTreePlanter, const WindowVector&, ButtonIdentifier, ModifierFlags, SignalHandlerResult, &DTreePlanter::mouseDown> MouseDownCaller;
-       void destroyed()
-  {
-    m_mouseDown = MouseEventHandlerId();
-    m_destroyed = SignalHandlerId();
-  }
-  typedef Member<DTreePlanter, void, &DTreePlanter::destroyed> DestroyedCaller;
-
-  DTreePlanter() {
-               m_numModels =   0;
-               m_offset =              0;
-               m_maxPitch =    0;
-               m_minPitch =    0;
-               m_maxYaw =              0;
-               m_minYaw =              0;
-               m_setAngles =   false;
-               m_useScale =    false;
-               m_autoLink =    false;
-               m_linkNum =             0;
-
-               m_world.LoadSelectedBrushes();
-
-               char buffer[256];
-               GetFilename( buffer, "bt/tp_ent.txt" );
-
-               FILE* file = fopen( buffer, "rb" );
-               if(file) {
-                       fseek( file, 0, SEEK_END );
-                       int len = ftell( file );
-                       fseek( file, 0, SEEK_SET );
-
-                       if(len) {
-                               char* buf = new char[len+1];
-                               buf[len] = '\0';
-                               // parser will do the cleanup, dont delete.
-
-                               fread( buf, len, 1, file );
-
-                               CScriptParser parser;
-                               parser.SetScript( buf );
-
-                               ReadConfig( &parser );
-                       }
-
-                       fclose( file );
+SignalHandlerResult mouseDown( const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers );
+typedef Member3<DTreePlanter, const WindowVector&, ButtonIdentifier, ModifierFlags, SignalHandlerResult, &DTreePlanter::mouseDown> MouseDownCaller;
+void destroyed(){
+       m_mouseDown = MouseEventHandlerId();
+       m_destroyed = SignalHandlerId();
+}
+typedef Member<DTreePlanter, void, &DTreePlanter::destroyed> DestroyedCaller;
+
+DTreePlanter() {
+       m_numModels =   0;
+       m_offset =      0;
+       m_maxPitch =    0;
+       m_minPitch =    0;
+       m_maxYaw =      0;
+       m_minYaw =      0;
+       m_setAngles =   false;
+       m_useScale =    false;
+       m_autoLink =    false;
+       m_linkNum =     0;
+
+       m_world.LoadSelectedBrushes();
+
+       char buffer[256];
+       GetFilename( buffer, "bt/tp_ent.txt" );
+
+       FILE* file = fopen( buffer, "rb" );
+       if ( file ) {
+               fseek( file, 0, SEEK_END );
+               int len = ftell( file );
+               fseek( file, 0, SEEK_SET );
+
+               if ( len ) {
+                       char* buf = new char[len + 1];
+                       buf[len] = '\0';
+                       // parser will do the cleanup, dont delete.
+
+                       fread( buf, len, 1, file );
+
+                       CScriptParser parser;
+                       parser.SetScript( buf );
+
+                       ReadConfig( &parser );
                }
 
-    m_mouseDown = GlobalRadiant().XYWindowMouseDown_connect(makeSignalHandler3(MouseDownCaller(), *this));
-    m_destroyed = GlobalRadiant().XYWindowDestroyed_connect(makeSignalHandler(DestroyedCaller(), *this));
+               fclose( file );
        }
 
-  virtual ~DTreePlanter()
-  {
-    if(!m_mouseDown.isNull())
-    {
-      GlobalRadiant().XYWindowMouseDown_disconnect(m_mouseDown);
-    }
-    if(!m_destroyed.isNull())
-    {
-      GlobalRadiant().XYWindowDestroyed_disconnect(m_destroyed);
-    }
-  }
-
-#define MT(t)  string_equal_nocase( pToken, t )
-#define GT             pToken = pScriptParser->GetToken( true )
-#define CT             if(!*pToken) { return; }
-
-       void ReadConfig( CScriptParser* pScriptParser ) {
-               const char* GT;
-               CT;
-
-               do {
-                       GT;
-                       if(*pToken == '}') {
-                               break;
-                       }
+       m_mouseDown = GlobalRadiant().XYWindowMouseDown_connect( makeSignalHandler3( MouseDownCaller(), *this ) );
+       m_destroyed = GlobalRadiant().XYWindowDestroyed_connect( makeSignalHandler( DestroyedCaller(), *this ) );
+}
 
-                       if(MT("model")) {
-                               if(m_numModels >= MAX_TP_MODELS) {
-                                       return;
-                               }
+virtual ~DTreePlanter(){
+       if ( !m_mouseDown.isNull() ) {
+               GlobalRadiant().XYWindowMouseDown_disconnect( m_mouseDown );
+       }
+       if ( !m_destroyed.isNull() ) {
+               GlobalRadiant().XYWindowDestroyed_disconnect( m_destroyed );
+       }
+}
 
-                               GT; CT;
+#define MT( t )   string_equal_nocase( pToken, t )
+#define GT      pToken = pScriptParser->GetToken( true )
+#define CT      if ( !*pToken ) { return; }
 
-                               strncpy( m_trees[m_numModels++].name, pToken, MAX_QPATH );
-                       } else if(MT("link")) {
-                               GT; CT;
+void ReadConfig( CScriptParser* pScriptParser ) {
+       const char* GT;
+       CT;
 
-                               strncpy( m_linkName, pToken, MAX_QPATH );
+       do {
+               GT;
+               if ( *pToken == '}' ) {
+                       break;
+               }
 
-                               m_autoLink = true;
-                       } else if(MT("entity")) {
-                               GT; CT;
+               if ( MT( "model" ) ) {
+                       if ( m_numModels >= MAX_TP_MODELS ) {
+                               return;
+                       }
 
-                               strncpy( m_entType, pToken, MAX_QPATH );
-                       } else if(MT("offset")) {
-                               GT; CT;
+                       GT; CT;
 
-                               m_offset = atoi(pToken);
-                       } else if(MT("pitch")) {
-                               GT; CT;
+                       strncpy( m_trees[m_numModels++].name, pToken, MAX_QPATH );
+               }
+               else if ( MT( "link" ) ) {
+                       GT; CT;
 
-                               m_minPitch = atoi(pToken);
+                       strncpy( m_linkName, pToken, MAX_QPATH );
 
-                               GT; CT;
+                       m_autoLink = true;
+               }
+               else if ( MT( "entity" ) ) {
+                       GT; CT;
 
-                               m_maxPitch = atoi(pToken);
+                       strncpy( m_entType, pToken, MAX_QPATH );
+               }
+               else if ( MT( "offset" ) ) {
+                       GT; CT;
 
-                               m_setAngles = true;
-                       } else if(MT("yaw")) {
-                               GT; CT;
+                       m_offset = atoi( pToken );
+               }
+               else if ( MT( "pitch" ) ) {
+                       GT; CT;
 
-                               m_minYaw = atoi(pToken);
+                       m_minPitch = atoi( pToken );
 
-                               GT; CT;
+                       GT; CT;
 
-                               m_maxYaw = atoi(pToken);
+                       m_maxPitch = atoi( pToken );
 
-                               m_setAngles = true;
-                       } else if(MT("scale")) {
-                               GT; CT;
+                       m_setAngles = true;
+               }
+               else if ( MT( "yaw" ) ) {
+                       GT; CT;
 
-                               m_minScale = static_cast<float>(atof(pToken));
+                       m_minYaw = atoi( pToken );
 
-                               GT; CT;
+                       GT; CT;
 
-                               m_maxScale = static_cast<float>(atof(pToken));
+                       m_maxYaw = atoi( pToken );
 
-                               m_useScale = true;
-                       } else if(MT("numlinks")) {
-                               GT; CT;
+                       m_setAngles = true;
+               }
+               else if ( MT( "scale" ) ) {
+                       GT; CT;
 
-                               m_linkNum = atoi( pToken );
-                       }
-               } while( true );
-       }
+                       m_minScale = static_cast<float>( atof( pToken ) );
+
+                       GT; CT;
+
+                       m_maxScale = static_cast<float>( atof( pToken ) );
+
+                       m_useScale = true;
+               }
+               else if ( MT( "numlinks" ) ) {
+                       GT; CT;
+
+                       m_linkNum = atoi( pToken );
+               }
+       } while ( true );
+}
 
-       bool FindDropPoint(vec3_t in, vec3_t out);
-       void DropEntsToGround( void );
-       void MakeChain( int linkNum, const char* linkName );
-       void SelectChain( void );
+bool FindDropPoint( vec3_t in, vec3_t out );
+void DropEntsToGround( void );
+void MakeChain( int linkNum, const char* linkName );
+void SelectChain( void );
 
 private:
-       DEntity                 m_world;
+DEntity m_world;
 
-       treeModel_t             m_trees[MAX_TP_MODELS];
+treeModel_t m_trees[MAX_TP_MODELS];
 
-       int                             m_numModels;
-       int                             m_offset;
-       int                             m_maxPitch;
-       int                             m_minPitch;
-       int                             m_maxYaw;
-       int                             m_minYaw;
+int m_numModels;
+int m_offset;
+int m_maxPitch;
+int m_minPitch;
+int m_maxYaw;
+int m_minYaw;
 
-       char                    m_entType[MAX_QPATH];
-       char                    m_linkName[MAX_QPATH];
-       int                             m_linkNum;
+char m_entType[MAX_QPATH];
+char m_linkName[MAX_QPATH];
+int m_linkNum;
 
-       float                   m_minScale;
-       float                   m_maxScale;
+float m_minScale;
+float m_maxScale;
 
-       bool                    m_useScale;
-       bool                    m_setAngles;
-       bool                    m_autoLink;
+bool m_useScale;
+bool m_setAngles;
+bool m_autoLink;
 };
 
 #endif