diff --git a/src/camera.cpp b/src/camera.cpp
index 76e68a3..966c43d 100644
--- a/src/camera.cpp
+++ b/src/camera.cpp
@@ -12,6 +12,8 @@
namespace rw {
+PluginList Camera::s_plglist = { sizeof(Camera), sizeof(Camera), nil, nil };
+
void
defaultBeginUpdateCB(Camera *cam)
{
diff --git a/src/clump.cpp b/src/clump.cpp
index 17efa3d..258d737 100644
--- a/src/clump.cpp
+++ b/src/clump.cpp
@@ -13,6 +13,9 @@
namespace rw {
+PluginList Clump::s_plglist = { sizeof(Clump), sizeof(Clump), nil, nil };
+PluginList Atomic::s_plglist = { sizeof(Atomic), sizeof(Atomic), nil, nil };
+
//
// Clump
//
diff --git a/src/frame.cpp b/src/frame.cpp
index 80fbe41..ff635d2 100644
--- a/src/frame.cpp
+++ b/src/frame.cpp
@@ -12,6 +12,7 @@
namespace rw {
LinkList Frame::dirtyList;
+PluginList Frame::s_plglist = { sizeof(Frame), sizeof(Frame), nil, nil };
Frame*
Frame::create(void)
diff --git a/src/geometry.cpp b/src/geometry.cpp
index 2ee044d..44dcfc4 100644
--- a/src/geometry.cpp
+++ b/src/geometry.cpp
@@ -14,6 +14,9 @@
namespace rw {
+PluginList Geometry::s_plglist = { sizeof(Geometry), sizeof(Geometry), nil, nil };
+PluginList Material::s_plglist = { sizeof(Material), sizeof(Material), nil, nil };
+
SurfaceProperties defaultSurfaceProps = { 1.0f, 1.0f, 1.0f };
Geometry*
diff --git a/src/image.cpp b/src/image.cpp
index 06a7ef3..244ff77 100644
--- a/src/image.cpp
+++ b/src/image.cpp
@@ -24,6 +24,10 @@
namespace rw {
+PluginList TexDictionary::s_plglist = { sizeof(TexDictionary), sizeof(TexDictionary), nil, nil };
+PluginList Texture::s_plglist = { sizeof(Texture), sizeof(Texture), nil, nil };
+PluginList Raster::s_plglist = { sizeof(Raster), sizeof(Raster), nil, nil };
+
//
// TexDictionary
//
diff --git a/src/light.cpp b/src/light.cpp
index 55eeba0..21ced14 100644
--- a/src/light.cpp
+++ b/src/light.cpp
@@ -11,6 +11,8 @@
namespace rw {
+PluginList Light::s_plglist = { sizeof(Light), sizeof(Light), nil, nil };
+
static void
lightSync(ObjectWithFrame*)
{
diff --git a/src/rwobjects.h b/src/rwobjects.h
index d38373a..e18fa70 100644
--- a/src/rwobjects.h
+++ b/src/rwobjects.h
@@ -82,8 +82,9 @@ struct Object
}
};
-struct Frame : PluginBase
+struct Frame
{
+ PLUGINBASE
typedef Frame *(*Callback)(Frame *f, void *data);
enum { ID = 0 };
enum { // private flags
@@ -215,8 +216,9 @@ struct RasterLevels
} levels[1]; // 0 is illegal :/
};
-struct Raster : PluginBase
+struct Raster
{
+ PLUGINBASE
int32 platform;
int32 type; // hardly used
@@ -268,8 +270,9 @@ struct Raster : PluginBase
struct TexDictionary;
-struct Texture : PluginBase
+struct Texture
{
+ PLUGINBASE
Raster *raster;
TexDictionary *dict;
LLLink inDict;
@@ -317,8 +320,9 @@ struct SurfaceProperties
float32 diffuse;
};
-struct Material : PluginBase
+struct Material
{
+ PLUGINBASE
Texture *texture;
RGBA color;
SurfaceProperties surfaceProps;
@@ -391,8 +395,9 @@ struct MaterialList
uint32 streamGetSize(void);
};
-struct Geometry : PluginBase
+struct Geometry
{
+ PLUGINBASE
enum { ID = 8 };
Object object;
uint32 flags;
@@ -453,8 +458,9 @@ void registerNativeDataPlugin(void);
struct Clump;
struct World;
-struct Atomic : PluginBase
+struct Atomic
{
+ PLUGINBASE
typedef void (*RenderCB)(Atomic *atomic);
enum { ID = 1 };
enum {
@@ -509,8 +515,9 @@ struct Atomic : PluginBase
void registerAtomicRightsPlugin(void);
-struct Light : PluginBase
+struct Light
{
+ PLUGINBASE
enum { ID = 3 };
ObjectWithFrame object;
float32 radius;
@@ -568,8 +575,9 @@ struct FrustumPlane
uint8 closestZ;
};
-struct Camera : PluginBase
+struct Camera
{
+ PLUGINBASE
enum { ID = 4 };
enum { PERSPECTIVE = 1, PARALLEL };
enum { CLEARIMAGE = 0x1, CLEARZ = 0x2};
@@ -625,8 +633,9 @@ struct Camera : PluginBase
void setFOV(float32 fov, float32 ratio);
};
-struct Clump : PluginBase
+struct Clump
{
+ PLUGINBASE
enum { ID = 2 };
Object object;
LinkList atomics;
@@ -664,8 +673,9 @@ struct Clump : PluginBase
};
// A bit of a stub right now
-struct World : PluginBase
+struct World
{
+ PLUGINBASE
enum { ID = 7 };
Object object;
LinkList lights; // these have positions (type >= 0x80)
@@ -676,8 +686,9 @@ struct World : PluginBase
void addCamera(Camera *cam);
};
-struct TexDictionary : PluginBase
+struct TexDictionary
{
+ PLUGINBASE
enum { ID = 6 };
Object object;
LinkList textures;
diff --git a/src/rwplg.h b/src/rwplg.h
index 9dc082b..38a1bee 100644
--- a/src/rwplg.h
+++ b/src/rwplg.h
@@ -49,27 +49,22 @@ struct PluginList
int32 getPluginOffset(uint32 id);
};
-template
-struct PluginBase
-{
- static PluginList s_plglist;
+#define PLUGINBASE \
+ static PluginList s_plglist; \
+ static int32 registerPlugin(int32 size, uint32 id, Constructor ctor, \
+ Destructor dtor, CopyConstructor copy){ \
+ return s_plglist.registerPlugin(size, id, ctor, dtor, copy); \
+ } \
+ static int32 registerPluginStream(uint32 id, StreamRead read, \
+ StreamWrite write, StreamGetSize getSize){ \
+ return s_plglist.registerStream(id, read, write, getSize); \
+ } \
+ static int32 setStreamRightsCallback(uint32 id, RightsCallback cb){ \
+ return s_plglist.setStreamRightsCallback(id, cb); \
+ } \
+ static int32 getPluginOffset(uint32 id){ \
+ return s_plglist.getPluginOffset(id); \
+ }
- static int32 registerPlugin(int32 size, uint32 id, Constructor ctor,
- Destructor dtor, CopyConstructor copy){
- return s_plglist.registerPlugin(size, id, ctor, dtor, copy);
- }
- static int32 registerPluginStream(uint32 id, StreamRead read,
- StreamWrite write, StreamGetSize getSize){
- return s_plglist.registerStream(id, read, write, getSize);
- }
- static int32 setStreamRightsCallback(uint32 id, RightsCallback cb){
- return s_plglist.setStreamRightsCallback(id, cb);
- }
- static int32 getPluginOffset(uint32 id){
- return s_plglist.getPluginOffset(id);
- }
-};
-template
-PluginList PluginBase::s_plglist = { sizeof(T), sizeof(T), nil, nil };
}
diff --git a/src/world.cpp b/src/world.cpp
index f63c618..41bad9e 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -13,6 +13,8 @@
namespace rw {
+PluginList World::s_plglist = { sizeof(World), sizeof(World), nil, nil };
+
World*
World::create(void)
{