Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support | Shelf | Store

Privacy Policy


Post Reply 
swprintf confusion
Author Message
RobRendell Offline
Junior Member

Posts: 3
Joined: May 2010
Reputation: 0
Post: #1
swprintf confusion
Hi! Thanks for open-sourcing Penumbra: Overture... I was finding it crashed a lot when I downloaded it from the Humble Indy Bundle, so the opportunity to find and fix the issue(s) is very satisfying... the game looks great, and I'm looking forward to playing it in full Smile

I've found an issue that strikes me as odd. My debug build of Overture was failing to find/load any resources. I traced the problem into Impl/System/win32.cpp, where the function Platform::FindFileInDir makes a few calls to swprintf, e.g.:

swprintf(sSpec,256,_W("%s\\%s"),asDir.c_str(),asMask.c_str());

However, the version of swprintf my version of Visual Studio 2005 has doesn't take a size parameter... that's snwprintf. VS2005's swprint just takes the output string, format and args, without a size.

I've corrected them in my version and the game now loads and runs, but I don't really understand how this could have ever worked. Does swprintf sometimes take an "n" in some library versions or something?
05-17-2010 01:09 PM
Find all posts by this user Quote this message in a reply
Urkle Offline
FG - Associate

Posts: 1,101
Joined: Jul 2006
Reputation: 14
Post: #2
RE: swprintf confusion
swprintf is a PAIN. The Correct (ISO C defintion) version is supposed to have a count parameter, but M$ has an incompatible version that doesn't.. Read this doc about the mess.. Now since we are compiling in C++ mode VS *should* be loading in both versions as overloads and the compiler should compile using the ISO C variant (which is SAFER as you are telling it how big the buffer is.. so no buffer overflows).

A way to ensure that C++ version gets loaded is to change the include header to include <cstdio> instead of <stdio.h> and then add a using std; line in the code (or just call std::swprintf() );

http://msdn.microsoft.com/en-us/library/...71%29.aspx

Developing away on one of
Mac Pro Dual 2Ghz, 7GB RAM, Snow Leopard, nVidia 8800 512MB.
Linux, 3-core AMD, 4GB RAM, Fedora 16, nVidia 450 1GB
05-17-2010 02:25 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Urkle Offline
FG - Associate

Posts: 1,101
Joined: Jul 2006
Reputation: 14
Post: #3
RE: swprintf confusion
Have you tried the latest EXE that thomas put out there?

http://www.frictionalgames.com/forum/thread-3328.html

That EXE seems to fix crashes for many other users on Windows. It's actually build from the latest source (ie.. what was released as open source) but with VS 2003.

Developing away on one of
Mac Pro Dual 2Ghz, 7GB RAM, Snow Leopard, nVidia 8800 512MB.
Linux, 3-core AMD, 4GB RAM, Fedora 16, nVidia 450 1GB
05-17-2010 04:00 PM
Visit this user's website Find all posts by this user Quote this message in a reply
RobRendell Offline
Junior Member

Posts: 3
Joined: May 2010
Reputation: 0
Post: #4
RE: swprintf confusion
Thanks for the info on swprintf.

I hadn't tried that exe, no. I just downloaded it and gave it a shot, and it did in fact fix my reliable crash problem (entering the office for the first time... no crowbar involved).

I'll keep my debug version around, in case any more issues come up Smile

Thanks!
05-17-2010 10:39 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)