Skip to content

Commit

Permalink
Added GNU Public License and fixed bugs
Browse files Browse the repository at this point in the history
- Fixed a bug in which the client would fail to load GLMVS due to lua
files loading incorrectly, had to recode the addon a bit more and caused
an unexpected result...
- Added the GNU General Public License v3, so nobody can claim they did
this.

Update GLMVS and it should work fine, adding maps still have the same
way of adding them. Nothing has changed for adding, might polish this
later.
  • Loading branch information
ptown2 committed Jun 28, 2013
1 parent 64b7561 commit 12913f4
Show file tree
Hide file tree
Showing 12 changed files with 795 additions and 76 deletions.
596 changes: 596 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

56 changes: 50 additions & 6 deletions lua/autorun/autorun.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,64 @@
include( "fileload.lua" )

if SERVER then
AddCSLuaFile()
AddCSLuaFile( "fileload.lua " )
AddCSLuaFile( "fileload.lua" )
AddCSLuaFile( "init.lua" )
AddCSLuaFile( "shared.lua" )
--AddCSLuaFile( "shared.lua" )
AddCSLuaFile( "sh_addmaps.lua" )
AddCSLuaFile( "cl_init.lua" )

include( "shared.lua" )
-- AddCSLuaFile'd all modules manually...
AddCSLuaFile( "modules/glmvs/shared.lua" )
AddCSLuaFile( "modules/glmvs/sh_convars.lua" )
AddCSLuaFile( "modules/glmvs/cl_init.lua" )
AddCSLuaFile( "modules/gdebug/shared.lua" )
AddCSLuaFile( "modules/skin/cl_zombiesurvival.lua" )
AddCSLuaFile( "modules/utils/cl_init.lua" )

AddCSLuaFile( "gamemodes/gm_zs.lua" )
AddCSLuaFile( "gamemodes/gm_ttt.lua" )
AddCSLuaFile( "gamemodes/gm_zescape.lua" )
AddCSLuaFile( "gamemodes/gm_stalker.lua" )
end

if SERVER then
include( "fileload.lua" )

-- Included all modules manually...
include( "modules/glmvs/shared.lua" )
include( "modules/glmvs/sh_convars.lua" )
include( "modules/glmvs/init.lua" )
include( "modules/glmvs/sv_load.lua" )
include( "modules/gdebug/init.lua" )
include( "modules/gdebug/shared.lua" )
include( "modules/utils/init.lua" )

include( "gamemodes/gm_zs.lua" )
include( "gamemodes/gm_ttt.lua" )
include( "gamemodes/gm_zescape.lua" )
include( "gamemodes/gm_stalker.lua" )

--include( "shared.lua" )
include( "sh_addmaps.lua" )
include( "init.lua" )
end

if CLIENT then
include( "shared.lua" )
include( "fileload.lua" )

-- Included all modules manually...
include( "modules/glmvs/shared.lua" )
include( "modules/glmvs/sh_convars.lua" )
include( "modules/glmvs/cl_init.lua" )
include( "modules/gdebug/shared.lua" )
include( "modules/skin/cl_zombiesurvival.lua" )
include( "modules/utils/cl_init.lua" )

include( "gamemodes/gm_zs.lua" )
include( "gamemodes/gm_ttt.lua" )
include( "gamemodes/gm_zescape.lua" )
include( "gamemodes/gm_stalker.lua" )

--include( "shared.lua" )
include( "sh_addmaps.lua" )
include( "cl_init.lua" )
end
29 changes: 17 additions & 12 deletions lua/autorun/fileload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,21 @@ local function LoadFile( strDirectory, strFile )
local prefix = string.sub( strFile, 0, 3 )
local realFile = strDirectory.. "/" ..strFile

if ( prefix == "cl_" || strFile == "cl_init.lua" ) then
if SERVER then AddCSLuaFile( realFile ) else include( realFile ) end
return
elseif ( prefix == "sh_" || strFile == "shared.lua" ) then
if ( prefix == "sh_" || strFile == "shared.lua" ) then
MsgN( "SHARED Lua file: ", realFile, " loaded." )
if SERVER then AddCSLuaFile( realFile ) end
include( realFile )
return
elseif ( prefix == "cl_" || strFile == "cl_init.lua" ) then
MsgN( "CLIENT Lua file: ", realFile, " loaded." )
if SERVER then AddCSLuaFile( realFile ) else include( realFile ) end
elseif ( prefix == "sv_" || strFile == "init.lua" ) then
MsgN( "SERVER Lua file: ", realFile, " loaded." )
if SERVER then include( realFile ) end
return
elseif strDirectory == "gamemodes" then
MsgN( "GAMEMODE Lua file: ", realFile, " loaded." )
if SERVER then AddCSLuaFile( realFile ) end
include( realFile )
end

AddCSLuaFile( realFile )
include( realFile )
end

