Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ add_definitions(-DIVAN_VERSION="${PROJECT_VERSION}" -DUSE_SDL)
option(BUILD_MAC_APP "Build standalone application for MacOS" OFF)
option(USE_HOME_FOR_STATE_DIR "Statedir will be /.ivan/ in current user's homedir" OFF)
option(WIZARD "Enable Wizard Mode" OFF)
option(PORTABLE_BUILD "Keep game and user data in the directory IVAN is launched from" OFF)

if(UNIX)
add_definitions(-DUNIX)
if(NOT PORTABLE_BUILD)
include(GNUInstallDirs)

if(BUILD_MAC_APP)
Expand All @@ -37,6 +39,7 @@ if(UNIX)
" please move them to \"$ENV{HOME}/.ivan\".")
endif()
endif()
endif()

elseif(WIN32)
install(DIRECTORY Graphics Script Music Sound DESTINATION "ivan")
Expand All @@ -63,6 +66,10 @@ if(WIZARD)
add_definitions(-DWIZARD)
endif()

if(PORTABLE_BUILD)
add_definitions(-DPORTABLE_BUILD)
endif()

find_path(EXECINFO_INCLUDE_DIR NAMES execinfo.h)
if(NOT EXECINFO_INCLUDE_DIR MATCHES "-NOTFOUND$")
add_definitions(-DBACKTRACE)
Expand Down
4 changes: 2 additions & 2 deletions FeLib/Include/fearray.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ template <class type>
inline fearray<type>::fearray(const type* Array, sizetype Size)
: Size(Size)
{
char* Ptr = new char[Size * sizeof(type) + sizeof(int*)];
char* Ptr = new char[Size * sizeof(type) + sizeof(ulong)];
*reinterpret_cast<ulong*>(Ptr) = 0;
Data = reinterpret_cast<type*>(Ptr + sizeof(int*));
Data = reinterpret_cast<type*>(Ptr + sizeof(ulong));

for(sizetype c = 0; c < Size; ++c)
new(&Data[c]) type(Array[c]);
Expand Down
5 changes: 5 additions & 0 deletions FeLib/Include/hscore.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@

#include "festring.h"

#ifdef PORTABLE_BUILD
#define HIGH_SCORE_FILENAME "ivan-highscore.scores"
#else

#ifdef UNIX
#define HIGH_SCORE_FILENAME "ivan-highscore.scores"
#endif

#if defined(WIN32) || defined(__DJGPP__)
#define HIGH_SCORE_FILENAME "HScore.dat"
#endif
#endif

class festring;

Expand Down
33 changes: 33 additions & 0 deletions FeLib/Include/save.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,41 @@ inline inputfile& operator>>(inputfile& SaveFile, ushort& Value)
return SaveFile;
}

/* SAVE_COMPATIBILITY:
* make x86_64-w64-mingw32 saves compatible with Linux,
* by forcing the correct sizes.
* Note: This also lets us save 64-bit time_t values.
**/

#if SAVE_COMPATIBILITY
#include <stdint.h>
RAW_SAVE_LOAD(int64_t)
RAW_SAVE_LOAD(uint64_t)

inline outputfile& operator<<(outputfile& SaveFile, long Value)
{
int64_t Value2 = Value; return SaveFile << Value2;
}

inline inputfile& operator>>(inputfile& SaveFile, long& Value)
{
int64_t Value2; SaveFile >> Value2; Value = Value2; return SaveFile;
}

inline outputfile& operator<<(outputfile& SaveFile, ulong Value)
{
uint64_t Value2 = Value; return SaveFile << Value2;
}

inline inputfile& operator>>(inputfile& SaveFile, ulong& Value)
{
uint64_t Value2; SaveFile >> Value2; Value = Value2; return SaveFile;
}

#else
RAW_SAVE_LOAD(long)
RAW_SAVE_LOAD(ulong)
#endif
RAW_SAVE_LOAD(int)
RAW_SAVE_LOAD(uint)
RAW_SAVE_LOAD(double)
Expand Down
19 changes: 13 additions & 6 deletions FeLib/Source/feio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,22 @@
#include <cstring>
#include <vector>

#if defined(UNIX) || defined(USE_OPENDIR)
#include <dirent.h>
#else

#ifdef WIN32
#define stat _stat
#include <io.h>
#endif

#ifdef __DJGPP__
#include <dir.h>
#endif

#endif

#ifdef UNIX
#include <dirent.h>
#include <stddef.h>
#include <cstdio>
#include <time.h>
Expand All @@ -37,9 +46,6 @@
#include <sstream>
#endif

#ifdef __DJGPP__
#include <dir.h>
#endif

#include "bitmap.h"
#include "error.h"
Expand Down Expand Up @@ -1044,7 +1050,7 @@ festring iosystem::ContinueMenu(col16 TopicColor, col16 ListColor,
felist List(CONST_S("Choose a file and be sorry:"), TopicColor);

////////////////////////// OS SPECIFIC!!! collect all files at save folder. //////////////////////////
#ifdef UNIX
#if defined(UNIX) || defined(USE_OPENDIR)
{
DIR* dp;
struct dirent* ep;
Expand All @@ -1055,7 +1061,7 @@ festring iosystem::ContinueMenu(col16 TopicColor, col16 ListColor,
closedir(dp);
}
}
#endif
#else

#ifdef WIN32
struct _finddata_t Found;
Expand Down Expand Up @@ -1091,6 +1097,7 @@ festring iosystem::ContinueMenu(col16 TopicColor, col16 ListColor,
Check = findnext(&Found);
}
}
#endif
#endif

