Angband.oook.cz
Angband.oook.cz
AboutDownloadVariantsLadderForumCompetitionSpoilersComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old June 19, 2011, 04:18   #1
Blue Baron
Adept
 
Join Date: Apr 2011
Posts: 103
Blue Baron is on a distinguished road
Bug Report: Graphics not masking

The 8x8, 8x16, and 16x16 tiles are not masking properly in windows because they have a white background, rather than a black one. I think whoever saves them probably needs to make sure that the paper color is black, since it probably cannot be seen because of the transparency.

Also, ANGBAND_DIR_XRTA_FONT is still being initialized in init_stuff in main-win.c (lines 4873-4878). It should be either removed from here, like the ones for graphics and sounds were, or put in an if (!ANGBAND_DIR_XRTA_FONT) wrapper. Like the others were, the memory is being allocated twice, but only freed once.

Also, would ticket #1461 be fixed by removing the line "file_delete(old_savefile);" from line 380 and putting it on line 402? (The exsiting .old file is not deleted until the .new file is confirmed to have been written, but before the existing save file is renamed .old.) You can remove the lines " else file_delete(old_savefile);" on lines 414 and 415, if you want the .old file to remain as a backup.

For ticket #942, I'm curious what the OSX and SDL ports use for icons?

Lastly, what does the "multiple save file handling " mentioned in other threads mean? I could not find a therad that talked about it.

Edit: for the first part of ticket #1469, adding the line "case VK_CLEAR: ch = '5'; kp=TRUE; break;" in handle_keydown() works for me. (wParam is 12 for me when pressing numpad5 when numlock is not on.)

Edit: For the second part of ticket #1469, the numpad keys are not handled in handle_keydown(), but WM_CHAR message are not generated for them, so they are not handled that way. ( I do not know where the plain numpad keypresses are handled.) Maybe in handle_keydown add lines like "case VK_NUMPAD7: if (mc||ma||ms) {ch = VK_NUMPAD7; kp = TRUE;} break;"

Last edited by Blue Baron; June 19, 2011 at 05:37.
Blue Baron is offline   Reply With Quote
Old June 19, 2011, 07:18   #2
myshkin
Angband Devteam member
 
Join Date: Apr 2007
Posts: 311
myshkin is on a distinguished road
Quote:
Originally Posted by Blue Baron View Post
Also, would ticket #1461 be fixed by removing the line "file_delete(old_savefile);" from line 380 and putting it on line 402? (The exsiting .old file is not deleted until the .new file is confirmed to have been written, but before the existing save file is renamed .old.) You can remove the lines " else file_delete(old_savefile);" on lines 414 and 415, if you want the .old file to remain as a backup.
No. The initially reported problem was that people were manually making copies of their savefiles, and the game was deleting them. The game should not be using any fixed filenames as temporary files.

Quote:
Originally Posted by Blue Baron View Post
For ticket #942, I'm curious what the OSX and SDL ports use for icons?
Look at lib/xtra/icon/att*.png.

Quote:
Originally Posted by Blue Baron View Post
Edit: for the first part of ticket #1469, adding the line "case VK_CLEAR: ch = '5'; kp=TRUE; break;" in handle_keydown() works for me. (wParam is 12 for me when pressing numpad5 when numlock is not on.)

Edit: For the second part of ticket #1469, the numpad keys are not handled in handle_keydown(), but WM_CHAR message are not generated for them, so they are not handled that way. ( I do not know where the plain numpad keypresses are handled.) Maybe in handle_keydown add lines like "case VK_NUMPAD7: if (mc||ma||ms) {ch = VK_NUMPAD7; kp = TRUE;} break;"
Strange. I guess the mapping of keypad 5 to clear does have some historical precedent. I know essentially nothing about the Windows port, and so will wait for someone else to comment, but this is quite encouraging.
myshkin is offline   Reply With Quote
Old June 19, 2011, 08:18   #3
d_m
Angband Devteam member
 
d_m's Avatar
 
Join Date: Aug 2008
Location: Philadelphia, PA, USA
Age: 34
Posts: 1,500
d_m is on a distinguished road
Blue Baron, you are my personal hero!

In case anyone else is interested, I fixed the PNG tilesets by opening them in gimp, saving a copy as PNG, turning off "save background color" and "save color value for transparent pixels".

