extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
{
- GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
- GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
- GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
- GlobalModuleServer::instance().set(server);
+ initialiseModule(server);
g_PrtViewPluginModule.selfRegister();
}
#define INCLUDED_MODULESYSTEM_H
#include "generic/static.h"
+#include "debugging/debugging.h"
#if defined(WIN32)
#define RADIANT_DLLEXPORT __stdcall
}
+inline void initialiseModule(ModuleServer& server)
+{
+ GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
+ GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
+ GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
+ GlobalModuleServer::instance().set(server);
+}
+
+
+
template<typename Type>
class Modules
{
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
{
- GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
- GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
- GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
- GlobalModuleServer::instance().set(server);
+ initialiseModule(server);
g_ArchivePakModule.selfRegister();
}
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
{
- GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
- GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
- GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
- GlobalModuleServer::instance().set(server);
+ initialiseModule(server);
g_ArchiveWadModule.selfRegister();
}
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
{
- GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
- GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
- GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
- GlobalModuleServer::instance().set(server);
+ initialiseModule(server);
g_ArchiveZipModule.selfRegister();
g_ArchivePK4Module.selfRegister();
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
{
- GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
- GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
- GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
- GlobalModuleServer::instance().set(server);
+ initialiseModule(server);
g_EntityQ3Module.selfRegister();
g_EntityWolfModule.selfRegister();
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
{
- GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
- GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
- GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
- GlobalModuleServer::instance().set(server);
+ initialiseModule(server);
g_ImageTGAModule.selfRegister();
g_ImageJPGModule.selfRegister();
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
{
- GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
- GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
- GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
- GlobalModuleServer::instance().set(server);
+ initialiseModule(server);
g_ImageHLWModule.selfRegister();
g_ImageMipModule.selfRegister();
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
{
- GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
- GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
- GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
- GlobalModuleServer::instance().set(server);
+ initialiseModule(server);
g_ImagePNGModule.selfRegister();
}
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
{
- GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
- GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
- GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
- GlobalModuleServer::instance().set(server);
+ initialiseModule(server);
g_ImageWalModule.selfRegister();
g_ImageM8Module.selfRegister();
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
{
- GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
- GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
- GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
- GlobalModuleServer::instance().set(server);
+ initialiseModule(server);
g_MapDoom3Module.selfRegister();
g_MapQuake4Module.selfRegister();
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
{
- GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
- GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
- GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
- GlobalModuleServer::instance().set(server);
+ initialiseModule(server);
g_MapXMLModule.selfRegister();
}
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
{
- GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
- GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
- GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
- GlobalModuleServer::instance().set(server);
+ initialiseModule(server);
g_ModelMD3Module.selfRegister();
g_ModelMD2Module.selfRegister();
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
{
- GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
- GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
- GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
- GlobalModuleServer::instance().set(server);
+ initialiseModule(server);
pico_initialise();
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
{
- GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
- GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
- GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
- GlobalModuleServer::instance().set(server);
+ initialiseModule(server);
g_SamplePluginModule.selfRegister();
}
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
{
- GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
- GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
- GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
- GlobalModuleServer::instance().set(server);
+ initialiseModule(server);
g_ShadersQ3Module.selfRegister();
g_ShadersDoom3Module.selfRegister();
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
{
- GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
- GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
- GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
- GlobalModuleServer::instance().set(server);
+ initialiseModule(server);
g_FileSystemQ3Module.selfRegister();
}
std::size_t Sys_Print(int level, const char* buf, std::size_t length)
{
- bool contains_newline = strchr(buf, '\n') != 0;
+ bool contains_newline = std::find(buf, buf+length, '\n') != buf+length;
if(level == SYS_ERR)
{
}
};
+class LineLimitedTextOutputStream : public TextOutputStream
+{
+ TextOutputStream& outputStream;
+ std::size_t count;
+public:
+ LineLimitedTextOutputStream(TextOutputStream& outputStream, std::size_t count)
+ : outputStream(outputStream), count(count)
+ {
+ }
+ std::size_t write(const char* buffer, std::size_t length)
+ {
+ if(count != 0)
+ {
+ const char* p = buffer;
+ const char* end = buffer+length;
+ for(;;)
+ {
+ p = std::find(p, end, '\n');
+ if(p == end)
+ {
+ break;
+ }
+ ++p;
+ if(--count == 0)
+ {
+ length = p - buffer;
+ break;
+ }
+ }
+ outputStream.write(buffer, length);
+ }
+ return length;
+ }
+};
+
class PopupDebugMessageHandler : public DebugMessageHandler
{
StringOutputStream m_buffer;
bool handleMessage()
{
getOutputStream() << "----------------\n";
- write_stack_trace(getOutputStream());
+ LineLimitedTextOutputStream outputStream(getOutputStream(), 24);
+ write_stack_trace(outputStream);
getOutputStream() << "----------------\n";
if(!m_lock.locked())
{