diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..cd2285f
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,178 @@
+name: Release
+
+on:
+ release:
+ types:
+ - released
+
+jobs:
+ verify_version_number:
+ runs-on: ubuntu-latest
+ steps:
+ - id: get_version
+ name: Get version
+ uses: jannemattila/get-version-from-tag@v1
+
+ - name: Verify version number
+ run: |
+ set -e
+ grep -F '"version": "${{ steps.get_version.outputs.version }}"' factorio/info.json
+ grep -F 'VERSION "${{ steps.get_version.outputs.version }}"' mumble/CMakeLists.txt
+ grep -F "${{ steps.get_version.outputs.version }}" mumble/manifest.xml
+ grep -F 'char *VERSION = "${{ steps.get_version.outputs.version }}";' mumble/plugin.c
+
+ build:
+ runs-on: ${{ matrix.os }}
+
+ strategy:
+ # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
+ fail-fast: false
+
+ # Set up a matrix to run the following 3 configurations:
+ # 1.
+ # 2.
+ # 3.
+ #
+ # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
+ matrix:
+ os: [ubuntu-latest, windows-latest]
+ build_type: [Release]
+ c_compiler: [gcc, clang, cl]
+ include:
+ - os: windows-latest
+ c_compiler: cl
+ cpp_compiler: cl
+ - os: ubuntu-latest
+ c_compiler: gcc
+ cpp_compiler: g++
+ - os: ubuntu-latest
+ c_compiler: clang
+ cpp_compiler: clang++
+ exclude:
+ - os: windows-latest
+ c_compiler: gcc
+ - os: windows-latest
+ c_compiler: clang
+ - os: ubuntu-latest
+ c_compiler: cl
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Set reusable strings
+ # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
+ id: strings
+ shell: bash
+ run: |
+ echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
+ echo "build-input-dir=${{ github.workspace }}/mumble" >> "$GITHUB_OUTPUT"
+
+ - name: Configure CMake
+ # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
+ # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
+ run: >
+ cmake -B ${{ steps.strings.outputs.build-output-dir }}
+ -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
+ -DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
+ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
+ -S ${{ steps.strings.outputs.build-input-dir }}
+
+ - name: Build
+ # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
+ run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
+
+ - name: Upload a Build Artifact
+ uses: actions/upload-artifact@v3.1.3
+ with:
+ name: build
+ path: ${{ steps.strings.outputs.build-output-dir }}
+
+ bundle_mumble:
+ needs: build
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+
+ - uses: actions/download-artifact@v3
+ with:
+ name: build
+ path: build
+
+ - name: Bundle
+ run: |
+ mv build/libfactorio_linux_x86_64.so libplugin.so
+ mv build/Release/plugin.dll plugin.dll
+ mv mumble/manifest.xml manifest.xml
+ zip -MM factorio.mumble_plugin manifest.xml libplugin.so plugin.dll
+
+ - name: Upload a Build Artifact
+ uses: actions/upload-artifact@v3.1.3
+ with:
+ name: bundle
+ path: factorio.mumble_plugin
+
+ bundle_factorio:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+
+ - id: get_version
+ name: Get version
+ uses: jannemattila/get-version-from-tag@v1
+
+ - name: Bundle
+ run: |
+ cp -r factorio/ proximity-chat/
+ zip -r proximity-chat_${{ steps.get_version.outputs.version }}.zip proximity-chat
+
+ - name: Upload a Build Artifact
+ uses: actions/upload-artifact@v3.1.3
+ with:
+ name: proximity-chat_${{ steps.get_version.outputs.version }}.zip
+ path: proximity-chat_${{ steps.get_version.outputs.version }}.zip
+
+ add_release_files:
+ needs: [bundle_mumble, bundle_factorio]
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+
+ - id: get_version
+ name: Get version
+ uses: jannemattila/get-version-from-tag@v1
+
+ - uses: actions/download-artifact@v3
+ with:
+ name: bundle
+ path: bundle
+
+ - uses: actions/download-artifact@v3
+ with:
+ name: proximity-chat_${{ steps.get_version.outputs.version }}.zip
+ path: proximity-chat_${{ steps.get_version.outputs.version }}.zip
+
+ - name: Get release
+ id: get_release
+ uses: bruceadams/get-release@v1.3.2
+ env:
+ GITHUB_TOKEN: ${{ github.token }}
+
+ - name: Upload mumble plugin
+ uses: actions/upload-release-asset@v1.0.2
+ env:
+ GITHUB_TOKEN: ${{ github.token }}
+ with:
+ upload_url: ${{ steps.get_release.outputs.upload_url }}
+ asset_path: bundle/factorio.mumble_plugin
+ asset_name: factorio.mumble_plugin
+ asset_content_type: application/zip
+
+ - name: Upload factorio mod
+ uses: actions/upload-release-asset@v1.0.2
+ env:
+ GITHUB_TOKEN: ${{ github.token }}
+ with:
+ upload_url: ${{ steps.get_release.outputs.upload_url }}
+ asset_path: proximity-chat_${{ steps.get_version.outputs.version }}.zip
+ asset_name: proximity-chat_${{ steps.get_version.outputs.version }}.zip
+ asset_content_type: application/zip
diff --git a/factorio/info.json b/factorio/info.json
index 72e2993..f27352b 100644
--- a/factorio/info.json
+++ b/factorio/info.json
@@ -1,9 +1,9 @@
{
"name": "mumble-positional-audio",
- "version": "0.1.0",
+ "version": "0.2.0",
"title": "Mumble Positional Audio",
"author": "alifeee",
"factorio_version": "1.1",
"dependencies": ["base >= 1.1"],
"description": "This mod allows integration with the Mumble Factorio plugin, allowing proximity chat in multiplayer games."
-}
\ No newline at end of file
+}
diff --git a/mumble/CMakeLists.txt b/mumble/CMakeLists.txt
index 41ea36f..539c75b 100644
--- a/mumble/CMakeLists.txt
+++ b/mumble/CMakeLists.txt
@@ -5,7 +5,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(TargetArch)
project(MumblePlugin
- VERSION "0.1.0"
+ VERSION "0.2.0"
DESCRIPTION "Factorio Positional Audio Plugin"
LANGUAGES "C"
)
diff --git a/mumble/logfile.c b/mumble/logfile.c
index 1585d77..9b0c496 100644
--- a/mumble/logfile.c
+++ b/mumble/logfile.c
@@ -185,71 +185,3 @@ void parse_factorio_logfile(float *x, float *y, float *z, int *player, int *surf
if (line)
free(line);
}
-
-int main(int argc, char **argv)
-{
- char *homeDir = get_home_dir();
- printf("Home dir: %s\n\n", homeDir);
-
- if (is_factorio_logfile_there())
- {
- printf("Factorio logfile is present\n\n");
- }
- else
- {
- printf("Factorio logfile is not present. Terminating...\n");
- return 0;
- }
-
- float x, y, z;
- int player, surface;
- char *server;
- size_t server_len;
-
- parse_factorio_logfile(&x, &y, &z, &player, &surface, &server, &server_len);
-
- // log variables
- printf("x: %f\n", x);
- printf("y: %f\n", y);
- printf("z: %f\n", z);
- printf("player: %d\n", player);
- printf("surface: %d\n", surface);
- printf("server: %s\n", server);
-
- // combine surface and server
- char *context_str = malloc(server_len + 1 + 1 + 1);
- strcpy(context_str, server);
- strcat(context_str, "/");
- char surface_str[12];
- sprintf(surface_str, "%d", surface);
- strcat(context_str, surface_str);
- char *context = context_str;
-
- printf("context: %s\n", context_str);
-
- // get_file_modified_time
- time_t modified_time = get_factorio_file_modified_time();
- printf("modified time: %ld\n", modified_time);
- // compare to time now
- time_t now = time(NULL);
- printf("now: %ld\n", now);
- // difference
- time_t diff = now - modified_time;
- printf("diff: %ld\n", diff);
- if (diff > 20)
- {
- printf("More than 20 seconds ago!\n");
- }
-
- // is recent?
- if (is_factorio_logfile_recent(2))
- {
- printf("Factorio logfile is recent\n");
- }
- else
- {
- printf("Factorio logfile is not recent.\n");
- }
-
- return 0;
-}
diff --git a/mumble/logfile_test.c b/mumble/logfile_test.c
new file mode 100644
index 0000000..2c72f7c
--- /dev/null
+++ b/mumble/logfile_test.c
@@ -0,0 +1,72 @@
+#include "logfile.c"
+
+#include
+#include
+
+int main(int argc, char **argv)
+{
+ char *homeDir = get_home_dir();
+ printf("Home dir: %s\n\n", homeDir);
+
+ if (is_factorio_logfile_there())
+ {
+ printf("Factorio logfile is present\n\n");
+ }
+ else
+ {
+ printf("Factorio logfile is not present. Terminating...\n");
+ return 0;
+ }
+
+ float x, y, z;
+ int player, surface;
+ char *server;
+ size_t server_len;
+
+ parse_factorio_logfile(&x, &y, &z, &player, &surface, &server, &server_len);
+
+ // log variables
+ printf("x: %f\n", x);
+ printf("y: %f\n", y);
+ printf("z: %f\n", z);
+ printf("player: %d\n", player);
+ printf("surface: %d\n", surface);
+ printf("server: %s\n", server);
+
+ // combine surface and server
+ char *context_str = malloc(server_len + 1 + 1 + 1);
+ strcpy(context_str, server);
+ strcat(context_str, "/");
+ char surface_str[12];
+ sprintf(surface_str, "%d", surface);
+ strcat(context_str, surface_str);
+ char *context = context_str;
+
+ printf("context: %s\n", context_str);
+
+ // get_file_modified_time
+ time_t modified_time = get_factorio_file_modified_time();
+ printf("modified time: %ld\n", modified_time);
+ // compare to time now
+ time_t now = time(NULL);
+ printf("now: %ld\n", now);
+ // difference
+ time_t diff = now - modified_time;
+ printf("diff: %ld\n", diff);
+ if (diff > 20)
+ {
+ printf("More than 20 seconds ago!\n");
+ }
+
+ // is recent?
+ if (is_factorio_logfile_recent(2))
+ {
+ printf("Factorio logfile is recent\n");
+ }
+ else
+ {
+ printf("Factorio logfile is not recent.\n");
+ }
+
+ return 0;
+}
\ No newline at end of file
diff --git a/mumble/manifest.xml b/mumble/manifest.xml
index 6d1eac0..c314360 100644
--- a/mumble/manifest.xml
+++ b/mumble/manifest.xml
@@ -5,5 +5,5 @@
libplugin.so
Factorio Positional Audio
- 0.1.0
+ 0.2.0
\ No newline at end of file
diff --git a/mumble/plugin.c b/mumble/plugin.c
index c109ddb..667ef17 100644
--- a/mumble/plugin.c
+++ b/mumble/plugin.c
@@ -73,10 +73,14 @@ void mumble_releaseResource(const void *pointer)
mumble_version_t mumble_getVersion()
{
+ char *VERSION = "0.2.0";
+
mumble_version_t version;
- version.major = 0;
- version.minor = 1;
- version.patch = 0;
+ char *v = malloc(strlen(VERSION) + 1);
+ strcpy(v, VERSION); // cannot use strtok on const char*
+ version.major = atoi(strtok(v, "."));
+ version.minor = atoi(strtok(NULL, "."));
+ version.patch = atoi(strtok(NULL, "."));
return version;
}