Devilution: Create classes, constructors, and static variables

Created on 14 Jun 2018  路  5Comments  路  Source: diasurgical/devilution

This issue will be for creating the relevant C++ parts of the code. The decompiler doesn't have enough information on it's own to do so. The majority of data is currently written to the .DATA section of the executable, instead of .RDATA like the original. Classes will help to declare static/external variables and functions. The PSX symbol defines this for most functions/data.

Constructors should be used for a few files, example engine.cpp:

Class Engine
{
  public:
    gdwRandSeed;
    CelDecodeRaw(blah blah blah);
  private:
    Engine();
    ~Engine();
}
Engine()
//initialize CCritSection
~Engine()
//delete CCritSection
code cleanup low priority

Most helpful comment

Was that fixed already? The commit stream is so fast this week that it drowned me down a bit.

Haha, you are not the only one to be lost in the flurry of commits. Every time I go for lunch, sleep for a few hours, or look away from the screen, @galaxyhaxz, @AJenbo, @JustAnotherGuid and @qndel bump bin exactness by another percent or 5.

All 5 comments

It's possible to have static initializer functions without using C++, for example:

static void msgcmd_cpp_init_2(void)  // static initializer function
{
  msgcmd_init_event();
  msgcmd_cleanup_chatcmd_atexit();
}
// switch data segment to CRT$XCU (static constructor list)
#pragma data_seg(".CRT$XCU")
// store a pointer to the init function
void (*msgcmd_init)(void) = msgcmd_cpp_init_2;
// restore normal data segment
#pragma data_seg()

No idea if this works with mingw but I assume it would have to in order to be compatible with static libs.

Was that fixed already? The commit stream is so fast this week that it drowned me down a bit.

Was that fixed already? The commit stream is so fast this week that it drowned me down a bit.

Haha, you are not the only one to be lost in the flurry of commits. Every time I go for lunch, sleep for a few hours, or look away from the screen, @galaxyhaxz, @AJenbo, @JustAnotherGuid and @qndel bump bin exactness by another percent or 5.

this was done as part of the move from C++ to C afaik

There really aren't any C++ parts of the code except msgcmd.cpp (which is sitting in a PR) and possibly the Critical section constructors. I thought originally Diablo had used far more CPP then it actually did, hehe.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AJenbo picture AJenbo  路  8Comments

AJenbo picture AJenbo  路  8Comments

nomdenom picture nomdenom  路  9Comments

Ogodei picture Ogodei  路  6Comments

AJenbo picture AJenbo  路  7Comments