View Full Version : Question for the gamers
redtyphoon
09-03-11, 12:15 PM
The OpenSSN project is coming along nicely. I'm happy to report it's working well on FreeBSD, PC-BSD and it's in the process of being included in Debian and Ubuntu Linux.
As happy as I am about this, I realize a lot of gamers are on Windows. So, my question to you is, is there any interest in seeing OpenSSN ported to Windows? I may be able to get a Windows developer on board, but before I do that I'd like to make sure there's an interest in the game from Windows players.
http://openssn.sourceforge.net/
magicstix
09-03-11, 01:45 PM
If you're using only SDL for the graphics it should be a pretty straightforward port...
redtyphoon
09-03-11, 01:50 PM
The SDL library is the only external dependency. So, yes, porting should be fairly straight forward. However, I don't have a Windows box to compile/test with, which gets in the way.
magicstix
09-03-11, 01:58 PM
Hmm... I took a look through main.cpp and didn't see anything that would cause trouble under windows. I'll run it through visual studio and see what breaks.
redtyphoon
09-03-11, 02:08 PM
Most of the code should be fine, I've done my best to keep it to standards. The only place where I think there may be trouble is in files.cpp
The files.cpp module tries to find OpenSSN's data files and checks a couple of different places, including the current working directory. Since files are organized differently on Windows than Linux/BSD this function might bomb. I think it will still compile, but it might not return the correct location. Everything else is pretty vanilla.
magicstix
09-03-11, 02:10 PM
Which version of SDL are you using? The latest doesnt have the SDL subdirectory tree nor does it have SDL_image.h
magicstix
09-03-11, 02:12 PM
Nevermind... I didn't know it was a second library.
magicstix
09-03-11, 02:24 PM
OK thus far the biggest problems in getting openSSN to compile under MSVC are its use of non-standard C functions.
The biggest offenders are strcasestr and snprintf. They're not in the C89 standard (which MSVC uses). I'm working around them at the moment with macros.
The other offender is "unistd.h" which is a unix-only header file. I've gotten around this with #ifndef WIN32..#endif preventing the compiler from attempting to include the header. MSVC supports the types defined in it natively.
redtyphoon
09-03-11, 02:38 PM
I checked and the unistad.h include is an old dependency and is no longer needed. It can be removed entirely. For the next release of OpenSSN I'll put in checks so strcasecmp and snprintf are avoided if WIN32 is defined.
magicstix
09-03-11, 02:42 PM
I was hoping to get it to compile under MSVC without tearing up too much code, but it looks like the use of getopt() will be the show stopper on that. The other functions were trivial and could be worked around, but MSVC has no implementation of getopt whatsoever and to use it one would have to fish it out of the gnu standard library and include it with the source tree (probably not a good idea).
For portability, openSSN would probably benefit highly from replacing all of the old C-style calls and datastructures with their C++ STL equivalents (for example all of the snprintfs, strcmps, char* pointers with std::string and its operators). The C++ STL stuff tends to be safer and easier to use.
Replacing getopt() with something else for the options parsing would be a good idea too. I'd recommend using the boost library's program options, but this would add another dependency. However, boost comes with a lot of fancy tools like shared pointers, so you don't have to worry about memory leaks. Plus, when the time comes to add multiplayer support to openSSN, boost.asio is *really* good for doing network code.
redtyphoon
09-03-11, 03:44 PM
Since OpenSSN is almost never run with options, you can put a big #ifndef WIN32 around the entire getopts section.
As for moving to C++ STL, it's not going to happen. That code is far to cumbersome and heavy to work with for a project like this. I had to tear a whole bunch of it out earlier to get things to run properly.
magicstix
09-03-11, 03:59 PM
Success!
http://imgbucket.info/img/1q0ynqtuh/titlescreen.jpg
http://imgbucket.info/img/43jpbymz7/sonarstack.jpg
Hmm, it looks like the BTH isn't drawing properly under windows... Might be my version of SDL (1.2.11).
http://imgbucket.info/img/w2me27ywn/radarstack.jpg
http://imgbucket.info/img/0mshzsk1j/esmstack.jpg
Phew! That was a bit of a pain.
OK so basically here's what I had to do:
- Commented out the options parsing section, so only defaults are available if you compile with MSVC (until the getops() while loop is rewritten with something portable).
- In files.cpp defined DATADIR to be char* DATADIR = "data" This will make the game look in its binary path for the datafiles it needs.
- Changed fabs to abs in radar.cpp since the arguments are all signed ints (MSVC gets pissy about this because it can't determine from the argument types whether you want a double or float version of fabs).
- Got rid of all the weird double includes (i.e. #include "SDL/SDL.h" followed by #include <SDL/SDL.h>)
- Removed SDL/ from the beginning of all SDL-related includes.
- Defined snprintf as _snprintf for MSVC compiles
- Defined strcasestr as strstr for MSVC compiles (This is technically inaccurate as the two functions have slightly different behavior)
- Defined strncasecmp as _strnicmp for MSVC compiles (the former does not exist under MSVC as it's nonstandard C).
- Grabbed and compiled all the dependencies in addition to SDL (this part was a pain because the new versions of MSVC require you to specify your lib/include directories for each project individually).
In addition to SDL, openSSN needs the following deps:
- SDL_image
- SDL_gfx
- SDL_mixer
redtyphoon
09-03-11, 04:11 PM
Congrats on getting OpenSSN to compile.
One suggestion though regarding DATADIR. The DATADIR value is supposed to point to the top level of the OpenSSN directory tree. So, for example, if you had
C:\Program Files\OpenSSN\data
C:\Program Files\OpenSSN\sounds
C:\Program Files\OpenSSN\ships
C:\Program Files\OpenSSN\images
Then DATADIR should be "C:\Program Files\OpenSSN". If it's working as-is right now, it's probably because the files.cpp module also checks the current working directory if it doesn't find what it's looking for in DATADIR.
I'll make a note of your other changes so the next version of OpenSSN will be easier to work with. Thanks!
PS. If you'd like to e-mail me a ZIP file with your binary and data files, I'll upload it to the project's website so everyone has easy access to it.
jessefrgsmith@yahoo.ca
magicstix
09-03-11, 05:24 PM
Unfortunately gmail doesn't allow one to send .zips with exe files. I'll figure something out and post it somewhere I guess.
redtyphoon
09-03-11, 05:55 PM
If you have a SourceForge account I could just give you upload rights to the OpenSSN project.
Update:
Since the strncasestr and strncasecmp functions don't work in MSVC compiler and the _stricmp probably won't work on any other compiler besides MSVC I've decided to write my own versions of these functions. Having a local version of these functions should help. The getopt section I'll re-write to be more vanilla.
magicstix
09-04-11, 12:17 PM
You can just redefine them with a precompiler statement.
#if _MSC_VER
#define snprintf _snprintf
#define strncmp _strnicmp
#endif
Etc... This will be ignored by the linux compilers and will properly replace the functions under MSVC
redtyphoon
09-04-11, 01:24 PM
I think the define statements make sense short-term, to get OpenSSN up and running now. Long-term though I have concerns about patching against specific compilers. There are a lot of C/C++ compilers out there. Ideally I'd like to have a solution in place that will work on Windows, regardless of which compiler is used.
FERdeBOER
09-05-11, 06:55 AM
I will play openssn in Linux, but if you can port it to Windows you will enlarge your audience...
I think is more a matter of how much time you have at your disposal and how much of this time will the windows port need.
PS: i've just sent to you an outdated Spanish manual translation. :cry:
I have very little spare time this last month...
magicstix
09-05-11, 02:10 PM
Typhoon, if you want me to upload the windows binaries to SF my username is magic-stix.
redtyphoon
09-05-11, 02:25 PM
I've granted the account magic-stix release file access, which should allow you to upload binaries to the mirrors. If it's not working, please let me know.
magicstix
09-05-11, 02:58 PM
Windows version is up.
redtyphoon
09-05-11, 04:30 PM
Thanks!
Before announcing the new version I downloaded and tried to give it a run (I've got WINE) and I'm getting the "incorrect application configuration" message which so commonly plagues MSVC developers. Could you check to see if a DLL is missing?
This page has details on how to cover all the bases:
http://www.virtualdub.org/blog/pivot/entry.php?id=296
magicstix
09-05-11, 04:56 PM
Hmmm. That's odd, the game works fine for me right out of the zip. Does it say which dll is missing?
magicstix
09-05-11, 04:59 PM
OK I pulled the zip and ran it on my other windows machine and got an error. I'll look into it, i think I'm probably missing the msvc c runtime dll.
redtyphoon
09-05-11, 05:01 PM
No, the error doesn't say which DLLs are missing. But one of the prime characteristics of the "incorrect configuration" error is that people with MSVC installed on their machines can run the program fine, but people without MSVC cannot. It's pretty common. The list of problem DLLs is available in the link I posted.
Update: I just you beat me to a follow up post.
magicstix
09-05-11, 05:36 PM
For some reason it keeps trying to use the debug versions of the Visual C runtime libraries, I've gone back and rebuilt openSSN and all of its dependencies but the deps seem to still want to use debug symbols... I'll poke around at it some and see if I can fix it.
magicstix
09-05-11, 06:01 PM
OK try it now. For some reason the SDL_gfx.dll was trying to link against debug symbols for the C runtime regardless of how I built it, so I built it with static linking of deps instead. Works on both of my windows machines now.
redtyphoon
09-05-11, 07:04 PM
The new package works a-ok here. Everything seems to be intact and i was able to run it (emulated) and play through a mission. Very nicely done, sir. I will make the appropriate announcements.
Thank you very much for your hard work.
CTarana
02-10-12, 09:50 AM
I would definately be interested in seeing OpenSSN ported over to WindowsXP, Vista or 7. I use XP myself and the last version of OpenSSN I have works great. I have version 0.7. I just installed copies of MinGW C++ and Microsoft Visual Studio 8 for another project I'm working on. I'm trying to teach myself C++ and Visual Basic so I can port an older Visual Basic 5.5 program and finish it! :O:
ChristopherT
magicstix
02-10-12, 10:47 PM
I would definately be interested in seeing OpenSSN ported over to WindowsXP, Vista or 7. I use XP myself and the last version of OpenSSN I have works great. I have version 0.7. I just installed copies of MinGW C++ and Microsoft Visual Studio 8 for another project I'm working on. I'm trying to teach myself C++ and Visual Basic so I can port an older Visual Basic 5.5 program and finish it! :O:
ChristopherT
There's already a windows version out there, it's kinda old though...
CTarana
02-11-12, 11:55 PM
That's okay if it's old! Still MUCH better than 688 Attack Sub or SSN-21!
:D
ChristopherT
CTarana
02-12-12, 01:14 PM
Where do I install the SDL libraries if I'm going to try to use MinGW C++ to try to compile the source code for version 1.1 of OpenSSN? :) Mind you this is the first time I've used any sort of compiler! :up: I'm running on WinXP!
Thanks!
ChristopherT
magicstix
02-12-12, 08:11 PM
Where do I install the SDL libraries if I'm going to try to use MinGW C++ to try to compile the source code for version 1.1 of OpenSSN? :) Mind you this is the first time I've used any sort of compiler! :up: I'm running on WinXP!
Thanks!
ChristopherT
If you're using mingw c++ you're probably running under cygwin, correct? In that case you wouldn't be using DLLs, you'd be linking against the .so's.
It'd probably be a better idea to take the source and try to compile it under visual studio.
CTarana
02-12-12, 09:35 PM
Okay, I'll try to get a copy of Visual Studio C++, would the Express version work okay?
Thanks, Guys! :salute:
Christopher
magicstix
02-12-12, 11:28 PM
Okay, I'll try to get a copy of Visual Studio C++, would the Express version work okay?
Thanks, Guys! :salute:
Christopher
Express is fine; that's what I used in the port.
CTarana
02-13-12, 02:08 AM
:DWell, It took 4 hours but I got Visual Studio C++ 2010 Express installed! Now I'm going to shut off the computer, catch some ZZZZ's and start looking at the source code closer. Do I still have to install the SDL Libraries to compile the source code? :|\\ :zzz:
Later!
ChristopherT
CTarana
02-15-12, 09:20 AM
Okay, I'm out of it! I had to delete Visual Studio 2010 for C++ and Visual Basic because now my computer wont shut off! Darn! Everytime I go to shutdown the computer it won't stay off. At least it will go into Hibernate (Sleep) mode! Darn Darn Darn! I was trying to help but I can't risk the rest of this computer because all our personal files are on here to the tune of several gigs!
Sorry guys!
Christopher
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.