Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


swprintf confusion
RobRendell Offline
Junior Member

Posts: 3
Threads: 1
Joined: May 2010
Reputation: 0
#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
Urkle Offline
FG - Associate

Posts: 1,172
Threads: 31
Joined: Jul 2006
Reputation: 21
#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:Confusedwprintf() );

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

Developing away on one of
Multiple Macs running 10.6, 10.7, 10.8, and 10.9.
Linux, 8-core AMD, 8GB RAM, Fedora 18, nVidia 450 1GB
05-17-2010, 02:25 PM
Website Find
Urkle Offline
FG - Associate

Posts: 1,172
Threads: 31
Joined: Jul 2006
Reputation: 21
#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
Multiple Macs running 10.6, 10.7, 10.8, and 10.9.
Linux, 8-core AMD, 8GB RAM, Fedora 18, nVidia 450 1GB
05-17-2010, 04:00 PM
Website Find
RobRendell Offline
Junior Member

Posts: 3
Threads: 1
Joined: May 2010
Reputation: 0
#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




Users browsing this thread: 1 Guest(s)