For some reason (under WINE) I was able to walk/run/alter using the number pad with numlock on and off after applying your fix. Are you seeing problems still?
__________________
linux->xterm->screen->pmacs
d_m is offline   Reply With Quote
Old June 19, 2011, 08:48   #4
Blue Baron
Adept
 
Join Date: Apr 2011
Posts: 103
Blue Baron is on a distinguished road
Quote:
Originally Posted by myshkin View Post
No. The initially reported problem was that people were manually making copies of their savefiles, and the game was deleting them. The game should not be using any fixed filenames as temporary files.
so something like :
Code:
strnfmt(old_savefile, sizeof(old_savefile), "%s.old", path);
while (file_exists(old_savefile) && (count++ < 100))
{
    strnfmt(old_savefile, sizeof(old_savefile), "%s.%u%u.old", path, Rand_simple(32767), count);
}
except use the platform specific code where available? (file_exists has defines for platform specific code in z-file.c) err actually the Rand_simple function is defined in z-rand.h, but is not implemented. is there another random function that will not interfere with the game's rng?

Quote:
Originally Posted by myshkin View Post
Look at lib/xtra/icon/att*.png.
Ahh thanks I did not know they were there and was only looking in the src directory.
Blue Baron is offline   Reply With Quote
Old June 19, 2011, 08:57   #5
myshkin
Angband Devteam member
 
Join Date: Apr 2007
Posts: 311
myshkin is on a distinguished road
Quote:
Originally Posted by Blue Baron View Post
so something like :
Code:
strnfmt(old_savefile, sizeof(old_savefile), "%s.old", path);
while (file_exists(old_savefile) && (count++ < 100))
{
    strnfmt(old_savefile, sizeof(old_savefile), "%s.%u%u.old", path, Rand_simple(32767), count);
}
except use the platform specific code where available? (file_exists has defines for platform specific code in z-file.c) err actually the Rand_simple function is defined in z-rand.h, but is not implemented. is there another random function that will not interfere with the game's rng?
You have a good idea, but I prefer not writing independent security-related functions where possible. Alas, while most platforms have a reasonably secure function that opens a temporary file atomically, the function name and interface differ. My comments to the ticket indicate likely candidates for Unix-likes and Windows. I don't know what to do for nds.
myshkin is offline   Reply With Quote
Old June 19, 2011, 09:46   #6
Blue Baron
Adept
 
Join Date: Apr 2011
Posts: 103
Blue Baron is on a distinguished road
Quote:
Originally Posted by d_m View Post
For some reason (under WINE) I was able to walk/run/alter using the number pad with numlock on and off after applying your fix. Are you seeing problems still?
The plain numpad keys must be translated somewhere else. I was able to get the tunnelling working with numlock on by mapping the numpad keys to the characters used when numlock is off. But not running, probably where ever the plain keypresses are handled, trapping the WM_KEYDOWN message when shift is pressed, because I am not seeing a numpad keypress in handle_keydown when shift is pressed.

To say it another way, when numlock is on, handle_keydown() is seeing all of the numpad key presses except when shift is held down.

for the tunnelling I added lines like "case VK_NUMPAD7: if (mc||ma||ms) {ch = KC_HOME; kp = TRUE;} break;". When I had "ch = VK_NUMPAD7" in there various other commands were being executed, so the VK_ codes are can't be used directly by term_keypress().

Edit: It seems like with the shift key down, and num lock is on, windows is translating the numpad keys to the numpad keys with numlock off with shift off.

Last edited by Blue Baron; June 19, 2011 at 11:19.
Blue Baron is offline   Reply With Quote
Old June 19, 2011, 15:26   #7
d_m
Angband Devteam member
 
d_m's Avatar
 
Join Date: Aug 2008
Location: Philadelphia, PA, USA
Age: 34
Posts: 1,500
d_m is on a distinguished road
Quote:
Originally Posted by Blue Baron View Post
so something like :
Code:
strnfmt(old_savefile, sizeof(old_savefile), "%s.old", path);
while (file_exists(old_savefile) && (count++ < 100))
{
    strnfmt(old_savefile, sizeof(old_savefile), "%s.%u%u.old", path, Rand_simple(32767), count);
}
except use the platform specific code where available? (file_exists has defines for platform specific code in z-file.c) err actually the Rand_simple function is defined in z-rand.h, but is not implemented. is there another random function that will not interfere with the game's rng?
I think for this it's best to use mkstemp on Unix. I found a page with Unix-to-Windows conversion ideas:

http://www.suacommunity.com/dictiona...temp-entry.php

It looks like _mktemp_s() might be the thing to us. I think this is the strategy that the real world uses nowadays.
__________________
linux->xterm->screen->pmacs
d_m is offline   Reply With Quote
Old June 19, 2011, 15:27   #8
d_m
Angband Devteam member
 
d_m's Avatar
 
Join Date: Aug 2008
Location: Philadelphia, PA, USA
Age: 34
Posts: 1,500
d_m is on a distinguished road
Quote:
Originally Posted by Blue Baron View Post
The plain numpad keys must be translated somewhere else. I was able to get the tunnelling working with numlock on by mapping the numpad keys to the characters used when numlock is off. But not running, probably where ever the plain keypresses are handled, trapping the WM_KEYDOWN message when shift is pressed, because I am not seeing a numpad keypress in handle_keydown when shift is pressed.
Huh, this must be a place where WINE and Windows diverge I was able to hook up a keyboard to my Linux netbook and saw all the numpad stuff working. Sigh.
__________________
linux->xterm->screen->pmacs
d_m is offline   Reply With Quote
Old June 19, 2011, 17:55   #9
Blue Baron
Adept
 
Join Date: Apr 2011
Posts: 103
Blue Baron is on a distinguished road
Quote:
Originally Posted by d_m View Post
Huh, this must be a place where WINE and Windows diverge I was able to hook up a keyboard to my Linux netbook and saw all the numpad stuff working. Sigh.
I guess so Shift numpad with numlock on did not run, but walked, in angband-ef5f426, angband 3.2.0, and Z+ for me. Does it work for anyone in windows in any version or variant?

Also, the special_key_list in 3.2.0 captures VK_SELECT, VK_PRINT, VK_EXECUTE,VK_SNAPSHOT,VK_HELP, and VK_16-VK_24, but handle_keydown() does not. Does anyone care about these keys?

Edit:
Quote:
Originally Posted by d_m View Post
I think for this it's best to use mkstemp on Unix. I found a page with Unix-to-Windows conversion ideas:

http://www.suacommunity.com/dictiona...temp-entry.php

It looks like _mktemp_s() might be the thing to us. I think this is the strategy that the real world uses nowadays.
I understand the name collision part but not the security part. Is there anything I can read about it?

Anyways, above i meant something like:
Code:
#if (defined(POSIX)) // I do not know what should be here file_exists() uses #ifdef HAV_STAT
  strnfmt(old_savefile, sizeof(old_savefile),"%sXXXXXX", path);
  res =  mkstemp(old_saevfile);
#elif (defined(WINDOWS))
  strncopy(old_savefile, path,1024);
  res =  tmpnam_s(old_savefile, 1024); // or _mktmp_s()
  // However mkstemp opens a file descriptor, but these two don't. so there would be additional
  //  code either here or for the unix version
#else
  strnfmt(old_savefile, sizeof(old_savefile), "%s.old", path); 
  while (file_exists(old_savefile) && (count++ < 100))
  {
      strnfmt(old_savefile, sizeof(old_savefile), "%s.%u%u.old", path,   Rand_simple(32767), count);
  }
#endif
and something similar for the new_savefile name.

Last edited by Blue Baron; June 19, 2011 at 18:28.
Blue Baron is offline   Reply With Quote
Old July 4, 2011, 09:40   #10
myshkin
Angband Devteam member
 
Join Date: Apr 2007
Posts: 311
myshkin is on a distinguished road
Quote:
Originally Posted by Blue Baron View Post
I understand the name collision part but not the security part. Is there anything I can read about it?
Here is a decent summary of the potential security issues surrounding temporary file creation.
myshkin 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
Bug report: shopkeeper greetings Derakon Development 4 June 19, 2011 19:43
Bug report - negative min values in ego_item.txt jens Development 5 June 19, 2011 13:30
Bug report - money not updated jens Development 0 June 18, 2011 23:20
Bug Report - Subwindow refresh after options load dhegler Vanilla 3 March 2, 2010 19:56
Vanilla Bug Report: Everburning Lantern The G Masta Vanilla 1 November 11, 2009 18:35


All times are GMT +1. The time now is 02:52.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.