X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=plugins%2Fspritemodel%2Fplugin.cpp;h=84daad666d9c09c42e130f24e9c1a662c65e3aa7;hb=9dfae1c9b270ee369c6362903a9205b30751b95f;hp=5b74b87b4abed1cb652bee4c4785d765043a6bbf;hpb=bfc8a12a6b315ae261101a34db8ba1b682c67bb7;p=xonotic%2Fnetradiant.git diff --git a/plugins/spritemodel/plugin.cpp b/plugins/spritemodel/plugin.cpp index 5b74b87b..84daad66 100644 --- a/plugins/spritemodel/plugin.cpp +++ b/plugins/spritemodel/plugin.cpp @@ -1,22 +1,22 @@ /* -Copyright (C) 2002 Dominic Clifton. + Copyright (C) 2002 Dominic Clifton. -This file is part of GtkRadiant. + This file is part of GtkRadiant. -GtkRadiant is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + GtkRadiant is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -GtkRadiant 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 General Public License for more details. + GtkRadiant 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 General Public License for more details. -You should have received a copy of the GNU General Public License -along with GtkRadiant; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ + You should have received a copy of the GNU General Public License + along with GtkRadiant; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ // // Sprite Model Plugin @@ -50,7 +50,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA baseq3/scripts/entities.def =========================== - \/\*QUAKED ammo_bfg (.3 .3 1) (-16 -16 -16) (16 16 16) SUSPENDED + \/\*QUAKED ammo_bfg (.3 .3 1) (-16 -16 -16) (16 16 16) SUSPENDED ... -------- MODEL FOR RADIANT ONLY - DO NOT SET THIS AS A KEY -------- model="sprites/powerups/ammo/bfgam.bmp"\*\/ @@ -84,20 +84,20 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ToDo ==== - * make sprites always face the camera (is this done in camwindow.cpp ?) + * make sprites always face the camera (is this done in camwindow.cpp ?) - * maybe add an option to scale the sprites in the prefs ? + * maybe add an option to scale the sprites in the prefs ? - * un-hack the default fall-though to "sprite" model version (see m_version) + * un-hack the default fall-though to "sprite" model version (see m_version) - * maybe convert to a new kind of class not based on model. + * maybe convert to a new kind of class not based on model. - * allow sprites on non-fixedsize ents + * allow sprites on non-fixedsize ents - * fix reversed alpha map in spr loader + * fix reversed alpha map in spr loader - * allow an entity to have both an .md? and a sprite model. -*/ + * allow an entity to have both an .md? and a sprite model. + */ #include "plugin.h" #include "spritemodel.h" @@ -116,106 +116,110 @@ _QERShadersTable g_ShadersTable; #include "synapse.h" -char *supportedmodelformats[] = {"spr","bmp","tga","jpg","hlw",NULL}; // NULL is list delimiter +char *supportedmodelformats[] = {"spr", "bmp", "tga", "jpg", "hlw", NULL}; // NULL is list delimiter -static void add_model_apis(CSynapseClient& client) +static void add_model_apis(CSynapseClient &client) { - char **ext; - for (ext = supportedmodelformats; *ext != NULL; ext++) - { - client.AddAPI(MODEL_MAJOR, *ext, sizeof(_QERPlugModelTable)); - } + char **ext; + for (ext = supportedmodelformats; *ext != NULL; ext++) { + client.AddAPI(MODEL_MAJOR, *ext, sizeof(_QERPlugModelTable)); + } } -static bool model_is_supported(const char* extension) +static bool model_is_supported(const char *extension) { - char **ext; - for (ext = supportedmodelformats; *ext != NULL; ext++) - { - if (stricmp(extension,*ext)==0) - return true; - } - return false; + char **ext; + for (ext = supportedmodelformats; *ext != NULL; ext++) { + if (stricmp(extension, *ext) == 0) { + return true; + } + } + return false; } void init_filetypes() { - char **ext; - for (ext = supportedmodelformats; *ext != NULL; ext++) - { - GetFileTypeRegistry()->addType(MODEL_MAJOR, filetype_t("sprite", *ext)); - } + char **ext; + for (ext = supportedmodelformats; *ext != NULL; ext++) { + GetFileTypeRegistry()->addType(MODEL_MAJOR, filetype_t("sprite", *ext)); + } } -extern CSynapseServer* g_pSynapseServer; +extern CSynapseServer *g_pSynapseServer; -class CSynapseClientModel : public CSynapseClient -{ +class CSynapseClientModel : public CSynapseClient { public: - // CSynapseClient API - bool RequestAPI(APIDescriptor_t *pAPI); - const char* GetInfo(); - const char* GetName(); - - CSynapseClientModel() { } - virtual ~CSynapseClientModel() { } - - bool OnActivate() - { - init_filetypes(); // see todo list above. - return true; - } +// CSynapseClient API + bool RequestAPI(APIDescriptor_t *pAPI); + + const char *GetInfo(); + + const char *GetName(); + + CSynapseClientModel() + {} + + virtual ~CSynapseClientModel() + {} + + bool OnActivate() + { + init_filetypes(); // see todo list above. + return true; + } }; -CSynapseServer* g_pSynapseServer = NULL; +CSynapseServer *g_pSynapseServer = NULL; CSynapseClientModel g_SynapseClient; - -extern "C" CSynapseClient* SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces (const char *version, CSynapseServer *pServer) + +extern "C" CSynapseClient *SYNAPSE_DLL_EXPORT + +Synapse_EnumerateInterfaces(const char *version, CSynapseServer *pServer) { - if (strcmp(version, SYNAPSE_VERSION)) - { - Syn_Printf("ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version); - return NULL; - } - g_pSynapseServer = pServer; - g_pSynapseServer->IncRef(); - Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf()); - - add_model_apis(g_SynapseClient); // see todo list above. - - g_SynapseClient.AddAPI( PLUGIN_MAJOR, "sprite", sizeof( _QERPluginTable ) ); - g_SynapseClient.AddAPI( RADIANT_MAJOR, NULL, sizeof( g_FuncTable ), SYN_REQUIRE, &g_FuncTable ); - g_SynapseClient.AddAPI( QGL_MAJOR, NULL, sizeof( g_QglTable ), SYN_REQUIRE, &g_QglTable ); - g_SynapseClient.AddAPI( SHADERS_MAJOR, "*", sizeof( g_ShadersTable ), SYN_REQUIRE, &g_ShadersTable ); - - return &g_SynapseClient; + if (strcmp(version, SYNAPSE_VERSION)) { + Syn_Printf("ERROR: synapse API version mismatch: should be '" + SYNAPSE_VERSION + "', got '%s'\n", version ); + return NULL; + } + g_pSynapseServer = pServer; + g_pSynapseServer->IncRef(); + Set_Syn_Printf(g_pSynapseServer->Get_Syn_Printf()); + + add_model_apis(g_SynapseClient); // see todo list above. + + g_SynapseClient.AddAPI(PLUGIN_MAJOR, "sprite", sizeof(_QERPluginTable)); + g_SynapseClient.AddAPI(RADIANT_MAJOR, NULL, sizeof(g_FuncTable), SYN_REQUIRE, &g_FuncTable); + g_SynapseClient.AddAPI(QGL_MAJOR, NULL, sizeof(g_QglTable), SYN_REQUIRE, &g_QglTable); + g_SynapseClient.AddAPI(SHADERS_MAJOR, "*", sizeof(g_ShadersTable), SYN_REQUIRE, &g_ShadersTable); + + return &g_SynapseClient; } bool CSynapseClientModel::RequestAPI(APIDescriptor_t *pAPI) { - if (!strcmp(pAPI->major_name, MODEL_MAJOR)) - { - _QERPlugModelTable* pTable= static_cast<_QERPlugModelTable*>(pAPI->mpTable); + if (!strcmp(pAPI->major_name, MODEL_MAJOR)) { + _QERPlugModelTable *pTable = static_cast<_QERPlugModelTable *>( pAPI->mpTable ); - if (!strcmp(pAPI->minor_name, "sprite")) - { - pTable->m_pfnLoadModel = &LoadSpriteModel; - return true; + if (!strcmp(pAPI->minor_name, "sprite")) { + pTable->m_pfnLoadModel = &LoadSpriteModel; + return true; + } } - } - Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo()); - return false; + Syn_Printf("ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo()); + return false; } #include "version.h" -const char* CSynapseClientModel::GetInfo() +const char *CSynapseClientModel::GetInfo() { - return "Sprite Model module built " __DATE__ " " RADIANT_VERSION; + return "Sprite Model module built " __DATE__ " " + RADIANT_VERSION; } -const char* CSynapseClientModel::GetName() +const char *CSynapseClientModel::GetName() { - return "sprite"; + return "sprite"; }