Skip to content

Commit 77ca434

Browse files
committed
Add build script and restructire repo
1 parent f5c2c69 commit 77ca434

11 files changed

Lines changed: 207 additions & 42 deletions

File tree

.build-config

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PACKAGE_NAME=CustomWeaponsAPI
2+
PACKAGE_README_USE=1
3+
4+
PACKAGE_COMPILED_PLUGINS_USE=1
5+
PACKAGE_COMPILED_PLUGINS_SAVE=0
6+
7+
PACKAGE_PLUINGS_LIST_USE=0
8+
PACKAGE_ASSETS_USE=0
File renamed without changes.
File renamed without changes.

.gitignore

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
.gitattributes
2-
include/*
3-
compiled/*
4-
compile.exe
5-
amxxpc32.dll
6-
compile.dat
7-
amxxpc.exe
8-
TODO.txt
9-
!cwapi.inc
10-
*.lnk
111
*.amxx
2+
*.zip
3+
.build

Compile.bat

Lines changed: 0 additions & 12 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<img height=64 src="https://github.com/ArKaNeMaN/amxx-CustomWeaponsAPI/blob/master/IconBar-96.png?raw=true" alt="CWAPI-IconBar"/>
1+
<img height=64 src="https://github.com/ArKaNeMaN/amxx-CustomWeaponsAPI/blob/master/.github/IconBar-96.png?raw=true" alt="CWAPI-IconBar"/>
22

33
## Описание
44

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
#pragma semicolon 1
1010

1111
// Поставить тут 0 чтобы нельзя было выдавать пушки
12-
#define DEBUG 1
12+
#if !defined DEBUG
13+
#define DEBUG 0
14+
#endif
1315

1416
// Использование новых хуков в ReAPI (Почему-то работает криво)
1517
#define USE_NEW_REAPI_HOOKS 0
@@ -549,17 +551,14 @@ public Hook_PlayerGetMaxSpeed(const ItemId) {
549551

550552
public Hook_PrimaryAttack_Pre(ItemId) {
551553
new WeaponId = GetWeapId(ItemId);
552-
if (!IsCustomWeapon(WeaponId)) {
553-
return;
554-
}
555-
556-
if (get_member(ItemId, m_Weapon_iClip) < 1) {
557-
return;
558-
}
559554

560555
if (
561-
IsPistol(ItemId)
562-
&& get_member(ItemId, m_Weapon_iShotsFired)+1 > 1
556+
!IsCustomWeapon(WeaponId)
557+
|| get_member(ItemId, m_Weapon_iClip) < 1
558+
|| (
559+
IsPistol(ItemId)
560+
&& get_member(ItemId, m_Weapon_iShotsFired)+1 > 1
561+
)
563562
) {
564563
return;
565564
}
@@ -574,15 +573,14 @@ public Hook_PrimaryAttack_Pre(ItemId) {
574573
public Hook_PrimaryAttack_Post(ItemId) {
575574
new WeaponId = GetWeapId(ItemId);
576575

577-
if (!IsCustomWeapon(WeaponId)) {
578-
return HAM_IGNORED;
579-
}
580-
581-
if (get_member(ItemId, m_Weapon_fFireOnEmpty)) {
582-
return HAM_IGNORED;
583-
}
584-
585-
if (IsPistol(ItemId) && get_member(ItemId, m_Weapon_iShotsFired) > 1) {
576+
if (
577+
!IsCustomWeapon(WeaponId)
578+
|| get_member(ItemId, m_Weapon_fFireOnEmpty)
579+
|| (
580+
IsPistol(ItemId)
581+
&& get_member(ItemId, m_Weapon_iShotsFired) > 1
582+
)
583+
) {
586584
return HAM_IGNORED;
587585
}
588586

build-debug.bat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@echo off
2+
3+
set PACKAGE_DEBUG=1
4+
call build

build.bat

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
@echo off
2+
3+
call config
4+
5+
echo Copy includes to compiler...
6+
if exist "%INCLUDES_PATH%" (
7+
call :copy %INCLUDES_PATH%\*, %AMXX_COMPILER_INCLUDES_PATH%
8+
)
9+
10+
echo Cleanup old compiled plugins...
11+
call :deldir %COMPILER_OUTPUT_PATH%
12+
call :deldir %AMXMODX_PATH%\plugins
13+
14+
if not "%PACKAGE_COMPILED_PLUGINS_USE%" == "1" goto after-compile
15+
16+
echo Prepare for compiling plugins...
17+
18+
call :makedir %PLUGINS_LIST_PATH%
19+
call :del %PLUGINS_LIST%
20+
if "%PACKAGE_PLUINGS_LIST_USE%" == "1" (
21+
echo. 2>%PLUGINS_LIST%
22+
)
23+
24+
echo Compile plugins...
25+
26+
call :makedir %COMPILER_OUTPUT_PATH%
27+
cd %COMPILER_OUTPUT_PATH%
28+
for /R %AMXMODX_PATH%\scripting %%F in (*.sma) do (
29+
echo.
30+
echo Compile %%~nF:
31+
32+
if "%PACKAGE_DEBUG%" == "1" (
33+
%AMXX_COMPILER_EXECUTABLE_PATH% DEBUG=1 %%F
34+
) else (
35+
%AMXX_COMPILER_EXECUTABLE_PATH% %%F
36+
)
37+
38+
if errorlevel 1 (
39+
echo.
40+
echo Plugin %%~nF compiled with error.
41+
set /p q=
42+
exit /b %errorlevel%
43+
)
44+
45+
if "%PACKAGE_PLUINGS_LIST_USE%" == "1" (
46+
echo %%~nF.amxx>>%PLUGINS_LIST%
47+
)
48+
)
49+
cd %ROOT_PATH%
50+
:after-compile
51+
52+
echo Prepare files...
53+
call :makedir %BUILD_AMXMODX_PATH%
54+
call :copy "%AMXMODX_PATH%\*", "%BUILD_AMXMODX_PATH%"
55+
56+
if "%PACKAGE_README_USE%" == "1" (
57+
call :copy "%README_FILE%", "%BUILD_ROOT_PATH%"
58+
)
59+
60+
if "%PACKAGE_ASSETS_USE%" == "1" (
61+
call :makedir %BUILD_ASSETS_PATH%
62+
call :copy %ASSETS_PATH%\* %BUILD_ASSETS_PATH%
63+
)
64+
65+
echo Compress files to ZIP archive...
66+
call :del %ZIP_FILE%
67+
call :zip %BUILD_ROOT_PATH%/*, %ZIP_FILE%
68+
69+
echo Cleanup temp files...
70+
call :deldir %BUILD_ROOT_PATH%
71+
72+
echo Build finished.
73+
74+
exit 0
75+
76+
:makedir
77+
if not exist %~1 mkdir %~1
78+
exit /b
79+
80+
:deldir
81+
if exist %~1 rd /S /q %~1
82+
exit /b
83+
84+
:del
85+
if exist %~1 del %~1
86+
exit /b
87+
88+
:copy
89+
powershell Copy-Item -Path %~1 -Destination %~2 -Recurse -Force
90+
exit /b
91+
92+
:zip
93+
powershell Compress-Archive %~1 %~2 -Force
94+
exit /b

0 commit comments

Comments
 (0)