GZCOM Director - nsgomez/gzcom-dll GitHub Wiki

A GZCOM Director is an object that can interact with the framework when registered by adding new class objects and IDs, receiving hook calls, and calling into the framework itself and the application associated with it (i.e. SimCity 4).

The Rizzo COM Director (or RZCOMDirector) is a base implementation of a COM director that other directors are derived from. While most of its behavior is perfect and should work fine, there may be a few instances where it would be desirable to override default behavior. Namely:

  • All hooks, such as PreFrameWorkInit, PostAppInit, PostSystemServiceShutdown, etc. can be overloaded to set up and destroy any services and objects used by your modification as needed.
  • CanUnloadNow: By default, this only checks that your director's reference count is zero and that any sub-directors say they can unload. You may wish to add other conditions where you wouldn't want to have your DLL unloaded, such as in the middle of an asynchronous I/O operation.
  • GetHeapAllocatedSize: The vast majority of SC4's objects, if not all of them, appear to be allocated on the stack or statically allocated. If you need to create objects on the heap, you should override this and keep track of your heap size, though it's unknown if this actually influences any game behavior. In particular, the game's RZCheckHeap method is a dummy method that always returns true no matter what.

Note that returning false in OnStart appears to have no effect.

If you'd like to register new services and classes for other DLLs (or perhaps the game) to take advantage of, you can have your director extend cIGZSystemService and have its own service ID, or use AddCls and provide a factory method for spawning new IGZUnknown objects, respectively.

If you do this and create your own custom class, make sure to create your own abstract interface class to extend from and implement QueryInterface accordingly. Otherwise, any other directors trying to interact with that class will need far more header information about your class than should be necessary. Refer to the game's style of declaring classes and interfaces for a general idea on how to accomplish this.