D2X-XL Worklog

Notes on features and problems from the development of D2X-XL, newest first.

Code Cleanup: AI

After the 'high profile' enhanced Pyro coding had been going on during the last few weeks, I have found some time now to do some direly needed 'behind the scenes' clean up and reworking of the existing code base, which still in parts is a big, ugly mess, stuffing dozens and dozens of functions with thousands of code lines into one or two completely unstructured source files. I tried to avoid this task, but having to deal with bugs and flaws in exactly that code forced me into bringing it into a shape I could work with.

What I had tackled first was the AI code. I ended up in splitting two huge files into ten smaller ones that actually contained what the file names suggested. The main AI dispatcher function was a moloch with over 1000 lines of code, performing several tasks all in one. Well ... it worked somehow, so the guy who wrote it shall be forgiven - at least he is one of the guys who brought us Descent.

I moved each AI function's code block into a separate function that gets called via a function table using the AI state as table index. Instead of juggling around with a bunch of separate data areas, the communication between the various functions is performed by exchanging a neat and clean data block. Here is an excerpt of the code as it looks now to give you an impression (before, each function call was a big block of code):

void DoAIFrame (tObject *objP)
{
   tAIStateInfo si;

// initialize si here
si.nObject = OBJ_IDX (objP);
si.nObjRef = si.nObject ^ gameData.app.nFrameCount;
...
if (AIFireHandler (objP, &si)) return;
if (AIApproachHandler (objP, &si)) return;
if (AIRetryHandler (objP, &si)) return;
if (AIMatCenHandler (objP, &si)) return;
if (AIAwarenessHandler (objP, &si)) return;
if (AIPlayerDeadHandler (objP, &si)) return;
if (AIBumpHandler (objP, &si)) return;
...
}

Here is an example of using a function table instead of a big list of separate state queries (before, there was a huge case statement instead of the function call via the table):

// type of the handler function
typedef int (* pAIHandler) (tObject *objP, tAIStateInfo *);

//the function table containing the handler functions for each state
static pAIHandler aisHandler1 [] = {
   AISNoneHandler1, AISRestHandler1, AISSearchHandler1,
   AISLockHandler1, AINothingHandler, AISFireHandler1,
   AISRecoverHandler1, AINothingHandler};

int AIForceFireHandler (tObject *objP, tAIStateInfo *siP)
{
tAIStatic *aiP = siP->aiP;
...
//only call function if the state points into the table
if ((ushort) aiP->CURRENT_STATE < AIS_ERROR)
   return aisHandler1 [aiP->CURRENT_STATE] (objP, siP);
return AISDefaultHandler1 (objP, siP);
}


News

A new D2X-XL update fixing broken screen resolution persistence is available

There is yet another D2X-XL update is available (the new Pumo Mines broke a few things ...)

Believe it or not: There's a new D2X-XL version online!

Uploaded updated D2X-XL and library source code that compiles with Visual Studio 19

After a really long time, another new DLE version is available

A new DLE version is available (hear, hear!) :D

A new Max OS X version of D2X-XL is available!

D2X-XL now offers a cartoon style render mode!

New D2X-XL and DLE versions are available

Blarget has got his own area in the level spotlight

New D2X-XL and DLE versions are available

A couple of levels have been added to the level spotlight

Hooray! We're finally having a new Mac OS X version of D2X-XL!

D2X-XL now features an observer mode for multiplayer games

A new D2X-XL version with improved multiplayer synchronization is available

A new D2X-XL version fixing out of sync problems in multiplayer games is available

A new D2X-XL version with many multiplayer bug fixes is available

Added high quality (ogg) Descent 1 and 2 music to the downloads area

A new D2X-XL version with important bug fixes is available

D2X-XL compiles and runs on Linux again!

Descent 1 and 2 high res textures are now available as complete downloads

A new DLE version with a ton of bug fixes and improvements is online

A new D2X-XL version is online

A new D2X-XL version with a much needed bug fix is online

A new DLE version is online

Published another DLE version with more bug fixes and improvements by Sirius

Published a new D2X-XL version

Published a new DLE version with tons of bug fixes and improvements by Sirius

D2X-XL now supports Oculus Rift 3D headsets!

Updated DLE and D2X-XL to support new level features requested by Pumo

Added an article about DLE's new tunnel generator to the worklog

DLE's new tunnel generator is finished

Added a new article to the worklog

Published a new DLE version

Added a new article to the worklog

Added two new articles to the worklog

D2X-XL and DLE-XP now support triangular segment sides!

DLE-XP has an OpenGL render and 1st person view!

New DLE-XP version available

Wrote a new worklog article

Check out DarkFlameWolf's level spotlight section!

New DLE-XP and D2X-XL versions are available

A new DLE-XP version is available

Added a worklog article about the way point feature

Added way point support to DLE-XP and D2X-XL

Posted a bunch of new screenshots

Posted a bunch of new screenshots

A New version of DLE-XP is available

New OS X version of D2X-XL is available!

Added article about lightmaps to worklog.

New article and video added to worklog.