function RegisterLuaFolder( strDirectory )
Expand All @@ -67,16 +68,20 @@ function RegisterGamemodes( strDirectory )
LoadFile( strDirectory, filen )

if ( GAME.Name && GAME.ID ) then
GLMVS.Gamemodes[GAME.ID] = GAME
GLMVS.Gamemodes[GAME.Name] = GAME
GLMVS.Gamemodes[ GAME.ID ] = GAME
GLMVS.Gamemodes[ GAME.Name ] = GAME
end

included[filen] = GAME
GAME = nil
end
end
end

function RegisterGamemode( tblGame )
GLMVS.Gamemodes[ tblGame.ID ] = tblGame
GLMVS.Gamemodes[ tblGame.Name ] = tblGame
end

function RegisterLanguages( strDirectory )
local included = {}
--local langlist = GetFileList( strDirectory )
Expand Down
29 changes: 20 additions & 9 deletions lua/cl_init.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
/* --------------------------------------------------------------------------
GLMVS - Globalized Map Voting System
Copyright (C) 2012 Robert Lind (ptown2)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------- */

local VoteFrame = nil

local function CreateFonts()
surface.CreateFont( "VoteTitle", { font = "Bebas Neue", size = util.Sizeto720p( 54, ScrH() ), weight = 500 })
surface.CreateFont( "VoteCaption", { font = "Bebas Neue", size = util.Sizeto720p( 28, ScrH() ), weight = 500 })
end

-- Sort the map and keep the MapID for the server.
for id, info in pairs( GLMVS.Maplist ) do
info.ID = id
end

function Derma_Votemap()
if IsValid( VoteFrame ) then return end

Expand Down Expand Up @@ -43,16 +56,14 @@ function Derma_Votemap()
ListFrame:SetSpaceX( globalspacing )
ListFrame:SetSpaceY( globalspacing )

table.sort( GLMVS.Maplist, GLMVS.SortMaps )

for id, info in pairs( GLMVS.Maplist ) do
local ListItem = ListFrame:Add( "DButton" )
ListItem:SetSize( imapsize, imapsize )
ListItem:SetText( " " )
ListItem:SetDisabled( tobool( info.Locked ) )
ListItem.MapName = info.Name || info.Map
ListItem.ID = id
ListItem.MapID = info.ID
--ListItem.ID = id
ListItem.MapID = id
ListItem.Image = util.IsValidImage( info.Map )
ListItem.Paint = GLMVS.GenericImgButton
ListItem.DoClick = GLMVS.Votemap
Expand Down
6 changes: 5 additions & 1 deletion lua/gamemodes/gm_stalker.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local GAME = {}

-- This one will not work until the creator of this gamemode adds the line to call the hooks.
GAME.ID = "stalker"
GAME.Name = "The Stalker"
Expand Down Expand Up @@ -26,4 +28,6 @@ function GAME:ShouldRestartRound()
return false
end
return true
end
end

GLoader.RegisterGamemode( GAME )
6 changes: 5 additions & 1 deletion lua/gamemodes/gm_ttt.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local GAME = {}

GAME.ID = "ttt"
GAME.Name = "Trouble in Terrorist Town"
GAME.MapPrefix = {"gm", "ttt"}
Expand Down Expand Up @@ -27,4 +29,6 @@ function GAME:ShouldRestartRound()
end

return true
end
end

GLoader.RegisterGamemode( GAME )
12 changes: 5 additions & 7 deletions lua/gamemodes/gm_zescape.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local GAME = {}

GAME.ID = "zombieescape"
GAME.Name = "Zombie Escape"
GAME.MapPrefix = {"ze"}
Expand All @@ -21,11 +23,7 @@ end
function GAME:GetPlayerVote( pl )
local votes = 0

/*
if IsValid(pl) then
votes = votes + ( pl.ZombiesKilled or 0 )
end
*/

return math.ceil(votes / 5)
end
end

GLoader.RegisterGamemode( GAME )
12 changes: 8 additions & 4 deletions lua/gamemodes/gm_zs.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
local GAME = {}

GAME.ID = "zombiesurvival"
GAME.Name = "Zombie Survival"
GAME.MapPrefix = {"zs", "zm", "zh", "zps", "zr", "ze"}
GAME.MapPrefix = {"gm", "zs", "zm", "zh", "zps", "zr", "ze"}
GAME.MapFileDB = "map_zombiesurvival"

GAME.HookEnd = "EndRound"
Expand All @@ -14,11 +16,11 @@ function GAME:ShouldRestartRound()
return GAMEMODE:ShouldRestartRound()
end

function GAME:GetPlayerVote(pl)
function GAME:GetPlayerVote( pl )
local ct = CurTime()
local votes = 0

