Going Through Trash Most classic video games now got source code either leaked by the devs or reverse engineered.
Habitat (1986 MMORPG!) is really interesting, since they came with The Sims style smart objects long before 2000
https://github.com/historicalsource/habitat/blob/master/sources/c64/Behaviors/new.mudSomebody should make it run on modern systems just for kicks.
Here are a few more entity implementations:
https://github.com/jbalcomb/ReMoM/blob/main/src/UNITTYPE.Hhttps://github.com/videogamepreservation/creatures3/blob/master/engine/Agents/Agent.hhttps://github.com/mhjlam/bam/blob/master/CODE/SRC/UNITS.HPPhttps://github.com/dariusk/ja2/blob/master/ja2/Build/Tactical/Item%20Types.hhttps://github.com/grasmanek94/darkreign2/blob/master/coregame_objects/mapobj.hhttps://github.com/dkfans/keeperfx/blob/master/src/creature_states.hUkrainian video game, the code is pure C, despite files being .cpp.
AnimateElements shows how everything gets processed in a rather inefficient way:
https://github.com/videogamepreservation/carnivoresiceage/blob/master/Game.cppSerious Sam engine actually uses a barebones ECS, reminiscent to Ultima Underworld and attaching components to an ID
https://github.com/historicalsource/Serious-Engine/blob/master/Sources/Engine/Entities/Entity.hhttps://github.com/historicalsource/Serious-Engine/blob/master/Sources/Engine/Entities/EntityProperties.hhttps://github.com/Serious-Engine/EntitiesApparently these were added later, when ECS became well known, since Croats are too dumb to come with that themselves.
And the entity class is too bloated.
They also have a crazy macro processor used to produce the entity sub classes.
An RTS which used a hex grid (rather unusual choice):
https://github.com/Marenz/EnemyNations/blob/master/src/unit.hCheck SOLDIERTYPE in
https://github.com/dariusk/ja2/blob/master/ja2/Build/Tactical/Soldier%20Control.hit is insanely complex. Probably the most bloated class I ever seen.
Warcraft 2 was reversed and re-implemented multiple times, but here is the original unit.h from the leaked source code:
https://archive.org/details/warcraftIIsourcecodePSXIt has stuff like
UBYTE bFlashColor;
UBYTE bFlashCount;
which is active only for one unit at tine, but wastes memory on all units.
but animation system looks especially kludgety.
/* if this structure changes, seqx.asm must be changed */
typedef struct TSeqStruct {
GPOINT seqPix; /* absolute pixel coords */
UWORD seqScriptPtr; /* offset into scripts data */
UBYTE seqFlags; /* object flags */
UBYTE seqTimer; /* countdown timer */
UBYTE seqAction; /* USEQ type */
UBYTE seqFrame; /* current frame */
UBYTE seqFace; /* frame direction */
UBYTE seqSound; /* sound to play */
UBYTE seqDispOffset; /* displacement to make boat floating effect */
UBYTE seqDispTimer; /* displacement timer */
UWORD seqUnused;
} TSeq, * TSeqPtr;
typedef struct TUnitStruct {
TSeq unitSeq;
GPOINT unitMtx; /* unit matrix coordinate */
UWORD uFlags;
UWORD sFlags;
UWORD aiFlags;
UWORD unitHP; /* hitpoints */
UBYTE bSndCounter;
UBYTE unitCard;
UBYTE unitMP; /* misc points (dependent on unit type)*/
UBYTE unitType; /* infantry, wizard, etc.*/
UBYTE unitMasked; /* Bits indicate if unit is masked to a particular player */
UBYTE unitVisMask; /* unit visibility per player */
UBYTE unitClass; /* Land/Water, Air/submerged */
UBYTE unitGroup; /* current group file */
UBYTE unitOwner;
UBYTE unitCreator; /* Player that created this unit */
UBYTE unitCurrAction; /* active unit orders */
UBYTE unitNextAction; /* next orders when curr orders done */
UBYTE bTravFaces[TRAVERSE_STEPS];
UWORD unitInvis; /* time until spells wear off */
UWORD unitArmor; /* time until spells wear off */
UWORD unitRage; /* time until spells wear off */
SWORD unitWarp; /* time until spells wear off */
UWORD unitSpells; /* checked by computer players only */
UWORD unitFire; /* this is time until next fire is allowed */
UBYTE bFlashColor;
UBYTE bFlashCount;
UWORD patrolFlags;
PTUnit pAttacker; /* who's attacking me?*/
TUnitAI unitAI;
PTUnit pNext; /* linked list for each owner */
/* ut: union */
/* peon --> when tree/stone will be harvested */
/* build -> when next grunt will be completed */
union {
TMan man;
TBuild build;
TTransport trans;
} ut;
/* um: union */
/* bldg is for buildings --> workers/repair state */
/* target is for men --> attack location */
union {
TBldg bldg;
TTarget targ;
} um;
} TUnit;
Current Mood: amused