Help decrypting the effect_list ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PaulBlay
    Knight
    • Jan 2009
    • 657

    Help decrypting the effect_list ?

    Code:
    /* Use a slightly unusual include method to create effect_list[] */
    static const char *effect_list[] =
    {
    	#define EFFECT(x, y, r, z)    #x,
    	#include "list-effects.h"
    	#undef EFFECT
    };
    Code:
    EFFECT(XXX,            FALSE,  0,	NULL)
    EFFECT(POISON,         FALSE,  0,	"poisons you for 2d7+10 turns")
    EFFECT(BLIND,          FALSE,  0,	"blinds you for 4d25+75 turns")
    EFFECT(SCARE,          FALSE,  0,	"induces fear in you for 1d10+10 turns")
    Basically I'm currently (attempting to) make Angband place nicely with Unicode.

    My problem is that I don't know exactly what "#define EFFECT(x, y, r, z) #x," does and I need to change it because the "XXX" etc. are being treated as narrow text strings (8bit) and I either need to make them wide (16bit) or work out how to get it to compile while they are still narrow.

    So I'd really like to know what the "slightly unusual include method" is.
    Currently turning (Angband) Japanese.
  • takkaria
    Veteran
    • Apr 2007
    • 1951

    #2
    Originally posted by PaulBlay
    Code:
    /* Use a slightly unusual include method to create effect_list[] */
    static const char *effect_list[] =
    {
    	#define EFFECT(x, y, r, z)    #x,
    	#include "list-effects.h"
    	#undef EFFECT
    };
    Code:
    EFFECT(XXX,            FALSE,  0,	NULL)
    EFFECT(POISON,         FALSE,  0,	"poisons you for 2d7+10 turns")
    EFFECT(BLIND,          FALSE,  0,	"blinds you for 4d25+75 turns")
    EFFECT(SCARE,          FALSE,  0,	"induces fear in you for 1d10+10 turns")
    Basically I'm currently (attempting to) make Angband place nicely with Unicode.

    My problem is that I don't know exactly what "#define EFFECT(x, y, r, z) #x," does and I need to change it because the "XXX" etc. are being treated as narrow text strings (8bit) and I either need to make them wide (16bit) or work out how to get it to compile while they are still narrow.

    So I'd really like to know what the "slightly unusual include method" is.
    #x in an macro "stringifies" x. So, what that #define is just making EFFECT(XXX) into "XXX", or EFFECT(POISON) into "POISON", etc.

    (And can't you just use UTF-8 instead of UTF-16? It's much nicer... )
    takkaria whispers something about options. -more-

    Comment

    • PaulBlay
      Knight
      • Jan 2009
      • 657

      #3
      Originally posted by takkaria
      (And can't you just use UTF-8 instead of UTF-16? It's much nicer... )
      Now, now, you know it's only fun if everybody gets to make their own mistakes.

      Thanks for the #x info. Unfortunately I think the necessary changes would break that cute bit of coding so I'm re-doing it with extra redundancy for now.
      Currently turning (Angband) Japanese.

      Comment

      Working...
      😀
      😂
      🥰
      😘
      🤢
      😎
      😞
      😡
      👍
      👎