PDCurses getch not working as intended

G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

No one replied to some of my previous, maybe they were eaten by server
or something... Anyway, everyone on Win98 seems to get this problem, yet
I was unable to find a solution. The problem is that getch() from
PDCurses seems to miss or get wrong values for most of keypresses. When
I try to move a PC in my project I need to press the same key 5 or more
times before the game reacts. NPCs move with each keypress. When I undef
getch (so the getch from conio.h is used) everything works as intended.
Is there a way around this bug? Cause it really drives me mad.


--
|a\o/r|,-------------.,---------- Timofei Shatrov aka Grue ------------.
| m"a ||FC AMKAR PERM|| mail: grue at mail.ru http://grue3.tripod.com |
| k || PWNZ J00 || Kingdom of Loathing: Grue3 lvl 18 Seal Clubber |
`-----'`-------------'`-------------------------------------------[4*72]
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

On Mon, 23 May 2005 11:54:34 GMT, grue@mail.ru (Timofei Shatrov) tried
to confuse everyone with this message:

>No one replied to some of my previous, maybe they were eaten by server
>or something... Anyway, everyone on Win98 seems to get this problem, yet
>I was unable to find a solution. The problem is that getch() from
>PDCurses seems to miss or get wrong values for most of keypresses. When
>I try to move a PC in my project I need to press the same key 5 or more
>times before the game reacts. NPCs move with each keypress. When I undef
>getch (so the getch from conio.h is used) everything works as intended.
>Is there a way around this bug? Cause it really drives me mad.
>

To anyone else who encountered this problem, here is the temporary fix
I've found. Instead of

c=getch();

write

c=getch(); if (c>=60928) c-=60928;

That's one weird bug...

--
|a\o/r|,-------------.,---------- Timofei Shatrov aka Grue ------------.
| m"a ||FC AMKAR PERM|| mail: grue at mail.ru http://grue3.tripod.com |
| k || PWNZ J00 || Kingdom of Loathing: Grue3 lvl 18 Seal Clubber |
`-----'`-------------'`-------------------------------------------[4*72]
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

On Mon, 23 May 2005 11:54:34 GMT, grue@mail.ru (Timofei Shatrov) tried
to confuse everyone with this message:

Oh, and if anyone wants to try out a pre-alpha buggy version of my
project, ASCII FOOTIE, download it here:
http://grue3.tripod.com/footie.exe

The controls are: numpad for moving (Numlock on), '.' for short wait,
'W' for long wait, 'k' to kick, 'q' to quit.

--
|a\o/r|,-------------.,---------- Timofei Shatrov aka Grue ------------.
| m"a ||FC AMKAR PERM|| mail: grue at mail.ru http://grue3.tripod.com |
| k || PWNZ J00 || Kingdom of Loathing: Grue3 lvl 18 Seal Clubber |
`-----'`-------------'`-------------------------------------------[4*72]
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

On Mon, 23 May 2005 12:19:59 GMT, grue@mail.ru (Timofei Shatrov) tried
to confuse everyone with this message:

>On Mon, 23 May 2005 11:54:34 GMT, grue@mail.ru (Timofei Shatrov) tried
>to confuse everyone with this message:

>To anyone else who encountered this problem, here is the temporary fix
>I've found. Instead of
>
>c=getch();
>
>write
>
>c=getch(); if (c>=60928) c-=60928;
>

Well, I learned the hard way that the constant "60928" above is random
for each session. Looks like some lazy programmer forgot to initialise
some counter... That's why I hate open source software. You don't even
know who to blame!

Anyway, the user would have to type "zzz" at the beginning of the game:
this will be enough to calculate the constant. If he types something
else... he is screwed!

--
|a\o/r|,-------------.,---------- Timofei Shatrov aka Grue ------------.
| m"a ||FC AMKAR PERM|| mail: grue at mail.ru http://grue3.tripod.com |
| k || PWNZ J00 || Kingdom of Loathing: Grue3 lvl 18 Seal Clubber |
`-----'`-------------'`-------------------------------------------[4*72]
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

