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, 02:10 PM   #1
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   #2
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   #3
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   #4
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   #5
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   #6
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   #7
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   #8
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   #9
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 02-10-12, 09:50 AM   #10
CTarana
Bosun
 
Join Date: Jan 2009
Posts: 68
Downloads: 28
Uploads: 0
Default

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!

ChristopherT
CTarana is offline   Reply With Quote
Old 02-10-12, 10:47 PM   #11
magicstix
Captain
 
Join Date: Aug 2011
Location: Nuclear submarine under the North Pole
Posts: 481
Downloads: 1
Uploads: 0
Default

Quote:
Originally Posted by CTarana View Post
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!

ChristopherT
There's already a windows version out there, it's kinda old though...
magicstix is offline   Reply With Quote
Old 02-11-12, 11:55 PM   #12
CTarana
Bosun
 
Join Date: Jan 2009
Posts: 68
Downloads: 28
Uploads: 0
That's okay if it's old! Still MUCH better than 688 Attack Sub or SSN-21!


ChristopherT
CTarana is offline   Reply With Quote
Old 02-12-12, 01:14 PM   #13
CTarana
Bosun
 
Join Date: Jan 2009
Posts: 68
Downloads: 28
Uploads: 0
Default

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! I'm running on WinXP!

Thanks!

ChristopherT
CTarana is offline   Reply With Quote
Old 02-12-12, 08:11 PM   #14
magicstix
Captain
 
Join Date: Aug 2011
Location: Nuclear submarine under the North Pole
Posts: 481
Downloads: 1
Uploads: 0
Default

Quote:
Originally Posted by CTarana View Post
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! 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.
magicstix is offline   Reply With Quote
Old 02-12-12, 09:35 PM   #15
CTarana
Bosun
 
Join Date: Jan 2009
Posts: 68
Downloads: 28
Uploads: 0
Default

Okay, I'll try to get a copy of Visual Studio C++, would the Express version work okay?

Thanks, Guys!

Christopher
CTarana 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 09:44 PM.


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