Skip to content
This repository has been archived by the owner on Jun 26, 2019. It is now read-only.

Commit

Permalink
some merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillerDragon committed Dec 12, 2018
2 parents 96d6f08 + 13acd08 commit 6928f1f
Show file tree
Hide file tree
Showing 49 changed files with 1,942 additions and 1,262 deletions.
11 changes: 1 addition & 10 deletions bam.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
CheckVersion("0.5")

Import("configure.lua")
Import("other/sdl/sdl.lua")
Import("other/freetype/freetype.lua")

--- Setup Config -------
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(OptLibrary("zlib", "zlib.h", false))
config:Add(SDL.OptFind("sdl", true))
config:Add(FreeType.OptFind("freetype", true))
config:Finalize("config.lua")

generated_src_dir = "build/src"
Expand Down Expand Up @@ -158,8 +154,6 @@ function GenerateMacOSXSettings(settings, conf, arch, compiler)
-- Client
settings.link.frameworks:Add("OpenGL")
settings.link.frameworks:Add("AGL")
-- FIXME: the SDL config is applied in BuildClient too but is needed here before so the launcher will compile
config.sdl:Apply(settings)
BuildClient(settings)

-- Content
Expand Down Expand Up @@ -274,7 +268,7 @@ function SharedCommonFiles()
if not shared_common_files then
local network_source = ContentCompile("network_source", "generated/protocol.cpp")
local network_header = ContentCompile("network_header", "generated/protocol.h")
AddDependency(network_source, network_header)
AddDependency(network_source, network_header, "src/engine/shared/protocol.h")

local nethash = CHash("generated/nethash.cpp", "src/engine/shared/protocol.h", "src/game/tuning.h", "src/game/gamecore.cpp", network_header)
shared_common_files = {network_source, nethash}
Expand Down Expand Up @@ -329,9 +323,6 @@ end


function BuildClient(settings, family, platform)
config.sdl:Apply(settings)
config.freetype:Apply(settings)

local client = Compile(settings, Collect("src/engine/client/*.cpp"))

local game_client = Compile(settings, CollectRecursive("src/game/client/*.cpp"), SharedClientFiles())
Expand Down
Binary file modified datasrc/mapres/jungle_unhookables.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion datasrc/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,12 @@
NetIntRange("m_SoundID", 0, 'NUM_SOUNDS-1'),
]),

NetEvent("DamageInd:Common", [
NetEvent("Damage:Common", [ # Unused yet
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'),
NetIntAny("m_Angle"),
NetIntRange("m_HealthAmount", 0, 9),
NetIntRange("m_ArmorAmount", 0, 9),
NetBool("m_Self"),
]),
]

Expand Down
34 changes: 20 additions & 14 deletions scripts/make_release.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import shutil, optparse, os, re, sys, zipfile
from distutils.dir_util import copy_tree
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])) + "/..")
import twlib

Expand Down Expand Up @@ -124,9 +125,9 @@ def clean():
shutil.copy("storage.cfg", package_dir)

if include_data and not use_bundle:
shutil.copytree(source_package_dir+"data", package_dir+"/data")
copyfiles(languages_dir, package_dir+"/data/languages")
copyfiles(maps_dir, package_dir+"/data/maps")
copy_tree(source_package_dir+"data", package_dir+"/data")
copy_tree(languages_dir, package_dir+"/data/languages")
copy_tree(maps_dir, package_dir+"/data/maps")
if platform[:3] == "win":
shutil.copy("other/config_directory.bat", package_dir)
shutil.copy(source_package_dir+"SDL2.dll", package_dir)
Expand All @@ -145,7 +146,7 @@ def clean():

