Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old April 21, 2009, 19:38   #1
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
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.
PaulBlay is offline   Reply With Quote
Old April 21, 2009, 19:40   #2
PowerDiver
Prophet
 
Join Date: Mar 2008
Posts: 2,712
PowerDiver is on a distinguished road
Quote:
Originally Posted by PaulBlay View Post
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.
PowerDiver is offline   Reply With Quote
Old April 21, 2009, 19:41   #3
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quote:
Originally Posted by PowerDiver View Post
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.
PaulBlay is offline   Reply With Quote
Old April 21, 2009, 20:54   #4
takkaria
Veteran
 
takkaria's Avatar
 
Join Date: Apr 2007
Posts: 1,936
Donated: $40
takkaria is on a distinguished road
Quote:
Originally Posted by PaulBlay View Post
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.

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

Quote:
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.

Quote:
[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-
takkaria is offline   Reply With Quote
Old April 21, 2009, 21:38   #5
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quote:
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!

Quote:
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.
PaulBlay is offline   Reply With Quote
Old April 22, 2009, 05:24   #6
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 5,414
Donated: $40
Pete Mack is on a distinguished road
@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.
Pete Mack is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 15:04.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.