Merge branch 'master' into pr/317

This commit is contained in:
H-M-H 2015-11-15 00:05:04 +01:00
commit 8d9dd65f0b
53 changed files with 561 additions and 476 deletions

View file

@ -12,8 +12,10 @@ Building
To compile DDNet yourself, you can follow the [instructions for compiling Teeworlds](https://www.teeworlds.com/?page=docs&wiki=compiling_everything).
DDNet requires additional libraries, that are bundled for the most common platforms (Windows, Mac, Linux, all x86 and x86_64). Instead you can install these libraries on your system, remove the `config.lua` and `bam` should use the system-wide libraries by default: `libcurl, libogg, libopus, libopusfile`
DDNet requires additional libraries, that are bundled for the most common platforms (Windows, Mac, Linux, all x86 and x86_64). Instead you can install these libraries on your system, remove the `config.lua` and `bam` should use the system-wide libraries by default. You can install all required dependencies on Debian and Ubuntu like this:
apt-get install libsdl1.2-dev libfreetype6-dev libcurl4-openssl-dev libogg-dev libopus-dev libopusfile-dev
If you have the libraries installed, but still want to use the bundled ones instead, you can specify so by running `bam config curl.use_pkgconfig=false opus.use_pkgconfig=false opusfile.use_pkgconfig=false ogg.use_pkgconfig=false`.
The MySQL server is not included in the binary releases and can be built with `bam server_sql_release`. It requires `libmariadbclient-dev` and `libmysqlcppconn-dev`, which are also bundled for the common platforms.
The MySQL server is not included in the binary releases and can be built with `bam server_sql_release`. It requires `libmariadbclient-dev`, `libmysqlcppconn-dev` and `libboost-dev`, which are also bundled for the common platforms.

View file

@ -26,6 +26,9 @@ sv_rcon_password ""
# rcon (F2) password for moderator. If you don't set one, none exists.
sv_rcon_mod_password ""
# rcon (F2) password for helper. If you don't set one, none exists.
sv_rcon_helper_password ""
# Map to start server with
sv_map "Kobra 4"
@ -137,36 +140,47 @@ add_vote "Option: Shutdown server" "shutdown"
# ADDITIONAL COMMANDS PERMISSIONS
# -------------------------------
# You can see all commands which are accessible for moderators by using "mod_status"
# and "user_status" for normal players
# You can see all commands which are accessible for specific authentication-levels by using "access_status"
# Format: acces_status [0: admin, 1: moderator, 2: helper or 3: user]
#
# Format: mod_command [command] [0 or 1]
# Where 0 means no permissions to use, and 1 gives access to command
# Format: access_level [command] [0: admin, 1: moderator, 2: helper or 3: user]
# Where 0 means only accessible for admin, 1 gives access to moderator and 2 gives access to helper
# Example: mod_command ban 1
# Non-default commands to which moderator will have access
mod_command left 1
mod_command right 1
mod_command up 1
mod_command down 1
mod_command super 1
mod_command unsuper 1
mod_command tele 1
mod_command totele 1
mod_command totelecp 1
mod_command logout 1
mod_command ninja 1
mod_command grenade 1
mod_command shotgun 1
mod_command rifle 1
mod_command weapons 1
mod_command unweapons 1
mod_command unrifle 1
mod_command unshotgun 1
mod_command ungrenade 1
mod_command unsolo 1
mod_command undeep 1
mod_command status 1
# Non-default commands to which moderators and helpers will have access
access_level left 2
access_level right 2
access_level up 2
access_level down 2
access_level super 2
access_level unsuper 2
access_level tele 2
access_level totele 2
access_level totelecp 2
access_level logout 2
access_level ninja 2
access_level grenade 2
access_level shotgun 2
access_level rifle 2
access_level weapons 2
access_level unweapons 2
access_level unrifle 2
access_level unshotgun 2
access_level ungrenade 2
access_level unsolo 2
access_level undeep 2
access_level status 2
# commands for moderators only
access_level ban 1
access_level unban 1
access_level ban_range 1
access_level unban_range 1
access_level unban_all 1
access_level bans 1
access_level bans_save 1
access_level kick 1
access_level force_vote 1

110
bam.lua
View file

@ -1,5 +1,18 @@
CheckVersion("0.4")
target_family = os.getenv("TARGET_FAMILY")
if target_family then
family = target_family
end
target_platform = os.getenv("TARGET_PLATFORM")
if target_platform then
platform = target_platform
end
target_arch = os.getenv("TARGET_ARCH")
if target_arch then
arch = target_arch
end
Import("configure.lua")
Import("other/sdl/sdl.lua")
Import("other/freetype/freetype.lua")
@ -28,7 +41,7 @@ config:Finalize("config.lua")
-- data compiler
function Script(name)
if family == "windows" then
if family == "windows" and target_family ~= "windows" then
return str_replace(name, "/", "\\")
end
return "python " .. name
@ -67,14 +80,20 @@ DuplicateDirectoryStructure("src", "src", "objs")
]]
function ResCompile(scriptfile)
windres = os.getenv("WINDRES")
if not windres then
windres = "windres"
end
scriptfile = Path(scriptfile)
if config.compiler.driver == "cl" then
output = PathBase(scriptfile) .. ".res"
AddJob(output, "rc " .. scriptfile, "rc /fo " .. output .. " " .. scriptfile)
elseif config.compiler.driver == "gcc" then
output = PathBase(scriptfile) .. ".coff"
AddJob(output, "windres " .. scriptfile, "windres -i " .. scriptfile .. " -o " .. output)
AddJob(output, windres .. " " .. scriptfile, windres .. " -i " .. scriptfile .. " -o " .. output)
end
AddDependency(output, scriptfile)
return output
end
@ -128,36 +147,37 @@ server_sql_depends = {}
if family == "windows" then
if platform == "win32" then
table.insert(client_depends, CopyToDirectory(".", "other\\freetype\\lib32\\freetype.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\sdl\\lib32\\SDL.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/freetype/lib32/freetype.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/sdl/lib32/SDL.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\curl\\windows\\lib32\\libcurl.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\curl\\windows\\lib32\\libeay32.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\curl\\windows\\lib32\\libidn-11.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\curl\\windows\\lib32\\ssleay32.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\curl\\windows\\lib32\\zlib1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/curl/windows/lib32/libcurl.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/curl/windows/lib32/libeay32.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/curl/windows/lib32/libidn-11.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/curl/windows/lib32/ssleay32.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/curl/windows/lib32/zlib1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\opus\\windows\\lib32\\libgcc_s_sjlj-1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\opus\\windows\\lib32\\libogg-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\opus\\windows\\lib32\\libopus-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\opus\\windows\\lib32\\libopusfile-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib32/libwinpthread-1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib32/libgcc_s_sjlj-1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib32/libogg-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib32/libopus-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib32/libopusfile-0.dll"))
else
table.insert(client_depends, CopyToDirectory(".", "other\\freetype\\lib64\\freetype.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\sdl\\lib64\\SDL.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/freetype/lib64/freetype.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/sdl/lib64/SDL.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\curl\\windows\\lib64\\libcurl.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\curl\\windows\\lib64\\libeay32.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\curl\\windows\\lib64\\ssleay32.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\curl\\windows\\lib64\\zlib1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/curl/windows/lib64/libcurl.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/curl/windows/lib64/libeay32.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/curl/windows/lib64/ssleay32.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/curl/windows/lib64/zlib1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\opus\\windows\\lib64\\libwinpthread-1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\opus\\windows\\lib64\\libgcc_s_seh-1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\opus\\windows\\lib64\\libogg-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\opus\\windows\\lib64\\libopus-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\opus\\windows\\lib64\\libopusfile-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib64/libwinpthread-1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib64/libgcc_s_seh-1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib64/libogg-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib64/libopus-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib64/libopusfile-0.dll"))
end
table.insert(server_sql_depends, CopyToDirectory(".", "other\\mysql\\vc2005libs\\mysqlcppconn.dll"))
table.insert(server_sql_depends, CopyToDirectory(".", "other\\mysql\\vc2005libs\\libmysql.dll"))
table.insert(server_sql_depends, CopyToDirectory(".", "other/mysql/vc2005libs/mysqlcppconn.dll"))
table.insert(server_sql_depends, CopyToDirectory(".", "other/mysql/vc2005libs/libmysql.dll"))
if config.compiler.driver == "cl" then
client_link_other = {ResCompile("other/icons/teeworlds_cl.rc")}
@ -175,13 +195,20 @@ end
function build(settings)
-- apply compiler settings
config.compiler:Apply(settings)
--settings.objdir = Path("objs")
settings.cc.Output = Intermediate_Output
--settings.cc.flags:Add("-m32")
--settings.link.flags:Add("-m32")
cc = os.getenv("CC")
if cc then
settings.cc.exe_c = cc
end
cxx = os.getenv("CXX")
if cxx then
settings.cc.exe_cxx = cxx
settings.link.exe = cxx
settings.dll.exe = cxx
end
cflags = os.getenv("CFLAGS")
if cflags then
settings.cc.flags:Add(cflags)
@ -228,14 +255,12 @@ function build(settings)
if platform == "macosx" then
settings.link.frameworks:Add("Carbon")
settings.link.frameworks:Add("AppKit")
settings.link.libs:Add("dl")
settings.link.libs:Add("crypto")
else
settings.link.libs:Add("pthread")
settings.link.libs:Add("dl")
settings.link.libs:Add("rt")
end
if platform == "solaris" then
settings.link.flags:Add("-lsocket")
settings.link.flags:Add("-lnsl")
@ -288,7 +313,6 @@ function build(settings)
client_settings.link.libs:Add("X11")
client_settings.link.libs:Add("GL")
client_settings.link.libs:Add("GLU")
client_settings.link.libs:Add("dl")
end
elseif family == "windows" then
@ -315,6 +339,13 @@ function build(settings)
config.opus:Apply(client_settings)
config.ogg:Apply(client_settings)
if family == "unix" and (platform == "macosx" or platform == "linux") then
engine_settings.link.libs:Add("dl")
server_settings.link.libs:Add("dl")
client_settings.link.libs:Add("dl")
launcher_settings.link.libs:Add("dl")
end
engine = Compile(engine_settings, Collect("src/engine/shared/*.cpp", "src/base/*.c"))
client = Compile(client_settings, Collect("src/engine/client/*.cpp"))
server = Compile(server_settings, Collect("src/engine/server/*.cpp"))
@ -336,7 +367,6 @@ function build(settings)
if platform == "macosx" then
notification_settings = client_settings:Copy()
notification_settings.cc.flags:Add("-x objective-c++")
notification_settings.cc.flags:Add("-I/System/Library/Frameworks/Foundation.framework/Versions/C/Headers")
client_notification = Compile(notification_settings, "src/osx/notification.m")
client_osxlaunch = Compile(client_settings, "src/osxlaunch/client.m")
server_osxlaunch = Compile(launcher_settings, "src/osxlaunch/server.m")
@ -434,14 +464,14 @@ if platform == "macosx" then
debug_sql_settings_ppc.cc.flags:Add("-arch ppc")
debug_sql_settings_ppc.link.flags:Add("-arch ppc")
debug_sql_settings_ppc.cc.defines:Add("CONF_DEBUG", "CONF_SQL")
release_settings_ppc = release_settings:Copy()
release_settings_ppc.config_name = "release_ppc"
release_settings_ppc.config_ext = "_ppc"
release_settings_ppc.cc.flags:Add("-arch ppc")
release_settings_ppc.link.flags:Add("-arch ppc")
release_settings_ppc.cc.defines:Add("CONF_RELEASE")
release_sql_settings_ppc = release_sql_settings:Copy()
release_sql_settings_ppc.config_name = "sql_release_ppc"
release_sql_settings_ppc.config_ext = "_sql_ppc"
@ -475,7 +505,7 @@ if platform == "macosx" then
release_settings_x86.cc.flags:Add("-arch i386")
release_settings_x86.link.flags:Add("-arch i386")
release_settings_x86.cc.defines:Add("CONF_RELEASE")
release_sql_settings_x86 = release_sql_settings:Copy()
release_sql_settings_x86.config_name = "sql_release_x86"
release_sql_settings_x86.config_ext = "_sql_x86"
@ -510,7 +540,7 @@ if platform == "macosx" then
release_settings_x86_64.cc.flags:Add("-arch x86_64")
release_settings_x86_64.link.flags:Add("-arch x86_64")
release_settings_x86_64.cc.defines:Add("CONF_RELEASE")
release_sql_settings_x86_64 = release_sql_settings:Copy()
release_sql_settings_x86_64.config_name = "sql_release_x86_64"
release_sql_settings_x86_64.config_ext = "_sql_x86_64"
@ -525,7 +555,7 @@ if platform == "macosx" then
end
DefaultTarget("game_debug_x86")
if config.macosxppc.value == 1 then
if arch == "ia32" then
PseudoTarget("release", ppc_r, x86_r)

View file

@ -382,8 +382,8 @@ function OptCCompiler(name, default_driver, default_c, default_cxx, desc)
error(option.driver.." is not a known c/c++ compile driver")
end
if option.c_compiler then settings.cc.c_compiler = option.c_compiler end
if option.cxx_compiler then settings.cc.cxx_compiler = option.cxx_compiler end
if option.c_compiler then settings.cc.exe_c = option.c_compiler end
if option.cxx_compiler then settings.cc.exe_cxx = option.cxx_compiler end
end
local save = function(option, output)

View file