if(vFiles.size()==0){
Expand Down
12 changes: 4 additions & 8 deletions FeLib/Source/femath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,26 +315,22 @@ void ReadData(region& R, inputfile& SaveFile)

outputfile& operator<<(outputfile& SaveFile, const interval& I)
{
SaveFile.Write(reinterpret_cast<cchar*>(&I), sizeof(I));
return SaveFile;
return SaveFile << I.Min << I.Max;
}

inputfile& operator>>(inputfile& SaveFile, interval& I)
{
SaveFile.Read(reinterpret_cast<char*>(&I), sizeof(I));
return SaveFile;
return SaveFile >> I.Min >> I.Max;
}

outputfile& operator<<(outputfile& SaveFile, const region& R)
{
SaveFile.Write(reinterpret_cast<cchar*>(&R), sizeof(R));
return SaveFile;
return SaveFile << R.X << R.Y;
}

inputfile& operator>>(inputfile& SaveFile, region& R)
{
SaveFile.Read(reinterpret_cast<char*>(&R), sizeof(R));
return SaveFile;
return SaveFile >> R.X >> R.Y;
}

long femath::SumArray(const fearray<long>& Vector)
Expand Down
2 changes: 1 addition & 1 deletion FeLib/Source/festring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ long festring::GetCheckSum() const
void festring::CreateNewData(sizetype N)
{
Reserved = N|FESTRING_PAGE;
Data = sizeof(int*) + new char[Reserved + sizeof(int*) + 1];
Data = sizeof(ulong) + new char[Reserved + sizeof(ulong) + 1];
OwnsData = true;
REFS(Data) = 0;
Size = 0;
Expand Down
4 changes: 4 additions & 0 deletions FeLib/Source/save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,9 @@ void MakePath(cfestring& Path)

festring GetUserDataDir()
{
#ifdef PORTABLE_BUILD
return "./";
#else
#ifdef UNIX
festring Dir;
#ifdef MAC_APP
Expand All @@ -834,4 +837,5 @@ festring GetUserDataDir()
#if defined(WIN32) || defined(__DJGPP__)
return "./";
#endif
#endif
}
2 changes: 1 addition & 1 deletion Main/Include/square.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class square
area* GetArea() const { return AreaUnder; }
virtual gterrain* GetGTerrain() const = 0;
virtual oterrain* GetOTerrain() const = 0;
festring GetMemorizedDescription() { return MemorizedDescription; }
festring GetMemorizedDescription() const { return MemorizedDescription; }
void SetMemorizedDescription(cfestring& What) { MemorizedDescription = What; }
virtual truth CanBeSeenByPlayer(truth = false) const = 0;
virtual truth CanBeSeenFrom(v2, long, truth = false) const = 0;
Expand Down
1 change: 1 addition & 0 deletions Main/Include/trap.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class itemtrapbase
{
public:
itemtrapbase() : Active(false) { }
virtual ~itemtrapbase() { }
void Save(outputfile&) const;
void Load(inputfile&);
void SetIsActive(truth);
Expand Down
2 changes: 1 addition & 1 deletion Main/Source/bugworkaround.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ character* bugfixdp::ValidatePlayerAt(square* sqr)

if(vPF.size()>1){ // FIRST CHECK/FIX!
festring fsMsg;
fsMsg << "Multiple player instances found (x" << vPF.size() << "), try to fix this?";
fsMsg << "Multiple player instances found (x" << int(vPF.size()) << "), try to fix this?";
if(AlertConfirmFixMsg(fsMsg.CStr()))
return BugWorkaroundDupPlayer();
/**
Expand Down
2 changes: 1 addition & 1 deletion Main/Source/cmdcraft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3062,7 +3062,7 @@ void updateCraftDesc(){

festring fsDesc=fsSkill;
if(vSuspended.size()>0)
fsDesc<<" (Suspended Actions: "<<vSuspended.size()<<")";
fsDesc<<" (Suspended Actions: "<<int(vSuspended.size())<<")";

craftRecipes.AddDescription(fsDesc,fSkill<10?RED:WHITE);
}
Expand Down
4 changes: 4 additions & 0 deletions Main/Source/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5304,6 +5304,9 @@ inputfile& operator>>(inputfile& SaveFile, dangerid& Value)

festring game::GetDataDir()
{
#ifdef PORTABLE_BUILD
return "./";
#else
#ifdef UNIX
#ifdef MAC_APP
return "../Resources/data/";
Expand All @@ -5315,6 +5318,7 @@ festring game::GetDataDir()
#if defined(WIN32) || defined(__DJGPP__)
return GetUserDataDir();
#endif
#endif
}

festring game::GetSaveDir()
Expand Down
6 changes: 2 additions & 4 deletions Main/Source/lsquare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1398,14 +1398,12 @@ void lsquare::KickAnyoneStandingHereAway()

outputfile& operator<<(outputfile& SaveFile, const emitter& Emitter)
{
SaveFile.Write(reinterpret_cast<cchar*>(&Emitter), sizeof(Emitter));
return SaveFile;
return SaveFile << Emitter.ID << Emitter.Emitation;
}

inputfile& operator>>(inputfile& SaveFile, emitter& Emitter)
{
SaveFile.Read(reinterpret_cast<char*>(&Emitter), sizeof(Emitter));
return SaveFile;
return SaveFile >> Emitter.ID >> Emitter.Emitation;
}

void lsquare::AddItem(item* Item)
Expand Down
4 changes: 4 additions & 0 deletions xbrzscale/libxbrzscale.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _XRBZSCALE_
#define _XRBZSCALE_

#ifndef XBRZLIB_RELATIVEPATHSDL
#include <SDL_stdinc.h>
#else
Expand Down Expand Up @@ -49,3 +52,4 @@ class libxbrzscale
static bool bFreeInputSurfaceAfterScale;
static bool bFreeOutputSurfaceAfterScale;
};
#endif
Loading