Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old April 26, 2009, 11:52   #1
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Cool Yay INT2BYTE!

I've been putting in a lot of debug-mode checking on type conversion into my code and it's finally paid off.

Code:
#ifndef NDEBUG
# define INT2BYTE(P) int2byte(P)
#else
# define INT2BYTE(P) (byte) (P)
#endif

#ifndef NDEBUG
byte int2byte(const int P)
{	
	assert(P >= 0);
	assert(P <= 255);
	return((byte) P);
}
#endif
It caught that the ego_item data I'm using allows negative to hit / to dam bonuses but the ego_item_type struct in Vanilla Angband stores them in byte (unsigned char) variables.
__________________
Currently turning (Angband) Japanese.
PaulBlay is offline   Reply With Quote
Old May 3, 2009, 11:16   #2
zaimoni
Knight
 
zaimoni's Avatar
 
Join Date: Apr 2007
Posts: 590
zaimoni is on a distinguished road
May I invite you to the darkness that is C++?

From Zaiband:
Code:
/*
 * Class to automate runtime checking of valid usage of m_idx against mon_list
 * It has some obnoxious traits, so use only when mon_list+m_idx_type needs to work automatically.
 */
class m_idx_type
{
	s16b _m_idx;
public:
	m_idx_type() {};
	m_idx_type(s16b src) : _m_idx(src) {assert(0<src);assert(mon_max>src);};
	void operator=(s16b src) {assert(0<src);assert(mon_max>src);_m_idx = src;};
	operator s16b() const {return _m_idx;};
	s16b operator--() {assert(1<_m_idx); return --_m_idx;}
	s16b operator--(int) {assert(1<_m_idx); return _m_idx--;}
};
zaimoni is offline   Reply With Quote
Old May 3, 2009, 11:59   #3
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quote:
Originally Posted by zaimoni View Post
May I invite you to the darkness that is C++?
Haha, well not until I've reached beta with C at any rate.

One programming language is more than enough to learn at a time.
__________________
Currently turning (Angband) Japanese.
PaulBlay 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 16:38.


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