]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - plugins/model/plugin.cpp
reformat code! now the code is only ugly on the *inside*
[xonotic/netradiant.git] / plugins / model / plugin.cpp
index d23809a6571a2514675542229a66bb4f78e55af4..51aa05b32287b0efeed1de0bde463e8d52b68b01 100644 (file)
@@ -21,7 +21,9 @@
 
 #include <stdio.h>
 #include "picomodel.h"
+
 typedef unsigned char byte;
+
 #include <stdlib.h>
 #include <algorithm>
 #include <list>
@@ -44,108 +46,121 @@ typedef unsigned char byte;
 
 #include "model.h"
 
-void PicoPrintFunc( int level, const char *str ){
-       if ( str == 0 ) {
-               return;
-       }
-       switch ( level )
-       {
-       case PICO_NORMAL:
-               globalOutputStream() << str << "\n";
-               break;
-
-       case PICO_VERBOSE:
-               //globalOutputStream() << "PICO_VERBOSE: " << str << "\n";
-               break;
-
-       case PICO_WARNING:
-               globalErrorStream() << "PICO_WARNING: " << str << "\n";
-               break;
-
-       case PICO_ERROR:
-               globalErrorStream() << "PICO_ERROR: " << str << "\n";
-               break;
-
-       case PICO_FATAL:
-               globalErrorStream() << "PICO_FATAL: " << str << "\n";
-               break;
-       }
+void PicoPrintFunc(int level, const char *str)
+{
+    if (str == 0) {
+        return;
+    }
+    switch (level) {
+        case PICO_NORMAL:
+            globalOutputStream() << str << "\n";
+            break;
+
+        case PICO_VERBOSE:
+            //globalOutputStream() << "PICO_VERBOSE: " << str << "\n";
+            break;
+
+        case PICO_WARNING:
+            globalErrorStream() << "PICO_WARNING: " << str << "\n";
+            break;
+
+        case PICO_ERROR:
+            globalErrorStream() << "PICO_ERROR: " << str << "\n";
+            break;
+
+        case PICO_FATAL:
+            globalErrorStream() << "PICO_FATAL: " << str << "\n";
+            break;
+    }
 }
 
-void PicoLoadFileFunc( const char *name, byte **buffer, int *bufSize ){
-       *bufSize = vfsLoadFile( name, (void**) buffer );
+void PicoLoadFileFunc(const char *name, byte **buffer, int *bufSize)
+{
+    *bufSize = vfsLoadFile(name, (void **) buffer);
 }
 
-void PicoFreeFileFunc( void* file ){
-       vfsFreeFile( file );
+void PicoFreeFileFunc(void *file)
+{
+    vfsFreeFile(file);
 }
 
-void pico_initialise(){
-       PicoInit();
-       PicoSetMallocFunc( malloc );
-       PicoSetFreeFunc( free );
-       PicoSetPrintFunc( PicoPrintFunc );
-       PicoSetLoadFileFunc( PicoLoadFileFunc );
-       PicoSetFreeFileFunc( PicoFreeFileFunc );
+void pico_initialise()
+{
+    PicoInit();
+    PicoSetMallocFunc(malloc);
+    PicoSetFreeFunc(free);
+    PicoSetPrintFunc(PicoPrintFunc);
+    PicoSetLoadFileFunc(PicoLoadFileFunc);
+    PicoSetFreeFileFunc(PicoFreeFileFunc);
 }
 
 
-class PicoModelLoader : public ModelLoader
-{
-const picoModule_t* m_module;
+class PicoModelLoader : public ModelLoader {
+    const picoModule_t *m_module;
 public:
-PicoModelLoader( const picoModule_t* module ) : m_module( module ){
-}
-scene::Node& loadModel( ArchiveFile& file ){
-       return loadPicoModel( m_module, file );
-}
+    PicoModelLoader(const picoModule_t *module) : m_module(module)
+    {
+    }
+
+    scene::Node &loadModel(ArchiveFile &file)
+    {
+        return loadPicoModel(m_module, file);
+    }
 };
 
 class ModelPicoDependencies :
-       public GlobalFileSystemModuleRef,
-       public GlobalOpenGLModuleRef,
-       public GlobalUndoModuleRef,
-       public GlobalSceneGraphModuleRef,
-       public GlobalShaderCacheModuleRef,
-       public GlobalSelectionModuleRef,
-       public GlobalFiletypesModuleRef
-{
+        public GlobalFileSystemModuleRef,
+        public GlobalOpenGLModuleRef,
+        public GlobalUndoModuleRef,
+        public GlobalSceneGraphModuleRef,
+        public GlobalShaderCacheModuleRef,
+        public GlobalSelectionModuleRef,
+        public GlobalFiletypesModuleRef {
 };
 
-class ModelPicoAPI : public TypeSystemRef
-{
-PicoModelLoader m_modelLoader;
+class ModelPicoAPI : public TypeSystemRef {
+    PicoModelLoader m_modelLoader;
 public:
-typedef ModelLoader Type;
-
-ModelPicoAPI( const char* extension, const picoModule_t* module ) :
-       m_modelLoader( module ){
-       StringOutputStream filter( 128 );
-       filter << "*." << extension;
-       GlobalFiletypesModule::getTable().addType( Type::Name(), extension, filetype_t( module->displayName, filter.c_str() ) );
-}
-ModelLoader* getTable(){
-       return &m_modelLoader;
-}
+    typedef ModelLoader Type;
+
+    ModelPicoAPI(const char *extension, const picoModule_t *module) :
+            m_modelLoader(module)
+    {
+        StringOutputStream filter(128);
+        filter << "*." << extension;
+        GlobalFiletypesModule::getTable().addType(Type::Name(), extension,
+                                                  filetype_t(module->displayName, filter.c_str()));
+    }
+
+    ModelLoader *getTable()
+    {
+        return &m_modelLoader;
+    }
 };
 
-class PicoModelAPIConstructor
-{
-CopiedString m_extension;
-const picoModule_t* m_module;
+class PicoModelAPIConstructor {
+    CopiedString m_extension;
+    const picoModule_t *m_module;
 public:
-PicoModelAPIConstructor( const char* extension, const picoModule_t* module ) :
-       m_extension( extension ), m_module( module ){
-}
-const char* getName(){
-       return m_extension.c_str();
-}
-ModelPicoAPI* constructAPI( ModelPicoDependencies& dependencies ){
-       return new ModelPicoAPI( m_extension.c_str(), m_module );
-}
-void destroyAPI( ModelPicoAPI* api ){
-       delete api;
-}
+    PicoModelAPIConstructor(const char *extension, const picoModule_t *module) :
+            m_extension(extension), m_module(module)
+    {
+    }
+
+    const char *getName()
+    {
+        return m_extension.c_str();
+    }
+
+    ModelPicoAPI *constructAPI(ModelPicoDependencies &dependencies)
+    {
+        return new ModelPicoAPI(m_extension.c_str(), m_module);
+    }
+
+    void destroyAPI(ModelPicoAPI *api)
+    {
+        delete api;
+    }
 };
 
 
@@ -154,21 +169,20 @@ typedef std::list<PicoModelModule> PicoModelModules;
 PicoModelModules g_PicoModelModules;
 
 
-extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){
-       initialiseModule( server );
-
-       pico_initialise();
-
-       const picoModule_t** modules = PicoModuleList( 0 );
-       while ( *modules != 0 )
-       {
-               const picoModule_t* module = *modules++;
-               if ( module->canload && module->load ) {
-                       for ( char*const* ext = module->defaultExts; *ext != 0; ++ext )
-                       {
-                               g_PicoModelModules.push_back( PicoModelModule( PicoModelAPIConstructor( *ext, module ) ) );
-                               g_PicoModelModules.back().selfRegister();
-                       }
-               }
-       }
+extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer &server)
+{
+    initialiseModule(server);
+
+    pico_initialise();
+
+    const picoModule_t **modules = PicoModuleList(0);
+    while (*modules != 0) {
+        const picoModule_t *module = *modules++;
+        if (module->canload && module->load) {
+            for (char *const *ext = module->defaultExts; *ext != 0; ++ext) {
+                g_PicoModelModules.push_back(PicoModelModule(PicoModelAPIConstructor(*ext, module)));
+                g_PicoModelModules.back().selfRegister();
+            }
+        }
+    }
 }