From 9397c4a55f5cf59d290b59439892f8b5e86d9c56 Mon Sep 17 00:00:00 2001 From: GreYFoX Date: Fri, 15 Apr 2011 02:58:39 +0200 Subject: [PATCH] some make release changes for adding sql server files Servers are no longer build with SQL by default. fixed compilation on Mac OS X 10.5 --- bam.lua | 146 ++++++++---------- scripts/make_release.py | 46 +++++- src/game/client/components/camera.cpp | 4 +- src/game/client/components/chat.cpp | 4 +- src/game/client/components/console.cpp | 5 +- src/game/client/components/controls.cpp | 5 +- src/game/client/components/effects.cpp | 5 +- src/game/client/components/menus.cpp | 3 + src/game/client/components/menus_demo.cpp | 4 +- src/game/client/components/menus_settings.cpp | 4 +- src/game/client/components/players.cpp | 5 +- src/game/client/components/sounds.cpp | 3 + src/game/editor/ed_editor.cpp | 4 +- src/game/editor/ed_io.cpp | 5 +- src/game/server/gamecontext.cpp | 4 +- src/osxlaunch/server.m | 4 +- src/osxlaunch/server_mysql.m | 112 ++++++++++++++ 17 files changed, 259 insertions(+), 104 deletions(-) create mode 100644 src/osxlaunch/server_mysql.m diff --git a/bam.lua b/bam.lua index 93322d48f..96a19e776 100644 --- a/bam.lua +++ b/bam.lua @@ -190,9 +190,10 @@ function build(settings) server_settings = engine_settings:Copy() client_settings = engine_settings:Copy() launcher_settings = engine_settings:Copy() + launcher_settings_mysql = engine_settings:Copy() if family == "unix" then - if not string.find(settings.config_name, "nosql") then + if string.find(settings.config_name, "sql") then server_settings.link.libs:Add("mysqlcppconn-static") server_settings.link.libs:Add("mysqlclient") end @@ -203,7 +204,8 @@ function build(settings) client_settings.link.frameworks:Add("Carbon") client_settings.link.frameworks:Add("Cocoa") launcher_settings.link.frameworks:Add("Cocoa") - if not string.find(settings.config_name, "nosql") then + launcher_settings_mysql.link.frameworks:Add("Cocoa") + if string.find(settings.config_name, "sql") then if arch == "amd64" then server_settings.link.libpath:Add("other/mysql/mac/lib64") else @@ -214,7 +216,7 @@ function build(settings) client_settings.link.libs:Add("X11") client_settings.link.libs:Add("GL") client_settings.link.libs:Add("GLU") - if not string.find(settings.config_name, "nosql") then + if string.find(settings.config_name, "sql") then if arch == "amd64" then server_settings.link.libpath:Add("other/mysql/linux/lib64") else @@ -227,7 +229,7 @@ function build(settings) client_settings.link.libs:Add("opengl32") client_settings.link.libs:Add("glu32") client_settings.link.libs:Add("winmm") - if not string.find(settings.config_name, "nosql") then + if string.find(settings.config_name, "sql") then server_settings.link.libpath:Add("other/mysql/vc2005libs") server_settings.link.libs:Add("mysqlcppconn") end @@ -255,9 +257,11 @@ function build(settings) client_osxlaunch = {} server_osxlaunch = {} + server_osxlaunch_mysql = {} if platform == "macosx" then client_osxlaunch = Compile(client_settings, "src/osxlaunch/client.m") server_osxlaunch = Compile(launcher_settings, "src/osxlaunch/server.m") + server_osxlaunch_mysql = Compile(launcher_settings_mysql, "src/osxlaunch/server_mysql.m") end tools = {} @@ -275,8 +279,10 @@ function build(settings) game_shared, game_server, zlib, server_link_other) serverlaunch = {} + serverlaunch_mysql = {} if platform == "macosx" then serverlaunch = Link(launcher_settings, "serverlaunch", server_osxlaunch) + serverlaunch_mysql = Link(launcher_settings_mysql, "serverlaunch_mysql", server_osxlaunch_mysql) end versionserver_exe = Link(server_settings, "versionsrv", versionserver, @@ -290,18 +296,10 @@ function build(settings) -- make targets c = PseudoTarget("client".."_"..settings.config_name, client_exe, client_depends) - if string.find(settings.config_name, "nosql") then - s = PseudoTarget("server".."_"..settings.config_name, server_exe, serverlaunch) + if string.find(settings.config_name, "sql") then + s = PseudoTarget("server".."_"..settings.config_name, server_exe, serverlaunch_mysql, server_sql_depends) else - if family == "windows" then - if string.find(settings.config_name, "sql") or not string.find(settings.config_name, "release") then - s = PseudoTarget("server".."_"..settings.config_name, server_exe, serverlaunch, server_sql_depends) - else - s = PseudoTarget("server".."_"..settings.config_name, server_exe, serverlaunch) - end - else - s = PseudoTarget("server".."_"..settings.config_name, server_exe, serverlaunch, server_sql_depends) - end + s = PseudoTarget("server".."_"..settings.config_name, server_exe, serverlaunch) end g = PseudoTarget("game".."_"..settings.config_name, client_exe, server_exe) @@ -320,42 +318,28 @@ debug_settings.config_name = "debug" debug_settings.config_ext = "_d" debug_settings.debug = 1 debug_settings.optimize = 0 -debug_settings.cc.defines:Add("CONF_DEBUG", "CONF_SQL") +debug_settings.cc.defines:Add("CONF_DEBUG") -debug_nosql_settings = NewSettings() -debug_nosql_settings.config_name = "nosql_debug" -debug_nosql_settings.config_ext = "_nosql_d" -debug_nosql_settings.debug = 1 -debug_nosql_settings.optimize = 0 -debug_nosql_settings.cc.defines:Add("CONF_DEBUG") +debug_sql_settings = NewSettings() +debug_sql_settings.config_name = "sql_debug" +debug_sql_settings.config_ext = "_sql_d" +debug_sql_settings.debug = 1 +debug_sql_settings.optimize = 0 +debug_sql_settings.cc.defines:Add("CONF_DEBUG", "CONF_SQL") release_settings = NewSettings() release_settings.config_name = "release" release_settings.config_ext = "" release_settings.debug = 0 release_settings.optimize = 1 -if family == "windows" then - release_settings.cc.defines:Add("CONF_RELEASE") - release_settings.config_ext = "" - - release_nosql_settings = NewSettings() - release_nosql_settings.config_name = "sql_release" - release_nosql_settings.config_ext = "_sql" - release_nosql_settings.debug = 0 - release_nosql_settings.optimize = 1 - release_nosql_settings.cc.defines:Add("CONF_RELEASE", "CONF_SQL") -else +release_settings.cc.defines:Add("CONF_RELEASE") - release_settings.cc.defines:Add("CONF_RELEASE", "CONF_SQL") - release_settings.config_ext = "" - - release_nosql_settings = NewSettings() - release_nosql_settings.config_name = "nosql_release" - release_nosql_settings.config_ext = "_nosql" - release_nosql_settings.debug = 0 - release_nosql_settings.optimize = 1 - release_nosql_settings.cc.defines:Add("CONF_RELEASE") -end +release_sql_settings = NewSettings() +release_sql_settings.config_name = "sql_release" +release_sql_settings.config_ext = "_sql" +release_sql_settings.debug = 0 +release_sql_settings.optimize = 1 +release_sql_settings.cc.defines:Add("CONF_RELEASE", "CONF_SQL") if platform == "macosx" and arch == "ia32" then debug_settings_ppc = debug_settings:Copy() @@ -363,81 +347,81 @@ if platform == "macosx" and arch == "ia32" then 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", "CONF_SQL") + debug_settings_ppc.cc.defines:Add("CONF_DEBUG") - debug_nosql_settings_ppc = debug_nosql_settings:Copy() - debug_nosql_settings_ppc.config_name = "nosql_debug_ppc" - debug_nosql_settings_ppc.config_ext = "_nosql_ppc_d" - debug_nosql_settings_ppc.cc.flags:Add("-arch ppc") - debug_nosql_settings_ppc.link.flags:Add("-arch ppc") - debug_nosql_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", "CONF_SQL") + release_settings_ppc.cc.defines:Add("CONF_RELEASE") - release_nosql_settings_ppc = release_nosql_settings:Copy() - release_nosql_settings_ppc.config_name = "nosql_release_ppc" - release_nosql_settings_ppc.config_ext = "_nosql_ppc" - release_nosql_settings_ppc.cc.flags:Add("-arch ppc") - release_nosql_settings_ppc.link.flags:Add("-arch ppc") - release_nosql_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") 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", "CONF_SQL") + debug_settings_x86.cc.defines:Add("CONF_DEBUG") - debug_nosql_settings_x86 = debug_nosql_settings:Copy() - debug_nosql_settings_x86.config_name = "nosql_debug_x86" - debug_nosql_settings_x86.config_ext = "_nosql_x86_d" - debug_nosql_settings_x86.cc.flags:Add("-arch i386") - debug_nosql_settings_x86.link.flags:Add("-arch i386") - debug_nosql_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", "CONF_SQL") + release_settings_x86.cc.defines:Add("CONF_RELEASE") - release_nosql_settings_x86 = release_nosql_settings:Copy() - release_nosql_settings_x86.config_name = "nosql_release_x86" - release_nosql_settings_x86.config_ext = "_nosql_x86" - release_nosql_settings_x86.cc.flags:Add("-arch i386") - release_nosql_settings_x86.link.flags:Add("-arch i386") - release_nosql_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") ppc_d = build(debug_settings_ppc) x86_d = build(debug_settings_x86) - sql_ppc_d = build(debug_nosql_settings_ppc) - sql_x86_d = build(debug_nosql_settings_x86) + sql_ppc_d = build(debug_sql_settings_ppc) + sql_x86_d = build(debug_sql_settings_x86) ppc_r = build(release_settings_ppc) x86_r = build(release_settings_x86) - sql_ppc_r = build(release_nosql_settings_ppc) - sql_x86_r = build(release_nosql_settings_x86) + sql_ppc_r = build(release_sql_settings_ppc) + sql_x86_r = build(release_sql_settings_x86) DefaultTarget("game_debug_x86") PseudoTarget("release", ppc_r, x86_r) - PseudoTarget("nosql_release", nosql_ppc_r, nosql_x86_r) + PseudoTarget("sql_release", sql_ppc_r, sql_x86_r) PseudoTarget("debug", ppc_d, x86_d) - PseudoTarget("nosql_debug", nosql_ppc_d, nosql_x86_d) + PseudoTarget("sql_debug", sql_ppc_d, sql_x86_d) PseudoTarget("server_release", "server_release_x86", "server_release_ppc") - PseudoTarget("server_nosql_release", "server_nosql_release_x86", "server_nosql_release_ppc") + PseudoTarget("server_sql_release", "server_sql_release_x86", "server_sql_release_ppc") PseudoTarget("server_debug", "server_debug_x86", "server_debug_ppc") - PseudoTarget("server_nosql_debug", "server_nosql_debug_x86", "server_nosql_debug_ppc") + PseudoTarget("server_sql_debug", "server_sql_debug_x86", "server_sql_debug_ppc") PseudoTarget("client_release", "client_release_x86", "client_release_ppc") PseudoTarget("client_debug", "client_debug_x86", "client_debug_ppc") else build(debug_settings) - build(debug_nosql_settings) + build(debug_sql_settings) build(release_settings) - build(release_nosql_settings) + build(release_sql_settings) DefaultTarget("game_debug") end diff --git a/scripts/make_release.py b/scripts/make_release.py index 9e86b0886..d9326d40a 100644 --- a/scripts/make_release.py +++ b/scripts/make_release.py @@ -72,10 +72,13 @@ if include_data and not use_bundle: shutil.copy("other/config_directory.bat", package_dir) shutil.copy("SDL.dll", package_dir) shutil.copy("freetype.dll", package_dir) + shutil.copy("libmysql.dll", package_dir) + shutil.copy("mysqlcppconn.dll", package_dir) if include_exe and not use_bundle: shutil.copy(name+exe_ext, package_dir) shutil.copy(name+"-Server"+exe_ext, package_dir) + shutil.copy(name+"-Server_sql"+exe_ext, package_dir) if include_src: for p in ["src", "scripts", "datasrc", "other", "objs"]: @@ -86,8 +89,10 @@ if include_src: if use_bundle: os.system("lipo -create -output "+name+"-Server "+name+"-Server"+"_ppc "+name+"-Server"+"_x86") + os.system("lipo -create -output "+name+"-Server_sql "+name+"-Server_sql"+"_ppc "+name+"-Server_sql"+"_x86") os.system("lipo -create -output "+name+" "+name+"_ppc "+name+"_x86") os.system("lipo -create -output serverlaunch serverlaunch_ppc serverlaunch_x86") + os.system("lipo -create -output serverlaunch_sql serverlaunch_sql_ppc serverlaunch_sql_x86") # create Teeworlds appfolder clientbundle_content_dir = os.path.join(package_dir, "DDRace.app/Contents") @@ -128,7 +133,7 @@ if use_bundle: """ % (version)) file(os.path.join(clientbundle_content_dir, "PkgInfo"), "w").write("APPL????") - # create Teeworlds Server appfolder + # create DDRace Server appfolder serverbundle_content_dir = os.path.join(package_dir, "DDRace-Server.app/Contents") serverbundle_bin_dir = os.path.join(serverbundle_content_dir, "MacOS") serverbundle_resource_dir = os.path.join(serverbundle_content_dir, "Resources") @@ -163,6 +168,45 @@ if use_bundle: CFBundleVersion %s + + """ % (version)) + file(os.path.join(serverbundle_content_dir, "PkgInfo"), "w").write("APPL????") + + # create DDRace Server sql appfolder + serverbundle_content_dir = os.path.join(package_dir, "DDRace-Server_sql.app/Contents") + serverbundle_bin_dir = os.path.join(serverbundle_content_dir, "MacOS") + serverbundle_resource_dir = os.path.join(serverbundle_content_dir, "Resources") + os.mkdir(os.path.join(package_dir, "DDRace-Server_sql.app")) + os.mkdir(serverbundle_content_dir) + os.mkdir(serverbundle_bin_dir) + os.mkdir(serverbundle_resource_dir) + 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) + shutil.copy("other/icons/DDRace-Server.icns", serverbundle_resource_dir) + shutil.copy(name+"-Server"+exe_ext, serverbundle_bin_dir) + shutil.copy("serverlaunch_sql"+exe_ext, serverbundle_bin_dir + "/"+name+"_server") + file(os.path.join(serverbundle_content_dir, "Info.plist"), "w").write(""" + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + DDRace_Server + CFBundleIconFile + DDRace-Server_sql + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + %s + """ % (version)) file(os.path.join(serverbundle_content_dir, "PkgInfo"), "w").write("APPL????") diff --git a/src/game/client/components/camera.cpp b/src/game/client/components/camera.cpp index 15877086f..dd5097d08 100644 --- a/src/game/client/components/camera.cpp +++ b/src/game/client/components/camera.cpp @@ -1,5 +1,8 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ + +#include + #include #include @@ -10,7 +13,6 @@ #include "camera.h" #include "controls.h" -#include #include CCamera::CCamera() diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index aa6521197..5db87c761 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -1,6 +1,8 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ +#include + #include #include #include @@ -18,8 +20,6 @@ #include "chat.h" -#include - CChat::CChat() { OnReset(); diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index ad542e2d6..b3902161c 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -1,5 +1,8 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ + +#include + #include #include @@ -28,8 +31,6 @@ #include "console.h" -#include - enum { CONSOLE_CLOSED, diff --git a/src/game/client/components/controls.cpp b/src/game/client/components/controls.cpp index 56f59ab08..24e0b06ad 100644 --- a/src/game/client/components/controls.cpp +++ b/src/game/client/components/controls.cpp @@ -1,5 +1,8 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ + +#include + #include #include @@ -13,8 +16,6 @@ #include "controls.h" -#include - CControls::CControls() { mem_zero(&m_LastData, sizeof(m_LastData)); diff --git a/src/game/client/components/effects.cpp b/src/game/client/components/effects.cpp index 5401bddf3..1a14087b6 100644 --- a/src/game/client/components/effects.cpp +++ b/src/game/client/components/effects.cpp @@ -1,5 +1,8 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ + +#include + #include #include @@ -16,8 +19,6 @@ #include "effects.h" -#include - inline vec2 RandomDir() { return normalize(vec2(frandom()-0.5f, frandom()-0.5f)); } CEffects::CEffects() diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 0989cbcaa..3a96997e4 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -1,5 +1,8 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ + +#include + #include #include diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index 97b21487b..997ad0c4c 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -1,6 +1,8 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ +#include + #include #include @@ -19,8 +21,6 @@ #include "menus.h" -#include - int CMenus::DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, const CUIRect *pRect) { RenderTools()->DrawUIRect(pRect, vec4(1,1,1, Checked ? 0.10f : 0.5f)*ButtonColorMul(pID), CUI::CORNER_ALL, 5.0f); diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 54e66fb43..be4d61e92 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -1,6 +1,8 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ +#include + #include #include @@ -25,8 +27,6 @@ #include "menus.h" #include "skins.h" -#include - CMenusKeyBinder CMenus::m_Binder; CMenusKeyBinder::CMenusKeyBinder() diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp index d7ed29e00..1b0ce254f 100644 --- a/src/game/client/components/players.cpp +++ b/src/game/client/components/players.cpp @@ -1,5 +1,8 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ + +#include + #include #include #include @@ -21,8 +24,6 @@ #include "players.h" -#include - void CPlayers::RenderHand(CTeeRenderInfo *pInfo, vec2 CenterPos, vec2 Dir, float AngleOffset, vec2 PostRotOffset) { // for drawing hand diff --git a/src/game/client/components/sounds.cpp b/src/game/client/components/sounds.cpp index ffafa128b..62b2ac163 100644 --- a/src/game/client/components/sounds.cpp +++ b/src/game/client/components/sounds.cpp @@ -1,5 +1,8 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ + +#include + #include #include #include diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 94c844fc0..d9730e28f 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -1,6 +1,8 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ +#include + #include #include @@ -23,8 +25,6 @@ #include -#include - int CEditor::ms_CheckerTexture; int CEditor::ms_BackgroundTexture; int CEditor::ms_CursorTexture; diff --git a/src/game/editor/ed_io.cpp b/src/game/editor/ed_io.cpp index 7fda0a321..56b91cc31 100644 --- a/src/game/editor/ed_io.cpp +++ b/src/game/editor/ed_io.cpp @@ -1,5 +1,8 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ + +#include + #include #include #include @@ -8,8 +11,6 @@ #include #include "ed_editor.h" -#include - template static int MakeVersion(int i, const T &v) { return (i<<16)+sizeof(T); } diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index baac70414..1780986c0 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -1,5 +1,8 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ + +#include + #include #include #include @@ -16,7 +19,6 @@ #include #include -#include #include #include "gamemodes/DDRace.h" #include "score.h" diff --git a/src/osxlaunch/server.m b/src/osxlaunch/server.m index 5ae32c6fa..1aff6bc5d 100644 --- a/src/osxlaunch/server.m +++ b/src/osxlaunch/server.m @@ -83,7 +83,7 @@ void runServer() backing: NSBackingStoreBuffered defer: NO]; - [window setTitle: @"Teeworlds Server"]; + [window setTitle: @"DDRace Server"]; view = [[[ServerView alloc] initWithFrame: graphicsRect] autorelease]; [view setEditable: NO]; @@ -94,7 +94,7 @@ void runServer() [window makeKeyAndOrderFront: nil]; [view listenTo: task]; - [task setLaunchPath: [mainBundle pathForAuxiliaryExecutable: @"teeworlds_srv"]]; + [task setLaunchPath: [mainBundle pathForAuxiliaryExecutable: @"DDRace-Server"]]; [task setArguments: arguments]; [task launch]; [NSApp run]; diff --git a/src/osxlaunch/server_mysql.m b/src/osxlaunch/server_mysql.m new file mode 100644 index 000000000..89430cd93 --- /dev/null +++ b/src/osxlaunch/server_mysql.m @@ -0,0 +1,112 @@ +#import + +@interface ServerView : NSTextView +{ + NSTask *task; + NSFileHandle *file; +} +- (void)listenTo: (NSTask*)t; +@end + +@implementation ServerView +- (void)listenTo: (NSTask*)t; +{ + NSPipe *pipe; + task = t; + pipe = [NSPipe pipe]; + [task setStandardOutput: pipe]; + file = [pipe fileHandleForReading]; + + [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(outputNotification:) name: NSFileHandleReadCompletionNotification object: file]; + + [file readInBackgroundAndNotify]; +} + +- (void) outputNotification: (NSNotification *) notification +{ + NSData *data = [[[notification userInfo] objectForKey: NSFileHandleNotificationDataItem] retain]; + NSString *string = [[NSString alloc] initWithData: data encoding: NSASCIIStringEncoding]; + NSAttributedString *attrstr = [[NSAttributedString alloc] initWithString: string]; + + [[self textStorage] appendAttributedString: attrstr]; + int length = [[self textStorage] length]; + NSRange range = NSMakeRange(length, 0); + [self scrollRangeToVisible: range]; + + [attrstr release]; + [string release]; + [file readInBackgroundAndNotify]; +} + +-(void)windowWillClose:(NSNotification *)notification +{ + [task terminate]; + [NSApp terminate:self]; +} +@end + +void runServer() +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSApp = [NSApplication sharedApplication]; + NSBundle* mainBundle = [NSBundle mainBundle]; + NSTask *task; + task = [[NSTask alloc] init]; + [task setCurrentDirectoryPath: [mainBundle resourcePath]]; + + // get a server config + NSOpenPanel* openDlg = [NSOpenPanel openPanel]; + [openDlg setCanChooseFiles:YES]; + + if([openDlg runModalForDirectory:nil file:nil] != NSOKButton) + return; + + NSArray* filenames = [openDlg filenames]; + if([filenames count] != 1) + return; + + NSString* filename = [filenames objectAtIndex: 0]; + NSArray* arguments = [NSArray arrayWithObjects: @"-f", filename, nil]; + + // run server + NSWindow *window; + ServerView *view; + NSRect graphicsRect; + + graphicsRect = NSMakeRect(100.0, 1000.0, 600.0, 400.0); + + window = [[NSWindow alloc] + initWithContentRect: graphicsRect + styleMask: NSTitledWindowMask + | NSClosableWindowMask + | NSMiniaturizableWindowMask + backing: NSBackingStoreBuffered + defer: NO]; + + [window setTitle: @"DDRace Server"]; + + view = [[[ServerView alloc] initWithFrame: graphicsRect] autorelease]; + [view setEditable: NO]; + [view setRulerVisible: YES]; + + [window setContentView: view]; + [window setDelegate: view]; + [window makeKeyAndOrderFront: nil]; + + [view listenTo: task]; + [task setLaunchPath: [mainBundle pathForAuxiliaryExecutable: @"DDRace-Server_sql"]]; + [task setArguments: arguments]; + [task launch]; + [NSApp run]; + [task terminate]; + + [NSApp release]; + [pool release]; +} + +int main (int argc, char **argv) +{ + runServer(); + + return 0; +}