diff --git a/autoexec_server.cfg b/autoexec_server.cfg index c7e85af..643b00d 100644 --- a/autoexec_server.cfg +++ b/autoexec_server.cfg @@ -1,29 +1,29 @@ #STANDARD SETTINGS -sv_name "『中国活动服』xPanic 僵尸惊魂-安全屋" +sv_name "Server name" sv_max_clients 64 sv_max_clients_per_ip 2 -sv_port 0 +sv_port 8303 sv_map "xPanic life" sv_gametype xPanic sv_register 1 #RCON PASSWORD -sv_rcon_password "NOT CHNFUN PASSWORD XD" -sv_rcon_mod_password "DODODODO" -sv_rcon_helper_password "114514" +sv_rcon_password "rcon password" +sv_rcon_mod_password "mod password" +sv_rcon_helper_password "helper password" #114514真的是helper密码,直接输入就行 #OTHER SETTINGS -sv_exp_bonus 5 +sv_exp_bonus 3 sv_emoticon_delay 0 sv_test_cmds 1 sv_warmup 15 sv_inactivekick 4 sv_spectator_votes 0 sv_timelimit 5 -sv_new_hearth 0 +sv_new_hearth 1 logfile "xPanic.log" sv_motd "输入/help获得帮助" @@ -52,9 +52,9 @@ add_vote "|地图| 我的世界MC惊魂" "change_map panic_minecraft" add_vote "|地图| 法老金字塔" "change_map Pharao-Pyramid" add_vote "|地图| Rioの避难所" "change_map Shelter by Rio" add_vote "|地图| 隧道" "change_map Tunnel" -add_vote "|地图| X-惊魂的人生" "change_map xPanic life" -add_vote "|地图| 僵急追 尸速逐 X-15号" "change_map Zumbierunx15" -add_vote "|地图| HG-DIO的『世 界』" "change_map THE_WORLD" +add_vote "|地图| X人生" "change_map xPanic life" +add_vote "|地图| Zombie Run X15" "change_map Zumbierunx15" +add_vote "|地图| ()Dio的『世 界』" "change_map THE_WORLD" # ACCESS DDNET diff --git a/bam.lua b/bam.lua index 09c423e..314b7b8 100644 --- a/bam.lua +++ b/bam.lua @@ -1,16 +1,14 @@ -CheckVersion("0.4") - target_family = os.getenv("TARGET_FAMILY") if target_family then - family = target_family + family = target_family end target_platform = os.getenv("TARGET_PLATFORM") if target_platform then - platform = target_platform + platform = target_platform end target_arch = os.getenv("TARGET_ARCH") if target_arch then - arch = target_arch + arch = target_arch end Import("configure.lua") @@ -26,7 +24,8 @@ Import("other/mysql/mysql.lua") config = NewConfig() config:Add(OptCCompiler("compiler")) config:Add(OptTestCompileC("stackprotector", "int main(){return 0;}", "-fstack-protector -fstack-protector-all")) -config:Add(OptTestCompileC("minmacosxsdk", "int main(){return 0;}", "-mmacosx-version-min=10.7 -isysroot /Developer/SDKs/MacOSX10.7.sdk")) +config:Add(OptTestCompileC("minmacosxsdk", "int main(){return 0;}", + "-mmacosx-version-min=10.7 -isysroot /Developer/SDKs/MacOSX10.7.sdk")) config:Add(OptTestCompileC("macosxppc", "int main(){return 0;}", "-arch ppc")) config:Add(OptLibrary("zlib", "zlib.h", false)) config:Add(SDL.OptFind("sdl", true)) @@ -41,31 +40,31 @@ config:Finalize("config.lua") -- data compiler function Script(name) - if family == "windows" and target_family ~= "windows" then - return str_replace(name, "/", "\\") - end - return "python " .. name + if family == "windows" and target_family ~= "windows" then + return str_replace(name, "/", "\\") + end + return "python3 " .. name end function CHash(output, ...) - local inputs = TableFlatten({...}) + local inputs = TableFlatten({...}) - output = Path(output) + output = Path(output) - -- compile all the files - local cmd = Script("scripts/cmd5.py") .. " " - for index, inname in ipairs(inputs) do - cmd = cmd .. Path(inname) .. " " - end + -- compile all the files + local cmd = Script("scripts/cmd5.py") .. " " + for index, inname in ipairs(inputs) do + cmd = cmd .. Path(inname) .. " " + end - cmd = cmd .. " > " .. output + cmd = cmd .. " > " .. output - AddJob(output, "cmd5 " .. output, cmd) - for index, inname in ipairs(inputs) do - AddDependency(output, inname) - end - AddDependency(output, "scripts/cmd5.py") - return output + AddJob(output, "cmd5 " .. output, cmd) + for index, inname in ipairs(inputs) do + AddDependency(output, inname) + end + AddDependency(output, "scripts/cmd5.py") + return output end --[[ @@ -80,50 +79,43 @@ 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) - end - - AddDependency(output, scriptfile) - return output + 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) + end + + AddDependency(output, scriptfile) + return output end function Dat2c(datafile, sourcefile, arrayname) - datafile = Path(datafile) - sourcefile = Path(sourcefile) - - AddJob( - sourcefile, - "dat2c " .. PathFilename(sourcefile) .. " = " .. PathFilename(datafile), - Script("scripts/dat2c.py").. "\" " .. sourcefile .. " " .. datafile .. " " .. arrayname - ) - AddDependency(sourcefile, datafile) - return sourcefile + datafile = Path(datafile) + sourcefile = Path(sourcefile) + + AddJob(sourcefile, "dat2c " .. PathFilename(sourcefile) .. " = " .. PathFilename(datafile), + Script("scripts/dat2c.py") .. "\" " .. sourcefile .. " " .. datafile .. " " .. arrayname) + AddDependency(sourcefile, datafile) + return sourcefile end function ContentCompile(action, output) - output = Path(output) - AddJob( - output, - action .. " > " .. output, - --Script("datasrc/compile.py") .. "\" ".. Path(output) .. " " .. action - Script("datasrc/compile.py") .. " " .. action .. " > " .. Path(output) - ) - AddDependency(output, Path("datasrc/content.py")) -- do this more proper - AddDependency(output, Path("datasrc/network.py")) - AddDependency(output, Path("datasrc/compile.py")) - AddDependency(output, Path("datasrc/datatypes.py")) - return output + output = Path(output) + AddJob(output, action .. " > " .. output, -- Script("datasrc/compile.py") .. "\" ".. Path(output) .. " " .. action + Script("datasrc/compile.py") .. " " .. action .. " > " .. Path(output)) + AddDependency(output, Path("datasrc/content.py")) -- do this more proper + AddDependency(output, Path("datasrc/network.py")) + AddDependency(output, Path("datasrc/compile.py")) + AddDependency(output, Path("datasrc/datatypes.py")) + return output end -- Content Compile @@ -138,7 +130,8 @@ AddDependency(network_source, network_header) AddDependency(client_content_source, client_content_header) AddDependency(server_content_source, server_content_header) -nethash = CHash("src/game/generated/nethash.cpp", "src/engine/shared/protocol.h", "src/game/generated/protocol.h", "src/game/tuning.h", "src/game/gamecore.cpp", network_header) +nethash = CHash("src/game/generated/nethash.cpp", "src/engine/shared/protocol.h", "src/game/generated/protocol.h", + "src/game/tuning.h", "src/game/gamecore.cpp", network_header) icu_depends = {} client_link_other = {} @@ -147,338 +140,333 @@ server_link_other = {} 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/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/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")) - - if config.compiler.driver == "cl" then - table.insert(icu_depends, CopyToDirectory(".", "other/icu/vc/lib32/icudt53.dll")) - table.insert(icu_depends, CopyToDirectory(".", "other/icu/vc/lib32/icuin53.dll")) - table.insert(icu_depends, CopyToDirectory(".", "other/icu/vc/lib32/icuuc53.dll")) - elseif config.compiler.driver == "gcc" then - table.insert(icu_depends, CopyToDirectory(".", "other/icu/gcc/lib32/icudt53.dll")) - table.insert(icu_depends, CopyToDirectory(".", "other/icu/gcc/lib32/icuin53.dll")) - table.insert(icu_depends, CopyToDirectory(".", "other/icu/gcc/lib32/icuuc53.dll")) - end - 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/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")) - - -- Add ICU because its a HAVE to - if config.compiler.driver == "cl" then - table.insert(icu_depends, CopyToDirectory(".", "other/icu/vc/lib64/icudt53.dll")) - table.insert(icu_depends, CopyToDirectory(".", "other/icu/vc/lib64/icuin53.dll")) - table.insert(icu_depends, CopyToDirectory(".", "other/icu/vc/lib64/icuuc53.dll")) - elseif config.compiler.driver == "gcc" then - table.insert(icu_depends, CopyToDirectory(".", "other/icu/gcc/lib64/icudt53.dll")) - table.insert(icu_depends, CopyToDirectory(".", "other/icu/gcc/lib64/icuin53.dll")) - table.insert(icu_depends, CopyToDirectory(".", "other/icu/gcc/lib64/icuuc53.dll")) - end - end - 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")} - server_link_other = {ResCompile("other/icons/teeworlds_srv_cl.rc")} - elseif config.compiler.driver == "gcc" then - client_link_other = {ResCompile("other/icons/teeworlds_gcc.rc")} - server_link_other = {ResCompile("other/icons/teeworlds_srv_gcc.rc")} - end + 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/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/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")) + + if config.compiler.driver == "cl" then + table.insert(icu_depends, CopyToDirectory(".", "other/icu/vc/lib32/icudt53.dll")) + table.insert(icu_depends, CopyToDirectory(".", "other/icu/vc/lib32/icuin53.dll")) + table.insert(icu_depends, CopyToDirectory(".", "other/icu/vc/lib32/icuuc53.dll")) + elseif config.compiler.driver == "gcc" then + table.insert(icu_depends, CopyToDirectory(".", "other/icu/gcc/lib32/icudt53.dll")) + table.insert(icu_depends, CopyToDirectory(".", "other/icu/gcc/lib32/icuin53.dll")) + table.insert(icu_depends, CopyToDirectory(".", "other/icu/gcc/lib32/icuuc53.dll")) + end + 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/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")) + + -- Add ICU because its a HAVE to + if config.compiler.driver == "cl" then + table.insert(icu_depends, CopyToDirectory(".", "other/icu/vc/lib64/icudt53.dll")) + table.insert(icu_depends, CopyToDirectory(".", "other/icu/vc/lib64/icuin53.dll")) + table.insert(icu_depends, CopyToDirectory(".", "other/icu/vc/lib64/icuuc53.dll")) + elseif config.compiler.driver == "gcc" then + table.insert(icu_depends, CopyToDirectory(".", "other/icu/gcc/lib64/icudt53.dll")) + table.insert(icu_depends, CopyToDirectory(".", "other/icu/gcc/lib64/icuin53.dll")) + table.insert(icu_depends, CopyToDirectory(".", "other/icu/gcc/lib64/icuuc53.dll")) + end + end + 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")} + server_link_other = {ResCompile("other/icons/teeworlds_srv_cl.rc")} + elseif config.compiler.driver == "gcc" then + client_link_other = {ResCompile("other/icons/teeworlds_gcc.rc")} + server_link_other = {ResCompile("other/icons/teeworlds_srv_gcc.rc")} + end end function Intermediate_Output(settings, input) - return "objs/" .. string.sub(PathBase(input), string.len("src/")+1) .. settings.config_ext + return "objs/" .. string.sub(PathBase(input), string.len("src/") + 1) .. settings.config_ext end function build(settings) - -- apply compiler settings - config.compiler:Apply(settings) - - --settings.objdir = Path("objs") - settings.cc.Output = Intermediate_Output - - 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) - end - ldflags = os.getenv("LDFLAGS") - if ldflags then - settings.link.flags:Add(ldflags) - end - - if config.websockets.value then - settings.cc.defines:Add("WEBSOCKETS") - end - - if config.compiler.driver == "cl" then - settings.cc.flags:Add("/wd4244") - settings.cc.flags:Add("/EHsc") - else - settings.cc.flags:Add("-Wall") - if family == "windows" then - if config.compiler.driver == "gcc" then - settings.link.flags:Add("-static-libgcc") - settings.link.flags:Add("-static-libstdc++") - end - -- disable visibility attribute support for gcc on windows - settings.cc.defines:Add("NO_VIZ") - elseif platform == "macosx" then - settings.cc.flags:Add("-mmacosx-version-min=10.7") - settings.link.flags:Add("-mmacosx-version-min=10.7") - settings.cc.flags:Add("-stdlib=libc++") - settings.link.flags:Add("-stdlib=libc++") - if config.minmacosxsdk.value == 1 then - settings.cc.flags:Add("-isysroot /Developer/SDKs/MacOSX10.7.sdk") - settings.link.flags:Add("-isysroot /Developer/SDKs/MacOSX10.7.sdk") - end - elseif config.stackprotector.value == 1 then - settings.cc.flags:Add("-fstack-protector", "-fstack-protector-all") - settings.link.flags:Add("-fstack-protector", "-fstack-protector-all") - end - end - - settings.cc.includes:Add("src") - settings.cc.includes:Add("src/engine/external") - - -- set some platform specific settings - if family == "unix" then - if platform == "macosx" then - settings.cc.flags_cxx:Add("-stdlib=libc++") - settings.cc.includes:Add("/usr/local/opt/icu4c/include") - settings.link.libs:Add("icui18n") - settings.link.libs:Add("icuuc") - settings.link.libs:Add("c++") - settings.link.libpath:Add("/usr/local/opt/icu4c/lib") - settings.link.frameworks:Add("Carbon") - settings.link.frameworks:Add("AppKit") - else - settings.link.libs:Add("pthread") - -- add ICU for linux - if ExecuteSilent("pkg-config icu-uc icu-i18n") == 0 then - end - - settings.cc.flags:Add("`pkg-config --cflags icu-uc icu-i18n`") - settings.link.flags:Add("`pkg-config --libs icu-uc icu-i18n`") - end - - if platform == "solaris" then - settings.link.flags:Add("-lsocket") - settings.link.flags:Add("-lnsl") - end - elseif family == "windows" then - settings.link.libs:Add("gdi32") - settings.link.libs:Add("user32") - settings.link.libs:Add("ws2_32") - settings.link.libs:Add("ole32") - settings.link.libs:Add("shell32") - settings.link.libs:Add("advapi32") - - -- add ICU also here - settings.cc.includes:Add("other\\icu\\include") - end - - -- compile zlib if needed - if config.zlib.value == 1 then - settings.link.libs:Add("z") - if config.zlib.include_path then - settings.cc.includes:Add(config.zlib.include_path) - end - zlib = {} - else - zlib = Compile(settings, Collect("src/engine/external/zlib/*.c")) - settings.cc.includes:Add("src/engine/external/zlib") - end - - -- build the small libraries - wavpack = Compile(settings, Collect("src/engine/external/wavpack/*.c")) - pnglite = Compile(settings, Collect("src/engine/external/pnglite/*.c")) - jsonparser = Compile(settings, Collect("src/engine/external/json-parser/*.c")) - md5 = Compile(settings, "src/engine/external/md5/md5.c") - if config.websockets.value then - libwebsockets = Compile(settings, Collect("src/engine/external/libwebsockets/*.c")) - end - - -- build game components - engine_settings = settings:Copy() - server_settings = engine_settings:Copy() - client_settings = engine_settings:Copy() - launcher_settings = engine_settings:Copy() - - if family == "unix" then - if platform == "macosx" then - client_settings.link.frameworks:Add("OpenGL") - client_settings.link.frameworks:Add("AGL") - client_settings.link.frameworks:Add("Carbon") - client_settings.link.frameworks:Add("Cocoa") - launcher_settings.link.frameworks:Add("Cocoa") - client_settings.cc.flags:Add("-I/opt/X11/include") - else - client_settings.link.libs:Add("X11") - client_settings.link.libs:Add("GL") - client_settings.link.libs:Add("GLU") - end - - elseif family == "windows" then - if arch == "amd64" then - client_settings.link.libpath:Add("other/curl/windows/lib64") - else - client_settings.link.libpath:Add("other/curl/windows/lib32") - end - client_settings.link.libs:Add("opengl32") - client_settings.link.libs:Add("glu32") - client_settings.link.libs:Add("winmm") - client_settings.link.libs:Add("libopusfile-0") - client_settings.link.libs:Add("curl") - if string.find(settings.config_name, "sql") then - server_settings.link.libpath:Add("other/mysql/vc2005libs") - server_settings.link.libs:Add("mysqlcppconn") - end - - -- Add ICU because its a HAVE to - if platform == "win32" then - if config.compiler.driver == "cl" then - server_settings.link.libpath:Add("other/icu/vc/lib32") - elseif config.compiler.driver == "gcc" then - server_settings.link.libpath:Add("other/icu/gcc/lib32") - end - server_settings.link.libs:Add("icudt") - server_settings.link.libs:Add("icuin") - server_settings.link.libs:Add("icuuc") - else - if config.compiler.driver == "cl" then - server_settings.link.libpath:Add("other/icu/vc/lib64") - elseif config.compiler.driver == "gcc" then - server_settings.link.libpath:Add("other/icu/gcc/lib64") - end - server_settings.link.libs:Add("icudt") - server_settings.link.libs:Add("icuin") - server_settings.link.libs:Add("icuuc") - end - end - - config.sdl:Apply(client_settings) - config.freetype:Apply(client_settings) - config.curl:Apply(client_settings) - config.opusfile:Apply(client_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")) - teeothers = Compile(server_settings, Collect("src/teeothers/*.cpp", "src/teeothers/components/*.cpp", "src/teeothers/system/*.cpp")) - - - versionserver = Compile(settings, Collect("src/versionsrv/*.cpp")) - masterserver = Compile(settings, Collect("src/mastersrv/*.cpp")) - twping = Compile(settings, Collect("src/twping/*.cpp")) - game_shared = Compile(settings, Collect("src/game/*.cpp"), nethash, network_source) - game_client = Compile(client_settings, CollectRecursive("src/game/client/*.cpp"), client_content_source) - game_server = Compile(settings, CollectRecursive("src/game/server/*.cpp"), server_content_source) - game_editor = Compile(settings, Collect("src/game/editor/*.cpp")) - - -- build tools (TODO: fix this so we don't get double _d_d stuff) - tools_src = Collect("src/tools/*.cpp", "src/tools/*.c") - - client_notification = {} - client_osxlaunch = {} - server_osxlaunch = {} - if platform == "macosx" then - notification_settings = client_settings:Copy() - notification_settings.cc.flags:Add("-x objective-c++") - 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") - end - - tools = {} - for i,v in ipairs(tools_src) do - toolname = PathFilename(PathBase(v)) - tools[i] = Link(settings, toolname, Compile(settings, v), engine, zlib, pnglite, md5) - end - - -- build client, server, version server and master server - client_exe = Link(client_settings, "xPanic-Editor", game_shared, game_client, - engine, client, game_editor, zlib, pnglite, wavpack, - client_link_other, client_osxlaunch, jsonparser, libwebsockets, md5, client_notification) - - server_exe = Link(server_settings, "xPanic-Server", engine, server, - game_shared, game_server, zlib, server_link_other, libwebsockets, md5, icu_depends, teeothers, jsonparser) - - serverlaunch = {} - if platform == "macosx" then - serverlaunch = Link(launcher_settings, "serverlaunch", server_osxlaunch) - end - - versionserver_exe = Link(server_settings, "versionsrv", versionserver, - engine, zlib, libwebsockets, md5) - - masterserver_exe = Link(server_settings, "mastersrv", masterserver, - engine, zlib, md5) - - twping_exe = Link(server_settings, "twping", twping, - engine, zlib, md5) - - -- make targets - c = PseudoTarget("client".."_"..settings.config_name, client_exe, client_depends) - if string.find(settings.config_name, "sql") then - s = PseudoTarget("server".."_"..settings.config_name, server_exe, serverlaunch, server_sql_depends) - else - s = PseudoTarget("server".."_"..settings.config_name, server_exe, serverlaunch) - end - g = PseudoTarget("game".."_"..settings.config_name, client_exe, server_exe) - - v = PseudoTarget("versionserver".."_"..settings.config_name, versionserver_exe) - m = PseudoTarget("masterserver".."_"..settings.config_name, masterserver_exe) - t = PseudoTarget("tools".."_"..settings.config_name, tools) - p = PseudoTarget("twping".."_"..settings.config_name, twping_exe) - - all = PseudoTarget(settings.config_name, c, s, v, m, t, p) - return all + -- apply compiler settings + config.compiler:Apply(settings) + + -- settings.objdir = Path("objs") + settings.cc.Output = Intermediate_Output + + 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) + end + ldflags = os.getenv("LDFLAGS") + if ldflags then + settings.link.flags:Add(ldflags) + end + + if config.websockets.value then + settings.cc.defines:Add("WEBSOCKETS") + end + + if config.compiler.driver == "cl" then + settings.cc.flags:Add("/wd4244") + settings.cc.flags:Add("/EHsc") + else + settings.cc.flags:Add("-Wall") + if family == "windows" then + if config.compiler.driver == "gcc" then + settings.link.flags:Add("-static-libgcc") + settings.link.flags:Add("-static-libstdc++") + end + -- disable visibility attribute support for gcc on windows + settings.cc.defines:Add("NO_VIZ") + elseif platform == "macosx" then + settings.cc.flags:Add("-mmacosx-version-min=10.7") + settings.link.flags:Add("-mmacosx-version-min=10.7") + settings.cc.flags:Add("-stdlib=libc++") + settings.link.flags:Add("-stdlib=libc++") + if config.minmacosxsdk.value == 1 then + settings.cc.flags:Add("-isysroot /Developer/SDKs/MacOSX10.7.sdk") + settings.link.flags:Add("-isysroot /Developer/SDKs/MacOSX10.7.sdk") + end + elseif config.stackprotector.value == 1 then + settings.cc.flags:Add("-fstack-protector", "-fstack-protector-all") + settings.link.flags:Add("-fstack-protector", "-fstack-protector-all") + end + end + + settings.cc.includes:Add("src") + settings.cc.includes:Add("src/engine/external") + + -- set some platform specific settings + if family == "unix" then + if platform == "macosx" then + settings.cc.flags_cxx:Add("-stdlib=libc++") + settings.cc.includes:Add("/usr/local/opt/icu4c/include") + settings.link.libs:Add("icui18n") + settings.link.libs:Add("icuuc") + settings.link.libs:Add("c++") + settings.link.libpath:Add("/usr/local/opt/icu4c/lib") + settings.link.frameworks:Add("Carbon") + settings.link.frameworks:Add("AppKit") + else + settings.link.libs:Add("pthread") + -- add ICU for linux + if ExecuteSilent("pkg-config icu-uc icu-i18n") == 0 then + end + + settings.cc.flags:Add("`pkg-config --cflags icu-uc icu-i18n`") + settings.link.flags:Add("`pkg-config --libs icu-uc icu-i18n`") + end + + if platform == "solaris" then + settings.link.flags:Add("-lsocket") + settings.link.flags:Add("-lnsl") + end + elseif family == "windows" then + settings.link.libs:Add("gdi32") + settings.link.libs:Add("user32") + settings.link.libs:Add("ws2_32") + settings.link.libs:Add("ole32") + settings.link.libs:Add("shell32") + settings.link.libs:Add("advapi32") + + -- add ICU also here + settings.cc.includes:Add("other\\icu\\include") + end + + -- compile zlib if needed + if config.zlib.value == 1 then + settings.link.libs:Add("z") + if config.zlib.include_path then + settings.cc.includes:Add(config.zlib.include_path) + end + zlib = {} + else + zlib = Compile(settings, Collect("src/engine/external/zlib/*.c")) + settings.cc.includes:Add("src/engine/external/zlib") + end + + -- build the small libraries + wavpack = Compile(settings, Collect("src/engine/external/wavpack/*.c")) + pnglite = Compile(settings, Collect("src/engine/external/pnglite/*.c")) + jsonparser = Compile(settings, Collect("src/engine/external/json-parser/*.c")) + md5 = Compile(settings, "src/engine/external/md5/md5.c") + if config.websockets.value then + libwebsockets = Compile(settings, Collect("src/engine/external/libwebsockets/*.c")) + end + + -- build game components + engine_settings = settings:Copy() + server_settings = engine_settings:Copy() + client_settings = engine_settings:Copy() + launcher_settings = engine_settings:Copy() + + if family == "unix" then + if platform == "macosx" then + client_settings.link.frameworks:Add("OpenGL") + client_settings.link.frameworks:Add("AGL") + client_settings.link.frameworks:Add("Carbon") + client_settings.link.frameworks:Add("Cocoa") + launcher_settings.link.frameworks:Add("Cocoa") + client_settings.cc.flags:Add("-I/opt/X11/include") + else + client_settings.link.libs:Add("X11") + client_settings.link.libs:Add("GL") + client_settings.link.libs:Add("GLU") + end + + elseif family == "windows" then + if arch == "amd64" then + client_settings.link.libpath:Add("other/curl/windows/lib64") + else + client_settings.link.libpath:Add("other/curl/windows/lib32") + end + client_settings.link.libs:Add("opengl32") + client_settings.link.libs:Add("glu32") + client_settings.link.libs:Add("winmm") + client_settings.link.libs:Add("libopusfile-0") + client_settings.link.libs:Add("curl") + if string.find(settings.config_name, "sql") then + server_settings.link.libpath:Add("other/mysql/vc2005libs") + server_settings.link.libs:Add("mysqlcppconn") + end + + -- Add ICU because its a HAVE to + if platform == "win32" then + if config.compiler.driver == "cl" then + server_settings.link.libpath:Add("other/icu/vc/lib32") + elseif config.compiler.driver == "gcc" then + server_settings.link.libpath:Add("other/icu/gcc/lib32") + end + server_settings.link.libs:Add("icudt") + server_settings.link.libs:Add("icuin") + server_settings.link.libs:Add("icuuc") + else + if config.compiler.driver == "cl" then + server_settings.link.libpath:Add("other/icu/vc/lib64") + elseif config.compiler.driver == "gcc" then + server_settings.link.libpath:Add("other/icu/gcc/lib64") + end + server_settings.link.libs:Add("icudt") + server_settings.link.libs:Add("icuin") + server_settings.link.libs:Add("icuuc") + end + end + + config.sdl:Apply(client_settings) + config.freetype:Apply(client_settings) + config.curl:Apply(client_settings) + config.opusfile:Apply(client_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")) + teeothers = Compile(server_settings, + Collect("src/teeothers/*.cpp", "src/teeothers/components/*.cpp", "src/teeothers/system/*.cpp")) + + versionserver = Compile(settings, Collect("src/versionsrv/*.cpp")) + masterserver = Compile(settings, Collect("src/mastersrv/*.cpp")) + twping = Compile(settings, Collect("src/twping/*.cpp")) + game_shared = Compile(settings, Collect("src/game/*.cpp"), nethash, network_source) + game_client = Compile(client_settings, CollectRecursive("src/game/client/*.cpp"), client_content_source) + game_server = Compile(settings, CollectRecursive("src/game/server/*.cpp"), server_content_source) + game_editor = Compile(settings, Collect("src/game/editor/*.cpp")) + + -- build tools (TODO: fix this so we don't get double _d_d stuff) + tools_src = Collect("src/tools/*.cpp", "src/tools/*.c") + + client_notification = {} + client_osxlaunch = {} + server_osxlaunch = {} + if platform == "macosx" then + notification_settings = client_settings:Copy() + notification_settings.cc.flags:Add("-x objective-c++") + 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") + end + + tools = {} + for i, v in ipairs(tools_src) do + toolname = PathFilename(PathBase(v)) + tools[i] = Link(settings, toolname, Compile(settings, v), engine, zlib, pnglite, md5) + end + + -- build client, server, version server and master server + client_exe = Link(client_settings, "xPanic-Editor", game_shared, game_client, engine, client, game_editor, zlib, + pnglite, wavpack, client_link_other, client_osxlaunch, jsonparser, libwebsockets, md5, client_notification) + + server_exe = Link(server_settings, "xPanic-Server", engine, server, game_shared, game_server, zlib, + server_link_other, libwebsockets, md5, icu_depends, teeothers, jsonparser) + + serverlaunch = {} + if platform == "macosx" then + serverlaunch = Link(launcher_settings, "serverlaunch", server_osxlaunch) + end + + versionserver_exe = Link(server_settings, "versionsrv", versionserver, engine, zlib, libwebsockets, md5) + + masterserver_exe = Link(server_settings, "mastersrv", masterserver, engine, zlib, md5) + + twping_exe = Link(server_settings, "twping", twping, engine, zlib, md5) + + -- make targets + c = PseudoTarget("client" .. "_" .. settings.config_name, client_exe, client_depends) + if string.find(settings.config_name, "sql") then + s = PseudoTarget("server" .. "_" .. settings.config_name, server_exe, serverlaunch, server_sql_depends) + else + s = PseudoTarget("server" .. "_" .. settings.config_name, server_exe, serverlaunch) + end + g = PseudoTarget("game" .. "_" .. settings.config_name, client_exe, server_exe) + + v = PseudoTarget("versionserver" .. "_" .. settings.config_name, versionserver_exe) + m = PseudoTarget("masterserver" .. "_" .. settings.config_name, masterserver_exe) + t = PseudoTarget("tools" .. "_" .. settings.config_name, tools) + p = PseudoTarget("twping" .. "_" .. settings.config_name, twping_exe) + + all = PseudoTarget(settings.config_name, c, s, v, m, t, p) + return all end - debug_settings = NewSettings() debug_settings.config_name = "debug" debug_settings.config_ext = "_d" @@ -511,175 +499,176 @@ config.mysql:Apply(debug_sql_settings) config.mysql:Apply(release_sql_settings) if platform == "macosx" then - debug_settings_ppc = debug_settings:Copy() - debug_settings_ppc.config_name = "debug_ppc" - debug_settings_ppc.config_ext = "_ppc_d" - debug_settings_ppc.cc.flags:Add("-arch ppc") - debug_settings_ppc.link.flags:Add("-arch ppc") - debug_settings_ppc.cc.defines:Add("CONF_DEBUG") - - debug_sql_settings_ppc = debug_sql_settings:Copy() - debug_sql_settings_ppc.config_name = "sql_debug_ppc" - debug_sql_settings_ppc.config_ext = "_sql_ppc_d" - 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" - release_sql_settings_ppc.cc.flags:Add("-arch ppc") - release_sql_settings_ppc.link.flags:Add("-arch ppc") - release_sql_settings_ppc.cc.defines:Add("CONF_RELEASE", "CONF_SQL") - - ppc_d = build(debug_settings_ppc) - ppc_r = build(release_settings_ppc) - sql_ppc_d = build(debug_sql_settings_ppc) - sql_ppc_r = build(release_sql_settings_ppc) - - if arch == "ia32" or arch == "amd64" then - debug_settings_x86 = debug_settings:Copy() - debug_settings_x86.config_name = "debug_x86" - debug_settings_x86.config_ext = "_x86_d" - debug_settings_x86.cc.flags:Add("-arch i386") - debug_settings_x86.link.flags:Add("-arch i386") - debug_settings_x86.cc.defines:Add("CONF_DEBUG") - - debug_sql_settings_x86 = debug_sql_settings:Copy() - debug_sql_settings_x86.config_name = "sql_debug_x86" - debug_sql_settings_x86.config_ext = "_sql_x86_d" - debug_sql_settings_x86.cc.flags:Add("-arch i386") - debug_sql_settings_x86.link.flags:Add("-arch i386") - debug_sql_settings_x86.cc.defines:Add("CONF_DEBUG", "CONF_SQL") - - release_settings_x86 = release_settings:Copy() - release_settings_x86.config_name = "release_x86" - release_settings_x86.config_ext = "_x86" - 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" - release_sql_settings_x86.cc.flags:Add("-arch i386") - release_sql_settings_x86.link.flags:Add("-arch i386") - release_sql_settings_x86.cc.defines:Add("CONF_RELEASE", "CONF_SQL") - - x86_d = build(debug_settings_x86) - sql_x86_d = build(debug_sql_settings_x86) - x86_r = build(release_settings_x86) - sql_x86_r = build(release_sql_settings_x86) - end - - if arch == "amd64" then - debug_settings_x86_64 = debug_settings:Copy() - debug_settings_x86_64.config_name = "debug_x86_64" - debug_settings_x86_64.config_ext = "_x86_64_d" - debug_settings_x86_64.cc.flags:Add("-arch x86_64") - debug_settings_x86_64.link.flags:Add("-arch x86_64") - debug_settings_x86_64.cc.defines:Add("CONF_DEBUG") - - debug_sql_settings_x86_64 = debug_sql_settings:Copy() - debug_sql_settings_x86_64.config_name = "sql_debug_x86_64" - debug_sql_settings_x86_64.config_ext = "_sql_x86_64_d" - debug_sql_settings_x86_64.cc.flags:Add("-arch x86_64") - debug_sql_settings_x86_64.link.flags:Add("-arch x86_64") - debug_sql_settings_x86_64.cc.defines:Add("CONF_DEBUG", "CONF_SQL") - - release_settings_x86_64 = release_settings:Copy() - release_settings_x86_64.config_name = "release_x86_64" - release_settings_x86_64.config_ext = "_x86_64" - 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" - release_sql_settings_x86_64.cc.flags:Add("-arch x86_64") - release_sql_settings_x86_64.link.flags:Add("-arch x86_64") - release_sql_settings_x86_64.cc.defines:Add("CONF_RELEASE", "CONF_SQL") - - x86_64_d = build(debug_settings_x86_64) - sql_x86_64_d = build(debug_sql_settings_x86_64) - x86_64_r = build(release_settings_x86_64) - sql_x86_64_r = build(release_sql_settings_x86_64) - end - - DefaultTarget("game_debug_x86") - - if config.macosxppc.value == 1 then - if arch == "ia32" then - PseudoTarget("release", ppc_r, x86_r) - PseudoTarget("debug", ppc_d, x86_d) - PseudoTarget("server_release", "server_release_ppc", "server_release_x86") - PseudoTarget("server_debug", "server_debug_ppc", "server_debug_x86") - PseudoTarget("client_release", "client_release_ppc", "client_release_x86") - PseudoTarget("client_debug", "client_debug_ppc", "client_debug_x86") - PseudoTarget("sql_release", sql_ppc_r, sql_x86_r) - PseudoTarget("sql_debug", sql_ppc_d, sql_x86_d) - PseudoTarget("server_sql_release", "server_sql_release_ppc", "server_sql_release_x86") - PseudoTarget("server_sql_debug", "server_sql_debug_ppc", "server_sql_debug_x86") - elseif arch == "amd64" then - PseudoTarget("release", ppc_r, x86_r, x86_64_r) - PseudoTarget("debug", ppc_d, x86_d, x86_64_d) - PseudoTarget("server_release", "server_release_ppc", "server_release_x86", "server_release_x86_64") - PseudoTarget("server_debug", "server_debug_ppc", "server_debug_x86", "server_debug_x86_64") - PseudoTarget("client_release", "client_release_ppc", "client_release_x86", "client_release_x86_64") - PseudoTarget("client_debug", "client_debug_ppc", "client_debug_x86", "client_debug_x86_64") - PseudoTarget("sql_release", sql_ppc_r, sql_x86_r, sql_x86_64_r) - PseudoTarget("sql_debug", sql_ppc_d, sql_x86_d, sql_x86_64_d) - PseudoTarget("server_sql_release", "server_sql_release_ppc", "server_sql_release_x86", "server_sql_release_x86_64") - PseudoTarget("server_sql_debug", "server_sql_debug_ppc", "server_sql_debug_x86", "server_sql_debug_x86_64") - else - PseudoTarget("release", ppc_r) - PseudoTarget("debug", ppc_d) - PseudoTarget("server_release", "server_release_ppc") - PseudoTarget("server_debug", "server_debug_ppc") - PseudoTarget("client_release", "client_release_ppc") - PseudoTarget("client_debug", "client_debug_ppc") - PseudoTarget("sql_release", sql_ppc_r) - PseudoTarget("sql_debug", sql_ppc_d) - PseudoTarget("server_sql_release", "server_sql_release_ppc") - PseudoTarget("server_sql_debug", "server_sql_debug_ppc") - end - else - if arch == "ia32" then - PseudoTarget("release", x86_r) - PseudoTarget("debug", x86_d) - PseudoTarget("server_release", "server_release_x86") - PseudoTarget("server_debug", "server_debug_x86") - PseudoTarget("client_release", "client_release_x86") - PseudoTarget("client_debug", "client_debug_x86") - PseudoTarget("sql_release", sql_x86_r) - PseudoTarget("sql_debug", sql_x86_d) - PseudoTarget("server_sql_release", "server_sql_release_x86") - PseudoTarget("server_sql_debug", "server_sql_debug_x86") - elseif arch == "amd64" then - PseudoTarget("release", x86_r, x86_64_r) - PseudoTarget("debug", x86_d, x86_64_d) - PseudoTarget("server_release", "server_release_x86", "server_release_x86_64") - PseudoTarget("server_debug", "server_debug_x86", "server_debug_x86_64") - PseudoTarget("client_release", "client_release_x86", "client_release_x86_64") - PseudoTarget("client_debug", "client_debug_x86", "client_debug_x86_64") - PseudoTarget("sql_release", sql_x86_r, sql_x86_64_r) - PseudoTarget("sql_debug", sql_x86_d, sql_x86_64_d) - PseudoTarget("server_sql_release", "server_sql_release_x86", "server_sql_release_x86_64") - PseudoTarget("server_sql_debug", "server_sql_debug_x86", "server_sql_debug_x86_64") - end - end + debug_settings_ppc = debug_settings:Copy() + debug_settings_ppc.config_name = "debug_ppc" + debug_settings_ppc.config_ext = "_ppc_d" + debug_settings_ppc.cc.flags:Add("-arch ppc") + debug_settings_ppc.link.flags:Add("-arch ppc") + debug_settings_ppc.cc.defines:Add("CONF_DEBUG") + + debug_sql_settings_ppc = debug_sql_settings:Copy() + debug_sql_settings_ppc.config_name = "sql_debug_ppc" + debug_sql_settings_ppc.config_ext = "_sql_ppc_d" + 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" + release_sql_settings_ppc.cc.flags:Add("-arch ppc") + release_sql_settings_ppc.link.flags:Add("-arch ppc") + release_sql_settings_ppc.cc.defines:Add("CONF_RELEASE", "CONF_SQL") + + ppc_d = build(debug_settings_ppc) + ppc_r = build(release_settings_ppc) + sql_ppc_d = build(debug_sql_settings_ppc) + sql_ppc_r = build(release_sql_settings_ppc) + + if arch == "ia32" or arch == "amd64" then + debug_settings_x86 = debug_settings:Copy() + debug_settings_x86.config_name = "debug_x86" + debug_settings_x86.config_ext = "_x86_d" + debug_settings_x86.cc.flags:Add("-arch i386") + debug_settings_x86.link.flags:Add("-arch i386") + debug_settings_x86.cc.defines:Add("CONF_DEBUG") + + debug_sql_settings_x86 = debug_sql_settings:Copy() + debug_sql_settings_x86.config_name = "sql_debug_x86" + debug_sql_settings_x86.config_ext = "_sql_x86_d" + debug_sql_settings_x86.cc.flags:Add("-arch i386") + debug_sql_settings_x86.link.flags:Add("-arch i386") + debug_sql_settings_x86.cc.defines:Add("CONF_DEBUG", "CONF_SQL") + + release_settings_x86 = release_settings:Copy() + release_settings_x86.config_name = "release_x86" + release_settings_x86.config_ext = "_x86" + 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" + release_sql_settings_x86.cc.flags:Add("-arch i386") + release_sql_settings_x86.link.flags:Add("-arch i386") + release_sql_settings_x86.cc.defines:Add("CONF_RELEASE", "CONF_SQL") + + x86_d = build(debug_settings_x86) + sql_x86_d = build(debug_sql_settings_x86) + x86_r = build(release_settings_x86) + sql_x86_r = build(release_sql_settings_x86) + end + + if arch == "amd64" then + debug_settings_x86_64 = debug_settings:Copy() + debug_settings_x86_64.config_name = "debug_x86_64" + debug_settings_x86_64.config_ext = "_x86_64_d" + debug_settings_x86_64.cc.flags:Add("-arch x86_64") + debug_settings_x86_64.link.flags:Add("-arch x86_64") + debug_settings_x86_64.cc.defines:Add("CONF_DEBUG") + + debug_sql_settings_x86_64 = debug_sql_settings:Copy() + debug_sql_settings_x86_64.config_name = "sql_debug_x86_64" + debug_sql_settings_x86_64.config_ext = "_sql_x86_64_d" + debug_sql_settings_x86_64.cc.flags:Add("-arch x86_64") + debug_sql_settings_x86_64.link.flags:Add("-arch x86_64") + debug_sql_settings_x86_64.cc.defines:Add("CONF_DEBUG", "CONF_SQL") + + release_settings_x86_64 = release_settings:Copy() + release_settings_x86_64.config_name = "release_x86_64" + release_settings_x86_64.config_ext = "_x86_64" + 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" + release_sql_settings_x86_64.cc.flags:Add("-arch x86_64") + release_sql_settings_x86_64.link.flags:Add("-arch x86_64") + release_sql_settings_x86_64.cc.defines:Add("CONF_RELEASE", "CONF_SQL") + + x86_64_d = build(debug_settings_x86_64) + sql_x86_64_d = build(debug_sql_settings_x86_64) + x86_64_r = build(release_settings_x86_64) + sql_x86_64_r = build(release_sql_settings_x86_64) + end + + DefaultTarget("game_debug_x86") + + if config.macosxppc.value == 1 then + if arch == "ia32" then + PseudoTarget("release", ppc_r, x86_r) + PseudoTarget("debug", ppc_d, x86_d) + PseudoTarget("server_release", "server_release_ppc", "server_release_x86") + PseudoTarget("server_debug", "server_debug_ppc", "server_debug_x86") + PseudoTarget("client_release", "client_release_ppc", "client_release_x86") + PseudoTarget("client_debug", "client_debug_ppc", "client_debug_x86") + PseudoTarget("sql_release", sql_ppc_r, sql_x86_r) + PseudoTarget("sql_debug", sql_ppc_d, sql_x86_d) + PseudoTarget("server_sql_release", "server_sql_release_ppc", "server_sql_release_x86") + PseudoTarget("server_sql_debug", "server_sql_debug_ppc", "server_sql_debug_x86") + elseif arch == "amd64" then + PseudoTarget("release", ppc_r, x86_r, x86_64_r) + PseudoTarget("debug", ppc_d, x86_d, x86_64_d) + PseudoTarget("server_release", "server_release_ppc", "server_release_x86", "server_release_x86_64") + PseudoTarget("server_debug", "server_debug_ppc", "server_debug_x86", "server_debug_x86_64") + PseudoTarget("client_release", "client_release_ppc", "client_release_x86", "client_release_x86_64") + PseudoTarget("client_debug", "client_debug_ppc", "client_debug_x86", "client_debug_x86_64") + PseudoTarget("sql_release", sql_ppc_r, sql_x86_r, sql_x86_64_r) + PseudoTarget("sql_debug", sql_ppc_d, sql_x86_d, sql_x86_64_d) + PseudoTarget("server_sql_release", "server_sql_release_ppc", "server_sql_release_x86", + "server_sql_release_x86_64") + PseudoTarget("server_sql_debug", "server_sql_debug_ppc", "server_sql_debug_x86", "server_sql_debug_x86_64") + else + PseudoTarget("release", ppc_r) + PseudoTarget("debug", ppc_d) + PseudoTarget("server_release", "server_release_ppc") + PseudoTarget("server_debug", "server_debug_ppc") + PseudoTarget("client_release", "client_release_ppc") + PseudoTarget("client_debug", "client_debug_ppc") + PseudoTarget("sql_release", sql_ppc_r) + PseudoTarget("sql_debug", sql_ppc_d) + PseudoTarget("server_sql_release", "server_sql_release_ppc") + PseudoTarget("server_sql_debug", "server_sql_debug_ppc") + end + else + if arch == "ia32" then + PseudoTarget("release", x86_r) + PseudoTarget("debug", x86_d) + PseudoTarget("server_release", "server_release_x86") + PseudoTarget("server_debug", "server_debug_x86") + PseudoTarget("client_release", "client_release_x86") + PseudoTarget("client_debug", "client_debug_x86") + PseudoTarget("sql_release", sql_x86_r) + PseudoTarget("sql_debug", sql_x86_d) + PseudoTarget("server_sql_release", "server_sql_release_x86") + PseudoTarget("server_sql_debug", "server_sql_debug_x86") + elseif arch == "amd64" then + PseudoTarget("release", x86_r, x86_64_r) + PseudoTarget("debug", x86_d, x86_64_d) + PseudoTarget("server_release", "server_release_x86", "server_release_x86_64") + PseudoTarget("server_debug", "server_debug_x86", "server_debug_x86_64") + PseudoTarget("client_release", "client_release_x86", "client_release_x86_64") + PseudoTarget("client_debug", "client_debug_x86", "client_debug_x86_64") + PseudoTarget("sql_release", sql_x86_r, sql_x86_64_r) + PseudoTarget("sql_debug", sql_x86_d, sql_x86_64_d) + PseudoTarget("server_sql_release", "server_sql_release_x86", "server_sql_release_x86_64") + PseudoTarget("server_sql_debug", "server_sql_debug_x86", "server_sql_debug_x86_64") + end + end else - build(debug_settings) - build(debug_sql_settings) - build(release_settings) - build(release_sql_settings) - DefaultTarget("game_debug") + build(debug_settings) + build(debug_sql_settings) + build(release_settings) + build(release_sql_settings) + DefaultTarget("game_debug") end diff --git a/configure.lua b/configure.lua index f06b77d..dca2d4f 100644 --- a/configure.lua +++ b/configure.lua @@ -1,504 +1,566 @@ - ---[[@GROUP Configuration@END]]-- - +--[[@GROUP Configuration@END]] -- --[[@FUNCTION TODO -@END]]-- -function NewConfig(on_configured_callback) - local config = {} - - config.OnConfigured = function(self) - return true - end - - if on_configured_callback then config.OnConfigured = on_configured_callback end - - config.options = {} - config.settings = NewSettings() - - config.NewSettings = function(self) - local s = NewSettings() - for _,v in pairs(self.options) do - v:Apply(s) - end - return s - end - - config.Add = function(self, o) - table.insert(self.options, o) - self[o.name] = o - end - - config.Print = function(self) - for k,v in pairs(self.options) do - print(v:FormatDisplay()) - end - end - - config.Save = function(self, filename) - print("saved configuration to '"..filename.."'") - local file = io.open(filename, "w") - - -- Define a little helper function to save options - local saver = {} - saver.file = file - - saver.line = function(self, str) - self.file:write(str .. "\n") - end - - saver.option = function(self, option, name) - local valuestr = "no" - if type(option[name]) == type(0) then - valuestr = option[name] - elseif type(option[name]) == type(true) then - valuestr = "false" - if option[name] then - valuestr = "true" - end - elseif type(option[name]) == type("") then - valuestr = "'"..option[name].."'" - else - error("option "..name.." have a value of type ".. type(option[name]).." that can't be saved") - end - self.file:write(option.name.."."..name.." = ".. valuestr.."\n") - end - - -- Save all the options - for k,v in pairs(self.options) do - v:Save(saver) - end - file:close() - end - - config.Load = function(self, filename) - local options_func = loadfile(filename) - local options_table = {} - - if not options_func then - print("auto configuration") - self:Config(filename) - options_func = loadfile(filename) - end - - if options_func then - -- Setup the options tables - for k,v in pairs(self.options) do - options_table[v.name] = {} - end - setfenv(options_func, options_table) - - -- this is to make sure that we get nice error messages when - -- someone sets an option that isn't valid. - local mt = {} - mt.__index = function(t, key) - local v = rawget(t, key) - if v ~= nil then return v end - error("there is no configuration option named '" .. key .. "'") - end - - setmetatable(options_table, mt) - - -- Process the options - options_func() - - -- Copy the options - for k,v in pairs(self.options) do - if options_table[v.name] then - for k2,v2 in pairs(options_table[v.name]) do - v[k2] = v2 - end - v.auto_detected = false - end - end - else - print("error: no '"..filename.."' found") - print("") - print("run 'bam config' to generate") - print("run 'bam config help' for configuration options") - print("") - os.exit(1) - end - end - - config.Config = function(self, filename) - print("") - print("configuration:") - if _bam_targets[1] == "print" then - self:Load(filename) - self:Print() - print("") - print("notes:") - self:OnConfigured() - print("") - else - self:Autodetect() - print("") - print("notes:") - if self:OnConfigured() then - self:Save(filename) - end - print("") - end - - end - - config.Autodetect = function(self) - for k,v in pairs(self.options) do - v:Check(self.settings) - print(v:FormatDisplay()) - self[v.name] = v - end - end - - config.PrintHelp = function(self) - print("options:") - for k,v in pairs(self.options) do - if v.PrintHelp then - v:PrintHelp() - end - end - end - - config.Finalize = function(self, filename) - if _bam_targets[0] == "config" then - if _bam_targets[1] == "help" then - self:PrintHelp() - os.exit(0) - end - - self:Config(filename) - - os.exit(0) - end - - self:Load(filename) - bam_update_globalstamp(filename) - end - - return config +@END]] -- +function loadfile_(filename, env) + local file + if _VERSION == "Lua 5.1" then + file = loadfile(filename) + if file then + setfenv(file, env) + end + else + file = loadfile(filename, nil, env) + end + return file end +function NewConfig(on_configured_callback) + local config = {} + + config.OnConfigured = function(self) + return true + end + + if on_configured_callback then + config.OnConfigured = on_configured_callback + end + + config.options = {} + config.settings = NewSettings() + + config.NewSettings = function(self) + local s = NewSettings() + for _, v in pairs(self.options) do + v:Apply(s) + end + return s + end + + config.Add = function(self, o) + table.insert(self.options, o) + self[o.name] = o + end + + config.Print = function(self) + for k, v in pairs(self.options) do + print(v:FormatDisplay()) + end + end + + config.Save = function(self, filename) + print("saved configuration to '" .. filename .. "'") + local file = io.open(filename, "w") + + -- Define a little helper function to save options + local saver = {} + saver.file = file + + saver.line = function(self, str) + self.file:write(str .. "\n") + end + + saver.option = function(self, option, name) + local valuestr = "no" + if type(option[name]) == type(0) then + valuestr = option[name] + elseif type(option[name]) == type(true) then + valuestr = "false" + if option[name] then + valuestr = "true" + end + elseif type(option[name]) == type("") then + valuestr = "'" .. option[name] .. "'" + else + error("option " .. name .. " have a value of type " .. type(option[name]) .. " that can't be saved") + end + self.file:write(option.name .. "." .. name .. " = " .. valuestr .. "\n") + end + + -- Save all the options + for k, v in pairs(self.options) do + v:Save(saver) + end + file:close() + end + + config.Load = function(self, filename) + local options_table = {} + local options_func = loadfile_(filename, options_table) + + if not options_func then + print("auto configuration") + self:Config(filename) + options_func = loadfile_(filename, options_table) + end + + if options_func then + -- Setup the options tables + for k, v in pairs(self.options) do + options_table[v.name] = {} + end + + -- this is to make sure that we get nice error messages when + -- someone sets an option that isn't valid. + local mt = {} + mt.__index = function(t, key) + local v = rawget(t, key) + if v ~= nil then + return v + end + error("there is no configuration option named '" .. key .. "'") + end + + setmetatable(options_table, mt) + + -- Process the options + options_func() + + -- Copy the options + for k, v in pairs(self.options) do + if options_table[v.name] then + for k2, v2 in pairs(options_table[v.name]) do + v[k2] = v2 + end + v.auto_detected = false + end + end + else + print("error: no '" .. filename .. "' found") + print("") + print("run 'bam config' to generate") + print("run 'bam config help' for configuration options") + print("") + os.exit(1) + end + end + + config.Config = function(self, filename) + print("") + print("configuration:") + if _bam_targets[1] == "print" then + self:Load(filename) + self:Print() + print("") + print("notes:") + self:OnConfigured() + print("") + else + self:Autodetect() + print("") + print("notes:") + if self:OnConfigured() then + self:Save(filename) + end + print("") + end + + end + + config.Autodetect = function(self) + for k, v in pairs(self.options) do + v:Check(self.settings) + print(v:FormatDisplay()) + self[v.name] = v + end + end + + config.PrintHelp = function(self) + print("options:") + for k, v in pairs(self.options) do + if v.PrintHelp then + v:PrintHelp() + end + end + end + + config.Finalize = function(self, filename) + if _bam_targets[0] == "config" then + if _bam_targets[1] == "help" then + self:PrintHelp() + os.exit(0) + end + + self:Config(filename) + + os.exit(0) + end + + self:Load(filename) + bam_update_globalstamp(filename) + end + + return config +end -- Helper functions -------------------------------------- function DefaultOptionDisplay(option) - if not option.value then return "no" end - if option.value == 1 or option.value == true then return "yes" end - return option.value + if not option.value then + return "no" + end + if option.value == 1 or option.value == true then + return "yes" + end + return option.value end function IsNegativeTerm(s) - if s == "no" then return true end - if s == "false" then return true end - if s == "off" then return true end - if s == "disable" then return true end - if s == "0" then return true end - return false + if s == "no" then + return true + end + if s == "false" then + return true + end + if s == "off" then + return true + end + if s == "disable" then + return true + end + if s == "0" then + return true + end + return false end function IsPositiveTerm(s) - if s == "yes" then return true end - if s == "true" then return true end - if s == "on" then return true end - if s == "enable" then return true end - if s == "1" then return true end - return false + if s == "yes" then + return true + end + if s == "true" then + return true + end + if s == "on" then + return true + end + if s == "enable" then + return true + end + if s == "1" then + return true + end + return false end function MakeOption(name, value, check, save, display, printhelp) - local o = {} - o.name = name - o.value = value - o.Check = check - o.Save = save - o.auto_detected = true - o.FormatDisplay = function(self) - local a = "SET" - if self.auto_detected then a = "AUTO" end - return string.format("%-5s %-20s %s", a, self.name, self:Display()) - end - - o.Display = display - o.PrintHelp = printhelp - if o.Display == nil then o.Display = DefaultOptionDisplay end - return o + local o = {} + o.name = name + o.value = value + o.Check = check + o.Save = save + o.auto_detected = true + o.FormatDisplay = function(self) + local a = "SET" + if self.auto_detected then + a = "AUTO" + end + return string.format("%-5s %-20s %s", a, self.name, self:Display()) + end + + o.Display = display + o.PrintHelp = printhelp + if o.Display == nil then + o.Display = DefaultOptionDisplay + end + return o end - -- Test Compile C -------------------------------------- function OptTestCompileC(name, source, compileoptions, desc) - local check = function(option, settings) - option.value = false - if ScriptArgs[option.name] then - if IsNegativeTerm(ScriptArgs[option.name]) then - option.value = false - elseif IsPositiveTerm(ScriptArgs[option.name]) then - option.value = true - else - error(ScriptArgs[option.name].." is not a valid value for option "..option.name) - end - option.auto_detected = false - else - if CTestCompile(settings, option.source, option.compileoptions) then - option.value = true - end - end - end - - local save = function(option, output) - output:option(option, "value") - end - - local printhelp = function(option) - print("\t"..option.name.."=on|off") - if option.desc then print("\t\t"..option.desc) end - end - - local o = MakeOption(name, false, check, save, nil, printhelp) - o.desc = desc - o.source = source - o.compileoptions = compileoptions - return o + local check = function(option, settings) + option.value = false + if ScriptArgs[option.name] then + if IsNegativeTerm(ScriptArgs[option.name]) then + option.value = false + elseif IsPositiveTerm(ScriptArgs[option.name]) then + option.value = true + else + error(ScriptArgs[option.name] .. " is not a valid value for option " .. option.name) + end + option.auto_detected = false + else + if CTestCompile(settings, option.source, option.compileoptions) then + option.value = true + end + end + end + + local save = function(option, output) + output:option(option, "value") + end + + local printhelp = function(option) + print("\t" .. option.name .. "=on|off") + if option.desc then + print("\t\t" .. option.desc) + end + end + + local o = MakeOption(name, false, check, save, nil, printhelp) + o.desc = desc + o.source = source + o.compileoptions = compileoptions + return o end - -- OptToggle -------------------------------------- function OptToggle(name, default_value, desc) - local check = function(option, settings) - if ScriptArgs[option.name] then - if IsNegativeTerm(ScriptArgs[option.name]) then - option.value = false - elseif IsPositiveTerm(ScriptArgs[option.name]) then - option.value = true - else - error(ScriptArgs[option.name].." is not a valid value for option "..option.name) - end - end - end - - local save = function(option, output) - output:option(option, "value") - end - - local printhelp = function(option) - print("\t"..option.name.."=on|off") - if option.desc then print("\t\t"..option.desc) end - end - - local o = MakeOption(name, default_value, check, save, nil, printhelp) - o.desc = desc - return o + local check = function(option, settings) + if ScriptArgs[option.name] then + if IsNegativeTerm(ScriptArgs[option.name]) then + option.value = false + elseif IsPositiveTerm(ScriptArgs[option.name]) then + option.value = true + else + error(ScriptArgs[option.name] .. " is not a valid value for option " .. option.name) + end + end + end + + local save = function(option, output) + output:option(option, "value") + end + + local printhelp = function(option) + print("\t" .. option.name .. "=on|off") + if option.desc then + print("\t\t" .. option.desc) + end + end + + local o = MakeOption(name, default_value, check, save, nil, printhelp) + o.desc = desc + return o end -- OptInteger -------------------------------------- function OptInteger(name, default_value, desc) - local check = function(option, settings) - if ScriptArgs[option.name] then - option.value = tonumber(ScriptArgs[option.name]) - end - end - - local save = function(option, output) - output:option(option, "value") - end - - local printhelp = function(option) - print("\t"..option.name.."=N") - if option.desc then print("\t\t"..option.desc) end - end - - local o = MakeOption(name, default_value, check, save, nil, printhelp) - o.desc = desc - return o + local check = function(option, settings) + if ScriptArgs[option.name] then + option.value = tonumber(ScriptArgs[option.name]) + end + end + + local save = function(option, output) + output:option(option, "value") + end + + local printhelp = function(option) + print("\t" .. option.name .. "=N") + if option.desc then + print("\t\t" .. option.desc) + end + end + + local o = MakeOption(name, default_value, check, save, nil, printhelp) + o.desc = desc + return o end - -- OptString -------------------------------------- function OptString(name, default_value, desc) - local check = function(option, settings) - if ScriptArgs[option.name] then - option.value = ScriptArgs[option.name] - end - end - - local save = function(option, output) - output:option(option, "value") - end - - local printhelp = function(option) - print("\t"..option.name.."=STRING") - if option.desc then print("\t\t"..option.desc) end - end - - local o = MakeOption(name, default_value, check, save, nil, printhelp) - o.desc = desc - return o + local check = function(option, settings) + if ScriptArgs[option.name] then + option.value = ScriptArgs[option.name] + end + end + + local save = function(option, output) + output:option(option, "value") + end + + local printhelp = function(option) + print("\t" .. option.name .. "=STRING") + if option.desc then + print("\t\t" .. option.desc) + end + end + + local o = MakeOption(name, default_value, check, save, nil, printhelp) + o.desc = desc + return o end -- Find Compiler -------------------------------------- --[[@FUNCTION TODO -@END]]-- +@END]] -- function OptCCompiler(name, default_driver, default_c, default_cxx, desc) - local check = function(option, settings) - if ScriptArgs[option.name] then - -- set compile driver - option.driver = ScriptArgs[option.name] - - -- set c compiler - if ScriptArgs[option.name..".c"] then - option.c_compiler = ScriptArgs[option.name..".c"] - end - - -- set c+= compiler - if ScriptArgs[option.name..".cxx"] then - option.cxx_compiler = ScriptArgs[option.name..".cxx"] - end - - option.auto_detected = false - elseif option.driver then - -- no need todo anything if we have a driver - -- TODO: test if we can find the compiler - else - if ExecuteSilent("cl") == 0 then - option.driver = "cl" - elseif ExecuteSilent("g++ -v") == 0 then - option.driver = "gcc" - elseif ExecuteSilent("clang++ -v") == 0 then - option.driver = "clang" - else - error("no c/c++ compiler found") - end - end - --setup_compiler(option.value) - end - - local apply = function(option, settings) - if option.driver == "cl" then - SetDriversCL(settings) - elseif option.driver == "gcc" then - SetDriversGCC(settings) - elseif option.driver == "clang" then - SetDriversClang(settings) - else - error(option.driver.." is not a known c/c++ compile driver") - 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) - output:option(option, "driver") - output:option(option, "c_compiler") - output:option(option, "cxx_compiler") - end - - local printhelp = function(option) - local a = "" - if option.desc then a = "for "..option.desc end - print("\t"..option.name.."=gcc|cl|clang") - print("\t\twhat c/c++ compile driver to use"..a) - print("\t"..option.name..".c=FILENAME") - print("\t\twhat c compiler executable to use"..a) - print("\t"..option.name..".cxx=FILENAME") - print("\t\twhat c++ compiler executable to use"..a) - end - - local display = function(option) - local s = option.driver - if option.c_compiler then s = s .. " c="..option.c_compiler end - if option.cxx_compiler then s = s .. " cxx="..option.cxx_compiler end - return s - end - - local o = MakeOption(name, nil, check, save, display, printhelp) - o.desc = desc - o.driver = false - o.c_compiler = false - o.cxx_compiler = false - - if default_driver then o.driver = default_driver end - if default_c then o.c_compiler = default_c end - if default_cxx then o.cxx_compiler = default_cxx end - - o.Apply = apply - return o + local check = function(option, settings) + if ScriptArgs[option.name] then + -- set compile driver + option.driver = ScriptArgs[option.name] + + -- set c compiler + if ScriptArgs[option.name .. ".c"] then + option.c_compiler = ScriptArgs[option.name .. ".c"] + end + + -- set c+= compiler + if ScriptArgs[option.name .. ".cxx"] then + option.cxx_compiler = ScriptArgs[option.name .. ".cxx"] + end + + option.auto_detected = false + elseif option.driver then + -- no need todo anything if we have a driver + -- TODO: test if we can find the compiler + else + if ExecuteSilent("cl") == 0 then + option.driver = "cl" + elseif ExecuteSilent("g++ -v") == 0 then + option.driver = "gcc" + else + error("no c/c++ compiler found") + end + end + -- setup_compiler(option.value) + end + + local apply = function(option, settings) + if option.driver == "cl" then + SetDriversCL(settings) + elseif option.driver == "gcc" then + SetDriversGCC(settings) + elseif option.driver == "clang" then + SetDriversClang(settings) + else + 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 + end + + local save = function(option, output) + output:option(option, "driver") + output:option(option, "c_compiler") + output:option(option, "cxx_compiler") + end + + local printhelp = function(option) + local a = "" + if option.desc then + a = "for " .. option.desc + end + print("\t" .. option.name .. "=gcc|cl|clang") + print("\t\twhat c/c++ compile driver to use" .. a) + print("\t" .. option.name .. ".c=FILENAME") + print("\t\twhat c compiler executable to use" .. a) + print("\t" .. option.name .. ".cxx=FILENAME") + print("\t\twhat c++ compiler executable to use" .. a) + end + + local display = function(option) + local s = option.driver + if option.c_compiler then + s = s .. " c=" .. option.c_compiler + end + if option.cxx_compiler then + s = s .. " cxx=" .. option.cxx_compiler + end + return s + end + + local o = MakeOption(name, nil, check, save, display, printhelp) + o.desc = desc + o.driver = false + o.c_compiler = false + o.cxx_compiler = false + + if default_driver then + o.driver = default_driver + end + if default_c then + o.c_compiler = default_c + end + if default_cxx then + o.cxx_compiler = default_cxx + end + + o.Apply = apply + return o end -- Option Library -------------------------------------- --[[@FUNCTION TODO -@END]]-- +@END]] -- function OptLibrary(name, header, desc) - local check = function(option, settings) - option.value = false - option.include_path = false - - local function check_compile_include(filename, paths) - if CTestCompile(settings, "#include <" .. filename .. ">\nint main(){return 0;}", "") then - return "" - end - - for k,v in pairs(paths) do - if CTestCompile(settings, "#include <" .. filename .. ">\nint main(){return 0;}", "-I"..v) then - return v - end - end - - return false - end - - if ScriptArgs[option.name] then - if IsNegativeTerm(ScriptArgs[option.name]) then - option.value = false - elseif ScriptArgs[option.name] == "system" then - option.value = true - else - option.value = true - option.include_path = ScriptArgs[option.name] - end - option.auto_detected = false - else - option.include_path = check_compile_include(option.header, {}) - if option.include_path == false then - if option.required then - print(name.." library not found and is required") - error("required library not found") - end - else - option.value = true - option.include_path = false - end - end - end - - local save = function(option, output) - output:option(option, "value") - output:option(option, "include_path") - end - - local display = function(option) - if option.value then - if option.include_path then - return option.include_path - else - return "(in system path)" - end - else - return "not found" - end - end - - local printhelp = function(option) - print("\t"..option.name.."=disable|system|PATH") - if option.desc then print("\t\t"..option.desc) end - end - - local o = MakeOption(name, false, check, save, display, printhelp) - o.include_path = false - o.header = header - o.desc = desc - return o + local check = function(option, settings) + option.value = false + option.include_path = false + + local function check_compile_include(filename, paths) + if CTestCompile(settings, "#include <" .. filename .. ">\nint main(){return 0;}", "") then + return "" + end + + for k, v in pairs(paths) do + if CTestCompile(settings, "#include <" .. filename .. ">\nint main(){return 0;}", "-I" .. v) then + return v + end + end + + return false + end + + if ScriptArgs[option.name] then + if IsNegativeTerm(ScriptArgs[option.name]) then + option.value = false + elseif ScriptArgs[option.name] == "system" then + option.value = true + else + option.value = true + option.include_path = ScriptArgs[option.name] + end + option.auto_detected = false + else + option.include_path = check_compile_include(option.header, {}) + if option.include_path == false then + if option.required then + print(name .. " library not found and is required") + error("required library not found") + end + else + option.value = true + option.include_path = false + end + end + end + + local save = function(option, output) + output:option(option, "value") + output:option(option, "include_path") + end + + local display = function(option) + if option.value then + if option.include_path then + return option.include_path + else + return "(in system path)" + end + else + return "not found" + end + end + + local printhelp = function(option) + print("\t" .. option.name .. "=disable|system|PATH") + if option.desc then + print("\t\t" .. option.desc) + end + end + + local o = MakeOption(name, false, check, save, display, printhelp) + o.include_path = false + o.header = header + o.desc = desc + return o end diff --git a/server_lang/index.json b/server_lang/index.json index fc403ad..5a9950b 100644 --- a/server_lang/index.json +++ b/server_lang/index.json @@ -1,9 +1,8 @@ { - "language indices": - [ + "language indices": [ { "file": "cn", - "name": "English" + "name": "中文" }, { "file": "en", @@ -11,4 +10,4 @@ "parent": "cn" } ] -} +} \ No newline at end of file diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index d910ef3..23edd69 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -2129,6 +2129,14 @@ int main(int argc, const char **argv) // ignore_convention IStorage *pStorage = CreateStorage("Teeworlds", IStorage::STORAGETYPE_SERVER, argc, argv); // ignore_convention IConfig *pConfig = CreateConfig(); + pServer->m_pLocalization = new CLocalization(pStorage); + pServer->m_pLocalization->InitConfig(0, NULL); + if (!pServer->m_pLocalization->Init()) + { + dbg_msg("localization", "could not initialize localization"); + return -1; + } + pServer->InitRegister(&pServer->m_NetServer, pEngineMasterServer, pConsole); { diff --git a/src/game/generated/nethash.cpp b/src/game/generated/nethash.cpp index 75a0083..5ec2b9a 100644 --- a/src/game/generated/nethash.cpp +++ b/src/game/generated/nethash.cpp @@ -1,2 +1,2 @@ #define GAME_NETVERSION_HASH "4809cbaa4680af30" -#define GIT_SHORTREV_HASH "6a01780c" +#define GIT_SHORTREV_HASH "7edea615" diff --git a/src/game/server/entities/account.cpp b/src/game/server/entities/account.cpp index 6016326..ba58f0d 100644 --- a/src/game/server/entities/account.cpp +++ b/src/game/server/entities/account.cpp @@ -7,6 +7,7 @@ #include #include "account.h" +#include CAccount::CAccount(CPlayer *pPlayer, CGameContext *pGameServer) { @@ -18,10 +19,10 @@ void CAccount::Login(char *Username, char *Password) { char aBuf[125]; if (m_pPlayer->m_AccData.m_UserID) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "您已经登录了."); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("您已经登录了.")); if (!Exists(Username)) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "此账号不存在. 输入 /help"); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("此账号不存在. 输入 /help")); str_format(aBuf, sizeof(aBuf), "accounts/%s.acc", Username); @@ -38,7 +39,7 @@ void CAccount::Login(char *Username, char *Password) if (GameServer()->m_apPlayers[j] && GameServer()->m_apPlayers[j]->m_AccData.m_UserID == AccID) { dbg_msg("account", "账号登录失败 (账号 - '%s' - 正在被使用 (当前服务器))", Username); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "账号正在被使用"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("账号正在被使用")); return; } @@ -48,14 +49,14 @@ void CAccount::Login(char *Username, char *Password) if (AccID == GameServer()->m_aaExtIDs[j]) { dbg_msg("account", "账号登录失败 (账号 - '%s' - 正在被使用 (其他服务器))", Username); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "Account already in use"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("Account already in use")); return; } } if (strcmp(Username, AccUsername) || strcmp(Password, AccPassword)) { dbg_msg("account", "账号登录失败 (账号 - '%s' - 错误的名称)", Username); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "用户名/账号名错误"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("用户名/账号名错误")); return; } @@ -100,24 +101,24 @@ void CAccount::Login(char *Username, char *Password) m_pPlayer->SetTeam(TEAM_BLUE); } - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "登录成功!祝您玩的开心!"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("登录成功!祝您玩的开心!")); } void CAccount::Register(char *Username, char *Password) { char aBuf[125]; if(m_pPlayer->m_AccData.m_UserID) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "已经登录了"); - + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("已经登录了")); + if(Exists(Username)) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "账号已存在."); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("账号已存在.")); char Filter[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_"; char *p = strpbrk(Username, Filter); if(!p) { - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "请使用以下字符注册用户名!"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "A - Z, a - z, 0 - 9, . - _"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("请使用以下字符注册用户名!")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("A - Z, a - z, 0 - 9, . - _")); return; } @@ -160,14 +161,14 @@ void CAccount::Register(char *Username, char *Password) Login(Username, Password); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "~~~~~~~~~~~ ! 注册 ! ~~~~~~~~~~~"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("~~~~~~~~~~~ ! 注册 ! ~~~~~~~~~~~")); str_format(aBuf, sizeof(aBuf), "登录: %s", Username); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _(aBuf)); str_format(aBuf, sizeof(aBuf), "密码: %s", Password); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _(aBuf)); str_format(aBuf, sizeof(aBuf), "现在输入 /login %s %s", Username, Password); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "~~~~~~~~~~~ ! 注册 ! ~~~~~~~~~~~"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _(aBuf)); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("~~~~~~~~~~~ ! 注册 ! ~~~~~~~~~~~")); } bool CAccount::Exists(const char *Username) @@ -243,7 +244,7 @@ void CAccount::NewPassword(char *NewPassword) { char aBuf[48]; str_format(aBuf, sizeof(aBuf), "密码太%s!", str_length(NewPassword)<4?"长了":"短了"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _(aBuf)); return; } @@ -251,8 +252,8 @@ void CAccount::NewPassword(char *NewPassword) char *p = strpbrk(NewPassword, Filter); if(!p) { - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "请使用以下字符作为注册密码!"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "A - Z, a - z, 0 - 9, . - _"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("请使用以下字符作为注册密码!")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("A - Z, a - z, 0 - 9, . - _")); return; } @@ -260,7 +261,7 @@ void CAccount::NewPassword(char *NewPassword) Apply(); dbg_msg("account", "密码更改为 - ('%s')", m_pPlayer->m_AccData.m_Username); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "密码更改成功"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("密码更改成功")); } diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index badc075..cbd3ba3 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -15,10 +15,12 @@ #include "mine.h" #include "turret.h" +#include + MACRO_ALLOC_POOL_ID_IMPL(CCharacter, MAX_CLIENTS) CCharacter::CCharacter(CGameWorld *pWorld) -: CEntity(pWorld, CGameWorld::ENTTYPE_CHARACTER) + : CEntity(pWorld, CGameWorld::ENTTYPE_CHARACTER) { m_ProximityRadius = ms_PhysSize; m_Health = 0; @@ -26,7 +28,8 @@ CCharacter::CCharacter(CGameWorld *pWorld) m_InvisID = Server()->SnapNewID(); } -void CCharacter::Reset(){ +void CCharacter::Reset() +{ Destroy(); } @@ -36,15 +39,15 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos) m_LastWeapon = WEAPON_HAMMER; m_pPlayer = pPlayer; - m_Pos = Pos; + m_Pos = Pos; m_OldPos = Pos; m_Core.Reset(); m_Core.m_Id = GetPlayer()->GetCID(); - m_Core.Init(&GameServer()->m_World.m_Core, GameServer()->Collision(), &((CGameControllerDDRace*)GameServer()->m_pController)->m_Teams.m_Core, &((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts); + m_Core.Init(&GameServer()->m_World.m_Core, GameServer()->Collision(), &((CGameControllerDDRace *)GameServer()->m_pController)->m_Teams.m_Core, &((CGameControllerDDRace *)GameServer()->m_pController)->m_TeleOuts); m_Core.m_Pos = m_Pos; GameServer()->m_World.m_Core.m_apCharacters[m_pPlayer->GetCID()] = &m_Core; - + m_ReckoningTick = 0; mem_zero(&m_SendCore, sizeof(m_SendCore)); mem_zero(&m_ReckoningCore, sizeof(m_ReckoningCore)); @@ -54,28 +57,33 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos) m_LastRefillJumps = m_HittingDoor = m_iVisible = m_TypeHealthCh = false; m_TurretActive[0] = m_TurretActive[1] = m_TurretActive[2] = m_TurretActive[3] = m_TurretActive[4] = false; - + m_SuperJump = false; m_PrevPos = m_Pos; m_TeleCheckpoint = 0; m_BurnedFrom = pPlayer->GetCID(); m_PushDirection = vec2(0, 0); - + m_TuneZone = GameServer()->Collision()->IsTune(GameServer()->Collision()->GetMapIndex(Pos)); - m_TuneZoneOld = -1; // no zone leave msg on spawn + m_TuneZoneOld = -1; // no zone leave msg on spawn m_NeededFaketuning = 0; // reset fake tunings on respawn and send the client - SendZoneMsgs(); // we want a entermessage also on spawn + SendZoneMsgs(); // we want a entermessage also on spawn GameServer()->SendTuningParams(pPlayer->GetCID(), m_TuneZone); - m_HeartTick = 1*Server()->TickSpeed(); + m_HeartTick = 1 * Server()->TickSpeed(); GameServer()->m_pController->OnCharacterSpawn(this); - if (pPlayer->GetTeam() == TEAM_RED) m_Core.m_ActiveWeapon = WEAPON_HAMMER; - else if (pPlayer->GetTeam() == TEAM_BLUE) m_Core.m_ActiveWeapon = WEAPON_GUN; + if (pPlayer->GetTeam() == TEAM_RED) + m_Core.m_ActiveWeapon = WEAPON_HAMMER; + else if (pPlayer->GetTeam() == TEAM_BLUE) + m_Core.m_ActiveWeapon = WEAPON_GUN; m_Core.m_Jumps = 2 + pPlayer->m_JumpsShop; - if (pPlayer->m_AccData.m_Level >= 50 && pPlayer->m_AccData.m_Level <= 99) m_mAmmo = 20 + pPlayer->m_AccData.m_Ammo; - else if (pPlayer->m_AccData.m_Level >= 100) m_mAmmo = 30 + pPlayer->m_AccData.m_Ammo; - else m_mAmmo = 10 + pPlayer->m_AccData.m_Ammo; + if (pPlayer->m_AccData.m_Level >= 50 && pPlayer->m_AccData.m_Level <= 99) + m_mAmmo = 20 + pPlayer->m_AccData.m_Ammo; + else if (pPlayer->m_AccData.m_Level >= 100) + m_mAmmo = 30 + pPlayer->m_AccData.m_Ammo; + else + m_mAmmo = 10 + pPlayer->m_AccData.m_Ammo; GameServer()->SendBroadcast("", pPlayer->GetCID()); return true; @@ -83,7 +91,7 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos) void CCharacter::Destroy() { - if(m_InvisID >= 0) + if (m_InvisID >= 0) { Server()->SnapFreeID(m_InvisID); m_InvisID = -1; @@ -94,7 +102,7 @@ void CCharacter::Destroy() void CCharacter::SetWeapon(int W) { - if(W == m_Core.m_ActiveWeapon || m_pPlayer->GetTeam() == TEAM_RED) + if (W == m_Core.m_ActiveWeapon || m_pPlayer->GetTeam() == TEAM_RED) return; m_LastWeapon = m_Core.m_ActiveWeapon; @@ -102,25 +110,25 @@ void CCharacter::SetWeapon(int W) m_Core.m_ActiveWeapon = W; GameServer()->CreateSound(m_Pos, SOUND_WEAPON_SWITCH, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); - if(m_Core.m_ActiveWeapon < 0 || m_Core.m_ActiveWeapon >= NUM_WEAPONS) + if (m_Core.m_ActiveWeapon < 0 || m_Core.m_ActiveWeapon >= NUM_WEAPONS) m_Core.m_ActiveWeapon = 0; } bool CCharacter::IsGrounded() { - if(GameServer()->Collision()->CheckPoint(m_Pos.x+m_ProximityRadius/2, m_Pos.y+m_ProximityRadius/2+5)) + if (GameServer()->Collision()->CheckPoint(m_Pos.x + m_ProximityRadius / 2, m_Pos.y + m_ProximityRadius / 2 + 5)) return true; - if(GameServer()->Collision()->CheckPoint(m_Pos.x-m_ProximityRadius/2, m_Pos.y+m_ProximityRadius/2+5)) + if (GameServer()->Collision()->CheckPoint(m_Pos.x - m_ProximityRadius / 2, m_Pos.y + m_ProximityRadius / 2 + 5)) return true; - int index = GameServer()->Collision()->GetPureMapIndex(vec2(m_Pos.x, m_Pos.y+m_ProximityRadius/2+4)); + int index = GameServer()->Collision()->GetPureMapIndex(vec2(m_Pos.x, m_Pos.y + m_ProximityRadius / 2 + 4)); int tile = GameServer()->Collision()->GetTileIndex(index); int flags = GameServer()->Collision()->GetTileFlags(index); - if(tile == TILE_STOPA || (tile == TILE_STOP && flags == ROTATION_0) || (tile ==TILE_STOPS && (flags == ROTATION_0 || flags == ROTATION_180))) + if (tile == TILE_STOPA || (tile == TILE_STOP && flags == ROTATION_0) || (tile == TILE_STOPS && (flags == ROTATION_0 || flags == ROTATION_180))) return true; tile = GameServer()->Collision()->GetFTileIndex(index); flags = GameServer()->Collision()->GetFTileFlags(index); - if(tile == TILE_STOPA || (tile == TILE_STOP && flags == ROTATION_0) || (tile ==TILE_STOPS && (flags == ROTATION_0 || flags == ROTATION_180))) + if (tile == TILE_STOPA || (tile == TILE_STOP && flags == ROTATION_0) || (tile == TILE_STOPS && (flags == ROTATION_0 || flags == ROTATION_180))) return true; return false; @@ -128,7 +136,7 @@ bool CCharacter::IsGrounded() void CCharacter::DoWeaponSwitch() { - if(m_ReloadTimer != 0 || m_QueuedWeapon == -1 || m_aWeapons[WEAPON_NINJA].m_Got) + if (m_ReloadTimer != 0 || m_QueuedWeapon == -1 || m_aWeapons[WEAPON_NINJA].m_Got) return; SetWeapon(m_QueuedWeapon); @@ -137,54 +145,54 @@ void CCharacter::DoWeaponSwitch() void CCharacter::HandleWeaponSwitch() { int WantedWeapon = m_Core.m_ActiveWeapon; - if(m_QueuedWeapon != -1) + if (m_QueuedWeapon != -1) WantedWeapon = m_QueuedWeapon; bool Anything = false; - for(int i = 0; i < NUM_WEAPONS - 1; ++i) - if(m_aWeapons[i].m_Got) - Anything = true; - if(!Anything) - return; + for (int i = 0; i < NUM_WEAPONS - 1; ++i) + if (m_aWeapons[i].m_Got) + Anything = true; + if (!Anything) + return; - if(m_pPlayer->m_AccData.m_Freeze) + if (m_pPlayer->m_AccData.m_Freeze) return; - + int Next = CountInput(m_LatestPrevInput.m_NextWeapon, m_LatestInput.m_NextWeapon).m_Presses; int Prev = CountInput(m_LatestPrevInput.m_PrevWeapon, m_LatestInput.m_PrevWeapon).m_Presses; - if(Next < 128) // make sure we only try sane stuff + if (Next < 128) // make sure we only try sane stuff { - while(Next) // Next Weapon selection + while (Next) // Next Weapon selection { if (!m_pPlayer->m_LifeActives && m_pPlayer->GetTeam() == TEAM_RED && g_Config.m_SvNewHearth) m_TypeHealthCh = true; - WantedWeapon = (WantedWeapon+1)%NUM_WEAPONS; - if(m_aWeapons[WantedWeapon].m_Got) + WantedWeapon = (WantedWeapon + 1) % NUM_WEAPONS; + if (m_aWeapons[WantedWeapon].m_Got) Next--; } } - if(Prev < 128) // make sure we only try sane stuff + if (Prev < 128) // make sure we only try sane stuff { - while(Prev) // Prev Weapon selection + while (Prev) // Prev Weapon selection { if (!m_pPlayer->m_LifeActives && m_pPlayer->GetTeam() == TEAM_RED && g_Config.m_SvNewHearth) m_TypeHealthCh = false; - WantedWeapon = (WantedWeapon-1)<0?NUM_WEAPONS-1:WantedWeapon-1; - if(m_aWeapons[WantedWeapon].m_Got) + WantedWeapon = (WantedWeapon - 1) < 0 ? NUM_WEAPONS - 1 : WantedWeapon - 1; + if (m_aWeapons[WantedWeapon].m_Got) Prev--; } } // Direct Weapon selection - if(m_LatestInput.m_WantedWeapon) - WantedWeapon = m_Input.m_WantedWeapon-1; + if (m_LatestInput.m_WantedWeapon) + WantedWeapon = m_Input.m_WantedWeapon - 1; // check for insane values - if(WantedWeapon >= 0 && WantedWeapon < NUM_WEAPONS && WantedWeapon != m_Core.m_ActiveWeapon && m_aWeapons[WantedWeapon].m_Got) + if (WantedWeapon >= 0 && WantedWeapon < NUM_WEAPONS && WantedWeapon != m_Core.m_ActiveWeapon && m_aWeapons[WantedWeapon].m_Got) m_QueuedWeapon = WantedWeapon; DoWeaponSwitch(); @@ -195,209 +203,214 @@ void CCharacter::GrenadeFire(vec2 Pos) vec2 Direction = normalize(m_Pos - Pos); vec2 ProjStartPos = Pos + Direction; - new CProjectile(GameWorld(), WEAPON_GRENADE, m_pPlayer->GetCID(), ProjStartPos, Direction, (int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GrenadeLifetime), 1, true, 17, SOUND_GRENADE_EXPLODE, WEAPON_GRENADE); + new CProjectile(GameWorld(), WEAPON_GRENADE, m_pPlayer->GetCID(), ProjStartPos, Direction, (int)(Server()->TickSpeed() * GameServer()->Tuning()->m_GrenadeLifetime), 1, true, 17, SOUND_GRENADE_EXPLODE, WEAPON_GRENADE); GameServer()->CreateSound(Pos, SOUND_GRENADE_FIRE); } void CCharacter::FireWeapon() { - if(m_ReloadTimer != 0 || m_pPlayer->m_AccData.m_Freeze) + if (m_ReloadTimer != 0 || m_pPlayer->m_AccData.m_Freeze) return; - + DoWeaponSwitch(); vec2 Direction = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY)); bool FullAuto = false; - if(m_Core.m_ActiveWeapon == WEAPON_GRENADE || m_Core.m_ActiveWeapon == WEAPON_SHOTGUN || m_Core.m_ActiveWeapon == WEAPON_GUN || + if (m_Core.m_ActiveWeapon == WEAPON_GRENADE || m_Core.m_ActiveWeapon == WEAPON_SHOTGUN || m_Core.m_ActiveWeapon == WEAPON_GUN || m_Core.m_ActiveWeapon == WEAPON_HAMMER && m_pPlayer->m_AccData.m_Level >= 10 || m_Core.m_ActiveWeapon == WEAPON_GUN) FullAuto = true; // check if we gonna fire bool WillFire = false; - if(CountInput(m_LatestPrevInput.m_Fire, m_LatestInput.m_Fire).m_Presses) + if (CountInput(m_LatestPrevInput.m_Fire, m_LatestInput.m_Fire).m_Presses) WillFire = true; - if(FullAuto && (m_LatestInput.m_Fire&1) && m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo) + if (FullAuto && (m_LatestInput.m_Fire & 1) && m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo) WillFire = true; - if(!WillFire) + if (!WillFire) return; - if(!m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo) + if (!m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo) { m_ReloadTimer = 125 * Server()->TickSpeed() / 1000; GameServer()->CreateSound(m_Pos, SOUND_WEAPON_NOAMMO); return; } - vec2 ProjStartPos = m_Pos+Direction*m_ProximityRadius*0.75f; - switch(m_Core.m_ActiveWeapon) + vec2 ProjStartPos = m_Pos + Direction * m_ProximityRadius * 0.75f; + switch (m_Core.m_ActiveWeapon) { - case WEAPON_HAMMER: + case WEAPON_HAMMER: + { + m_NumObjectsHit = 0; + GameServer()->CreateSound(m_Pos, SOUND_HAMMER_FIRE, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); + CCharacter *apEnts[MAX_CLIENTS]; + int Hits = 0; + if (m_pPlayer->GetTeam() == TEAM_RED) { - m_NumObjectsHit = 0; - GameServer()->CreateSound(m_Pos, SOUND_HAMMER_FIRE, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); - CCharacter *apEnts[MAX_CLIENTS]; - int Hits = 0; - if (m_pPlayer->GetTeam() == TEAM_RED) + int rands = rand() % 150; + if (rands == 15) + new CMine(GameWorld(), m_Pos, m_pPlayer->GetCID()); + + if (!m_pPlayer->m_LifeActives && !m_HeartTick && (m_TypeHealthCh && g_Config.m_SvNewHearth || !g_Config.m_SvNewHearth)) + m_pPlayer->m_LifeActives = true; + + CTurret *pClosest = (CTurret *)GameWorld()->FindFirst(CGameWorld::ENTTYPE_TURRET); + while (pClosest) { - int rands = rand() % 150; - if (rands == 15) - new CMine(GameWorld(), m_Pos, m_pPlayer->GetCID()); - - if (!m_pPlayer->m_LifeActives && !m_HeartTick && (m_TypeHealthCh && g_Config.m_SvNewHearth || !g_Config.m_SvNewHearth)) - m_pPlayer->m_LifeActives = true; - - CTurret *pClosest = (CTurret *)GameWorld()->FindFirst(CGameWorld::ENTTYPE_TURRET); - while (pClosest) + if (distance(pClosest->m_Pos, m_Pos) <= 25) { - if (distance(pClosest->m_Pos, m_Pos) <= 25) + if (!GameServer()->Collision()->IntersectLine(m_Pos, pClosest->m_Pos, 0, 0, false)) { - if (!GameServer()->Collision()->IntersectLine(m_Pos, pClosest->m_Pos, 0, 0, false)) - { - if(GameServer()->GetPlayerChar(pClosest->m_Owner)) - GameServer()->CreateSoundGlobal(35, pClosest->m_Owner); - - GameServer()->CreateHammerHit(pClosest->m_Pos); - pClosest->Reset(); - ExperienceAdd(1, m_pPlayer->GetCID()); - } + if (GameServer()->GetPlayerChar(pClosest->m_Owner)) + GameServer()->CreateSoundGlobal(35, pClosest->m_Owner); + + GameServer()->CreateHammerHit(pClosest->m_Pos); + pClosest->Reset(); + ExperienceAdd(1, m_pPlayer->GetCID()); } - pClosest = (CTurret *)pClosest->TypeNext(); } - - int Num = GameServer()->m_World.FindEntities(ProjStartPos, m_ProximityRadius*(m_pPlayer->m_RangeShop?2.00f:0.76f), (CEntity**)apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER); - for (int i = 0; i < Num; ++i) - { - CCharacter *pTarget = apEnts[i]; + pClosest = (CTurret *)pClosest->TypeNext(); + } + + int Num = GameServer()->m_World.FindEntities(ProjStartPos, m_ProximityRadius * (m_pPlayer->m_RangeShop ? 2.00f : 0.76f), (CEntity **)apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER); + for (int i = 0; i < Num; ++i) + { + CCharacter *pTarget = apEnts[i]; - if (pTarget == this || (pTarget->IsAlive() && GameServer()->Collision()->IntersectLine(ProjStartPos, pTarget->m_Pos, NULL, NULL, false)) || pTarget->m_pPlayer->GetTeam() == TEAM_RED) - continue; + if (pTarget == this || (pTarget->IsAlive() && GameServer()->Collision()->IntersectLine(ProjStartPos, pTarget->m_Pos, NULL, NULL, false)) || pTarget->m_pPlayer->GetTeam() == TEAM_RED) + continue; - if (length(pTarget->m_Pos - ProjStartPos) > 0.0f) - GameServer()->CreateHammerHit(pTarget->m_Pos - normalize(pTarget->m_Pos - ProjStartPos)*m_ProximityRadius*0.5f, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); - else - GameServer()->CreateHammerHit(ProjStartPos, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); + if (length(pTarget->m_Pos - ProjStartPos) > 0.0f) + GameServer()->CreateHammerHit(pTarget->m_Pos - normalize(pTarget->m_Pos - ProjStartPos) * m_ProximityRadius * 0.5f, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); + else + GameServer()->CreateHammerHit(ProjStartPos, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); - if (!pTarget->IhammerTick) - pTarget->m_pPlayer->SetZomb(m_pPlayer->GetCID()); - - Hits++; - } + if (!pTarget->IhammerTick) + pTarget->m_pPlayer->SetZomb(m_pPlayer->GetCID()); + + Hits++; } - else + } + else + { + if (!IhammerRelTick) { - if (!IhammerRelTick) - { - GameServer()->CreatePlayerSpawn(m_Pos); - IhammerTick = 5 * Server()->TickSpeed(); - IhammerRelTick = 30 * Server()->TickSpeed(); - } + GameServer()->CreatePlayerSpawn(m_Pos); + IhammerTick = 5 * Server()->TickSpeed(); + IhammerRelTick = 30 * Server()->TickSpeed(); + } - int Num = GameServer()->m_World.FindEntities(ProjStartPos, m_ProximityRadius*0.5f, (CEntity**)apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER); - for (int i = 0; i < Num; ++i) - { - CCharacter *pTarget = apEnts[i]; + int Num = GameServer()->m_World.FindEntities(ProjStartPos, m_ProximityRadius * 0.5f, (CEntity **)apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER); + for (int i = 0; i < Num; ++i) + { + CCharacter *pTarget = apEnts[i]; - if ((pTarget == this || (pTarget->IsAlive() && !CanCollide(pTarget->GetPlayer()->GetCID())) || pTarget->m_pPlayer->GetTeam() != TEAM_RED)) - continue; + if ((pTarget == this || (pTarget->IsAlive() && !CanCollide(pTarget->GetPlayer()->GetCID())) || pTarget->m_pPlayer->GetTeam() != TEAM_RED)) + continue; - if (length(pTarget->m_Pos - ProjStartPos) > 0.0f) - GameServer()->CreateHammerHit(pTarget->m_Pos - normalize(pTarget->m_Pos - ProjStartPos)*m_ProximityRadius*0.5f, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); - else - GameServer()->CreateHammerHit(ProjStartPos, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); + if (length(pTarget->m_Pos - ProjStartPos) > 0.0f) + GameServer()->CreateHammerHit(pTarget->m_Pos - normalize(pTarget->m_Pos - ProjStartPos) * m_ProximityRadius * 0.5f, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); + else + GameServer()->CreateHammerHit(ProjStartPos, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); - pTarget->TakeDamage(vec2(0,0), 3+m_pPlayer->m_AccData.m_Dmg, m_pPlayer->GetCID(), m_Core.m_ActiveWeapon); - Hits++; - } + pTarget->TakeDamage(vec2(0, 0), 3 + m_pPlayer->m_AccData.m_Dmg, m_pPlayer->GetCID(), m_Core.m_ActiveWeapon); + Hits++; } - if(Hits) - m_ReloadTimer = Server()->TickSpeed()/3; - } break; + } + if (Hits) + m_ReloadTimer = Server()->TickSpeed() / 3; + } + break; - case WEAPON_GUN: - { - new CProjectile(GameWorld(), WEAPON_GUN, m_pPlayer->GetCID(), ProjStartPos, Direction, (int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GunLifetime), 2+m_pPlayer->m_AccData.m_Dmg, m_pPlayer->m_KillingSpree >= g_Config.m_SvKillingSpree & g_Config.m_SvKillingSpree ? true : false, 22, -1, WEAPON_GUN); - GameServer()->CreateSound(m_Pos, SOUND_GUN_FIRE); - } break; + case WEAPON_GUN: + { + new CProjectile(GameWorld(), WEAPON_GUN, m_pPlayer->GetCID(), ProjStartPos, Direction, (int)(Server()->TickSpeed() * GameServer()->Tuning()->m_GunLifetime), 2 + m_pPlayer->m_AccData.m_Dmg, m_pPlayer->m_KillingSpree >= g_Config.m_SvKillingSpree & g_Config.m_SvKillingSpree ? true : false, 22, -1, WEAPON_GUN); + GameServer()->CreateSound(m_Pos, SOUND_GUN_FIRE); + } + break; - case WEAPON_SHOTGUN: + case WEAPON_SHOTGUN: + { + int ShotSpread = 5 + m_pPlayer->m_AccData.m_Level / 10; + if (ShotSpread > 15) { - int ShotSpread = 5 + m_pPlayer->m_AccData.m_Level / 10; - if(ShotSpread > 15) - { - ShotSpread = 15 + m_pPlayer->m_AccData.m_Level / 70; - if(ShotSpread > 36) - ShotSpread = 36; - } - - CMsgPacker Msg(NETMSGTYPE_SV_EXTRAPROJECTILE); - Msg.AddInt(ShotSpread / 2 * 2 + 1); + ShotSpread = 15 + m_pPlayer->m_AccData.m_Level / 70; + if (ShotSpread > 36) + ShotSpread = 36; + } - float Spreading[20 * 2 + 1]; - for (int i = 0; i < 20 * 2 + 1; i++) - Spreading[i] = -1.2f + 0.06f * i; + CMsgPacker Msg(NETMSGTYPE_SV_EXTRAPROJECTILE); + Msg.AddInt(ShotSpread / 2 * 2 + 1); - for (int i = -ShotSpread / 2; i <= ShotSpread / 2; ++i) - { - float a = GetAngle(Direction); - a += Spreading[i + 20]; - float v = 1 - (absolute(i) / (float)ShotSpread) / 2; - float Speed = m_pPlayer->m_AccData.m_Level > 19 ? 1.2f : mix((float)GameServer()->Tuning()->m_ShotgunSpeeddiff, 1.2f, v); - new CProjectile(GameWorld(), WEAPON_SHOTGUN, m_pPlayer->GetCID(), ProjStartPos, vec2(cosf(a), sinf(a))*Speed, (int)(Server()->TickSpeed()*1.5), 1+m_pPlayer->m_AccData.m_Dmg/5, 0, 1, -1, WEAPON_SHOTGUN); - } - Server()->SendMsg(&Msg, 0, m_pPlayer->GetCID()); - GameServer()->CreateSound(m_Pos, SOUND_SHOTGUN_FIRE); - } break; + float Spreading[20 * 2 + 1]; + for (int i = 0; i < 20 * 2 + 1; i++) + Spreading[i] = -1.2f + 0.06f * i; - case WEAPON_GRENADE: + for (int i = -ShotSpread / 2; i <= ShotSpread / 2; ++i) { - new CProjectile(GameWorld(), WEAPON_GRENADE, m_pPlayer->GetCID(), ProjStartPos, Direction, (int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GrenadeLifetime), 0, true, 17, SOUND_GRENADE_EXPLODE, WEAPON_GRENADE); - GameServer()->CreateSound(m_Pos, SOUND_GRENADE_FIRE, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); - } break; + float a = GetAngle(Direction); + a += Spreading[i + 20]; + float v = 1 - (absolute(i) / (float)ShotSpread) / 2; + float Speed = m_pPlayer->m_AccData.m_Level > 19 ? 1.2f : mix((float)GameServer()->Tuning()->m_ShotgunSpeeddiff, 1.2f, v); + new CProjectile(GameWorld(), WEAPON_SHOTGUN, m_pPlayer->GetCID(), ProjStartPos, vec2(cosf(a), sinf(a)) * Speed, (int)(Server()->TickSpeed() * 1.5), 1 + m_pPlayer->m_AccData.m_Dmg / 5, 0, 1, -1, WEAPON_SHOTGUN); + } + Server()->SendMsg(&Msg, 0, m_pPlayer->GetCID()); + GameServer()->CreateSound(m_Pos, SOUND_SHOTGUN_FIRE); + } + break; + + case WEAPON_GRENADE: + { + new CProjectile(GameWorld(), WEAPON_GRENADE, m_pPlayer->GetCID(), ProjStartPos, Direction, (int)(Server()->TickSpeed() * GameServer()->Tuning()->m_GrenadeLifetime), 0, true, 17, SOUND_GRENADE_EXPLODE, WEAPON_GRENADE); + GameServer()->CreateSound(m_Pos, SOUND_GRENADE_FIRE, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); + } + break; - case WEAPON_RIFLE: + case WEAPON_RIFLE: + { + vec2 To; + if (m_RiflePos != vec2(0, 0)) { - vec2 To; - if (m_RiflePos != vec2(0, 0)) + if (m_RiflePos == m_Pos) { - if (m_RiflePos == m_Pos) - { - m_aWeapons[WEAPON_RIFLE].m_Ammo = 2; - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "第二个标点不能设置在这里."); - m_RiflePos = vec2(0, 0); - return; - } - new CWall(GameWorld(), m_RiflePos, m_Pos, m_pPlayer->GetCID(), 8); + m_aWeapons[WEAPON_RIFLE].m_Ammo = 2; + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("第二个标点不能设置在这里.")); + m_RiflePos = vec2(0, 0); + return; } - else m_RiflePos = m_Pos; - } break; - - case WEAPON_NINJA: - break; + new CWall(GameWorld(), m_RiflePos, m_Pos, m_pPlayer->GetCID(), 8); + } + else + m_RiflePos = m_Pos; + } + break; + case WEAPON_NINJA: + break; } m_AttackTick = Server()->Tick(); - if(m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo > 0) + if (m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo > 0) m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo--; - if(!m_ReloadTimer) + if (!m_ReloadTimer) { float FireDelay; if (!m_TuneZone) GameServer()->Tuning()->Get(38 + m_Core.m_ActiveWeapon, &FireDelay); else GameServer()->TuningList()[m_TuneZone].Get(38 + m_Core.m_ActiveWeapon, &FireDelay); - + m_ReloadTimer = FireDelay * Server()->TickSpeed() / (1000 + m_pPlayer->m_AccData.m_Handle * 16); } } void CCharacter::HandleWeapons() { - if(m_ReloadTimer) + if (m_ReloadTimer) { m_ReloadTimer--; return; @@ -406,7 +419,8 @@ void CCharacter::HandleWeapons() if (m_pPlayer->m_AccData.m_Ammoregen >= 1 && m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo < m_mAmmo + m_pPlayer->m_AccData.m_Ammo && (m_Core.m_ActiveWeapon == WEAPON_SHOTGUN || m_Core.m_ActiveWeapon == WEAPON_GRENADE)) { - if (m_RegenTime) m_RegenTime--; + if (m_RegenTime) + m_RegenTime--; else { m_RegenTime = 160 - m_pPlayer->m_AccData.m_Ammoregen * 2 - 5; @@ -415,7 +429,7 @@ void CCharacter::HandleWeapons() } int AmmoRegenTime = g_pData->m_Weapons.m_aId[m_Core.m_ActiveWeapon].m_Ammoregentime; - if(AmmoRegenTime) + if (AmmoRegenTime) { if (m_ReloadTimer <= 0) { @@ -439,8 +453,10 @@ bool CCharacter::GiveWeapon(int Weapon, int Ammo) if (Weapon == WEAPON_RIFLE && !m_aWeapons[Weapon].m_Ammo || Weapon != WEAPON_RIFLE && m_aWeapons[Weapon].m_Ammo < 5 || !m_aWeapons[Weapon].m_Got) { m_aWeapons[Weapon].m_Got = true; - if (Weapon == WEAPON_RIFLE) m_aWeapons[Weapon].m_Ammo = min((2), Ammo); - else m_aWeapons[Weapon].m_Ammo = min(m_mAmmo+m_pPlayer->m_AccData.m_Ammo, Ammo); + if (Weapon == WEAPON_RIFLE) + m_aWeapons[Weapon].m_Ammo = min((2), Ammo); + else + m_aWeapons[Weapon].m_Ammo = min(m_mAmmo + m_pPlayer->m_AccData.m_Ammo, Ammo); return true; } @@ -456,7 +472,7 @@ void CCharacter::SetEmote(int Emote, int Tick) void CCharacter::OnPredictedInput(CNetObj_PlayerInput *pNewInput) { // check for changes - if(mem_comp(&m_Input, pNewInput, sizeof(CNetObj_PlayerInput)) != 0) + if (mem_comp(&m_Input, pNewInput, sizeof(CNetObj_PlayerInput)) != 0) m_LastAction = Server()->Tick(); // copy new input @@ -464,7 +480,7 @@ void CCharacter::OnPredictedInput(CNetObj_PlayerInput *pNewInput) m_NumInputs++; // it is not allowed to aim in the center - if(m_Input.m_TargetX == 0 && m_Input.m_TargetY == 0) + if (m_Input.m_TargetX == 0 && m_Input.m_TargetY == 0) m_Input.m_TargetY = -1; } @@ -474,10 +490,10 @@ void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput) mem_copy(&m_LatestInput, pNewInput, sizeof(m_LatestInput)); // it is not allowed to aim in the center - if(m_LatestInput.m_TargetX == 0 && m_LatestInput.m_TargetY == 0) + if (m_LatestInput.m_TargetX == 0 && m_LatestInput.m_TargetY == 0) m_LatestInput.m_TargetY = -1; - if(m_NumInputs > 2 && m_pPlayer->GetTeam() != TEAM_SPECTATORS) + if (m_NumInputs > 2 && m_pPlayer->GetTeam() != TEAM_SPECTATORS) { HandleWeaponSwitch(); FireWeapon(); @@ -491,7 +507,7 @@ void CCharacter::ResetInput() m_Input.m_Direction = 0; m_Input.m_Hook = 0; // simulate releasing the fire button - if((m_Input.m_Fire&1) != 0) + if ((m_Input.m_Fire & 1) != 0) m_Input.m_Fire++; m_Input.m_Fire &= INPUT_STATE_MASK; m_Input.m_Jump = 0; @@ -508,7 +524,7 @@ void CCharacter::Tick() HandleWeapons(); DDRacePostCoreTick(); m_ActivTurs = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY)); - + if (m_HeartTick) m_HeartTick--; if (IhammerRelTick) @@ -522,7 +538,7 @@ void CCharacter::Tick() IhammerTick--; char aBuf[26]; - str_format(aBuf, sizeof(aBuf), "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n隐身: %d.%d", IhammerTick/Server()->TickSpeed() , ITickSecond*2); + str_format(aBuf, sizeof(aBuf), "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n隐身: %d.%d", IhammerTick / Server()->TickSpeed(), ITickSecond * 2); GameServer()->SendBroadcast(aBuf, m_pPlayer->GetCID()); if (!IhammerTick) { @@ -545,14 +561,16 @@ void CCharacter::Tick() } } - if(m_HittingDoor) + if (m_HittingDoor) { - m_Core.m_Vel += m_PushDirection*length(m_Core.m_Vel); - if(m_Core.m_Jumped&3) m_Core.m_Jumped &= ~2; + m_Core.m_Vel += m_PushDirection * length(m_Core.m_Vel); + if (m_Core.m_Jumped & 3) + m_Core.m_Jumped &= ~2; } - else if(!m_HittingDoor) m_OldPos = m_Core.m_Pos; + else if (!m_HittingDoor) + m_OldPos = m_Core.m_Pos; m_HittingDoor = false; - + m_PrevInput = m_Input; m_PrevPos = m_Core.m_Pos; return; @@ -563,14 +581,14 @@ void CCharacter::TickDefered() // advance the dummy { CWorldCore TempWorld; - m_ReckoningCore.Init(&TempWorld, GameServer()->Collision(), &((CGameControllerDDRace*)GameServer()->m_pController)->m_Teams.m_Core, &((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts); + m_ReckoningCore.Init(&TempWorld, GameServer()->Collision(), &((CGameControllerDDRace *)GameServer()->m_pController)->m_Teams.m_Core, &((CGameControllerDDRace *)GameServer()->m_pController)->m_TeleOuts); m_ReckoningCore.m_Id = m_pPlayer->GetCID(); m_ReckoningCore.Tick(false, false); m_ReckoningCore.Move(); m_ReckoningCore.Quantize(); } - //lastsentcore + // lastsentcore vec2 StartPos = m_Core.m_Pos; vec2 StartVel = m_Core.m_Vel; bool StuckBefore = GameServer()->Collision()->TestBox(m_Core.m_Pos, vec2(28.0f, 28.0f)); @@ -582,14 +600,14 @@ void CCharacter::TickDefered() bool StuckAfterQuant = GameServer()->Collision()->TestBox(m_Core.m_Pos, vec2(28.0f, 28.0f)); m_Pos = m_Core.m_Pos; - if(!StuckBefore && (StuckAfterMove || StuckAfterQuant)) + if (!StuckBefore && (StuckAfterMove || StuckAfterQuant)) { // Hackish solution to get rid of strict-aliasing warning union { float f; unsigned u; - }StartPosX, StartPosY, StartVelX, StartVelY; + } StartPosX, StartPosY, StartVelX, StartVelY; StartPosX.f = StartPos.x; StartPosY.f = StartPos.y; @@ -598,27 +616,30 @@ void CCharacter::TickDefered() char aBuf[128]; str_format(aBuf, sizeof(aBuf), "STUCK!!! %d %d %d %f %f %f %f %x %x %x %x", - StuckBefore, - StuckAfterMove, - StuckAfterQuant, - StartPos.x, StartPos.y, - StartVel.x, StartVel.y, - StartPosX.u, StartPosY.u, - StartVelX.u, StartVelY.u); + StuckBefore, + StuckAfterMove, + StuckAfterQuant, + StartPos.x, StartPos.y, + StartVel.x, StartVel.y, + StartPosX.u, StartPosY.u, + StartVelX.u, StartVelY.u); GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); } int Events = m_Core.m_TriggeredEvents; - //int Mask = CmaskAllExceptOne(m_pPlayer->GetCID()); + // int Mask = CmaskAllExceptOne(m_pPlayer->GetCID()); - if(Events&COREEVENT_GROUND_JUMP) GameServer()->CreateSound(m_Pos, SOUND_PLAYER_JUMP, Teams()->TeamMask(Team(), m_pPlayer->GetCID())); + if (Events & COREEVENT_GROUND_JUMP) + GameServer()->CreateSound(m_Pos, SOUND_PLAYER_JUMP, Teams()->TeamMask(Team(), m_pPlayer->GetCID())); - if(Events&COREEVENT_HOOK_ATTACH_PLAYER) GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_PLAYER, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); - if(Events&COREEVENT_HOOK_ATTACH_GROUND) GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_GROUND, Teams()->TeamMask(Team(), m_pPlayer->GetCID(), m_pPlayer->GetCID())); - if(Events&COREEVENT_HOOK_HIT_NOHOOK) GameServer()->CreateSound(m_Pos, SOUND_HOOK_NOATTACH, Teams()->TeamMask(Team(), m_pPlayer->GetCID(), m_pPlayer->GetCID())); + if (Events & COREEVENT_HOOK_ATTACH_PLAYER) + GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_PLAYER, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); + if (Events & COREEVENT_HOOK_ATTACH_GROUND) + GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_GROUND, Teams()->TeamMask(Team(), m_pPlayer->GetCID(), m_pPlayer->GetCID())); + if (Events & COREEVENT_HOOK_HIT_NOHOOK) + GameServer()->CreateSound(m_Pos, SOUND_HOOK_NOATTACH, Teams()->TeamMask(Team(), m_pPlayer->GetCID(), m_pPlayer->GetCID())); - - if(m_pPlayer->GetTeam() == TEAM_SPECTATORS) + if (m_pPlayer->GetTeam() == TEAM_SPECTATORS) { m_Pos.x = m_Input.m_TargetX; m_Pos.y = m_Input.m_TargetY; @@ -634,7 +655,7 @@ void CCharacter::TickDefered() m_Core.Write(&Current); // only allow dead reackoning for a top of 3 seconds - if(m_Core.m_pReset || m_ReckoningTick+Server()->TickSpeed()*3 < Server()->Tick() || mem_comp(&Predicted, &Current, sizeof(CNetObj_Character)) != 0) + if (m_Core.m_pReset || m_ReckoningTick + Server()->TickSpeed() * 3 < Server()->Tick() || mem_comp(&Predicted, &Current, sizeof(CNetObj_Character)) != 0) { m_ReckoningTick = Server()->Tick(); m_SendCore = m_Core; @@ -649,62 +670,64 @@ void CCharacter::TickPaused() ++m_AttackTick; ++m_DamageTakenTick; ++m_ReckoningTick; - if(m_LastAction != -1) + if (m_LastAction != -1) ++m_LastAction; - if(m_aWeapons[m_Core.m_ActiveWeapon].m_AmmoRegenStart > -1) + if (m_aWeapons[m_Core.m_ActiveWeapon].m_AmmoRegenStart > -1) ++m_aWeapons[m_Core.m_ActiveWeapon].m_AmmoRegenStart; - if(m_EmoteStop > -1) + if (m_EmoteStop > -1) ++m_EmoteStop; } void CCharacter::ExperienceAdd(int Exp, int ClientID) { - CPlayer* pPlayer = GameServer()->m_apPlayers[ClientID]; - if(m_pPlayer) pPlayer->m_AccData.m_Exp += m_pPlayer->m_AccData.m_Freeze?0:Exp; - else pPlayer->m_AccData.m_Exp += Exp; - - if (pPlayer->m_AccData.m_Exp >= pPlayer->m_AccData.m_Level && pPlayer && GameServer()->GetPlayerChar(ClientID)) + CPlayer *pPlayer = GameServer()->m_apPlayers[ClientID]; + if (m_pPlayer) + pPlayer->m_AccData.m_Exp += m_pPlayer->m_AccData.m_Freeze ? 0 : Exp; + else + pPlayer->m_AccData.m_Exp += Exp; + + if (pPlayer->m_AccData.m_Exp >= pPlayer->ExpNeedToNextLvl() && pPlayer && GameServer()->GetPlayerChar(ClientID)) { m_EmoteType = EMOTE_HAPPY, m_EmoteStop = Server()->Tick() + Server()->TickSpeed(); } else { char SendExp[64]; - str_format(SendExp, sizeof(SendExp), "经验 %d/%d", pPlayer->m_AccData.m_Exp, pPlayer->m_AccData.m_Level); + str_format(SendExp, sizeof(SendExp), "经验 %d/%d", pPlayer->m_AccData.m_Exp, pPlayer->ExpNeedToNextLvl()); GameServer()->SendChatTarget(ClientID, SendExp); } } bool CCharacter::IncreaseHealth(int Amount) { - if(m_Health >= 12000) + if (m_Health >= 12000) return false; - m_Health = clamp(m_Health+Amount, 0, 12000); + m_Health = clamp(m_Health + Amount, 0, 12000); return true; } bool CCharacter::IncreaseArmor(int Amount) { - if(m_Armor >= 10) + if (m_Armor >= 10) return false; - m_Armor = clamp(m_Armor+Amount, 0, 10); + m_Armor = clamp(m_Armor + Amount, 0, 10); return true; } void CCharacter::Die(int Killer, int Weapon) { - m_pPlayer->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()/2; + m_pPlayer->m_RespawnTick = Server()->Tick() + Server()->TickSpeed() / 2; int ModeSpecial = GameServer()->m_pController->OnCharacterDeath(this, GameServer()->m_apPlayers[Killer], Weapon); char aBuf[128]; str_format(aBuf, sizeof(aBuf), "kill killer='%d:%s' victim='%d:%s' weapon=%d special=%d", - Killer, Server()->ClientName(Killer), - m_pPlayer->GetCID(), Server()->ClientName(m_pPlayer->GetCID()), Weapon, ModeSpecial); + Killer, Server()->ClientName(Killer), + m_pPlayer->GetCID(), Server()->ClientName(m_pPlayer->GetCID()), Weapon, ModeSpecial); GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); if (m_pPlayer->GetTeam() == TEAM_BLUE) { - if(GameServer()->m_pController->ZombStarted() && !GameServer()->m_pController->m_Warmup) + if (GameServer()->m_pController->ZombStarted() && !GameServer()->m_pController->m_Warmup) m_pPlayer->SetZomb(m_pPlayer->GetCID()); } else @@ -718,7 +741,7 @@ void CCharacter::Die(int Killer, int Weapon) } GameServer()->CreateSound(m_Pos, SOUND_PLAYER_DIE, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); m_pPlayer->m_DieTick = Server()->Tick(); - + m_Alive = false; GameServer()->m_World.RemoveEntity(this); GameServer()->m_World.m_Core.m_apCharacters[m_pPlayer->GetCID()] = 0; @@ -727,28 +750,28 @@ void CCharacter::Die(int Killer, int Weapon) bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon) { - if(From == m_pPlayer->GetCID() && m_pPlayer->GetTeam() == TEAM_BLUE && g_Config.m_SvJumpGrenadeHuman) + if (From == m_pPlayer->GetCID() && m_pPlayer->GetTeam() == TEAM_BLUE && g_Config.m_SvJumpGrenadeHuman) m_Core.m_Vel += Force; if (m_pPlayer->GetTeam() == TEAM_BLUE) return false; if (Weapon == WEAPON_SHOTGUN) - m_Core.m_Vel += Force*3.60f; + m_Core.m_Vel += Force * 3.60f; else if (Weapon == WEAPON_GUN) - m_Core.m_Vel += Force*0.50f; + m_Core.m_Vel += Force * 0.50f; else if (Weapon == WEAPON_GRENADE) - m_Core.m_Vel += Force*2.10f; - else + m_Core.m_Vel += Force * 2.10f; + else m_Core.m_Vel += Force; - if(GameServer()->m_pController->IsFriendlyFire(m_pPlayer->GetCID(), From)) + if (GameServer()->m_pController->IsFriendlyFire(m_pPlayer->GetCID(), From)) return false; m_DamageTaken++; - if(Server()->Tick() < m_DamageTakenTick+25) - GameServer()->CreateDamageInd(m_Pos, m_DamageTaken*0.25f, (Dmg > 50) ? 25 : Dmg); + if (Server()->Tick() < m_DamageTakenTick + 25) + GameServer()->CreateDamageInd(m_Pos, m_DamageTaken * 0.25f, (Dmg > 50) ? 25 : Dmg); else { m_DamageTaken = 0; @@ -757,40 +780,42 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon) if (Dmg) m_Health -= Dmg; - + m_DamageTakenTick = Server()->Tick(); - if(From >= 0 && From != m_pPlayer->GetCID() && GameServer()->m_apPlayers[From]) + if (From >= 0 && From != m_pPlayer->GetCID() && GameServer()->m_apPlayers[From]) { int64_t Mask = CmaskOne(From); - for(int i = 0; i < MAX_CLIENTS; i++) + for (int i = 0; i < MAX_CLIENTS; i++) { - if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS && GameServer()->m_apPlayers[i]->m_SpectatorID == From) + if (GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS && GameServer()->m_apPlayers[i]->m_SpectatorID == From) Mask |= CmaskOne(i); } GameServer()->CreateSound(GameServer()->m_apPlayers[From]->m_ViewPos, SOUND_HIT, Mask); } - if(m_Health <= 0) + if (m_Health <= 0) { if (From >= 0 && m_pPlayer->GetCID() != From && GameServer()->m_apPlayers[From]) { ExperienceAdd(3 + m_pPlayer->m_AccData.m_Level / 40 * g_Config.m_SvExpBonus, From); GameServer()->m_apPlayers[From]->m_KillingSpree++; - if(GameServer()->m_apPlayers[From]->m_KillingSpree == g_Config.m_SvKillingSpree) + if (GameServer()->m_apPlayers[From]->m_KillingSpree == g_Config.m_SvKillingSpree) { char aBuf[48]; str_format(aBuf, sizeof(aBuf), "%s is on killing spree!", Server()->ClientName(From)); GameServer()->SendChatTarget(-1, aBuf); } } - + Die(From, Weapon); return false; } - if (Dmg > 2) GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_LONG); - else GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_SHORT); + if (Dmg > 2) + GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_LONG); + else + GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_SHORT); m_EmoteType = EMOTE_PAIN; m_EmoteStop = Server()->Tick() + 500 * Server()->TickSpeed() / 1000; @@ -812,24 +837,24 @@ void CCharacter::Snap(int SnappingClient) { int id = m_pPlayer->GetCID(); - if(SnappingClient > -1 && !Server()->Translate(id, SnappingClient)) + if (SnappingClient > -1 && !Server()->Translate(id, SnappingClient)) return; - if(NetworkClipped(SnappingClient)) + if (NetworkClipped(SnappingClient)) return; - - if(SnappingClient > -1) + + if (SnappingClient > -1) { - CCharacter* SnapChar = GameServer()->GetPlayerChar(SnappingClient); - CPlayer* SnapPlayer = GameServer()->m_apPlayers[SnappingClient]; + CCharacter *SnapChar = GameServer()->GetPlayerChar(SnappingClient); + CPlayer *SnapPlayer = GameServer()->m_apPlayers[SnappingClient]; - if(SnapPlayer->GetTeam() == TEAM_SPECTATORS && SnapPlayer->m_SpectatorID != -1 && !CanCollide(SnapPlayer->m_SpectatorID) && !SnapPlayer->m_ShowOthers) + if (SnapPlayer->GetTeam() == TEAM_SPECTATORS && SnapPlayer->m_SpectatorID != -1 && !CanCollide(SnapPlayer->m_SpectatorID) && !SnapPlayer->m_ShowOthers) return; - if(SnapPlayer->GetTeam() != TEAM_SPECTATORS && SnapChar && !CanCollide(SnappingClient) && !SnapPlayer->m_ShowOthers) + if (SnapPlayer->GetTeam() != TEAM_SPECTATORS && SnapChar && !CanCollide(SnappingClient) && !SnapPlayer->m_ShowOthers) return; - if(SnapPlayer->GetTeam() == TEAM_SPECTATORS && SnapPlayer->m_SpectatorID == -1 && !CanCollide(SnappingClient) && SnapPlayer->m_SpecTeam) + if (SnapPlayer->GetTeam() == TEAM_SPECTATORS && SnapPlayer->m_SpectatorID == -1 && !CanCollide(SnappingClient) && SnapPlayer->m_SpecTeam) return; } @@ -839,10 +864,10 @@ void CCharacter::Snap(int SnappingClient) if (m_iVisible && GetPlayer()->GetCID() != SnappingClient) return; - if(IhammerTick && SnappingClient == m_pPlayer->GetCID()) + if (IhammerTick && SnappingClient == m_pPlayer->GetCID()) { CNetObj_Pickup *pP = static_cast(Server()->SnapNewItem(NETOBJTYPE_PICKUP, m_InvisID, sizeof(CNetObj_Pickup))); - if(!pP) + if (!pP) return; pP->m_X = (int)m_Pos.x; @@ -850,13 +875,13 @@ void CCharacter::Snap(int SnappingClient) pP->m_Type = POWERUP_ARMOR; pP->m_Subtype = 0; } - + CNetObj_Character *pCharacter = static_cast(Server()->SnapNewItem(NETOBJTYPE_CHARACTER, id, sizeof(CNetObj_Character))); - if(!pCharacter) + if (!pCharacter) return; - + // write down the m_Core - if(!m_ReckoningTick || GameServer()->m_World.m_Paused) + if (!m_ReckoningTick || GameServer()->m_World.m_Paused) { // no dead reckoning when paused because the client doesn't know // how far to perform the reckoning @@ -890,82 +915,87 @@ void CCharacter::Snap(int SnappingClient) pCharacter->m_Health = 0; pCharacter->m_Armor = 0; - if(m_pPlayer->GetCID() == SnappingClient || SnappingClient == -1 || + if (m_pPlayer->GetCID() == SnappingClient || SnappingClient == -1 || (!g_Config.m_SvStrictSpectateMode && m_pPlayer->GetCID() == GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID)) { pCharacter->m_Health = m_Health; pCharacter->m_Armor = m_Armor; - if(m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo > 0) + if (m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo > 0) pCharacter->m_AmmoCount = m_aWeapons[m_Core.m_ActiveWeapon].m_Ammo; } if (GetPlayer()->m_Afk) pCharacter->m_Emote = EMOTE_BLINK; - if(GetPlayer()->m_RangeShop) + if (GetPlayer()->m_RangeShop) pCharacter->m_Emote = EMOTE_ANGRY; if (GetPlayer()->m_AccData.m_Freeze) { if (pCharacter->m_Emote == EMOTE_NORMAL) pCharacter->m_Emote = EMOTE_BLINK; - + pCharacter->m_Weapon = WEAPON_NINJA; } - - if(pCharacter->m_Emote == EMOTE_NORMAL) + + if (pCharacter->m_Emote == EMOTE_NORMAL) { - if(250 - ((Server()->Tick() - m_LastAction)%(250)) < 5) + if (250 - ((Server()->Tick() - m_LastAction) % (250)) < 5) pCharacter->m_Emote = EMOTE_BLINK; } pCharacter->m_PlayerFlags = GetPlayer()->m_PlayerFlags; } -int CCharacter::NetworkClipped(int SnappingClient){ +int CCharacter::NetworkClipped(int SnappingClient) +{ return NetworkClipped(SnappingClient, m_Pos); } int CCharacter::NetworkClipped(int SnappingClient, vec2 CheckPos) { - if(SnappingClient == -1 || GameServer()->m_apPlayers[SnappingClient]->m_ShowAll) + if (SnappingClient == -1 || GameServer()->m_apPlayers[SnappingClient]->m_ShowAll) return 0; - float dx = GameServer()->m_apPlayers[SnappingClient]->m_ViewPos.x-CheckPos.x; - float dy = GameServer()->m_apPlayers[SnappingClient]->m_ViewPos.y-CheckPos.y; + float dx = GameServer()->m_apPlayers[SnappingClient]->m_ViewPos.x - CheckPos.x; + float dy = GameServer()->m_apPlayers[SnappingClient]->m_ViewPos.y - CheckPos.y; - if(absolute(dx) > 1000.0f || absolute(dy) > 800.0f) + if (absolute(dx) > 1000.0f || absolute(dy) > 800.0f) return 1; - if(distance(GameServer()->m_apPlayers[SnappingClient]->m_ViewPos, CheckPos) > 4000.0f) + if (distance(GameServer()->m_apPlayers[SnappingClient]->m_ViewPos, CheckPos) > 4000.0f) return 1; return 0; } -bool CCharacter::CanCollide(int ClientID){ +bool CCharacter::CanCollide(int ClientID) +{ return Teams()->m_Core.CanCollide(GetPlayer()->GetCID(), ClientID); } -bool CCharacter::SameTeam(int ClientID){ +bool CCharacter::SameTeam(int ClientID) +{ return Teams()->m_Core.SameTeam(GetPlayer()->GetCID(), ClientID); } -int CCharacter::Team(){ +int CCharacter::Team() +{ return Teams()->m_Core.Team(m_pPlayer->GetCID()); } -CGameTeams* CCharacter::Teams(){ - return &((CGameControllerDDRace*)GameServer()->m_pController)->m_Teams; +CGameTeams *CCharacter::Teams() +{ + return &((CGameControllerDDRace *)GameServer()->m_pController)->m_Teams; } void CCharacter::HandleSkippableTiles(int Index) { // handle death-tiles and leaving gamelayer - if((GameServer()->Collision()->GetCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH || - GameServer()->Collision()->GetCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y+m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH || - GameServer()->Collision()->GetCollisionAt(m_Pos.x-m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH || - GameServer()->Collision()->GetFCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH || - GameServer()->Collision()->GetFCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y+m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH || - GameServer()->Collision()->GetFCollisionAt(m_Pos.x-m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH || - GameServer()->Collision()->GetCollisionAt(m_Pos.x-m_ProximityRadius/3.f, m_Pos.y+m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH)) + if ((GameServer()->Collision()->GetCollisionAt(m_Pos.x + m_ProximityRadius / 3.f, m_Pos.y - m_ProximityRadius / 3.f) & CCollision::COLFLAG_DEATH || + GameServer()->Collision()->GetCollisionAt(m_Pos.x + m_ProximityRadius / 3.f, m_Pos.y + m_ProximityRadius / 3.f) & CCollision::COLFLAG_DEATH || + GameServer()->Collision()->GetCollisionAt(m_Pos.x - m_ProximityRadius / 3.f, m_Pos.y - m_ProximityRadius / 3.f) & CCollision::COLFLAG_DEATH || + GameServer()->Collision()->GetFCollisionAt(m_Pos.x + m_ProximityRadius / 3.f, m_Pos.y - m_ProximityRadius / 3.f) & CCollision::COLFLAG_DEATH || + GameServer()->Collision()->GetFCollisionAt(m_Pos.x + m_ProximityRadius / 3.f, m_Pos.y + m_ProximityRadius / 3.f) & CCollision::COLFLAG_DEATH || + GameServer()->Collision()->GetFCollisionAt(m_Pos.x - m_ProximityRadius / 3.f, m_Pos.y - m_ProximityRadius / 3.f) & CCollision::COLFLAG_DEATH || + GameServer()->Collision()->GetCollisionAt(m_Pos.x - m_ProximityRadius / 3.f, m_Pos.y + m_ProximityRadius / 3.f) & CCollision::COLFLAG_DEATH)) { Die(m_pPlayer->GetCID(), WEAPON_WORLD); return; @@ -977,57 +1007,58 @@ void CCharacter::HandleSkippableTiles(int Index) return; } - if(Index < 0) + if (Index < 0) return; // handle speedup tiles - if(GameServer()->Collision()->IsSpeedup(Index)) + if (GameServer()->Collision()->IsSpeedup(Index)) { vec2 Direction, MaxVel, TempVel = m_Core.m_Vel; int Force, MaxSpeed = 0; float TeeAngle, SpeederAngle, DiffAngle, SpeedLeft, TeeSpeed; GameServer()->Collision()->GetSpeedup(Index, &Direction, &Force, &MaxSpeed); - if(Force == 255 && MaxSpeed) + if (Force == 255 && MaxSpeed) { - m_Core.m_Vel = Direction * (MaxSpeed/5); + m_Core.m_Vel = Direction * (MaxSpeed / 5); } else { - if(MaxSpeed > 0 && MaxSpeed < 5) MaxSpeed = 5; - //dbg_msg("speedup tile start","Direction %f %f, Force %d, Max Speed %d", (Direction).x,(Direction).y, Force, MaxSpeed); - if(MaxSpeed > 0) + if (MaxSpeed > 0 && MaxSpeed < 5) + MaxSpeed = 5; + // dbg_msg("speedup tile start","Direction %f %f, Force %d, Max Speed %d", (Direction).x,(Direction).y, Force, MaxSpeed); + if (MaxSpeed > 0) { - if(Direction.x > 0.0000001f) + if (Direction.x > 0.0000001f) SpeederAngle = -atan(Direction.y / Direction.x); - else if(Direction.x < 0.0000001f) + else if (Direction.x < 0.0000001f) SpeederAngle = atan(Direction.y / Direction.x) + 2.0f * asin(1.0f); - else if(Direction.y > 0.0000001f) + else if (Direction.y > 0.0000001f) SpeederAngle = asin(1.0f); else SpeederAngle = asin(-1.0f); - if(SpeederAngle < 0) + if (SpeederAngle < 0) SpeederAngle = 4.0f * asin(1.0f) + SpeederAngle; - if(TempVel.x > 0.0000001f) + if (TempVel.x > 0.0000001f) TeeAngle = -atan(TempVel.y / TempVel.x); - else if(TempVel.x < 0.0000001f) + else if (TempVel.x < 0.0000001f) TeeAngle = atan(TempVel.y / TempVel.x) + 2.0f * asin(1.0f); - else if(TempVel.y > 0.0000001f) + else if (TempVel.y > 0.0000001f) TeeAngle = asin(1.0f); else TeeAngle = asin(-1.0f); - if(TeeAngle < 0) + if (TeeAngle < 0) TeeAngle = 4.0f * asin(1.0f) + TeeAngle; TeeSpeed = sqrt(pow(TempVel.x, 2) + pow(TempVel.y, 2)); DiffAngle = SpeederAngle - TeeAngle; SpeedLeft = MaxSpeed / 5.0f - cos(DiffAngle) * TeeSpeed; - if(abs((int)SpeedLeft) > Force && SpeedLeft > 0.0000001f) + if (abs((int)SpeedLeft) > Force && SpeedLeft > 0.0000001f) TempVel += Direction * Force; - else if(abs((int)SpeedLeft) > Force) + else if (abs((int)SpeedLeft) > Force) TempVel += Direction * -Force; else TempVel += Direction * SpeedLeft; @@ -1035,13 +1066,13 @@ void CCharacter::HandleSkippableTiles(int Index) else TempVel += Direction * Force; - if(TempVel.x > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_270) || (m_TileIndexL == TILE_STOP && m_TileFlagsL == ROTATION_270) || (m_TileIndexL == TILE_STOPS && (m_TileFlagsL == ROTATION_90 || m_TileFlagsL ==ROTATION_270)) || (m_TileIndexL == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_270) || (m_TileFIndexL == TILE_STOP && m_TileFFlagsL == ROTATION_270) || (m_TileFIndexL == TILE_STOPS && (m_TileFFlagsL == ROTATION_90 || m_TileFFlagsL == ROTATION_270)) || (m_TileFIndexL == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_270) || (m_TileSIndexL == TILE_STOP && m_TileSFlagsL == ROTATION_270) || (m_TileSIndexL == TILE_STOPS && (m_TileSFlagsL == ROTATION_90 || m_TileSFlagsL == ROTATION_270)) || (m_TileSIndexL == TILE_STOPA))) + if (TempVel.x > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_270) || (m_TileIndexL == TILE_STOP && m_TileFlagsL == ROTATION_270) || (m_TileIndexL == TILE_STOPS && (m_TileFlagsL == ROTATION_90 || m_TileFlagsL == ROTATION_270)) || (m_TileIndexL == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_270) || (m_TileFIndexL == TILE_STOP && m_TileFFlagsL == ROTATION_270) || (m_TileFIndexL == TILE_STOPS && (m_TileFFlagsL == ROTATION_90 || m_TileFFlagsL == ROTATION_270)) || (m_TileFIndexL == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_270) || (m_TileSIndexL == TILE_STOP && m_TileSFlagsL == ROTATION_270) || (m_TileSIndexL == TILE_STOPS && (m_TileSFlagsL == ROTATION_90 || m_TileSFlagsL == ROTATION_270)) || (m_TileSIndexL == TILE_STOPA))) TempVel.x = 0; - if(TempVel.x < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_90) || (m_TileIndexR == TILE_STOP && m_TileFlagsR == ROTATION_90) || (m_TileIndexR == TILE_STOPS && (m_TileFlagsR == ROTATION_90 || m_TileFlagsR == ROTATION_270)) || (m_TileIndexR == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_90) || (m_TileFIndexR == TILE_STOP && m_TileFFlagsR == ROTATION_90) || (m_TileFIndexR == TILE_STOPS && (m_TileFFlagsR == ROTATION_90 || m_TileFFlagsR == ROTATION_270)) || (m_TileFIndexR == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_90) || (m_TileSIndexR == TILE_STOP && m_TileSFlagsR == ROTATION_90) || (m_TileSIndexR == TILE_STOPS && (m_TileSFlagsR == ROTATION_90 || m_TileSFlagsR == ROTATION_270)) || (m_TileSIndexR == TILE_STOPA))) + if (TempVel.x < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_90) || (m_TileIndexR == TILE_STOP && m_TileFlagsR == ROTATION_90) || (m_TileIndexR == TILE_STOPS && (m_TileFlagsR == ROTATION_90 || m_TileFlagsR == ROTATION_270)) || (m_TileIndexR == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_90) || (m_TileFIndexR == TILE_STOP && m_TileFFlagsR == ROTATION_90) || (m_TileFIndexR == TILE_STOPS && (m_TileFFlagsR == ROTATION_90 || m_TileFFlagsR == ROTATION_270)) || (m_TileFIndexR == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_90) || (m_TileSIndexR == TILE_STOP && m_TileSFlagsR == ROTATION_90) || (m_TileSIndexR == TILE_STOPS && (m_TileSFlagsR == ROTATION_90 || m_TileSFlagsR == ROTATION_270)) || (m_TileSIndexR == TILE_STOPA))) TempVel.x = 0; - if(TempVel.y < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_180) || (m_TileIndexB == TILE_STOP && m_TileFlagsB == ROTATION_180) || (m_TileIndexB == TILE_STOPS && (m_TileFlagsB == ROTATION_0 || m_TileFlagsB == ROTATION_180)) || (m_TileIndexB == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_180) || (m_TileFIndexB == TILE_STOP && m_TileFFlagsB == ROTATION_180) || (m_TileFIndexB == TILE_STOPS && (m_TileFFlagsB == ROTATION_0 || m_TileFFlagsB == ROTATION_180)) || (m_TileFIndexB == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_180) || (m_TileSIndexB == TILE_STOP && m_TileSFlagsB == ROTATION_180) || (m_TileSIndexB == TILE_STOPS && (m_TileSFlagsB == ROTATION_0 || m_TileSFlagsB == ROTATION_180)) || (m_TileSIndexB == TILE_STOPA))) + if (TempVel.y < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_180) || (m_TileIndexB == TILE_STOP && m_TileFlagsB == ROTATION_180) || (m_TileIndexB == TILE_STOPS && (m_TileFlagsB == ROTATION_0 || m_TileFlagsB == ROTATION_180)) || (m_TileIndexB == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_180) || (m_TileFIndexB == TILE_STOP && m_TileFFlagsB == ROTATION_180) || (m_TileFIndexB == TILE_STOPS && (m_TileFFlagsB == ROTATION_0 || m_TileFFlagsB == ROTATION_180)) || (m_TileFIndexB == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_180) || (m_TileSIndexB == TILE_STOP && m_TileSFlagsB == ROTATION_180) || (m_TileSIndexB == TILE_STOPS && (m_TileSFlagsB == ROTATION_0 || m_TileSFlagsB == ROTATION_180)) || (m_TileSIndexB == TILE_STOPA))) TempVel.y = 0; - if(TempVel.y > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_0) || (m_TileIndexT == TILE_STOP && m_TileFlagsT == ROTATION_0) || (m_TileIndexT == TILE_STOPS && (m_TileFlagsT == ROTATION_0 || m_TileFlagsT == ROTATION_180)) || (m_TileIndexT == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_0) || (m_TileFIndexT == TILE_STOP && m_TileFFlagsT == ROTATION_0) || (m_TileFIndexT == TILE_STOPS && (m_TileFFlagsT == ROTATION_0 || m_TileFFlagsT == ROTATION_180)) || (m_TileFIndexT == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_0) || (m_TileSIndexT == TILE_STOP && m_TileSFlagsT == ROTATION_0) || (m_TileSIndexT == TILE_STOPS && (m_TileSFlagsT == ROTATION_0 || m_TileSFlagsT == ROTATION_180)) || (m_TileSIndexT == TILE_STOPA))) + if (TempVel.y > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_0) || (m_TileIndexT == TILE_STOP && m_TileFlagsT == ROTATION_0) || (m_TileIndexT == TILE_STOPS && (m_TileFlagsT == ROTATION_0 || m_TileFlagsT == ROTATION_180)) || (m_TileIndexT == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_0) || (m_TileFIndexT == TILE_STOP && m_TileFFlagsT == ROTATION_0) || (m_TileFIndexT == TILE_STOPS && (m_TileFFlagsT == ROTATION_0 || m_TileFFlagsT == ROTATION_180)) || (m_TileFIndexT == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_0) || (m_TileSIndexT == TILE_STOP && m_TileSFlagsT == ROTATION_0) || (m_TileSIndexT == TILE_STOPS && (m_TileSFlagsT == ROTATION_0 || m_TileSFlagsT == ROTATION_180)) || (m_TileSIndexT == TILE_STOPA))) TempVel.y = 0; m_Core.m_Vel = TempVel; } @@ -1050,7 +1081,7 @@ void CCharacter::HandleSkippableTiles(int Index) void CCharacter::HandleTiles(int Index) { - CGameControllerDDRace* Controller = (CGameControllerDDRace*)GameServer()->m_pController; + CGameControllerDDRace *Controller = (CGameControllerDDRace *)GameServer()->m_pController; int MapIndex = Index; float Offset = 4.0f; int MapIndexL = GameServer()->Collision()->GetPureMapIndex(vec2(m_Pos.x + (m_ProximityRadius / 2) + Offset, m_Pos.y)); @@ -1076,9 +1107,9 @@ void CCharacter::HandleTiles(int Index) m_TileFIndexB = GameServer()->Collision()->GetFTileIndex(MapIndexB); m_TileFFlagsB = GameServer()->Collision()->GetFTileFlags(MapIndexB); m_TileFIndexT = GameServer()->Collision()->GetFTileIndex(MapIndexT); - m_TileFFlagsT = GameServer()->Collision()->GetFTileFlags(MapIndexT);// - //dbg_msg("Tiles","%d, %d, %d, %d, %d", m_TileSIndex, m_TileSIndexL, m_TileSIndexR, m_TileSIndexB, m_TileSIndexT); - //Sensitivity + m_TileFFlagsT = GameServer()->Collision()->GetFTileFlags(MapIndexT); // + // dbg_msg("Tiles","%d, %d, %d, %d, %d", m_TileSIndex, m_TileSIndexL, m_TileSIndexR, m_TileSIndexB, m_TileSIndexT); + // Sensitivity int S1 = GameServer()->Collision()->GetPureMapIndex(vec2(m_Pos.x + m_ProximityRadius / 3.f, m_Pos.y - m_ProximityRadius / 3.f)); int S2 = GameServer()->Collision()->GetPureMapIndex(vec2(m_Pos.x + m_ProximityRadius / 3.f, m_Pos.y + m_ProximityRadius / 3.f)); int S3 = GameServer()->Collision()->GetPureMapIndex(vec2(m_Pos.x - m_ProximityRadius / 3.f, m_Pos.y - m_ProximityRadius / 3.f)); @@ -1091,27 +1122,27 @@ void CCharacter::HandleTiles(int Index) int FTile2 = GameServer()->Collision()->GetFTileIndex(S2); int FTile3 = GameServer()->Collision()->GetFTileIndex(S3); int FTile4 = GameServer()->Collision()->GetFTileIndex(S4); - if(Index < 0) + if (Index < 0) { m_iVisible = false; m_LastRefillJumps = false; return; } int tcp = GameServer()->Collision()->IsTCheckpoint(MapIndex); - if(tcp) + if (tcp) m_TeleCheckpoint = tcp; - if(m_TileIndex >= TILE_HOLDPOINT_BEGIN && m_TileIndex <= TILE_HOLDPOINT_END) - GameServer()->m_pController->OnHoldpoint(m_TileIndex-TILE_HOLDPOINT_BEGIN); - else if(m_TileIndex >= TILE_ZSTOP_BEGIN && m_TileIndex <= TILE_ZSTOP_END && m_pPlayer->GetTeam() == TEAM_BLUE) - GameServer()->m_pController->OnZStop(m_TileIndex-TILE_ZSTOP_BEGIN); - else if(m_TileIndex >= TILE_ZHOLDPOINT_BEGIN && m_TileIndex <= TILE_ZHOLDPOINT_END && m_pPlayer->GetTeam() == TEAM_BLUE) - GameServer()->m_pController->OnZHoldpoint(m_TileIndex-TILE_ZHOLDPOINT_BEGIN+32); + if (m_TileIndex >= TILE_HOLDPOINT_BEGIN && m_TileIndex <= TILE_HOLDPOINT_END) + GameServer()->m_pController->OnHoldpoint(m_TileIndex - TILE_HOLDPOINT_BEGIN); + else if (m_TileIndex >= TILE_ZSTOP_BEGIN && m_TileIndex <= TILE_ZSTOP_END && m_pPlayer->GetTeam() == TEAM_BLUE) + GameServer()->m_pController->OnZStop(m_TileIndex - TILE_ZSTOP_BEGIN); + else if (m_TileIndex >= TILE_ZHOLDPOINT_BEGIN && m_TileIndex <= TILE_ZHOLDPOINT_END && m_pPlayer->GetTeam() == TEAM_BLUE) + GameServer()->m_pController->OnZHoldpoint(m_TileIndex - TILE_ZHOLDPOINT_BEGIN + 32); // unlimited air jumps - if(((m_TileIndex == TILE_SUPER_START) || (m_TileFIndex == TILE_SUPER_START)) && !m_SuperJump) + if (((m_TileIndex == TILE_SUPER_START) || (m_TileFIndex == TILE_SUPER_START)) && !m_SuperJump) { - GameServer()->SendChatTarget(GetPlayer()->GetCID(),"你获得了无限的跳跃"); + GameServer()->SendChatTarget(GetPlayer()->GetCID(), _("你获得了无限的跳跃")); m_SuperJump = true; if (m_Core.m_Jumps == 0) { @@ -1119,9 +1150,9 @@ void CCharacter::HandleTiles(int Index) GameServer()->SendTuningParams(m_pPlayer->GetCID(), m_TuneZone); // update tunings } } - else if(((m_TileIndex == TILE_SUPER_END) || (m_TileFIndex == TILE_SUPER_END)) && m_SuperJump) + else if (((m_TileIndex == TILE_SUPER_END) || (m_TileFIndex == TILE_SUPER_END)) && m_SuperJump) { - GameServer()->SendChatTarget(GetPlayer()->GetCID(), "你失去了无限跳."); + GameServer()->SendChatTarget(GetPlayer()->GetCID(), _("你失去了无限跳.")); m_SuperJump = false; if (m_Core.m_Jumps == 0) { @@ -1131,9 +1162,9 @@ void CCharacter::HandleTiles(int Index) } // walljump - if((m_TileIndex == TILE_WALLJUMP) || (m_TileFIndex == TILE_WALLJUMP)) + if ((m_TileIndex == TILE_WALLJUMP) || (m_TileFIndex == TILE_WALLJUMP)) { - if(m_Core.m_Vel.y > 0 && m_Core.m_Colliding && m_Core.m_LeftWall) + if (m_Core.m_Vel.y > 0 && m_Core.m_Colliding && m_Core.m_LeftWall) { m_Core.m_LeftWall = false; m_Core.m_JumpedTotal = m_Core.m_Jumps - 1; @@ -1142,47 +1173,47 @@ void CCharacter::HandleTiles(int Index) } // refill jumps - if(((m_TileIndex == TILE_REFILL_JUMPS) || (m_TileFIndex == TILE_REFILL_JUMPS)) && !m_LastRefillJumps) + if (((m_TileIndex == TILE_REFILL_JUMPS) || (m_TileFIndex == TILE_REFILL_JUMPS)) && !m_LastRefillJumps) { m_Core.m_JumpedTotal = 0; m_Core.m_Jumped = 0; m_LastRefillJumps = true; } - if((m_TileIndex != TILE_REFILL_JUMPS) && (m_TileFIndex != TILE_REFILL_JUMPS)) + if ((m_TileIndex != TILE_REFILL_JUMPS) && (m_TileFIndex != TILE_REFILL_JUMPS)) m_LastRefillJumps = false; // no visible - if(((m_TileIndex == TILE_VISIBLE) || (m_TileFIndex == TILE_VISIBLE)) && !m_iVisible) + if (((m_TileIndex == TILE_VISIBLE) || (m_TileFIndex == TILE_VISIBLE)) && !m_iVisible) m_iVisible = true; - if((m_TileIndex != TILE_VISIBLE) && (m_TileFIndex != TILE_VISIBLE) && m_iVisible) + if ((m_TileIndex != TILE_VISIBLE) && (m_TileFIndex != TILE_VISIBLE) && m_iVisible) m_iVisible = false; - + // stopper - if(((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_270) || (m_TileIndexL == TILE_STOP && m_TileFlagsL == ROTATION_270) || (m_TileIndexL == TILE_STOPS && (m_TileFlagsL == ROTATION_90 || m_TileFlagsL ==ROTATION_270)) || (m_TileIndexL == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_270) || (m_TileFIndexL == TILE_STOP && m_TileFFlagsL == ROTATION_270) || (m_TileFIndexL == TILE_STOPS && (m_TileFFlagsL == ROTATION_90 || m_TileFFlagsL == ROTATION_270)) || (m_TileFIndexL == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_270) || (m_TileSIndexL == TILE_STOP && m_TileSFlagsL == ROTATION_270) || (m_TileSIndexL == TILE_STOPS && (m_TileSFlagsL == ROTATION_90 || m_TileSFlagsL == ROTATION_270)) || (m_TileSIndexL == TILE_STOPA)) && m_Core.m_Vel.x > 0) + if (((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_270) || (m_TileIndexL == TILE_STOP && m_TileFlagsL == ROTATION_270) || (m_TileIndexL == TILE_STOPS && (m_TileFlagsL == ROTATION_90 || m_TileFlagsL == ROTATION_270)) || (m_TileIndexL == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_270) || (m_TileFIndexL == TILE_STOP && m_TileFFlagsL == ROTATION_270) || (m_TileFIndexL == TILE_STOPS && (m_TileFFlagsL == ROTATION_90 || m_TileFFlagsL == ROTATION_270)) || (m_TileFIndexL == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_270) || (m_TileSIndexL == TILE_STOP && m_TileSFlagsL == ROTATION_270) || (m_TileSIndexL == TILE_STOPS && (m_TileSFlagsL == ROTATION_90 || m_TileSFlagsL == ROTATION_270)) || (m_TileSIndexL == TILE_STOPA)) && m_Core.m_Vel.x > 0) { - if((int)GameServer()->Collision()->GetPos(MapIndexL).x) - if((int)GameServer()->Collision()->GetPos(MapIndexL).x < (int)m_Core.m_Pos.x) + if ((int)GameServer()->Collision()->GetPos(MapIndexL).x) + if ((int)GameServer()->Collision()->GetPos(MapIndexL).x < (int)m_Core.m_Pos.x) m_Core.m_Pos = m_PrevPos; m_Core.m_Vel.x = 0; } - if(((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_90) || (m_TileIndexR == TILE_STOP && m_TileFlagsR == ROTATION_90) || (m_TileIndexR == TILE_STOPS && (m_TileFlagsR == ROTATION_90 || m_TileFlagsR == ROTATION_270)) || (m_TileIndexR == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_90) || (m_TileFIndexR == TILE_STOP && m_TileFFlagsR == ROTATION_90) || (m_TileFIndexR == TILE_STOPS && (m_TileFFlagsR == ROTATION_90 || m_TileFFlagsR == ROTATION_270)) || (m_TileFIndexR == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_90) || (m_TileSIndexR == TILE_STOP && m_TileSFlagsR == ROTATION_90) || (m_TileSIndexR == TILE_STOPS && (m_TileSFlagsR == ROTATION_90 || m_TileSFlagsR == ROTATION_270)) || (m_TileSIndexR == TILE_STOPA)) && m_Core.m_Vel.x < 0) + if (((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_90) || (m_TileIndexR == TILE_STOP && m_TileFlagsR == ROTATION_90) || (m_TileIndexR == TILE_STOPS && (m_TileFlagsR == ROTATION_90 || m_TileFlagsR == ROTATION_270)) || (m_TileIndexR == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_90) || (m_TileFIndexR == TILE_STOP && m_TileFFlagsR == ROTATION_90) || (m_TileFIndexR == TILE_STOPS && (m_TileFFlagsR == ROTATION_90 || m_TileFFlagsR == ROTATION_270)) || (m_TileFIndexR == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_90) || (m_TileSIndexR == TILE_STOP && m_TileSFlagsR == ROTATION_90) || (m_TileSIndexR == TILE_STOPS && (m_TileSFlagsR == ROTATION_90 || m_TileSFlagsR == ROTATION_270)) || (m_TileSIndexR == TILE_STOPA)) && m_Core.m_Vel.x < 0) { - if((int)GameServer()->Collision()->GetPos(MapIndexR).x) - if((int)GameServer()->Collision()->GetPos(MapIndexR).x > (int)m_Core.m_Pos.x) + if ((int)GameServer()->Collision()->GetPos(MapIndexR).x) + if ((int)GameServer()->Collision()->GetPos(MapIndexR).x > (int)m_Core.m_Pos.x) m_Core.m_Pos = m_PrevPos; m_Core.m_Vel.x = 0; } - if(((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_180) || (m_TileIndexB == TILE_STOP && m_TileFlagsB == ROTATION_180) || (m_TileIndexB == TILE_STOPS && (m_TileFlagsB == ROTATION_0 || m_TileFlagsB == ROTATION_180)) || (m_TileIndexB == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_180) || (m_TileFIndexB == TILE_STOP && m_TileFFlagsB == ROTATION_180) || (m_TileFIndexB == TILE_STOPS && (m_TileFFlagsB == ROTATION_0 || m_TileFFlagsB == ROTATION_180)) || (m_TileFIndexB == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_180) || (m_TileSIndexB == TILE_STOP && m_TileSFlagsB == ROTATION_180) || (m_TileSIndexB == TILE_STOPS && (m_TileSFlagsB == ROTATION_0 || m_TileSFlagsB == ROTATION_180)) || (m_TileSIndexB == TILE_STOPA)) && m_Core.m_Vel.y < 0) + if (((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_180) || (m_TileIndexB == TILE_STOP && m_TileFlagsB == ROTATION_180) || (m_TileIndexB == TILE_STOPS && (m_TileFlagsB == ROTATION_0 || m_TileFlagsB == ROTATION_180)) || (m_TileIndexB == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_180) || (m_TileFIndexB == TILE_STOP && m_TileFFlagsB == ROTATION_180) || (m_TileFIndexB == TILE_STOPS && (m_TileFFlagsB == ROTATION_0 || m_TileFFlagsB == ROTATION_180)) || (m_TileFIndexB == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_180) || (m_TileSIndexB == TILE_STOP && m_TileSFlagsB == ROTATION_180) || (m_TileSIndexB == TILE_STOPS && (m_TileSFlagsB == ROTATION_0 || m_TileSFlagsB == ROTATION_180)) || (m_TileSIndexB == TILE_STOPA)) && m_Core.m_Vel.y < 0) { - if((int)GameServer()->Collision()->GetPos(MapIndexB).y) - if((int)GameServer()->Collision()->GetPos(MapIndexB).y > (int)m_Core.m_Pos.y) + if ((int)GameServer()->Collision()->GetPos(MapIndexB).y) + if ((int)GameServer()->Collision()->GetPos(MapIndexB).y > (int)m_Core.m_Pos.y) m_Core.m_Pos = m_PrevPos; m_Core.m_Vel.y = 0; } - if(((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_0) || (m_TileIndexT == TILE_STOP && m_TileFlagsT == ROTATION_0) || (m_TileIndexT == TILE_STOPS && (m_TileFlagsT == ROTATION_0 || m_TileFlagsT == ROTATION_180)) || (m_TileIndexT == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_0) || (m_TileFIndexT == TILE_STOP && m_TileFFlagsT == ROTATION_0) || (m_TileFIndexT == TILE_STOPS && (m_TileFFlagsT == ROTATION_0 || m_TileFFlagsT == ROTATION_180)) || (m_TileFIndexT == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_0) || (m_TileSIndexT == TILE_STOP && m_TileSFlagsT == ROTATION_0) || (m_TileSIndexT == TILE_STOPS && (m_TileSFlagsT == ROTATION_0 || m_TileSFlagsT == ROTATION_180)) || (m_TileSIndexT == TILE_STOPA)) && m_Core.m_Vel.y > 0) + if (((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_0) || (m_TileIndexT == TILE_STOP && m_TileFlagsT == ROTATION_0) || (m_TileIndexT == TILE_STOPS && (m_TileFlagsT == ROTATION_0 || m_TileFlagsT == ROTATION_180)) || (m_TileIndexT == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_0) || (m_TileFIndexT == TILE_STOP && m_TileFFlagsT == ROTATION_0) || (m_TileFIndexT == TILE_STOPS && (m_TileFFlagsT == ROTATION_0 || m_TileFFlagsT == ROTATION_180)) || (m_TileFIndexT == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_0) || (m_TileSIndexT == TILE_STOP && m_TileSFlagsT == ROTATION_0) || (m_TileSIndexT == TILE_STOPS && (m_TileSFlagsT == ROTATION_0 || m_TileSFlagsT == ROTATION_180)) || (m_TileSIndexT == TILE_STOPA)) && m_Core.m_Vel.y > 0) { - if((int)GameServer()->Collision()->GetPos(MapIndexT).y) - if((int)GameServer()->Collision()->GetPos(MapIndexT).y < (int)m_Core.m_Pos.y) + if ((int)GameServer()->Collision()->GetPos(MapIndexT).y) + if ((int)GameServer()->Collision()->GetPos(MapIndexT).y < (int)m_Core.m_Pos.y) m_Core.m_Pos = m_PrevPos; m_Core.m_Vel.y = 0; m_Core.m_Jumped = 0; @@ -1190,34 +1221,34 @@ void CCharacter::HandleTiles(int Index) } int z = GameServer()->Collision()->IsTeleport(MapIndex); - if(!g_Config.m_SvOldTeleportHook && !g_Config.m_SvOldTeleportWeapons && z && Controller->m_TeleOuts[z-1].size()) + if (!g_Config.m_SvOldTeleportHook && !g_Config.m_SvOldTeleportWeapons && z && Controller->m_TeleOuts[z - 1].size()) { - int Num = Controller->m_TeleOuts[z-1].size(); - m_Core.m_Pos = Controller->m_TeleOuts[z-1][(!Num)?Num:rand() % Num]; - if(!g_Config.m_SvTeleportHoldHook) + int Num = Controller->m_TeleOuts[z - 1].size(); + m_Core.m_Pos = Controller->m_TeleOuts[z - 1][(!Num) ? Num : rand() % Num]; + if (!g_Config.m_SvTeleportHoldHook) { m_Core.m_HookedPlayer = -1; m_Core.m_HookState = HOOK_RETRACTED; m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT; m_Core.m_HookPos = m_Core.m_Pos; } - if(g_Config.m_SvTeleportLoseWeapons) + if (g_Config.m_SvTeleportLoseWeapons) { - for(int i=WEAPON_SHOTGUN;iCollision()->IsEvilTeleport(MapIndex); - if(evilz && Controller->m_TeleOuts[evilz-1].size()) + if (evilz && Controller->m_TeleOuts[evilz - 1].size()) { - int Num = Controller->m_TeleOuts[evilz-1].size(); - m_Core.m_Pos = Controller->m_TeleOuts[evilz-1][(!Num)?Num:rand() % Num]; + int Num = Controller->m_TeleOuts[evilz - 1].size(); + m_Core.m_Pos = Controller->m_TeleOuts[evilz - 1][(!Num) ? Num : rand() % Num]; if (!g_Config.m_SvOldTeleportHook && !g_Config.m_SvOldTeleportWeapons) { - m_Core.m_Vel = vec2(0,0); + m_Core.m_Vel = vec2(0, 0); - if(!g_Config.m_SvTeleportHoldHook) + if (!g_Config.m_SvTeleportHoldHook) { m_Core.m_HookedPlayer = -1; m_Core.m_HookState = HOOK_RETRACTED; @@ -1225,65 +1256,65 @@ void CCharacter::HandleTiles(int Index) GameWorld()->ReleaseHooked(GetPlayer()->GetCID()); m_Core.m_HookPos = m_Core.m_Pos; } - if(g_Config.m_SvTeleportLoseWeapons) + if (g_Config.m_SvTeleportLoseWeapons) { - for(int i=WEAPON_SHOTGUN;iCollision()->IsCheckEvilTeleport(MapIndex)) + if (GameServer()->Collision()->IsCheckEvilTeleport(MapIndex)) { // first check if there is a TeleCheckOut for the current recorded checkpoint, if not check previous checkpoints - for(int k=m_TeleCheckpoint-1; k >= 0; k--) + for (int k = m_TeleCheckpoint - 1; k >= 0; k--) { - if(Controller->m_TeleCheckOuts[k].size()) + if (Controller->m_TeleCheckOuts[k].size()) { m_Core.m_HookedPlayer = -1; m_Core.m_HookState = HOOK_RETRACTED; m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT; int Num = Controller->m_TeleCheckOuts[k].size(); - m_Core.m_Pos = Controller->m_TeleCheckOuts[k][(!Num)?Num:rand() % Num]; + m_Core.m_Pos = Controller->m_TeleCheckOuts[k][(!Num) ? Num : rand() % Num]; GameWorld()->ReleaseHooked(GetPlayer()->GetCID()); - m_Core.m_Vel = vec2(0,0); + m_Core.m_Vel = vec2(0, 0); m_Core.m_HookPos = m_Core.m_Pos; return; } } // if no checkpointout have been found (or if there no recorded checkpoint), teleport to start vec2 SpawnPos; - if(GameServer()->m_pController->CanSpawn(m_pPlayer->GetTeam(), &SpawnPos)) + if (GameServer()->m_pController->CanSpawn(m_pPlayer->GetTeam(), &SpawnPos)) { m_Core.m_HookedPlayer = -1; m_Core.m_HookState = HOOK_RETRACTED; m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT; m_Core.m_Pos = SpawnPos; GameWorld()->ReleaseHooked(GetPlayer()->GetCID()); - m_Core.m_Vel = vec2(0,0); + m_Core.m_Vel = vec2(0, 0); m_Core.m_HookPos = m_Core.m_Pos; } return; } - if(GameServer()->Collision()->IsCheckTeleport(MapIndex)) + if (GameServer()->Collision()->IsCheckTeleport(MapIndex)) { // first check if there is a TeleCheckOut for the current recorded checkpoint, if not check previous checkpoints - for(int k=m_TeleCheckpoint-1; k >= 0; k--) + for (int k = m_TeleCheckpoint - 1; k >= 0; k--) { - if(Controller->m_TeleCheckOuts[k].size()) + if (Controller->m_TeleCheckOuts[k].size()) { m_Core.m_HookedPlayer = -1; m_Core.m_HookState = HOOK_RETRACTED; m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT; int Num = Controller->m_TeleCheckOuts[k].size(); - m_Core.m_Pos = Controller->m_TeleCheckOuts[k][(!Num)?Num:rand() % Num]; + m_Core.m_Pos = Controller->m_TeleCheckOuts[k][(!Num) ? Num : rand() % Num]; m_Core.m_HookPos = m_Core.m_Pos; return; } } // if no checkpointout have been found (or if there no recorded checkpoint), teleport to start vec2 SpawnPos; - if(GameServer()->m_pController->CanSpawn(m_pPlayer->GetTeam(), &SpawnPos)) + if (GameServer()->m_pController->CanSpawn(m_pPlayer->GetTeam(), &SpawnPos)) { m_Core.m_HookedPlayer = -1; m_Core.m_HookState = HOOK_RETRACTED; @@ -1301,7 +1332,7 @@ void CCharacter::HandleTuneLayer() int CurrentIndex = GameServer()->Collision()->GetMapIndex(m_Pos); m_TuneZone = GameServer()->Collision()->IsTune(CurrentIndex); - if(m_TuneZone) + if (m_TuneZone) m_Core.m_pWorld->m_Tuning[g_Config.m_ClDummy] = GameServer()->TuningList()[m_TuneZone]; // throw tunings from specific zone into gamecore else m_Core.m_pWorld->m_Tuning[g_Config.m_ClDummy] = *GameServer()->Tuning(); @@ -1315,32 +1346,32 @@ void CCharacter::SendZoneMsgs() // send zone leave msg if (m_TuneZoneOld >= 0 && GameServer()->m_ZoneLeaveMsg[m_TuneZoneOld]) // m_TuneZoneOld >= 0: avoid zone leave msgs on spawn { - const char* cur = GameServer()->m_ZoneLeaveMsg[m_TuneZoneOld]; - const char* pos; + const char *cur = GameServer()->m_ZoneLeaveMsg[m_TuneZoneOld]; + const char *pos; while ((pos = str_find(cur, "\\n"))) { char aBuf[256]; str_copy(aBuf, cur, pos - cur + 1); aBuf[pos - cur + 1] = '\0'; cur = pos + 2; - GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _(aBuf)); } - GameServer()->SendChatTarget(m_pPlayer->GetCID(), cur); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _(cur)); } // send zone enter msg if (GameServer()->m_ZoneEnterMsg[m_TuneZone]) { - const char* cur = GameServer()->m_ZoneEnterMsg[m_TuneZone]; - const char* pos; + const char *cur = GameServer()->m_ZoneEnterMsg[m_TuneZone]; + const char *pos; while ((pos = str_find(cur, "\\n"))) { char aBuf[256]; str_copy(aBuf, cur, pos - cur + 1); aBuf[pos - cur + 1] = '\0'; cur = pos + 2; - GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _(aBuf)); } - GameServer()->SendChatTarget(m_pPlayer->GetCID(), cur); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _(cur)); } } @@ -1349,10 +1380,11 @@ void CCharacter::DDRaceTick() if (m_Input.m_Direction != 0 || m_Input.m_Jump != 0) m_LastMove = Server()->Tick(); - if (m_pPlayer->m_AccData.m_Freeze){ + if (m_pPlayer->m_AccData.m_Freeze) + { m_Input.m_Direction = m_Input.m_Jump = m_Input.m_Hook = 0; } - + HandleTuneLayer(); m_Core.m_Id = GetPlayer()->GetCID(); } @@ -1366,9 +1398,12 @@ void CCharacter::DDRacePostCoreTick() m_EmoteStop = -1; } - if (m_Core.m_Jumps == 0) m_Core.m_Jumped = 3; - else if (m_Core.m_Jumps == 1 && m_Core.m_Jumped > 0) m_Core.m_Jumped = 3; - else if (m_Core.m_JumpedTotal < m_Core.m_Jumps - 1 && m_Core.m_Jumped > 1) m_Core.m_Jumped = 1; + if (m_Core.m_Jumps == 0) + m_Core.m_Jumped = 3; + else if (m_Core.m_Jumps == 1 && m_Core.m_Jumped > 0) + m_Core.m_Jumped = 3; + else if (m_Core.m_JumpedTotal < m_Core.m_Jumps - 1 && m_Core.m_Jumped > 1) + m_Core.m_Jumped = 1; if (m_SuperJump && m_Core.m_Jumped > 1) m_Core.m_Jumped = 1; @@ -1376,10 +1411,10 @@ void CCharacter::DDRacePostCoreTick() int CurrentIndex = GameServer()->Collision()->GetMapIndex(m_Pos); HandleSkippableTiles(CurrentIndex); - std::list < int > Indices = GameServer()->Collision()->GetMapIndices(m_PrevPos, m_Pos); + std::list Indices = GameServer()->Collision()->GetMapIndices(m_PrevPos, m_Pos); if (!Indices.empty()) { - for (std::list < int >::iterator i = Indices.begin(); i != Indices.end(); i++) + for (std::list::iterator i = Indices.begin(); i != Indices.end(); i++) HandleTiles(*i); } else diff --git a/src/game/server/entities/cmds.cpp b/src/game/server/entities/cmds.cpp index 188d2b9..ff938c8 100644 --- a/src/game/server/entities/cmds.cpp +++ b/src/game/server/entities/cmds.cpp @@ -8,6 +8,8 @@ #include "account.h" #include "hearth.h" +#include + CCmd::CCmd(CPlayer *pPlayer, CGameContext *pGameServer) { m_pPlayer = pPlayer; @@ -16,46 +18,46 @@ CCmd::CCmd(CPlayer *pPlayer, CGameContext *pGameServer) void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) { - if(!strncmp(Msg->m_pMessage, "/login", 6)) + if (!strncmp(Msg->m_pMessage, "/login", 6)) { - LastChat(); - if(GameServer()->m_World.m_Paused) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "请等待此回合结束!"); + LastChat(); + if (GameServer()->m_World.m_Paused) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("请等待此回合结束!")); char Username[256], Password[256]; if(sscanf(Msg->m_pMessage, "/login %s %s", Username, Password) != 2) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "格式错误: /login <用户名> <密码>"); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("格式错误: /login <用户名> <密码>")); if(str_length(Username) > 15 || str_length(Username) < 4 || str_length(Password) > 15 || str_length(Password) < 4) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "提示:用户名 / 密码必须在4-15个字母内"); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("提示:用户名 / 密码必须在4-15个字母内")); m_pPlayer->m_pAccount->Login(Username, Password); return; } - - else if(!strncmp(Msg->m_pMessage, "/register", 9)) + + else if (!strncmp(Msg->m_pMessage, "/register", 9)) { LastChat(); - if(GameServer()->m_World.m_Paused) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "请等待此回合结束!"); + if (GameServer()->m_World.m_Paused) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("请等待此回合结束!")); char Username[256], Password[256]; if(sscanf(Msg->m_pMessage, "/register %s %s", Username, Password) != 2) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "格式错误:/register <用户名> <密码>"); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("格式错误:/register <用户名> <密码>")); if(str_length(Username) > 15 || str_length(Username) < 4 || str_length(Password) > 15 || str_length(Password) < 4) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "用户名和密码必须要有4-15个字母"); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("用户名和密码必须要有4-15个字母")); else if (!strcmp(Username, Password)) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "用户名和密码不能相同"); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("用户名和密码不能相同")); m_pPlayer->m_pAccount->Register(Username, Password); return; } - + else if (!strncmp(Msg->m_pMessage, "/sd", 3) && GameServer()->Server()->IsAuthed(m_pPlayer->GetCID())) { LastChat(); int size = 0; if ((sscanf(Msg->m_pMessage, "/sd %d", &size)) != 1) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "提示:/sd <声音ID>"); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("提示:/sd <声音ID>")); if (m_pPlayer->GetTeam() == TEAM_SPECTATORS || !GameServer()->GetPlayerChar(m_pPlayer->GetCID())) return; @@ -65,43 +67,43 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) return; } - else if(!strcmp(Msg->m_pMessage, "/logout")) + else if (!strcmp(Msg->m_pMessage, "/logout")) { LastChat(); - if(!m_pPlayer->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "你还没有登录!"); - if(GameServer()->m_World.m_Paused) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "请等待此回合结束"); - if (GameServer()->m_pController->NumZombs() == 1 && m_pPlayer->GetTeam() == TEAM_RED) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "作为第一只僵尸你不能退出登录"); - if (GameServer()->m_pController->NumPlayers() < 3 && GameServer()->m_pController->m_Warmup) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "请等待此回合开始!"); + if (!m_pPlayer->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("你还没有登录!")); + if(GameServer()->m_World.m_Paused) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("请等待此回合结束")); + if (GameServer()->m_pController->NumZombs() == 1 && m_pPlayer->GetTeam() == TEAM_RED) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("作为第一只僵尸你不能退出登录")); + if (GameServer()->m_pController->NumPlayers() < 3 && GameServer()->m_pController->m_Warmup) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("请等待此回合开始!")); m_pPlayer->m_pAccount->Apply(), m_pPlayer->m_pAccount->Reset(); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "退出登录!"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "使用/login <用户名> <密码> 重新登录"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("退出登录!")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("使用/login <用户名> <密码> 重新登录")); if(GameServer()->GetPlayerChar(m_pPlayer->GetCID()) && GameServer()->GetPlayerChar(m_pPlayer->GetCID())->IsAlive()) GameServer()->GetPlayerChar(m_pPlayer->GetCID())->Die(m_pPlayer->GetCID(), WEAPON_GAME); return; - } - + } + else if (!strncmp(Msg->m_pMessage, "/upgr", 5)) { LastChat(); - if (!m_pPlayer->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "你还没有登录! 输入 /account 获取帮助"); + if (!m_pPlayer->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("你还没有登录! 输入 /account 获取帮助")); char supgr[256], andg[64]; if (sscanf(Msg->m_pMessage, "/upgr %s", supgr) != 1) { - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "使用 /upgr , , , , , 来给你升级"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), " 是攻击力, 是血量, 是攻速(必升 超神), 是子弹恢复速度, 是子弹总数, 是显示当前全部等级"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("使用 /upgr , , , , , 来给你升级")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _(" 是攻击力, 是血量, 是攻速(必升 超神), 是子弹恢复速度, 是子弹总数, 是显示当前全部等级")); return; } if (!strcmp(supgr, "handle")) { - if (m_pPlayer->m_AccData.m_Handle >= 300) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "已达到最高等级 (300)."); + if (m_pPlayer->m_AccData.m_Handle >= 300) + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("已达到最高等级 (300).")); if (m_pPlayer->m_AccData.m_Money <= 0) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "升级点不足 (至少1点)."); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("升级点不足 (至少1点).")); m_pPlayer->m_AccData.m_Money--, m_pPlayer->m_AccData.m_Handle++; str_format(andg, sizeof(andg), "当前攻速: %d, 当前升级点: %d", m_pPlayer->m_AccData.m_Handle, m_pPlayer->m_AccData.m_Money); @@ -111,10 +113,10 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) } else if (!strcmp(supgr, "dmg")) { - if (m_pPlayer->m_AccData.m_Dmg >= 21) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "已经达到最高级 (21)."); + if (m_pPlayer->m_AccData.m_Dmg >= 21) + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("已经达到最高级 (21).")); if (m_pPlayer->m_AccData.m_Money <= 0) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "升级点不足 (至少1点)."); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("升级点不足 (至少1点).")); m_pPlayer->m_AccData.m_Money--, m_pPlayer->m_AccData.m_Dmg++; str_format(andg, sizeof(andg), "当前伤害: %d, 当前升级点: %d", m_pPlayer->m_AccData.m_Dmg, m_pPlayer->m_AccData.m_Money); @@ -124,10 +126,10 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) } else if (!strcmp(supgr, "hp")) { - if (m_pPlayer->m_AccData.m_Health >= 100) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "已达到最高血量 (100)."); + if (m_pPlayer->m_AccData.m_Health >= 100) + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("已达到最高血量 (100).")); if (m_pPlayer->m_AccData.m_Money <= 0) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "升级点不足 (至少1点)."); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("升级点不足 (至少1点).")); m_pPlayer->m_AccData.m_Money--, m_pPlayer->m_AccData.m_Health++; str_format(andg, sizeof(andg), "当前血量: %d, 最高血量: %d, 当前升级点: %d", m_pPlayer->m_AccData.m_Health, 1000 + m_pPlayer->m_AccData.m_Health * 10 + m_pPlayer->m_AccData.m_Level * 20, m_pPlayer->m_AccData.m_Money); @@ -137,10 +139,10 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) } else if (!strcmp(supgr, "ammoregen")) { - if (m_pPlayer->m_AccData.m_Ammoregen >= 60) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "子弹恢复已达到最高级 (60)."); + if (m_pPlayer->m_AccData.m_Ammoregen >= 60) + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("子弹恢复已达到最高级 (60).")); if (m_pPlayer->m_AccData.m_Money <= 0) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "穷逼 (1点都出不起)."); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("穷逼 (1点都出不起).")); m_pPlayer->m_AccData.m_Money--, m_pPlayer->m_AccData.m_Ammoregen++; str_format(andg, sizeof(andg), "当前子弹恢复等级: %d, 当前升级点: %d", m_pPlayer->m_AccData.m_Ammoregen, m_pPlayer->m_AccData.m_Money); @@ -150,10 +152,10 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) } else if (!strcmp(supgr, "ammo")) { - if (m_pPlayer->m_AccData.m_Ammo >= 20) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "已达到子弹最高数量 (20)."); + if (m_pPlayer->m_AccData.m_Ammo >= 20) + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("已达到子弹最高数量 (20).")); if (m_pPlayer->m_AccData.m_Money < 10) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "升级点不足 (至少10点)."); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("升级点不足 (至少10点).")); m_pPlayer->m_AccData.m_Money -= 10, m_pPlayer->m_AccData.m_Ammo++; str_format(andg, sizeof(andg), "当前子弹数: %d, 当前升级点: %d", GameServer()->GetPlayerChar(m_pPlayer->GetCID())->m_mAmmo + m_pPlayer->m_AccData.m_Ammo, m_pPlayer->m_AccData.m_Money); @@ -163,8 +165,8 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) } else if (!strcmp(supgr, "stats")) { - char aBuf2[32]; - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "~~~~~~~~ ! 等级升级明细 ! ~~~~~~~~"); + char aBuf2[32]; + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("~~~~~~~~ ! 等级升级明细 ! ~~~~~~~~")); str_format(aBuf2, sizeof(aBuf2), "伤害: %d", m_pPlayer->m_AccData.m_Dmg); GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf2); str_format(aBuf2, sizeof(aBuf2), "血量: %d", m_pPlayer->m_AccData.m_Health); @@ -175,54 +177,54 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf2); str_format(aBuf2, sizeof(aBuf2), "子弹: %d", m_pPlayer->m_AccData.m_Ammo); GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf2); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "~~~~~~~~ ! 等级升级明细 ! ~~~~~~~~"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("~~~~~~~~ ! 等级升级明细 ! ~~~~~~~~")); return; } - else return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "这个类别不存在."); + else return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("这个类别不存在.")); } - else if(!strncmp(Msg->m_pMessage, "/turret", 7)) + else if (!strncmp(Msg->m_pMessage, "/turret", 7)) { LastChat(); - if(!m_pPlayer->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "你还没有登录! 输入 /account 获得账号帮助"); + if (!m_pPlayer->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("你还没有登录! 输入 /account 获得账号帮助")); char supgr[256], andg[64]; if (sscanf(Msg->m_pMessage, "/turret %s", supgr) != 1) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "提示: /turret info"); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("提示: /turret info")); if(!strcmp(supgr, "info")) - { - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/turret info - 关于"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/turret help - 帮助"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/turret stats - 显示炮塔等级"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/turret speed - 升级炮塔攻速 (1 炮塔点)"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/turret dmg - 升级炮塔伤害 (1 炮塔点)"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/turret ammo - 升级炮塔子弹总数 (1 炮塔点)"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/turret ammoregen - 升级炮塔子弹恢复速度 (1 炮塔点)"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/turret range - 升级炮塔发射范围 (1 炮塔点)"); + { + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/turret info - 关于")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/turret help - 帮助")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/turret stats - 显示炮塔等级")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/turret speed - 升级炮塔攻速 (1 炮塔点)")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/turret dmg - 升级炮塔伤害 (1 炮塔点)")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/turret ammo - 升级炮塔子弹总数 (1 炮塔点)")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/turret ammoregen - 升级炮塔子弹恢复速度 (1 炮塔点)")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/turret range - 升级炮塔发射范围 (1 炮塔点)")); return; } else if(!strcmp(supgr, "help")) { - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "使用表情(左Shift)鬼魂防止炮塔"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "炮塔有3种不一样的武器"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "炮塔是一种很有效的杀死僵尸的方式"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "拿不同的武器可以放置不同的炮塔"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "手枪炮塔: 每秒射击一次敌人 朝任意方向开火(range)"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "散弹枪炮塔: 每3秒射击一次 朝任意方向放置"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "激光炮塔: 如果僵尸路过它瞄准的位置,瞬间放置墙挡住(捕捉)僵尸 一个地方放置,走到或跳到另一个无遮挡的地方朝向第一个点放置"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "榴弹炮塔: 在自己的线区不断放置榴弹,发送延迟由炮台speed(速度)属性控制 与激光炮塔的放置方法一样"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "*** 炮塔不包括地雷,但是以下是地雷介绍"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "*** 只有一个地雷,也只能放置一个"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "和炮塔的放置方法一样,放置的武器是锤子"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "地雷如果用的好将成为翻盘的关键点!"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("使用表情(左Shift)鬼魂防止炮塔")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("炮塔有3种不一样的武器")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("炮塔是一种很有效的杀死僵尸的方式")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("拿不同的武器可以放置不同的炮塔")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("手枪炮塔: 每秒射击一次敌人 朝任意方向开火(range)")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("散弹枪炮塔: 每3秒射击一次 朝任意方向放置")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("激光炮塔: 如果僵尸路过它瞄准的位置,瞬间放置墙挡住(捕捉)僵尸 一个地方放置,走到或跳到另一个无遮挡的地方朝向第一个点放置")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("榴弹炮塔: 在自己的线区不断放置榴弹,发送延迟由炮台speed(速度)属性控制 与激光炮塔的放置方法一样")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("*** 炮塔不包括地雷,但是以下是地雷介绍")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("*** 只有一个地雷,也只能放置一个")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("和炮塔的放置方法一样,放置的武器是锤子")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("地雷如果用的好将成为翻盘的关键点!")); return; } else if(!strcmp(supgr, "dmg")) { - if(m_pPlayer->m_AccData.m_TurretDmg > 100) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "已达到炮塔最高伤害"); + if (m_pPlayer->m_AccData.m_TurretDmg > 100) + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("已达到炮塔最高伤害")); if(m_pPlayer->m_AccData.m_TurretMoney <= 0) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "你没有足够的炮塔点"); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("你没有足够的炮塔点")); m_pPlayer->m_AccData.m_TurretMoney--, m_pPlayer->m_AccData.m_TurretDmg++; str_format(andg, sizeof(andg), "你的炮塔伤害增加了, 现在是: %d", m_pPlayer->m_AccData.m_TurretDmg); @@ -232,10 +234,10 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) } else if(!strcmp(supgr, "speed")) { - if(m_pPlayer->m_AccData.m_TurretSpeed >= 500) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "已达到炮塔最高速度"); + if (m_pPlayer->m_AccData.m_TurretSpeed >= 500) + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("已达到炮塔最高速度")); if(m_pPlayer->m_AccData.m_TurretMoney <= 0) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "你个穷逼"); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("你个穷逼")); m_pPlayer->m_AccData.m_TurretMoney--, m_pPlayer->m_AccData.m_TurretSpeed++; str_format(andg, sizeof(andg), "你的炮塔速度提升了, 现在是: %d", m_pPlayer->m_AccData.m_TurretSpeed); @@ -245,10 +247,10 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) } else if (!strcmp(supgr, "ammo")) { - if (m_pPlayer->m_AccData.m_TurretAmmo >= 100) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "已达到炮塔最高子弹数"); + if (m_pPlayer->m_AccData.m_TurretAmmo >= 100) + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("已达到炮塔最高子弹数")); if (m_pPlayer->m_AccData.m_TurretMoney <= 0) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "你没有足够的炮塔点"); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("你没有足够的炮塔点")); m_pPlayer->m_AccData.m_TurretMoney--, m_pPlayer->m_AccData.m_TurretAmmo++; str_format(andg, sizeof(andg), "你的炮塔枪升级了, 现在是: %d", m_pPlayer->m_AccData.m_TurretAmmo); @@ -258,10 +260,10 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) } else if (!strcmp(supgr, "ammoregen")) { - if (m_pPlayer->m_AccData.m_TurretShotgun >= 75) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "已达到炮塔最高子弹恢复速"); + if (m_pPlayer->m_AccData.m_TurretShotgun >= 75) + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("已达到炮塔最高子弹恢复速")); if (m_pPlayer->m_AccData.m_TurretMoney <= 0) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "你没钱"); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("你没钱")); m_pPlayer->m_AccData.m_TurretMoney--, m_pPlayer->m_AccData.m_TurretShotgun++; str_format(andg, sizeof(andg), "你的炮塔子弹恢复速升级了, 现在是: %d", m_pPlayer->m_AccData.m_TurretShotgun); @@ -271,10 +273,10 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) } else if (!strcmp(supgr, "range")) { - if (m_pPlayer->m_AccData.m_TurretRange >= 200) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "已达到炮塔最大攻击范围"); + if (m_pPlayer->m_AccData.m_TurretRange >= 200) + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("已达到炮塔最大攻击范围")); if (m_pPlayer->m_AccData.m_TurretMoney <= 0) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "没钱滚"); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("没钱滚")); m_pPlayer->m_AccData.m_TurretMoney--, m_pPlayer->m_AccData.m_TurretRange++; str_format(andg, sizeof(andg), "你的炮塔攻击范围提升, 现在是: %d", m_pPlayer->m_AccData.m_TurretRange); @@ -284,8 +286,8 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) } else if (!strcmp(supgr, "stats")) { - char aBuf[64]; - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "------ 炮塔 ------"); + char aBuf[64]; + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("------ 炮塔 ------")); str_format(aBuf, sizeof(aBuf), "等级: %d", m_pPlayer->m_AccData.m_TurretLevel); GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf); str_format(aBuf, sizeof(aBuf), "经验: %d", m_pPlayer->m_AccData.m_TurretExp); @@ -302,28 +304,28 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf); str_format(aBuf, sizeof(aBuf), "范围: %d", m_pPlayer->m_AccData.m_TurretRange); GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "------ 炮塔 ------"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("------ 炮塔 ------")); return; } else { - str_format(andg, sizeof(andg), "没有这个炮塔升级指令: '%s'!", supgr); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), andg); - return; + str_format(andg, sizeof(andg), "没有这个炮塔升级指令: '%s'!", supgr); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), andg); + return; } } else if (!str_comp_nocase(Msg->m_pMessage, "/me") || !str_comp_nocase(Msg->m_pMessage, "/status") || !str_comp_nocase(Msg->m_pMessage, "/stats")) { LastChat(); - if (!m_pPlayer->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "你还没有登录! 输入 /account 获取帮助"); + if (!m_pPlayer->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("你还没有登录! 输入 /account 获取帮助")); char aBuf[64]; - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "~~~~~~~~ ! 你的账号明细 ! ~~~~~~~~"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("~~~~~~~~ ! 你的账号明细 ! ~~~~~~~~")); str_format(aBuf, sizeof(aBuf), "登录: %s", m_pPlayer->m_AccData.m_Username); GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf); str_format(aBuf, sizeof(aBuf), "密码: %s", m_pPlayer->m_AccData.m_Password); GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "邮箱: <没有邮箱> (没做)"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("邮箱: <没有邮箱> (没做)")); str_format(aBuf, sizeof(aBuf), "等级: %d", m_pPlayer->m_AccData.m_Level); GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf); str_format(aBuf, sizeof(aBuf), "经验: %d/%d", m_pPlayer->m_AccData.m_Exp, m_pPlayer->m_AccData.m_Level); @@ -332,17 +334,17 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf); str_format(aBuf, sizeof(aBuf), "冰冻: %s", m_pPlayer->m_AccData.m_Freeze ? "yes" : "no"); GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "你可以使用这个指令修改密码:"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/password <新密码>"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "~~~~~~~~ ! 你的账户明细 ! ~~~~~~~~"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("你可以使用这个指令修改密码:")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/password <新密码>")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("~~~~~~~~ ! 你的账户明细 ! ~~~~~~~~")); return; } - else if(!strncmp(Msg->m_pMessage, "/idlist", 7)) + else if (!strncmp(Msg->m_pMessage, "/idlist", 7)) { - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "------ ID列表 ------"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("------ ID列表 ------")); for(int i = 0; i < MAX_CLIENTS; i++) { - if(GameServer()->m_apPlayers[i]) + if (GameServer()->m_apPlayers[i]) { char aBuf[32]; str_format(aBuf, sizeof(aBuf), "%s ID:%i", GameServer()->Server()->ClientName(i), i); @@ -351,15 +353,15 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) } return; } - else if(!strncmp(Msg->m_pMessage, "/password", 9)) + else if (!strncmp(Msg->m_pMessage, "/password", 9)) { LastChat(); if (!m_pPlayer->m_AccData.m_UserID) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "你还没有登录! 输入 /account 获取帮助"); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("你还没有登录! 输入 /account 获取帮助")); char NewPassword[256]; if(sscanf(Msg->m_pMessage, "/password %s", NewPassword) != 1) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "格式错误 \"/password <新密码>\""); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("格式错误 \"/password <新密码>\"")); m_pPlayer->m_pAccount->NewPassword(NewPassword); return; @@ -367,129 +369,129 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) else if (!strcmp(Msg->m_pMessage, "/vip")) { LastChat(); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "--- ViP ---"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "不存在的"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("--- ViP ---")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("不存在的")); return; } else if (!strcmp(Msg->m_pMessage, "/supervip")) { LastChat(); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "--- 超级ViP ---"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "不存在的"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("--- 超级ViP ---")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("不存在的")); return; } else if (!strcmp(Msg->m_pMessage, "/ultimatevip")) { LastChat(); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "--- 终极ViP ---"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "不存在的"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("--- 终极ViP ---")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("不存在的")); return; } else if (!strcmp(Msg->m_pMessage, "/info")) { LastChat(); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "~~~~~~~~ 欢迎来到服务器介绍 ~~~~~~~~"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "管理员: FlowerFell-Sans,管理员QQ:1421709710"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "Panic mod by Kurosio, 翻译者: FlowerFell-Sans"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "~~~~~~~~ 欢迎来到服务器介绍 ~~~~~~~~"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("~~~~~~~~ 欢迎来到服务器介绍 ~~~~~~~~")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("管理员: FlowerFell-Sans,管理员QQ:1421709710")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("Panic mod by Kurosio, 翻译者: FlowerFell-Sans")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("~~~~~~~~ 欢迎来到服务器介绍 ~~~~~~~~")); return; } - else if(!strcmp(Msg->m_pMessage, "/help")) - { + else if (!strcmp(Msg->m_pMessage, "/help")) + { LastChat(); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "~~~~~~~~ 欢迎来到服务器帮助 ~~~~~~~~"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/account - 关于和账号教程"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/news - 查看服务器最新消息"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/rules - 查看xPanic的规则"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/pm - 给别人发送私信"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/cmdlist - 查看服务器指令列表"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/vip - 获取vip等级"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/supervip - 获取超级vip等级"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/ultimatevip - 获取终极vip等级"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/turret info - 关于炮台"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/levels - 关于等级"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/shop - 分数商店"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "~~~~~~~~ 欢迎来到服务器帮助 ~~~~~~~~"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("~~~~~~~~ 欢迎来到服务器帮助 ~~~~~~~~")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/account - 关于和账号教程")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/news - 查看服务器最新消息")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/rules - 查看xPanic的规则")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/pm - 给别人发送私信")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/cmdlist - 查看服务器指令列表")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/vip - 获取vip等级")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/supervip - 获取超级vip等级")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/ultimatevip - 获取终极vip等级")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/turret info - 关于炮台")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/levels - 关于等级")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/shop - 分数商店")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("~~~~~~~~ 欢迎来到服务器帮助 ~~~~~~~~")); return; - } + } else if (!strcmp(Msg->m_pMessage, "/levels")) { LastChat(); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "从40级开始:你的散弹枪每10级多发射1颗子弹"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "50级: +10 子弹"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "100级: +10 子弹"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("从40级开始:你的散弹枪每10级多发射1颗子弹")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("50级: +10 子弹")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("100级: +10 子弹")); return; } else if (!strcmp(Msg->m_pMessage, "/account")) { LastChat(); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "-------- 账号 --------"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/register <用户名> <密码> - 注册新账号:不能包含中文"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/login <用户名> <密码> - 登录你的账户"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/logout - 退出登录"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/password - 改密码"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "-------- 账号 --------"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("-------- 账号 --------")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/register <用户名> <密码> - 注册新账号:不能包含中文")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/login <用户名> <密码> - 登录你的账户")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/logout - 退出登录")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/password - 改密码")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("-------- 账号 --------")); return; } else if (!strcmp(Msg->m_pMessage, "/shop")) { LastChat(); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "----- 商店 -----"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/range [10 分数] - 购买大范围僵尸锤"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/heart [20 score] - 在僵尸阵营购买一滴血"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/jump [3 score] - 购买一次多余的跳跃"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("----- 商店 -----")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/range [10 分数] - 购买大范围僵尸锤")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/heart [20 score] - 在僵尸阵营购买一滴血")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/jump [3 score] - 购买一次多余的跳跃")); return; } else if (!strcmp(Msg->m_pMessage, "/news")) { LastChat(); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "Languages"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("Languages")); return; } else if (!strcmp(Msg->m_pMessage, "/policehelp")) { LastChat(); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/kick - 踢出玩家"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/freeze - 冰冻玩家"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/idlist - 显示玩家ID"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/kick - 踢出玩家")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/freeze - 冰冻玩家")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/idlist - 显示玩家ID")); return; } - else if(!strcmp(Msg->m_pMessage, "/cmdlist")) + else if (!strcmp(Msg->m_pMessage, "/cmdlist")) { LastChat(); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "~~~~~~~~ 欢迎查看指令列表 ~~~~~~~~"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/register, /login, /logout - 账号系统"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/rules, /help, /info - 关于"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/stats, /upgr - 升级系统"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/shop - 分数商店"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "/idlist - 显示玩家ID"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("~~~~~~~~ 欢迎查看指令列表 ~~~~~~~~")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/register, /login, /logout - 账号系统")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/rules, /help, /info - 关于")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/stats, /upgr - 升级系统")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/shop - 分数商店")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("/idlist - 显示玩家ID")); if(m_pPlayer->m_AccData.m_PlayerState == 1) { - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "#这个是警察局"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "#/policehelp - 警察局帮助"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("#这个是警察局")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("#/policehelp - 警察局帮助")); } - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "~~~~~~~~ 欢迎查看指令列表 ~~~~~~~~"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("~~~~~~~~ 欢迎查看指令列表 ~~~~~~~~")); return; - } - else if(!strcmp(Msg->m_pMessage, "/rules")) + } + else if (!strcmp(Msg->m_pMessage, "/rules")) { LastChat(); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "1. 不要刷经验 (冻结账号)"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "2. 不要骂人 (禁言/封禁 1-7天)"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "3. 不要使用机器人 (永封)"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "4. 不要自杀 (跟刷经验一样)"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("1. 不要刷经验 (冻结账号)")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("2. 不要骂人 (禁言/封禁 1-7天)")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("3. 不要使用机器人 (永封)")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("4. 不要自杀 (跟刷经验一样)")); return; } else if (!strcmp(Msg->m_pMessage, "/heart")) { LastChat(); - if (!m_pPlayer->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "你没有登录! 输入/XXXXX获取账号帮助"); - if (!GameServer()->GetPlayerChar(m_pPlayer->GetCID())) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "只能在活着的时候使用!"); - if (GameServer()->m_World.m_Paused) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "请等待回合结束"); - if(m_pPlayer->GetTeam() != TEAM_RED) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "只能僵尸用"); - if (m_pPlayer->m_Score < 20) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "分数不足 (20)."); + if (!m_pPlayer->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("你没有登录! 输入/XXXXX获取账号帮助")); + if (!GameServer()->GetPlayerChar(m_pPlayer->GetCID())) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("只能在活着的时候使用!")); + if (GameServer()->m_World.m_Paused) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("请等待回合结束")); + if(m_pPlayer->GetTeam() != TEAM_RED) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("只能僵尸用")); + if (m_pPlayer->m_Score < 20) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("分数不足 (20).")); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "完成!"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("完成!")); m_pPlayer->m_Score -= 20; m_pPlayer->m_ActivesLife = false; m_pPlayer->m_LifeActives = false; @@ -499,12 +501,12 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) else if (!strcmp(Msg->m_pMessage, "/jump")) { LastChat(); - if (!m_pPlayer->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "你没有登录! 输/account"); - if (!GameServer()->GetPlayerChar(m_pPlayer->GetCID())) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "活着用!"); - if (GameServer()->m_World.m_Paused) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "等回合结束."); - if (m_pPlayer->m_Score < 3) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "你没分 (3)."); + if (!m_pPlayer->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("你没有登录! 输/account")); + if (!GameServer()->GetPlayerChar(m_pPlayer->GetCID())) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("活着用!")); + if (GameServer()->m_World.m_Paused) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("等回合结束.")); + if (m_pPlayer->m_Score < 3) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("你没分 (3).")); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "完成!"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("完成!")); m_pPlayer->m_JumpsShop++; m_pPlayer->m_Score -= 3; GameServer()->GetPlayerChar(m_pPlayer->GetCID())->m_Core.m_Jumps += 1; @@ -513,20 +515,20 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) else if (!strcmp(Msg->m_pMessage, "/range")) { LastChat(); - if (!m_pPlayer->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "你没登录"); + if (!m_pPlayer->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("你没登录")); - if (!GameServer()->GetPlayerChar(m_pPlayer->GetCID())) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "只能活着的时候用!"); - if (GameServer()->m_World.m_Paused) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "等回合结束."); - if (m_pPlayer->GetTeam() != TEAM_RED) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "只能僵尸用!"); - if (m_pPlayer->m_Score < 10) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "没有足够分数 (10)."); + if (!GameServer()->GetPlayerChar(m_pPlayer->GetCID())) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("只能活着的时候用!")); + if (GameServer()->m_World.m_Paused) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("等回合结束.")); + if (m_pPlayer->GetTeam() != TEAM_RED) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("只能僵尸用!")); + if (m_pPlayer->m_Score < 10) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("没有足够分数 (10).")); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "完成!"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("完成!")); m_pPlayer->m_RangeShop = true; m_pPlayer->m_Score -= 10; return; } - else if (!strncmp(Msg->m_pMessage, "/prefix", 7) && m_pPlayer->m_AccData.m_UserID && - (GameServer()->Server()->IsAuthed(m_pPlayer->GetCID()) || m_pPlayer->m_AccData.m_PlayerState == 2 || m_pPlayer->m_AccData.m_UserID == g_Config.m_SvOwnerAccID)) + else if (!strncmp(Msg->m_pMessage, "/prefix", 7) && m_pPlayer->m_AccData.m_UserID && + (GameServer()->Server()->IsAuthed(m_pPlayer->GetCID()) || m_pPlayer->m_AccData.m_PlayerState == 2 || m_pPlayer->m_AccData.m_UserID == g_Config.m_SvOwnerAccID)) { LastChat(); char aBuf[24]; @@ -540,7 +542,7 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) LastChat(); int id; if (sscanf(Msg->m_pMessage, "/w %d", &id) != 1) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "提示 /w "); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("提示 /w ")); int cid2 = clamp(id, 0, (int)MAX_CLIENTS - 1); char pLsMsg[128]; @@ -553,12 +555,17 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) LastChat(); int id, size; if ((sscanf(Msg->m_pMessage, "/setlvl %d %d", &id, &size)) != 2) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "Please use: /setlvl "); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("Please use: /setlvl ")); int cid2 = clamp(id, 0, (int)MAX_CLIENTS - 1); - if (!GameServer()->m_apPlayers[cid2]) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "There is no such player!'"); - if (!GameServer()->m_apPlayers[cid2]->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "The player is not logged in account!"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "You had to change your level!'"), GameServer()->m_apPlayers[cid2]->m_AccData.m_Level = size, GameServer()->m_apPlayers[cid2]->m_AccData.m_Exp = 0, GameServer()->m_apPlayers[cid2]->m_pAccount->Apply(); + if (!GameServer()->m_apPlayers[cid2]) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("There is no such player!'")); + if (!GameServer()->m_apPlayers[cid2]->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("The player is not logged in account!")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("You had to change your level!'")); + + GameServer()->m_apPlayers[cid2]->m_AccData.m_Level = size; + GameServer()->m_apPlayers[cid2]->m_AccData.m_Exp = 0; + GameServer()->m_apPlayers[cid2]->m_pAccount->Apply(); + return; } else if (!strncmp(Msg->m_pMessage, "/setmoney", 9) && GameServer()->Server()->IsAuthed(m_pPlayer->GetCID())) @@ -566,25 +573,28 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) LastChat(); int id, size; if ((sscanf(Msg->m_pMessage, "/setmoney %d %d", &id, &size)) != 2) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "Please use: /setmoney "); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("Please use: /setmoney ")); int cid2 = clamp(id, 0, (int)MAX_CLIENTS - 1); - if (!GameServer()->m_apPlayers[cid2]) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "There is no such player!'"); - if (!GameServer()->m_apPlayers[cid2]->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "The player is not logged in account!"); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "You had to change your level!'"), GameServer()->SendChatTarget(cid2, "Your money changed!'"), GameServer()->m_apPlayers[cid2]->m_AccData.m_Money = size, GameServer()->m_apPlayers[cid2]->m_pAccount->Apply(); + if (!GameServer()->m_apPlayers[cid2]) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("There is no such player!'")); + if (!GameServer()->m_apPlayers[cid2]->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("The player is not logged in account!")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("You had to change your level!'")); + GameServer()->SendChatTarget(cid2, "Your money changed!'"); + GameServer()->m_apPlayers[cid2]->m_AccData.m_Money = size; + GameServer()->m_apPlayers[cid2]->m_pAccount->Apply(); return; } else if (!strncmp(Msg->m_pMessage, "/freeze", 6) && (m_pPlayer->m_AccData.m_PlayerState == 1 || GameServer()->Server()->IsAuthed(m_pPlayer->GetCID()))) { LastChat(); int id; - if(sscanf(Msg->m_pMessage, "/freeze %d", &id) != 1) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "Please use: /freeze "); + if (sscanf(Msg->m_pMessage, "/freeze %d", &id) != 1) + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("Please use: /freeze ")); int cid2 = clamp(id, 0, (int)MAX_CLIENTS - 1); - if(cid2 == m_pPlayer->GetCID()) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "You can not freeze your account!"); - if (!GameServer()->m_apPlayers[cid2]) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "There is no such player!'"); - if (!GameServer()->m_apPlayers[cid2]->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "The player is not logged in account!"); + if(cid2 == m_pPlayer->GetCID()) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("You can not freeze your account!")); + if (!GameServer()->m_apPlayers[cid2]) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("There is no such player!'")); + if (!GameServer()->m_apPlayers[cid2]->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("The player is not logged in account!")); GameServer()->m_apPlayers[cid2]->m_AccData.m_Freeze ^= true; GameServer()->m_apPlayers[cid2]->m_pAccount->Apply(); @@ -602,16 +612,16 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) LastChat(); int id; if ((sscanf(Msg->m_pMessage, "/kick %d", &id)) != 1) - return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "Please use: /kick "); + return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("Please use: /kick ")); int cid2 = clamp(id, 0, (int)MAX_CLIENTS - 1); - if (!GameServer()->m_apPlayers[cid2]) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "There is no such player!'"); + if (!GameServer()->m_apPlayers[cid2]) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("There is no such player!'")); char buf[64]; str_format(buf, sizeof(buf), "%s kicked by the Police", GameServer()->Server()->ClientName(cid2)); GameServer()->SendChatTarget(-1, buf); - GameServer()->Server()->Kick(cid2, "You was kicked by the Police!"); + GameServer()->Server()->Kick(cid2, "You was kicked by the Police!"); return; } else if (!strncmp(Msg->m_pMessage, "/setgroup", 9) && GameServer()->Server()->IsAuthed(m_pPlayer->GetCID())) @@ -620,14 +630,14 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) int id, size; if (sscanf(Msg->m_pMessage, "/setgroup %d %d", &id, &size) != 2) { - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "Please use: /setgroup "); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "Group ID: 0 - Removed, 1 - Police, 2 - VIP, 3 - Helper"); return; + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("Please use: /setgroup ")); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("Group ID: 0 - Removed, 1 - Police, 2 - VIP, 3 - Helper")); return; } int cid2 = clamp(id, 0, (int)MAX_CLIENTS - 1); char gname[4][12] = {"", "police", "vip", "helper"}, aBuf[64]; - if (!GameServer()->m_apPlayers[cid2]) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "There is no such player!"); - if (!GameServer()->m_apPlayers[cid2]->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "The player is not logged in account!"); + if (!GameServer()->m_apPlayers[cid2]) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("There is no such player!")); + if (!GameServer()->m_apPlayers[cid2]->m_AccData.m_UserID) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("The player is not logged in account!")); switch (size) { @@ -640,9 +650,9 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) GameServer()->SendChatTarget(cid2, aBuf); GameServer()->m_apPlayers[cid2]->m_AccData.m_PlayerState = 0; } - else GameServer()->SendChatTarget(m_pPlayer->GetCID(), "This player already no in group!"); break; + else GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("This player already no in group!")); break; default: - if(size > 3 || size < 0) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), "Group ID not found!"); + if(size > 3 || size < 0) return GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("Group ID not found!")); GameServer()->m_apPlayers[cid2]->m_AccData.m_PlayerState = size; str_format(aBuf, sizeof(aBuf), "Set group %s for player '%s'", gname[GameServer()->m_apPlayers[cid2]->m_AccData.m_PlayerState], GameServer()->Server()->ClientName(cid2)); GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf); @@ -652,15 +662,14 @@ void CCmd::ChatCmd(CNetMsg_Cl_Say *Msg) return; } - if(!strncmp(Msg->m_pMessage, "/", 1)) + if (!strncmp(Msg->m_pMessage, "/", 1)) { LastChat(); - GameServer()->SendChatTarget(m_pPlayer->GetCID(), "错误的指令. 输入 /cmdlist"); + GameServer()->SendChatTarget(m_pPlayer->GetCID(), _("错误的指令. 输入 /cmdlist")); } - } void CCmd::LastChat() { - m_pPlayer->m_LastChat = GameServer()->Server()->Tick(); + m_pPlayer->m_LastChat = GameServer()->Server()->Tick(); } diff --git a/src/game/server/entities/hearth.cpp b/src/game/server/entities/hearth.cpp index b098c19..db203d8 100644 --- a/src/game/server/entities/hearth.cpp +++ b/src/game/server/entities/hearth.cpp @@ -5,26 +5,24 @@ #define M_PI 3.14159265358979323846 - CLifeHearth::CLifeHearth(CGameWorld *pGameWorld, vec2 Pos, int Owner) -: CEntity(pGameWorld, CGameWorld::ENTTYPE_FLAG) + : CEntity(pGameWorld, CGameWorld::ENTTYPE_FLAG) { m_Pos = Pos; m_Owner = Owner; - m_Lifetime = 1*Server()->TickSpeed(); - GameWorld()->InsertEntity(this); + m_Lifetime = 1 * Server()->TickSpeed(); + GameWorld()->InsertEntity(this); Fistheart = false; } -void CLifeHearth::Reset() -{ +void CLifeHearth::Reset() +{ GameServer()->m_World.DestroyEntity(this); } void CLifeHearth::Tick() { - if (!GameServer()->m_apPlayers[m_Owner] || GameServer()->m_apPlayers[m_Owner]->GetTeam() == TEAM_BLUE - || GameServer()->m_apPlayers[m_Owner]->GetTeam() == TEAM_SPECTATORS) + if (!GameServer()->m_apPlayers[m_Owner] || GameServer()->m_apPlayers[m_Owner]->GetTeam() == TEAM_BLUE || GameServer()->m_apPlayers[m_Owner]->GetTeam() == TEAM_SPECTATORS) return Reset(); if (!GameServer()->GetPlayerChar(m_Owner)) @@ -40,7 +38,7 @@ void CLifeHearth::Tick() if (GameServer()->GetPlayerChar(m_Owner)->m_TypeHealthCh && g_Config.m_SvNewHearth) m_Pos = GameServer()->GetPlayerChar(m_Owner)->m_Pos; else - m_Pos = GameServer()->GetPlayerChar(m_Owner)->m_Pos + normalize(GetDir(pi / 180 * ((Server()->Tick() + (360) % 360 + 1) * 6)))*(m_ProximityRadius + 36); + m_Pos = GameServer()->GetPlayerChar(m_Owner)->m_Pos + normalize(GetDir(pi / 180 * ((Server()->Tick() + (360) % 360 + 1) * 6))) * (m_ProximityRadius + 36); return; } @@ -57,15 +55,15 @@ void CLifeHearth::Tick() pClosest = (CCharacter *)pClosest->TypeNext(); } - if(!g_Config.m_SvNewHearth && !Fistheart) + if (!g_Config.m_SvNewHearth && !Fistheart) { Fistheart = true; m_Pos = GameServer()->GetPlayerChar(m_Owner)->m_Pos; } - + if (GameServer()->Collision()->IsSolid(m_Pos.x, m_Pos.y)) return Reset(); - + if (!pTarget) { if (!StopTickLef) @@ -86,12 +84,13 @@ void CLifeHearth::Tick() return; Lefpos = normalize(pTarget->m_Pos - m_Pos); - + if (m_Lifetime != 1000) m_Lifetime = 1000; if (distance(pTarget->m_Pos, m_Pos) < pTarget->m_ProximityRadius + 2.0f && GameServer()->m_apPlayers[m_Owner]->m_LifeActives) { + pTarget->m_BurnTick = Server()->TickSpeed() * 2; return Reset(); } } @@ -100,29 +99,30 @@ void CLifeHearth::Snap(int SnappingClient) { if (NetworkClipped(SnappingClient)) return; - + if (!GameServer()->GetPlayerChar(m_Owner)) return; - + CNetObj_Pickup *pP = static_cast(Server()->SnapNewItem(NETOBJTYPE_PICKUP, m_ID, sizeof(CNetObj_Pickup))); - if(!pP) + if (!pP) return; if (!GameServer()->m_apPlayers[m_Owner]->m_LifeActives) { - if (GameServer()->GetPlayerChar(m_Owner)->m_TypeHealthCh) + if (GameServer()->GetPlayerChar(m_Owner)->m_TypeHealthCh) { float a = GetAngle(GameServer()->GetPlayerChar(m_Owner)->m_ActivTurs); - pP->m_X = (int)(cos(a + M_PI / 1 * 4)*(32.0) + m_Pos.x); - pP->m_Y = (int)(sin(a + M_PI / 1 * 4)*(32.0) + m_Pos.y); + pP->m_X = (int)(cos(a + M_PI / 1 * 4) * (32.0) + m_Pos.x); + pP->m_Y = (int)(sin(a + M_PI / 1 * 4) * (32.0) + m_Pos.y); } - else + else { pP->m_X = (int)m_Pos.x; pP->m_Y = (int)m_Pos.y; } } - else{ + else + { pP->m_X = (int)m_Pos.x; pP->m_Y = (int)m_Pos.y; } diff --git a/src/game/server/entities/turret.cpp b/src/game/server/entities/turret.cpp index 19f2f76..ba09499 100644 --- a/src/game/server/entities/turret.cpp +++ b/src/game/server/entities/turret.cpp @@ -38,23 +38,18 @@ void CTurret::Reset() GameServer()->m_World.DestroyEntity(this); for (unsigned i = 0; i < sizeof(m_inIDs) / sizeof(int); i ++) { - if(m_inIDs[i] >= 0){ + if(m_inIDs[i]) Server()->SnapFreeID(m_inIDs[i]); - m_inIDs[i] = -1; - } } - if(m_IDS >= 0){ + + if(m_IDS) Server()->SnapFreeID(m_IDS); - m_IDS = -1; - } - if(m_IDC >= 0){ + + if(m_IDC) Server()->SnapFreeID(m_IDC); - m_IDC = -1; - } - if(m_IDG >= 0){ + + if(m_IDG) Server()->SnapFreeID(m_IDG); - m_IDG = -1; - } if (GameServer()->GetPlayerChar(m_Owner)) { @@ -349,13 +344,12 @@ void CTurret::Snap(int SnappingClient) else if (m_Type == WEAPON_GRENADE) pObj2->m_StartTick = Server()->Tick() - 2; else pObj2->m_StartTick = Server()->Tick(); - //laserpos2 - CNetObj_Laser *pObj3 = static_cast(Server()->SnapNewItem(NETOBJTYPE_LASER, m_IDG, sizeof(CNetObj_Laser))); - if (!pObj3) - return; - if(m_Type == WEAPON_GRENADE) { + // laserpos2 + CNetObj_Laser *pObj3 = static_cast(Server()->SnapNewItem(NETOBJTYPE_LASER, m_IDG, sizeof(CNetObj_Laser))); + if (!pObj3) + return; pObj3->m_X = (int)m_Pos2L.x; pObj3->m_Y = (int)m_Pos2L.y; diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 328e1c4..f49eae9 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -747,7 +747,7 @@ void CGameContext::OnClientEnter(int ClientID) if(((CServer *) Server())->m_aPrevStates[ClientID] < CServer::CClient::STATE_INGAME) { char aBuf[96]; - SendChatTarget(-1, "玩家'{str:PlayerName}' 加入了游戏", "PlayerName", Server()->ClientName(ClientID), NULL); + SendChatTarget(-1, _("玩家'{str:PlayerName}' 加入了游戏"), "PlayerName", Server()->ClientName(ClientID), NULL); str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' team=%d", ClientID, Server()->ClientName(ClientID), m_apPlayers[ClientID]->GetTeam()); Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); @@ -758,9 +758,9 @@ void CGameContext::OnClientEnter(int ClientID) SendVoteSet(ClientID); char Name[96]; - SendChatTarget(ClientID, "输入/register 用户名 密码 注册"); - SendChatTarget(ClientID, "输入/login 用户名 密码 登录"); - SendChatTarget(ClientID, "输入/cmdlist获取指令列表"); + SendChatTarget(ClientID, _("输入/register 用户名 密码 注册")); + SendChatTarget(ClientID, _("输入/login 用户名 密码 登录")); + SendChatTarget(ClientID, _("输入/cmdlist获取指令列表")); m_pController->CheckZomb(); m_apPlayers[ClientID]->m_Authed = ((CServer*)Server())->m_aClients[ClientID].m_Authed; @@ -807,8 +807,8 @@ void CGameContext::OnClientDrop(int ClientID, const char *pReason) void CGameContext::SendPM(int ClientID, int FromID, char *string) { - if(!m_apPlayers[FromID]) return SendChatTarget(ClientID, "没有玩家用这个ID"); - if(ClientID == FromID) return SendChatTarget(FromID, "尝试给自己发消息 (-_-')"); + if(!m_apPlayers[FromID]) return SendChatTarget(ClientID, _("没有玩家用这个ID")); + if(ClientID == FromID) return SendChatTarget(FromID, _("尝试给自己发消息 (-_-')")); if(Server()->ClientIngame(ClientID) && Server()->ClientIngame(FromID)) { char aBuf[128]; @@ -816,7 +816,7 @@ void CGameContext::SendPM(int ClientID, int FromID, char *string) SendChatTarget(FromID, aBuf); str_format(aBuf, sizeof(aBuf), "pm to '%s': %s", Server()->ClientName(FromID), string); SendChatTarget(ClientID, aBuf); - } + } } void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) @@ -887,13 +887,13 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) //if(pPlayer->GetTeam() == TEAM_SPECTATORS) if(g_Config.m_SvSpectatorVotes == 0 && pPlayer->GetTeam() == TEAM_SPECTATORS) { - SendChatTarget(ClientID, "没有登录不能投票"); + SendChatTarget(ClientID, _("没有登录不能投票")); return; } if(m_VoteCloseTime) { - SendChatTarget(ClientID, "请等待当前投票结束"); + SendChatTarget(ClientID, _("请等待当前投票结束")); return; } @@ -1267,13 +1267,13 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) { if (Collision()->IntersectLine(pChr->m_TurRifle, pChr->m_Pos, &pChr->m_Pos, 0,false)) { - SendChatTarget(ClientID, "离墙远点!"); + SendChatTarget(ClientID, _("离墙远点!")); pChr->m_TurRifle = vec2(0, 0); return; } if (distance(pChr->m_TurRifle, pChr->m_Pos) < 50) { - SendChatTarget(ClientID, "距离太靠近了!"); + SendChatTarget(ClientID, _("距离太近了!")); pChr->m_TurRifle = vec2(0, 0); return; } @@ -1301,13 +1301,13 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) { if (Collision()->IntersectLine(pChr->m_TurGrenade, pChr->m_Pos, &pChr->m_Pos, 0,false)) { - SendChatTarget(ClientID, "离墙远点!"); + SendChatTarget(ClientID, _("离墙远点!")); pChr->m_TurGrenade = vec2(0, 0); return; } if (distance(pChr->m_TurGrenade, pChr->m_Pos) < 50) { - SendChatTarget(ClientID, "距离太靠近了!"); + SendChatTarget(ClientID, _("距离太靠近了!")); pChr->m_TurGrenade = vec2(0, 0); return; } diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index af6af2a..e9f865d 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -13,6 +13,7 @@ #include "entities/zdoor.h" #include +#include IGameController::IGameController(class CGameContext *pGameServer) { @@ -220,12 +221,12 @@ void IGameController::EndRound() float kofs = (k / (k + d)) * 100; char aBuf[64]; - GameServer()->SendChatTarget(-1, "----------------------------------"); + GameServer()->SendChatTarget(-1, _("----------------------------------")); str_format(aBuf, sizeof(aBuf), "僵尸: %s (胜利)", Server()->ClientName(m_LastZomb)); GameServer()->SendChatTarget(-1, aBuf); str_format(aBuf, sizeof(aBuf), "胜利: %d / 失败: %d (%.1f)", GameServer()->m_apPlayers[m_LastZomb]->m_AccData.m_Winner, GameServer()->m_apPlayers[m_LastZomb]->m_AccData.m_Luser, kofs); GameServer()->SendChatTarget(-1, aBuf); - GameServer()->SendChatTarget(-1, "----------------------------------"); + GameServer()->SendChatTarget(-1, _("----------------------------------")); } } m_aTeamscore[TEAM_RED] = 100; @@ -250,12 +251,12 @@ void IGameController::EndRound() float kofs = (k / (k + d)) * 100; char aBuf[64]; - GameServer()->SendChatTarget(-1, "----------------------------------"); + GameServer()->SendChatTarget(-1, _("----------------------------------")); str_format(aBuf, sizeof(aBuf), "僵尸: %s (失败)", Server()->ClientName(m_LastZomb)); GameServer()->SendChatTarget(-1, aBuf); str_format(aBuf, sizeof(aBuf), "胜利: %d / 失败: %d (%.1f)", GameServer()->m_apPlayers[m_LastZomb]->m_AccData.m_Winner, GameServer()->m_apPlayers[m_LastZomb]->m_AccData.m_Luser, kofs); GameServer()->SendChatTarget(-1, aBuf); - GameServer()->SendChatTarget(-1, "----------------------------------"); + GameServer()->SendChatTarget(-1, _("----------------------------------")); } } m_aTeamscore[TEAM_BLUE] = 100; @@ -367,12 +368,12 @@ void IGameController::OnCharacterSpawn(class CCharacter *pChr) if (GameServer()->m_apPlayers[BigLvlID] && pChr->GetPlayer()->GetCID() != BigLvlID) { if (GameServer()->m_apPlayers[BigLvlID]->m_AccData.m_Level > pChr->GetPlayer()->m_AccData.m_Level && GameServer()->m_apPlayers[BigLvlID]->m_AccData.m_Level > 20) - pChr->IncreaseHealth(700 + pChr->GetPlayer()->m_AccData.m_Level * 10 + pChr->GetPlayer()->m_AccData.m_Health * 50 + GameServer()->m_apPlayers[BigLvlID]->m_AccData.m_Level * 5); + pChr->IncreaseHealth(70 + pChr->GetPlayer()->m_AccData.m_Level * 10 + pChr->GetPlayer()->m_AccData.m_Health * 20 + GameServer()->m_apPlayers[BigLvlID]->m_AccData.m_Level); else - pChr->IncreaseHealth(200 + pChr->GetPlayer()->m_AccData.m_Level * 10 + pChr->GetPlayer()->m_AccData.m_Health * 50); + pChr->IncreaseHealth(20 + pChr->GetPlayer()->m_AccData.m_Level * 10 + pChr->GetPlayer()->m_AccData.m_Health * 20); } else - pChr->IncreaseHealth(700 + pChr->GetPlayer()->m_AccData.m_Level * 10 + pChr->GetPlayer()->m_AccData.m_Health * 50); + pChr->IncreaseHealth(70 + pChr->GetPlayer()->m_AccData.m_Level * 10 + pChr->GetPlayer()->m_AccData.m_Health * 20); pChr->GiveWeapon(WEAPON_HAMMER, -1); pChr->GiveWeapon(WEAPON_GUN, 10); diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 1a2e328..19275f9 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -15,6 +15,8 @@ #include "entities/cmds.h" #include +#include + MACRO_ALLOC_POOL_ID_IMPL(CPlayer, MAX_CLIENTS) IServer *CPlayer::Server() const { return m_pGameServer->Server(); } @@ -27,13 +29,13 @@ CPlayer::CPlayer(CGameContext *pGameServer, int ClientID, int Team) m_pCharacter = 0; m_NumInputs = 0; m_KillMe = 0; - + m_pAccount = new CAccount(this, m_pGameServer); - m_pChatCmd = new CCmd(this, m_pGameServer); - - if(m_AccData.m_UserID) + m_pChatCmd = new CCmd(this, m_pGameServer); + + if (m_AccData.m_UserID) m_pAccount->Apply(); - + Reset(); } @@ -53,8 +55,8 @@ void CPlayer::Reset() m_SpectatorID = SPEC_FREEVIEW; m_LastActionTick = Server()->Tick(); - int* idMap = Server()->GetIdMap(m_ClientID); - for (int i = 1;i < VANILLA_MAX_CLIENTS;i++) + int *idMap = Server()->GetIdMap(m_ClientID); + for (int i = 1; i < VANILLA_MAX_CLIENTS; i++) { idMap[i] = -1; } @@ -84,15 +86,15 @@ void CPlayer::Reset() void CPlayer::Tick() { #ifdef CONF_DEBUG - if(!g_Config.m_DbgDummies || m_ClientID < MAX_CLIENTS-g_Config.m_DbgDummies) + if (!g_Config.m_DbgDummies || m_ClientID < MAX_CLIENTS - g_Config.m_DbgDummies) #endif - if(!Server()->ClientIngame(m_ClientID)) - return; + if (!Server()->ClientIngame(m_ClientID)) + return; if (!m_AccData.m_UserID) m_Team = -1; - if(m_KillMe != 0) + if (m_KillMe != 0) { KillCharacter(m_KillMe); m_KillMe = 0; @@ -102,10 +104,10 @@ void CPlayer::Tick() if (m_ChatScore > 0) m_ChatScore--; - if (m_AccData.m_UserID && m_AccData.m_Exp >= m_AccData.m_Level * 3) + if (m_AccData.m_UserID && m_AccData.m_Exp >= ExpNeedToNextLvl()) { m_AccData.m_Money++; - m_AccData.m_Exp -= m_AccData.m_Level * 3; + m_AccData.m_Exp -= ExpNeedToNextLvl(); m_AccData.m_Level++; if (m_AccData.m_Exp < m_AccData.m_Level) { @@ -117,22 +119,22 @@ void CPlayer::Tick() GameServer()->SendChatTarget(m_ClientID, SendLVL); } } - + Server()->SetClientScore(m_ClientID, m_Score); // do latency stuff { IServer::CClientInfo Info; - if(Server()->GetClientInfo(m_ClientID, &Info)) + if (Server()->GetClientInfo(m_ClientID, &Info)) { m_Latency.m_Accum += Info.m_Latency; m_Latency.m_AccumMax = max(m_Latency.m_AccumMax, Info.m_Latency); m_Latency.m_AccumMin = min(m_Latency.m_AccumMin, Info.m_Latency); } // each second - if(Server()->Tick()%Server()->TickSpeed() == 0) + if (Server()->Tick() % Server()->TickSpeed() == 0) { - m_Latency.m_Avg = m_Latency.m_Accum/Server()->TickSpeed(); + m_Latency.m_Avg = m_Latency.m_Accum / Server()->TickSpeed(); m_Latency.m_Max = m_Latency.m_AccumMax; m_Latency.m_Min = m_Latency.m_AccumMin; m_Latency.m_Accum = 0; @@ -141,7 +143,7 @@ void CPlayer::Tick() } } - if(((CServer *)Server())->m_NetServer.ErrorString(m_ClientID)[0]) + if (((CServer *)Server())->m_NetServer.ErrorString(m_ClientID)[0]) { char aBuf[128]; str_format(aBuf, sizeof(aBuf), "'%s' would have timed out, but can use timeout protection now", Server()->ClientName(m_ClientID)); @@ -149,17 +151,17 @@ void CPlayer::Tick() ((CServer *)(Server()))->m_NetServer.ResetErrorString(m_ClientID); } - if(!GameServer()->m_World.m_Paused) + if (!GameServer()->m_World.m_Paused) { - if(!m_pCharacter && m_Team == TEAM_SPECTATORS && m_SpectatorID == SPEC_FREEVIEW) - m_ViewPos -= vec2(clamp(m_ViewPos.x-m_LatestActivity.m_TargetX, -500.0f, 500.0f), clamp(m_ViewPos.y-m_LatestActivity.m_TargetY, -400.0f, 400.0f)); + if (!m_pCharacter && m_Team == TEAM_SPECTATORS && m_SpectatorID == SPEC_FREEVIEW) + m_ViewPos -= vec2(clamp(m_ViewPos.x - m_LatestActivity.m_TargetX, -500.0f, 500.0f), clamp(m_ViewPos.y - m_LatestActivity.m_TargetY, -400.0f, 400.0f)); - if(!m_pCharacter && m_DieTick+Server()->TickSpeed()*3 <= Server()->Tick()) + if (!m_pCharacter && m_DieTick + Server()->TickSpeed() * 3 <= Server()->Tick()) m_Spawning = true; - if(m_pCharacter) + if (m_pCharacter) { - if(m_pCharacter->IsAlive()) + if (m_pCharacter->IsAlive()) m_ViewPos = m_pCharacter->m_Pos; else { @@ -167,7 +169,7 @@ void CPlayer::Tick() m_pCharacter = 0; } } - else if(m_Spawning && m_RespawnTick <= Server()->Tick()) + else if (m_Spawning && m_RespawnTick <= Server()->Tick()) TryRespawn(); } else @@ -190,45 +192,51 @@ void CPlayer::Tick() void CPlayer::PostTick() { - if(m_PlayerFlags&PLAYERFLAG_SCOREBOARD) + if (m_PlayerFlags & PLAYERFLAG_SCOREBOARD) { - for(int i = 0; i < MAX_CLIENTS; ++i) + for (int i = 0; i < MAX_CLIENTS; ++i) { - if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS) + if (GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS) m_aActLatency[i] = GameServer()->m_apPlayers[i]->m_Latency.m_Min; } } - if(m_Team == TEAM_SPECTATORS && m_SpectatorID != SPEC_FREEVIEW && GameServer()->m_apPlayers[m_SpectatorID] && GameServer()->m_apPlayers[m_SpectatorID]->GetCharacter()) + if (m_Team == TEAM_SPECTATORS && m_SpectatorID != SPEC_FREEVIEW && GameServer()->m_apPlayers[m_SpectatorID] && GameServer()->m_apPlayers[m_SpectatorID]->GetCharacter()) m_ViewPos = GameServer()->m_apPlayers[m_SpectatorID]->GetCharacter()->m_Pos; } void CPlayer::Snap(int SnappingClient) { #ifdef CONF_DEBUG - if(!g_Config.m_DbgDummies || m_ClientID < MAX_CLIENTS-g_Config.m_DbgDummies) + if (!g_Config.m_DbgDummies || m_ClientID < MAX_CLIENTS - g_Config.m_DbgDummies) #endif - if(!Server()->ClientIngame(m_ClientID)) - return; + if (!Server()->ClientIngame(m_ClientID)) + return; int id = m_ClientID; - if (SnappingClient > -1 && !Server()->Translate(id, SnappingClient)) + if (SnappingClient > -1 && !Server()->Translate(id, SnappingClient)) return; CNetObj_ClientInfo *pClientInfo = static_cast(Server()->SnapNewItem(NETOBJTYPE_CLIENTINFO, id, sizeof(CNetObj_ClientInfo))); - if(!pClientInfo) + if (!pClientInfo) return; char pSendName[22]; if (m_AccData.m_UserID) { - if (m_AccData.m_UserID == g_Config.m_SvOwnerAccID && m_Prefix) str_format(pSendName, sizeof(pSendName), "[O]%s", Server()->ClientName(m_ClientID)); - else if(Server()->IsAuthed(GetCID()) && m_Prefix) str_format(pSendName, sizeof(pSendName), "[A]%s", Server()->ClientName(m_ClientID)); - else if(m_AccData.m_PlayerState == 1) str_format(pSendName, sizeof(pSendName), "[P-%d]%s", m_AccData.m_Level, Server()->ClientName(m_ClientID)); - else if(m_AccData.m_PlayerState == 2 && m_Prefix) str_format(pSendName, sizeof(pSendName), "[VIP]%s", Server()->ClientName(m_ClientID)); - else if(m_AccData.m_PlayerState == 3) str_format(pSendName, sizeof(pSendName), "[H-%d]%s", m_AccData.m_Level, Server()->ClientName(m_ClientID)); - else str_format(pSendName, sizeof(pSendName), "[%d]%s", m_AccData.m_Level, Server()->ClientName(m_ClientID)); - - if(m_AccData.m_Freeze) + if (m_AccData.m_UserID == g_Config.m_SvOwnerAccID && m_Prefix) + str_format(pSendName, sizeof(pSendName), "[O]%s", Server()->ClientName(m_ClientID)); + else if (Server()->IsAuthed(GetCID()) && m_Prefix) + str_format(pSendName, sizeof(pSendName), "[A]%s", Server()->ClientName(m_ClientID)); + else if (m_AccData.m_PlayerState == 1) + str_format(pSendName, sizeof(pSendName), "[P-%d]%s", m_AccData.m_Level, Server()->ClientName(m_ClientID)); + else if (m_AccData.m_PlayerState == 2 && m_Prefix) + str_format(pSendName, sizeof(pSendName), "[VIP]%s", Server()->ClientName(m_ClientID)); + else if (m_AccData.m_PlayerState == 3) + str_format(pSendName, sizeof(pSendName), "[H-%d]%s", m_AccData.m_Level, Server()->ClientName(m_ClientID)); + else + str_format(pSendName, sizeof(pSendName), "[%d]%s", m_AccData.m_Level, Server()->ClientName(m_ClientID)); + + if (m_AccData.m_Freeze) str_format(pSendName, sizeof(pSendName), "[F-%d]%s", m_AccData.m_Level, Server()->ClientName(m_ClientID)); } StrToInts(&pClientInfo->m_Name0, 4, m_AccData.m_UserID ? pSendName : Server()->ClientName(m_ClientID)); @@ -240,7 +248,8 @@ void CPlayer::Snap(int SnappingClient) pClientInfo->m_UseCustomColor = 0; pClientInfo->m_ColorBody = m_TeeInfos.m_ColorBody; pClientInfo->m_ColorFeet = m_TeeInfos.m_ColorFeet; - } else + } + else { StrToInts(&pClientInfo->m_Skin0, 6, m_TeeInfos.m_SkinName); pClientInfo->m_UseCustomColor = m_TeeInfos.m_UseCustomColor; @@ -249,7 +258,7 @@ void CPlayer::Snap(int SnappingClient) } CNetObj_PlayerInfo *pPlayerInfo = static_cast(Server()->SnapNewItem(NETOBJTYPE_PLAYERINFO, id, sizeof(CNetObj_PlayerInfo))); - if(!pPlayerInfo) + if (!pPlayerInfo) return; pPlayerInfo->m_Latency = SnappingClient == -1 ? m_Latency.m_Min : GameServer()->m_apPlayers[SnappingClient]->m_aActLatency[m_ClientID]; @@ -258,13 +267,13 @@ void CPlayer::Snap(int SnappingClient) pPlayerInfo->m_Score = m_Score; pPlayerInfo->m_Team = m_Team; - if(m_ClientID == SnappingClient) + if (m_ClientID == SnappingClient) pPlayerInfo->m_Local = 1; - if(m_ClientID == SnappingClient && m_Team == TEAM_SPECTATORS) + if (m_ClientID == SnappingClient && m_Team == TEAM_SPECTATORS) { CNetObj_SpectatorInfo *pSpectatorInfo = static_cast(Server()->SnapNewItem(NETOBJTYPE_SPECTATORINFO, m_ClientID, sizeof(CNetObj_SpectatorInfo))); - if(!pSpectatorInfo) + if (!pSpectatorInfo) return; pSpectatorInfo->m_SpectatorID = m_SpectatorID; @@ -277,7 +286,7 @@ void CPlayer::FakeSnap(int SnappingClient) { IServer::CClientInfo info; Server()->GetClientInfo(SnappingClient, &info); - CGameContext *GameContext = (CGameContext *) GameServer(); + CGameContext *GameContext = (CGameContext *)GameServer(); if (SnappingClient > -1 && GameContext->m_apPlayers[SnappingClient] && GameContext->m_apPlayers[SnappingClient]->m_ClientVersion >= VERSION_DDNET_OLD) return; @@ -285,7 +294,7 @@ void CPlayer::FakeSnap(int SnappingClient) CNetObj_ClientInfo *pClientInfo = static_cast(Server()->SnapNewItem(NETOBJTYPE_CLIENTINFO, id, sizeof(CNetObj_ClientInfo))); - if(!pClientInfo) + if (!pClientInfo) return; StrToInts(&pClientInfo->m_Name0, 4, " "); @@ -295,26 +304,25 @@ void CPlayer::FakeSnap(int SnappingClient) void CPlayer::OnDisconnect(const char *pReason) { - if(m_AccData.m_UserID) + if (m_AccData.m_UserID) m_pAccount->Reset(); - + KillCharacter(); - if(GameServer()->m_pController->NumZombs() == 1 && GetTeam() == TEAM_RED - && GameServer()->m_pController->ZombStarted() && !GameServer()->m_pController->m_Warmup) + if (GameServer()->m_pController->NumZombs() == 1 && GetTeam() == TEAM_RED && GameServer()->m_pController->ZombStarted() && !GameServer()->m_pController->m_Warmup) { char aBuf[128], aAddrStr[NETADDR_MAXSTRSIZE] = {0}; str_format(aBuf, sizeof(aBuf), "'%s' 被禁止进入这个世界 (应为作为唯一的僵尸退出,所以封禁5分钟)", Server()->ClientName(m_ClientID)); GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf); - + Server()->GetClientAddr(m_ClientID, aAddrStr, sizeof(aAddrStr)); str_format(aBuf, sizeof(aBuf), "ban %s 5 You were last zombie", aAddrStr); GameServer()->Console()->ExecuteLine(aBuf); } - else if(Server()->ClientIngame(m_ClientID)) + else if (Server()->ClientIngame(m_ClientID)) { char aBuf[96]; - if(pReason && *pReason) + if (pReason && *pReason) str_format(aBuf, sizeof(aBuf), "'%s' 被强制离开了这个世界 (%s)", Server()->ClientName(m_ClientID), pReason); else str_format(aBuf, sizeof(aBuf), "'%s' 离开了这个世界", Server()->ClientName(m_ClientID)); @@ -327,13 +335,13 @@ void CPlayer::OnDisconnect(const char *pReason) void CPlayer::OnPredictedInput(CNetObj_PlayerInput *NewInput) { - if((m_PlayerFlags&PLAYERFLAG_CHATTING) && (NewInput->m_PlayerFlags&PLAYERFLAG_CHATTING)) + if ((m_PlayerFlags & PLAYERFLAG_CHATTING) && (NewInput->m_PlayerFlags & PLAYERFLAG_CHATTING)) return; AfkVoteTimer(NewInput); m_NumInputs++; - if(m_pCharacter) + if (m_pCharacter) m_pCharacter->OnPredictedInput(NewInput); } @@ -343,14 +351,14 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput) return; // we must return if kicked, as player struct is already deleted AfkVoteTimer(NewInput); - if(NewInput->m_PlayerFlags&PLAYERFLAG_CHATTING) + if (NewInput->m_PlayerFlags & PLAYERFLAG_CHATTING) { - // skip the input if chat is active - if(m_PlayerFlags&PLAYERFLAG_CHATTING) - return; + // skip the input if chat is active + if (m_PlayerFlags & PLAYERFLAG_CHATTING) + return; // reset input - if(m_pCharacter) + if (m_pCharacter) m_pCharacter->ResetInput(); m_PlayerFlags = NewInput->m_PlayerFlags; @@ -359,19 +367,19 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput) m_PlayerFlags = NewInput->m_PlayerFlags; - if(m_pCharacter) + if (m_pCharacter) m_pCharacter->OnDirectInput(NewInput); - if(!m_pCharacter && m_Team != TEAM_SPECTATORS && (NewInput->m_Fire&1)) + if (!m_pCharacter && m_Team != TEAM_SPECTATORS && (NewInput->m_Fire & 1)) m_Spawning = true; - if(!m_pCharacter && m_Team == TEAM_SPECTATORS && m_SpectatorID == SPEC_FREEVIEW) + if (!m_pCharacter && m_Team == TEAM_SPECTATORS && m_SpectatorID == SPEC_FREEVIEW) m_ViewPos = vec2(NewInput->m_TargetX, NewInput->m_TargetY); // check for activity - if(NewInput->m_Direction || m_LatestActivity.m_TargetX != NewInput->m_TargetX || + if (NewInput->m_Direction || m_LatestActivity.m_TargetX != NewInput->m_TargetX || m_LatestActivity.m_TargetY != NewInput->m_TargetY || NewInput->m_Jump || - NewInput->m_Fire&1 || NewInput->m_Hook) + NewInput->m_Fire & 1 || NewInput->m_Hook) { m_LatestActivity.m_TargetX = NewInput->m_TargetX; m_LatestActivity.m_TargetY = NewInput->m_TargetY; @@ -381,14 +389,14 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput) CCharacter *CPlayer::GetCharacter() { - if(m_pCharacter && m_pCharacter->IsAlive()) + if (m_pCharacter && m_pCharacter->IsAlive()) return m_pCharacter; return 0; } void CPlayer::KillCharacter(int Weapon) { - if(m_pCharacter) + if (m_pCharacter) { m_pCharacter->Die(m_ClientID, Weapon); delete m_pCharacter; @@ -398,36 +406,36 @@ void CPlayer::KillCharacter(int Weapon) void CPlayer::Respawn() { - if(m_Team != TEAM_SPECTATORS) + if (m_Team != TEAM_SPECTATORS) m_Spawning = true; } void CPlayer::SetTeam(int Team, bool DoChatMsg) { Team = GameServer()->m_pController->ClampTeam(Team); - if(m_Team == Team) + if (m_Team == Team) return; if (!m_AccData.m_UserID) return GameServer()->SendBroadcast("输入/help获取帮助.", m_ClientID); - if (m_Team == TEAM_RED && Team != TEAM_SPECTATORS) + if (m_Team == TEAM_RED && Team != TEAM_SPECTATORS) return GameServer()->SendBroadcast("僵尸不能改团队.", m_ClientID); if (GameServer()->m_pController->ZombStarted() && !GameServer()->m_pController->m_Warmup && Team == TEAM_BLUE) return GameServer()->SendBroadcast("你只能在游戏没开始的时候加入人类.", m_ClientID); - + if (Team == TEAM_RED && ((GameServer()->m_pController->ZombStarted() && GameServer()->m_pController->m_Warmup) || !GameServer()->m_pController->ZombStarted())) return GameServer()->SendBroadcast("僵尸会在开始时随机选择.", m_ClientID); if (m_Team == TEAM_BLUE && GameServer()->m_pController->ZombStarted()) return GameServer()->SendBroadcast("你不能加入僵尸.", m_ClientID); - + if (m_Team == TEAM_RED && GameServer()->m_pController->NumZombs() < 2 && GameServer()->m_pController->ZombStarted()) return GameServer()->SendBroadcast("你是那唯一的僵尸.", m_ClientID); char aBuf[64]; - if(DoChatMsg) + if (DoChatMsg) { str_format(aBuf, sizeof(aBuf), "'%s' joined the %s", Server()->ClientName(m_ClientID), GameServer()->m_pController->GetTeamName(Team)); GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf); @@ -439,18 +447,18 @@ void CPlayer::SetTeam(int Team, bool DoChatMsg) m_LastActionTick = Server()->Tick(); m_SpectatorID = SPEC_FREEVIEW; - m_RespawnTick = Server()->Tick()+Server()->TickSpeed()/2; + m_RespawnTick = Server()->Tick() + Server()->TickSpeed() / 2; str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' m_Team=%d", m_ClientID, Server()->ClientName(m_ClientID), m_Team); GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); GameServer()->m_pController->OnPlayerInfoChange(GameServer()->m_apPlayers[m_ClientID]); GameServer()->m_pController->CheckZomb(); - if(Team == TEAM_SPECTATORS) + if (Team == TEAM_SPECTATORS) { - for(int i = 0; i < MAX_CLIENTS; ++i) + for (int i = 0; i < MAX_CLIENTS; ++i) { - if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->m_SpectatorID == m_ClientID) + if (GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->m_SpectatorID == m_ClientID) GameServer()->m_apPlayers[i]->m_SpectatorID = SPEC_FREEVIEW; } } @@ -460,11 +468,11 @@ void CPlayer::TryRespawn() { vec2 SpawnPos; - if(!GameServer()->m_pController->CanSpawn(m_Team, &SpawnPos)) + if (!GameServer()->m_pController->CanSpawn(m_Team, &SpawnPos)) return; m_Spawning = false; - m_pCharacter = new(m_ClientID) CCharacter(&GameServer()->m_World); + m_pCharacter = new (m_ClientID) CCharacter(&GameServer()->m_World); m_pCharacter->Spawn(this, SpawnPos); GameServer()->CreatePlayerSpawn(SpawnPos); } @@ -480,49 +488,46 @@ bool CPlayer::AfkTimer(int NewTargetX, int NewTargetY) returns true if kicked */ - if(m_Authed) + if (m_Authed) return false; // don't kick admins - if(g_Config.m_SvMaxAfkTime == 0) + if (g_Config.m_SvMaxAfkTime == 0) return false; // 0 = disabled - if(NewTargetX != m_LastTarget_x || NewTargetY != m_LastTarget_y) + if (NewTargetX != m_LastTarget_x || NewTargetY != m_LastTarget_y) { m_LastPlaytime = time_get(); m_LastTarget_x = NewTargetX; m_LastTarget_y = NewTargetY; m_Sent1stAfkWarning = 0; // afk timer's 1st warning after 50% of sv_max_afk_time m_Sent2ndAfkWarning = 0; - } else { // not playing, check how long - if(m_Sent1stAfkWarning == 0 && m_LastPlaytime < time_get()-time_freq()*(int)(g_Config.m_SvMaxAfkTime*0.5)) + if (m_Sent1stAfkWarning == 0 && m_LastPlaytime < time_get() - time_freq() * (int)(g_Config.m_SvMaxAfkTime * 0.5)) { sprintf( m_pAfkMsg, "You have been afk for %d seconds now. Please note that you get kicked after not playing for %d seconds.", - (int)(g_Config.m_SvMaxAfkTime*0.5), - g_Config.m_SvMaxAfkTime - ); + (int)(g_Config.m_SvMaxAfkTime * 0.5), + g_Config.m_SvMaxAfkTime); m_pGameServer->SendChatTarget(m_ClientID, m_pAfkMsg); m_Sent1stAfkWarning = 1; } - else if(m_Sent2ndAfkWarning == 0 && m_LastPlaytime < time_get()-time_freq()*(int)(g_Config.m_SvMaxAfkTime*0.9)) + else if (m_Sent2ndAfkWarning == 0 && m_LastPlaytime < time_get() - time_freq() * (int)(g_Config.m_SvMaxAfkTime * 0.9)) { sprintf( m_pAfkMsg, "You have been afk for %d seconds now. Please note that you get kicked after not playing for %d seconds.", - (int)(g_Config.m_SvMaxAfkTime*0.9), - g_Config.m_SvMaxAfkTime - ); + (int)(g_Config.m_SvMaxAfkTime * 0.9), + g_Config.m_SvMaxAfkTime); m_pGameServer->SendChatTarget(m_ClientID, m_pAfkMsg); m_Sent2ndAfkWarning = 1; } - else if(m_LastPlaytime < time_get()-time_freq()*g_Config.m_SvMaxAfkTime) + else if (m_LastPlaytime < time_get() - time_freq() * g_Config.m_SvMaxAfkTime) { - CServer* serv = (CServer*)m_pGameServer->Server(); - serv->Kick(m_ClientID,"Away from keyboard"); + CServer *serv = (CServer *)m_pGameServer->Server(); + serv->Kick(m_ClientID, "Away from keyboard"); return true; } } @@ -531,15 +536,15 @@ bool CPlayer::AfkTimer(int NewTargetX, int NewTargetY) void CPlayer::AfkVoteTimer(CNetObj_PlayerInput *NewTarget) { - if(g_Config.m_SvMaxAfkVoteTime == 0) + if (g_Config.m_SvMaxAfkVoteTime == 0) return; - if(mem_comp(NewTarget, &m_LastTarget, sizeof(CNetObj_PlayerInput)) != 0) + if (mem_comp(NewTarget, &m_LastTarget, sizeof(CNetObj_PlayerInput)) != 0) { m_LastPlaytime = time_get(); mem_copy(&m_LastTarget, NewTarget, sizeof(CNetObj_PlayerInput)); } - else if(m_LastPlaytime < time_get()-time_freq()*g_Config.m_SvMaxAfkVoteTime) + else if (m_LastPlaytime < time_get() - time_freq() * g_Config.m_SvMaxAfkVoteTime) { m_Afk = true; return; @@ -550,7 +555,7 @@ void CPlayer::AfkVoteTimer(CNetObj_PlayerInput *NewTarget) bool CPlayer::IsPlaying() { - if(m_pCharacter && m_pCharacter->IsAlive()) + if (m_pCharacter && m_pCharacter->IsAlive()) return true; return false; } @@ -564,8 +569,8 @@ void CPlayer::SetZomb(int From) Msg.m_Victim = m_ClientID; Msg.m_Weapon = WEAPON_HAMMER; GameServer()->m_apPlayers[From]->m_Score++; - if(GameServer()->GetPlayerChar(From) && From != m_ClientID) - GameServer()->GetPlayerChar(From)->ExperienceAdd(3 + m_AccData.m_Level / 50 * g_Config.m_SvExpBonus, From); + if (GameServer()->GetPlayerChar(From) && From != m_ClientID) + GameServer()->GetPlayerChar(From)->ExperienceAdd(g_Config.m_SvExpBonus, From); } Msg.m_ModeSpecial = 0; Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1); @@ -574,7 +579,7 @@ void CPlayer::SetZomb(int From) { if (From == -1) { - char aBuf[52]; + char aBuf[52]; str_format(aBuf, sizeof(aBuf), "'%s' 想要你的脑子!快跑!", Server()->ClientName(m_ClientID)); GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf); } @@ -585,7 +590,7 @@ void CPlayer::SetZomb(int From) m_pCharacter->SetZomb(); GameServer()->m_pController->OnPlayerInfoChange(GameServer()->m_apPlayers[m_ClientID]); GameServer()->m_pController->CheckZomb(); - GameServer()->SendChatTarget(m_ClientID, "你是一个僵尸了!吃掉他们的脑子!."); + GameServer()->SendChatTarget(m_ClientID, _("你被感染成了僵尸!吃掉他们的脑子!.")); } void CPlayer::ResetZomb() diff --git a/src/game/server/player.h b/src/game/server/player.h index 06da178..158d88a 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -84,6 +84,7 @@ class CPlayer class CCmd *m_pChatCmd; class CAccount *m_pAccount; + int ExpNeedToNextLvl() { return m_AccData.m_Level * 10; } // bool m_ActivesLife;