gothic-1-community-patch icon indicating copy to clipboard operation
gothic-1-community-patch copied to clipboard

Make an effort to remove integer variables where possible

Open szapp opened this issue 4 months ago • 0 comments

The G1CP is advertised as leaving no traces in the game save. That is true with the exception of integer variables that Gothic writes. Most uses of integer variables in the G1CP do not require persistence (as it goes against the idea of the G1CP).

To avoid cluttering save games it might be worth considering to replace integer variable declarations by constants where possible. Nevertheless, this is mostly a theoretical improvement, because integer function arguments are variables by necessity and cannot be replaced.

We should discuss where a replacement makes sense and whether it wouldn't just cause less readable code for no benefit.

Typical pattern:

func void G1CP_Before(var int willForeverBeAVariable) {
    var int couldBeAConstant; couldBeAConstant = willForeverBeAVariable+ 1;
    return couldBeAConstant;
};

func void G1CP_After(var int willForeverBeAnInteger) {
    const int isNowAConstant = -1; isNowAConstant = willForeverBeAVariable+ 1;
    return isNowAConstant;
};

szapp avatar Aug 04 '25 19:08 szapp