p_ptr->command_cmd

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

    p_ptr->command_cmd

    command_cmd of the player_type structure is s16b, but as far as I can tell it is never assigned values outside of the char range. Is more expected from command_cmd in the future?

    As it is there are places, like

    Code:
    	/* Check for a "prevention" inscription */
    	verify_inscrip[1] = p_ptr->command_cmd;
    where I'm not sure if it is safe, or appropriate, to 'cast' p_ptr->command_cmd to (char) or not. I've been going through my (mostly your ;-) code tweaking it to remove compiler warnings and this is one of the few left. I don't want to cast stuff unless I'm pretty sure the RHS is really not going to exceed the cast specified.

    [EDIT] Incidentally I think it would be nice if you could make a clean break between 'key pressed' and 'command action'. You could make macros and keymappings easier to read and more flexible for a start.
    Currently turning (Angband) Japanese.
  • PowerDiver
    Prophet
    • Mar 2008
    • 2820

    #2
    Originally posted by PaulBlay
    command_cmd of the player_type structure is s16b, but as far as I can tell it is never assigned values outside of the char range. Is more expected from command_cmd in the future?

    As it is there are places, like

    Code:
    	/* Check for a "prevention" inscription */
    	verify_inscrip[1] = p_ptr->command_cmd;
    where I'm not sure if it is safe, or appropriate, to 'cast' p_ptr->command_cmd to (char) or not. I've been going through my (mostly your ;-) code tweaking it to remove compiler warnings and this is one of the few left. I don't want to cast stuff unless I'm pretty sure the RHS is really not going to exceed the cast specified.
    That's one of the things asserts are for.

    Comment

    • PaulBlay
      Knight
      • Jan 2009
      • 657

      #3
      Originally posted by PowerDiver
      That's one of the things asserts are for.
      Yeah, I've added a few of those, but most places it's pretty obvious.

      (e.g. randint0(25) isn't going to exceed a char value ).
      Currently turning (Angband) Japanese.

      Comment

      • takkaria
        Veteran
        • Apr 2007
        • 1951

        #4
        Originally posted by PaulBlay
        command_cmd of the player_type structure is s16b, but as far as I can tell it is never assigned values outside of the char range. Is more expected from command_cmd in the future?

        As it is there are places, like

        Code:
        	/* Check for a "prevention" inscription */
        	verify_inscrip[1] = p_ptr->command_cmd;
        where I'm not sure if it is safe, or appropriate, to 'cast' p_ptr->command_cmd to (char) or not. I've been going through my (mostly your ;-) code
        I disclaim responsibility for the vast majority of Angband.

        tweaking it to remove compiler warnings
        What compiler are you using?

        and this is one of the few left. I don't want to cast stuff unless I'm pretty sure the RHS is really not going to exceed the cast specified.
        Looks like it's a fairly safe cast to make, yeah, but I have no exhaustive answer you for since I've not really looked at it and it involves inkey(), which I avoid like the plague.

        [EDIT] Incidentally I think it would be nice if you could make a clean break between 'key pressed' and 'command action'. You could make macros and keymappings easier to read and more flexible for a start.
        Yup, it would, and is somewhat slowly being worked on.
        takkaria whispers something about options. -more-

        Comment

        • PaulBlay
          Knight
          • Jan 2009
          • 657

          #5
          What compiler are you using?
          VC++ (which complains more) and Dev-C++ (which had been associated with an apparently compiler-related game crash but now seems to be behaving).

          I now have only 4 warnings (down from 207). Wo-hoo!

          Looks like it's a fairly safe cast to make, yeah, but I have no exhaustive answer you for since I've not really looked at it and it involves inkey(), which I avoid like the plague.
          I'll stick an assert or two in there just in case then.
          Currently turning (Angband) Japanese.

          Comment

          • Pete Mack
            Prophet
            • Apr 2007
            • 6883

            #6
            @paul
            Getting rid of all warnings is always a nice relaxing task that still feels satisfying to complete... And yes, Visual Studio, like gcc, is a big step up from off-brand compilers.

            Comment

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