Skip to content

Commit

Permalink
Merge pull request #23 from ArKaNeMaN/master
Browse files Browse the repository at this point in the history
  • Loading branch information
ufame authored Dec 5, 2024
2 parents dfcc9bf + d5029a0 commit bf5ff28
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 26 deletions.
99 changes: 76 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: CI

on:
push:
Expand All @@ -11,54 +11,107 @@ on:
release:
types: [published]

env:
PACKAGE_NAME: player-preferences

jobs:
build:
name: "Build"
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
outputs:
sha: ${{ steps.declare_sha.outputs.sha }}
semver: ${{ steps.declare_sha.outputs.semver }}
COMMIT_SHA: ${{ steps.declare_sha.outputs.COMMIT_SHA }}
SEMVER: ${{ steps.declare_sha.outputs.SEMVER }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4.1.1
with:
fetch-depth: 0

- name: Parse SemVer string (release)
id: semver_parser
if: |
github.event_name == 'release' &&
github.event.action == 'published' &&
startsWith(github.ref, 'refs/tags/')
uses: booxmedialtd/ws-action-parse-semver@v1.4.7
with:
input_string: ${{ github.ref }}
version_extractor_regex: 'refs\/tags\/(.*)$'

- name: Declare SHA & package name
id: declare_sha
shell: bash
run: |
SHA=$(git rev-parse --short HEAD)
echo "COMMIT_SHA=${SHA}" >> $GITHUB_ENV
echo "sha=$SHA" >> $GITHUB_OUTPUT
echo "semver=${{ steps.semver_parser.outputs.fullversion }}" >> $GITHUB_OUTPUT
echo "COMMIT_SHA=$SHA" >> $GITHUB_OUTPUT
echo "SEMVER=${{ steps.semver_parser.outputs.fullversion }}" >> $GITHUB_OUTPUT
- name: Setup AMXXPawn Compiler
uses: wopox1337/setup-amxxpawn@v1.0.2
uses: wopox1337/setup-amxxpawn@v1.1.0
with:
version: "1.10"
version: "1.10.5428"

- name: Compile AMXX plugins
- name: Compile plugins
working-directory: scripting/
env:
PLUGINS_INI_POSTFIX: ${{ env.PLUGINS_INI_POSTFIX }}
run: |
mkdir ../plugins/
compile() {
sourcefile=$1
amxxfile="$(echo $sourcefile | sed -e 's/\.sma$/.amxx/')"
output_path="../plugins/$amxxfile"
mkdir -p $(dirname $output_path)
for sourcefile in *.sma;
do
amxxfile="`echo $sourcefile | sed -e 's/\.sma$/.amxx/'`"
echo -n "Compiling $sourcefile ... "
amxxpc $sourcefile -o"$output_path" \
-i"include"
}
export -f compile
amxxpc $sourcefile -o"../plugins/$amxxfile" \
-i"include" \
done
find . -type f -name "*.sma" -exec bash -c 'compile "$0"' {} \;
- name: Move files
env:
STORE_README: ${{ env.STORE_README }}
run: |
mkdir publish
mv addons/ publish/
package_amxmodx_path=publish/${{ env.PACKAGE_NAME }}/addons/amxmodx/
mkdir -p $package_amxmodx_path
mv configs $package_amxmodx_path
mv scripting $package_amxmodx_path
mv migrations publish/
mv readme.md publish/
- name: Upload artifact
uses: actions/upload-artifact@v3
- name: Deploy artifact
uses: actions/upload-artifact@v4.3.1
with:
name: player-prefs-${{ env.COMMIT_SHA }}-dev
name: ${{ env.PACKAGE_NAME }}-${{ steps.declare_sha.outputs.COMMIT_SHA }}-dev
path: publish/*

publish:
name: "Publish release"
runs-on: ubuntu-latest
needs: [build]
if: |
github.event_name == 'release' &&
github.event.action == 'published' &&
startsWith(github.ref, 'refs/tags/')
steps:
- name: Download artifact
uses: actions/download-artifact@v4.1.4
with:
name: ${{ env.PACKAGE_NAME }}-${{ needs.build.outputs.COMMIT_SHA }}-dev

- name: Packaging binaries
id: packaging
run: 7z a -mm=Deflate -mfb=258 -mpass=15 -r ${{ env.PACKAGE_NAME }}-${{ needs.build.outputs.SEMVER }}.zip

- name: Publish artifacts
uses: softprops/action-gh-release@v2.0.4
id: publish-job
if: |
startsWith(github.ref, 'refs/tags/') &&
steps.packaging.outcome == 'success'
with:
files: |
*.zip
11 changes: 8 additions & 3 deletions scripting/player_prefs.sma
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ new Handle: g_hSqlTuple;
new bool: g_bDebugMode;

public plugin_init() {
register_plugin("Player preferences", "1.1.1", "ufame");
register_plugin("Player preferences", "1.2.0", "ufame");

CreateForwards();
ReadDbCredentials();
Expand Down Expand Up @@ -102,8 +102,11 @@ public bool: native_get_preference(iPlugin, iArgs) {

get_string(arg_key, szKey, charsmax(szKey));

if (!TrieGetString(g_tPlayerPreferences[iPlayer], szKey, szValue, charsmax(szValue)))
if (g_tPlayerPreferences[iPlayer] !== Invalid_Trie && TrieKeyExists(g_tPlayerPreferences[iPlayer], szKey)) {
TrieGetString(g_tPlayerPreferences[iPlayer], szKey, szValue, charsmax(szValue));
} else if (g_tKeys !== Invalid_Trie && TrieKeyExists(g_tKeys, szKey)) {
TrieGetString(g_tKeys, szKey, szValue, charsmax(szValue));
}

set_string(arg_dest, szValue, iLen);

Expand Down Expand Up @@ -173,7 +176,7 @@ bool:IsUserLoaded(const iPlayer) {
if (!is_user_connected(iPlayer))
return false;

return g_iPlayerDatabaseId[iPlayer] > 0;
return g_iPlayerDatabaseId[iPlayer] > 0 && g_tPlayerPreferences[iPlayer] != Invalid_Trie;
}

stock LoadPreferences(iPlayer) {
Expand Down Expand Up @@ -289,6 +292,8 @@ public ThreadQuery_Handler(iFailState, Handle: hQuery, szError[], iError, szData
return;
}

// Это немного ломало логику функи IsUserLoaded, в момент между этим и State_LoadPreferences
// Добавил там допом проверку на созданность trie с префами
g_iPlayerDatabaseId[iPlayer] = SQL_ReadResult(hQuery, SQL_FieldNameToNum(hQuery, "id"));

formatex(g_szQuery, charsmax(g_szQuery),
Expand Down

0 comments on commit bf5ff28

Please sign in to comment.