Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow editor switch entities #3236 #105

Open
wants to merge 30 commits into
base: community
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bd39db0
feat(CMenus): Refresh ServerBrowser using F5
ViMaSter Dec 3, 2022
8f9af16
Run CI in merge queue
ChillerDragon Feb 6, 2024
0717835
Merge pull request #2 from teeworlds-community/pr_merge_queue
chillerbotjpg Feb 6, 2024
6cd375e
Merge pull request #68 from ChillerDragon/pr_remove_trailing_space_in…
jtbx Feb 22, 2024
127f4dd
Merge pull request #59 from ChillerDragon/pr_mark_snapsmall_unused
jtbx Feb 23, 2024
91b7164
Silence initial client info
ChillerDragon Jan 6, 2024
a418c36
Remove unreachable dmg indicator code
ChillerDragon Jan 2, 2024
0ea4a7d
Merge pull request #66 from ChillerDragon/pr_silence_initial_client_info
jtbx Feb 23, 2024
2740312
Merge pull request #65 from ChillerDragon/pr_remove_dead_dmg_code
jtbx Feb 23, 2024
03aaba9
Merge pull request #62 from ChillerDragon/pr_deco_enum
jtbx Feb 23, 2024
6e46204
Merge pull request #56 from ViMaSter/server-browser-f5
Bamcane Feb 23, 2024
263f7e6
Merge pull request #58 from ChillerDragon/pr_rm_useless_ass
Bamcane Feb 23, 2024
e93c6d2
Merge pull request #60 from ChillerDragon/pr_couldnt_not
Bamcane Feb 23, 2024
3cf7de0
Merge pull request #67 from ChillerDragon/pr_ddnet_str_comp_filenames
jtbx Feb 23, 2024
4facac0
Merge pull request #63 from Panquesito7/update_year
chillerbotpng Feb 23, 2024
04da87f
Fix typos
Pere001 Feb 19, 2023
a2ff479
Fix typo
Pere001 Feb 19, 2023
80a038f
Merge pull request #61 from ChillerDragon/pr_teeworlds_fix_cmp0148
Kaffeine Feb 23, 2024
d165868
Merge pull request #72 from Bamcane/pr_fix_editor
Bamcane Feb 23, 2024
9e35052
Merge pull request #78 from Bamcane/pr_fix_workflow
Bamcane Feb 23, 2024
08ecbaa
Merge pull request #76 from jtbx/spoof-doc-typos
furo321 Feb 23, 2024
3c27b93
Merge pull request #53 from Robyt3/CJsonParser
furo321 Mar 2, 2024
42878d0
Merge pull request #85 from ChillerDragon/pr_polyfill_copy_tree
furo321 Mar 2, 2024
de1d2d8
ci: use `fail-fast: false`
MilkeeyCat Feb 26, 2024
ec7f2a4
Increase broadcast size
fokkonaut Mar 7, 2024
a9b7f8a
Fix cmd5.py SyntaxWarning: invalid escape sequence
ChillerDragon Feb 25, 2024
820ccf7
Merge pull request #103 from teeworlds-mirror/mirror_3242_fokkonaut_p…
furo321 Mar 12, 2024
27b3f2d
Merge pull request #98 from teeworlds-mirror/mirror_3225_ChillerDrago…
furo321 Mar 12, 2024
76acb6f
Merge pull request #96 from MilkeeyCat/foo
furo321 Mar 22, 2024
3c6f655
Allow editor switch entities
Bamcane Mar 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: Build

on: [push, pull_request]
on: [push, pull_request, merge_group]

jobs:
build-cmake:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest, ubuntu-20.04]
include:
Expand Down Expand Up @@ -53,7 +54,7 @@ jobs:
brew update || true
brew install pkg-config sdl2 python3 ninja || true
# --overwrite for: Target /usr/local/bin/2to3 already exists.
brew link --overwrite python@3.10
brew link --overwrite python@3.12
brew upgrade freetype
sudo rm -rf /Library/Developer/CommandLineTools

Expand Down Expand Up @@ -108,6 +109,7 @@ jobs:
build-bam:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- trying.tmp
- staging-squash-merge.tmp
pull_request:
merge_group:

jobs:
check-style:
Expand All @@ -28,4 +29,3 @@ jobs:
do
jq '.' "$json" || { echo "$json"; exit 1; };
done < <(find . -name "*.json");

