Skip to content

Commit

Permalink
Merge pull request #654 from ddrsoul/VCMI-1.6.0dev-update
Browse files Browse the repository at this point in the history
Vcmi 1.6.0dev update
  • Loading branch information
Cebion authored Sep 15, 2024
2 parents 078c64f + 3cebe14 commit 62201db
Show file tree
Hide file tree
Showing 373 changed files with 36,182 additions and 26,208 deletions.
53 changes: 51 additions & 2 deletions ports/vcmi/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,60 @@
## Notes

Thanks to [VCMI Team](https://github.com/vcmi/vcmi) for the open source Heroes of Might and Magic III engine that makes this possible. Also thanks to the [kloptops](https://github.com/kloptops/Portmaster-misc/tree/main/VCMI) for the porting work for portmaster.
Thanks to [VCMI Team](https://github.com/vcmi/vcmi) for the open source Heroes of Might and Magic III engine that makes this possible. Also thanks to the @kloptops for the porting work for portmaster.
Update to 1.6.0-dev was made by @ddrsoul with great help of @kloptops , @kotzebuedog and all VCMI and PortMaster community.

## Detailed Instructions

You need to add required game files either from CD1 & CD2, GoG or an installed copy of the game. <br> This requires about 2-3 gb of free space. For the gog version copy setup_heroes_of_might_and_magic_3_complete_4.0_(28740)-1.bin and setup_heroes_of_might_and_magic_3_complete_4.0_(28740).exe into ports/vcmi. <br> For the cd version copy the contents of cd1 into ports/vcmi/cd1 and cd2 into ports/vcmi/cd2. For the installed version copy installed game files into ports/vcmi/install.
You need to add required game files either from CD1 & CD2, GoG or an installed copy of the game.
This requires about 2-3 gb of free space. For the gog version copy setup_heroes_of_might_and_magic_3_complete_4.0_(28740)-1.bin and setup_heroes_of_might_and_magic_3_complete_4.0_(28740).exe into ports/vcmi.
For the cd version copy the contents of cd1 into ports/vcmi/cd1 and cd2 into ports/vcmi/cd2.
For the installed version copy installed game files into ports/vcmi/install.

## Controls

VCMI supports gamepad controls.
Controller mapping can be redone in ./config/shortcutsConfig.json

Some additional settings can be made in ./save/settings.json:
"input" : {
"enableController" : true // turn controller detection on/off
"controllerTriggerTreshold" : 0.3 // triggers, e.g. L2/R2 on PS controller would activate if they are pressed to 30%
"controllerAxisDeadZone" : 0.2 // analog sticks would activate if they are at 20% from resting position
"controllerAxisFullZone" : 1.0 // analog sticks would be maxed-out when they are at 100% from resting position
"controllerAxisSpeed" : 1000 // analog sticks would move at 1000 px/second
"controllerAxisScale" : 2 // adds acceleration to analog sticks. So, half-pressed stick would actually move not at 500 px/second, but 250 px/s IIRC. Changing to 1 would make analog sticks linear
}

## Building

```
git clone --recursive https://github.com/vcmi/vcmi.git
```

replace ./server/processors/PlayerMessageProcessor.cpp:653 with

```
std::string cheatTrimmed = boost::trim_copy(cheat);
boost::split(words, cheatTrimmed, boost::is_any_of("\t\r\n "));
```

put DATA_PATHS.diff inside ./vcmi folder

```
git apply DATA_PATHS.diff
mkdir build
cd build
cmake .. -DBIN_DIR:FILE="bin" -DCMAKE_INSTALL_PREFIX:FILE="." -DCOPY_CONFIG_ON_BUILD="ON" -DENABLE_DEBUG_CONSOLE="OFF" -DENABLE_EDITOR="OFF" -DENABLE_ERM="OFF" -DENABLE_GITVERSION="OFF" -DENABLE_LAUNCHER="OFF" -DENABLE_LUA="OFF" -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DENABLE_MONOLITHIC_INSTALL="OFF" -DENABLE_MULTI_PROCESS_BUILDS="ON" -DENABLE_NULLKILLER_AI="ON" -DENABLE_PCH="OFF" -DENABLE_SINGLE_APP_BUILD="OFF" -DENABLE_STATIC_AI_LIBS="OFF" -DENABLE_STRICT_COMPILATION="OFF" -DENABLE_TEST="OFF" -DENABLE_TRANSLATIONS="OFF" -DFL_BACKTRACE="ON" -DFL_BUILD_BINARY="OFF" -DFL_BUILD_SHARED="OFF" -DFL_BUILD_STATIC="ON" -DFL_BUILD_TESTS="OFF" -DFL_USE_FLOAT="OFF" -DFORCE_BUNDLED_FL="ON"
make
```

## Thanks

A special thanks to the excellent folks on the [AmberELEC discord](https://discord.com/invite/R9Er7hkRMe), especially [Cebion](https://github.com/Cebion) for all the testing.


10 changes: 8 additions & 2 deletions ports/vcmi/VCMI.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ printf "\033c" > $CUR_TTY
printf "\033c" > $CUR_TTY
## RUN SCRIPT HERE

if [ -f "$GAMEDIR/libs/libicudata.so.63.bz2" ]; then
bzip2 -fd "$GAMEDIR/libs/libicudata.so.63.bz2"
fi

if [[ ! -d "${GAMEDIR}/data/" ]]; then
FILES_TO_REMOVE=()
BUILDER_OPTIONS=()
Expand Down Expand Up @@ -63,9 +67,11 @@ echo "Starting game." > $CUR_TTY

export PORTMASTER_HOME="${GAMEDIR}"
export LD_LIBRARY_PATH="${GAMEDIR}/libs:${LD_LIBRARY_PATH}"
export SDL_GAMECONTROLLERCONFIG="$sdl_controllerconfig"
$ESUDO chmod 666 /dev/uinput

$GPTOKEYB "MainGUI" -c vcmi.gptk &
bin/vcmiclient
$GPTOKEYB "vcmiclient" &
./bin/vcmiclient 2>&1 | $ESUDO tee -a ./log.txt

$ESUDO kill -9 $(pidof gptokeyb)
$ESUDO killall -9 tee
Expand Down
1 change: 1 addition & 0 deletions ports/vcmi/vcmi/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

142 changes: 142 additions & 0 deletions ports/vcmi/vcmi/DATA_PATHS.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
diff --git a/Global.h b/Global.h
index 6fa656a17..d9e46738f 100644
--- a/Global.h
+++ b/Global.h
@@ -15,6 +15,8 @@
// Fixed width bool data type is important for serialization
static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");

+# define VCMI_PORTMASTER
+
/* ---------------------------------------------------------------------------- */
/* System detection. */
/* ---------------------------------------------------------------------------- */
diff --git a/client/gui/CursorHandler.cpp b/client/gui/CursorHandler.cpp
index 146f27b9c..696a8820f 100644
--- a/client/gui/CursorHandler.cpp
+++ b/client/gui/CursorHandler.cpp
@@ -23,7 +23,7 @@

std::unique_ptr<ICursor> CursorHandler::createCursor()
{
-#if defined(VCMI_MOBILE)
+#if defined(VCMI_MOBILE) || defined(VCMI_PORTMASTER)
if (settings["general"]["userRelativePointer"].Bool())
return std::make_unique<CursorSoftware>();
#endif
diff --git a/lib/VCMIDirs.cpp b/lib/VCMIDirs.cpp
index 1eaadefc2..340c13584 100644
--- a/lib/VCMIDirs.cpp
+++ b/lib/VCMIDirs.cpp
@@ -579,6 +579,89 @@ void VCMIDirsAndroid::init()
nativePath = envHelper.callStaticStringMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "nativePath");
IVCMIDirsUNIX::init();
}
+#elif defined(VCMI_PORTMASTER)
+class VCMIDirsPM : public IVCMIDirsUNIX
+{
+public:
+ bfs::path userDataPath() const override;
+ bfs::path userCachePath() const override;
+ bfs::path userConfigPath() const override;
+
+ std::vector<bfs::path> dataPaths() const override;
+
+ bfs::path libraryPath() const override;
+ bfs::path binaryPath() const override;
+
+ std::string libraryName(const std::string& basename) const override;
+};
+
+bfs::path VCMIDirsPM::userDataPath() const
+{
+ const char* homeDir;
+ if((homeDir = getenv("PORTMASTER_HOME")))
+ return bfs::path(homeDir) / "data";
+ else
+ return bfs::path(".") / "data";
+}
+bfs::path VCMIDirsPM::userCachePath() const
+{
+ // $XDG_CACHE_HOME, default: $HOME/.cache
+ const char * tempResult;
+ if ((tempResult = getenv("PORTMASTER_HOME")))
+ return bfs::path(tempResult) / "cache";
+ else
+ return bfs::path(".") / "cache";
+}
+bfs::path VCMIDirsPM::userConfigPath() const
+{
+ // $XDG_CONFIG_HOME, default: $HOME/.config
+ const char * tempResult;
+ if ((tempResult = getenv("PORTMASTER_HOME")))
+ return bfs::path(tempResult) / "save";
+ else
+ return bfs::path(".") / "save";
+}
+
+std::vector<bfs::path> VCMIDirsPM::dataPaths() const
+{
+ // $XDG_DATA_DIRS, default: /usr/local/share/:/usr/share/
+
+ // construct list in reverse.
+ // in specification first directory has highest priority
+ // in vcmi fs last directory has highest priority
+ std::vector<bfs::path> ret;
+ const char * tempResult;
+ if ((tempResult = getenv("PORTMASTER_HOME")))
+ {
+ ret.push_back(bfs::path(tempResult) / "data");
+ ret.push_back(bfs::path(tempResult));
+ }
+
+ ret.push_back(bfs::path(".") / "data");
+ ret.push_back(bfs::path("."));
+ return ret;
+}
+
+bfs::path VCMIDirsPM::libraryPath() const
+{
+ const char * tempResult;
+ if ((tempResult = getenv("PORTMASTER_HOME")))
+ return bfs::path(tempResult) / "libs";
+ else
+ return M_LIB_DIR;
+}
+
+bfs::path VCMIDirsPM::binaryPath() const
+{
+ const char * tempResult;
+ if ((tempResult = getenv("PORTMASTER_HOME")))
+ return bfs::path(tempResult) / "bin";
+ else
+ return M_BIN_DIR;
+}
+
+std::string VCMIDirsPM::libraryName(const std::string& basename) const { return "lib" + basename + ".so"; }
+
#elif defined(VCMI_XDG)
class VCMIDirsXDG : public IVCMIDirsUNIX
{
@@ -700,6 +783,8 @@ namespace VCMIDirs
static VCMIDirsWIN32 singleton;
#elif defined(VCMI_ANDROID)
static VCMIDirsAndroid singleton;
+ #elif defined(VCMI_PORTMASTER)
+ static VCMIDirsPM singleton;
#elif defined(VCMI_XDG)
static VCMIDirsXDG singleton;
#elif defined(VCMI_MAC)
diff --git a/scripting/lua/LuaScriptingContext.cpp b/scripting/lua/LuaScriptingContext.cpp
index 5c351f623..6f60207ad 100644
--- a/scripting/lua/LuaScriptingContext.cpp
+++ b/scripting/lua/LuaScriptingContext.cpp
@@ -46,7 +46,7 @@ LuaContext::LuaContext(const Script * source, const Environment * env_):
{LUA_TABLIBNAME, luaopen_table},
{LUA_STRLIBNAME, luaopen_string},
{LUA_MATHLIBNAME, luaopen_math},
- {LUA_BITLIBNAME, luaopen_bit}
+ {LUA_BITLIBNAME, luaopen_bit32}
};

for(const luaL_Reg & lib : STD_LIBS)
1 change: 1 addition & 0 deletions ports/vcmi/vcmi/Mods/vcmi/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ports/vcmi/vcmi/Mods/vcmi/Data/lobby/iconFolder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ports/vcmi/vcmi/Mods/vcmi/Data/lobby/iconPlayer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ports/vcmi/vcmi/Mods/vcmi/Data/lobby/iconSend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ports/vcmi/vcmi/Mods/vcmi/Data/lobby/townBorderBig.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ports/vcmi/vcmi/Mods/vcmi/Data/lobby/townBorderBigActivated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ports/vcmi/vcmi/Mods/vcmi/Data/lobby/townBorderBigGrayedOut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ports/vcmi/vcmi/Mods/vcmi/Data/lobby/townBorderSmallActivated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 39 additions & 39 deletions ports/vcmi/vcmi/Mods/vcmi/Data/s/std.verm
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
VERM
; standard verm file, global engine things should be put here
!?PI;
; example 1 --- Hello World
![print ^Hello world!^]
; example 2 --- simple arithmetics
![defun add [x y] [+ x y]]
![print [add 2 3]]
; example 3 --- semantic macros
![defmacro do-n-times [times body]
`[progn
[setq do-counter 0]
[setq do-max ,times]
[do [< do-counter do-max]
[progn
[setq do-counter [+ do-counter 1]]
,body
]
]
]
]
![do-n-times 4 [print ^tekst\n^]]
; example 4 --- conditional expression
![if [> 2 1] [print ^Wieksze^] [print ^Mniejsze^]]
; example 5 --- lambda expressions
![[lambda [x y] [if [> x y] [print ^wieksze^] [print ^mniejsze^]]] 2 3]
; example 6 --- resursion
![defun factorial [n]
[if [= n 0] 1
[* n [factorial [- n 1]]]
]
]
VERM
; standard verm file, global engine things should be put here

!?PI;
; example 1 --- Hello World
![print ^Hello world!^]

; example 2 --- simple arithmetics
![defun add [x y] [+ x y]]
![print [add 2 3]]

; example 3 --- semantic macros
![defmacro do-n-times [times body]
`[progn
[setq do-counter 0]
[setq do-max ,times]
[do [< do-counter do-max]
[progn
[setq do-counter [+ do-counter 1]]
,body
]
]
]
]
![do-n-times 4 [print ^tekst\n^]]


; example 4 --- conditional expression
![if [> 2 1] [print ^Wieksze^] [print ^Mniejsze^]]

; example 5 --- lambda expressions
![[lambda [x y] [if [> x y] [print ^wieksze^] [print ^mniejsze^]]] 2 3]

; example 6 --- resursion
![defun factorial [n]
[if [= n 0] 1
[* n [factorial [- n 1]]]
]
]
![print [factorial 8]]
26 changes: 13 additions & 13 deletions ports/vcmi/vcmi/Mods/vcmi/Data/s/testy.erm
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
ZVSE
!?PI;
!!VRv2777:S4;
!!DO1/0/5/1&v2777<>1:P0;
!?FU1;
!!VRv2778:Sx16%2;
!!IF&x16>3:M^Hello world number %X16! To duza liczba^;
!!IF&v2778==0&x16<=3:M^Hello world number %X16! To mala parzysta liczba^;
!!IF&v2778==1&x16<=3:M^Hello world number %X16! To mala nieparzysta liczba^;
!?PI;
!!VRz10:S^Composed hello ^;
ZVSE
!?PI;
!!VRv2777:S4;
!!DO1/0/5/1&v2777<>1:P0;

!?FU1;
!!VRv2778:Sx16%2;
!!IF&x16>3:M^Hello world number %X16! To duza liczba^;
!!IF&v2778==0&x16<=3:M^Hello world number %X16! To mala parzysta liczba^;
!!IF&v2778==1&x16<=3:M^Hello world number %X16! To mala nieparzysta liczba^;

!?PI;
!!VRz10:S^Composed hello ^;
!!IF:M^%Z10%%world%%, v2777=%V2777, v2778=%V2778!^;
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 1 addition & 8 deletions ports/vcmi/vcmi/Mods/vcmi/Sprites/PortraitsLarge.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,6 @@
{ "frame" : 152, "file" : "HPL009SH.bmp"},
{ "frame" : 153, "file" : "HPL008SH.bmp"},
{ "frame" : 154, "file" : "HPL001SH.bmp"},
{ "frame" : 155, "file" : "HPL131DM.bmp"},
{ "frame" : 156, "file" : "HPL129MK.bmp"},
{ "frame" : 157, "file" : "HPL002SH.bmp"},
{ "frame" : 158, "file" : "HPL132Wl.bmp"},
{ "frame" : 159, "file" : "HPL133Nc.bmp"},
{ "frame" : 160, "file" : "HPL134Nc.bmp"},
{ "frame" : 161, "file" : "HPL135Wi.bmp"},
{ "frame" : 162, "file" : "HPL136Wi.bmp"}
{ "frame" : 155, "file" : "HPL131DM.bmp"}
]
}
15 changes: 4 additions & 11 deletions ports/vcmi/vcmi/Mods/vcmi/Sprites/PortraitsSmall.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,9 @@
{ "frame" : 151, "file" : "HPS007SH.bmp"},
{ "frame" : 152, "file" : "HPS009SH.bmp"},
{ "frame" : 153, "file" : "HPS008SH.bmp"},
{ "frame" : 154, "file" : "HPS001SH.bmp"},
{ "frame" : 155, "file" : "HPS131DM.bmp"},
{ "frame" : 156, "file" : "HPS129MK.bmp"},
{ "frame" : 157, "file" : "HPS002SH.bmp"},
{ "frame" : 158, "file" : "HPS132Wl.bmp"},
{ "frame" : 159, "file" : "HPS133Nc.bmp"},
{ "frame" : 160, "file" : "HPS134Nc.bmp"},
{ "frame" : 161, "file" : "HPS135Wi.bmp"},
{ "frame" : 162, "file" : "HPS136Wi.bmp"},
{ "frame" : 163, "file" : "HPSRAND1.bmp"}, //random hero
{ "frame" : 164, "file" : "HPSRAND6.bmp"} //no hero
{ "frame" : 154, "file" : "HPS001SH.bmp"},
{ "frame" : 155, "file" : "HPS131DM.bmp"},
{ "frame" : 156, "file" : "HPSRAND1.bmp"}, // random hero
{ "frame" : 157, "file" : "HPSRAND6.bmp"} // no hero
]
}
Loading

0 comments on commit 62201db

Please sign in to comment.