if IsValid(pl) then
if IsValid( pl ) then
votes = votes + ((pl.ZombiesKilled or 0) / 5)
votes = votes + ((pl.ZombiesKilledAssists or 0) / 2)
votes = votes + ((pl.BrainsEaten or 0) * 2)
Expand All @@ -45,4 +47,6 @@ function GAME:GetPlayerVote(pl)
end

return math.ceil(votes / 5)
end
end

GLoader.RegisterGamemode( GAME )
49 changes: 34 additions & 15 deletions lua/init.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
local CurGamemode = GLMVS.ReturnCurGamemode()
/* --------------------------------------------------------------------------
GLMVS - Globalized Map Voting System
Copyright (C) 2012 Robert Lind (ptown2)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------- */

local function Initialize()
util.ValidFunction( CurGamemode, "OnInitialize" )
Expand Down Expand Up @@ -41,18 +57,15 @@ local function AddVote( pl, cmd, args )
util.ChattoPlayers( pl:Name().. " has voted " ..MapName.. " for " ..CurVotePower.. " votepoints." )
end

local function ClearVote()
local function ClearVote( pl )
if pl.VotedAlready then
GLMVS.Maplist[ pl.VotedAlready ].Votes = GLMVS.Maplist[ pl.VotedAlready ].Votes - pl.VotePower

net.Start( "GLMVS_ReceiveVotes" )
net.WriteInt( pl.VotedAlready, 32 )
net.WriteInt( -pl.VotePower, 32 )
net.Broadcast()
GLMVS.AddVote( pl, pl.VotedAlready, -pl.VotePower )
end
end

local function StartVote()
local CurGamemode = GLMVS.ReturnCurGamemode()

if ( util.ValidFunction( CurGamemode, "ShouldRestartRound" ) || false ) then return end

timer.Simple( math.floor( ( ( util.ValidFunction( CurGamemode, "GetEndTime" ) || 0 ) * 0.15 ) ), function()
Expand All @@ -62,6 +75,8 @@ local function StartVote()
end

local function EndVote()
local CurGamemode = GLMVS.ReturnCurGamemode()

if !( util.ValidFunction( CurGamemode, "ShouldChangeMap" ) || true ) then return end

local winner, votes = GLMVS.GetNextMap()
Expand All @@ -79,12 +94,16 @@ local function EndVote()
end

-- Connect everything for GLMVS to handle.
if ( #GLMVS.Maplist > 0 ) then
concommand.Add( "glmvs_vote", AddVote )
hook.Add( "InitPostEntity", "AddGMHooks", function()
local CurGamemode = GLMVS.ReturnCurGamemode()

hook.Add( "Initialize", "GLMVSHookInit", Initialize )
hook.Add( "PlayerDisconnected", "GLMVSClearVote", ClearVote )
if ( #GLMVS.Maplist > 0 ) then
concommand.Add( "glmvs_vote", AddVote )

hook.Add( util.ValidVariable( CurGamemode, "HookEnd" ), "GLMVSHookStart", StartVote )
hook.Add( util.ValidVariable( CurGamemode, "HookMap" ), "GLMVSHookEnd", EndVote )
end
hook.Add( "Initialize", "GLMVSHookInit", Initialize )
hook.Add( "PlayerDisconnected", "GLMVSClearVote", ClearVote )

hook.Add( util.ValidVariable( CurGamemode, "HookEnd" ), "GLMVSHookStart", StartVote )
hook.Add( util.ValidVariable( CurGamemode, "HookMap" ), "GLMVSHookEnd", EndVote )
end
end )
11 changes: 3 additions & 8 deletions lua/modules/glmvs/cl_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ module( "GLMVS", package.seeall )
net.Receive( "GLMVS_ReceiveVotes", function( pl, len )
local mapid, votes = net.ReadInt( 32 ), net.ReadInt( 32 )

for id, info in pairs( GLMVS.Maplist ) do
if ( info.ID == mapid ) then
GLMVS.Maplist[ id ].Votes = GLMVS.Maplist[ id ].Votes + votes
break
end
end
GLMVS.Maplist[ mapid ].Votes = GLMVS.Maplist[ mapid ].Votes + votes
end )

function Votemap( self )
Expand All @@ -24,7 +19,7 @@ end
function GenericImgButton( self )
local IsLocked = self:GetDisabled()
local c, alpha = color_white, 255
local mapid = self.ID
local mapid = self.MapID

if ( self.Hovered ) then alpha = 185 end
if ( self.Depressed ) then c = Color( 150, 255, 150 ) end
Expand All @@ -35,7 +30,7 @@ function GenericImgButton( self )
surface.DrawTexturedRect( 0, 0, self:GetWide() , self:GetTall() )

if ( IsLocked ) then
local iconmult = 0.47
local iconmult = 0.45

surface.SetDrawColor( color_white )
surface.SetMaterial( Material( "icon128/padlock.png", "smooth" ) )
Expand Down
Loading

0 comments on commit 12913f4

Please sign in to comment.