@ -12,7 +12,7 @@ Curl = {
option.use_pkgconfig = true
end
if ExecuteSilent("pkg-config libcurl") == 0 then
if family ~= "windows" and ExecuteSilent("pkg-config libcurl") == 0 then
option.value = true
if option.use_pkgconfig == nil then
option.use_pkgconfig = true
@ -59,10 +59,9 @@ Curl = {
settings.link.libpath:Add("other/curl/mac/lib32")
elseif platform == "macosx" and string.find(settings.config_name, "64") then
settings.link.libpath:Add("other/curl/mac/lib64")
elseif platform == "linux" and arch == "ia32" then
settings.link.libpath:Add("other/curl/linux/lib32")
elseif platform == "linux" and arch == "amd64" then
elseif platform == "linux" then
settings.link.libpath:Add("other/curl/linux/lib64")
settings.link.libpath:Add("other/curl/linux/lib32")
end
end
end

View file

@ -4,13 +4,13 @@ FreeType = {
OptFind = function (name, required)
local check = function(option, settings)
option.value = false
option.use_ftconfig = false
option.use_pkgconfig = false
option.use_winlib = 0
option.lib_path = nil
if ExecuteSilent("freetype-config") > 0 and ExecuteSilent("freetype-config --cflags") == 0 then
if family ~= "windows" and ExecuteSilent("pkg-config freetype2") == 0 then
option.value = true
option.use_ftconfig = true
option.use_pkgconfig = true
end
if platform == "win32" then
@ -26,9 +26,9 @@ FreeType = {
-- include path
settings.cc.includes:Add(FreeType.basepath .. "/include")
if option.use_ftconfig == true then
settings.cc.flags:Add("`freetype-config --cflags`")
settings.link.flags:Add("`freetype-config --libs`")
if option.use_pkgconfig == true then
settings.cc.flags:Add("`pkg-config freetype2 --cflags`")
settings.link.flags:Add("`pkg-config freetype2 --libs`")
elseif option.use_winlib > 0 then
if option.use_winlib == 32 then
@ -42,13 +42,13 @@ FreeType = {
local save = function(option, output)
output:option(option, "value")
output:option(option, "use_ftconfig")
output:option(option, "use_pkgconfig")
output:option(option, "use_winlib")
end
local display = function(option)
if option.value == true then
if option.use_ftconfig == true then return "using freetype-config" end
if option.use_pkgconfig == true then return "using pkg-config" end
if option.use_winlib == 32 then return "using supplied win32 libraries" end
if option.use_winlib == 64 then return "using supplied win64 libraries" end
return "using unknown method"

View file

@ -57,10 +57,9 @@ Mysql = {
settings.link.libpath:Add("other/mysql/mac/lib32")
elseif platform == "macosx" and string.find(settings.config_name, "64") then
settings.link.libpath:Add("other/mysql/mac/lib64")
elseif platform == "linux" and arch == "ia32" then
settings.link.libpath:Add("other/mysql/linux/lib32")
elseif platform == "linux" and arch == "amd64" then
elseif platform == "linux" then
settings.link.libpath:Add("other/mysql/linux/lib64")
settings.link.libpath:Add("other/mysql/linux/lib32")
end
end
end

View file

@ -12,7 +12,7 @@ Ogg = {
option.use_pkgconfig = true
end
if ExecuteSilent("pkg-config ogg") == 0 then
if family ~= "windows" and ExecuteSilent("pkg-config ogg") == 0 then
option.value = true
if option.use_pkgconfig == nil then
option.use_pkgconfig = true
@ -58,10 +58,9 @@ Ogg = {
client_settings.link.libpath:Add("other/opus/mac/lib32")
elseif platform == "macosx" and string.find(settings.config_name, "64") then
client_settings.link.libpath:Add("other/opus/mac/lib64")
elseif platform == "linux" and arch == "ia32" then
client_settings.link.libpath:Add("other/opus/linux/lib32")
elseif platform == "linux" and arch == "amd64" then
elseif platform == "linux" then
client_settings.link.libpath:Add("other/opus/linux/lib64")
client_settings.link.libpath:Add("other/opus/linux/lib32")
end
end
end

View file

@ -12,7 +12,7 @@ Opus = {
option.use_pkgconfig = true
end
if ExecuteSilent("pkg-config opus") == 0 then
if family ~= "windows" and ExecuteSilent("pkg-config opus") == 0 then
option.value = true
if option.use_pkgconfig == nil then
option.use_pkgconfig = true
@ -58,10 +58,9 @@ Opus = {
client_settings.link.libpath:Add("other/opus/mac/lib32")
elseif platform == "macosx" and string.find(settings.config_name, "64") then
client_settings.link.libpath:Add("other/opus/mac/lib64")
elseif platform == "linux" and arch == "ia32" then
client_settings.link.libpath:Add("other/opus/linux/lib32")
elseif platform == "linux" and arch == "amd64" then
elseif platform == "linux" then
client_settings.link.libpath:Add("other/opus/linux/lib64")
client_settings.link.libpath:Add("other/opus/linux/lib32")
end
end
end

View file

@ -12,7 +12,7 @@ Opusfile = {
option.use_pkgconfig = true
end
if ExecuteSilent("pkg-config opusfile") == 0 then
if family ~= "windows" and ExecuteSilent("pkg-config opusfile") == 0 then
option.value = true
if option.use_pkgconfig == nil then
option.use_pkgconfig = true
@ -58,10 +58,9 @@ Opusfile = {
client_settings.link.libpath:Add("other/opus/mac/lib32")
elseif platform == "macosx" and string.find(settings.config_name, "64") then
client_settings.link.libpath:Add("other/opus/mac/lib64")
elseif platform == "linux" and arch == "ia32" then
client_settings.link.libpath:Add("other/opus/linux/lib32")
elseif platform == "linux" and arch == "amd64" then
elseif platform == "linux" then
client_settings.link.libpath:Add("other/opus/linux/lib64")
client_settings.link.libpath:Add("other/opus/linux/lib32")
end
end
end

Binary file not shown.

View file

@ -4,14 +4,14 @@ SDL = {
OptFind = function (name, required)
local check = function(option, settings)
option.value = false
option.use_sdlconfig = false
option.use_pkgconfig = false
option.use_winlib = 0
option.use_osxframework = false
option.lib_path = nil
if ExecuteSilent("sdl-config") > 0 and ExecuteSilent("sdl-config --cflags") == 0 then
if family ~= "windows" and ExecuteSilent("pkg-config sdl") == 0 then
option.value = true
option.use_sdlconfig = true
option.use_pkgconfig = true
end
if platform == "win32" then
@ -25,14 +25,14 @@ SDL = {
if platform == "macosx" then
option.value = true
option.use_osxframework = true
option.use_sdlconfig = false
option.use_pkgconfig = false
end
end
local apply = function(option, settings)
if option.use_sdlconfig == true then
settings.cc.flags:Add("`sdl-config --cflags`")
settings.link.flags:Add("`sdl-config --libs`")
if option.use_pkgconfig == true then
settings.cc.flags:Add("`pkg-config sdl --cflags`")
settings.link.flags:Add("`pkg-config sdl --libs`")
end
if option.use_osxframework == true then
@ -54,14 +54,14 @@ SDL = {
local save = function(option, output)
output:option(option, "value")
output:option(option, "use_sdlconfig")
output:option(option, "use_pkgconfig")
output:option(option, "use_winlib")
output:option(option, "use_osxframework")
end
local display = function(option)
if option.value == true then
if option.use_sdlconfig == true then return "using sdl-config" end
if option.use_pkgconfig == true then return "using pkg-config" end
if option.use_winlib == 32 then return "using supplied win32 libraries" end
if option.use_winlib == 64 then return "using supplied win64 libraries" end
if option.use_osxframework == true then return "using osx framework" end

View file

@ -18,6 +18,7 @@ rm -rf AndroidData
# Actual compilation, needs a key to sign
cd /media/commandergenius
ln -s teeworlds project/jni/application/src
./changeAppSettings.sh -a
android update project -p project
./build.sh

View file

@ -74,8 +74,8 @@ if include_data and not use_bundle:
shutil.copy("libgcc_s_sjlj-1.dll", package_dir)
shutil.copy("libidn-11.dll", package_dir)
elif platform == "win64":
shutil.copy("libwinpthread-1.dll", package_dir)
shutil.copy("libgcc_s_seh-1.dll", package_dir)
shutil.copy("libwinpthread-1.dll", package_dir)
shutil.copy("libogg-0.dll", package_dir)
shutil.copy("libopus-0.dll", package_dir)
shutil.copy("libopusfile-0.dll", package_dir)

View file

@ -32,6 +32,13 @@
#define CONF_PLATFORM_STRING "freebsd"
#endif
#if defined(__NetBSD__)
#define CONF_FAMILY_UNIX 1
#define CONF_FAMILY_STRING "unix"
#define CONF_PLATFORM_NETBSD 1
#define CONF_PLATFORM_STRING "netbsd"
#endif
#if defined(__OpenBSD__)
#define CONF_FAMILY_UNIX 1
#define CONF_FAMILY_STRING "unix"
@ -82,7 +89,7 @@
/* use gcc endianness definitions when available */
#if defined(__GNUC__) && !defined(__APPLE__) && !defined(__MINGW32__) && !defined(__sun)
#if defined(__FreeBSD__) || defined(__OpenBSD__)
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
#include <sys/endian.h>
#else
#include <endian.h>

View file

@ -49,6 +49,7 @@
#elif defined(CONF_FAMILY_WINDOWS)
#define WIN32_LEAN_AND_MEAN
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0501 /* required for mingw to get getaddrinfo to work */
#include <windows.h>
#include <winsock2.h>
@ -181,9 +182,7 @@ void dbg_enable_threaded()
dbg_msg_threaded = 1;
Thread = thread_init(dbg_msg_thread, 0);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)Thread);
#endif
thread_detach(Thread);
}
#endif
@ -192,7 +191,6 @@ void dbg_msg(const char *sys, const char *fmt, ...)
va_list args;
char *msg;
int len;
int e;
//str_format(str, sizeof(str), "[%08x][%s]: ", (int)time(0), sys);
time_t rawtime;
@ -207,6 +205,7 @@ void dbg_msg(const char *sys, const char *fmt, ...)
#if !defined(CONF_PLATFORM_MACOSX)
if(dbg_msg_threaded)
{
int e;
semaphore_wait(&log_queue.notfull);
semaphore_wait(&log_queue.mutex);
e = queue_empty(&log_queue);
@ -2370,7 +2369,7 @@ int str_utf8_decode(const char **ptr)
{
return byte;
}
else if(0x80 <= byte && byte <= 0xDF)
else if(0xC2 <= byte && byte <= 0xDF)
{
utf8_bytes_needed = 1;
utf8_code_point = byte - 0xC0;

View file

@ -42,7 +42,7 @@ public:
int m_LocalIDs[2];
char m_aNews[NEWS_SIZE];
CNetObj_PlayerInput DummyInput;
CNetObj_PlayerInput m_DummyInput;
bool m_DummySendConnInfo;
@ -210,6 +210,7 @@ public:
virtual int OnSnapInput(int *pData) = 0;
virtual void SendDummyInfo(bool Start) = 0;
virtual void ResetDummyInput() = 0;
virtual const CNetObj_PlayerInput &getPlayerInput(int dummy) = 0;
virtual const char *GetItemName(int Type) = 0;
virtual const char *Version() = 0;

View file

@ -326,7 +326,7 @@ CClient::CClient() : m_DemoPlayer(&m_SnapshotDelta)
m_Fire = 0;
mem_zero(&m_aInputs, sizeof(m_aInputs));
mem_zero(&DummyInput, sizeof(DummyInput));
mem_zero(&m_DummyInput, sizeof(m_DummyInput));
mem_zero(&HammerInput, sizeof(HammerInput));
HammerInput.m_Fire = 0;
@ -510,16 +510,16 @@ void CClient::SendInput()
if(m_LastDummy != (bool)g_Config.m_ClDummy)
{
mem_copy(&DummyInput, &m_aInputs[!g_Config.m_ClDummy][(m_CurrentInput[!g_Config.m_ClDummy]+200-1)%200], sizeof(DummyInput));
m_DummyInput = GameClient()->getPlayerInput(!g_Config.m_ClDummy);
m_LastDummy = g_Config.m_ClDummy;
if (g_Config.m_ClDummyResetOnSwitch)
{
DummyInput.m_Jump = 0;
DummyInput.m_Hook = 0;
if(DummyInput.m_Fire & 1)
DummyInput.m_Fire++;
DummyInput.m_Direction = 0;
m_DummyInput.m_Jump = 0;
m_DummyInput.m_Hook = 0;
if(m_DummyInput.m_Fire & 1)
m_DummyInput.m_Fire++;
m_DummyInput.m_Direction = 0;
GameClient()->ResetDummyInput();
}
}
@ -535,22 +535,22 @@ void CClient::SendInput()
{
if(m_Fire != 0)
{
DummyInput.m_Fire = HammerInput.m_Fire;
m_DummyInput.m_Fire = HammerInput.m_Fire;
m_Fire = 0;
}
if(!Size && (!DummyInput.m_Direction && !DummyInput.m_Jump && !DummyInput.m_Hook))
if(!Size && (!m_DummyInput.m_Direction && !m_DummyInput.m_Jump && !m_DummyInput.m_Hook))
return;
// pack input
CMsgPacker Msg(NETMSG_INPUT);
Msg.AddInt(m_AckGameTick[!g_Config.m_ClDummy]);
Msg.AddInt(m_PredTick[!g_Config.m_ClDummy]);
Msg.AddInt(sizeof(DummyInput));
Msg.AddInt(sizeof(m_DummyInput));
// pack it
for(unsigned int i = 0; i < sizeof(DummyInput)/4; i++)
Msg.AddInt(((int*) &DummyInput)[i]);
for(unsigned int i = 0; i < sizeof(m_DummyInput)/4; i++)
Msg.AddInt(((int*) &m_DummyInput)[i]);
SendMsgExY(&Msg, MSGFLAG_FLUSH, true, !g_Config.m_ClDummy);
}
@ -1493,7 +1493,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
if(Sys)
{
// system message
if(Msg == NETMSG_MAP_CHANGE)
if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_MAP_CHANGE)
{
const char *pMap = Unpacker.GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES);
int MapCrc = Unpacker.GetInt();
@ -1602,7 +1602,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
}
}
}
else if(Msg == NETMSG_CON_READY)
else if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_CON_READY)
{
GameClient()->OnConnected();
}
@ -1611,7 +1611,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
CMsgPacker Msg(NETMSG_PING_REPLY);
SendMsgEx(&Msg, 0);
}
else if(Msg == NETMSG_RCON_CMD_ADD)
else if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_CMD_ADD)
{
const char *pName = Unpacker.GetString(CUnpacker::SANITIZE_CC);
const char *pHelp = Unpacker.GetString(CUnpacker::SANITIZE_CC);
@ -1619,13 +1619,13 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
if(Unpacker.Error() == 0)
m_pConsole->RegisterTemp(pName, pParams, CFGFLAG_SERVER, pHelp);
}
else if(Msg == NETMSG_RCON_CMD_REM)
else if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_CMD_REM)
{
const char *pName = Unpacker.GetString(CUnpacker::SANITIZE_CC);
if(Unpacker.Error() == 0)
m_pConsole->DeregisterTemp(pName);
}
else if(Msg == NETMSG_RCON_AUTH_STATUS)
else if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_AUTH_STATUS)
{
int Result = Unpacker.GetInt();
if(Unpacker.Error() == 0)
@ -1637,7 +1637,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
if(Old != 0 && m_UseTempRconCommands == 0)
m_pConsole->DeregisterTempAll();
}
else if(Msg == NETMSG_RCON_LINE)
else if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_LINE)
{
const char *pLine = Unpacker.GetString();
if(Unpacker.Error() == 0)
@ -1891,12 +1891,15 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
}
else
{
// game message
for(int i = 0; i < RECORDER_MAX; i++)
if(m_DemoRecorder[i].IsRecording())
m_DemoRecorder[i].RecordMessage(pPacket->m_pData, pPacket->m_DataSize);
if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 || Msg == NETMSGTYPE_SV_EXTRAPROJECTILE)
{
// game message
for(int i = 0; i < RECORDER_MAX; i++)
if(m_DemoRecorder[i].IsRecording())
m_DemoRecorder[i].RecordMessage(pPacket->m_pData, pPacket->m_DataSize);
GameClient()->OnMessage(Msg, &Unpacker);
GameClient()->OnMessage(Msg, &Unpacker);
}
}
}
@ -3312,10 +3315,10 @@ int main(int argc, const char **argv) // ignore_convention
pClient->InitInterfaces();
// execute config file
IOHANDLE file = pStorage->OpenFile(CONFIG_FILE, IOFLAG_READ, IStorage::TYPE_ALL);
if(file)
IOHANDLE File = pStorage->OpenFile(CONFIG_FILE, IOFLAG_READ, IStorage::TYPE_ALL);
if(File)
{
io_close(file);
io_close(File);
pConsole->ExecuteFile(CONFIG_FILE);
}
else // fallback
@ -3324,10 +3327,10 @@ int main(int argc, const char **argv) // ignore_convention
}
// execute autoexec file
file = pStorage->OpenFile(AUTOEXEC_CLIENT_FILE, IOFLAG_READ, IStorage::TYPE_ALL);
if(file)
File = pStorage->OpenFile(AUTOEXEC_CLIENT_FILE, IOFLAG_READ, IStorage::TYPE_ALL);
if(File)
{
io_close(file);
io_close(File);
pConsole->ExecuteFile(AUTOEXEC_CLIENT_FILE);
}
else // fallback
@ -3335,6 +3338,17 @@ int main(int argc, const char **argv) // ignore_convention
pConsole->ExecuteFile(AUTOEXEC_FILE);
}
if(g_Config.m_ClConfigVersion < 1)
{
if(g_Config.m_ClAntiPing == 0)
{
g_Config.m_ClAntiPingPlayers = 1;
g_Config.m_ClAntiPingGrenade = 1;
g_Config.m_ClAntiPingWeapons = 1;
}
}
g_Config.m_ClConfigVersion = 1;
// parse the command line arguments
if(argc > 1) // ignore_convention
pConsole->ParseArguments(argc-1, &argv[1]); // ignore_convention

View file

@ -19,6 +19,7 @@ public:
ACCESS_LEVEL_ADMIN=0,
ACCESS_LEVEL_MOD,
ACCESS_LEVEL_HELPER,
ACCESS_LEVEL_USER,
TEMPCMD_NAME_LENGTH=32,

View file

@ -309,6 +309,7 @@ CServer::CServer()
m_CurrentMapSize = 0;
m_MapReload = 0;
m_ReloadedWhenEmpty = false;
m_RconClientID = IServer::RCON_CID_SERV;
m_RconAuthLevel = AUTHED_ADMIN;
@ -910,7 +911,7 @@ void CServer::UpdateClientRconCommands()
if(m_aClients[ClientID].m_State != CClient::STATE_EMPTY && m_aClients[ClientID].m_Authed)
{
int ConsoleAccessLevel = m_aClients[ClientID].m_Authed == AUTHED_ADMIN ? IConsole::ACCESS_LEVEL_ADMIN : IConsole::ACCESS_LEVEL_MOD;
int ConsoleAccessLevel = m_aClients[ClientID].m_Authed == AUTHED_ADMIN ? IConsole::ACCESS_LEVEL_ADMIN : m_aClients[ClientID].m_Authed == AUTHED_MOD ? IConsole::ACCESS_LEVEL_MOD : IConsole::ACCESS_LEVEL_HELPER;
for(int i = 0; i < MAX_RCONCMD_SEND && m_aClients[ClientID].m_pRconCmdToSend; ++i)
{
SendRconCmdAdd(m_aClients[ClientID].m_pRconCmdToSend, ClientID);
@ -957,7 +958,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
// system message
if(Msg == NETMSG_INFO)
{
if(m_aClients[ClientID].m_State == CClient::STATE_AUTH)
if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && m_aClients[ClientID].m_State == CClient::STATE_AUTH)
{
const char *pVersion = Unpacker.GetString(CUnpacker::SANITIZE_CC);
if(str_comp(pVersion, GameServer()->NetVersion()) != 0)
@ -990,8 +991,8 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
}
else if(Msg == NETMSG_REQUEST_MAP_DATA)
{
if(m_aClients[ClientID].m_State < CClient::STATE_CONNECTING)
return; // no map w/o password, sorry guys
if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) == 0 || m_aClients[ClientID].m_State < CClient::STATE_CONNECTING)
return;
int Chunk = Unpacker.GetInt();
unsigned int ChunkSize = 1024-128;
@ -1035,7 +1036,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
}
else if(Msg == NETMSG_READY)
{
if(m_aClients[ClientID].m_State == CClient::STATE_CONNECTING)
if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && m_aClients[ClientID].m_State == CClient::STATE_CONNECTING)
{
char aAddrStr[NETADDR_MAXSTRSIZE];
net_addr_str(m_NetServer.ClientAddr(ClientID), aAddrStr, sizeof(aAddrStr), true);
@ -1051,7 +1052,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
}
else if(Msg == NETMSG_ENTERGAME)
{
if(m_aClients[ClientID].m_State == CClient::STATE_READY && GameServer()->IsClientReady(ClientID))
if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && m_aClients[ClientID].m_State == CClient::STATE_READY && GameServer()->IsClientReady(ClientID))
{
char aAddrStr[NETADDR_MAXSTRSIZE];
net_addr_str(m_NetServer.ClientAddr(ClientID), aAddrStr, sizeof(aAddrStr), true);
@ -1124,7 +1125,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
if (GameServer->m_apPlayers[ClientID] && GameServer->m_apPlayers[ClientID]->m_ClientVersion < VERSION_DDNET_OLD)
GameServer->m_apPlayers[ClientID]->m_ClientVersion = VERSION_DDNET_OLD;
} else
if(Unpacker.Error() == 0 && m_aClients[ClientID].m_Authed)
if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Unpacker.Error() == 0 && m_aClients[ClientID].m_Authed)
{
CGameContext *GameServer = (CGameContext *) m_pGameServer;
if (GameServer->m_apPlayers[ClientID] && (GameServer->m_apPlayers[ClientID]->m_ClientVersion < VERSION_DDNET_RCONPROTECT || m_aClients[ClientID].m_LastAuthed))
@ -1134,7 +1135,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
m_RconClientID = ClientID;
m_RconAuthLevel = m_aClients[ClientID].m_Authed;
Console()->SetAccessLevel(m_aClients[ClientID].m_Authed == AUTHED_ADMIN ? IConsole::ACCESS_LEVEL_ADMIN : m_aClients[ClientID].m_Authed == AUTHED_MOD ? IConsole::ACCESS_LEVEL_MOD : IConsole::ACCESS_LEVEL_USER);
Console()->SetAccessLevel(m_aClients[ClientID].m_Authed == AUTHED_ADMIN ? IConsole::ACCESS_LEVEL_ADMIN : m_aClients[ClientID].m_Authed == AUTHED_MOD ? IConsole::ACCESS_LEVEL_MOD : m_aClients[ClientID].m_Authed == AUTHED_HELPER ? IConsole::ACCESS_LEVEL_HELPER : IConsole::ACCESS_LEVEL_USER);
Console()->ExecuteLineFlag(pCmd, CFGFLAG_SERVER, ClientID);
Console()->SetAccessLevel(IConsole::ACCESS_LEVEL_ADMIN);
m_RconClientID = IServer::RCON_CID_SERV;
@ -1149,56 +1150,63 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
Unpacker.GetString(); // login name, not used
pPw = Unpacker.GetString(CUnpacker::SANITIZE_CC);
if(Unpacker.Error() == 0)
if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Unpacker.Error() == 0)
{
if(g_Config.m_SvRconPassword[0] == 0 && g_Config.m_SvRconModPassword[0] == 0)
int AuthLevel = -1;
if(g_Config.m_SvRconPassword[0] == 0 && g_Config.m_SvRconModPassword[0] == 0 && g_Config.m_SvRconHelperPassword[0] == 0)
{
SendRconLine(ClientID, "No rcon password set on server. Set sv_rcon_password and/or sv_rcon_mod_password to enable the remote console.");
}
else if(g_Config.m_SvRconPassword[0] && str_comp(pPw, g_Config.m_SvRconPassword) == 0)
{
m_aClients[ClientID].m_LastAuthed = AUTHED_ADMIN;
if(m_aClients[ClientID].m_Authed != AUTHED_ADMIN)
{
CMsgPacker Msg(NETMSG_RCON_AUTH_STATUS);
Msg.AddInt(1); //authed
Msg.AddInt(1); //cmdlist
SendMsgEx(&Msg, MSGFLAG_VITAL, ClientID, true);
m_aClients[ClientID].m_Authed = AUTHED_ADMIN;
int SendRconCmds = Unpacker.GetInt();
if(Unpacker.Error() == 0 && SendRconCmds)
m_aClients[ClientID].m_pRconCmdToSend = Console()->FirstCommandInfo(IConsole::ACCESS_LEVEL_ADMIN, CFGFLAG_SERVER);
SendRconLine(ClientID, "Admin authentication successful. Full remote console access granted.");
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "ClientID=%d authed (admin)", ClientID);
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
// DDRace
GameServer()->OnSetAuthed(ClientID, AUTHED_ADMIN);
}
}
AuthLevel = AUTHED_ADMIN;
else if(g_Config.m_SvRconModPassword[0] && str_comp(pPw, g_Config.m_SvRconModPassword) == 0)
AuthLevel = AUTHED_MOD;
else if(g_Config.m_SvRconHelperPassword[0] && str_comp(pPw, g_Config.m_SvRconHelperPassword) == 0)
AuthLevel = AUTHED_HELPER;
if(AuthLevel != -1)
{
m_aClients[ClientID].m_LastAuthed = AUTHED_MOD;
if(m_aClients[ClientID].m_Authed != AUTHED_MOD)
m_aClients[ClientID].m_LastAuthed = AuthLevel;
if(m_aClients[ClientID].m_Authed != AuthLevel)
{
CMsgPacker Msg(NETMSG_RCON_AUTH_STATUS);
Msg.AddInt(1); //authed
Msg.AddInt(1); //cmdlist
SendMsgEx(&Msg, MSGFLAG_VITAL, ClientID, true);
m_aClients[ClientID].m_Authed = AUTHED_MOD;
m_aClients[ClientID].m_Authed = AuthLevel;
int SendRconCmds = Unpacker.GetInt();
if(Unpacker.Error() == 0 && SendRconCmds)
m_aClients[ClientID].m_pRconCmdToSend = Console()->FirstCommandInfo(IConsole::ACCESS_LEVEL_MOD, CFGFLAG_SERVER);
SendRconLine(ClientID, "Moderator authentication successful. Limited remote console access granted.");
// AUTHED_ADMIN - AuthLevel gets the proper IConsole::ACCESS_LEVEL_<x>
m_aClients[ClientID].m_pRconCmdToSend = Console()->FirstCommandInfo(AUTHED_ADMIN - AuthLevel, CFGFLAG_SERVER);
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "ClientID=%d authed (moderator)", ClientID);
switch (AuthLevel)
{
case AUTHED_ADMIN:
{
SendRconLine(ClientID, "Admin authentication successful. Full remote console access granted.");
str_format(aBuf, sizeof(aBuf), "ClientID=%d authed (admin)", ClientID);
break;
}
case AUTHED_MOD:
{
SendRconLine(ClientID, "Moderator authentication successful. Limited remote console access granted.");
str_format(aBuf, sizeof(aBuf), "ClientID=%d authed (moderator)", ClientID);
break;
}
case AUTHED_HELPER:
{
SendRconLine(ClientID, "Helper authentication successful. Limited remote console access granted.");
str_format(aBuf, sizeof(aBuf), "ClientID=%d authed (helper)", ClientID);
break;
}
}
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
// DDRace
GameServer()->OnSetAuthed(ClientID, AUTHED_MOD);
GameServer()->OnSetAuthed(ClientID, AuthLevel);
}
}
else if(g_Config.m_SvRconMaxTries)
@ -1251,7 +1259,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
else
{
// game message
if(m_aClients[ClientID].m_State >= CClient::STATE_READY)
if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && m_aClients[ClientID].m_State >= CClient::STATE_READY)
GameServer()->OnMessage(Msg, &Unpacker, ClientID);
}
}
@ -1701,6 +1709,17 @@ int CServer::Run()
// wait for incoming data
if (NonActive)
{
if(g_Config.m_SvReloadWhenEmpty == 1)
{
m_MapReload = true;
g_Config.m_SvReloadWhenEmpty = 0;
}
else if(g_Config.m_SvReloadWhenEmpty == 2 && !m_ReloadedWhenEmpty)
{
m_MapReload = true;
m_ReloadedWhenEmpty = true;
}
if(g_Config.m_SvShutdownWhenEmpty)
m_RunServer = false;
else
@ -1708,6 +1727,8 @@ int CServer::Run()
}
else
{
m_ReloadedWhenEmpty = false;
set_new_tick();
int64 t = time_get();
int x = (TickStartTime(m_CurrentGameTick+1) - t) * 1000000 / time_freq() + 1;
@ -1776,7 +1797,8 @@ void CServer::ConStatus(IConsole::IResult *pResult, void *pUser)
if(pThis->m_aClients[i].m_State == CClient::STATE_INGAME)
{
const char *pAuthStr = pThis->m_aClients[i].m_Authed == CServer::AUTHED_ADMIN ? "(Admin)" :
pThis->m_aClients[i].m_Authed == CServer::AUTHED_MOD ? "(Mod)" : "";
pThis->m_aClients[i].m_Authed == CServer::AUTHED_MOD ? "(Mod)" :
pThis->m_aClients[i].m_Authed == CServer::AUTHED_HELPER ? "(Helper)" : "";
str_format(aBuf, sizeof(aBuf), "id=%d addr=%s name='%s' score=%d client=%d secure=%s %s", i, aAddrStr,
pThis->m_aClients[i].m_aName, pThis->m_aClients[i].m_Score, ((CGameContext *)(pThis->GameServer()))->m_apPlayers[i]->m_ClientVersion, pThis->m_NetServer.HasSecurityToken(i) ? "yes":"no", pAuthStr);
}
@ -1921,7 +1943,7 @@ void CServer::ConchainMaxclientsperipUpdate(IConsole::IResult *pResult, void *pU
((CServer *)pUserData)->m_NetServer.SetMaxClientsPerIP(pResult->GetInteger(0));
}
void CServer::ConchainModCommandUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
void CServer::ConchainCommandAccessUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
{
if(pResult->NumArguments() == 2)
{
@ -1935,11 +1957,13 @@ void CServer::ConchainModCommandUpdate(IConsole::IResult *pResult, void *pUserDa
{
for(int i = 0; i < MAX_CLIENTS; ++i)
{
if(pThis->m_aClients[i].m_State == CServer::CClient::STATE_EMPTY || pThis->m_aClients[i].m_Authed != CServer::AUTHED_MOD ||
(pThis->m_aClients[i].m_pRconCmdToSend && str_comp(pResult->GetString(0), pThis->m_aClients[i].m_pRconCmdToSend->m_pName) >= 0))
if(pThis->m_aClients[i].m_State == CServer::CClient::STATE_EMPTY ||
(pInfo->GetAccessLevel() > AUTHED_ADMIN - pThis->m_aClients[i].m_Authed && AUTHED_ADMIN - pThis->m_aClients[i].m_Authed < OldAccessLevel) ||
(pInfo->GetAccessLevel() < AUTHED_ADMIN - pThis->m_aClients[i].m_Authed && AUTHED_ADMIN - pThis->m_aClients[i].m_Authed > OldAccessLevel) ||
(pThis->m_aClients[i].m_pRconCmdToSend && str_comp(pResult->GetString(0), pThis->m_aClients[i].m_pRconCmdToSend->m_pName) >= 0))
continue;
if(OldAccessLevel == IConsole::ACCESS_LEVEL_ADMIN)
if(OldAccessLevel < pInfo->GetAccessLevel())
pThis->SendRconCmdAdd(pInfo, i);
else
pThis->SendRconCmdRem(pInfo, i);
@ -1960,34 +1984,39 @@ void CServer::ConchainConsoleOutputLevelUpdate(IConsole::IResult *pResult, void
}
}
void CServer::LogoutByAuthLevel(int AuthLevel) // AUTHED_<x>
{
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(m_aClients[i].m_State == CServer::CClient::STATE_EMPTY)
continue;
if(m_aClients[i].m_Authed == AuthLevel)
{
CMsgPacker Msg(NETMSG_RCON_AUTH_STATUS);
Msg.AddInt(0); //authed
Msg.AddInt(0); //cmdlist
SendMsgEx(&Msg, MSGFLAG_VITAL, i, true);
m_aClients[i].m_Authed = AUTHED_NO;
m_aClients[i].m_LastAuthed = AUTHED_NO;
m_aClients[i].m_AuthTries = 0;
m_aClients[i].m_pRconCmdToSend = 0;
SendRconLine(i, "Logged out by password change.");
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "ClientID=%d logged out by password change", i);
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
}
}
}
void CServer::ConchainRconPasswordChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
{
pfnCallback(pResult, pCallbackUserData);
if(pResult->NumArguments() == 1)
{
CServer *pServer = (CServer *)pUserData;
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(pServer->m_aClients[i].m_State == CServer::CClient::STATE_EMPTY)
continue;
if(pServer->m_aClients[i].m_Authed == AUTHED_ADMIN)
{
CMsgPacker Msg(NETMSG_RCON_AUTH_STATUS);
Msg.AddInt(0); //authed
Msg.AddInt(0); //cmdlist
pServer->SendMsgEx(&Msg, MSGFLAG_VITAL, i, true);
pServer->m_aClients[i].m_Authed = AUTHED_NO;
pServer->m_aClients[i].m_LastAuthed = AUTHED_NO;
pServer->m_aClients[i].m_AuthTries = 0;
pServer->m_aClients[i].m_pRconCmdToSend = 0;
pServer->SendRconLine(i, "Logged out by password change.");
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "ClientID=%d logged out by password change", i);
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
}
}
pServer->LogoutByAuthLevel(AUTHED_ADMIN);
}
}
@ -1997,28 +2026,17 @@ void CServer::ConchainRconModPasswordChange(IConsole::IResult *pResult, void *pU
if(pResult->NumArguments() == 1)
{
CServer *pServer = (CServer *)pUserData;
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(pServer->m_aClients[i].m_State == CServer::CClient::STATE_EMPTY)
continue;
if(pServer->m_aClients[i].m_Authed == AUTHED_MOD)
{
CMsgPacker Msg(NETMSG_RCON_AUTH_STATUS);
Msg.AddInt(0); //authed
Msg.AddInt(0); //cmdlist
pServer->SendMsgEx(&Msg, MSGFLAG_VITAL, i, true);
pServer->LogoutByAuthLevel(AUTHED_MOD);
}
}
pServer->m_aClients[i].m_Authed = AUTHED_NO;
pServer->m_aClients[i].m_LastAuthed = AUTHED_NO;
pServer->m_aClients[i].m_AuthTries = 0;
pServer->m_aClients[i].m_pRconCmdToSend = 0;
pServer->SendRconLine(i, "Logged out by password change.");
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "ClientID=%d logged out by password change", i);
pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
}
}
void CServer::ConchainRconHelperPasswordChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
{
pfnCallback(pResult, pCallbackUserData);
if(pResult->NumArguments() == 1)
{
CServer *pServer = (CServer *)pUserData;
pServer->LogoutByAuthLevel(AUTHED_HELPER);
}
}
@ -2044,11 +2062,12 @@ void CServer::RegisterCommands()
Console()->Chain("password", ConchainSpecialInfoupdate, this);
Console()->Chain("sv_max_clients_per_ip", ConchainMaxclientsperipUpdate, this);
Console()->Chain("mod_command", ConchainModCommandUpdate, this);
Console()->Chain("access_level", ConchainCommandAccessUpdate, this);
Console()->Chain("console_output_level", ConchainConsoleOutputLevelUpdate, this);
Console()->Chain("sv_rcon_password", ConchainRconPasswordChange, this);
Console()->Chain("sv_rcon_mod_password", ConchainRconModPasswordChange, this);
Console()->Chain("sv_rcon_helper_password", ConchainRconHelperPasswordChange, this);
// register console commands in sub parts
m_ServerBan.InitServerBan(Console(), Storage(), this);

