Welcome to GameHourz.com!
FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

libtcod 1.1 released

 
Goto page Previous  1, 2
   Game Forums (Home) -> Roguelike -> Development RSS
Related Topics:
libtcod 1.0.1 released - Hi all ! libtcod or "the Doryen is a part of the base classes used in the of the roguelike "The Of It is a simple, library for C / C++ roguelike Features * windowed or full screen..

PopulationGenerator v0.4 Released - Hello all, I have nearly done my I figured I should make a release and see what people think. In this release, the program creates a new and shows some debugging info. Next it goes in to mode, this mode..

[ANN] 7drl: Happy Hunting released for Windows - It has been some months since the release of the tiny and frivolous Seven Day Roguelike which I named This doesn't fit into the scope of the seven day roguelike but I have finally produced a Windows binary. A rather sad and..

Roguelike Library for Java v0.1 Released, LOS and FOV - Hi All, The first release of Roguelike Libary for Java has been made. Please find it at: This release has the following : Field of View (Precise Cone..

7DRL: Invader - Well, I've talked myself into a game for the 7DRL :-) Invader will be a sci-fi RL where the player is the planet's only hope of stopping a dread alien invasion ship. The base of will be their docked ship. ..
Next:  using a c debugger with a curses program  
Author Message
Ido Yehieli

External


Since: Nov 29, 2007
Posts: 75



(Msg. 16) Posted: Thu Feb 21, 2008 6:30 am
Post subject: Re: libtcod 1.1 released [Login to view extended thread Info.]
Archived from groups: rec>games>roguelike>development (more info?)

On Feb 21, 12:19 pm, jice <jice.nos....DeleteThis@gmail.com> wrote:
> Not in a turn-by-turn roguelike, but for a real-time game with 25
> fps...

Interesting.
I would have guessed that 25fps is very easy to achieve for a not-too-
resource-intensive game when you're writing in c, regardless of how
"naive" your code is.
After all, doom and its ilk run as fast or faster on a 486. I reckoned
the ~1000 fold increase in speed we have experienced since then took
care of that need.

-Ido.

 >> Stay informed about: libtcod 1.1 released 
Back to top
Login to vote
jice

External


Since: Nov 08, 2007
Posts: 90



(Msg. 17) Posted: Thu Feb 21, 2008 7:12 am
Post subject: Re: libtcod 1.1 released [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 21 fév, 15:30, Ido Yehieli <Ido.Yehi....TakeThisOut@gmail.com> wrote:
> On Feb 21, 12:19 pm, jice <jice.nos....TakeThisOut@gmail.com> wrote:
>
> > Not in a turn-by-turn roguelike, but for a real-time game with 25
> > fps...
>
> Interesting.
> I would have guessed that 25fps is very easy to achieve for a not-too-
> resource-intensive game when you're writing in c, regardless of how
> "naive" your code is.

I agree with that and I generally don't care about early optimization.
I said almost the same thing as you in a recent post on r.g.r.d., but
I think it would be wrong to avoid an easy optimization in a critical
function like the text output. Besides, since it's a library, I can't
be sure someone will not use it in a resource-intensive program. Once
you start using real-time realist lighting, even in a 80x50 roguelike
console, you can really quickly eat lots of milliseconds per frame,
especially since the library doesn't necessarily rely on hardware
accelerated APIs...

> After all, doom and its ilk run as fast or faster on a 486. I reckoned
> the ~1000 fold increase in speed we have experienced since then took
> care of that need.

I wouldn't call Doom's code "naive" and I'm not sure a 2.5D shooter
written naively (no bsp tree, no frustum clipping, no texture
compression & mipmapping, ...) would achieve decent performance even
on a recent computer. Used naively, a single 4096x4096 texture uses
64Mb of video memory, so a simple rotating textured cube can blow the
most expensive video card.

--
jice

 >> Stay informed about: libtcod 1.1 released 
Back to top
Login to vote
jice

External


Since: Nov 08, 2007
Posts: 90



(Msg. 18) Posted: Fri Feb 22, 2008 12:47 am
Post subject: Re: libtcod 1.1 released [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 22 fév, 05:08, Joni Toivanen <jomio... RemoveThis @gmail.com> wrote:
>
> The problem with that code is that it doesn't really work with a valid
> implementation of vsnprintf. According to the C99 the vsnprintf function
> should return "the number of characters that would have been written had
> [the buffer size] been sufficiently large, not counting the terminating
> null character, or a negative value if an encoding error occurred." (I'm
> guessing that an encoding error means invalid fmt string).
>
> At least Microsoft Visual C++ libraries and older versions of glibc
> implement the vsnprintf function incorrectly and return a negative value
> if the buffer isn't big enough, and your code would work on them, but on
> recent versions of glibc and other C libraries that have C99 conforming
> vsnprintf your code will fail if the initial 512 chars isn't enough.
>
> Here's a version of the function that should (untested, sorry) also work
> with a C99 conforming vsnprintf:
>
> static char *TCOD_console_vsprint(const char *fmt, va_list ap) {
>         static char *msg=NULL;
>         static int buflen=0;
>         int len;
>         bool ok=false;
>         if (!msg) {
>                 buflen=512;
>                 msg=(char *)calloc(sizeof(char),buflen);
>         }
>         len = vsnprintf(msg,buflen,fmt,ap);
>         if (len >= buflen) {
>                 // buffer not big enough, glibc
>                 buflen = len + 1;  // null char not included in len
>                 msg=(char *)calloc(sizeof(char),buflen);
>                 vsnprintf(msg,buflen,fmt,ap);
>                 return(msg);
>         } else if (len < 0) {
>                 // buffer not big enough, MSVC
>                 do {
>                         buflen*=2;
>                         free( msg );
>                         msg=(char *)calloc(sizeof(char),buflen);
>                 } while(vsnprintf(msg,buflen,fmt,ap) < 0);
>         }
>         return msg;
>
> }
>
> (I tried to imitate your coding style, but if it looks ugly to you, just
> reformat it -- provided that it works at all Smile
>
> Hope this helps...

Thanks for the information, I didn't read the whole man page...
Strangely, the code works on mingw32 with gcc 3.2.3. I guess it must
use a glibc < 2.1...

--
jice
 >> Stay informed about: libtcod 1.1 released 
Back to top
Login to vote
Jomppa

External


Since: Feb 22, 2008
Posts: 1



(Msg. 19) Posted: Fri Feb 22, 2008 2:13 am
Post subject: Re: libtcod 1.1 released [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Feb 22, 10:47 am, jice <jice.nos... DeleteThis @gmail.com> wrote:
>
> Thanks for the information, I didn't read the whole man page...
> Strangely, the code works on mingw32 with gcc 3.2.3. I guess it must
> use a glibc < 2.1...
>

I didn't have anything else to do this morning (hah), so I tested the
two
different versions of the function on my Linux box. Your version
worked
okay if the string was less than 512 chars long, but if it was longer
than that, it clipped the end off. The code I pasted worked even for
strings longer than 512 chars, but I've only tested it on Linux, so I
don't
know how it will react to MSVC or anything other than glibc and gcc...

Cheers Smile

(Posted from google groups, so the formatting might be off...)
 >> Stay informed about: libtcod 1.1 released 
Back to top
Login to vote
Joni Toivanen

External


Since: Jan 27, 2008
Posts: 2



(Msg. 20) Posted: Fri Feb 22, 2008 6:08 am
Post subject: Re: libtcod 1.1 released [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

jice wrote:
> On 21 fév, 11:46, Ido Yehieli <Ido.Yehi....RemoveThis@gmail.com> wrote:
>>
>> I can imagine you have a line of the sorts of "char buffer[256];"
>> somewhere in your code?
>> If you are using c99 you can take advantage of variable-length arrays:
>>
>> char buffer[snprintf(NULL, 0, your_string)];
>>
>> Or just dynamically allocate if you use c89.
>>
>> -Ido.
>
> To avoid calling vsnprintf twice for each printed string, I'm now
> using a resizable buffer :
>
> static char *TCOD_console_vsprint(const char *fmt, va_list ap) {
> static char *msg=NULL;
> static int buflen=0;
> bool ok=false;
> if (!msg) {
> buflen=512;
> msg=(char *)calloc(sizeof(char),buflen);
> }
> do {
> ok = (vsnprintf(msg,buflen,fmt,ap) != -1);
> if (!ok) {
> buflen*=2;
> free( msg );
> msg=(char *)calloc(sizeof(char),buflen);
> }
> } while (! ok);
> return msg;
> }

The problem with that code is that it doesn't really work with a valid
implementation of vsnprintf. According to the C99 the vsnprintf function
should return "the number of characters that would have been written had
[the buffer size] been sufficiently large, not counting the terminating
null character, or a negative value if an encoding error occurred." (I'm
guessing that an encoding error means invalid fmt string).

At least Microsoft Visual C++ libraries and older versions of glibc
implement the vsnprintf function incorrectly and return a negative value
if the buffer isn't big enough, and your code would work on them, but on
recent versions of glibc and other C libraries that have C99 conforming
vsnprintf your code will fail if the initial 512 chars isn't enough.

Here's a version of the function that should (untested, sorry) also work
with a C99 conforming vsnprintf:

static char *TCOD_console_vsprint(const char *fmt, va_list ap) {
static char *msg=NULL;
static int buflen=0;
int len;
bool ok=false;
if (!msg) {
buflen=512;
msg=(char *)calloc(sizeof(char),buflen);
}
len = vsnprintf(msg,buflen,fmt,ap);
if (len >= buflen) {
// buffer not big enough, glibc
buflen = len + 1; // null char not included in len
msg=(char *)calloc(sizeof(char),buflen);
vsnprintf(msg,buflen,fmt,ap);
return(msg);
} else if (len < 0) {
// buffer not big enough, MSVC
do {
buflen*=2;
free( msg );
msg=(char *)calloc(sizeof(char),buflen);
} while(vsnprintf(msg,buflen,fmt,ap) < 0);
}
return msg;
}

(I tried to imitate your coding style, but if it looks ugly to you, just
reformat it -- provided that it works at all Smile

Hope this helps...
 >> Stay informed about: libtcod 1.1 released 
Back to top
Login to vote
Display posts from previous:   
   Game Forums (Home) -> Roguelike -> Development All times are: Ekaterinburg, Islamabad, Karachi, Tashkent (change)
Goto page Previous  1, 2
Page 2 of 2

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]