Skip to content

Base objects

Gratt-5r2 edited this page Apr 9, 2022 · 2 revisions

← Gothic API

zCObject

• The main class of the gameplay classes is a zCObject. This is a smart-pointer object. Object will be deleted when refCtr (count of references) is 0. To above count of references use a AddRef() method and Release() to reduce. After creating default count is 1. Dont use operator delete directly to zCObject and its childs.

zCVob* self = new zCVob();  // self's refCrt is 1
zCVob* other = self;
other->AddRef();            // self's and other's refCrt is 2
self->Release();            // self's and other's refCrt is 1
other->Release();           // self's and other's refCrt is 0 - object deleted

• This class and its childs can be written to archives (save files), for that zCObject has two virtual methods: Archive() for write and Unarchive() for read.

• For easy cast object from one zCObject class to other, use the CastTo<T>() method.

zCVob* vob = player;
oCNpc* npc = player->CastTo<oCNpc>();

zCClassDef

The class is used to automatically create instances of classes from save files. For that classes has a declarator macro zCLASS_DECLARATION.

zCObjectFactory

Factory is a static class to create some classes (and Non-zCObject) - vobs, npcs, worlds etc.

Clone this wiki locally