Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old May 27, 2009, 20:15   #1
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quick Term_erase question.

And the question is ... what's this bit in aid of?

Code:
	if ((n > 0) && (scr_cc[x] == (char) -1) && (scr_aa[x] == 255))
	{
		x--;
		n++;
	}
Apart from not understanding it and wanting to my problem is that I am using wchar_t not char for text so that "(char) -1" and "255" might well not be compatible with the rest of the code now.

Incidentally, if I was going to guess, I'd suspect it might have something to do with BIGTILE mode? (Maybe not).

[EDIT] Yeah, looks like it's BIGTILE stuff. I think I've got a handle on it, but I guess I'll end up changing some code for this.
__________________
Currently turning (Angband) Japanese.

Last edited by PaulBlay; May 27, 2009 at 20:34.
PaulBlay is offline   Reply With Quote
Old May 28, 2009, 06:08   #2
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 5,327
Donated: $40
Pete Mack is on a distinguished road
Ain't that some nice 80's-style code. Sweet!

It's stepping back the pad character of a tile in double-wide mode.
Pete Mack is offline   Reply With Quote
Old May 28, 2009, 06:34   #3
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quote:
Originally Posted by Pete Mack View Post
Ain't that some nice 80's-style code. Sweet!
Tell me about it. There don't seem to be any #defines for attribute values so you just have to hope somebody left a comment or hope your psychic powers are up to stuff.

Quote:
It's stepping back the pad character of a tile in double-wide mode.
Yeah, I figured it was something like that. I'm going to have to do similar stuff for handling double-width characters as well.
__________________
Currently turning (Angband) Japanese.
PaulBlay is offline   Reply With Quote
Old May 28, 2009, 06:39   #4
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 5,327
Donated: $40
Pete Mack is on a distinguished road
I can write it more efficiently, if you like. The if statement is unnecessarily verbose.
Code:
         (n > 0) && (scr_cc[x] == (char) -1) && (scr_aa[x] == 255) && (x--, n++);
Pete Mack is offline   Reply With Quote
Old May 28, 2009, 11:24   #5
Nick
Vanilla maintainer
 
Nick's Avatar
 
Join Date: Apr 2007
Location: Canberra, Australia
Age: 54
Posts: 7,737
Donated: $60
Nick is on a distinguished road
Quote:
Originally Posted by PaulBlay View Post
Yeah, I figured it was something like that. I'm going to have to do similar stuff for handling double-width characters as well.
Andrew Doull has extended this for double and triple tiles - which I stole for FA. Working that out and debugging edge effect issues was a lot of fun You may find it useful to look at one of those implementations (Un or FA or O110u), or you may have a neater way of doing it.
__________________
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
Nick is offline   Reply With Quote
Old May 28, 2009, 11:28   #6
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quote:
Originally Posted by Nick View Post
Andrew Doull has extended this for double and triple tiles - which I stole for FA.
Thanks, I'll probably have a look at that later.

Quote:
Originally Posted by Nick View Post
or you may have a neater way of doing it.
That seems unlikely.
__________________
Currently turning (Angband) Japanese.
PaulBlay is offline   Reply With Quote
Old May 28, 2009, 13:58   #7
zaimoni
Knight
 
zaimoni's Avatar
 
Join Date: Apr 2007
Posts: 590
zaimoni is on a distinguished road
Quote:
Originally Posted by PaulBlay View Post
And the question is ... what's this bit in aid of?

Code:
	if ((n > 0) && (scr_cc[x] == (char) -1) && (scr_aa[x] == 255))
	{
		x--;
		n++;
	}
Apart from not understanding it and wanting to my problem is that I am using wchar_t not char for text so that "(char) -1" and "255" might well not be compatible with the rest of the code now.
(char)(-1) is just plain living dangerously. It's a warning silencer because char isn't guaranteed to be equivalent to signed char.

scr_aa originally was unsigned char; 255 is UCHAR_MAX assuming CHAR_BIT is 8 (which the entire V codebase does, I put a preprocessor test for this into Zaiband to trigger a preprocessing error on such unsupported systems).

If you're not using a proper UNICODE library, try WCHAR_MAX (C++) or WINT_MAX (C) in place of 255/UCHAR_MAX. [Note that the standards do *not* guarantee any particular encoding for wchar_t/wint_t . As usual, Solaris will give you a porting sunburn.] Note that you will want to use a proper UNICODE library, because Linux will railroad you into UTF-8 while Windows demands you use UCS-2 in practice.
zaimoni is offline   Reply With Quote
Old May 28, 2009, 14:19   #8
PaulBlay
Knight
 
Join Date: Jan 2009
Posts: 657
PaulBlay is on a distinguished road
Quote:
Originally Posted by zaimoni View Post
(char)(-1) is just plain living dangerously. It's a warning silencer because char isn't guaranteed to be equivalent to signed char.

scr_aa originally was unsigned char; 255 is UCHAR_MAX assuming CHAR_BIT is 8 (which the entire V codebase does, I put a preprocessor test for this into Zaiband to trigger a preprocessing error on such unsupported systems).

If you're not using a proper UNICODE library, try WCHAR_MAX (C++) or WINT_MAX (C) in place of 255/UCHAR_MAX.
I can see I'm going to have to stare blankly at the Term* functions for a few days for it to seep in.

Quote:
[Note that the standards do *not* guarantee any particular encoding for wchar_t/wint_t . As usual, Solaris will give you a porting sunburn.] Note that you will want to use a proper UNICODE library, because Linux will railroad you into UTF-8 while Windows demands you use UCS-2 in practice.
My, admittedly simplistic, reasoning is that it's going to be hard enough to get everything working in Windows XP - I'll worry about the rest after I get that far. This is after all as much about practice getting my hands dirty with C++ as it is anything else as I'm very much a novice.
__________________
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Yum! Favorite quick recipe. Pete Mack Idle chatter 1 April 22, 2009 10:12
Quick Diving versus "Recommended Depths" Wraitheist Vanilla 14 May 4, 2008 08:12


All times are GMT +1. The time now is 21:56.


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