3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,8 @@ set_src(ENGINE_SHARED GLOB src/engine/shared
huffman.h
jobs.cpp
jobs.h
jsonparser.cpp
jsonparser.h
jsonwriter.cpp
jsonwriter.h
kernel.cpp
Expand Down Expand Up @@ -1723,6 +1725,7 @@ if(GTEST_FOUND OR DOWNLOAD_GTEST)
git_revision.cpp
hash.cpp
io.cpp
jsonparser.cpp
jsonwriter.cpp
packer.cpp
sorted_array.cpp
Expand Down
8 changes: 4 additions & 4 deletions bam.lua
Original file line number Diff line number Diff line change
Expand Up @@ -368,24 +368,24 @@ function BuildServer(settings, family, platform)

local game_server = Compile(settings, CollectRecursive("src/game/server/*.cpp"), SharedServerFiles())

return Link(settings, "teeworlds_srv", libs["zlib"], libs["md5"], server, game_server)
return Link(settings, "teeworlds_srv", libs["zlib"], libs["md5"], libs["json"], server, game_server)
end

function BuildTools(settings)
local tools = {}
for i,v in ipairs(Collect("src/tools/*.cpp", "src/tools/*.c")) do
local toolname = PathFilename(PathBase(v))
tools[i] = Link(settings, toolname, Compile(settings, v), libs["zlib"], libs["md5"], libs["wavpack"], libs["png"])
tools[i] = Link(settings, toolname, Compile(settings, v), libs["zlib"], libs["md5"], libs["wavpack"], libs["png"], libs["json"])
end
PseudoTarget(settings.link.Output(settings, "pseudo_tools") .. settings.link.extension, tools)
end

function BuildMasterserver(settings)
return Link(settings, "mastersrv", Compile(settings, Collect("src/mastersrv/*.cpp")), libs["zlib"], libs["md5"])
return Link(settings, "mastersrv", Compile(settings, Collect("src/mastersrv/*.cpp")), libs["zlib"], libs["md5"], libs["json"])
end

function BuildVersionserver(settings)
return Link(settings, "versionsrv", Compile(settings, Collect("src/versionsrv/*.cpp")), libs["zlib"], libs["md5"])
return Link(settings, "versionsrv", Compile(settings, Collect("src/versionsrv/*.cpp")), libs["zlib"], libs["md5"], libs["json"])
end

function BuildContent(settings, arch, conf)
Expand Down
2 changes: 1 addition & 1 deletion license.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2007-2022 Magnus Auvinen
Copyright (C) 2007-2024 Magnus Auvinen

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
Expand Down
2 changes: 1 addition & 1 deletion scripts/cmd5.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def cstrip(lines):
l = re.sub("#.*".encode(), "".encode(), l)
l = re.sub("//.*".encode(), "".encode(), l)
d += l + " ".encode()
d = re.sub("\/\*.*?\*/".encode(), "".encode(), d) # remove /* */ comments
d = re.sub(r"\/\*.*?\*/".encode(), "".encode(), d) # remove /* */ comments
d = d.replace("\t".encode(), " ".encode()) # tab to space
d = re.sub(" *".encode(), " ".encode(), d) # remove double spaces
d = re.sub("".encode(), "".encode(), d) # remove /* */ comments
Expand Down
2 changes: 1 addition & 1 deletion scripts/download.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import shutil, os, re, sys, zipfile
from distutils.dir_util import copy_tree
os.chdir(os.path.dirname(os.path.realpath(sys.argv[0])) + "/..")
import twlib
from twlib import copy_tree

def unzip(filename, where):
try:
Expand Down
2 changes: 1 addition & 1 deletion scripts/make_release.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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
from twlib import copy_tree

arguments = optparse.OptionParser(usage="usage: %prog VERSION PLATFORM [options]\n\nVERSION - Version number\nPLATFORM - Target platform (f.e. linux_x86, linux_x86_64, macos, src, win32, win64)")
arguments.add_option("-l", "--url-languages", default = "http://github.com/teeworlds/teeworlds-translation/archive/master.zip", help = "URL from which the teeworlds language files will be downloaded")
Expand Down
9 changes: 9 additions & 0 deletions scripts/twlib.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import shutil
import sys
if sys.version_info[0] == 2:
import urllib
Expand All @@ -6,6 +7,14 @@
import urllib.request
url_lib = urllib.request

try:
from distutils.dir_util import copy_tree
except ModuleNotFoundError:
# distutils was removed in python 3.12
# https://peps.python.org/pep-0632/
def copy_tree(src, dst):
shutil.copytree(src, dst, dirs_exist_ok=True)

def fetch_file(url):
print("trying %s" % url)
try:
Expand Down
62 changes: 32 additions & 30 deletions src/base/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,28 +388,30 @@ unsigned io_read(IOHANDLE io, void *buffer, unsigned size)

void io_read_all(IOHANDLE io, void **result, unsigned *result_len)
{
unsigned char *buffer = malloc(1024);
unsigned len = 0;
unsigned cap = 1024;
unsigned read;

*result = 0;
*result_len = 0;

while((read = io_read(io, buffer + len, cap - len)) != 0)
unsigned len = (unsigned)io_length(io);
char *buffer = mem_alloc(len + 1);
unsigned read = io_read(io, buffer, len + 1); // +1 to check if the file size is larger than expected
if(read < len)
{
len += read;
if(len == cap)
{
cap *= 2;
buffer = realloc(buffer, cap);
}
buffer = realloc(buffer, read + 1);
len = read;
}
if(len == cap)
else if(read > len)
{
buffer = realloc(buffer, cap + 1);
unsigned cap = 2 * read;
len = read;
buffer = realloc(buffer, cap);
while((read = io_read(io, buffer + len, cap - len)) != 0)
{
len += read;
if(len == cap)
{
cap *= 2;
buffer = realloc(buffer, cap);
}
}
buffer = realloc(buffer, len + 1);
}
// ensure null termination
buffer[len] = 0;
*result = buffer;
*result_len = len;
Expand All @@ -419,12 +421,11 @@ char *io_read_all_str(IOHANDLE io)
{
void *buffer;
unsigned len;

io_read_all(io, &buffer, &len);
if(mem_has_null(buffer, len))
{
free(buffer);
return 0;
mem_free(buffer);
return 0x0;
}
return buffer;
}
Expand Down Expand Up @@ -749,7 +750,7 @@ static void netaddr_to_sockaddr_in6(const NETADDR *src, struct sockaddr_in6 *des
mem_zero(dest, sizeof(struct sockaddr_in6));
if(src->type != NETTYPE_IPV6)
{
dbg_msg("system", "couldn't not convert NETADDR of type %d to ipv6", src->type);
dbg_msg("system", "couldn't convert NETADDR of type %d to ipv6", src->type);
return;
}

Expand Down Expand Up @@ -2375,22 +2376,23 @@ int str_comp_filenames(const char *a, const char *b)
{
if(!result)
result = *a - *b;
++a; ++b;
}
while(*a >= '0' && *a <= '9' && *b >= '0' && *b <= '9');
++a;
++b;
} while(*a >= '0' && *a <= '9' && *b >= '0' && *b <= '9');

if(*a >= '0' && *a <= '9')
return 1;
else if(*b >= '0' && *b <= '9')
return -1;
else if(result)
else if(result || *a == '\0' || *b == '\0')
return result;
}

if(tolower(*a) != tolower(*b))
break;
result = tolower(*a) - tolower(*b);
if(result)
return result;
}
return tolower(*a) - tolower(*b);
return *a - *b;
}