if use_bundle:
bins = [name, name+'_srv', 'serverlaunch']
platforms = ('x86', 'x86_64', 'ppc')
platforms = ('x86_64')
for bin in bins:
to_lipo = []
for p in platforms:
Expand All @@ -160,19 +161,21 @@ def clean():
clientbundle_bin_dir = os.path.join(clientbundle_content_dir, "MacOS")
clientbundle_resource_dir = os.path.join(clientbundle_content_dir, "Resources")
clientbundle_framework_dir = os.path.join(clientbundle_content_dir, "Frameworks")
binary_path = clientbundle_bin_dir + "/" + name+exe_ext
os.mkdir(os.path.join(package_dir, "Teeworlds.app"))
os.mkdir(clientbundle_content_dir)
os.mkdir(clientbundle_bin_dir)
os.mkdir(clientbundle_resource_dir)
os.mkdir(clientbundle_framework_dir)
os.mkdir(os.path.join(clientbundle_resource_dir, "data"))
copydir("data", clientbundle_resource_dir)
os.chdir(languages_dir)
copydir("data", "../"+clientbundle_resource_dir)
os.chdir("..")
copy_tree(source_package_dir+"data", clientbundle_resource_dir+"/data")
copy_tree(languages_dir, clientbundle_resource_dir+"/data/languages")
copy_tree(maps_dir, clientbundle_resource_dir+"/data/maps")
shutil.copy("other/icons/Teeworlds.icns", clientbundle_resource_dir)
shutil.copy(name+exe_ext, clientbundle_bin_dir)
os.system("cp -R /Library/Frameworks/SDL.framework " + clientbundle_framework_dir)
shutil.copy(source_package_dir+name+exe_ext, clientbundle_bin_dir)
os.system("install_name_tool -change /usr/local/opt/freetype/lib/libfreetype.6.dylib @executable_path/../Frameworks/libfreetype.6.dylib " + binary_path)
os.system("install_name_tool -change /usr/local/opt/sdl2/lib/libSDL2-2.0.0.dylib @executable_path/../Frameworks/libSDL2-2.0.0.dylib " + binary_path)
os.system("cp /usr/local/opt/freetype/lib/libfreetype.6.dylib " + clientbundle_framework_dir)
os.system("cp /usr/local/opt/sdl2/lib/libSDL2-2.0.0.dylib " + clientbundle_framework_dir)
file(os.path.join(clientbundle_content_dir, "Info.plist"), "w").write("""
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Expand All @@ -192,6 +195,9 @@ def clean():
<string>????</string>
<key>CFBundleVersion</key>
<string>%s</string>
<key>CFBundleIdentifier</key>
<string>com.TeeworldsClient.app</string>
<key>NSHighResolutionCapable</key>
</dict>
</plist>
""" % (version))
Expand All @@ -208,10 +214,10 @@ def clean():
os.mkdir(os.path.join(serverbundle_resource_dir, "data"))
os.mkdir(os.path.join(serverbundle_resource_dir, "data/maps"))
os.mkdir(os.path.join(serverbundle_resource_dir, "data/mapres"))
copydir("data/maps", serverbundle_resource_dir)
copy_tree(maps_dir, serverbundle_resource_dir+"/data/maps")
shutil.copy("other/icons/Teeworlds_srv.icns", serverbundle_resource_dir)
shutil.copy(name+"_srv"+exe_ext, serverbundle_bin_dir)
shutil.copy("serverlaunch"+exe_ext, serverbundle_bin_dir + "/"+name+"_server")
shutil.copy(source_package_dir+name+"_srv"+exe_ext, serverbundle_bin_dir)
shutil.copy(source_package_dir+"serverlaunch"+exe_ext, serverbundle_bin_dir + "/"+name+"_server")
file(os.path.join(serverbundle_content_dir, "Info.plist"), "w").write("""
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Expand Down
44 changes: 24 additions & 20 deletions scripts/tw_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ def pack_control_msg_with_token(token_srv,token_cl):
NET_TOKENREQUEST_DATASIZE = 512
b = [0]*(4 + 3 + NET_TOKENREQUEST_DATASIZE)
# Header
b[0] = (token_srv >> 24) & 0xff
b[1] = (token_srv >> 16) & 0xff
b[2] = (token_srv >> 8) & 0xff
b[3] = (token_srv) & 0xff
b[4] = (NET_PACKETFLAG_CONTROL<<2)&0xfc
b[0] = (NET_PACKETFLAG_CONTROL<<2)&0xfc
b[3] = (token_srv >> 24) & 0xff
b[4] = (token_srv >> 16) & 0xff
b[5] = (token_srv >> 8) & 0xff
b[6] = (token_srv) & 0xff
# Data
b[7] = NET_CTRLMSG_TOKEN
b[8] = (token_cl >> 24) & 0xff
Expand All @@ -41,7 +41,7 @@ def pack_control_msg_with_token(token_srv,token_cl):

def unpack_control_msg_with_token(msg):
b = list(msg)
token_cl = (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + (b[3])
token_cl = (b[3] << 24) + (b[4] << 16) + (b[5] << 8) + (b[6])
token_srv = (b[8] << 24) + (b[9] << 16) + (b[10] << 8) + (b[11])
return token_cl,token_srv

Expand All @@ -50,11 +50,13 @@ def header_connless(token_srv, token_cl):
NET_PACKETFLAG_CONNLESS = 8
NET_PACKETVERSION = 1
b = [0]*9
b[0] = (token_srv >> 24) & 0xff
b[1] = (token_srv >> 16) & 0xff
b[2] = (token_srv >> 8) & 0xff
b[3] = (token_srv) & 0xff
b[4] = ((NET_PACKETFLAG_CONNLESS<<2)&0xfc) | (NET_PACKETVERSION&0x03)
# Header
b[0] = ((NET_PACKETFLAG_CONNLESS<<2)&0xfc) | (NET_PACKETVERSION&0x03)
b[1] = (token_srv >> 24) & 0xff
b[2] = (token_srv >> 16) & 0xff
b[3] = (token_srv >> 8) & 0xff
b[4] = (token_srv) & 0xff
# ResponseToken
b[5] = (token_cl >> 24) & 0xff
b[6] = (token_cl >> 16) & 0xff
b[7] = (token_cl >> 8) & 0xff
Expand Down Expand Up @@ -148,11 +150,7 @@ def get_server_info(address):
data = slots[2]
player["country"], data = unpack_int(data)
player["score"], data = unpack_int(data)
is_player, data = unpack_int(data)
if is_player:
player["player"] = True
else:
player["player"] = False
player["player"], data = unpack_int(data)
server_info["players"].append(player)

return server_info
Expand Down Expand Up @@ -183,6 +181,7 @@ def run(self):

def get_list(address):
servers = []
answer = False

try:
sock = socket(AF_INET, SOCK_DGRAM)
Expand All @@ -195,6 +194,7 @@ def get_list(address):
data, addr = sock.recvfrom(1024)
token_cl, token_srv = unpack_control_msg_with_token(data)
assert token_cl == token, "Master %s send wrong token: %d (%d expected)" % (address, token_cl, token)
answer = True

# Get list request
sock.sendto(header_connless(token_srv, token_cl) + PACKET_GETLIST, addr)
Expand All @@ -221,7 +221,7 @@ def get_list(address):
except AssertionError as e:
print(*e.args)
except OSError as e: # Timeout
if not servers:
if not answer:
print('> Master %s did not answer' % (address,))
except:
# import traceback
Expand All @@ -239,12 +239,12 @@ def get_list(address):
m.start()
time.sleep(0.001) # avoid issues

servers = []
servers = set()

while len(master_servers) != 0:
if master_servers[0].finished == True:
if master_servers[0].servers:
servers += master_servers[0].servers
servers.update(master_servers[0].servers)
del master_servers[0]
time.sleep(0.001) # be nice

Expand All @@ -260,15 +260,19 @@ def get_list(address):

num_players = 0
num_clients = 0
num_bots = 0

while len(servers_info) != 0:
if servers_info[0].finished == True:
if servers_info[0].info:
num_players += servers_info[0].info["num_players"]
num_clients += servers_info[0].info["num_clients"]
for p in servers_info[0].info["players"]:
if p["player"] == 2:
num_bots += 1

del servers_info[0]

time.sleep(0.001) # be nice

print(str(num_players) + " players and " + str(num_clients-num_players) + " spectators")
print('%d players (%d bots) and %d spectators' % (num_players, num_bots, num_clients - num_players))
3 changes: 0 additions & 3 deletions src/engine/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "kernel.h"

#include "message.h"
#include "graphics.h"

class IClient : public IInterface
{
Expand Down Expand Up @@ -149,8 +148,6 @@ class IClient : public IInterface
virtual bool ConnectionProblems() const = 0;

virtual bool SoundInitFailed() const = 0;

virtual IGraphics::CTextureHandle GetDebugFont() const = 0; // TODO: remove this function
};

class IGameClient : public IInterface
Expand Down
Loading

0 comments on commit 6928f1f

Please sign in to comment.