Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo support? #38

Open
neuromancer opened this issue Sep 6, 2020 · 3 comments
Open

Demo support? #38

neuromancer opened this issue Sep 6, 2020 · 3 comments
Assignees

Comments

@neuromancer
Copy link

I tried the latest revision (d28041e) with the "Age of Empires Demo" (from here).
As expected, it didn't work, since this port has a fixed data location using the cdrom path. The installed demo has this structure:

├── aelaunch.dll
├── AoEHlp.dll
├── campaign
│   ├── Armies at War, A Combat Showcase.cpn
│   └── Reign of the Hittites.cpn
├── data
│   ├── aggressive 3 attackers.per
│   ├── aggressive no defend.per
│   ├── aggressive.per
│   ├── aichall.ai
│   ├── aoe.ply
│   ├── Archers Bronze.ai
│   ├── Archers Iron.ai
│   ├── Assyria Ballista.ai
│   ├── Assyria Bowmen.ai
│   ├── Babylon Scouts.ai
│   ├── Babylon Swordsmen.ai
│   ├── Border.drs
│   ├── Cav Archer Iron.ai
│   ├── Cavalry Bronze.ai
│   ├── Cavalry Iron.ai
│   ├── Choson Axemen.ai
│   ├── Choson Swordsmen.ai
│   ├── closedpw.exe
│   ├── Death Match Assyria.ai
│   ├── Death Match Babylon.ai
│   ├── Death Match Choson.ai
│   ├── Death Match Egypt.ai
│   ├── Death Match Greek.ai
│   ├── Death Match Hittite.ai
│   ├── Death Match Minoa.ai
│   ├── Death Match Persia.ai
│   ├── Death Match Phoenicia.ai
│   ├── Death Match Shang.ai
│   ├── Death Match Sumeria.ai
│   ├── Death Match Yamato.ai
│   ├── Default.ai
│   ├── Default.cty
│   ├── Default.per
│   ├── Defensive.per
│   ├── Egypt Chariots.ai
│   ├── Egypt War Elephants.ai
│   ├── Elephant Archer Iron.ai
│   ├── empires.dat
│   ├── graphics.drs
│   ├── Greek Phalanx.ai
│   ├── Hittite Bowmen.ai
│   ├── Hittite Horse Archers.ai
│   ├── Immortal Assyria.ai
│   ├── Immortal Egypt.ai
│   ├── Immortal Greek.ai
│   ├── Immortal Minoa.ai
│   ├── Immortal Sumeria.ai
│   ├── Immortal Yamato.ai
│   ├── Infantry Bronze.ai
│   ├── Infantry Stone.ai
│   ├── Infantry Tool.ai
│   ├── Interfac.drs
│   ├── Minoa Composite bowmen.ai
│   ├── Passive Aggressive.per
│   ├── Passive.per
│   ├── Persia Elephant Archers.ai
│   ├── Phalanx Bronze.ai
│   ├── Phalanx Iron.ai
│   ├── Phoenicia Elephants.ai
│   ├── Priest Bronze.ai
│   ├── Priest Iron.ai
│   ├── rules.rps
│   ├── shadow.col
│   ├── Shang Cavalry.ai
│   ├── Shang Clubmen.ai
│   ├── Shang Heavy Cavalry.ai
│   ├── sounds.drs
│   ├── Sumeria Catapults.ai
│   ├── Sumeria Scouts.ai
│   ├── super aggressive.per
│   ├── Terrain.drs
│   ├── TILEEDGE.DAT
│   ├── Trireme Bronze.ai
│   ├── Trireme Iron.ai
│   ├── War Elephant Iron.ai
│   ├── wonderonly.ai
│   └── Yamato Heavy Cavalry.ai
├── docs
│   ├── assyrian.doc
│   ├── bablnian.doc
│   ├── choson.doc
│   ├── egyptian.doc
│   ├── greek.doc
│   ├── hittite.doc
│   ├── minoan.doc
│   ├── persian.doc
│   ├── phnician.doc
│   ├── README.doc
│   ├── shang.doc
│   ├── sumerian.doc
│   └── yamato.doc
├── empires.exe
├── EMPIRES.HLP
├── eula.txt
├── fonts
│   ├── arialbd.ttf
│   ├── arial.ttf
│   ├── comicbd.ttf
│   ├── comic.ttf
│   ├── coprgtb.ttf
│   └── coprgtl.ttf
├── language.dll
├── learn
│   └── Learn.txt
├── savegame
│   └── SAVEGAME.TXT
├── scenario
│   ├── Multiplayer Rumble (8-Player).scn
│   └── scenario.inf
├── SETUPENU.DLL
├── sound
│   ├── BIRD.WAV
│   ├── desert1.WAV
│   ├── forest1.wav
│   ├── LOST.MID
│   ├── MUSIC1.MID
│   ├── MUSIC2.MID
│   ├── MUSIC3.MID
│   ├── MUSIC4.MID
│   ├── MUSIC5.MID
│   ├── MUSIC6.MID
│   ├── MUSIC7.MID
│   ├── MUSIC8.MID
│   ├── MUSIC9.MID
│   ├── ocean1.wav
│   ├── OPEN.MID
│   ├── wind1.WAV
│   ├── wind2.wav
│   └── WON.MID
└── UNINSTAL.EXE

