Fixed caching bug (Net) & improved logs

master
AlmTech Software 5 years ago
parent 5af2943167
commit 6c93bff54c
  1. 8
      entities/entities/q_crafting_station/init.lua
  2. 4
      gamemode/engine/core/server/sv_player_damage.lua
  3. 2
      gamemode/engine/core/server/sv_player_init.lua
  4. 2
      gamemode/engine/lib/server/sv_character.lua
  5. 2
      gamemode/engine/lib/server/sv_inventory.lua
  6. 40
      gamemode/engine/lib/server/sv_networking.lua
  7. 4
      gamemode/engine/vars/sh_vars.lua

@ -24,14 +24,6 @@ function ENT:Initialize()
end
function ENT:Use( activator, caller )
-- if( activator:IsPlayer() ) then
-- if( activator.isloaded ) then
-- Quantum.Net.OpenMenu( activator, "crafting" )
-- end
-- end
end
function ENT:InitializeStation( stationid, pos, ang )
if( pos == nil || ang == nil ) then return end

@ -17,11 +17,11 @@ local damagescales = {
function GM:ScalePlayerDamage( pl, hitgroup, dmginfo ) -- This is used for getting shot etc
if( damagescales[hitgroup] ~= nil ) then dmginfo:ScaleDamage( damagescales[hitgroup] ) end
Quantum.Debug( tostring(pl) .. " got damaged ( " .. tostring(hitgroup) .. " : " .. tostring( math.Round( dmginfo:GetDamage() ) ) .. " )" )
Quantum.Debug( Quantum.PrintPlayer( pl ) .. " got damaged ( " .. tostring(hitgroup) .. " : " .. tostring( math.Round( dmginfo:GetDamage() ) ) .. " )" )
end
function GM:GetFallDamage( pl, vel )
Quantum.Debug( tostring(pl) .. " got damaged ( Fall Damage : " .. tostring( math.Round( vel / 8 ) ) .. " )" )
Quantum.Debug( Quantum.PrintPlayer( pl ) .. " got damaged ( Fall Damage : " .. tostring( math.Round( vel / 8 ) ) .. " )" )
return vel / 8 -- Makes the player take more "realistic" fall damage
end

@ -48,7 +48,7 @@ local function setUpPlayer( ply )
ply:Give( "quantum_hands" )
ply:SelectWeapon( "quantum_hands" )
Quantum.Debug( tostring( ply ) .. charnametxt )
Quantum.Debug( Quantum.PrintPlayer( pl ) .. charnametxt )
end
function GM:PlayerSpawn( ply )

@ -64,7 +64,7 @@ function Quantum.Server.Char.Remove( pl, index )
end
function Quantum.Server.Char.GetCurrentCharacter( pl )
if( pl.character == nil ) then Quantum.Error( tostring( pl ) .. " doesn't have a character! Unable to get current character table." ) end
if( pl.character == nil ) then Quantum.Error( Quantum.PrintPlayer( pl ) .. " doesn't have a character! Unable to get current character table." ) end
return pl.character
end

@ -367,7 +367,7 @@ function Quantum.Server.Inventory.DropItem( pl, index, amount ) -- Quantum.Serve
Quantum.Server.Item.SpawnItemAtPlayer( pl, itemid, amount )
end
else
Quantum.Error( "Player " .. tostring( pl ) .. " tried to drop a something from index=" .. tostring(index) .. " where there exists no item." )
Quantum.Error( "Player " .. Quantum.PrintPlayer( pl ) .. " tried to drop a something from index=" .. tostring(index) .. " where there exists no item." )
end
end

@ -18,26 +18,27 @@ local function checkCacheTable( ply, cache_id, dt )
Quantum.Error( tostring(ply) .. " does not have a cache table, creating..." )
ply.cache = {}
if( ply.cache ~= nil ) then Quantum.Debug( "Success! Created cache table for " .. tostring(ply) ) end
else
if( ply.cache[cache_id] == nil ) then
Quantum.Debug( tostring(ply) .. " does not have a cache for '" .. tostring(cache_id) .. "'. Creating..." )
ply.cache[cache_id] = {
id = cache_id,
cache = datatable
}
if( ply.cache[cache_id] ~= nil && table.Count( ply.cache[cache_id] ) >= 1 ) then
Quantum.Debug( "Success! Created cache '" .. tostring(cache_id) .. "' for " .. tostring(ply) .. "." )
if( ply.cache[cache_id].count == nil ) then
ply.cache[cache_id].count = 1
else
ply.cache[cache_id].count = ply.cache[cache_id].count + 1 -- keep count
end
end
if( ply.cache[cache_id] == nil ) then
Quantum.Debug( tostring(ply) .. " does not have a cache for '" .. tostring(cache_id) .. "'. Creating..." )
ply.cache[cache_id] = {
id = cache_id,
cache = datatable
}
if( ply.cache[cache_id] ~= nil ) then
Quantum.Debug( "Success! Created cache '" .. tostring(cache_id) .. "' for " .. tostring(ply) .. "." )
if( ply.cache[cache_id].count == nil ) then
ply.cache[cache_id].count = 1
else
Quantum.Error( "Failed. Creation of cache '" .. tostring(cache_id) .. "' for " .. tostring(ply) .. " failed to validate or did not get created." )
ply.cache[cache_id] = nil -- remove the cache since it is "broken"
ply.cache[cache_id].count = ply.cache[cache_id].count + 1 -- keep count
end
else
Quantum.Error( "Failed. Creation of cache '" .. tostring(cache_id) .. "' for " .. tostring(ply) .. " failed to validate or did not get created." )
ply.cache[cache_id] = nil -- remove the cache since it is "broken"
end
end
return ply.cache[cache_id]
end
@ -45,7 +46,6 @@ local function CacheDatatableMethod( id, datatable, ply )
ply.cache[id] = checkCacheTable( ply, id, datatable ) -- check caching tables etc
Quantum.Debug( "(" .. tostring(ply) .. " | " .. tostring(id) .. ") Removing known data in cache from datatable..." )
if( ply.cache[id] ~= nil ) then
PrintTable(ply.cache[id])
if( ply.cache[id].count > 1 ) then -- dont want to filter out data if this is the first time.
for k, v in pairs( datatable ) do -- loop through the datatable
for k2, v2 in pairs( table.GetKeys( ply.cache[id].cache ) ) do -- check each key with each key from the record cache
@ -79,7 +79,7 @@ local function SendDatatableToClient( client, dt, type )
net.WriteTable( datatable ) -- send the data to the player
end
net.Send( client )
Quantum.Debug("Net message sent.")
Quantum.Debug("Net message sent.\n")
end
function Quantum.Net.OpenMenu( pl, type, dt )
@ -95,10 +95,10 @@ local netfuncs = {
createChar = function( pl, args )
pl.charcount = Quantum.Server.Char.GetCharCount( pl )
if( #args.name > 16 ) then
Quantum.Debug( "Player " .. tostring( pl ) .. " character name too long. Unable to create." )
Quantum.Debug( "Player " .. Quantum.PrintPlayer( pl ) .. " character name too long. Unable to create." )
return
elseif( pl.charcount + 1 > Quantum.CharacterLimit ) then -- character limit
Quantum.Debug( "Player " .. tostring( pl ) .. " tried to exceed their character limit." )
Quantum.Debug( "Player " .. Quantum.PrintPlayer( pl ) .. " tried to exceed their character limit." )
return
end
Quantum.Server.Char.Load( pl, pl.charcount + 1, args )

@ -52,3 +52,7 @@ function Quantum.calculateNeededBits( n ) return math.ceil( math.log( n, 2 ) ) e
function Quantum.WriteIntcode( intcode )
net.WriteInt( intcode, Quantum.IntCode.BIT_SIZE )
end
function Quantum.PrintPlayer( pl )
return pl:Nick() .. " | " .. pl:SteamID()
end
Loading…
Cancel
Save