const char *str_startswith_nocase(const char *str, const char *prefix)
Expand Down Expand Up @@ -2563,7 +2565,7 @@ int mem_comp(const void *a, const void *b, int size)
int mem_has_null(const void *block, unsigned size)
{
const unsigned char *bytes = block;
unsigned i;
unsigned i;
for(i = 0; i < size; i++)
{
if(bytes[i] == 0)
Expand Down
1 change: 0 additions & 1 deletion src/base/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ unsigned io_read(IOHANDLE io, void *buffer, unsigned size);

Remarks:
- Does NOT guarantee that there are no internal null bytes.
- Guarantees that result will contain zero-termination.
- The result must be freed after it has been used.
*/
void io_read_all(IOHANDLE io, void **result, unsigned *result_len);
Expand Down
26 changes: 4 additions & 22 deletions src/engine/client/serverbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
#include <base/math.h>
#include <base/system.h>

#include <engine/external/json-parser/json.h>

#include <engine/shared/config.h>
#include <engine/shared/memheap.h>
#include <engine/shared/network.h>
#include <engine/shared/packer.h>
#include <engine/shared/jsonparser.h>
#include <engine/shared/jsonwriter.h>
#include <engine/shared/mapchecker.h>

Expand Down Expand Up @@ -610,25 +609,11 @@ void CServerBrowser::SetInfo(int ServerlistType, CServerEntry *pEntry, const CSe

void CServerBrowser::LoadServerlist()
{
// read file data into buffer
IOHANDLE File = Storage()->OpenFile(s_pFilename, IOFLAG_READ, IStorage::TYPE_ALL);
if(!File)
return;
int FileSize = (int)io_length(File);
char *pFileData = (char *)mem_alloc(FileSize);
io_read(File, pFileData, FileSize);
io_close(File);

// parse json data
json_settings JsonSettings;
mem_zero(&JsonSettings, sizeof(JsonSettings));
char aError[256];
json_value *pJsonData = json_parse_ex(&JsonSettings, pFileData, FileSize, aError);
mem_free(pFileData);

CJsonParser JsonParser;
const json_value *pJsonData = JsonParser.ParseFile(s_pFilename, Storage());
if(pJsonData == 0)
{
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, s_pFilename, aError);
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client_srvbrowse", JsonParser.Error());
return;
}

Expand All @@ -643,9 +628,6 @@ void CServerBrowser::LoadServerlist()
Set(Addr, SET_MASTER_ADD, -1, 0);
}
}

// clean up
json_value_free(pJsonData);
}

void CServerBrowser::SaveServerlist()
Expand Down
Loading
Loading