Multi code tags, issue or I did it wrong?

It's not about multiple code tags. The cause is the combination of putting the code tag on the same line as the code as well as having blank lines in the block.

This BBCode:

[code]foo

bar[/code]

Renders like this:

[code]foo

bar[/code]

But this BBCode:

[code]
foo

bar
[/code]

renders as expected

foo

bar

My advice is that, rather than having to find out how to deal with the differences in the handling of BBCode between the old SMF forum framework and the new Discourse framework, to abandon BBCode altogether and use the Markdown markup language instead. Markdown is increasingly becoming the universal standard, so if you take the time to learn it, you will end up finding that knowledge is useful many places, not only on forums.
https://www.markdownguide.org/extended-syntax/#fenced-code-blocks

```
x_message.topic = topic; //store new topic

int i = 0; // extract payload
for ( i; i < length; i++)
{
x_message.payload[i] = ((char)payload[i]);
}
x_message.payload[i] = ‘\0’;
```