SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Sub/Naval + Other Games > Indie Subsims
Forget password? Reset here

View Poll Results: Would you play OpenSSN on Windows?
Yes, please make OpenSSN available on Windows 14 93.33%
No, I already have subsims I like on Windows 1 6.67%
I don't use Windows 0 0%
Voters: 15. You may not vote on this poll

Reply
 
Thread Tools Display Modes
Old 09-03-11, 12:15 PM   #1
redtyphoon
Sailor man
 
Join Date: May 2011
Posts: 45
Downloads: 0
Uploads: 0
Question for the gamers

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/
redtyphoon is offline   Reply With Quote
Old 09-03-11, 01:45 PM   #2
magicstix
Captain
 
Join Date: Aug 2011
Location: Nuclear submarine under the North Pole
Posts: 481
Downloads: 1
Uploads: 0
Default

If you're using only SDL for the graphics it should be a pretty straightforward port...
magicstix is offline   Reply With Quote
Old 09-03-11, 01:50 PM   #3
redtyphoon
Sailor man
 
Join Date: May 2011
Posts: 45
Downloads: 0
Uploads: 0
Default SDL

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.
redtyphoon is offline   Reply With Quote
Old 09-03-11, 01:58 PM   #4
magicstix
Captain
 
Join Date: Aug 2011
Location: Nuclear submarine under the North Pole
Posts: 481
Downloads: 1
Uploads: 0
Default

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.
magicstix is offline   Reply With Quote
Old 09-03-11, 02:08 PM   #5
redtyphoon
Sailor man
 
Join Date: May 2011
Posts: 45
Downloads: 0
Uploads: 0
Default Porting

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.
redtyphoon is offline   Reply With Quote
Old 09-03-11, 02:10 PM   #6
magicstix
Captain
 
Join Date: Aug 2011
Location: Nuclear submarine under the North Pole
Posts: 481
Downloads: 1
Uploads: 0
Default

Which version of SDL are you using? The latest doesnt have the SDL subdirectory tree nor does it have SDL_image.h
magicstix is offline   Reply With Quote
Old 09-03-11, 02:12 PM   #7
magicstix
Captain
 
Join Date: Aug 2011
Location: Nuclear submarine under the North Pole
Posts: 481
Downloads: 1
Uploads: 0
Default

Nevermind... I didn't know it was a second library.
magicstix is offline   Reply With Quote
Old 09-03-11, 02:24 PM   #8
magicstix
Captain
 
Join Date: Aug 2011
Location: Nuclear submarine under the North Pole
Posts: 481
Downloads: 1
Uploads: 0
Default

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.
magicstix is offline   Reply With Quote
Old 09-03-11, 02:38 PM   #9
redtyphoon
Sailor man
 
Join Date: May 2011
Posts: 45
Downloads: 0
Uploads: 0
Default Compiler errors

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.
redtyphoon is offline   Reply With Quote
Old 09-03-11, 02:42 PM   #10
magicstix
Captain
 
Join Date: Aug 2011
Location: Nuclear submarine under the North Pole
Posts: 481
Downloads: 1
Uploads: 0
Default

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.
magicstix is offline   Reply With Quote
Old 09-03-11, 03:44 PM   #11
redtyphoon
Sailor man
 
Join Date: May 2011
Posts: 45
Downloads: 0
Uploads: 0
Default Compatibility

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.
redtyphoon is offline   Reply With Quote
Old 09-03-11, 03:59 PM   #12
magicstix
Captain
 
Join Date: Aug 2011
Location: Nuclear submarine under the North Pole
Posts: 481
Downloads: 1
Uploads: 0
Default

Success!




Hmm, it looks like the BTH isn't drawing properly under windows... Might be my version of SDL (1.2.11).





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
magicstix is offline   Reply With Quote
Old 09-03-11, 04:11 PM   #13
redtyphoon
Sailor man
 
Join Date: May 2011
Posts: 45
Downloads: 0
Uploads: 0
Default Congrats

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
redtyphoon is offline   Reply With Quote
Old 09-03-11, 05:24 PM   #14
magicstix
Captain
 
Join Date: Aug 2011
Location: Nuclear submarine under the North Pole
Posts: 481
Downloads: 1
Uploads: 0
Default

Unfortunately gmail doesn't allow one to send .zips with exe files. I'll figure something out and post it somewhere I guess.
magicstix is offline   Reply With Quote
Old 09-03-11, 05:55 PM   #15
redtyphoon
Sailor man
 
Join Date: May 2011
Posts: 45
Downloads: 0
Uploads: 0
Default Upload rights

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.

Last edited by redtyphoon; 09-04-11 at 11:02 AM.
redtyphoon is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:57 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 1995- 2024 Subsim®
"Subsim" is a registered trademark, all rights reserved.