Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
if: true
runs-on: ubuntu-latest
container:
image: debian:bookworm
image: debian:trixie

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Install dependencies
run: apt-get -y update && apt-get install -y libgmp-dev build-essential cmake
Expand Down Expand Up @@ -43,10 +43,10 @@ jobs:
if: true
runs-on: ubuntu-latest
container:
image: debian:bookworm
image: debian:trixie

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Install dependencies
run: apt-get -y update && apt-get install -y python3 python3-pip build-essential cmake
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
image: fedora:latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Install dependencies
run: dnf -y install gmp-devel make automake clang cmake
Expand All @@ -91,15 +91,15 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- uses: TheMrMilchmann/setup-msvc-dev@v3
- uses: TheMrMilchmann/setup-msvc-dev@79dac248aac9d0059f86eae9d8b5bfab4e95e97c # v4
with:
arch: x64

- name: Install Conan
id: conan
uses: turtlebrowser/get-conan@main
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d # v1.2

- name: Init conan
run: conan profile detect
Expand Down
40 changes: 20 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
if: true
runs-on: ubuntu-latest
container:
image: debian:bookworm
image: debian:trixie

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Install dependencies
run: apt-get -y update && apt-get install -y libgmp-dev build-essential cmake
Expand All @@ -33,7 +33,7 @@ jobs:
run: |
cpack -G "DEB" -D CPACK_PACKAGE_FILE_NAME=libbncsutil-dev_${{ github.ref_name }}_amd64

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
retention-days: 1
overwrite: true
Expand All @@ -47,7 +47,7 @@ jobs:
image: fedora:latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Install dependencies
run: dnf -y install gmp-devel make automake clang cmake rpm-build
Expand All @@ -62,7 +62,7 @@ jobs:
working-directory: build
run: cpack -G "RPM" -D CPACK_PACKAGE_FILE_NAME=libbncsutil-devel-${{ github.ref_name }}.x86_64

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
retention-days: 1
overwrite: true
Expand All @@ -74,22 +74,22 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- uses: TheMrMilchmann/setup-msvc-dev@v3
- uses: TheMrMilchmann/setup-msvc-dev@79dac248aac9d0059f86eae9d8b5bfab4e95e97c # v4
with:
arch: x64

- name: Cache Conan
uses: actions/cache@v3
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
key: conan-windows-amd64-${{ hashFiles('conanfile.py') }}
path: |
~/.conan2/p

- name: Install Conan
id: conan
uses: turtlebrowser/get-conan@main
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d # v1.2

- name: Init conan
run: conan profile detect
Expand All @@ -111,7 +111,7 @@ jobs:
Compress-Archive -Path Release/* -DestinationPath bncsutil_${{ github.ref_name }}_amd64_dll.zip
Compress-Archive -Path include -DestinationPath "bncsutil_${{ github.ref_name }}_amd64_dll.zip" -Update

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
retention-days: 1
overwrite: true
Expand All @@ -123,18 +123,18 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- uses: TheMrMilchmann/setup-msvc-dev@v3
- uses: TheMrMilchmann/setup-msvc-dev@79dac248aac9d0059f86eae9d8b5bfab4e95e97c # v4
with:
arch: x86

- name: Install Conan
id: conan
uses: turtlebrowser/get-conan@main
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d # v1.2

- name: Cache Conan
uses: actions/cache@v3
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
with:
key: conan-windows-x86-${{ hashFiles('conanfile.py') }}
path: |
Expand All @@ -160,7 +160,7 @@ jobs:
Compress-Archive -Path Release/* -DestinationPath bncsutil_${{ github.ref_name }}_x86_dll.zip
Compress-Archive -Path include -DestinationPath "bncsutil_${{ github.ref_name }}_x86_dll.zip" -Update

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
retention-days: 1
overwrite: true
Expand All @@ -174,27 +174,27 @@ jobs:

steps:
- name: Download deb
uses: actions/download-artifact@v4
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: libbncsutil-dev_${{ github.ref_name }}_amd64.deb

- name: Download rpm
uses: actions/download-artifact@v4
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: libbncsutil-devel-${{ github.ref_name }}.x86_64.rpm

- name: Download dll amd64
uses: actions/download-artifact@v4
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: bncsutil_${{ github.ref_name }}_amd64_dll.zip

- name: Download dll x86
uses: actions/download-artifact@v4
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: bncsutil_${{ github.ref_name }}_x86_dll.zip

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2
with:
files: |
libbncsutil-dev_${{ github.ref_name }}_amd64.deb
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ set(HEADERS
"src/bncsutil/file.h"
"src/bncsutil/keytables.h"
"src/bncsutil/libinfo.h"
"src/bncsutil/ms_stdint.h"
"src/bncsutil/mutil.h"
"src/bncsutil/mutil_types.h"
"src/bncsutil/nls.h"
Expand Down
15 changes: 8 additions & 7 deletions src/bncsutil/cdkeydecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ CDKeyDecoder::CDKeyDecoder(const char* cdKey, size_t keyLength) {
cdkey = new char[keyLength + 1];
initialized = 1;
keyLen = keyLength;
strcpy(cdkey, cdKey);
memcpy(cdkey, cdKey, keyLength);
cdkey[keyLength] = '\0';

switch (keyType) {
case KEY_STARCRAFT:
Expand Down Expand Up @@ -421,12 +422,12 @@ int CDKeyDecoder::processWarCraft2Key() {
cdkey[j] = c;
if (c <= '7') {
v = v2;
c2 = ((char) (v & 0xFF)) & 7 ^ c;
c2 = (((char) (v & 0xFF)) & 7) ^ c;
v >>= 3;
cdkey[j] = (char) c2;
v2 = v;
} else if (c < 'A') {
cdkey[j] = ((char) j) & 1 ^ c;
cdkey[j] = (((char) j) & 1) ^ c;
}
}

Expand Down Expand Up @@ -526,14 +527,14 @@ void CDKeyDecoder::decodeKeyTable(int* keyTable) {
/*
ecx = (j & 7) << 2;
ebp = (keyTable[0x3 - (j >> 3)] & (0xF << ecx)) >> ecx;
varC = w3TranslateMap[ebp ^ w3TranslateMap[varC + i] + i];
varC = w3TranslateMap[ebp ^ (w3TranslateMap[varC + i] + i)];
*/
ecx = (j & 7) << 2;
//ebp = (keyTable[0x3 - (j >> 3)] & (0xF << ecx)) >> ecx;
ebp = (keyTable[0x3 - (j >> 3)]);
ebp &= (0xF << ecx);
ebp = ebp >> ecx;
varC = w3TranslateMap[ebp ^ w3TranslateMap[varC + i] + i];
varC = w3TranslateMap[ebp ^ (w3TranslateMap[varC + i] + i)];
}
}

