Quake
2 Oop conversion project - Origins / Mission
Origins
/ Mission ( back to table of contents
) :
-
OOP means
Object Orientated
Programming. OOP is a datacentric progamming
style. C++ is an example of a programming language capable of true
OOP. In OOP, real life objects are coded as datatypes, or objects,
that have both internal properties and methods, or functions to define
that object's interaction with other things.
-
Quake2's dll / shared library game source
was released to the development community so that we could code TC's, weapons,
and other various addons. When it was released, many of us felt that C++
would be a much better language to represent the many things that are difficult
to NOT think of as objects. With the source code originally being
in C, it was impossible to implement OOP. The things that one might
think are objects are quite obvious, even without prior OOP experience:
all of the entites in the game would be objects. A monster is a type
of object, so is a player, and item, a platform, etc. Each has properties,
like health armor, targets, origin, etc, and has definite ways that they
interact with things such as, pain, run , die, attack, etc funcs.
In C, only the basic dataypes can be part of structs. In C++, all
the funcs specific to a type of object also become members of that struct/class.
-
C++ supports inheritance. Where one
object is defined as a type of another with more members added. In
the quake2 code, one would have a monster class (object type). Then, for
example, your light soldier would be defined as a type of monster class.
Things that are specific to the soldier type are now added to it's definition.
So the light soldier class now contains all the properties and functions
of the basic monster class and the new ones specific to the soldier class.
The Tank monster then would also be based on the monster base class, but
it would not share the data memebers or funcs that are specific to the
light soldier class. OOP leads to code reuse and encapsulation as
well as dynamic use of the object types. A few more features specific to
C++, not found in C, are the use of virtual functions, and the new and
delete operators. These features would greatly enhance the way code
is organized, and save a bit of busy work.
-
PeteDog had posted to a Quake 2 forum news
about his work, a translation of the source code into C++. His C++
version was only the code modified so that it would have a valid C++ syntax.
We started conversing and decided to found a project to convert the entire
source to utilize the conecpts of OOP. This also led to us discussing the
wants and needs to be able to mix and match multiple mod developers work.
The socket / plugin architecture will allow us to mix and match player
/ monster entities with weapons and other items. This means someone
could create a new type of monster, weapon, etc, compile and distribute
it, and have it work with the rest of the standard id entites while not
having to recompile id's entites as well. It also means, that each
new object does not need to know about the other types of objects for it
to work.
Quake
2 Oop Project Goals :
-
To implement OOP concepts in the code,
and to extend the api for more functionality.
-
Develop a plugin/socket API that would
allow mod makers to add new components to the game while only having to
compile code specific to their mod.