]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/imagehl/imagehl.cpp
uncrustify! now the code is only ugly on the *inside*
[xonotic/netradiant.git] / plugins / imagehl / imagehl.cpp
1 /*
2    Copyright (c) 2001, Loki software, inc.
3    All rights reserved.
4
5    Redistribution and use in source and binary forms, with or without modification,
6    are permitted provided that the following conditions are met:
7
8    Redistributions of source code must retain the above copyright notice, this list
9    of conditions and the following disclaimer.
10
11    Redistributions in binary form must reproduce the above copyright notice, this
12    list of conditions and the following disclaimer in the documentation and/or
13    other materials provided with the distribution.
14
15    Neither the name of Loki software nor the names of its contributors may be used
16    to endorse or promote products derived from this software without specific prior
17    written permission.
18
19    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
20    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22    DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
23    DIRECT,INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26    ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 //
32 // HalfLife WAD format image loading plugin
33 //
34 // hydra - hydra@hydras-world.com
35 //
36
37 #include <stdio.h>
38 #include "imagehl.h"
39 #include "lbmlib.h"
40
41 // =============================================================================
42 // static variables
43
44 _QERFuncTable_1 g_FuncTable; // Radiant function table
45 _QERFileSystemTable g_FileSystemTable;
46
47 // =============================================================================
48 // SYNAPSE
49
50 CSynapseServer* g_pSynapseServer = NULL;
51 CSynapseClientImageHL g_SynapseClient;
52
53 #if __GNUC__ >= 4
54 #pragma GCC visibility push(default)
55 #endif
56 extern "C" CSynapseClient * SYNAPSE_DLL_EXPORT Synapse_EnumerateInterfaces( const char *version, CSynapseServer *pServer ) {
57 #if __GNUC__ >= 4
58 #pragma GCC visibility pop
59 #endif
60         if ( strcmp( version, SYNAPSE_VERSION ) ) {
61                 Syn_Printf( "ERROR: synapse API version mismatch: should be '" SYNAPSE_VERSION "', got '%s'\n", version );
62                 return NULL;
63         }
64         g_pSynapseServer = pServer;
65         g_pSynapseServer->IncRef();
66         Set_Syn_Printf( g_pSynapseServer->Get_Syn_Printf() );
67
68 #ifdef USE_HLW
69         g_SynapseClient.AddAPI( IMAGE_MAJOR, "hlw", sizeof( _QERPlugImageTable ) );
70 #endif
71 #ifdef USE_MIP
72         g_SynapseClient.AddAPI( IMAGE_MAJOR, "mip", sizeof( _QERPlugImageTable ) );
73 #endif
74 #ifdef USE_IDSP
75         g_SynapseClient.AddAPI( IMAGE_MAJOR, "spr", sizeof( _QERPlugImageTable ) );
76 #endif
77         // this "wad" needs to be "*" for the VFS, we don't care what VFS we have, as long as we have one.
78         g_SynapseClient.AddAPI( VFS_MAJOR, "wad", sizeof( _QERFileSystemTable ), SYN_REQUIRE, &g_FileSystemTable );
79         g_SynapseClient.AddAPI( RADIANT_MAJOR, NULL, sizeof( _QERFuncTable_1 ), SYN_REQUIRE, &g_FuncTable );
80
81         return &g_SynapseClient;
82 }
83
84 bool CSynapseClientImageHL::RequestAPI( APIDescriptor_t *pAPI ){
85         if ( !strcmp( pAPI->major_name, "image" ) ) {
86                 _QERPlugImageTable* pTable = static_cast<_QERPlugImageTable*>( pAPI->mpTable );
87
88                 pTable->m_pfnLoadImage = &LoadImage;
89                 return true;
90         }
91
92         Syn_Printf( "ERROR: RequestAPI( '%s' ) not found in '%s'\n", pAPI->major_name, GetInfo() );
93         return false;
94 }
95
96 #include "version.h"
97
98 const char* CSynapseClientImageHL::GetInfo(){
99         return "imagehl formats module built " __DATE__ " " RADIANT_VERSION;
100 }