I modified a little the paths in the code to match what we have. This is the diff:

diff --git a/empiresx/fs.cpp b/empiresx/fs.cpp
index f6335bb..868916e 100644
--- a/empiresx/fs.cpp
+++ b/empiresx/fs.cpp
@@ -136,16 +136,10 @@ bool FS::find_cdrom(OS &os) {
                }
        }
 #else
-       path_cdrom = "/media/cdrom/";
-       if (std::ifstream("/media/cdrom/SYSTEM/FONTS/ARIAL.TTF", std::ios::binary))
+       path_cdrom = "./";
+       if (std::ifstream(path_cdrom + "FONTS/ARIAL.TTF", std::ios::binary))
                return true;
-       if (std::ifstream("/media/cdrom/system/fonts/arial.ttf", std::ios::binary))
-               return true;
-
-       path_cdrom = "/media/" + os.username + "/cdrom/";
-       if (std::ifstream(path_cdrom + "SYSTEM/FONTS/ARIAL.TTF", std::ios::binary))
-               return true;
-       if (std::ifstream(path_cdrom + "system/fonts/arial.ttf", std::ios::binary))
+       if (std::ifstream(path_cdrom + "fonts/arial.ttf", std::ios::binary))
                return true;
 #endif
        return false;
@@ -158,20 +152,20 @@ void FS::init(OS &os) {
 
 Font FS::open_ttf(const std::string &name, int ptsize) {
        std::string base(name);
-       std::string path(path_cdrom + "system/fonts/" + base), orig(path);
+       std::string path(path_cdrom + "/fonts/" + base), orig(path);
        TTF_Font *f;
 
        if ((f = TTF_OpenFont(path.c_str(), ptsize)) != NULL)
                return Font(f, ptsize);
 
        tolower(base);
-       path = path_cdrom + "system/fonts/" + base;
+       path = path_cdrom + "/fonts/" + base;
 
        if ((f = TTF_OpenFont(path.c_str(), ptsize)) != NULL)
                return Font(f, ptsize);
 
        toupper(base);
-       path = path_cdrom + "SYSTEM/FONTS/" + base;
+       path = path_cdrom + "/FONTS/" + base;
 
        if ((f = TTF_OpenFont(path.c_str(), ptsize)) != NULL)
                return Font(f, ptsize);
@@ -181,20 +175,20 @@ Font FS::open_ttf(const std::string &name, int ptsize) {
 
 DRS FS::open_drs(const std::string &name, bool map) {
        std::string base(name);
-       std::string path(path_cdrom + "game/data/" + base), orig(path);
+       std::string path(path_cdrom + "data/" + base), orig(path);
        iofd fd;
 
        if ((fd = iofd_open(path)) != FD_INVALID)
                return DRS(path, fd, map);
 
        tolower(base);
-       path = path_cdrom + "game/data/" + base;
+       path = path_cdrom + "data/" + base;
 
        if ((fd = iofd_open(path)) != FD_INVALID)
                return DRS(path, fd, map);
 
        toupper(base);
-       path = path_cdrom + "GAME/DATA/" + base;
+       path = path_cdrom + "DATA/" + base;
 
        if ((fd = iofd_open(path)) != FD_INVALID)
                return DRS(path, fd, map);
@@ -204,20 +198,20 @@ DRS FS::open_drs(const std::string &name, bool map) {
 
 PE FS::open_pe(const std::string &name) {
        std::string base(name);
-       std::string path(path_cdrom + "game/" + base), orig(path);
+       std::string path(path_cdrom + base), orig(path);
        iofd fd;
 
        if ((fd = iofd_open(path)) != FD_INVALID)
                return PE(path, fd);
 
        tolower(base);
-       path = path_cdrom + "game/" + base;
+       path = path_cdrom + base;
 
        if ((fd = iofd_open(path)) != FD_INVALID)
                return PE(path, fd);
 
        toupper(base);
-       path = path_cdrom + "GAME/" + base;
+       path = path_cdrom + base;
 
        if ((fd = iofd_open(path)) != FD_INVALID)
                return PE(path, fd);
@@ -227,28 +221,28 @@ PE FS::open_pe(const std::string &name) {
 
 Mix_Music *FS::open_msc(const std::string &name) {
        std::string base(name);
-       std::string path(path_cdrom + "game/sound/" + base);
+       std::string path(path_cdrom + "sound/" + base);
        Mix_Music *msc;
 
        if ((msc = Mix_LoadMUS(path.c_str())) != 0)
                return msc;
 
        toupper(base);
-       path = path_cdrom + "GAME/SOUND/" + base;
+       path = path_cdrom + "SOUND/" + base;
 
        return Mix_LoadMUS(path.c_str());
 }
 
 Mix_Chunk *FS::open_wav(const std::string &name) {
        std::string base(name);
-       std::string path(path_cdrom + "game/sound/" + base);
+       std::string path(path_cdrom + "sound/" + base);
        Mix_Chunk *sfx;
 
        if ((sfx = Mix_LoadWAV(path.c_str())) != 0)
                return sfx;
 
        toupper(base);
-       path = path_cdrom + "GAME/SOUND/" + base;
+       path = path_cdrom + "SOUND/" + base;
 
        return Mix_LoadWAV(path.c_str());
 }

However, this still fails with:

Could not load animation 50100: bad id

Is it possible to support the demo? It will allow users to easily test this reimplementation without buying the full game.

@FolkertVanVerseveld
Copy link
Owner

Indeed, it would be nice to allow using the demo version without buying the full game.
As you mentioned, the codebase currently has many hardcoded paths that I will get rid of as the engine improves. I will try to incorporate the changes you've pasted (probably this weekend). Thanks for testing my project!

@neuromancer
Copy link
Author

Neat!, let me know if you need any testing. I can also prepare some script/instructions on how to use it (as a PR).

@FolkertVanVerseveld
Copy link
Owner

Sorry for the late reply. Life has other plans for me at the moment, but will definitely start working on this next weekend!

@FolkertVanVerseveld FolkertVanVerseveld self-assigned this Sep 28, 2020
@FolkertVanVerseveld FolkertVanVerseveld added this to Brain farts in Playable prototype via automation Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Playable prototype
  
Brain farts
Status: No status
Development

No branches or pull requests

2 participants