Expand All @@ -544,13 +545,13 @@ void CDKeyDecoder::decodeKeyTable(int* keyTable) {
ebp = (keyTable[0x3 - (j >> 3)]);
ebp &= (0xF << ecx);
ebp = ebp >> ecx;
varC = w3TranslateMap[ebp ^ w3TranslateMap[varC + i] + i];
varC = w3TranslateMap[ebp ^ (w3TranslateMap[varC + i] + i)];
j--;
}

j = 3 - var4;
ebx = (w3TranslateMap[varC + i] & 0xF) << esi;
keyTable[j] = (ebx | ~(0xF << esi) & ((int) keyTable[j]));
keyTable[j] = (ebx | (~(0xF << esi) & ((int) keyTable[j])));
} while ((i -= 16) >= 0);

// pass 2
Expand Down
4 changes: 2 additions & 2 deletions src/bncsutil/checkrevision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ MEXP(int) checkRevision(const char* formula, const char* files[], int numFiles,
values[0] ^= checkrevision_seeds[mpqNumber];

for (int i = 0; i < numFiles; i++) {
size_t file_len, remainder, rounded_size, buffer_size;
size_t file_len, remainder, buffer_size;

f = file_open(files[i], FILE_READ);
if (!f) {
Expand All @@ -230,7 +230,6 @@ MEXP(int) checkRevision(const char* formula, const char* files[], int numFiles,

file_len = file_size(f);
remainder = file_len % 1024;
rounded_size = file_len - remainder;

file_buffer = (uint8_t*) file_map(f, file_len, 0);
if (!file_buffer) {
Expand Down Expand Up @@ -291,6 +290,7 @@ MEXP(int) checkRevision(const char* formula, const char* files[], int numFiles,
break;
case '/':
// well, you never know
if (values[ovs2[k]] == 0) return 0;
values[ovd[k]] = values[ovs1[k]] / values[ovs2[k]];
break;
default:
Expand Down
4 changes: 2 additions & 2 deletions src/bncsutil/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ file_t file_open(const char* filename, unsigned int mode)

try {
data = new _file;
} catch (std::bad_alloc) {
} catch (const std::bad_alloc&) {
//bncsutil_debug_message_a("Failed to allocate %u bytes to hold file structure.", sizeof(struct _file));
CloseHandle(file);
return (file_t) 0;
Expand Down Expand Up @@ -200,7 +200,7 @@ file_t file_open(const char* filename, const unsigned int mode_flags)

try {
data = new _file;
} catch (std::bad_alloc) {
} catch (const std::bad_alloc&) {
//bncsutil_debug_message_a("Failed to allocate %u bytes to hold file structure.", sizeof(struct _file));
fclose(f);
return (file_t) 0;
Expand Down
Loading