Skip to content

Commit

Permalink
Make the Linux version loading and producing Windows compatible saveg…
Browse files Browse the repository at this point in the history
…ames

../ctp2_code/gs/fileio/GameFile.cpp
../ctp2_code/os/nowin32/windows.h
../ctp2_code/ui/netshell/allinonewindow.cpp
../ctp2_code/ui/netshell/netfunc.cpp
../ctp2_code/ui/netshell/netfunc.h
../ctp2_code/ui/netshell/ns_gamesetup.cpp
../ctp2_code/ui/netshell/ns_gamesetup.h

Added enable logging for the final version, however so far not tested
../configure.ac
  • Loading branch information
MartinGuehmann committed Jan 16, 2019
1 parent 868ba95 commit 22dd180
Show file tree
Hide file tree
Showing 8 changed files with 6,598 additions and 6,371 deletions.
9 changes: 8 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ package_sysconfdir=$(eval echo $sysconfdir)
AC_DEFINE_UNQUOTED(PACKAGE_DATADIR,"${package_datadir}",[read-only architecture-independent data [PREFIX/share]])
AC_DEFINE_UNQUOTED(PACKAGE_SYSCONFDIR,"${package_sysconfdir}",[read-only single-machine data [PREFIX/etc]])

AC_ARG_ENABLE([logging],
AC_HELP_STRING([--enable-logging],[enable logging]),,
[enable_logging=no])
if test x$enable_logging = xyes || test x$enable_logging = xfull; then
AC_DEFINE(USE_LOGGING,1,[Enable logging])
fi

AC_ARG_ENABLE([debug],
AC_HELP_STRING([--enable-debug],[enable debugging]),,
[enable_debug=no])
Expand All @@ -145,7 +152,7 @@ enable_anet=no
AC_ARG_ENABLE([anet],
AC_HELP_STRING([--enable-anet],[enable external anet library]),,
[enable_anet=no])
AC_MSG_CHECKING([wether to build with internal anet library])
AC_MSG_CHECKING([whether to build with internal anet library])
if test x$enable_anet == xno; then
AC_MSG_RESULT([yes])
AC_CONFIG_SUBDIRS([ctp2_code/libs/anet])
Expand Down
33 changes: 10 additions & 23 deletions ctp2_code/gs/fileio/GameFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
// - Removed old concept database. (31-Mar-2007 Martin Gühmann)
// - Removed old const database. (5-Aug-2007 Martin Gühmann)
// - Replaced CIV_INDEX by sint32. (2-Jan-2008 Martin Gühmann)
// - Make the Linux version loading and producing Windows compatible
// savegames. (16-Jan-2019 Martin Gühmann)
//
//----------------------------------------------------------------------------

Expand Down Expand Up @@ -1096,19 +1098,14 @@ bool GameFile::LoadExtendedGameInfo(FILE *saveFile, SaveInfo *info)
info->networkGUID[i].guid = guid;
}

n = c3files_fread(&info->gameSetup, sizeof(nf_GameSetup), 1, saveFile);
if (n != 1)
{
c3files_fclose(saveFile);
return false;
}
info->gameSetup.ReadFromFile(saveFile);

NETFunc::Session * s = (NETFunc::Session *) &info->gameSetup;
dp_session_t * sess =
(dp_session_t *)((uint8*)s + sizeof(NETFunc::Key));
(dp_session_t *)((uint8*)s + sizeof(NETFunc::Key)); // Problem
sess->sessionType = GAMEID;

n = c3files_fread(&info->options, sizeof(SaveInfo::OptionScreenSettings), 1, saveFile);
n = c3files_fread(&info->options, sizeof(SaveInfo::OptionScreenSettings), 1, saveFile); // No problem, unless BOOL is not 4 bytes
if (n != 1)
{
c3files_fclose(saveFile);
Expand Down Expand Up @@ -1139,7 +1136,7 @@ bool GameFile::LoadExtendedGameInfo(FILE *saveFile, SaveInfo *info)
return false;
}

n = c3files_fread(&info->positions, sizeof(StartingPosition), k_MAX_START_POINTS, saveFile);
n = c3files_fread(&info->positions, sizeof(StartingPosition), k_MAX_START_POINTS, saveFile); // Problem, but should be OK
if(n != k_MAX_START_POINTS)
{
c3files_fclose(saveFile);
Expand Down Expand Up @@ -1320,14 +1317,9 @@ bool GameFile::LoadBasicGameInfo(FILE *saveFile, SaveInfo *info)
info->networkGUID[i].guid = guid;
}

n = c3files_fread(&info->gameSetup, sizeof(nf_GameSetup), 1, saveFile);
if (n != 1)
{
c3files_fclose(saveFile);
return false;
}
info->gameSetup.ReadFromFile(saveFile); // 720 bytes

n = c3files_fread(&info->options, sizeof(SaveInfo::OptionScreenSettings), 1, saveFile);
n = c3files_fread(&info->options, sizeof(SaveInfo::OptionScreenSettings), 1, saveFile); // Problem, seems to be OK unless BOOL is not 4 bytes
if (n != 1)
{
c3files_fclose(saveFile);
Expand Down Expand Up @@ -1523,15 +1515,10 @@ void GameFile::SaveExtendedGameInfo(FILE *saveFile, SaveInfo *info)
civindex = -1;
}
c3files_fwrite(&civindex, 1, sizeof(sint32), saveFile);
c3files_fwrite(&guid, 1, sizeof(GUID), saveFile);
c3files_fwrite(&guid, 1, sizeof(GUID), saveFile); // Check Linux implementation, should have 16 bytes
}

n = c3files_fwrite(&info->gameSetup, sizeof(nf_GameSetup), 1, saveFile);
if (n != 1)
{
c3errors_FatalDialog(functionName, errorString);
return;
}
info->gameSetup.WriteToFile(saveFile);

n = c3files_fwrite(&info->options, sizeof(SaveInfo::OptionScreenSettings), 1, saveFile);
if (n != 1)
Expand Down
Loading

0 comments on commit 22dd180

Please sign in to comment.