Common LPC Migration issues: v2019

starting FluffOS v2019, the driver makes a lot of effort to stay in compatible with old lib.

In general, the driver will have an set of standard language features that will not change in minor releases.

However:

  1. New efun could still be added, but very rarely, more stuff will appear in stdlib in LPC instead.
  2. New language features could be implemented only if it is backward compatible
  3. Once LPC formatter and fixer tool are implemented, all language changes will include automatic fixes by this tool.

Otherwise, Here are a list of common issues you may encounter upgrading the lib to latest fluffos 2019.

Keyword: static

Long ago, driver uses an keyword static on both variable declarations and function prototype, which has very complex meaning that is hard to grasp. Later, an #define SENSIBLE_MODIFIER is introduced, which get rid of static and replace them with nosave and protected, this is not backward compatible, meaning you must change your LPC code before it compiles. nosave means the variable would be ignored during “save_object()” and “restore_object()” , and “protected” means that the function is accessible by inherited program , by default all functions are declared “private” meaning it is not accessible by inherited program.

In v2019, the driver enable this by default, and it is strongly discouraged for anyone to turn it off. This compile time define will be removed in the future, so it is highly recommended to take the time to fix this in your lib code.

As an reference, the time that takes to fix static in the lib is generally 30 minutes to an hour at most, it is not an big deal as many would think.

Example: Variables

static int a;

should be changed to

nosave int a;

Example: Function Prototype

static int func(...) {
   ...
}

should be changed to

protected int func(...) {
  ...
}

Furthermore, if you see some uncommon usage like:

static private int func() {
   ....
}

These should be changed to

protected int func() {
  ...
}

Keyword: array

The driver got rid of the array keyword that was used to declare arrays, * should be used instead.

Example: variable declartion

int array v1;

should be changed to

int *v1;

instead.

int array v1, v2;

should be

int *v1, *v2;

instead.

Example: function prototype

int array func(...) { ... }

should be changed to

int* func(...) { ... }

instead.

Special case: untyped variable.

array v1;

should be changed to

mixed *v1;

instead.

Keyword: class, ref

If you have variable names as “class” . “ref” , just change it to other name.

string class; could simply be changed to string str_class instead.

EFUN: apply() is missing

Use the LPC simul_efun implementation instead
https://github.com/fluffos/fluffos/blob/master/compat/simuls/apply.c

UTF-8 related issue

string in FluffOS v2019 is utf-8 native. You can not store arbitrary bytes into string unless it is valid UTF-8 string. Instead, you should be using buffer type to store bytes instead.

see UTF-8 support in v2019 for more details on the topic.

1 Like

Crypt

  1. crypt(password, “”) will by default use SHA512 to securely encrypt your password!
  2. crypt with old password will still work, but will complain in debug log.
  3. oldcrypt() is the old MD5 based crypt() that also works, and also complains, please have user type password again to securely encrypt their password to SHA512.