![]() |
SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997 |
|
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 |
![]() |
|
Thread Tools | Display Modes |
|
![]() |
#1 |
Captain
![]() Join Date: Aug 2011
Location: Nuclear submarine under the North Pole
Posts: 481
Downloads: 1
Uploads: 0
|
![]()
Which version of SDL are you using? The latest doesnt have the SDL subdirectory tree nor does it have SDL_image.h
|
![]() |
![]() |
![]() |
#2 |
Captain
![]() Join Date: Aug 2011
Location: Nuclear submarine under the North Pole
Posts: 481
Downloads: 1
Uploads: 0
|
![]()
Nevermind... I didn't know it was a second library.
|
![]() |
![]() |
![]() |
#3 |
Captain
![]() Join Date: Aug 2011
Location: Nuclear submarine under the North Pole
Posts: 481
Downloads: 1
Uploads: 0
|
![]()
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. |
![]() |
![]() |
![]() |
#4 |
Sailor man
![]() Join Date: May 2011
Posts: 45
Downloads: 0
Uploads: 0
|
![]()
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.
|
![]() |
![]() |
![]() |
#5 |
Captain
![]() Join Date: Aug 2011
Location: Nuclear submarine under the North Pole
Posts: 481
Downloads: 1
Uploads: 0
|
![]()
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. |
![]() |
![]() |
![]() |
#6 |
Sailor man
![]() Join Date: May 2011
Posts: 45
Downloads: 0
Uploads: 0
|
![]()
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. |
![]() |
![]() |
![]() |
#7 |
Captain
![]() Join Date: Aug 2011
Location: Nuclear submarine under the North Pole
Posts: 481
Downloads: 1
Uploads: 0
|
![]()
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 |
![]() |
![]() |
![]() |
#8 |
Sailor man
![]() Join Date: May 2011
Posts: 45
Downloads: 0
Uploads: 0
|
![]()
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 |
![]() |
![]() |
![]() |
#9 |
Captain
![]() Join Date: Aug 2011
Location: Nuclear submarine under the North Pole
Posts: 481
Downloads: 1
Uploads: 0
|
![]()
Unfortunately gmail doesn't allow one to send .zips with exe files. I'll figure something out and post it somewhere I guess.
|
![]() |
![]() |
![]() |
#10 |
Bosun
![]() Join Date: Jan 2009
Posts: 68
Downloads: 28
Uploads: 0
|
![]()
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 |
![]() |
![]() |
![]() |
#11 | |
Captain
![]() Join Date: Aug 2011
Location: Nuclear submarine under the North Pole
Posts: 481
Downloads: 1
Uploads: 0
|
![]() Quote:
|
|
![]() |
![]() |
![]() |
#12 |
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 |
![]() |
![]() |
![]() |
#13 |
Bosun
![]() Join Date: Jan 2009
Posts: 68
Downloads: 28
Uploads: 0
|
![]()
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?
![]() ![]() Thanks! ChristopherT |
![]() |
![]() |
![]() |
#14 | |
Captain
![]() Join Date: Aug 2011
Location: Nuclear submarine under the North Pole
Posts: 481
Downloads: 1
Uploads: 0
|
![]() Quote:
It'd probably be a better idea to take the source and try to compile it under visual studio. |
|
![]() |
![]() |
![]() |
#15 |
Bosun
![]() Join Date: Jan 2009
Posts: 68
Downloads: 28
Uploads: 0
|
![]()
Okay, I'll try to get a copy of Visual Studio C++, would the Express version work okay?
Thanks, Guys! ![]() Christopher |
![]() |
![]() |
![]() |
|
|