Added: Track assembly retrieve owner from entity (#44)

Fixed: Dashes saves as UTF-8
Fixed: Integrated commit hook
Fixed: Switch TA initialization to ANSI
Improved: Better future support
Improved: The way script handles the owner
Updated: Keep code conversion
Updated: Version equalize
Updated: WS publish now calls integrated NP
Added: Commit hooks ENV variables initial commit
Added: Track assembly retrieve owner from entity
Removed: Hook `pre-commit.bat` timeout
Removed: Timeout at the execution end
This commit is contained in:
Deyan Dobromirov 2023-01-12 20:10:41 +02:00 committed by GitHub
parent 6702a6af6e
commit 546ee5eb65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 70 additions and 73 deletions

5
.tgitconfig Normal file
View File

@ -0,0 +1,5 @@
[hook "precommit"]
[hook "startcommit"]
cmdline = data\\trackassembly\\tools\\hooks\\pre-commit.bat
wait = true
show = true

View File

@ -8,10 +8,10 @@ set hookOutFile=trackassembly_init.lua
set hookBasPath=%~dp0 set hookBasPath=%~dp0
:: The path to the Lua eceutable including :: The path to the Lua eceutable including
set hookLuaPath=%1 set "hookLuaPath=%LUA_HOME%\bin\lua.exe"
:: The path to the log file. Folder must exist! :: The path to the log file. Folder must exist!
set hookLogFile=%2 set "hookLogFile=%TEMP%\commit_hook.log"
:: Where to read the revision file from :: Where to read the revision file from
set hookCpyPath=%hookBasPath%..\..\..\..\lua\autorun set hookCpyPath=%hookBasPath%..\..\..\..\lua\autorun
@ -37,5 +37,5 @@ echo Cleanup pieces manager buid...>>%hookLogFile%
rd /s /q %hookPimMath%\bin rd /s /q %hookPimMath%\bin
rd /s /q %hookPimMath%\obj rd /s /q %hookPimMath%\obj
del %hookPimMath%\peaces_manager.layout del %hookPimMath%\peaces_manager.layout
timeout 500
exit 0 exit 0

View File

@ -93,7 +93,7 @@ local asmlib = trackasmlib; if(not asmlib) then -- Module present
------------ CONFIGURE ASMLIB ------------ ------------ CONFIGURE ASMLIB ------------
asmlib.InitBase("track","assembly") asmlib.InitBase("track","assembly")
asmlib.SetOpVar("TOOL_VERSION","8.697") asmlib.SetOpVar("TOOL_VERSION","8.698")
asmlib.SetIndexes("V" ,1,2,3) asmlib.SetIndexes("V" ,1,2,3)
asmlib.SetIndexes("A" ,1,2,3) asmlib.SetIndexes("A" ,1,2,3)
asmlib.SetIndexes("WV",1,2,3) asmlib.SetIndexes("WV",1,2,3)
@ -240,7 +240,7 @@ local conElements = asmlib.GetContainer("LIST_VGUI")
local conWorkMode = asmlib.GetContainer("WORK_MODE") local conWorkMode = asmlib.GetContainer("WORK_MODE")
conWorkMode:Push("SNAP" ) -- General spawning and snapping mode conWorkMode:Push("SNAP" ) -- General spawning and snapping mode
conWorkMode:Push("CROSS") -- Ray cross intersect interpolation conWorkMode:Push("CROSS") -- Ray cross intersect interpolation
conWorkMode:Push("CURVE") -- CatmullRom spline interpolation fitting conWorkMode:Push("CURVE") -- Catmull-Rom spline interpolation fitting
conWorkMode:Push("OVER" ) -- Trace normal ray location piece flip-snap conWorkMode:Push("OVER" ) -- Trace normal ray location piece flip-snap
conWorkMode:Push("TURN" ) -- Produces smoother turns with Bezier curve conWorkMode:Push("TURN" ) -- Produces smoother turns with Bezier curve
@ -496,7 +496,7 @@ if(CLIENT) then
asmlib.ToIcon("dsvlist_extdb" , "database_go" ) asmlib.ToIcon("dsvlist_extdb" , "database_go" )
asmlib.ToIcon("workmode_snap" , "plugin" ) -- General spawning and snapping mode asmlib.ToIcon("workmode_snap" , "plugin" ) -- General spawning and snapping mode
asmlib.ToIcon("workmode_cross" , "chart_line" ) -- Ray cross intersect interpolation asmlib.ToIcon("workmode_cross" , "chart_line" ) -- Ray cross intersect interpolation
asmlib.ToIcon("workmode_curve" , "vector" ) -- CatmullRom curve line segment fitting asmlib.ToIcon("workmode_curve" , "vector" ) -- Catmull-Rom curve line segment fitting
asmlib.ToIcon("workmode_over" , "shape_move_back" ) -- Trace normal ray location piece flip-spawn asmlib.ToIcon("workmode_over" , "shape_move_back" ) -- Trace normal ray location piece flip-spawn
asmlib.ToIcon("workmode_turn" , "arrow_turn_right") -- Produces smoother turns with Bezier curve asmlib.ToIcon("workmode_turn" , "arrow_turn_right") -- Produces smoother turns with Bezier curve
asmlib.ToIcon("property_type" , "package_green" ) asmlib.ToIcon("property_type" , "package_green" )

View File

@ -272,6 +272,29 @@ function IsPlayer(oPly)
return true return true
end end
function GetOwner(oEnt)
if(not (oEnt and oEnt:IsValid())) then return nil end
local set, ows = oEnt.OnDieFunctions
-- Use CPPI first when installed. If fails search down
ows = ((CPPI and oEnt.CPPIGetOwner) and oEnt:CPPIGetOwner() or nil)
if(IsPlayer(ows)) then return ows else ows = nil end
-- Try the direct entity methods. Extract owner from functios
ows = (oEnt.GetOwner and oEnt:GetOwner() or nil)
if(IsPlayer(ows)) then return ows else ows = nil end
ows = (oEnt.GetCreator and oEnt:GetCreator() or nil)
if(IsPlayer(ows)) then return ows else ows = nil end
-- Try then various entity internal key values
ows = oEnt.player; if(IsPlayer(ows)) then return ows else ows = nil end
ows = oEnt.Owner; if(IsPlayer(ows)) then return ows else ows = nil end
ows = oEnt.owner; if(IsPlayer(ows)) then return ows else ows = nil end
if(set) then -- Duplicatior die functions are registered
set = set.GetCountUpdate; ows = (set.Args and set.Args[1] or nil)
if(IsPlayer(ows)) then return ows else ows = nil end
set = set.undo1; ows = (set.Args and set.Args[1] or nil)
if(IsPlayer(ows)) then return ows else ows = nil end
end; return nil -- No owner is found. Nothing is returned
end
function IsOther(oEnt) function IsOther(oEnt)
if(not IsHere(oEnt)) then return true end if(not IsHere(oEnt)) then return true end
if(not IsEntity(oEnt)) then return true end if(not IsEntity(oEnt)) then return true end

View File

@ -1587,8 +1587,8 @@ function TOOL:Reload(stTrace)
end end
end end
local trRec = asmlib.CacheQueryPiece(trEnt:GetModel()) local trRec = asmlib.CacheQueryPiece(trEnt:GetModel())
if(asmlib.IsHere(trRec) and trEnt:GetCreator() == ply) then trEnt:Remove() if(asmlib.IsHere(trRec) and (asmlib.GetOwner(trEnt) == ply or ply:IsAdmin())) then
asmlib.LogInstance("(Prop) Remove piece",gtLogs); return true trEnt:Remove(); asmlib.LogInstance("(Prop) Remove piece",gtLogs); return true
end; asmlib.LogInstance("(Prop) Success",gtLogs) end; asmlib.LogInstance("(Prop) Success",gtLogs)
end; return false end; return false
end end

View File

@ -11,95 +11,64 @@ setlocal EnableDelayedExpansion
set gmadGitHEAD= set gmadGitHEAD=
set gmadRevPath=%~dp0 set gmadRevPath=%~dp0
set gmadNameLOG=gmad_log.txt set gmadNameLOG=gmad_log.txt
set gmadNameGIT=gmad_git.txt
set gmadName=TrackAssemblyTool set gmadName=TrackAssemblyTool
set gmadCommits=https://github.com/dvdvideo1234/%gmadName%/commit/ set gmadCommits=https://github.com/dvdvideo1234/%gmadName%/commit/
set gmadPathGIT=D:\Git\bin set "gmadPathGIT=%GIT_HOME%\bin\git.exe"
set gmadBinPath=F:\Games\Steam\steamapps\common\GarrysMod\bin set gmadBinPath=%GMOD_HOME%\bin
set gmadADTools=%gmadRevPath%data\trackassembly\tools set "gmadADTools=%gmadRevPath%data\trackassembly\tools"
set "gmadTime=%date% %time%" set "gmadTime=%date% %time%"
set gmadID=287012681 set gmadID=287012681
set gmadDirs=(lua resource) set gmadDirs=(lua resource)
set gmadLogs=
set gmadCRLF=^
:: New line is actually needed when escaped
title Addon %gmadName% updater/publisher title Addon %gmadName% updater/publisher
echo Press Crtl+C to terminate ! echo Press Crtl+C to terminate^^!
echo Press a key if you do not want to wait ! echo Press a key if you do not want to wait^^!
echo Rinning in %gmadRevPath%. echo Rinning in: %gmadRevPath%
echo Npp Find --\h{1,}\n-- replace --\n-- in dos format before commit ! echo Npp Find --\h{1,}\n-- replace --\n-- in dos format before commit^^!
echo. echo Extracting repository source contents^^!
if exist !gmadNameLOG! del !gmadNameLOG!
:: Extract repository source contents if exist !gmadNameGIT! del !gmadNameGIT!
if exist Workshop rd /S /Q Workshop
rd /S /Q !gmadRevPath!Workshop
del !gmadRevPath!!gmadNameLOG!
timeout 5 timeout 5
md %gmadRevPath%Workshop\!gmadName! md "%gmadRevPath%Workshop\!gmadName!" >> !gmadNameLOG!
for %%i in %gmadDirs% do ( for %%i in %gmadDirs% do (
echo Extracting %%i echo Exporting addon content: %%i
timeout 3 call xcopy "!gmadRevPath!%%i" "!gmadRevPath!Workshop\!gmadName!\%%i" /EXCLUDE:!gmadADTools!\workshop\key.txt /E /C /I /F /R /Y >> !gmadNameLOG!
xcopy !gmadRevPath!%%i !gmadRevPath!Workshop\!gmadName!\%%i /EXCLUDE:!gmadADTools!\workshop\key.txt /E /C /I /F /R /Y
) )
call copy !gmadADTools!\workshop\addon.json !gmadRevPath!Workshop\!gmadName!\addon.json call copy "!gmadADTools!\workshop\addon.json" "!gmadRevPath!Workshop\!gmadName!\addon.json" >> !gmadNameLOG!
call !gmadBinPath!\gmad.exe create -folder "!gmadRevPath!Workshop\!gmadName!" -out "!gmadRevPath!Workshop\!gmadName!.gma" call "!gmadBinPath!\gmad.exe" create -folder "!gmadRevPath!Workshop\!gmadName!" -out "!gmadRevPath!Workshop\!gmadName!.gma" >> !gmadNameLOG!
:: Obtain the latest commit hash from the repository echo Obtain the latest repository commit log^^!
call !gmadPathGIT!\git.exe rev-parse HEAD>!gmadNameLOG!
call set /p gmadGitHEAD=<!gmadNameLOG!
call del !gmadRevPath!!gmadNameLOG!
:: Obtain the log message from the latest revision for /F "tokens=*" %%i in ('call "!gmadPathGIT!" rev-parse HEAD') do (set "gmadGitHEAD=%%i")
call echo !gmadTime!>!gmadNameLOG!
call echo.>>!gmadNameLOG!
call echo !gmadCommits!!gmadGitHEAD!>>!gmadNameLOG!
call echo. >> !gmadNameLOG!
!gmadPathGIT!\git.exe log -1 --pretty=%%B>>!gmadNameLOG! call echo !gmadTime! >> !gmadNameGIT!
call echo. >> !gmadNameGIT!
for /f "delims=" %%i in ('type !gmadNameLOG!') do ( call echo !gmadCommits!!gmadGitHEAD! >> !gmadNameGIT!
call echo. >> !gmadNameGIT!
IF DEFINED gmadLogs ( call "!gmadPathGIT!" log -1 >> !gmadNameGIT!
set "gmadLogs=!gmadLogs!!gmadCRLF!%%i"
) ELSE (
set "gmadLogs=%%i"
)
)
:: Publish if ID is available or create if it is not.
echo .
echo .
echo THIS IS THE LAST LOG
echo .
echo .
echo !gmadLogs!
echo .
timeout 15 timeout 15
IF DEFINED gmadID ( if defined gmadID (
call !gmadBinPath!\gmpublish.exe update -addon "!gmadRevPath!Workshop\!gmadName!.gma" -id "!gmadID!" -icon "!gmadADTools!\pictures\icon.jpg" -changes "Generated by batch !" call "!gmadBinPath!\gmpublish.exe" update -addon "!gmadRevPath!Workshop\!gmadName!.gma" -id "!gmadID!" -icon "!gmadADTools!\pictures\icon.jpg" -changes "Generated by batch" >> !gmadNameLOG!
) ELSE ( ) else (
call !gmadBinPath!\gmpublish.exe create -addon "!gmadRevPath!Workshop\!gmadName!.gma" -icon "!gmadADTools!\pictures\icon.jpg" call "!gmadBinPath!\gmpublish.exe" create -addon "!gmadRevPath!Workshop\!gmadName!.gma" -icon "!gmadADTools!\pictures\icon.jpg" >> !gmadNameLOG!
) )
:: Tell the user we are done and clean-up the directory echo !gmadName! Published^^!
echo. call "%WINDIR%\System32\notepad.exe" "!gmadRevPath!!gmadNameGIT!"
rd /S /Q !gmadRevPath!Workshop
echo !gmadName! Published ! echo Cleaning up the working directory^^!
echo.
timeout 500
:: Give a chance to copy the logs rd /S /Q "!gmadRevPath!Workshop"
del !gmadRevPath!!gmadNameLOG! del "!gmadRevPath!!gmadNameLOG!"
del "!gmadRevPath!!gmadNameGIT!"
exit 0 exit 0