stefanhendriks / Dune-II---The-Maker

A remake of the classic Dune 2 - The Building of a Dynasty (by Westwood Studios) with several enhancements. Like: higher screenresolutions, zooming, multiselect, skirmish play, etc.
https://www.dune2themaker.com
301 stars 26 forks source link

Compiles on Linux but not fully functional? #577

Open bhenstra opened 1 year ago

bhenstra commented 1 year ago

Hello,

I was able to compile the executable for Linux. I did notice the missions don't work. I don't have options to build and so on. There is no map. Is that correct?

Currently playing Dune 2 DOS version in DOSBox. I would really like to play Dune 2 in high resolution :1st_place_medal:

Is it me doing something wrong? Do I have to copy the original game dirs? Or is the Linux version not ready yet?

Thanks.

stefanhendriks commented 1 year ago

I do know the linux build is buggy (see #458 and #492 ). I wonder though; where do you put the executable? Afaik if you keep the folder structure from the original ZIP and put the linux executable where the d2tm.exe is, it should basically find all the files and at least start (and probably let you play skirmish).

maciejla commented 1 year ago

With the executable at root, skirmish works as intended, but there aren't any buildings on campaign (#458) log.txt below

\\-------------------
\\Dune II - The Maker
\\-------------------
\\
\\-------------------
\\Version information
\\-------------------
0|INFO|VERSION|Version 0.7.0, Compiled at Dec 28 2022 , 14:02:42|Initializing
0|INFO|GAMEINI|Load file settings.ini|(cIniFile)
0|INFO|GAMEINI|Load file game.ini|(cIniFile)
\\-------
\\Allegro
\\-------
3|INFO|ALLEGRO|Allegro 4.4.3, Unix|SUCCESS|Allegro init
3|INFO|ALLEGRO|Dune II - The Maker [0.7.0] - (by Stefan Hendriks)|SUCCESS|Set up window title
3|INFO|ALLEGRO|install_timer()|SUCCESS|Initializing timer functions
3|INFO|ALLEGRO|alfont_init()|SUCCESS|Initializing ALFONT
27|INFO|ALLEGRO|install_keyboard()|SUCCESS|Initializing Allegro Keyboard
27|INFO|ALLEGRO|install_mouse()|SUCCESS|Initializing Allegro Mouse
27|INFO|ALLEGRO|LOCK_VARIABLE/LOCK_FUNCTION|SUCCESS|Set up timer related variables
27|INFO|SETUP|Resolution 1680x1050 loaded from settings.ini.|Resolution from ini file
27|INFO|ALLEGRO|Desktop color dept is 32.|Screen init
27|INFO|ALLEGRO|Fullscreen mode requested.|Screen init
33|INFO|ALLEGRO|Successfully initialized full-screen with resolution 1680x1050 and color depth 32.|SUCCESS|Screen init
33|INFO|ALLEGRO|Set text mode to -1|SUCCESS|Font settings
33|INFO|ALFONT|loaded arrakeen.fon|SUCCESS|Loading font
33|INFO|ALFONT|loaded benegess.fon|SUCCESS|Loading font
33|INFO|ALFONT|loaded data/small.ttf|SUCCESS|Loading font
54|INFO|SOUND|Hooked datafile: gfxaudio.dat.|SUCCESS|Initialization
59|INFO|SOUND|Failed reserving 256 voices. Will try 128.|FAILED|Initialization
60|INFO|SOUND|Failed reserving 128 voices. Will try 64.|FAILED|Initialization
63|INFO|SOUND|Successfully installed sound. 64 voices reserved|SUCCESS|Initialization
\\----
\\GAME
\\----
137|INFO|ALLEGRO|Hooked datafile: gfxdata.dat|SUCCESS|Load data
162|INFO|ALLEGRO|Hooked datafile: gfxinter.dat|SUCCESS|Load data
173|INFO|ALLEGRO|Hooked datafile: gfxworld.dat|SUCCESS|Load data
200|INFO|ALLEGRO|Hooked datafile: gfxmentat.dat|SUCCESS|Load data
\\--------
\\SHUTDOWN
\\--------
7811|INFO|ALLEGRO|Shutting down...|Allegro shutdown
7813|INFO|ALLEGRO|Thanks for playing!|SUCCESS|Allegro shutdown
7813|INFO|NONE|Thanks for playing.|Logger shut down
cm8 commented 8 months ago

The issue is unrelated to 32/64 bit type/machine differences and simply stems from the fact, that the game provided INI file reader does not cope well with campaign/mission ini files that are encoded using DOS-style line endings (i.e. \r\n instead of plain \n).

There are two solutions to this:

The second option makes exchange of ini files between windows and linux users easier and the game more interoperable and, additionally, the patch for this is very small and overseeable. Please find it in d2tm-no-campaign-playable-on-linux.patch.zip or in the markup below.

diff --git a/ini.cpp b/ini.cpp
index cca17dc2..ca6c7c42 100644
--- a/ini.cpp
+++ b/ini.cpp
@@ -77,7 +77,8 @@ void INI_Sentence(FILE *f, char result[MAX_LINE_LENGTH]) {
         result[i] = '\0';

     while ((feof(f) == 0) && ((ch = fgetc(f)) != '\n')) {
-        result[pos] = ch;
+        if (ch != '\r')
+            result[pos] = ch;
         pos++;

         // do not allow strings greater then 80 characters. This check prevents a crash for