Timofei Shatrov wrote:
> On Mon, 23 May 2005 11:54:34 GMT, grue@mail.ru (Timofei Shatrov) tried
> to confuse everyone with this message:
>
> Oh, and if anyone wants to try out a pre-alpha buggy version of my
> project, ASCII FOOTIE, download it here:
> http://grue3.tripod.com/footie.exe
>
> The controls are: numpad for moving (Numlock on), '.' for short wait,
> 'W' for long wait, 'k' to kick, 'q' to quit.

You have to change the extension to something like *.ex_, or put it in a
zip file. Tripod prohibits download of executbles (you can mail me the
exe directly too ;-) ).
--
At your service,
Kornel Kisielewicz (charonATmagma-net.pl) [http://chaos.magma-net.pl]
"The development cycle for roguelikes never ends..." -- Joseph
Hewitt
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

On Mon, 23 May 2005 15:52:00 +0200, Kornel Kisielewicz
<kisielewicz@gazeta.pl> tried to confuse everyone with this message:

>Timofei Shatrov wrote:
>> On Mon, 23 May 2005 11:54:34 GMT, grue@mail.ru (Timofei Shatrov) tried
>> to confuse everyone with this message:
>>
>> Oh, and if anyone wants to try out a pre-alpha buggy version of my
>> project, ASCII FOOTIE, download it here:
>> http://grue3.tripod.com/footie.exe
>>
>> The controls are: numpad for moving (Numlock on), '.' for short wait,
>> 'W' for long wait, 'k' to kick, 'q' to quit.
>
>You have to change the extension to something like *.ex_, or put it in a
>zip file. Tripod prohibits download of executbles (you can mail me the
>exe directly too ;-) ).

Damn that tripod! Now they don't even have a FTP access so I have to use
their clunky site to upload files. The game is not very playable btw, it
just demonstrates the engine ;)

The new link is http://grue3.tripod.com/footie.zip

--
|a\o/r|,-------------.,---------- Timofei Shatrov aka Grue ------------.
| m"a ||FC AMKAR PERM|| mail: grue at mail.ru http://grue3.tripod.com |
| k || PWNZ J00 || Kingdom of Loathing: Grue3 lvl 18 Seal Clubber |
`-----'`-------------'`-------------------------------------------[4*72]
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

grue@mail.ru (Timofei Shatrov) wrote:
> On Mon, 23 May 2005 11:54:34 GMT, grue@mail.ru (Timofei Shatrov)
> tried to confuse everyone with this message:
>
>>No one replied to some of my previous, maybe they were eaten by
>>server or something... Anyway, everyone on Win98 seems to get this
>>problem, yet I was unable to find a solution. The problem is that
>>getch() from PDCurses seems to miss or get wrong values for most
>>of keypresses. When I try to move a PC in my project I need to
>>press the same key 5 or more times before the game reacts. NPCs
>>move with each keypress. When I undef getch (so the getch from
>>conio.h is used) everything works as intended. Is there a way
>>around this bug? Cause it really drives me mad.
>>
>
> To anyone else who encountered this problem, here is the temporary
> fix I've found. Instead of
>
> c=getch();
>
> write
>
> c=getch(); if (c>=60928) c-=60928;
>
> That's one weird bug...

60928 = 0xEE00, from which I would guess that you're taking a char
return value and interpreting it as a short or long, and getting
leftover junk in the upper part of the register. The actual keycode it
gave you is 0 (null), which tends to show up in inputs a bunch of times
and should just be ignored.

The fact that this is happening suggests that you're using the library
from one version of curses and the header files from another;
ordinarily, the compiler would handle type conversion issues like that.

--
CalcRogue: TI-89, TI-92+, PalmOS, Windows and Linux.
http://calcrogue.jimrandomh.org/
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

On Mon, 23 May 2005 16:08:29 GMT, jimrandomh
<usenetNOSPAM@jimrandomh.org> tried to confuse everyone with this
message:


>60928 = 0xEE00, from which I would guess that you're taking a char
>return value and interpreting it as a short or long, and getting
>leftover junk in the upper part of the register. The actual keycode it
>gave you is 0 (null), which tends to show up in inputs a bunch of times
>and should just be ignored.
>
>The fact that this is happening suggests that you're using the library
>from one version of curses and the header files from another;
>ordinarily, the compiler would handle type conversion issues like that.
>

You were right that I used the old header file, but updating it didn't
help... The only chars used in my project are related to strings.
However you gave me a good idea: I'll do getch()%256.
--
|a\o/r|,-------------.,---------- Timofei Shatrov aka Grue ------------.
| m"a ||FC AMKAR PERM|| mail: grue at mail.ru http://grue3.tripod.com |
| k || PWNZ J00 || Kingdom of Loathing: Grue3 lvl 18 Seal Clubber |
`-----'`-------------'`-------------------------------------------[4*72]
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

Timofei Shatrov wrote:
>>You have to change the extension to something like *.ex_, or put it in a
>>zip file. Tripod prohibits download of executbles (you can mail me the
>>exe directly too ;-) ).
>
> Damn that tripod! Now they don't even have a FTP access so I have to use
> their clunky site to upload files. The game is not very playable btw, it
> just demonstrates the engine ;)
>
> The new link is http://grue3.tripod.com/footie.zip

My god, this is brilliant! :-D
I'm waiting eagerly for further result! Have you considered a
"BloodBowl" variant? I tried to kick a player to death but it didn't
work :-/
--
At your service,
Kornel Kisielewicz (charonATmagma-net.pl) [http://chaos.magma-net.pl]
"The development cycle for roguelikes never ends..." -- Joseph
Hewitt
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

On Mon, 23 May 2005 19:36:16 +0200, Kornel Kisielewicz
<kisielewicz@gazeta.pl> tried to confuse everyone with this message:

>Timofei Shatrov wrote:
>>>You have to change the extension to something like *.ex_, or put it in a
>>>zip file. Tripod prohibits download of executbles (you can mail me the
>>>exe directly too ;-) ).
>>
>> Damn that tripod! Now they don't even have a FTP access so I have to use
>> their clunky site to upload files. The game is not very playable btw, it
>> just demonstrates the engine ;)
>>
>> The new link is http://grue3.tripod.com/footie.zip
>
>My god, this is brilliant! :-D
>I'm waiting eagerly for further result! Have you considered a
>"BloodBowl" variant? I tried to kick a player to death but it didn't
>work :-/

I'm trying to create a realistic simulation here ;) You'll get sent off
for that and banned for the next few matches... But maybe there would be
a hidden option for increased violence ;)

Anyway, thanks to everyone, I completely rewritten it under PDCurses and
it kinda works. Now I need to work on a gameplay.

--
|a\o/r|,-------------.,---------- Timofei Shatrov aka Grue ------------.
| m"a ||FC AMKAR PERM|| mail: grue at mail.ru http://grue3.tripod.com |
| k || PWNZ J00 || Kingdom of Loathing: Grue3 lvl 18 Seal Clubber |
`-----'`-------------'`-------------------------------------------[4*72]
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

In article <42920b43.41341272@news.readfreenews.net>,
Timofei Shatrov <grue@mail.ru> wrote:

>You were right that I used the old header file, but updating it didn't
>help... The only chars used in my project are related to strings.
>However you gave me a good idea: I'll do getch()%256.

Hmmm. Are you sure that the getch() you're calling is actually the
one included with pdcurses? I vaguely remember getch() being part of
some PC compiler's library. Maybe you're calling the wrong getch()
but using the prototype in the PDcurses include file.

Alternately, there could be some difference between the calling
conventions of your compiler and the one that compiled your library.
You might want to try building PDcurses from sources with the same
compiler you're using to write your roguelike. This will also make it
easier to step through PDcurses code with a debugger.


--Chris


--
Chris Reuter http://www.blit.ca
"Lack Of A Diploma Won't Hod You Back"
--Some diploma spammer
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

Chris Reuter wrote:
> I vaguely remember getch() being part of
> some PC compiler's library. Maybe you're calling the wrong getch()
> but using the prototype in the PDcurses include file.

It's in conio.h and I noticed the older version of Mingw/GCC was
including that even without #include <conio.h>. I guess it was some
kind of automatic basic library include. When I compiled my project
with new Mingw I got lots of undefined errors, because there were
missing library includes.
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

On 26 May 2005 01:50:10 -0700, "Krice" <paulkp@mbnet.fi> tried to
confuse everyone with this message:

