]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - r_modules.c
attempting to make darkplaces able to compile as 32bit on 64bit host systems (by...
[xonotic/darkplaces.git] / r_modules.c
index 1c30a4caf638fcb347205fcc74c9b9d1eed244e7..fc0186a3e852e50fe4b71a8992fa9bb5785dc30e 100644 (file)
@@ -1,46 +1,48 @@
 
 #include "quakedef.h"
 
+#define MAXRENDERMODULES 64
+
 typedef struct rendermodule_s
 {
        int active; // set by start, cleared by shutdown
        char *name;
-       void(*start)();
-       void(*shutdown)();
+       void(*start)(void);
+       void(*shutdown)(void);
+       void(*newmap)(void);
 }
 rendermodule_t;
 
-rendermodule_t rendermodule[64];
+rendermodule_t rendermodule[MAXRENDERMODULES];
 
-void R_Modules_Init()
+void R_Modules_Init(void)
 {
-       int i;
-       for (i = 0;i < 64;i++)
-               rendermodule[i].name = NULL;
+       Cmd_AddCommand("r_restart", R_Modules_Restart);
 }
 
-void R_RegisterModule(char *name, void(*start)(), void(*shutdown)())
+void R_RegisterModule(char *name, void(*start)(void), void(*shutdown)(void), void(*newmap)(void))
 {
        int i;
-       for (i = 0;i < 64;i++)
+       for (i = 0;i < MAXRENDERMODULES;i++)
        {
                if (rendermodule[i].name == NULL)
                        break;
                if (!strcmp(name, rendermodule[i].name))
                        Sys_Error("R_RegisterModule: module \"%s\" registered twice\n", name);
        }
-       if (i >= 64)
-               Sys_Error("R_RegisterModule: ran out of renderer module slots (64)\n");
+       if (i >= MAXRENDERMODULES)
+               Sys_Error("R_RegisterModule: ran out of renderer module slots (%i)\n", MAXRENDERMODULES);
        rendermodule[i].active = 0;
        rendermodule[i].name = name;
        rendermodule[i].start = start;
        rendermodule[i].shutdown = shutdown;
+       rendermodule[i].newmap = newmap;
 }
 
-void R_StartModules ()
+void R_Modules_Start(void)
 {
        int i;
-       for (i = 0;i < 64;i++)
+       for (i = 0;i < MAXRENDERMODULES;i++)
        {
                if (rendermodule[i].name == NULL)
                        continue;
@@ -51,10 +53,11 @@ void R_StartModules ()
        }
 }
 
-void R_ShutdownModules ()
+void R_Modules_Shutdown(void)
 {
        int i;
-       for (i = 0;i < 64;i++)
+       // shutdown in reverse
+       for (i = MAXRENDERMODULES - 1;i >= 0;i--)
        {
                if (rendermodule[i].name == NULL)
                        continue;
@@ -65,8 +68,23 @@ void R_ShutdownModules ()
        }
 }
 
-void R_Restart ()
+void R_Modules_Restart(void)
 {
-       R_ShutdownModules();
-       R_StartModules();
+       Con_Print("restarting renderer\n");
+       R_Modules_Shutdown();
+       R_Modules_Start();
 }
+
+void R_Modules_NewMap(void)
+{
+       int i;
+       for (i = 0;i < MAXRENDERMODULES;i++)
+       {
+               if (rendermodule[i].name == NULL)
+                       continue;
+               if (!rendermodule[i].active)
+                       continue;
+               rendermodule[i].newmap();
+       }
+}
+