View file

@ -83,6 +83,7 @@ public:
enum
{
AUTHED_NO=0,
AUTHED_HELPER,
AUTHED_MOD,
AUTHED_ADMIN,
@ -162,6 +163,7 @@ public:
//int m_CurrentGameTick;
int m_RunServer;
int m_MapReload;
bool m_ReloadedWhenEmpty;
int m_RconClientID;
int m_RconAuthLevel;
int m_PrintCBIndex;
@ -263,10 +265,14 @@ public:
static void ConLogout(IConsole::IResult *pResult, void *pUser);
static void ConchainSpecialInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConchainMaxclientsperipUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConchainModCommandUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConchainCommandAccessUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConchainConsoleOutputLevelUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
void LogoutByAuthLevel(int AuthLevel);
static void ConchainRconPasswordChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConchainRconModPasswordChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConchainRconHelperPasswordChange(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
void RegisterCommands();

View file

@ -75,7 +75,7 @@ public:
virtual void Save()
{
if(!m_pStorage)
if(!m_pStorage || !g_Config.m_ClSaveSettings)
return;
m_ConfigFile = m_pStorage->OpenFile(CONFIG_FILE ".tmp", IOFLAG_WRITE, IStorage::TYPE_SAVE);

View file

@ -15,6 +15,7 @@ MACRO_CONFIG_STR(Password, password, 32, "", CFGFLAG_CLIENT|CFGFLAG_SERVER, "Pas
MACRO_CONFIG_STR(Logfile, logfile, 128, "", CFGFLAG_SAVE|CFGFLAG_CLIENT|CFGFLAG_SERVER, "Filename to log all output to")
MACRO_CONFIG_INT(ConsoleOutputLevel, console_output_level, 0, 0, 2, CFGFLAG_CLIENT|CFGFLAG_SERVER, "Adjusts the amount of information in the console")
MACRO_CONFIG_INT(ClSaveSettings, cl_save_settings, 1, 0, 1, CFGFLAG_CLIENT, "Write the settings file on exit")
MACRO_CONFIG_INT(ClCpuThrottle, cl_cpu_throttle, 0, 0, 100, CFGFLAG_SAVE|CFGFLAG_CLIENT, "")
MACRO_CONFIG_INT(ClCpuThrottleInactive, cl_cpu_throttle_inactive, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "")
MACRO_CONFIG_INT(ClEditor, cl_editor, 0, 0, 1, CFGFLAG_CLIENT, "")
@ -140,6 +141,7 @@ MACRO_CONFIG_INT(SvHighBandwidth, sv_high_bandwidth, 0, 0, 1, CFGFLAG_SERVER, "U
MACRO_CONFIG_INT(SvRegister, sv_register, 1, 0, 1, CFGFLAG_SERVER, "Register server with master server for public listing")
MACRO_CONFIG_STR(SvRconPassword, sv_rcon_password, 32, "", CFGFLAG_SERVER, "Remote console password (full access)")
MACRO_CONFIG_STR(SvRconModPassword, sv_rcon_mod_password, 32, "", CFGFLAG_SERVER, "Remote console password for moderators (limited access)")
MACRO_CONFIG_STR(SvRconHelperPassword, sv_rcon_helper_password, 32, "", CFGFLAG_SERVER, "Remote console password for helpers (limited access)")
MACRO_CONFIG_INT(SvRconMaxTries, sv_rcon_max_tries, 30, 0, 100, CFGFLAG_SERVER, "Maximum number of tries for remote console authentication")
MACRO_CONFIG_INT(SvRconBantime, sv_rcon_bantime, 5, 0, 1440, CFGFLAG_SERVER, "The time a client gets banned if remote console authentication fails. 0 makes it just use kick")
MACRO_CONFIG_INT(SvAutoDemoRecord, sv_auto_demo_record, 0, 0, 1, CFGFLAG_SERVER, "Automatically record demos")
@ -217,24 +219,25 @@ MACRO_CONFIG_STR(SvSqlUser, sv_sql_user, 32, "nameless", CFGFLAG_SERVER, "SQL Us
MACRO_CONFIG_STR(SvSqlPw, sv_sql_pw, 32, "tee", CFGFLAG_SERVER, "SQL Password")
MACRO_CONFIG_STR(SvSqlIp, sv_sql_ip, 32, "127.0.0.1", CFGFLAG_SERVER, "SQL Database IP")
MACRO_CONFIG_INT(SvSqlPort, sv_sql_port, 3306, 0, 65535, CFGFLAG_SERVER, "SQL Database port")
MACRO_CONFIG_INT(SvSqlCreateTables, sv_sql_create_tables, 1, 0, 1, CFGFLAG_SERVER, "Try to create the SQL tables when starting")
MACRO_CONFIG_STR(SvSqlDatabase, sv_sql_database, 16, "teeworlds", CFGFLAG_SERVER, "SQL Database name")
MACRO_CONFIG_STR(SvSqlServerName, sv_sql_servername, 4, "UNK", CFGFLAG_SERVER, "SQL Server name that is inserted into record table")
MACRO_CONFIG_STR(SvSqlServerName, sv_sql_servername, 5, "UNK", CFGFLAG_SERVER, "SQL Server name that is inserted into record table")
MACRO_CONFIG_STR(SvSqlPrefix, sv_sql_prefix, 16, "record", CFGFLAG_SERVER, "SQL Database table prefix")
MACRO_CONFIG_INT(SvSaveGames, sv_savegames, 1, 0, 1, CFGFLAG_SERVER, "Enables savegames (/save and /load)")
MACRO_CONFIG_INT(SvSaveGamesDelay, sv_savegames_delay, 60, 0, 10000, CFGFLAG_SERVER, "Delay in seconds for loading a savegame")
#endif
MACRO_CONFIG_INT(SvDDRaceRules, sv_ddrace_rules, 1, 0, 1, CFGFLAG_SERVER, "Whether the default mod rules are displayed or not")
MACRO_CONFIG_STR(SvRulesLine1, sv_rules_line1, 40, "", CFGFLAG_SERVER, "Rules line 1")
MACRO_CONFIG_STR(SvRulesLine2, sv_rules_line2, 40, "", CFGFLAG_SERVER, "Rules line 2")
MACRO_CONFIG_STR(SvRulesLine3, sv_rules_line3, 40, "", CFGFLAG_SERVER, "Rules line 3")
MACRO_CONFIG_STR(SvRulesLine4, sv_rules_line4, 40, "", CFGFLAG_SERVER, "Rules line 4")
MACRO_CONFIG_STR(SvRulesLine5, sv_rules_line5, 40, "", CFGFLAG_SERVER, "Rules line 5")
MACRO_CONFIG_STR(SvRulesLine6, sv_rules_line6, 40, "", CFGFLAG_SERVER, "Rules line 6")
MACRO_CONFIG_STR(SvRulesLine7, sv_rules_line7, 40, "", CFGFLAG_SERVER, "Rules line 7")
MACRO_CONFIG_STR(SvRulesLine8, sv_rules_line8, 40, "", CFGFLAG_SERVER, "Rules line 8")
MACRO_CONFIG_STR(SvRulesLine9, sv_rules_line9, 40, "", CFGFLAG_SERVER, "Rules line 9")
MACRO_CONFIG_STR(SvRulesLine10, sv_rules_line10, 40, "", CFGFLAG_SERVER, "Rules line 10")
MACRO_CONFIG_STR(SvRulesLine1, sv_rules_line1, 128, "", CFGFLAG_SERVER, "Rules line 1")
MACRO_CONFIG_STR(SvRulesLine2, sv_rules_line2, 128, "", CFGFLAG_SERVER, "Rules line 2")
MACRO_CONFIG_STR(SvRulesLine3, sv_rules_line3, 128, "", CFGFLAG_SERVER, "Rules line 3")
MACRO_CONFIG_STR(SvRulesLine4, sv_rules_line4, 128, "", CFGFLAG_SERVER, "Rules line 4")
MACRO_CONFIG_STR(SvRulesLine5, sv_rules_line5, 128, "", CFGFLAG_SERVER, "Rules line 5")
MACRO_CONFIG_STR(SvRulesLine6, sv_rules_line6, 128, "", CFGFLAG_SERVER, "Rules line 6")
MACRO_CONFIG_STR(SvRulesLine7, sv_rules_line7, 128, "", CFGFLAG_SERVER, "Rules line 7")
MACRO_CONFIG_STR(SvRulesLine8, sv_rules_line8, 128, "", CFGFLAG_SERVER, "Rules line 8")
MACRO_CONFIG_STR(SvRulesLine9, sv_rules_line9, 128, "", CFGFLAG_SERVER, "Rules line 9")
MACRO_CONFIG_STR(SvRulesLine10, sv_rules_line10, 128, "", CFGFLAG_SERVER, "Rules line 10")
MACRO_CONFIG_INT(SvTeam, sv_team, 1, 0, 3, CFGFLAG_SERVER|CFGFLAG_GAME, "Teams configuration (0 = off, 1 = on but optional, 2 = must play only with teams, 3 = forced random team only for you)")
MACRO_CONFIG_INT(SvTeamMaxSize, sv_max_team_size, MAX_CLIENTS, 1, MAX_CLIENTS, CFGFLAG_SERVER|CFGFLAG_GAME, "Maximum team size (from 2 to 64)")
@ -311,6 +314,7 @@ MACRO_CONFIG_INT(SvMaxAfkTime, sv_max_afk_time, 0, 0, 9999, CFGFLAG_SERVER, "The
MACRO_CONFIG_INT(SvMaxAfkVoteTime, sv_max_afk_vote_time, 300, 0, 9999, CFGFLAG_SERVER, "The time in seconds a player can be afk and his votes still count (0 = disabled)")
MACRO_CONFIG_INT(SvPlasmaRange, sv_plasma_range, 700, 1, 99999, CFGFLAG_SERVER|CFGFLAG_GAME, "How far will the plasma gun track tees")
MACRO_CONFIG_INT(SvPlasmaPerSec, sv_plasma_per_sec, 3, 0, 50, CFGFLAG_SERVER|CFGFLAG_GAME, "How many shots does the plasma gun fire per seconds")
MACRO_CONFIG_INT(SvDraggerRange, sv_dragger_range, 700, 1, 99999, CFGFLAG_SERVER|CFGFLAG_GAME, "How far will the dragger track tees")
MACRO_CONFIG_INT(SvVotePause, sv_vote_pause, 1, 0, 1, CFGFLAG_SERVER, "Allow voting to pause players (instead of moving to spectators)")
MACRO_CONFIG_INT(SvVotePauseTime, sv_vote_pause_time, 10, 0, 360, CFGFLAG_SERVER, "The time (in seconds) players have to wait in pause when paused by vote")
MACRO_CONFIG_INT(SvTuneReset, sv_tune_reset, 1, 0, 1, CFGFLAG_SERVER, "Whether tuning is reset after each map change or not")
@ -330,6 +334,7 @@ MACRO_CONFIG_INT(SvSpamMuteDuration, sv_spam_mute_duration, 60, 0, 3600 , CFGFLA
MACRO_CONFIG_INT(SvEvents, sv_events, 1, 0, 1, CFGFLAG_SERVER, "Enable triggering of server events, like the happy eyeemotes on some holidays.")
MACRO_CONFIG_INT(SvRankCheats, sv_rank_cheats, 0, 0, 1, CFGFLAG_SERVER, "Enable ranks after cheats have been used (file based server only)")
MACRO_CONFIG_INT(SvShutdownWhenEmpty, sv_shutdown_when_empty, 0, 0, 1, CFGFLAG_SERVER, "Shutdown server as soon as noone is on it anymore")
MACRO_CONFIG_INT(SvReloadWhenEmpty, sv_reload_when_empty, 0, 0, 2, CFGFLAG_SERVER, "Reload map when server is empty (1 = reload once, 2 = reload everytime server gets empty)")
MACRO_CONFIG_INT(SvKillProtection, sv_kill_protection, 20, 0, 9999, CFGFLAG_SERVER, "0 - Disable, 1-9999 minutes")
MACRO_CONFIG_INT(SvSoloServer, sv_solo_server, 0, 0, 1, CFGFLAG_SERVER|CFGFLAG_GAME, "Set server to solo mode (no player interactions, has to be set before loading the map)")
MACRO_CONFIG_STR(SvClientSuggestion, sv_client_suggestion, 128, "Get DDNet client from DDNet.tw to use all features on DDNet!", CFGFLAG_SERVER, "Broadcast to display to players without DDNet client")
@ -359,6 +364,7 @@ MACRO_CONFIG_INT(InpJoystick, inp_joystick, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT
#else
MACRO_CONFIG_INT(InpJoystick, inp_joystick, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Try to use a joystick as input")
#endif
MACRO_CONFIG_INT(ClConfigVersion, cl_config_version, 0, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "The config version. Helps newer clients fix bugs with older configs.")
// demo editor
MACRO_CONFIG_INT(ClDemoSliceBegin, cl_demo_slice_begin, -1, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Begin marker for demo slice")

View file

@ -514,7 +514,7 @@ void CConsole::Con_Exec(IResult *pResult, void *pUserData)
((CConsole*)pUserData)->ExecuteFile(pResult->GetString(0));
}
void CConsole::ConModCommandAccess(IResult *pResult, void *pUser)
void CConsole::ConCommandAccess(IResult *pResult, void *pUser)
{
CConsole* pConsole = static_cast<CConsole *>(pUser);
char aBuf[128];
@ -526,12 +526,16 @@ void CConsole::ConModCommandAccess(IResult *pResult, void *pUser)
pCommand->SetAccessLevel(pResult->GetInteger(1));
str_format(aBuf, sizeof(aBuf), "moderator access for '%s' is now %s", pResult->GetString(0), pCommand->GetAccessLevel() ? "enabled" : "disabled");
pConsole->Print(OUTPUT_LEVEL_STANDARD, "console", aBuf);
str_format(aBuf, sizeof(aBuf), "helper access for '%s' is now %s", pResult->GetString(0), pCommand->GetAccessLevel() >= ACCESS_LEVEL_HELPER ? "enabled" : "disabled");
pConsole->Print(OUTPUT_LEVEL_STANDARD, "console", aBuf);
str_format(aBuf, sizeof(aBuf), "user access for '%s' is now %s", pResult->GetString(0), pCommand->GetAccessLevel() >= ACCESS_LEVEL_USER ? "enabled" : "disabled");
}
else
{
str_format(aBuf, sizeof(aBuf), "moderator access for '%s' is %s", pResult->GetString(0), pCommand->GetAccessLevel() ? "enabled" : "disabled");
pConsole->Print(OUTPUT_LEVEL_STANDARD, "console", aBuf);
str_format(aBuf, sizeof(aBuf), "helper access for '%s' is %s", pResult->GetString(0), pCommand->GetAccessLevel() >= ACCESS_LEVEL_HELPER ? "enabled" : "disabled");
pConsole->Print(OUTPUT_LEVEL_STANDARD, "console", aBuf);
str_format(aBuf, sizeof(aBuf), "user access for '%s' is %s", pResult->GetString(0), pCommand->GetAccessLevel() >= ACCESS_LEVEL_USER ? "enabled" : "disabled");
}
}
@ -541,7 +545,7 @@ void CConsole::ConModCommandAccess(IResult *pResult, void *pUser)
pConsole->Print(OUTPUT_LEVEL_STANDARD, "console", aBuf);
}
void CConsole::ConModCommandStatus(IResult *pResult, void *pUser)
void CConsole::ConCommandStatus(IResult *pResult, void *pUser)
{
CConsole* pConsole = static_cast<CConsole *>(pUser);
char aBuf[240];
@ -550,7 +554,7 @@ void CConsole::ConModCommandStatus(IResult *pResult, void *pUser)
for(CCommand *pCommand = pConsole->m_pFirstCommand; pCommand; pCommand = pCommand->m_pNext)
{
if(pCommand->m_Flags&pConsole->m_FlagMask && pCommand->GetAccessLevel() >= ACCESS_LEVEL_MOD)
if(pCommand->m_Flags&pConsole->m_FlagMask && pCommand->GetAccessLevel() >= clamp(pResult->GetInteger(0), (int)ACCESS_LEVEL_ADMIN, (int)ACCESS_LEVEL_USER))
{
int Length = str_length(pCommand->m_pName);
if(Used + Length + 2 < (int)(sizeof(aBuf)))
@ -576,6 +580,18 @@ void CConsole::ConModCommandStatus(IResult *pResult, void *pUser)
pConsole->Print(OUTPUT_LEVEL_STANDARD, "console", aBuf);
}
void CConsole::ConUserCommandStatus(IResult *pResult, void *pUser)
{
CConsole* pConsole = static_cast<CConsole *>(pUser);
CResult Result;
Result.m_pCommand = "access_status";
char aBuf[4];
str_format(aBuf, sizeof(aBuf), "%d", IConsole::ACCESS_LEVEL_USER);
Result.AddArgument(aBuf);
pConsole->ConCommandStatus(&Result, pConsole);
}
struct CIntVariableData
{
IConsole *m_pConsole;
@ -753,9 +769,8 @@ CConsole::CConsole(int FlagMask)
Register("toggle", "sii", CFGFLAG_SERVER|CFGFLAG_CLIENT, ConToggle, this, "Toggle config value");
Register("+toggle", "sii", CFGFLAG_CLIENT, ConToggleStroke, this, "Toggle config value via keypress");
Register("mod_command", "s?i", CFGFLAG_SERVER, ConModCommandAccess, this, "Specify command accessibility for moderators");
Register("mod_status", "", CFGFLAG_SERVER, ConModCommandStatus, this, "List all commands which are accessible for moderators");
Register("user_status", "", CFGFLAG_SERVER, ConUserCommandStatus, this, "List all commands which are accessible for users");
Register("access_level", "s?i", CFGFLAG_SERVER, ConCommandAccess, this, "Specify command accessibility (admin = 0, moderator = 1, helper = 2, all = 3)");
Register("access_status", "i", CFGFLAG_SERVER, ConCommandStatus, this, "List all commands which are accessible for admin = 0, moderator = 1, helper = 2, all = 3");
Register("cmdlist", "", CFGFLAG_SERVER|CFGFLAG_CHAT, ConUserCommandStatus, this, "List all commands which are accessible for users");
// TODO: this should disappear
@ -1003,41 +1018,6 @@ const IConsole::CCommandInfo *CConsole::GetCommandInfo(const char *pName, int Fl
extern IConsole *CreateConsole(int FlagMask) { return new CConsole(FlagMask); }
void CConsole::ConUserCommandStatus(IResult *pResult, void *pUser)
{
CConsole* pConsole = static_cast<CConsole *>(pUser);
char aBuf[240];
mem_zero(aBuf, sizeof(aBuf));
int Used = 0;
for(CCommand *pCommand = pConsole->m_pFirstCommand; pCommand; pCommand = pCommand->m_pNext)
{
if(pCommand->m_Flags&pConsole->m_FlagMask && pCommand->GetAccessLevel() == ACCESS_LEVEL_USER)
{
int Length = str_length(pCommand->m_pName);
if(Used + Length + 2 < (int)(sizeof(aBuf)))
{
if(Used > 0)
{
Used += 2;
str_append(aBuf, ", ", sizeof(aBuf));
}
str_append(aBuf, pCommand->m_pName, sizeof(aBuf));
Used += Length;
}
else
{
pConsole->Print(OUTPUT_LEVEL_STANDARD, "console", aBuf);
mem_zero(aBuf, sizeof(aBuf));
str_copy(aBuf, pCommand->m_pName, sizeof(aBuf));
Used = Length;
}
}
}
if(Used > 0)
pConsole->Print(OUTPUT_LEVEL_STANDARD, "console", aBuf);
}
void CConsole::ResetServerGameSettings()
{
#define MACRO_CONFIG_INT(Name,ScriptName,Def,Min,Max,Flags,Desc) \

View file

@ -56,8 +56,8 @@ class CConsole : public IConsole
static void Con_Exec(IResult *pResult, void *pUserData);
static void ConToggle(IResult *pResult, void *pUser);
static void ConToggleStroke(IResult *pResult, void *pUser);
static void ConModCommandAccess(IResult *pResult, void *pUser);
static void ConModCommandStatus(IConsole::IResult *pResult, void *pUser);
static void ConCommandAccess(IResult *pResult, void *pUser);
static void ConCommandStatus(IConsole::IResult *pResult, void *pUser);
void ExecuteFileRecurse(const char *pFilename);
void ExecuteLineStroked(int Stroke, const char *pStr, int ClientID = -1);

View file

@ -28,7 +28,7 @@ FifoConsole::FifoConsole(IConsole *pConsole, char *pFifoFile, int flag)
m_pConsole = pConsole;
m_flag = flag;
pthread_detach((pthread_t)m_pFifoThread);
thread_detach(m_pFifoThread);
}
FifoConsole::~FifoConsole()

View file

@ -83,7 +83,7 @@ int CNetRecvUnpacker::FetchChunk(CNetChunk *pChunk)
// fill in the info
pChunk->m_ClientID = m_ClientID;
pChunk->m_Address = m_Addr;
pChunk->m_Flags = 0;
pChunk->m_Flags = Header.m_Flags;
pChunk->m_DataSize = Header.m_Size;
pChunk->m_pData = pData;
return 1;

View file

@ -153,6 +153,7 @@ class CNetConnection
private:
unsigned short m_Sequence;
unsigned short m_Ack;
unsigned short m_PeerAck;
unsigned m_State;
int m_Token;

View file

@ -20,6 +20,7 @@ void CNetConnection::Reset(bool Rejoin)
{
m_Sequence = 0;
m_Ack = 0;
m_PeerAck = 0;
m_RemoteClosed = 0;
if (!Rejoin)
@ -205,9 +206,12 @@ void CNetConnection::Disconnect(const char *pReason)
else
SendControl(NET_CTRLMSG_CLOSE, 0, 0);
m_ErrorString[0] = 0;
if(pReason && pReason != m_ErrorString)
str_copy(m_ErrorString, pReason, sizeof(m_ErrorString));
if(pReason != m_ErrorString)
{
m_ErrorString[0] = 0;
if(pReason)
str_copy(m_ErrorString, pReason, sizeof(m_ErrorString));
}
}
Reset();
@ -246,6 +250,19 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr, SECURITY_
}
}
// check if actual ack value is valid(own sequence..latest peer ack)
if(m_Sequence >= m_PeerAck)
{
if(pPacket->m_Ack < m_PeerAck || pPacket->m_Ack > m_Sequence)
return 0;
}
else
{
if(pPacket->m_Ack < m_PeerAck && pPacket->m_Ack > m_Sequence)
return 0;
}
m_PeerAck = pPacket->m_Ack;
int64 Now = time_get();
// check if resend is requested

View file

@ -207,6 +207,8 @@ public:
"/usr/share/games/teeworlds/data",
"/usr/local/share/teeworlds/data",
"/usr/local/share/games/teeworlds/data",
"/usr/pkg/share/teeworlds/data",
"/usr/pkg/share/games/teeworlds/data",
"/opt/teeworlds/data"
};
const int DirsCount = sizeof(aDirs) / sizeof(aDirs[0]);

View file

@ -264,7 +264,7 @@ int CControls::SnapInput(int *pData)
// dummy copy moves
if(g_Config.m_ClDummyCopyMoves)
{
CNetObj_PlayerInput *DummyInput = &Client()->DummyInput;
CNetObj_PlayerInput *DummyInput = &Client()->m_DummyInput;
DummyInput->m_Direction = m_InputData[g_Config.m_ClDummy].m_Direction;
DummyInput->m_Hook = m_InputData[g_Config.m_ClDummy].m_Hook;
DummyInput->m_Jump = m_InputData[g_Config.m_ClDummy].m_Jump;

View file

@ -57,7 +57,7 @@ void CItems::RenderProjectile(const CNetObj_Projectile *pCurrent, int ItemID)
int PrevTick = Client()->PrevGameTick();
if (g_Config.m_ClAntiPingGrenade && LocalPlayerInGame && !(Client()->State() == IClient::STATE_DEMOPLAYBACK))
if (m_pClient->AntiPingGrenade() && LocalPlayerInGame && !(Client()->State() == IClient::STATE_DEMOPLAYBACK))
{
// calc predicted game tick
static int Offset = 0;

View file

@ -125,8 +125,6 @@ void CMapLayers::OnRender()
Graphics()->GetScreen(&Screen.x, &Screen.y, &Screen.w, &Screen.h);
vec2 Center = m_pClient->m_pCamera->m_Center;
//float center_x = gameclient.camera->center.x;
//float center_y = gameclient.camera->center.y;
bool PassedGameLayer = false;
@ -176,7 +174,7 @@ void CMapLayers::OnRender()
if(pLayer == (CMapItemLayer*)m_pLayers->GameLayer())
{
IsGameLayer = true;
PassedGameLayer = 1;
PassedGameLayer = true;
}
if(pLayer == (CMapItemLayer*)m_pLayers->FrontLayer())
@ -200,13 +198,13 @@ void CMapLayers::OnRender()
if(m_Type == -1)
Render = true;
else if(m_Type == 0)
else if(m_Type == TYPE_BACKGROUND)
{
if(PassedGameLayer)
return;
Render = true;
}
else
else // TYPE_FOREGROUND
{
if(PassedGameLayer && !IsGameLayer)
Render = true;
@ -235,8 +233,6 @@ void CMapLayers::OnRender()
if((Render && g_Config.m_ClOverlayEntities < 100 && !IsGameLayer && !IsFrontLayer && !IsSwitchLayer && !IsTeleLayer && !IsSpeedupLayer && !IsTuneLayer) || (g_Config.m_ClOverlayEntities && IsGameLayer))
{
//layershot_begin();
if(pLayer->m_Type == LAYERTYPE_TILES)
{
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
@ -283,10 +279,8 @@ void CMapLayers::OnRender()
Graphics()->BlendNormal();
RenderTools()->RenderQuads(pQuads, pQLayer->m_NumQuads, LAYERRENDERFLAG_TRANSPARENT, EnvelopeEval, this);
}
//layershot_end();
}
else if(g_Config.m_ClOverlayEntities && IsFrontLayer)
else if(Render && g_Config.m_ClOverlayEntities && IsFrontLayer)
{
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
Graphics()->TextureSet(m_pClient->m_pMapimages->GetEntities());
@ -305,7 +299,7 @@ void CMapLayers::OnRender()
EnvelopeEval, this, pTMap->m_ColorEnv, pTMap->m_ColorEnvOffset);
}
}
else if(g_Config.m_ClOverlayEntities && IsSwitchLayer)
else if(Render && g_Config.m_ClOverlayEntities && IsSwitchLayer)
{
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
Graphics()->TextureSet(m_pClient->m_pMapimages->GetEntities());
@ -323,7 +317,7 @@ void CMapLayers::OnRender()
RenderTools()->RenderSwitchOverlay(pSwitchTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, g_Config.m_ClOverlayEntities/100.0f);
}
}
else if(g_Config.m_ClOverlayEntities && IsTeleLayer)
else if(Render && g_Config.m_ClOverlayEntities && IsTeleLayer)
{
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
Graphics()->TextureSet(m_pClient->m_pMapimages->GetEntities());
@ -341,7 +335,7 @@ void CMapLayers::OnRender()
RenderTools()->RenderTeleOverlay(pTeleTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, g_Config.m_ClOverlayEntities/100.0f);
}
}
else if(g_Config.m_ClOverlayEntities && IsSpeedupLayer)
else if(Render && g_Config.m_ClOverlayEntities && IsSpeedupLayer)
{
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
Graphics()->TextureSet(m_pClient->m_pMapimages->GetEntities());
@ -359,7 +353,7 @@ void CMapLayers::OnRender()
RenderTools()->RenderSpeedupOverlay(pSpeedupTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, g_Config.m_ClOverlayEntities/100.0f);
}
}
else if(g_Config.m_ClOverlayEntities && IsTuneLayer)
else if(Render && g_Config.m_ClOverlayEntities && IsTuneLayer)
{
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
Graphics()->TextureSet(m_pClient->m_pMapimages->GetEntities());

View file

@ -1243,11 +1243,12 @@ void CMenus::RenderServerbrowser(CUIRect MainView)
// status box
{
CUIRect Button, ButtonArea, Part;
CUIRect Button, ButtonArea;
StatusBox.HSplitTop(5.0f, 0, &StatusBox);
// version note
#if defined(CONF_FAMILY_WINDOWS) || (defined(CONF_PLATFORM_LINUX) && !defined(__ANDROID__))
CUIRect Part;
StatusBox.HSplitBottom(15.0f, &StatusBox, &Button);
char aBuf[64];
int State = Updater()->GetCurrentState();

View file

@ -796,9 +796,7 @@ void CMenus::RenderInGameBrowser(CUIRect MainView)
CUIRect Box = MainView;
CUIRect Button;
static int PrevPage = g_Config.m_UiPage;
static int LastServersPage = g_Config.m_UiPage;
int ActivePage = g_Config.m_UiPage;
int Page = g_Config.m_UiPage;
int NewPage = -1;
RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_ALL, 10.0f);
@ -809,40 +807,37 @@ void CMenus::RenderInGameBrowser(CUIRect MainView)
Box.VSplitLeft(100.0f, &Button, &Box);
static int s_InternetButton=0;
if(DoButton_MenuTab(&s_InternetButton, Localize("Internet"), ActivePage==PAGE_INTERNET, &Button, CUI::CORNER_TL))
if(DoButton_MenuTab(&s_InternetButton, Localize("Internet"), Page==PAGE_INTERNET, &Button, CUI::CORNER_TL))
{
if (PrevPage != PAGE_SETTINGS || LastServersPage != PAGE_INTERNET) ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET);
LastServersPage = PAGE_INTERNET;
if (Page != PAGE_INTERNET)
ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET);
NewPage = PAGE_INTERNET;
}
//Box.VSplitLeft(4.0f, 0, &Box);
Box.VSplitLeft(80.0f, &Button, &Box);
static int s_LanButton=0;
if(DoButton_MenuTab(&s_LanButton, Localize("LAN"), ActivePage==PAGE_LAN, &Button, 0))
if(DoButton_MenuTab(&s_LanButton, Localize("LAN"), Page==PAGE_LAN, &Button, 0))
{
if (PrevPage != PAGE_SETTINGS || LastServersPage != PAGE_LAN) ServerBrowser()->Refresh(IServerBrowser::TYPE_LAN);
LastServersPage = PAGE_LAN;
if (Page != PAGE_LAN)
ServerBrowser()->Refresh(IServerBrowser::TYPE_LAN);
NewPage = PAGE_LAN;
}
//box.VSplitLeft(4.0f, 0, &box);
Box.VSplitLeft(110.0f, &Button, &Box);
static int s_FavoritesButton=0;
if(DoButton_MenuTab(&s_FavoritesButton, Localize("Favorites"), ActivePage==PAGE_FAVORITES, &Button, 0))
if(DoButton_MenuTab(&s_FavoritesButton, Localize("Favorites"), Page==PAGE_FAVORITES, &Button, 0))
{
if (PrevPage != PAGE_SETTINGS || LastServersPage != PAGE_FAVORITES) ServerBrowser()->Refresh(IServerBrowser::TYPE_FAVORITES);
LastServersPage = PAGE_FAVORITES;
if (Page != PAGE_FAVORITES)
ServerBrowser()->Refresh(IServerBrowser::TYPE_FAVORITES);
NewPage = PAGE_FAVORITES;
}
//box.VSplitLeft(4.0f, 0, &box);
Box.VSplitLeft(110.0f, &Button, &Box);
static int s_DDNetButton=0;
if(DoButton_MenuTab(&s_DDNetButton, Localize("DDNet"), ActivePage==PAGE_DDNET, &Button, CUI::CORNER_TR))
if(DoButton_MenuTab(&s_DDNetButton, Localize("DDNet"), Page==PAGE_DDNET, &Button, CUI::CORNER_TR))
{
if (PrevPage != PAGE_SETTINGS || LastServersPage != PAGE_DDNET) ServerBrowser()->Refresh(IServerBrowser::TYPE_DDNET);
LastServersPage = PAGE_DDNET;
if (Page != PAGE_DDNET)
ServerBrowser()->Refresh(IServerBrowser::TYPE_DDNET);
NewPage = PAGE_DDNET;
}
@ -852,8 +847,6 @@ void CMenus::RenderInGameBrowser(CUIRect MainView)
g_Config.m_UiPage = NewPage;
}
PrevPage = g_Config.m_UiPage;
RenderServerbrowser(MainView);
return;
}

View file

@ -392,7 +392,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
Dummy.HSplitTop(20.0f, &DummyLabel, &Dummy);
if(DoButton_CheckBox(&g_Config.m_ClVanillaSkinsOnly, Localize("Vanilla Skins only"), !g_Config.m_ClVanillaSkinsOnly, &DummyLabel))
if(DoButton_CheckBox(&g_Config.m_ClVanillaSkinsOnly, Localize("Vanilla Skins only"), g_Config.m_ClVanillaSkinsOnly, &DummyLabel))
{
g_Config.m_ClVanillaSkinsOnly ^= 1;
m_NeedRestartSkins = true;
@ -936,7 +936,7 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
g_Config.m_SndEnable ^= 1;
if(g_Config.m_SndEnable)
{
if(g_Config.m_SndMusic)
if(g_Config.m_SndMusic && Client()->State() == IClient::STATE_OFFLINE)
m_pClient->m_pSounds->Play(CSounds::CHN_MUSIC, SOUND_MENU, 1.0f);
}
else

View file

@ -88,7 +88,7 @@ void CNamePlates::RenderNameplate(
void CNamePlates::OnRender()
{
if (!g_Config.m_ClNameplates || g_Config.m_ClAntiPingPlayers)
if (!g_Config.m_ClNameplates || m_pClient->AntiPingPlayers())
return;
for(int i = 0; i < MAX_CLIENTS; i++)

View file

@ -257,7 +257,7 @@ void CPlayers::RenderHook(
// set size
RenderInfo.m_Size = 64.0f;
if (!g_Config.m_ClAntiPingPlayers)
if (!m_pClient->AntiPingPlayers())
{
// use preditect players if needed
if(pInfo.m_Local && g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK)
@ -290,7 +290,7 @@ void CPlayers::RenderHook(
}
vec2 Position;
if (!g_Config.m_ClAntiPingPlayers)
if (!m_pClient->AntiPingPlayers())
Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick);
else
Position = parPosition;
@ -305,7 +305,7 @@ void CPlayers::RenderHook(
vec2 Pos = Position;
vec2 HookPos;
if (!g_Config.m_ClAntiPingPlayers)
if (!m_pClient->AntiPingPlayers())
{
if(pPlayerChar->m_HookedPlayer != -1)
{
@ -440,7 +440,7 @@ void CPlayers::RenderPlayer(
// use preditect players if needed
if (!g_Config.m_ClAntiPingPlayers)
if (!m_pClient->AntiPingPlayers())
{
if(pInfo.m_Local && g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK)
{
@ -475,7 +475,7 @@ void CPlayers::RenderPlayer(
vec2 Direction = GetDirection((int)(Angle*256.0f));
vec2 Position;
if (!g_Config.m_ClAntiPingPlayers)
if (!m_pClient->AntiPingPlayers())
Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick);
else
Position = parPosition;
@ -878,7 +878,7 @@ void CPlayers::RenderPlayer(
Graphics()->QuadsEnd();
}
if(g_Config.m_ClNameplates && g_Config.m_ClAntiPingPlayers)
if(g_Config.m_ClNameplates && m_pClient->AntiPingPlayers())
{
float FontSize = 18.0f + 20.0f * g_Config.m_ClNameplatesSize / 100.0f;
float FontSizeClan = 18.0f + 20.0f * g_Config.m_ClNameplatesClanSize / 100.0f;
@ -972,7 +972,7 @@ void CPlayers::OnRender()
static int predcnt = 0;
if (g_Config.m_ClAntiPingPlayers)
if (m_pClient->AntiPingPlayers())
{
for(int i = 0; i < MAX_CLIENTS; i++)
{
@ -999,7 +999,7 @@ void CPlayers::OnRender()
}
}
if(g_Config.m_ClAntiPingPlayers && g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK)
if(m_pClient->AntiPingPlayers() && g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK)
if(m_pClient->m_Snap.m_pLocalCharacter && !(m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER))
{
// double ping = m_pClient->m_Snap.m_pLocalInfo->m_Latency;

View file

@ -185,7 +185,7 @@ void CSpectator::OnRender()
return;
}
if(!m_pClient->m_Snap.m_SpecInfo.m_Active && !Client()->State() == IClient::STATE_DEMOPLAYBACK)
if(!m_pClient->m_Snap.m_SpecInfo.m_Active && Client()->State() != IClient::STATE_DEMOPLAYBACK)
{
m_Active = false;
m_WasActive = false;

View file

@ -110,6 +110,11 @@ const char *CGameClient::Version() { return GAME_VERSION; }
const char *CGameClient::NetVersion() { return GAME_NETVERSION; }
const char *CGameClient::GetItemName(int Type) { return m_NetObjHandler.GetObjName(Type); }
const CNetObj_PlayerInput &CGameClient::getPlayerInput(int dummy)
{
return m_pControls->m_InputData[dummy];
}
void CGameClient::ResetDummyInput()
{
m_pControls->ResetInput(!g_Config.m_ClDummy);
@ -461,7 +466,7 @@ void CGameClient::UpdatePositions()
// local character position
if(g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK)
{
if (!g_Config.m_ClAntiPingPlayers)
if(!AntiPingPlayers())
{
if(!m_Snap.m_pLocalCharacter || (m_Snap.m_pGameInfoObj && m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER))
{
@ -488,7 +493,7 @@ void CGameClient::UpdatePositions()
vec2(m_Snap.m_pLocalCharacter->m_X, m_Snap.m_pLocalCharacter->m_Y), Client()->IntraGameTick());
}
if (g_Config.m_ClAntiPingPlayers)
if (AntiPingPlayers())
{
for (int i = 0; i < MAX_CLIENTS; i++)
{
@ -579,14 +584,6 @@ void CGameClient::OnRender()
m_NewTick = false;
m_NewPredictedTick = false;
if(g_Config.m_ClAntiPing != m_CurrentAntiPing)
{
g_Config.m_ClAntiPingPlayers = g_Config.m_ClAntiPing;
g_Config.m_ClAntiPingGrenade = g_Config.m_ClAntiPing;
g_Config.m_ClAntiPingWeapons = g_Config.m_ClAntiPing;
m_CurrentAntiPing = g_Config.m_ClAntiPing;
}
if(g_Config.m_ClDummy && !Client()->DummyConnected())
g_Config.m_ClDummy = 0;
@ -664,7 +661,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker, bool IsDummy)
g_GameClient.m_pItems->AddExtraProjectile(&Proj);
if(g_Config.m_ClAntiPingWeapons && Proj.m_Type == WEAPON_GRENADE && !UseExtraInfo(&Proj))
if(AntiPingWeapons() && Proj.m_Type == WEAPON_GRENADE && !UseExtraInfo(&Proj))
{
vec2 StartPos;
vec2 Direction;
@ -1310,7 +1307,7 @@ void CGameClient::OnPredict()
}
static bool IsWeaker[2][MAX_CLIENTS] = {{0}};
if(g_Config.m_ClAntiPingPlayers)
if(AntiPingPlayers())
FindWeaker(IsWeaker);
// repredict character
@ -1338,7 +1335,7 @@ void CGameClient::OnPredict()
int ReloadTimer = 0;
vec2 PrevPos;
if(g_Config.m_ClAntiPingWeapons)
if(AntiPingWeapons())
{
for(int Index = 0; Index < MaxProjectiles; Index++)
PredictedProjectiles[Index].Deactivate();
@ -1419,7 +1416,7 @@ void CGameClient::OnPredict()
}
}
if(g_Config.m_ClAntiPingWeapons)
if(AntiPingWeapons())
{
const float ProximityRadius = 28.0f;
CNetObj_PlayerInput Input;
@ -1593,7 +1590,7 @@ void CGameClient::OnPredict()
}
// calculate where everyone should move
if(g_Config.m_ClAntiPingPlayers)
if(AntiPingPlayers())
{
//first apply Tick to weaker players (players that the local client has strong hook against), then local, then stronger players
for(int h = 0; h < 3; h++)
@ -1623,7 +1620,7 @@ void CGameClient::OnPredict()
}
// move all players and quantize their data
if(g_Config.m_ClAntiPingPlayers)
if(AntiPingPlayers())
{
// Everyone with weaker hook
for(int c = 0; c < MAX_CLIENTS; c++)
@ -1700,7 +1697,7 @@ void CGameClient::OnPredict()
{
m_PredictedChar = *World.m_apCharacters[m_Snap.m_LocalClientID];
if (g_Config.m_ClAntiPingPlayers)
if (AntiPingPlayers())
{
for (int c = 0; c < MAX_CLIENTS; c++)
{

View file

@ -314,6 +314,8 @@ public:
virtual const char *Version();
virtual const char *NetVersion();
virtual const CNetObj_PlayerInput &getPlayerInput(int dummy);
// actions
// TODO: move these
@ -363,11 +365,13 @@ public:
void FindWeaker(bool IsWeaker[2][MAX_CLIENTS]);
private:
bool AntiPingPlayers() { return g_Config.m_ClAntiPing && g_Config.m_ClAntiPingPlayers; }
bool AntiPingGrenade() { return g_Config.m_ClAntiPing && g_Config.m_ClAntiPingGrenade; }
bool AntiPingWeapons() { return g_Config.m_ClAntiPing && g_Config.m_ClAntiPingWeapons; }
private:
bool m_DDRaceMsgSent[2];
int m_ShowOthers[2];
bool m_CurrentAntiPing;
};

View file

@ -324,6 +324,9 @@ void CRenderTools::RenderTilemap(CTile *pTiles, int w, int h, float Scale, vec4
void CRenderTools::RenderTeleOverlay(CTeleTile *pTele, int w, int h, float Scale, float Alpha)
{
if(!g_Config.m_ClTextEntities)
return;
float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
@ -412,27 +415,32 @@ void CRenderTools::RenderSpeedupOverlay(CSpeedupTile *pSpeedup, int w, int h, fl
Graphics()->QuadsEnd();
// draw force
char aBuf[16];
str_format(aBuf, sizeof(aBuf), "%d", Force);
UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
UI()->TextRender()->Text(0, mx*Scale, my*Scale+16, Scale-20, aBuf, -1);
UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
if(MaxSpeed)
if(g_Config.m_ClTextEntities)
{
str_format(aBuf, sizeof(aBuf), "%d", MaxSpeed);
// draw force
char aBuf[16];
str_format(aBuf, sizeof(aBuf), "%d", Force);
UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
UI()->TextRender()->Text(0, mx*Scale, my*Scale-2, Scale-20, aBuf, -1);
UI()->TextRender()->Text(0, mx*Scale, my*Scale+16, Scale-20, aBuf, -1);
UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
if(MaxSpeed)
{
str_format(aBuf, sizeof(aBuf), "%d", MaxSpeed);
UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
UI()->TextRender()->Text(0, mx*Scale, my*Scale-2, Scale-20, aBuf, -1);
UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}
}
}
}
Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
}
void CRenderTools::RenderSwitchOverlay(CSwitchTile *pSwitch, int w, int h, float Scale, float Alpha)
{
if(!g_Config.m_ClTextEntities)
return;
float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
@ -488,6 +496,9 @@ void CRenderTools::RenderSwitchOverlay(CSwitchTile *pSwitch, int w, int h, float
void CRenderTools::RenderTuneOverlay(CTuneTile *pTune, int w, int h, float Scale, float Alpha)
{
if(!g_Config.m_ClTextEntities)
return;
float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);

View file

@ -206,7 +206,7 @@ void CEditorImage::AnalyseTileFlags()
int tw = m_Width/16; // tilesizes
int th = m_Height/16;
if ( tw == th )
if ( tw == th && m_Format == CImageInfo::FORMAT_RGBA )
{
unsigned char *pPixelData = (unsigned char *)m_pData;
@ -4267,8 +4267,8 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
{
if(pNewEnv->m_Channels == 4)
{
pNewEnv->AddPoint(0, 1,1,1,1);
pNewEnv->AddPoint(1000, 1,1,1,1);
pNewEnv->AddPoint(0, f2fx(1.0f), f2fx(1.0f), f2fx(1.0f), f2fx(1.0f));
pNewEnv->AddPoint(1000, f2fx(1.0f), f2fx(1.0f), f2fx(1.0f), f2fx(1.0f));
}
else
{
@ -4417,7 +4417,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
int Time = (int)(((UI()->MouseX()-View.x)*TimeScale)*1000.0f);
//float env_y = (UI()->MouseY()-view.y)/TimeScale;
float aChannels[4];
pEnvelope->Eval(Time, aChannels);
pEnvelope->Eval(Time / 1000.0f, aChannels);
pEnvelope->AddPoint(Time,
f2fx(aChannels[0]), f2fx(aChannels[1]),
f2fx(aChannels[2]), f2fx(aChannels[3]));
@ -5466,9 +5466,7 @@ void CEditor::DoMapBorder()
void CEditor::CreateUndoStep()
{
void *CreateThread = thread_init(CreateUndoStepThread, this);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)CreateThread);
#endif
thread_detach(CreateThread);
}
void CEditor::CreateUndoStepThread(void *pUser)

View file

@ -622,16 +622,28 @@ void CGameContext::ConSave(IConsole::IResult *pResult, void *pUserData)
int Team = ((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.m_Core.Team(pResult->m_ClientID);
const char* pCode = pResult->GetString(0);
char aCountry[4];
char aCountry[5];
if(str_length(pCode) > 3 && pCode[0] >= 'A' && pCode[0] <= 'Z' && pCode[1] >= 'A'
&& pCode[1] <= 'Z' && pCode[2] >= 'A' && pCode[2] <= 'Z' && pCode[3] == ' ')
&& pCode[1] <= 'Z' && pCode[2] >= 'A' && pCode[2] <= 'Z')
{
str_copy(aCountry, pCode, 4);
pCode = pCode + 4;
if(pCode[3] == ' ')
{
str_copy(aCountry, pCode, 4);
pCode = pCode + 4;
}
else if(str_length(pCode) > 4 && pCode[4] == ' ')
{
str_copy(aCountry, pCode, 5);
pCode = pCode + 5;
}
else
{
str_copy(aCountry, g_Config.m_SvSqlServerName, sizeof(aCountry));
}
}
else
{
str_copy(aCountry, g_Config.m_SvSqlServerName, 4);
str_copy(aCountry, g_Config.m_SvSqlServerName, sizeof(aCountry));
}
pSelf->Score()->SaveTeam(Team, pCode, pResult->m_ClientID, aCountry);

View file

@ -476,7 +476,7 @@ void CCharacter::FireWeapon()
for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
Msg.AddInt(((int *)&p)[i]);
Server()->SendMsg(&Msg, 0, m_pPlayer->GetCID());
Server()->SendMsg(&Msg, MSGFLAG_VITAL, m_pPlayer->GetCID());
GameServer()->CreateSound(m_Pos, SOUND_GUN_FIRE, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID()));
}
} break;
@ -510,7 +510,7 @@ void CCharacter::FireWeapon()
Msg.AddInt(((int *)&p)[i]);
}
Server()->SendMsg(&Msg, 0,m_pPlayer->GetCID());
Server()->SendMsg(&Msg, MSGFLAG_VITAL, m_pPlayer->GetCID());
GameServer()->CreateSound(m_Pos, SOUND_SHOTGUN_FIRE);*/
float LaserReach;
@ -554,7 +554,7 @@ void CCharacter::FireWeapon()
Msg.AddInt(1);
for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
Msg.AddInt(((int *)&p)[i]);
Server()->SendMsg(&Msg, 0, m_pPlayer->GetCID());
Server()->SendMsg(&Msg, MSGFLAG_VITAL, m_pPlayer->GetCID());
GameServer()->CreateSound(m_Pos, SOUND_GRENADE_FIRE, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID()));
} break;

View file

@ -1,14 +1,13 @@
/* (c) Shereef Marzouk. See "licence DDRace.txt" and the readme.txt in the root of the distribution for more information. */
#include <engine/config.h>
#include <engine/server.h>
#include <engine/shared/config.h>
#include <game/generated/protocol.h>
#include <game/server/gamecontext.h>
#include <game/server/teams.h>
#include <game/server/gamemodes/DDRace.h>
#include "dragger.h"
const int LENGTH = 700;
CDragger::CDragger(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW,
int CatchedTeam, int Layer, int Number) :
CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER)
@ -39,7 +38,7 @@ void CDragger::Move()
mem_zero(m_SoloEnts, sizeof(m_SoloEnts));
CCharacter *TempEnts[MAX_CLIENTS];
int Num = GameServer()->m_World.FindEntities(m_Pos, LENGTH,
int Num = GameServer()->m_World.FindEntities(m_Pos, g_Config.m_SvDraggerRange,
(CEntity**) m_SoloEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
mem_copy(TempEnts, m_SoloEnts, sizeof(TempEnts));
@ -118,7 +117,7 @@ void CDragger::Drag()
else
Res = GameServer()->Collision()->IntersectNoLaserNW(m_Pos,
Target->m_Pos, 0, 0);
if (Res || length(m_Pos - Target->m_Pos) > 700)
if (Res || length(m_Pos - Target->m_Pos) > g_Config.m_SvDraggerRange)
{
Target = 0;
if (i == -1)

View file

@ -1096,7 +1096,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
Console()->SetFlagMask(CFGFLAG_CHAT);
if (pPlayer->m_Authed)
Console()->SetAccessLevel(pPlayer->m_Authed == CServer::AUTHED_ADMIN ? IConsole::ACCESS_LEVEL_ADMIN : IConsole::ACCESS_LEVEL_MOD);
Console()->SetAccessLevel(pPlayer->m_Authed == CServer::AUTHED_ADMIN ? IConsole::ACCESS_LEVEL_ADMIN : pPlayer->m_Authed == CServer::AUTHED_MOD ? IConsole::ACCESS_LEVEL_MOD : IConsole::ACCESS_LEVEL_HELPER);
else
Console()->SetAccessLevel(IConsole::ACCESS_LEVEL_USER);
Console()->SetPrintOutputLevel(m_ChatPrintCBIndex, 0);

View file

@ -96,9 +96,7 @@ void CFileScore::SaveScoreThread(void *pUser)
void CFileScore::Save()
{
void *pSaveThread = thread_init(SaveScoreThread, this);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)pSaveThread);
#endif
thread_detach(pSaveThread);
}
void CFileScore::Init()

View file

@ -95,8 +95,11 @@ bool CSqlScore::Connect()
m_pStatement = m_pConnection->createStatement();
// Create database if not exists
str_format(aBuf, sizeof(aBuf), "CREATE DATABASE IF NOT EXISTS %s", m_pDatabase);
m_pStatement->execute(aBuf);
if(g_Config.m_SvSqlCreateTables)
{
str_format(aBuf, sizeof(aBuf), "CREATE DATABASE IF NOT EXISTS %s", m_pDatabase);
m_pStatement->execute(aBuf);
}
// Connect to specific database
m_pConnection->setSchema(m_pDatabase);
@ -163,25 +166,27 @@ void CSqlScore::Init()
{
try
{
// create tables
char aBuf[1024];
// create tables
if(g_Config.m_SvSqlCreateTables)
{
str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_race (Map VARCHAR(128) BINARY NOT NULL, Name VARCHAR(%d) BINARY NOT NULL, Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , Time FLOAT DEFAULT 0, Server CHAR(4), cp1 FLOAT DEFAULT 0, cp2 FLOAT DEFAULT 0, cp3 FLOAT DEFAULT 0, cp4 FLOAT DEFAULT 0, cp5 FLOAT DEFAULT 0, cp6 FLOAT DEFAULT 0, cp7 FLOAT DEFAULT 0, cp8 FLOAT DEFAULT 0, cp9 FLOAT DEFAULT 0, cp10 FLOAT DEFAULT 0, cp11 FLOAT DEFAULT 0, cp12 FLOAT DEFAULT 0, cp13 FLOAT DEFAULT 0, cp14 FLOAT DEFAULT 0, cp15 FLOAT DEFAULT 0, cp16 FLOAT DEFAULT 0, cp17 FLOAT DEFAULT 0, cp18 FLOAT DEFAULT 0, cp19 FLOAT DEFAULT 0, cp20 FLOAT DEFAULT 0, cp21 FLOAT DEFAULT 0, cp22 FLOAT DEFAULT 0, cp23 FLOAT DEFAULT 0, cp24 FLOAT DEFAULT 0, cp25 FLOAT DEFAULT 0, KEY (Map, Name)) CHARACTER SET utf8 ;", m_pPrefix, MAX_NAME_LENGTH);
m_pStatement->execute(aBuf);
str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_race (Map VARCHAR(128) BINARY NOT NULL, Name VARCHAR(%d) BINARY NOT NULL, Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , Time FLOAT DEFAULT 0, Server CHAR(3), cp1 FLOAT DEFAULT 0, cp2 FLOAT DEFAULT 0, cp3 FLOAT DEFAULT 0, cp4 FLOAT DEFAULT 0, cp5 FLOAT DEFAULT 0, cp6 FLOAT DEFAULT 0, cp7 FLOAT DEFAULT 0, cp8 FLOAT DEFAULT 0, cp9 FLOAT DEFAULT 0, cp10 FLOAT DEFAULT 0, cp11 FLOAT DEFAULT 0, cp12 FLOAT DEFAULT 0, cp13 FLOAT DEFAULT 0, cp14 FLOAT DEFAULT 0, cp15 FLOAT DEFAULT 0, cp16 FLOAT DEFAULT 0, cp17 FLOAT DEFAULT 0, cp18 FLOAT DEFAULT 0, cp19 FLOAT DEFAULT 0, cp20 FLOAT DEFAULT 0, cp21 FLOAT DEFAULT 0, cp22 FLOAT DEFAULT 0, cp23 FLOAT DEFAULT 0, cp24 FLOAT DEFAULT 0, cp25 FLOAT DEFAULT 0, KEY (Map, Name)) CHARACTER SET utf8 ;", m_pPrefix, MAX_NAME_LENGTH);
m_pStatement->execute(aBuf);
str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_teamrace (Map VARCHAR(128) BINARY NOT NULL, Name VARCHAR(%d) BINARY NOT NULL, Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, Time FLOAT DEFAULT 0, ID VARBINARY(16) NOT NULL, KEY Map (Map)) CHARACTER SET utf8 ;", m_pPrefix, MAX_NAME_LENGTH);
m_pStatement->execute(aBuf);
str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_teamrace (Map VARCHAR(128) BINARY NOT NULL, Name VARCHAR(%d) BINARY NOT NULL, Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, Time FLOAT DEFAULT 0, ID VARBINARY(16) NOT NULL, KEY Map (Map)) CHARACTER SET utf8 ;", m_pPrefix, MAX_NAME_LENGTH);
m_pStatement->execute(aBuf);
str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_maps (Map VARCHAR(128) BINARY NOT NULL, Server VARCHAR(32) BINARY NOT NULL, Mapper VARCHAR(128) BINARY NOT NULL, Points INT DEFAULT 0, Stars INT DEFAULT 0, Timestamp TIMESTAMP, UNIQUE KEY Map (Map)) CHARACTER SET utf8 ;", m_pPrefix);
m_pStatement->execute(aBuf);
str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_maps (Map VARCHAR(128) BINARY NOT NULL, Server VARCHAR(32) BINARY NOT NULL, Mapper VARCHAR(128) BINARY NOT NULL, Points INT DEFAULT 0, Stars INT DEFAULT 0, Timestamp TIMESTAMP, UNIQUE KEY Map (Map)) CHARACTER SET utf8 ;", m_pPrefix);
m_pStatement->execute(aBuf);
str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_saves (Savegame TEXT CHARACTER SET utf8 BINARY NOT NULL, Map VARCHAR(128) BINARY NOT NULL, Code VARCHAR(128) BINARY NOT NULL, Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, Server CHAR(4), UNIQUE KEY (Map, Code)) CHARACTER SET utf8 ;", m_pPrefix);
m_pStatement->execute(aBuf);
str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_saves (Savegame TEXT CHARACTER SET utf8 BINARY NOT NULL, Map VARCHAR(128) BINARY NOT NULL, Code VARCHAR(128) BINARY NOT NULL, Timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, Server CHAR(3), UNIQUE KEY (Map, Code)) CHARACTER SET utf8 ;", m_pPrefix);
m_pStatement->execute(aBuf);
str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_points (Name VARCHAR(%d) BINARY NOT NULL, Points INT DEFAULT 0, UNIQUE KEY Name (Name)) CHARACTER SET utf8 ;", m_pPrefix, MAX_NAME_LENGTH);
m_pStatement->execute(aBuf);
str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_points (Name VARCHAR(%d) BINARY NOT NULL, Points INT DEFAULT 0, UNIQUE KEY Name (Name)) CHARACTER SET utf8 ;", m_pPrefix, MAX_NAME_LENGTH);
m_pStatement->execute(aBuf);
dbg_msg("SQL", "Tables were created successfully");
dbg_msg("SQL", "Tables were created successfully");
}
// get the best time
str_format(aBuf, sizeof(aBuf), "SELECT Time FROM %s_race WHERE Map='%s' ORDER BY `Time` ASC LIMIT 0, 1;", m_pPrefix, m_aMap);
@ -279,9 +284,7 @@ void CSqlScore::LoadScore(int ClientID)
Tmp->m_pSqlData = this;
void *LoadThread = thread_init(LoadScoreThread, Tmp);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)LoadThread);
#endif
thread_detach(LoadThread);
}
void CSqlScore::SaveTeamScoreThread(void *pUser)
@ -416,9 +419,7 @@ void CSqlScore::MapVote(int ClientID, const char* MapName)
Tmp->m_pSqlData = this;
void *VoteThread = thread_init(MapVoteThread, Tmp);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)VoteThread);
#endif
thread_detach(VoteThread);
}
void CSqlScore::MapVoteThread(void *pUser)
@ -518,9 +519,7 @@ void CSqlScore::MapInfo(int ClientID, const char* MapName)
Tmp->m_pSqlData = this;
void *InfoThread = thread_init(MapInfoThread, Tmp);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)InfoThread);
#endif
thread_detach(InfoThread);
}
void CSqlScore::MapInfoThread(void *pUser)
@ -693,9 +692,7 @@ void CSqlScore::SaveScore(int ClientID, float Time, float CpTime[NUM_CHECKPOINTS
Tmp->m_pSqlData = this;
void *SaveThread = thread_init(SaveScoreThread, Tmp);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)SaveThread);
#endif
thread_detach(SaveThread);
}
void CSqlScore::SaveTeamScore(int* aClientIDs, unsigned int Size, float Time)
@ -714,9 +711,7 @@ void CSqlScore::SaveTeamScore(int* aClientIDs, unsigned int Size, float Time)
Tmp->m_pSqlData = this;
void *SaveTeamThread = thread_init(SaveTeamScoreThread, Tmp);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)SaveTeamThread);
#endif
thread_detach(SaveTeamThread);
}
void CSqlScore::ShowTeamRankThread(void *pUser)
@ -836,7 +831,7 @@ void CSqlScore::ShowTeamTop5Thread(void *pUser)
char aNames[2300];
int Rank = 0;
float Time = 0;
int aCuts[Rows];
int aCuts[320]; // 64 * 5
int CutPos = 0;
aNames[0] = '\0';
@ -983,9 +978,7 @@ void CSqlScore::ShowTeamRank(int ClientID, const char* pName, bool Search)
Tmp->m_pSqlData = this;
void *TeamRankThread = thread_init(ShowTeamRankThread, Tmp);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)TeamRankThread);
#endif
thread_detach(TeamRankThread);
}
void CSqlScore::ShowRank(int ClientID, const char* pName, bool Search)
@ -998,9 +991,7 @@ void CSqlScore::ShowRank(int ClientID, const char* pName, bool Search)
Tmp->m_pSqlData = this;
void *RankThread = thread_init(ShowRankThread, Tmp);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)RankThread);
#endif
thread_detach(RankThread);
}
void CSqlScore::ShowTop5Thread(void *pUser)
@ -1152,9 +1143,7 @@ void CSqlScore::ShowTeamTop5(IConsole::IResult *pResult, int ClientID, void *pUs
Tmp->m_pSqlData = this;
void *TeamTop5Thread = thread_init(ShowTeamTop5Thread, Tmp);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)TeamTop5Thread);
#endif
thread_detach(TeamTop5Thread);
}
void CSqlScore::ShowTop5(IConsole::IResult *pResult, int ClientID, void *pUserData, int Debut)
@ -1165,9 +1154,7 @@ void CSqlScore::ShowTop5(IConsole::IResult *pResult, int ClientID, void *pUserDa
Tmp->m_pSqlData = this;
void *Top5Thread = thread_init(ShowTop5Thread, Tmp);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)Top5Thread);
#endif
thread_detach(Top5Thread);
}
void CSqlScore::ShowTimes(int ClientID, int Debut)
@ -1179,9 +1166,7 @@ void CSqlScore::ShowTimes(int ClientID, int Debut)
Tmp->m_Search = false;
void *TimesThread = thread_init(ShowTimesThread, Tmp);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)TimesThread);
#endif
thread_detach(TimesThread);
}
void CSqlScore::ShowTimes(int ClientID, const char* pName, int Debut)
@ -1194,9 +1179,7 @@ void CSqlScore::ShowTimes(int ClientID, const char* pName, int Debut)
Tmp->m_Search = true;
void *TimesThread = thread_init(ShowTimesThread, Tmp);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)TimesThread);
#endif
thread_detach(TimesThread);
}
void CSqlScore::FuzzyString(char *pString)
@ -1221,7 +1204,7 @@ void CSqlScore::FuzzyString(char *pString)
// anti SQL injection
void CSqlScore::ClearString(char *pString, int size)
{
char newString[size*2-1];
char *newString = (char *)malloc(size * 2 - 1);
int pos = 0;
for(int i=0;i<size;i++)
@ -1250,6 +1233,7 @@ void CSqlScore::ClearString(char *pString, int size)
newString[pos] = '\0';
strcpy(pString,newString);
free(newString);
}
void CSqlScore::agoTimeToString(int agoTime, char agoString[])
@ -1399,9 +1383,7 @@ void CSqlScore::ShowPoints(int ClientID, const char* pName, bool Search)
Tmp->m_pSqlData = this;
void *PointsThread = thread_init(ShowPointsThread, Tmp);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)PointsThread);
#endif
thread_detach(PointsThread);
}
void CSqlScore::ShowTopPointsThread(void *pUser)
@ -1463,9 +1445,7 @@ void CSqlScore::ShowTopPoints(IConsole::IResult *pResult, int ClientID, void *pU
Tmp->m_pSqlData = this;
void *TopPointsThread = thread_init(ShowTopPointsThread, Tmp);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)TopPointsThread);
#endif
thread_detach(TopPointsThread);
}
void CSqlScore::RandomMapThread(void *pUser)
@ -1589,9 +1569,7 @@ void CSqlScore::RandomMap(int ClientID, int stars)
Tmp->m_pSqlData = this;
void *RandomThread = thread_init(RandomMapThread, Tmp);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)RandomThread);
#endif
thread_detach(RandomThread);
}
void CSqlScore::RandomUnfinishedMap(int ClientID, int stars)
@ -1603,9 +1581,7 @@ void CSqlScore::RandomUnfinishedMap(int ClientID, int stars)
Tmp->m_pSqlData = this;
void *RandomUnfinishedThread = thread_init(RandomUnfinishedMapThread, Tmp);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)RandomUnfinishedThread);
#endif
thread_detach(RandomUnfinishedThread);
}
void CSqlScore::SaveTeam(int Team, const char* Code, int ClientID, const char* Server)
@ -1630,9 +1606,7 @@ void CSqlScore::SaveTeam(int Team, const char* Code, int ClientID, const char* S
Tmp->m_pSqlData = this;
void *SaveThread = thread_init(SaveTeamThread, Tmp);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)SaveThread);
#endif
thread_detach(SaveThread);
}
void CSqlScore::SaveTeamThread(void *pUser)
@ -1745,9 +1719,7 @@ void CSqlScore::LoadTeam(const char* Code, int ClientID)
Tmp->m_pSqlData = this;
void *LoadThread = thread_init(LoadTeamThread, Tmp);
#if defined(CONF_FAMILY_UNIX)
pthread_detach((pthread_t)LoadThread);
#endif
thread_detach(LoadThread);
}
void CSqlScore::LoadTeamThread(void *pUser)
@ -1776,7 +1748,7 @@ void CSqlScore::LoadTeamThread(void *pUser)
if (pData->m_pSqlData->m_pResults->rowsCount() > 0)
{
pData->m_pSqlData->m_pResults->first();
char ServerName[4];
char ServerName[5];
str_copy(ServerName, pData->m_pSqlData->m_pResults->getString("Server").c_str(), sizeof(ServerName));
if(str_comp(ServerName, g_Config.m_SvSqlServerName))
{

View file

@ -144,7 +144,7 @@ struct CSqlTeamSave
int m_Team;
int m_ClientID;
char m_Code[128];
char m_Server[4];
char m_Server[5];
CSqlScore *m_pSqlData;
};

View file

@ -623,11 +623,21 @@ void CGameTeams::OnCharacterDeath(int ClientID, int Weapon)
SetForceCharacterTeam(ClientID, Team);
if (GetTeamState(Team) != TEAMSTATE_OPEN)
{
ChangeTeamState(Team, CGameTeams::TEAMSTATE_OPEN);
char aBuf[512];
str_format(aBuf, sizeof(aBuf), "Everyone in your locked team was killed because you %s.", Weapon == WEAPON_SELF ? "killed" : "died");
GameServer()->SendChatTarget(ClientID, aBuf);
str_format(aBuf, sizeof(aBuf), "Everyone in your locked team was killed because '%s' %s.", Server()->ClientName(ClientID), Weapon == WEAPON_SELF ? "killed" : "died");
for (int i = 0; i < MAX_CLIENTS; i++)
if(m_Core.Team(i) == Team && i != ClientID && GameServer()->m_apPlayers[i])
GameServer()->m_apPlayers[i]->KillCharacter(-2);
ChangeTeamState(Team, CGameTeams::TEAMSTATE_OPEN);
{
GameServer()->m_apPlayers[i]->KillCharacter(WEAPON_SELF);
GameServer()->SendChatTarget(i, aBuf);
}
}
}
}

