VCMI for Android

Just want to let you know. I’ve been working on android version for a couple of days and currently have a quite stable application (vcmi master (0.99), boost 1.61, ffmpeg master, SDL 2.0.5). If there aren’t any big issues, I’ll try to upload it to github in a few days.

Main changes in vcmi to make it working:

  • similarly to xyzz’s version, I compiled AI libraries together with main lib; android’s support for dlopen/dlsym is broken (it compiles and kind of works, but RTTI between libraries is broken),
  • I disabled StupidAI for now (currently always using BattleAI); is StupidAI important? the game seems to work correctly with BattleAI; I didn’t search a lot why it doesn’t work, but it seems that memory gets corrupted somewhere in there,
  • starting server / notifying client that server is ready can’t use boost IPC, so these messages go through java (using android’s Messenger for a simple IPC)

Currently testing only on my android 7.1, but in theory it should work on 4.1+.

I didn’t try to play any game longer than a week, but I think it is quite stable. Playing feels very weird, because map can’t be swiped and only viable way to scroll the map is through minimap.


I pretty sure that original idea to have StupidAI is to make it handle neutral creatures while BattleAI should be used for VCAI players.

Sadly this is not implemented: #2369

To be fair I not sure we should use it even on desktop since it’s cause compatability issues with Windows and we use networking for local game anyway.

So personally I would prefer to have it removed: #2560

PS: I sent you invite to our slack.

Yay~!
It’s great to hear the VCMI for Android will be alive again :slight_smile:
I have seen “oh so original” Heroes 3 “HD” version on Android at friend’s smartphone and… How should I put it, the laugh is still on… They have some bug on PL letters which suddenly cuts the texts making funny situations like “Troglodyci widz” which we could kinda translate to “Troglodyte Spectator” which in turn made my friend to extend the joke to the point of the image attached~
AHEM

Besides what SXX said, I guess it is important so the CPU will not think in full power which in turn will allow us to sometimes win :stuck_out_tongue:

If you will need testing reports I can test as hard as possible the game on Android 5.5 , 6.0 and probably some 4.x if I will search a bit.
I can’t test on Android 7.0 yet but since you have that version I guess that won’t be problem for now :slight_smile:

Have a nice and sunny day~

Kiiro Yakumo

Do you mean it should work correctly without boost IPC in the current version? Hmm, maybe I should check if it works on android. That replacement for IPC was a first thing that worked correctly so I went with it… (currently messaging works like this: client-cpp sends msg to client-java (and enters waiting loop) -> client-java -> server-java -> server-cpp -> (server-inits and messages back) -> server-java -> client-java -> client-cpp -> (atomic_bool gets switched and we exit waiting loop)).

I’ll leave stupidAI/battleAI like this for now. It needs to be checked but it doesn’t seem that important… For now I’d like to make building process easier and allow for basic config editiing like in standalone launcher.

As you can see, currently special characters are broken on my version as well. :wink: That’s probably because vcmi default to CP1252 codepage and I currently don’t change it to anything else.

I have access to various versions of androids at work, but for the last week I’ve been quite busy and haven’t been able to check yet. I’ll upload the project soon(ish) and of course you’re welcome to test. :slight_smile:

I was working on porting it to Android on my own too, but didn’t manage to even get it working, so won’t call it stable like yours.
I guess I’ll ditch whatever I have and try helping your project - as soon as you upload it somewhere :stuck_out_tongue:

I’m on Android 6.1, so I’m up for testing too.

No. I just mean on PC we don’t really need any IPC at all since we can just start process and then do everything over network. Shared memory is absolutely unnecessary dependency we better to drop.

Shared memory is used to signal that server has opened socket.

Hello, I downloaded VCMI for Android 0.97 and copied VCMI 0.99 windows version over. Played on THL 5000 Android 4.4.2 scenario All for one with music and it was quite fluently - only few small lags through game (played whole surface) Problem was subterranean gates were not working and happiness and morale buildings show confirm button without text…
…but Scrolling is working also on map and adventure window (sometimes it needed smooth touch to the edge of screen)
Looking forward to see address for the new vcmi playable version
Wish All of You the best…

Yeah it is, but using shared memory for that purpose is overkill. Especially when it’s doesn’t work properly at least on 2 of 4 platforms. We could just start process and attempt to connect until port to open.

True, but if they are just replaced with some other characters instead of cutting the rest of the text at this point, it’s still better than “HD” Edition (screenshot added in the attachment by the rule pics or it didn’t happen or whatever).
I DO admit that I have played Heroes of Might and Magic 3 long enough to read those cut messages from memory by first words and know what’s gonna happen next - most of them at least - but it’s still ugly to see that kind of bug which is probably still not fixed.

Take your time then~ I will prepare the Inferno army in the meantime~ :sunglasses:

Wow I bet an Asuran Golem with that kind of Android installed could prepare tea in the meantime :stuck_out_tongue:

EDIT #1
For some reason preview of the file is kinda fuzzy but if clicked it will show the image properly.


Sooo… first of all, disclaimer – I have no clue if this works for anyone. :stuck_out_tongue: I tried to make building process straightforward, but it’s still a horrible mess.

Compiled apks are here:
github.com/Fayth/vcmi-android/r … 3-debug.7z (for android 4.1+, only armeabi)
github.com/Fayth/vcmi-android/r … 3-debug.7z (for android 5.0+, all abis (arm, arm v7a, arm64, x86, x86_64))
Project code: github.com/Fayth/vcmi-android
Modified vcmi: github.com/Fayth/vcmi/tree/android-support

The app should tell you how to setup the data, but roughly it goes like this: start app -> app detects this is a first run and creates /vcmi-data folder -> you’re supposed to put h3 data there (+optionally mods as well) -> restart the app -> app unpacks internal configs (including extra resolutions submod) to internal location -> start game (it’ll probably hang for few seconds before getting to main menu, because data-loading thread in CMT is joined to the ui thread – this should be changed at some point to load data without blocking main thread).

If you want to try to build it yourself, the rough outline is here: github.com/Fayth/vcmi-android/b … ilding.txt (I’m on win10, it probably should kind of work on linux (except maybe some permission magic in the scripts?), probably won’t work on older windows (needs win10 bash for ffmpeg build) and I have no clue abous macs)

I’ll try to answer tomorrow if you have any questions etc…

Some thoughts/details about the current state of the project in totally random order:

  • currently special characters seem to work correctly for me no matter if I choose CP1250 or CP1252; I’m not sure if this setting is correctly applied…
  • building ffmpeg is hell; fortunately someone did it before and I mostly reused his confs ( github.com/yesimroy/build-scrip … ndroid-ndk ),
  • I managed to run the game on my android 7.1, an 4.4.2 and a very old 4.1 (needed some extra hacks to get it running and the game is very slow :wink: )
  • I’ll probably take a break from coding this for a few days,
  • vcmi’s repository.json is broken and can’t be parsed without some non-strict mode (missing commas),
  • I tried adding WoG and I think it worked correctly (didn’t try to play a lot, but generated the map and didn’t crash),
  • RMG takes a very long time,
  • Higher resolutions should work, but the game is noticeably slower,
  • Few times I encountered the problem where the game wouldn’t start (both client and server were ready, last thing in the logs are successful autosave, then the game just idled on the loading screen and didn’t move to the game),
  • I’m probably not the best guy to handle contributions/requests etc and don’t really plan to make extensive use of github, so if you want I can add you as owners of the repo or whatever (not sure how, but I assume it’s possible).
  • I tried to gather are configurable paths into one place (vcmiconf.in), but of course there’s a possibility that I forgot about some of them… so if you find some hardcoded absolute paths then let me know :wink:
  • I think that vcmi like to randomly (?) remove my settings from settings.json reverting selected screen res/codepage (possible during a crash?)
  • this is the first time I’ve ever used python, so not sure about scripts quality :wink:

One thing we must decide on is where to store build scripts and configuration.

From one point it’s would be handy to have it in main repository too since then we can at least cover develop itself with Travis builds for Android (no reason to check it for pull requests since they took long enough already).

In same time I not sure how to make it all clean. :wink:

BTW any chance you have any device with Cyanogenmod?

I tried to install it, but looks like even with permissions given it’s can’t access or create directory. It’s says data must be put into “/storage/emulated/0/vcmi-data/Data”, but I suppose for whatever reason user under which application running don’t have the access there.

Though I’m pretty lame on how Android work so testing all of this over SSH as root. :mrgreen:

UPD: Find out that vcmi-data directory in root of internal memory wasn’t visible for file management over MTP for some reason. It’s works via with SSH though.

Now stuck at “Error: Heroes III data was not found!” :frowning:

I dooon’t think so. Personally I’ve never used any custom ROMs. I can ask around but I don’t think I can find something.

This is normal. It’ll usually be storage/emulated for devices without sdcard and something like /mnt/sdcard for the rest. This should be a root folder that is accessible though mtp. As far as I remember, Android does have some problem with syncing the data automatically, maybe that’s why it wasn’t visible… I can try to check later if there’s something to force syncing.

Hm, that’s a message from the actual game, right? So launcher detected that the files were added correctly. Are you able to access logs from logcat (through something like “adb logcat -f output.txt”)? There should be a line “Accessing data root: /storage/emulated/0/vcmi-data” – that’s the path that gets passed to VCMIDirs. Is it correct?

Yeah obviously VCMI was able to write cache. Ok it’s working now. Looks like I just mess and put my “Data” inside “Data” somehow.

It’s working now except screen is all red. E.g in taskbar (running app list) it’s looks fine and it’s also show proper colors for a second when I’m lock screen, but when it’s open in full screen colors are broken.

This is CyanogenMod 13 on Xiaomi Redmi Note 3.

PS: So it’s looks pretty much like this bug.

So far so good~
The game loads, starts, all is fine. The game goes in english language but I’m not mad, I believe I can understand english enough to play fluently :stuck_out_tongue:
For now I had only RoE + AB + SoD files nearby so I tested that a bit.
I will try to test WoG soon because why not, the intro in WoG is worth of trying :3
I have launched it on Huawei P9 with Android 6.0 onboard, I will try with Samsung S2+ with Android 5.5 (Resurrection Remix) soon, I have to clean some space first.
In theory I can try with Samsung Galaxy S1 with uh… There is CyanogenMod installed but I forgot exact numbers, I’m pretty sure it has Android from 4 branch but I’m yet to check, I simply forgot, forgive me :stuck_out_tongue:

To set up the name one has to do it the classic way (unless I don’t know about something):

  1. Multiplayer mode
  2. Backspace a lot, enter the name (it may be in blind mode because keyboard will slide in just like that)
  3. After typing the name, press “back” whatever your phone has either <- or <| or whatnot, ONCE
  4. Press Host button, the game will probably crash but fear not, the name will be memorised for next time you launch the game.
  5. Enjoy your player name replaced with proper name :slight_smile:

Back to the game! (This time Tower castle because golems~!)

More devices testing soon/later.

Black screen on my SGS4, Android v5 stock.
Any other selection differ than “Start VCMI” in launcher lead to crash of vcmi (Unfortunately VCMI, has stopped).
HMMIII data taken from my PC, where VCMI works with it.

Hello. First time tried install vcmi for android. My shitty china device show me black screen. I waiting few minutes but nothing not happing. Some tech info about pixs.ru/showimage/Screenshot_725 … 181784.png

  1. May be fault what i have russian version heroes?
  2. Or may be need install apk for android4?
    Idk.

Get and upload the logs from “cache” directory on your SD card next to where you put “Data” folder.
They’ll tell why it’s crashing in case VCMI itself managed to start.

Sounds like SDL incorrectly chooses pixel format. I didn’t see any calls to methods described in that bug report in vcmi. Possibly sdl receives some unhandled pixel format from the system here github.com/Fayth/vcmi-android/b … java#L1426 (and then it defaults to rgb565). There should be an entry in logcat logs with “pixel format xxx” if you want to check it.
(edit ~ actually, there’s one direct pixelformat manipulation in video handler, but I think if that was a problem, it would affect only the videos, not the whole game)

Yay, so it’s not only working for me. :wink:

Hm, the language should be based on your data files… It’s not in english for me (unless I add WoG).

I probably should have added saving launcher logs to a file, because currently launcher logs can only be retrieved through adb (or shell).

Black screen issue sounds more like some vcmi/SDL initialization problem, but it’s hard to say anything without any details. There might be some useful info in client log (in vcmi-data/cache, as SXX noted).

I might try to setup some emulators tomorrow to try to reproduce some problems (I wonder if there’s a way to use cyanogen emulator :wink: ).