diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df2a381..b5f7c9e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,12 +25,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 with: path: ${{ github.repository }} - name: Checkout world-portals - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 with: repository: AmyJeanes/world-portals ref: dev @@ -46,16 +46,8 @@ jobs: env: combined: ${{ github.workspace }}/combined - - name: Create gma file - run: | - wget -O /tmp/fastgmad.zip "https://github.com/WilliamVenner/fastgmad/releases/download/v0.2.0/fastgmad_linux.zip" - unzip /tmp/fastgmad.zip -d /tmp/fastgmad - chmod +x /tmp/fastgmad/fastgmad - mkdir -p /tmp/addon - /tmp/fastgmad/fastgmad create -folder . -out /tmp/addon/addon.gma - working-directory: ${{ github.workspace }}/combined - - name: Set workshop addon id + id: workshop_id if: (github.event_name == 'push' && contains(fromJSON('["refs/heads/dev"]'), github.ref)) || github.event.inputs.publish == 'true' run: | if [[ "${{ github.event.inputs.addon }}" == "beta" || "${{ github.ref }}" == "refs/heads/dev" ]]; then @@ -66,15 +58,15 @@ jobs: fi echo "Publishing to workshop ID $WORKSHOP_ID" - echo "WORKSHOP_ID=$WORKSHOP_ID" >> $GITHUB_ENV + echo "WORKSHOP_ID=$WORKSHOP_ID" >> $GITHUB_OUTPUT - - name: Publish to workshop - if: env.WORKSHOP_ID - run: | - docker run --rm \ - -e STEAM_USER="${{ vars.STEAM_USERNAME }}" \ - -e STEAM_PASSWORD="${{ secrets.STEAM_PASSWORD }}" \ - --mount type=bind,source="/tmp/addon",target=/home/gmodws/upload \ - aperturedevelopment/gmodws:latest \ - upload ${{ env.WORKSHOP_ID }} addon.gma \ - "${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}" + - uses: AmyJeanes/gmod-upload@main + name: Publish to workshop + with: + id: ${{ steps.workshop_id.outputs.WORKSHOP_ID }} + changelog: "${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}" + folder: ${{ github.workspace }}/combined + dry-run: ${{ steps.workshop_id.outputs.WORKSHOP_ID == '' }} + env: + STEAM_USERNAME: ${{ vars.STEAM_USERNAME }} + STEAM_PASSWORD: ${{ secrets.STEAM_PASSWORD }} diff --git a/lua/doors/libraries/sh_entities.lua b/lua/doors/libraries/sh_entities.lua index f4e0be1..7c1e02e 100644 --- a/lua/doors/libraries/sh_entities.lua +++ b/lua/doors/libraries/sh_entities.lua @@ -3,9 +3,13 @@ Doors.Interiors={} function Doors:AddInterior(e) self.Interiors[e]=true + + hook.Call("Doors-InteriorAdded", GAMEMODE, e) end function Doors:RemoveInterior(e) self.Interiors[e]=nil + + hook.Call("Doors-InteriorRemoved", GAMEMODE, e) end function Doors:GetInteriors() return self.Interiors @@ -14,10 +18,14 @@ end Doors.Exteriors={} function Doors:AddExterior(e) self.Exteriors[e]=true + + hook.Call("Doors-ExteriorAdded", GAMEMODE, e) end function Doors:RemoveExterior(e) self.Exteriors[e]=nil + + hook.Call("Doors-ExteriorRemoved", GAMEMODE, e) end function Doors:GetExteriors() return self.Exteriors -end \ No newline at end of file +end diff --git a/lua/entities/gmod_door_exterior/modules/sh_interior.lua b/lua/entities/gmod_door_exterior/modules/sh_interior.lua index ebdbec0..0cb9b50 100644 --- a/lua/entities/gmod_door_exterior/modules/sh_interior.lua +++ b/lua/entities/gmod_door_exterior/modules/sh_interior.lua @@ -1,6 +1,6 @@ -- Adds an interior - +CreateConVar("doors_interior_tries", 10000, {FCVAR_ARCHIVE, FCVAR_REPLICATED, FCVAR_NOTIFY}, "Doors - How many tries to find a valid interior placement") if SERVER then function ENT:FindPosition(e) @@ -16,7 +16,7 @@ if SERVER then td.maxs=e.maxs or e:OBBMaxs() td.mask=MASK_PLAYERSOLID local max=16384 - local tries=10000 + local tries=GetConVar("doors_interior_tries"):GetInt() local targetframetime=1/30 local nowhere local highest diff --git a/lua/entities/gmod_door_exterior/modules/sh_players.lua b/lua/entities/gmod_door_exterior/modules/sh_players.lua index 19af97c..27594c0 100644 --- a/lua/entities/gmod_door_exterior/modules/sh_players.lua +++ b/lua/entities/gmod_door_exterior/modules/sh_players.lua @@ -18,9 +18,10 @@ if SERVER then self.occupants[ply]=true net.Start("Doors-EnterExit") net.WriteBool(true) + net.WriteEntity(ply) net.WriteEntity(self) net.WriteEntity(self.interior) - net.Send(ply) + net.Broadcast() ply.door = self ply.doori = self.interior if IsValid(self.interior) then @@ -97,9 +98,10 @@ if SERVER then self.occupants[ply]=nil net.Start("Doors-EnterExit") net.WriteBool(false) + net.WriteEntity(ply) net.WriteEntity(self) net.WriteEntity(self.interior) - net.Send(ply) + net.Broadcast() ply.door = nil ply.doori = nil if not notp and self.Fallback then @@ -138,19 +140,34 @@ if SERVER then end end end) + + ENT:AddHook("PlayerInitialize", "players", function(self) + net.WriteTable(self.occupants) + end) else net.Receive("Doors-EnterExit", function() local enter=net.ReadBool() + local ply=net.ReadEntity() local ext=net.ReadEntity() local int=net.ReadEntity() + + if not IsValid(ply) then return end if enter then - LocalPlayer().door=ext - LocalPlayer().doori=int + ply.door=ext + ply.doori=int + if IsValid(ext) then + ext.occupants[ply]=true + end else - LocalPlayer().door=nil - LocalPlayer().doori=nil + ply.door=nil + ply.doori=nil + if IsValid(ext) then + ext.occupants[ply]=nil + end end + + if ply~=LocalPlayer() then return end if IsValid(ext) and ext._init then if enter then @@ -168,4 +185,8 @@ else end end end) -end \ No newline at end of file + + ENT:AddHook("PlayerInitialize", "players", function(self) + self.occupants = net.ReadTable() + end) +end diff --git a/lua/entities/gmod_door_interior/modules/sh_handleplayers.lua b/lua/entities/gmod_door_interior/modules/sh_handleplayers.lua index 8b6b0c3..36addb1 100644 --- a/lua/entities/gmod_door_interior/modules/sh_handleplayers.lua +++ b/lua/entities/gmod_door_interior/modules/sh_handleplayers.lua @@ -102,14 +102,43 @@ if SERVER then end end) else + ENT:AddHook("Initialize", "handleplayers", function(self) + self.occupants=self.exterior.occupants -- Hooray for referenced tables + end) + ENT:AddHook("ShouldDraw", "handleplayers", function(self) if (LocalPlayer().doori~=self) and not wp.drawing and not self.contains[LocalPlayer().door] then return false end end) + ENT:AddHook("ShouldThink", "handleplayers", function(self) if LocalPlayer().doori~=self then return false end end) + + hook.Add("PrePlayerDraw", "doors-handleplayers", function(ply) + local int=ply.doori + if not IsValid(int) then return end + local localply=LocalPlayer() + local localplyinside=localply.doori==int + local drawingportal=wp.drawing and wp.drawingent==int.portals.exterior + local shoulddraw=int:CallHook("ShouldDrawPlayer", ply, localply) + if (not localplyinside or shoulddraw==false) and not drawingportal then + return true + end + end) + + hook.Add("DrawPhysgunBeam", "doors-handleplayers", function(ply) + local int=ply.doori + if not IsValid(int) then return end + local localply=LocalPlayer() + local localplyinside=localply.doori==int + local drawingportal=wp.drawing and wp.drawingent==int.portals.exterior + local shoulddraw=int:CallHook("ShouldDrawPlayer", ply, localply) + if (not localplyinside or shoulddraw==false) and not drawingportal then + return false + end + end) end \ No newline at end of file