View file

@ -7,16 +7,17 @@
// client
MACRO_CONFIG_INT(ClPredict, cl_predict, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict client movements")
MACRO_CONFIG_INT(ClAntiPingLimit, cl_antiping_limit, 0, 0, 200, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping limit (0 to disable)")
MACRO_CONFIG_INT(ClAntiPing, cl_antiping, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping (sets all Antiping settings)")
MACRO_CONFIG_INT(ClAntiPingPlayers, cl_antiping_players, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping (predict other players' movements)")
MACRO_CONFIG_INT(ClAntiPingGrenade, cl_antiping_grenade, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping (predict grenades)")
MACRO_CONFIG_INT(ClAntiPingWeapons, cl_antiping_weapons, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Antiping (predict weapons)")
MACRO_CONFIG_INT(ClAntiPing, cl_antiping, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Enable antiping, i. e. more aggressive prediction.")
MACRO_CONFIG_INT(ClAntiPingPlayers, cl_antiping_players, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict other player's movement more aggressively (only enabled if cl_antiping is set to 1)")
MACRO_CONFIG_INT(ClAntiPingGrenade, cl_antiping_grenade, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict grenades (only enabled if cl_antiping is set to 1)")
MACRO_CONFIG_INT(ClAntiPingWeapons, cl_antiping_weapons, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict weapon projectiles (only enabled if cl_antiping is set to 1)")
MACRO_CONFIG_INT(ClNameplates, cl_nameplates, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show name plates")
MACRO_CONFIG_INT(ClNameplatesAlways, cl_nameplates_always, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Always show name plates disregarding of distance")
MACRO_CONFIG_INT(ClNameplatesTeamcolors, cl_nameplates_teamcolors, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Use team colors for name plates")
MACRO_CONFIG_INT(ClNameplatesSize, cl_nameplates_size, 50, 0, 100, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Size of the name plates from 0 to 100%")
MACRO_CONFIG_INT(ClNameplatesClan, cl_nameplates_clan, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show clan in name plates")
MACRO_CONFIG_INT(ClNameplatesClanSize, cl_nameplates_clan_size, 30, 0, 100, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Size of the clan plates from 0 to 100%")
MACRO_CONFIG_INT(ClTextEntities, cl_text_entities, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Render textual entity data")
#if defined(__ANDROID__)
MACRO_CONFIG_INT(ClAutoswitchWeapons, cl_autoswitch_weapons, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Auto switch weapon on pickup")
MACRO_CONFIG_INT(ClAutoswitchWeaponsOutOfAmmo, cl_autoswitch_weapons_out_of_ammo, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Auto switch weapon when out of ammo")

View file

@ -1,7 +1,7 @@
#include <NSString.h>
#include <NSUserNotification.h>
#include <Cocoa/Cocoa.h>
#include "notification.h"
#import <Foundation/Foundation.h>
#import <Foundation/NSUserNotification.h>
#import <Cocoa/Cocoa.h>
#import "notification.h"
void CNotification::notify(const char *pTitle, const char *pMsg)
{