>Chris Reuter wrote:
>> I vaguely remember getch() being part of
>> some PC compiler's library. Maybe you're calling the wrong getch()
>> but using the prototype in the PDcurses include file.
>
>It's in conio.h and I noticed the older version of Mingw/GCC was
>including that even without #include <conio.h>. I guess it was some
>kind of automatic basic library include. When I compiled my project
>with new Mingw I got lots of undefined errors, because there were
>missing library includes.

As I wrote before, conio.h's getch _is_ working properly. I'm almost
sure it's system-dependent PDCurses bug as some people had the same
problem.

--
|a\o/r|,-------------.,---------- Timofei Shatrov aka Grue ------------.
| m"a ||FC AMKAR PERM|| mail: grue at mail.ru http://grue3.tripod.com |
| k || PWNZ J00 || Kingdom of Loathing: Grue3 lvl 18 Seal Clubber |
`-----'`-------------'`-------------------------------------------[4*72]
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

grue@mail.ru (Timofei Shatrov) wrote:
> As I wrote before, conio.h's getch _is_ working properly. I'm almost
> sure it's system-dependent PDCurses bug as some people had the same
> problem.

No, what you have here is a namespace conflict. Two libraries both
contain functions named 'getch'. The compiler uses the prototype in the
header file of one of those libraries. The linker uses the function
from the other library. In this case, getch will work only if the two
libraries happened to define getch with the same signature; otherwise
you have an undetected type error, which may produce exactly the
symptom you described at the top of this thread.

Are you, by any chance, compiling without warnings enabled? You need to
pass the -Wall option to the compiler. Also, make sure you are linking
with the pdcurses library properly (-lpdcurses option, after all the
object files), and including the right header files.

--
CalcRogue: TI-89, TI-92+, PalmOS, Windows and Linux.
http://calcrogue.jimrandomh.org/
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

jimrandomh wrote:
> No, what you have here is a namespace conflict. Two libraries both
> contain functions named 'getch'. The compiler uses the prototype in the
> header file of one of those libraries. The linker uses the function
> from the other library. In this case, getch will work only if the two
> libraries happened to define getch with the same signature; otherwise
> you have an undetected type error, which may produce exactly the
> symptom you described at the top of this thread.
>
> Are you, by any chance, compiling without warnings enabled? You need to
> pass the -Wall option to the compiler. Also, make sure you are linking
> with the pdcurses library properly (-lpdcurses option, after all the
> object files), and including the right header files.

And if you're using the library with the conflicting getch as well as
pdcurses, put -lpdcurses *earlier* on the linker commandline than that
other library. The linker will then use the correct getch.

--
http://www.gnu.org/philosophy/right-to-read.html
Palladium? Trusted Computing? DRM? Microsoft? Sauron.
"One ring to rule them all, one ring to find them
One ring to bring them all, and in the darkness bind them."
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

On Mon, 23 May 2005 14:52:31 GMT, grue@mail.ru (Timofei Shatrov)
wrote:

>The new link is http://grue3.tripod.com/footie.zip

Cute.

Actually, I'm thinking some simple sports sims would be great in any
roguelike attempting to create a "living world" effect. And then, to
satisfy the combat monkeys, rioting fans afterwards!

--
R. Dan Henry = danhenry@inreach.com
Dance, Puppet, dance!
But why are there *humans* dancing for the puppet?
 
G

Guest

Guest
Archived from groups: rec.games.roguelike.development (More info?)

R. Dan Henry wrote:
> On Mon, 23 May 2005 14:52:31 GMT, grue@mail.ru (Timofei Shatrov)
> wrote:
>
>>The new link is http://grue3.tripod.com/footie.zip
>
> Cute.
>
> Actually, I'm thinking some simple sports sims would be great in any
> roguelike attempting to create a "living world" effect. And then, to
> satisfy the combat monkeys, rioting fans afterwards!

Fun game!

--
ABCGi ---- (abcgi@yahoo.com) ---- http://codemonkey.sunsite.dk
..Hajo's H-World - RogueLike/RPG Engine SourceForge Project...
.......Downloads - https://sourceforge.net/projects/h-world...
............Home - http://h-world.simugraph.com...............