CoolFace
Datasetpublic

GSaha567/seq_level_training_data

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes52downloads
shard_000034.csv85447 linesDownload Raw Back to root
1text,length,is_long_context,metric_val,label_metric2"/*************************************************************************/3/*  main.cpp                                                             */4/*************************************************************************/5/*                       This file is part of:                           */6/*                           GODOT ENGINE                                */7/*                      https://godotengine.org                          */8/*************************************************************************/9/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.                 */10/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)    */11/*                                                                       */12/* Permission is hereby granted, free of charge, to any person obtaining */13/* a copy of this software and associated documentation files (the       */14/* ""Software""), to deal in the Software without restriction, including   */15/* without limitation the rights to use, copy, modify, merge, publish,   */16/* distribute, sublicense, and/or sell copies of the Software, and to    */17/* permit persons to whom the Software is furnished to do so, subject to */18/* the following conditions:                                             */19/*                                                                       */20/* The above copyright notice and this permission notice shall be        */21/* included in all copies or substantial portions of the Software.       */22/*                                                                       */23/* THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,       */24/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */25/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/26/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */27/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */28/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */29/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */30/*************************************************************************/31 32#include ""main.h""33 34#include ""app_icon.gen.h""35#include ""core/register_core_types.h""36#include ""drivers/register_driver_types.h""37#include ""message_queue.h""38#include ""modules/register_module_types.h""39#include ""os/os.h""40#include ""platform/register_platform_apis.h""41#include ""project_settings.h""42#include ""scene/register_scene_types.h""43#include ""script_debugger_local.h""44#include ""script_debugger_remote.h""45#include ""servers/register_server_types.h""46#include ""splash.gen.h""47#include ""splash_editor.gen.h""48 49#include ""input_map.h""50#include ""io/resource_loader.h""51#include ""scene/main/scene_tree.h""52#include ""servers/arvr_server.h""53#include ""servers/audio_server.h""54#include ""servers/physics_2d_server.h""55#include ""servers/physics_server.h""56 57#include ""io/resource_loader.h""58#include ""script_language.h""59 60#include ""core/io/ip.h""61#include ""main/tests/test_main.h""62#include ""os/dir_access.h""63#include ""scene/main/viewport.h""64#include ""scene/resources/packed_scene.h""65 66#ifdef TOOLS_ENABLED67#include ""editor/doc/doc_data.h""68#include ""editor/doc/doc_data_class_path.gen.h""69#include ""editor/editor_node.h""70#include ""editor/project_manager.h""71#endif72 73#include ""io/file_access_network.h""74#include ""servers/physics_2d_server.h""75 76#include ""core/io/file_access_pack.h""77#include ""core/io/file_access_zip.h""78#include ""core/io/stream_peer_ssl.h""79#include ""core/io/stream_peer_tcp.h""80#include ""main/input_default.h""81#include ""performance.h""82#include ""translation.h""83#include ""version.h""84#include ""version_hash.gen.h""85 86static ProjectSettings *globals = NULL;87static Engine *engine = NULL;88static InputMap *input_map = NULL;89static bool _start_success = false;90static ScriptDebugger *script_debugger = NULL;91AudioServer *audio_server = NULL;92ARVRServer *arvr_server = NULL;93PhysicsServer *physics_server = NULL;94Physics2DServer *physics_2d_server = NULL;95 96static MessageQueue *message_queue = NULL;97static Performance *performance = NULL;98 99static PackedData *packed_data = NULL;100#ifdef MINIZIP_ENABLED101static ZipArchive *zip_packed_data = NULL;102#endif103static FileAccessNetworkClient *file_access_network_client = NULL;104static TranslationServer *translation_server = NULL;105 106static OS::VideoMode video_mode;107static bool init_maximized = false;108static bool init_windowed = false;109static bool init_fullscreen = false;110static bool init_always_on_top = false;111static bool init_use_custom_pos = false;112#ifdef DEBUG_ENABLED113static bool debug_collisions = false;114static bool debug_navigation = false;115#endif116static int frame_delay = 0;117static Vector2 init_custom_pos;118static int video_driver_idx = -1;119static int audio_driver_idx = -1;120static String locale;121static bool use_debug_profiler = false;122static bool force_lowdpi = false;123static int init_screen = -1;124static bool use_vsync = true;125static bool editor = false;126static bool show_help = false;127static bool disable_render_loop = false;128static int fixed_fps = -1;129 130static OS::ProcessID allow_focus_steal_pid = 0;131 132static bool project_manager = false;133 134bool Main::is_project_manager() {135	return project_manager;136}137 138void initialize_physics() {139 140	/// 3D Physics Server141	physics_server = PhysicsServerManager::new_server(ProjectSettings::get_singleton()->get(PhysicsServerManager::setting_property_name));142	if (!physics_server) {143		// Physics server not found, Use the default physics144		physics_server = PhysicsServerManager::new_default_server();145	}146	ERR_FAIL_COND(!physics_server);147	physics_server->init();148 149	/// 2D Physics server150	physics_2d_server = Physics2DServerManager::new_server(ProjectSettings::get_singleton()->get(Physics2DServerManager::setting_property_name));151	if (!physics_2d_server) {152		// Physics server not found, Use the default physics153		physics_2d_server = Physics2DServerManager::new_default_server();154	}155	ERR_FAIL_COND(!physics_2d_server);156	physics_2d_server->init();157}158 159void finalize_physics() {160	physics_server->finish();161	memdelete(physics_server);162 163	physics_2d_server->finish();164	memdelete(physics_2d_server);165}166 167static String unescape_cmdline(const String &p_str) {168 169	return p_str.replace(""%20"", "" "");170}171 172static String get_full_version_string() {173 174	String hash = String(VERSION_HASH);175	if (hash.length() != 0)176		hash = ""."" + hash.left(7);177	return String(VERSION_MKSTRING) + hash;178}179 180//#define DEBUG_INIT181#ifdef DEBUG_INIT182#define MAIN_PRINT(m_txt) print_line(m_txt)183#else184#define MAIN_PRINT(m_txt)185#endif186 187void Main::print_help(const char *p_binary) {188 189	print_line(String(VERSION_NAME) + "" v"" + get_full_version_string() + "" - https://godotengine.org"");190	OS::get_singleton()->print(""(c) 2007-2018 Juan Linietsky, Ariel Manzur.\\n"");191	OS::get_singleton()->print(""(c) 2014-2018 Godot Engine contributors.\\n"");192	OS::get_singleton()->print(""\\n"");193	OS::get_singleton()->print(""Usage: %s [options] [path to scene or 'project.godot' file]\\n"", p_binary);194	OS::get_singleton()->print(""\\n"");195 196	OS::get_singleton()->print(""General options:\\n"");197	OS::get_singleton()->print(""  -h, --help                       Display this help message.\\n"");198	OS::get_singleton()->print(""  --version                        Display the version string.\\n"");199	OS::get_singleton()->print(""  -v, --verbose                    Use verbose stdout mode.\\n"");200	OS::get_singleton()->print(""  --quiet                          Quiet mode, silences stdout messages. Errors are still displayed.\\n"");201	OS::get_singleton()->print(""\\n"");202 203	OS::get_singleton()->print(""Run options:\\n"");204#ifdef TOOLS_ENABLED205	OS::get_singleton()->print(""  -e, --editor                     Start the editor instead of running the scene.\\n"");206	OS::get_singleton()->print(""  -p, --project-manager            Start the project manager, even if a project is auto-detected.\\n"");207#endif208	OS::get_singleton()->print(""  -l, --language <locale>          Use a specific locale (<locale> being a two-letter code).\\n"");209	OS::get_singleton()->print(""  --path <directory>               Path to a project (<directory> must contain a 'project.godot' file).\\n"");210	OS::get_singleton()->print(""  -u, --upwards                    Scan folders upwards for project.godot file.\\n"");211	OS::get_singleton()->print(""  --main-pack <file>               Path to a pack (.pck) file to load.\\n"");212	OS::get_singleton()->print(""  --render-thread <mode>           Render thread mode ('unsafe', 'safe', 'separate').\\n"");213	OS::get_singleton()->print(""  --remote-fs <address>            Remote filesystem (<host/IP>[:<port>] address).\\n"");214	OS::get_singleton()->print(""  --remote-fs-password <password>  Password for remote filesystem.\\n"");215	OS::get_singleton()->print(""  --audio-driver <driver>          Audio driver ("");216	for (int i = 0; i < OS::get_singleton()->get_audio_driver_count(); i++) {217		if (i != 0)218			OS::get_singleton()->print("", "");219		OS::get_singleton()->print(""'%s'"", OS::get_singleton()->get_audio_driver_name(i));220	}221	OS::get_singleton()->print("").\\n"");222	OS::get_singleton()->print(""  --video-driver <driver>          Video driver ("");223	for (int i = 0; i < OS::get_singleton()->get_video_driver_count(); i++) {224		if (i != 0)225			OS::get_singleton()->print("", "");226		OS::get_singleton()->print(""'%s'"", OS::get_singleton()->get_video_driver_name(i));227	}228	OS::get_singleton()->print("").\\n"");229	OS::get_singleton()->print(""\\n"");230 231	OS::get_singleton()->print(""Display options:\\n"");232	OS::get_singleton()->print(""  -f, --fullscreen                 Request fullscreen mode.\\n"");233	OS::get_singleton()->print(""  -m, --maximized                  Request a maximized window.\\n"");234	OS::get_singleton()->print(""  -w, --windowed                   Request windowed mode.\\n"");235	OS::get_singleton()->print(""  -t, --always-on-top              Request an always-on-top window.\\n"");236	OS::get_singleton()->print(""  --resolution <W>x<H>             Request window resolution.\\n"");237	OS::get_singleton()->print(""  --position <X>,<Y>               Request window position.\\n"");238	OS::get_singleton()->print(""  --low-dpi                        Force low-DPI mode (macOS and Windows only).\\n"");239	OS::get_singleton()->print(""  --no-window                      Disable window creation (Windows only). Useful together with --script.\\n"");240	OS::get_singleton()->print(""\\n"");241 242	OS::get_singleton()->print(""Debug options:\\n"");243	OS::get_singleton()->print(""  -d, --debug                      Debug (local stdout debugger).\\n"");244	OS::get_singleton()->print(""  -b, --breakpoints                Breakpoint list as source::line comma-separated pairs, no spaces (use %%20 instead).\\n"");245	OS::get_singleton()->print(""  --profiling                      Enable profiling in the script debugger.\\n"");246	OS::get_singleton()->print(""  --remote-debug <address>         Remote debug (<host/IP>:<port> address).\\n"");247#ifdef DEBUG_ENABLED248	OS::get_singleton()->print(""  --debug-collisions               Show collisions shapes when running the scene.\\n"");249	OS::get_singleton()->print(""  --debug-navigation               Show navigation polygons when running the scene.\\n"");250#endif251	OS::get_singleton()->print(""  --frame-delay <ms>               Simulate high CPU load (delay each frame by <ms> milliseconds).\\n"");252	OS::get_singleton()->print(""  --time-scale <scale>             Force time scale (higher values are faster, 1.0 is normal speed).\\n"");253	OS::get_singleton()->print(""  --disable-render-loop            Disable render loop so rendering only occurs when called explicitly from script.\\n"");254	OS::get_singleton()->print(""  --disable-crash-handler          Disable crash handler when supported by the platform code.\\n"");255	OS::get_singleton()->print(""  --fixed-fps <fps>                Force a fixed number of frames per second. This setting disables real-time synchronization.\\n"");256	OS::get_singleton()->print(""\\n"");257 258	OS::get_singleton()->print(""Standalone tools:\\n"");259	OS::get_singleton()->print(""  -s, --script <script>            Run a script.\\n"");260#ifdef TOOLS_ENABLED261	OS::get_singleton()->print(""  --export <target>                Export the project using the given export target.\\n"");262	OS::get_singleton()->print(""  --export-debug                   Use together with --export, enables debug mode for the template.\\n"");263	OS::get_singleton()->print(""  --doctool <path>                 Dump the engine API reference to the given <path> in XML format, merging if existing files are found.\\n"");264	OS::get_singleton()->print(""  --no-docbase                     Disallow dumping the base types (used with --doctool).\\n"");265#ifdef DEBUG_METHODS_ENABLED266	OS::get_singleton()->print(""  --gdnative-generate-json-api     Generate JSON dump of the Godot API for GDNative bindings.\\n"");267#endif268	OS::get_singleton()->print(""  --test <test>                    Run a unit test ("");269	const char **test_names = tests_get_names();270	const char *comma = """";271	while (*test_names) {272		OS::get_singleton()->print(""%s'%s'"", comma, *test_names);273		test_names++;274		comma = "", "";275	}276	OS::get_singleton()->print("").\\n"");277#endif278}279 280Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_phase) {281	RID_OwnerBase::init_rid();282 283	OS::get_singleton()->initialize_core();284 285	engine = memnew(Engine);286 287	ClassDB::init();288 289	MAIN_PRINT(""Main: Initialize CORE"");290 291	register_core_types();292	register_core_driver_types();293 294	MAIN_PRINT(""Main: Initialize Globals"");295 296	Thread::_main_thread_id = Thread::get_caller_id();297 298	globals = memnew(ProjectSettings);299	input_map = memnew(InputMap);300 301	register_core_settings(); //here globals is present302 303	translation_server = memnew(TranslationServer);304	performance = memnew(Performance);305	ClassDB::register_class<Performance>();306	engine->add_singleton(Engine::Singleton(""Performance"", performance));307 308	GLOBAL_DEF(""debug/settings/crash_handler/message"", String(""Please include this when reporting the bug on https://github.com/godotengine/godot/issues""));309 310	MAIN_PRINT(""Main: Parse CMDLine"");311 312	/* argument parsing and main creation */313	List<String> args;314	List<String> main_args;315 316	for (int i = 0; i < argc; i++) {317 318		args.push_back(String::utf8(argv[i]));319	}320 321	List<String>::Element *I = args.front();322 323	I = args.front();324 325	while (I) {326 327		I->get() = unescape_cmdline(I->get().strip_escapes());328		I = I->next();329	}330 331	I = args.front();332 333	String video_driver = """";334	String audio_driver = """";335	String game_path = ""."";336	bool upwards = false;337	String debug_mode;338	String debug_host;339	String main_pack;340	bool quiet_stdout = false;341	int rtm = -1;342 343	String remotefs;344	String remotefs_pass;345 346	Vector<String> breakpoints;347	bool use_custom_res = true;348	bool force_res = false;349 350	packed_data = PackedData::get_singleton();351	if (!packed_data)352		packed_data = memnew(PackedData);353 354#ifdef MINIZIP_ENABLED355 356	//XXX: always get_singleton() == 0x0357	zip_packed_data = ZipArchive::get_singleton();358	//TODO: remove this temporary fix359	if (!zip_packed_data) {360		zip_packed_data = memnew(ZipArchive);361	}362 363	packed_data->add_pack_source(zip_packed_data);364#endif365 366	I = args.front();367	while (I) {368 369		List<String>::Element *N = I->next();370 371		if (I->get() == ""-h"" || I->get() == ""--help"" || I->get() == ""/?"") { // display help372 373			show_help = true;374			goto error;375 376		} else if (I->get() == ""--version"") {377 378			print_line(get_full_version_string());379			goto error;380 381		} else if (I->get() == ""--resolution"") { // force resolution382 383			if (I->next()) {384 385				String vm = I->next()->get();386 387				if (vm.find(""x"") == -1) { // invalid parameter format388 389					OS::get_singleton()->print(""Invalid resolution '%s', it should be e.g. '1280x720'.\\n"", vm.utf8().get_data());390					goto error;391				}392 393				int w = vm.get_slice(""x"", 0).to_int();394				int h = vm.get_slice(""x"", 1).to_int();395 396				if (w <= 0 || h <= 0) {397 398					OS::get_singleton()->print(""Invalid resolution '%s', width and height must be above 0.\\n"", vm.utf8().get_data());399					goto error;400				}401 402				video_mode.width = w;403				video_mode.height = h;404				force_res = true;405 406				N = I->next()->next();407			} else {408				OS::get_singleton()->print(""Missing resolution argument, aborting.\\n"");409				goto error;410			}411		} else if (I->get() == ""--position"") { // set window position412 413			if (I->next()) {414 415				String vm = I->next()->get();416 417				if (vm.find("","") == -1) { // invalid parameter format418 419					OS::get_singleton()->print(""Invalid position '%s', it should be e.g. '80,128'.\\n"", vm.utf8().get_data());420					goto error;421				}422 423				int x = vm.get_slice("","", 0).to_int();424				int y = vm.get_slice("","", 1).to_int();425 426				init_custom_pos = Point2(x, y);427				init_use_custom_pos = true;428 429				N = I->next()->next();430			} else {431				OS::get_singleton()->print(""Missing position argument, aborting.\\n"");432				goto error;433			}434 435		} else if (I->get() == ""-m"" || I->get() == ""--maximized"") { // force maximized window436 437			init_maximized = true;438			video_mode.maximized = true;439		} else if (I->get() == ""-w"" || I->get() == ""--windowed"") { // force windowed window440 441			init_windowed = true;442		} else if (I->get() == ""-t"" || I->get() == ""--always-on-top"") { // force always-on-top window443 444			init_always_on_top = true;445		} else if (I->get() == ""--profiling"") { // enable profiling446 447			use_debug_profiler = true;448		} else if (I->get() == ""--video-driver"") { // force video driver449 450			if (I->next()) {451 452				video_driver = I->next()->get();453				N = I->next()->next();454			} else {455				OS::get_singleton()->print(""Missing video driver argument, aborting.\\n"");456				goto error;457			}458		} else if (I->get() == ""-l"" || I->get() == ""--language"") { // language459 460			if (I->next()) {461 462				locale = I->next()->get();463				N = I->next()->next();464			} else {465				OS::get_singleton()->print(""Missing language argument, aborting.\\n"");466				goto error;467			}468		} else if (I->get() == ""--low-dpi"") { // force low DPI (macOS only)469 470			force_lowdpi = true;471		} else if (I->get() == ""--remote-fs"") { // remote filesystem472 473			if (I->next()) {474 475				remotefs = I->next()->get();476				N = I->next()->next();477			} else {478				OS::get_singleton()->print(""Missing remote filesystem address, aborting.\\n"");479				goto error;480			}481		} else if (I->get() == ""--remote-fs-password"") { // remote filesystem password482 483			if (I->next()) {484 485				remotefs_pass = I->next()->get();486				N = I->next()->next();487			} else {488				OS::get_singleton()->print(""Missing remote filesystem password, aborting.\\n"");489				goto error;490			}491		} else if (I->get() == ""--render-thread"") { // render thread mode492 493			if (I->next()) {494 495				if (I->next()->get() == ""safe"")496					rtm = OS::RENDER_THREAD_SAFE;497				else if (I->next()->get() == ""unsafe"")498					rtm = OS::RENDER_THREAD_UNSAFE;499				else if (I->next()->get() == ""separate"")500					rtm = OS::RENDER_SEPARATE_THREAD;501 502				N = I->next()->next();503			} else {504				OS::get_singleton()->print(""Missing render thread mode argument, aborting.\\n"");505				goto error;506			}507 508		} else if (I->get() == ""--audio-driver"") { // audio driver509 510			if (I->next()) {511 512				audio_driver = I->next()->get();513				N = I->next()->next();514			} else {515				OS::get_singleton()->print(""Missing audio driver argument, aborting.\\n"");516				goto error;517			}518 519		} else if (I->get() == ""-f"" || I->get() == ""--fullscreen"") { // force fullscreen520 521			//video_mode.fullscreen=false;522			init_fullscreen = true;523#ifdef TOOLS_ENABLED524		} else if (I->get() == ""-e"" || I->get() == ""--editor"") { // starts editor525 526			editor = true;527		} else if (I->get() == ""-p"" || I->get() == ""--project-manager"") { // starts project manager528 529			project_manager = true;530#endif531		} else if (I->get() == ""--no-window"") { // disable window creation, Windows only532 533			OS::get_singleton()->set_no_window_mode(true);534		} else if (I->get() == ""--quiet"") { // quieter output535 536			quiet_stdout = true;537		} else if (I->get() == ""-v"" || I->get() == ""--verbose"") { // verbose output538			OS::get_singleton()->_verbose_stdout = true;539		} else if (I->get() == ""--path"") { // set path of project to start or edit540 541			if (I->next()) {542 543				String p = I->next()->get();544				if (OS::get_singleton()->set_cwd(p) == OK) {545					//nothing546				} else {547					game_path = I->next()->get(); //use game_path instead548				}549				N = I->next()->next();550			} else {551				OS::get_singleton()->print(""Missing relative or absolute path, aborting.\\n"");552				goto error;553			}554		} else if (I->get() == ""-u"" || I->get() == ""--upwards"") { // scan folders upwards555			upwards = true;556		} else if (I->get().ends_with(""project.godot"")) {557			String path;558			String file = I->get();559			int sep = MAX(file.find_last(""/""), file.find_last(""\\\\""));560			if (sep == -1)561				path = ""."";562			else {563				path = file.substr(0, sep);564			}565			if (OS::get_singleton()->set_cwd(path) == OK) {566				// path already specified, don't override567			} else {568				game_path = path;569			}570#ifdef TOOLS_ENABLED571			editor = true;572#endif573		} else if (I->get() == ""-b"" || I->get() == ""--breakpoints"") { // add breakpoints574 575			if (I->next()) {576 577				String bplist = I->next()->get();578				breakpoints = bplist.split("","");579				N = I->next()->next();580			} else {581				OS::get_singleton()->print(""Missing list of breakpoints, aborting.\\n"");582				goto error;583			}584 585		} else if (I->get() == ""--frame-delay"") { // force frame delay586 587			if (I->next()) {588 589				frame_delay = I->next()->get().to_int();590				N = I->next()->next();591			} else {592				OS::get_singleton()->print(""Missing frame delay argument, aborting.\\n"");593				goto error;594			}595 596		} else if (I->get() == ""--time-scale"") { // force time scale597 598			if (I->next()) {599 600				Engine::get_singleton()->set_time_scale(I->next()->get().to_double());601				N = I->next()->next();602			} else {603				OS::get_singleton()->print(""Missing time scale argument, aborting.\\n"");604				goto error;605			}606 607		} else if (I->get() == ""--main-pack"") {608 609			if (I->next()) {610 611				main_pack = I->next()->get();612				N = I->next()->next();613			} else {614				OS::get_singleton()->print(""Missing path to main pack file, aborting.\\n"");615				goto error;616			};617 618		} else if (I->get() == ""-d"" || I->get() == ""--debug"") {619			debug_mode = ""local"";620#ifdef DEBUG_ENABLED621		} else if (I->get() == ""--debug-collisions"") {622			debug_collisions = true;623		} else if (I->get() == ""--debug-navigation"") {624			debug_navigation = true;625#endif626		} else if (I->get() == ""--remote-debug"") {627			if (I->next()) {628 629				debug_mode = ""remote"";630				debug_host = I->next()->get();631				if (debug_host.find("":"") == -1) { // wrong address632					OS::get_singleton()->print(""Invalid debug host address, it should be of the form <host/IP>:<port>.\\n"");633					goto error;634				}635				N = I->next()->next();636			} else {637				OS::get_singleton()->print(""Missing remote debug host address, aborting.\\n"");638				goto error;639			}640		} else if (I->get() == ""--allow_focus_steal_pid"") { // not exposed to user641			if (I->next()) {642 643				allow_focus_steal_pid = I->next()->get().to_int64();644				N = I->next()->next();645			} else {646				OS::get_singleton()->print(""Missing editor PID argument, aborting.\\n"");647				goto error;648			}649		} else if (I->get() == ""--disable-render-loop"") {650			disable_render_loop = true;651		} else if (I->get() == ""--fixed-fps"") {652			if (I->next()) {653				fixed_fps = I->next()->get().to_int();654				N = I->next()->next();655			} else {656				OS::get_singleton()->print(""Missing fixed-fps argument, aborting.\\n"");657				goto error;658			}659		} else if (I->get() == ""--disable-crash-handler"") {660			OS::get_singleton()->disable_crash_handler();661		} else {662 663			//test for game path664			bool gpfound = false;665 666			if (!I->get().begins_with(""-"") && game_path == """") {667				DirAccess *da = DirAccess::open(I->get());668				if (da != NULL) {669					game_path = I->get();670					gpfound = true;671					memdelete(da);672				}673			}674 675			if (!gpfound) {676				main_args.push_back(I->get());677			}678		}679 680		I = N;681	}682 683	GLOBAL_DEF(""memory/limits/multithreaded_server/rid_pool_prealloc"", 60);684	GLOBAL_DEF(""network/limits/debugger_stdout/max_chars_per_second"", 2048);685	GLOBAL_DEF(""network/limits/debugger_stdout/max_messages_per_frame"", 10);686	GLOBAL_DEF(""network/limits/debugger_stdout/max_errors_per_frame"", 10);687 688	if (debug_mode == ""remote"") {689 690		ScriptDebuggerRemote *sdr = memnew(ScriptDebuggerRemote);691		uint16_t debug_port = 6007;692		if (debug_host.find("":"") != -1) {693			int sep_pos = debug_host.find_last("":"");694			debug_port = debug_host.substr(sep_pos + 1, debug_host.length()).to_int();695			debug_host = debug_host.substr(0, sep_pos);696		}697		Error derr = sdr->connect_to_host(debug_host, debug_port);698 699		if (derr != OK) {700			memdelete(sdr);701		} else {702			script_debugger = sdr;703		}704	} else if (debug_mode == ""local"") {705 706		script_debugger = memnew(ScriptDebuggerLocal);707	}708 709	FileAccessNetwork::configure();710 711	if (remotefs != """") {712 713		file_access_network_client = memnew(FileAccessNetworkClient);714		int port;715		if (remotefs.find("":"") != -1) {716			port = remotefs.get_slicec(':', 1).to_int();717			remotefs = remotefs.get_slicec(':', 0);718		} else {719			port = 6010;720		}721 722		Error err = file_access_network_client->connect(remotefs, port, remotefs_pass);723		if (err) {724			OS::get_singleton()->printerr(""Could not connect to remotefs: %s:%i.\\n"", remotefs.utf8().get_data(), port);725			goto error;726		}727 728		FileAccess::make_default<FileAccessNetwork>(FileAccess::ACCESS_RESOURCES);729	}730	if (script_debugger) {731		//there is a debugger, parse breakpoints732 733		for (int i = 0; i < breakpoints.size(); i++) {734 735			String bp = breakpoints[i];736			int sp = bp.find_last("":"");737			if (sp == -1) {738				ERR_EXPLAIN(""Invalid breakpoint: '"" + bp + ""', expected file:line format."");739				ERR_CONTINUE(sp == -1);740			}741 742			script_debugger->insert_breakpoint(bp.substr(sp + 1, bp.length()).to_int(), bp.substr(0, sp));743		}744	}745 746#ifdef TOOLS_ENABLED747	if (editor) {748		packed_data->set_disabled(true);749		globals->set_disable_feature_overrides(true);750		StreamPeerSSL::initialize_certs = false; //will be initialized by editor751	}752 753#endif754 755	if (globals->setup(game_path, main_pack, upwards) != OK) {756 757#ifdef TOOLS_ENABLED758		editor = false;759#else760		OS::get_singleton()->print(""Error: Could not load game path '%s'.\\n"", game_path.ascii().get_data());761 762		goto error;763#endif764	} else if (String(GLOBAL_DEF(""application/run/main_scene"", """")) == """") {765#ifdef TOOLS_ENABLED766		if (!editor) {767#endif768			OS::get_singleton()->print(""Error: Can't run project: no main scene defined.\\n"");769			goto error;770#ifdef TOOLS_ENABLED771		}772#endif773	}774 775	GLOBAL_DEF(""logging/file_logging/enable_file_logging"", false);776	GLOBAL_DEF(""logging/file_logging/log_path"", ""user://logs/log.txt"");777	GLOBAL_DEF(""logging/file_logging/max_log_files"", 10);778	if (FileAccess::get_create_func(FileAccess::ACCESS_USERDATA) && GLOBAL_GET(""logging/file_logging/enable_file_logging"")) {779		String base_path = GLOBAL_GET(""logging/file_logging/log_path"");780		int max_files = GLOBAL_GET(""logging/file_logging/max_log_files"");781		OS::get_singleton()->add_logger(memnew(RotatedFileLogger(base_path, max_files)));782	}783 784	if (editor) {785		Engine::get_singleton()->set_editor_hint(true);786		main_args.push_back(""--editor"");787		if (!init_windowed) {788			init_maximized = true;789			video_mode.maximized = true;790		}791		use_custom_res = false;792	}793 794	if (bool(ProjectSettings::get_singleton()->get(""application/run/disable_stdout""))) {795		quiet_stdout = true;796	}797	if (bool(ProjectSettings::get_singleton()->get(""application/run/disable_stderr""))) {798		_print_error_enabled = false;799	};800 801	if (quiet_stdout)802		_print_line_enabled = false;803 804	OS::get_singleton()->set_cmdline(execpath, main_args);805 806#ifdef TOOLS_ENABLED807 808	if (!project_manager) {809		// Determine if the project manager should be requested810		project_manager =811				main_args.size() == 0 &&812				!ProjectSettings::get_singleton()->has_setting(""application/run/main_loop_type"") &&813				(!ProjectSettings::get_singleton()->has_setting(""application/run/main_scene"") ||814						String(ProjectSettings::get_singleton()->get(""application/run/main_scene"")) == """");815	}816 817	if (project_manager) {818		use_custom_res = false; //project manager (run without arguments)819	}820 821#endif822 823	if (editor)824		input_map->load_default(); //keys for editor825	else826		input_map->load_from_globals(); //keys for game827 828	//if (video_driver == """") // useless for now, so removing829	//	video_driver = GLOBAL_DEF(""display/driver/name"", Variant((const char *)OS::get_singleton()->get_video_driver_name(0)));830 831	GLOBAL_DEF(""display/window/size/width"", 1024);832	GLOBAL_DEF(""display/window/size/height"", 600);833	GLOBAL_DEF(""display/window/size/resizable"", true);834	GLOBAL_DEF(""display/window/size/borderless"", false);835	GLOBAL_DEF(""display/window/size/fullscreen"", false);836	GLOBAL_DEF(""display/window/size/always_on_top"", false);837	GLOBAL_DEF(""display/window/size/test_width"", 0);838	GLOBAL_DEF(""display/window/size/test_height"", 0);839 840	if (use_custom_res) {841 842		if (!force_res) {843			video_mode.width = GLOBAL_GET(""display/window/size/width"");844			video_mode.height = GLOBAL_GET(""display/window/size/height"");845 846			if (globals->has_setting(""display/window/size/test_width"") && globals->has_setting(""display/window/size/test_height"")) {847				int tw = globals->get(""display/window/size/test_width"");848				int th = globals->get(""display/window/size/test_height"");849				if (tw > 0 && th > 0) {850					video_mode.width = tw;851					video_mode.height = th;852				}853			}854		}855 856		video_mode.resizable = GLOBAL_GET(""display/window/size/resizable"");857		video_mode.borderless_window = GLOBAL_GET(""display/window/size/borderless"");858		video_mode.fullscreen = GLOBAL_GET(""display/window/size/fullscreen"");859		video_mode.always_on_top = GLOBAL_GET(""display/window/size/always_on_top"");860	}861 862	if (!force_lowdpi) {863		OS::get_singleton()->_allow_hidpi = GLOBAL_DEF(""display/window/dpi/allow_hidpi"", false);864	}865 866	video_mode.use_vsync = GLOBAL_DEF(""display/window/vsync/use_vsync"", true);867 868	GLOBAL_DEF(""rendering/quality/intended_usage/framebuffer_allocation"", 2);869	GLOBAL_DEF(""rendering/quality/intended_usage/framebuffer_allocation.mobile"", 3);870 871	if (editor || project_manager) {872		// The editor and project manager always detect and use hiDPI if needed873		OS::get_singleton()->_allow_hidpi = true;874	}875 876	Engine::get_singleton()->_pixel_snap = GLOBAL_DEF(""rendering/quality/2d/use_pixel_snap"", false);877	OS::get_singleton()->_keep_screen_on = GLOBAL_DEF(""display/window/energy_saving/keep_screen_on"", true);878	if (rtm == -1) {879		rtm = GLOBAL_DEF(""rendering/threads/thread_model"", OS::RENDER_THREAD_SAFE);880	}881 882	if (rtm >= 0 && rtm < 3) {883		if (editor) {884			rtm = OS::RENDER_THREAD_SAFE;885		}886		OS::get_singleton()->_render_thread_mode = OS::RenderThreadMode(rtm);887	}888 889	/* Determine audio and video drivers */890 891	for (int i = 0; i < OS::get_singleton()->get_video_driver_count(); i++) {892 893		if (video_driver == OS::get_singleton()->get_video_driver_name(i)) {894 895			video_driver_idx = i;896			break;897		}898	}899 900	if (video_driver_idx < 0) {901 902		//OS::get_singleton()->alert(""Invalid Video Driver: "" + video_driver);903		video_driver_idx = 0;904		//goto error;905	}906 907	if (audio_driver == """") { // specified in project.godot908		audio_driver = GLOBAL_DEF(""audio/driver"", OS::get_singleton()->get_audio_driver_name(0));909	}910 911	for (int i = 0; i < OS::get_singleton()->get_audio_driver_count(); i++) {912 913		if (audio_driver == OS::get_singleton()->get_audio_driver_name(i)) {914 915			audio_driver_idx = i;916			break;917		}918	}919 920	if (audio_driver_idx < 0) {921 922		OS::get_singleton()->alert(""Invalid Audio Driver: "" + audio_driver);923		audio_driver_idx = 0;924		//goto error;925	}926 927	{928		String orientation = GLOBAL_DEF(""display/window/handheld/orientation"", ""landscape"");929 930		if (orientation == ""portrait"")931			OS::get_singleton()->set_screen_orientation(OS::SCREEN_PORTRAIT);932		else if (orientation == ""reverse_landscape"")933			OS::get_singleton()->set_screen_orientation(OS::SCREEN_REVERSE_LANDSCAPE);934		else if (orientation == ""reverse_portrait"")935			OS::get_singleton()->set_screen_orientation(OS::SCREEN_REVERSE_PORTRAIT);936		else if (orientation == ""sensor_landscape"")937			OS::get_singleton()->set_screen_orientation(OS::SCREEN_SENSOR_LANDSCAPE);938		else if (orientation == ""sensor_portrait"")939			OS::get_singleton()->set_screen_orientation(OS::SCREEN_SENSOR_PORTRAIT);940		else if (orientation == ""sensor"")941			OS::get_singleton()->set_screen_orientation(OS::SCREEN_SENSOR);942		else943			OS::get_singleton()->set_screen_orientation(OS::SCREEN_LANDSCAPE);944	}945 946	Engine::get_singleton()->set_iterations_per_second(GLOBAL_DEF(""physics/common/physics_fps"", 60));947	Engine::get_singleton()->set_target_fps(GLOBAL_DEF(""debug/settings/fps/force_fps"", 0));948 949	GLOBAL_DEF(""debug/settings/stdout/print_fps"", OS::get_singleton()->is_stdout_verbose());950 951	if (!OS::get_singleton()->_verbose_stdout) //overridden952		OS::get_singleton()->_verbose_stdout = GLOBAL_DEF(""debug/settings/stdout/verbose_stdout"", false);953 954	if (frame_delay == 0) {955		frame_delay = GLOBAL_DEF(""application/run/frame_delay_msec"", 0);956	}957 958	OS::get_singleton()->set_low_processor_usage_mode(GLOBAL_DEF(""application/run/low_processor_mode"", false));959	OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(GLOBAL_DEF(""application/run/low_processor_mode_sleep_usec"", 8000));960 961	Engine::get_singleton()->set_frame_delay(frame_delay);962 963	message_queue = memnew(MessageQueue);964 965	ProjectSettings::get_singleton()->register_global_defaults();966 967	if (p_second_phase)968		return setup2();969 970	return OK;971 972error:973 974	video_driver = """";975	audio_driver = """";976	game_path = """";977 978	args.clear();979	main_args.clear();980 981	if (show_help)982		print_help(execpath);983 984	if (performance)985		memdelete(performance);986	if (input_map)987		memdelete(input_map);988	if (translation_server)989		memdelete(translation_server);990	if (globals)991		memdelete(globals);992	if (engine)993		memdelete(engine);994	if (script_debugger)995		memdelete(script_debugger);996	if (packed_data)997		memdelete(packed_data);998	if (file_access_network_client)999		memdelete(file_access_network_client);1000 1001	// Note 1: *zip_packed_data live into *packed_data1002	// Note 2: PackedData::~PackedData destroy this.1003	/*1004#ifdef MINIZIP_ENABLED1005	if (zip_packed_data)1006		memdelete( zip_packed_data );1007#endif1008*/1009 1010	unregister_core_driver_types();1011	unregister_core_types();1012 1013	OS::get_singleton()->_cmdline.clear();1014 1015	if (message_queue)1016		memdelete(message_queue);1017	OS::get_singleton()->finalize_core();1018	locale = String();1019 1020	return ERR_INVALID_PARAMETER;1021}1022 1023Error Main::setup2(Thread::ID p_main_tid_override) {1024 1025	if (p_main_tid_override) {1026		Thread::_main_thread_id = p_main_tid_override;1027	}1028 1029	Error err = OS::get_singleton()->initialize(video_mode, video_driver_idx, audio_driver_idx);1030	if (err != OK) {1031		return err;1032	}1033	if (init_use_custom_pos) {1034		OS::get_singleton()->set_window_position(init_custom_pos);1035	}1036 1037	// right moment to create and initialize the audio server1038 1039	audio_server = memnew(AudioServer);1040	audio_server->init();1041 1042	// also init our arvr_server from here1043	arvr_server = memnew(ARVRServer);1044 1045	register_core_singletons();1046 1047	MAIN_PRINT(""Main: Setup Logo"");1048 1049#ifdef JAVASCRIPT_ENABLED1050	bool show_logo = false;1051#else1052	bool show_logo = true;1053#endif1054 1055	if (init_screen != -1) {1056		OS::get_singleton()->set_current_screen(init_screen);1057	}1058	if (init_windowed) {1059		//do none..1060	} else if (init_maximized) {1061		OS::get_singleton()->set_window_maximized(true);1062	} else if (init_fullscreen) {1063		OS::get_singleton()->set_window_fullscreen(true);1064	}1065	if (init_always_on_top) {1066		OS::get_singleton()->set_window_always_on_top(true);1067	}1068 1069	register_server_types();1070 1071	MAIN_PRINT(""Main: Load Remaps"");1072 1073	Color clear = GLOBAL_DEF(""rendering/environment/default_clear_color"", Color(0.3, 0.3, 0.3));1074	VisualServer::get_singleton()->set_default_clear_color(clear);1075 1076	if (show_logo) { //boot logo!1077		String boot_logo_path = GLOBAL_DEF(""application/boot_splash/image"", String());1078		bool boot_logo_scale = GLOBAL_DEF(""application/boot_splash/fullsize"", true);1079		ProjectSettings::get_singleton()->set_custom_property_info(""application/boot_splash/image"", PropertyInfo(Variant::STRING, ""application/boot_splash/image"", PROPERTY_HINT_FILE, ""*.png""));1080 1081		Ref<Image> boot_logo;1082 1083		boot_logo_path = boot_logo_path.strip_edges();1084 1085		if (boot_logo_path != String() /*&& FileAccess::exists(boot_logo_path)*/) {1086			print_line(""Boot splash path: "" + boot_logo_path);1087			boot_logo.instance();1088			Error err = boot_logo->load(boot_logo_path);1089			if (err)1090				ERR_PRINTS(""Non-existing or invalid boot splash at: "" + boot_logo_path + "". Loading default splash."");1091		}1092 1093		if (boot_logo.is_valid()) {1094			OS::get_singleton()->_msec_splash = OS::get_singleton()->get_ticks_msec();1095			Color boot_bg = GLOBAL_DEF(""application/boot_splash/bg_color"", clear);1096			VisualServer::get_singleton()->set_boot_image(boot_logo, boot_bg, boot_logo_scale);1097#ifndef TOOLS_ENABLED1098//no tools, so free the boot logo (no longer needed)1099//ProjectSettings::get_singleton()->set(""application/boot_logo"",Image());1100#endif1101 1102		} else {1103#ifndef NO_DEFAULT_BOOT_LOGO1104 1105			MAIN_PRINT(""Main: Create bootsplash"");1106#if defined(TOOLS_ENABLED) && !defined(NO_EDITOR_SPLASH)1107 1108			Ref<Image> splash = editor ? memnew(Image(boot_splash_editor_png)) : memnew(Image(boot_splash_png));1109#else1110			Ref<Image> splash = memnew(Image(boot_splash_png));1111#endif1112 1113			MAIN_PRINT(""Main: ClearColor"");1114			VisualServer::get_singleton()->set_default_clear_color(boot_splash_bg_color);1115			MAIN_PRINT(""Main: Image"");1116			VisualServer::get_singleton()->set_boot_image(splash, boot_splash_bg_color, false);1117#endif1118		}1119 1120#ifdef TOOLS_ENABLED1121		Ref<Image> icon = memnew(Image(app_icon_png));1122		OS::get_singleton()->set_icon(icon);1123#endif1124	}1125 1126	MAIN_PRINT(""Main: DCC"");1127	VisualServer::get_singleton()->set_default_clear_color(GLOBAL_DEF(""rendering/environment/default_clear_color"", Color(0.3, 0.3, 0.3)));1128	MAIN_PRINT(""Main: END"");1129 1130	GLOBAL_DEF(""application/config/icon"", String());1131	ProjectSettings::get_singleton()->set_custom_property_info(""application/config/icon"", PropertyInfo(Variant::STRING, ""application/config/icon"", PROPERTY_HINT_FILE, ""*.png,*.webp""));1132 1133	if (bool(GLOBAL_DEF(""display/window/handheld/emulate_touchscreen"", false))) {1134		if (!OS::get_singleton()->has_touchscreen_ui_hint() && Input::get_singleton() && !editor) {1135			//only if no touchscreen ui hint, set emulation1136			InputDefault *id = Object::cast_to<InputDefault>(Input::get_singleton());1137			if (id)1138				id->set_emulate_touch(true);1139		}1140	}1141 1142	MAIN_PRINT(""Main: Load Remaps"");1143 1144	MAIN_PRINT(""Main: Load Scene Types"");1145 1146	register_scene_types();1147 1148	GLOBAL_DEF(""display/mouse_cursor/custom_image"", String());1149	GLOBAL_DEF(""display/mouse_cursor/custom_image_hotspot"", Vector2());1150	ProjectSettings::get_singleton()->set_custom_property_info(""display/mouse_cursor/custom_image"", PropertyInfo(Variant::STRING, ""display/mouse_cursor/custom_image"", PROPERTY_HINT_FILE, ""*.png,*.webp""));1151 1152	if (String(ProjectSettings::get_singleton()->get(""display/mouse_cursor/custom_image"")) != String()) {1153 1154		//print_line(""use custom cursor"");1155		Ref<Texture> cursor = ResourceLoader::load(ProjectSettings::get_singleton()->get(""display/mouse_cursor/custom_image""));1156		if (cursor.is_valid()) {1157			//print_line(""loaded ok"");1158			Vector2 hotspot = ProjectSettings::get_singleton()->get(""display/mouse_cursor/custom_image_hotspot"");1159			Input::get_singleton()->set_custom_mouse_cursor(cursor, Input::CURSOR_ARROW, hotspot);1160		}1161	}1162#ifdef TOOLS_ENABLED1163	ClassDB::set_current_api(ClassDB::API_EDITOR);1164	EditorNode::register_editor_types();1165 1166	ClassDB::set_current_api(ClassDB::API_CORE);1167 1168#endif1169 1170	if (allow_focus_steal_pid) {1171		OS::get_singleton()->enable_for_stealing_focus(allow_focus_steal_pid);1172	}1173 1174	MAIN_PRINT(""Main: Load Modules, Physics, Drivers, Scripts"");1175 1176	register_platform_apis();1177	register_module_types();1178 1179	initialize_physics();1180	register_server_singletons();1181 1182	register_driver_types();1183 1184	ScriptServer::init_languages();1185 1186	MAIN_PRINT(""Main: Load Translations"");1187 1188	translation_server->setup(); //register translations, load them, etc.1189	if (locale != """") {1190 1191		translation_server->set_locale(locale);1192	}1193	translation_server->load_translations();1194	ResourceLoader::load_translation_remaps(); //load remaps for resources1195 1196	ResourceLoader::load_path_remaps();1197 1198	audio_server->load_default_bus_layout();1199 1200	if (use_debug_profiler && script_debugger) {

Showing the first 1,200 of 85447 lines. Download the file for the rest.