mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
2893: Determine binary dir independently of data dir (fixes #2891) r=heinrich5991 a=def- @Learath2 Could you check if this can be extended to also find the DDNet-Server executable on Mac? 2972: Add explicit button for current map as BG r=heinrich5991 a=def- 2974: Fix autoformatting wrt. generated files r=def- a=heinrich5991 Fix #2962. Co-authored-by: def <dennis@felsin9.de> Co-authored-by: Dennis Felsing <dennis@felsin9.de> Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
This commit is contained in:
commit
b27b54a051
|
@ -98,6 +98,8 @@ if gen_network_header:
|
|||
|
||||
print("#ifndef GAME_GENERATED_PROTOCOL_H")
|
||||
print("#define GAME_GENERATED_PROTOCOL_H")
|
||||
print("#include <engine/shared/protocol.h>")
|
||||
print("#include <engine/message.h>")
|
||||
print(network.RawHeader)
|
||||
|
||||
for e in network.Enums:
|
||||
|
@ -167,9 +169,9 @@ if gen_network_source:
|
|||
# create names
|
||||
lines = []
|
||||
|
||||
lines += ['#include "protocol.h"']
|
||||
lines += ['#include <engine/shared/protocol.h>']
|
||||
lines += ['#include <engine/message.h>']
|
||||
lines += ['#include "protocol.h"']
|
||||
lines += ['#include <game/mapitems_ex.h>']
|
||||
|
||||
lines += ['CNetObjHandler::CNetObjHandler()']
|
||||
|
|
|
@ -99,6 +99,8 @@ if gen_network_header:
|
|||
|
||||
print("#ifndef GAME_GENERATED_PROTOCOL7_H")
|
||||
print("#define GAME_GENERATED_PROTOCOL7_H")
|
||||
print("#include <engine/shared/protocol.h>")
|
||||
print("#include <engine/message.h>")
|
||||
print("namespace protocol7 {")
|
||||
print(network.RawHeader)
|
||||
|
||||
|
@ -177,9 +179,9 @@ if gen_network_source:
|
|||
# create names
|
||||
lines = []
|
||||
|
||||
lines += ['#include "protocol7.h"']
|
||||
lines += ['#include <engine/shared/protocol.h>']
|
||||
lines += ['#include <engine/message.h>']
|
||||
lines += ['#include "protocol7.h"']
|
||||
|
||||
lines += ['namespace protocol7 {']
|
||||
|
||||
|
|
|
@ -8,14 +8,21 @@ import sys
|
|||
|
||||
os.chdir(os.path.dirname(__file__) + "/..")
|
||||
|
||||
ignore_files = ["src/engine/keys.h", "src/engine/client/keynames.h"]
|
||||
|
||||
def recursive_file_list(path):
|
||||
result = []
|
||||
for dirpath, dirnames, filenames in os.walk(path):
|
||||
result += filter(lambda p: p not in ignore_files, [os.path.join(dirpath, filename) for filename in filenames])
|
||||
result += [os.path.join(dirpath, filename) for filename in filenames]
|
||||
return result
|
||||
|
||||
IGNORE_FILES = [
|
||||
"src/engine/client/keynames.h",
|
||||
"src/engine/keys.h",
|
||||
]
|
||||
def filter_ignored(filenames):
|
||||
return [filename for filename in filenames
|
||||
if filename not in IGNORE_FILES
|
||||
and not filename.startswith("src/game/generated/")]
|
||||
|
||||
def filter_cpp(filenames):
|
||||
return [filename for filename in filenames
|
||||
if any(filename.endswith(ext) for ext in ".c .cpp .h".split())]
|
||||
|
@ -31,7 +38,7 @@ def main():
|
|||
p = argparse.ArgumentParser(description="Check and fix style of changed files")
|
||||
p.add_argument("-n", "--dry-run", action="store_true", help="Don't fix, only warn")
|
||||
args = p.parse_args()
|
||||
filenames = filter_cpp(recursive_file_list("src"))
|
||||
filenames = filter_ignored(filter_cpp(recursive_file_list("src")))
|
||||
if not args.dry_run:
|
||||
reformat(filenames)
|
||||
else:
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "linereader.h"
|
||||
#include <base/math.h>
|
||||
#include <base/system.h>
|
||||
#include <engine/client/updater.h>
|
||||
#include <engine/storage.h>
|
||||
|
||||
class CStorage : public IStorage
|
||||
|
@ -31,6 +32,9 @@ public:
|
|||
// get datadir
|
||||
FindDatadir(ppArguments[0]);
|
||||
|
||||
// get binarydir
|
||||
FindBinarydir(ppArguments[0]);
|
||||
|
||||
// get currentdir
|
||||
if(!fs_getcwd(m_aCurrentdir, sizeof(m_aCurrentdir)))
|
||||
m_aCurrentdir[0] = 0;
|
||||
|
@ -166,7 +170,6 @@ public:
|
|||
if(fs_is_dir("data/mapres"))
|
||||
{
|
||||
str_copy(m_aDatadir, "data", sizeof(m_aDatadir));
|
||||
str_copy(m_aBinarydir, "", sizeof(m_aBinarydir));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -175,11 +178,6 @@ public:
|
|||
if(fs_is_dir(DATA_DIR "/mapres"))
|
||||
{
|
||||
str_copy(m_aDatadir, DATA_DIR, sizeof(m_aDatadir));
|
||||
#if defined(BINARY_DIR)
|
||||
str_copy(m_aBinarydir, BINARY_DIR, sizeof(m_aBinarydir));
|
||||
#else
|
||||
str_copy(m_aBinarydir, DATA_DIR "/..", sizeof(m_aBinarydir));
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -194,15 +192,14 @@ public:
|
|||
if(Pos < MAX_PATH_LENGTH)
|
||||
{
|
||||
char aBuf[MAX_PATH_LENGTH];
|
||||
str_copy(m_aBinarydir, pArgv0, Pos + 1);
|
||||
str_format(aBuf, sizeof(aBuf), "%s/data/mapres", m_aBinarydir);
|
||||
char aDir[MAX_PATH_LENGTH];
|
||||
str_copy(aDir, pArgv0, Pos + 1);
|
||||
str_format(aBuf, sizeof(aBuf), "%s/data/mapres", aDir);
|
||||
if(fs_is_dir(aBuf))
|
||||
{
|
||||
str_format(m_aDatadir, sizeof(m_aDatadir), "%s/data", m_aBinarydir);
|
||||
str_format(m_aDatadir, sizeof(m_aDatadir), "%s/data", aDir);
|
||||
return;
|
||||
}
|
||||
else
|
||||
m_aBinarydir[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,7 +223,6 @@ public:
|
|||
str_format(aBuf, sizeof(aBuf), "%s/data/mapres", aDirs[i]);
|
||||
if(fs_is_dir(aBuf))
|
||||
{
|
||||
str_copy(m_aBinarydir, aDirs[i], sizeof(m_aDatadir));
|
||||
str_format(m_aDatadir, sizeof(m_aDatadir), "%s/data", aDirs[i]);
|
||||
return;
|
||||
}
|
||||
|
@ -234,8 +230,55 @@ public:
|
|||
}
|
||||
#endif
|
||||
|
||||
// no data-dir found
|
||||
dbg_msg("storage", "warning no data directory found");
|
||||
dbg_msg("storage", "warning: no data directory found");
|
||||
}
|
||||
|
||||
void FindBinarydir(const char *pArgv0)
|
||||
{
|
||||
#if defined(BINARY_DIR)
|
||||
str_copy(m_aBinarydir, BINARY_DIR, sizeof(m_aBinarydir));
|
||||
return;
|
||||
#endif
|
||||
|
||||
// check for usable path in argv[0]
|
||||
{
|
||||
unsigned int Pos = ~0U;
|
||||
for(unsigned i = 0; pArgv0[i]; i++)
|
||||
if(pArgv0[i] == '/' || pArgv0[i] == '\\')
|
||||
Pos = i;
|
||||
|
||||
if(Pos < MAX_PATH_LENGTH)
|
||||
{
|
||||
char aBuf[MAX_PATH_LENGTH];
|
||||
str_copy(m_aBinarydir, pArgv0, Pos + 1);
|
||||
str_format(aBuf, sizeof(aBuf), "%s/" PLAT_SERVER_EXEC, m_aBinarydir);
|
||||
IOHANDLE File = io_open(aBuf, IOFLAG_READ);
|
||||
if(File)
|
||||
{
|
||||
io_close(File);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(CONF_PLATFORM_MACOSX)
|
||||
str_append(m_aBinarydir, "/../../../DDNet-Server.app/Contents/MacOS", sizeof(m_aBinarydir));
|
||||
str_format(aBuf, sizeof(aBuf), "%s/" PLAT_SERVER_EXEC, m_aBinarydir);
|
||||
IOHANDLE File = io_open(aBuf, IOFLAG_READ);
|
||||
if(File)
|
||||
{
|
||||
io_close(File);
|
||||
return;
|
||||
}
|
||||
else
|
||||
m_aBinarydir[0] = 0;
|
||||
#else
|
||||
m_aBinarydir[0] = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// no binary directory found, use $PATH on Posix, $PWD on Windows
|
||||
}
|
||||
|
||||
virtual void ListDirectoryInfo(int Type, const char *pPath, FS_LISTDIR_INFO_CALLBACK pfnCallback, void *pUser)
|
||||
|
|
|
@ -39,7 +39,7 @@ void CBackground::OnInit()
|
|||
{
|
||||
m_pImages->m_pClient = GameClient();
|
||||
Kernel()->RegisterInterface(m_pBackgroundMap);
|
||||
if(g_Config.m_ClBackgroundEntities[0] != '\0' && str_comp(g_Config.m_ClBackgroundEntities, CURRENT))
|
||||
if(g_Config.m_ClBackgroundEntities[0] != '\0' && str_comp(g_Config.m_ClBackgroundEntities, CURRENT_MAP))
|
||||
LoadBackground();
|
||||
}
|
||||
|
||||
|
@ -61,14 +61,7 @@ void CBackground::LoadBackground()
|
|||
str_copy(m_aMapName, g_Config.m_ClBackgroundEntities, sizeof(m_aMapName));
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof(aBuf), "maps/%s", g_Config.m_ClBackgroundEntities);
|
||||
if(m_pMap->Load(aBuf))
|
||||
{
|
||||
m_pLayers->InitBackground(m_pMap);
|
||||
RenderTools()->RenderTilemapGenerateSkip(m_pLayers);
|
||||
NeedImageLoading = true;
|
||||
m_Loaded = true;
|
||||
}
|
||||
else if(str_comp(g_Config.m_ClBackgroundEntities, CURRENT) == 0)
|
||||
if(str_comp(g_Config.m_ClBackgroundEntities, CURRENT_MAP) == 0)
|
||||
{
|
||||
m_pMap = Kernel()->RequestInterface<IEngineMap>();
|
||||
if(m_pMap->IsLoaded())
|
||||
|
@ -78,6 +71,13 @@ void CBackground::LoadBackground()
|
|||
m_Loaded = true;
|
||||
}
|
||||
}
|
||||
else if(m_pMap->Load(aBuf))
|
||||
{
|
||||
m_pLayers->InitBackground(m_pMap);
|
||||
RenderTools()->RenderTilemapGenerateSkip(m_pLayers);
|
||||
NeedImageLoading = true;
|
||||
m_Loaded = true;
|
||||
}
|
||||
|
||||
if(m_Loaded)
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ void CBackground::LoadBackground()
|
|||
|
||||
void CBackground::OnMapLoad()
|
||||
{
|
||||
if(str_comp(g_Config.m_ClBackgroundEntities, CURRENT) == 0 || str_comp(g_Config.m_ClBackgroundEntities, m_aMapName))
|
||||
if(str_comp(g_Config.m_ClBackgroundEntities, CURRENT_MAP) == 0 || str_comp(g_Config.m_ClBackgroundEntities, m_aMapName))
|
||||
{
|
||||
m_LastLoad = 0;
|
||||
LoadBackground();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <game/client/components/maplayers.h>
|
||||
|
||||
// Special value to use background of current map
|
||||
#define CURRENT "%current%"
|
||||
#define CURRENT_MAP "%current%"
|
||||
|
||||
class CBackgroundEngineMap : public CMap
|
||||
{
|
||||
|
|
|
@ -2017,7 +2017,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
|
|||
}
|
||||
}
|
||||
|
||||
MainView.HSplitTop(310.0f, &Gameplay, &MainView);
|
||||
MainView.HSplitTop(330.0f, &Gameplay, &MainView);
|
||||
|
||||
Gameplay.HSplitTop(30.0f, &Label, &Gameplay);
|
||||
UI()->DoLabelScaled(&Label, Localize("Gameplay"), 20.0f, -1);
|
||||
|
@ -2173,6 +2173,16 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
|
|||
UI()->DoLabelScaled(&Label, Localize("Map"), 14.0f, -1);
|
||||
DoEditBox(g_Config.m_ClBackgroundEntities, &Left, g_Config.m_ClBackgroundEntities, sizeof(g_Config.m_ClBackgroundEntities), 14.0f, &s_Map);
|
||||
|
||||
aRects[1].HSplitTop(20.0f, &Button, &aRects[1]);
|
||||
bool UseCurrentMap = str_comp(g_Config.m_ClBackgroundEntities, CURRENT_MAP) == 0;
|
||||
if(DoButton_CheckBox(&UseCurrentMap, Localize("Use current map as background"), UseCurrentMap, &Button))
|
||||
{
|
||||
if(UseCurrentMap)
|
||||
g_Config.m_ClBackgroundEntities[0] = '\0';
|
||||
else
|
||||
str_copy(g_Config.m_ClBackgroundEntities, CURRENT_MAP, sizeof(g_Config.m_ClBackgroundEntities));
|
||||
}
|
||||
|
||||
aRects[1].HSplitTop(20.0f, &Button, 0);
|
||||
if(DoButton_CheckBox(&g_Config.m_ClBackgroundShowTilesLayers, Localize("Show tiles layers from BG map"), g_Config.m_ClBackgroundShowTilesLayers, &Button))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue