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

Unable to detect Feature tags #8

Open
ZackingIt opened this issue Jul 29, 2020 · 9 comments
Open

Unable to detect Feature tags #8

ZackingIt opened this issue Jul 29, 2020 · 9 comments

Comments

@ZackingIt
Copy link

ZackingIt commented Jul 29, 2020

Am using 3.2.2 headless server and OS.has_feature is not returning true for either "client" or "server" and as such my code is always running the default-case "cannot detect blah blah blah" -- below are my export settings for Server.pck. I left "embed PCK" unchecked and I clicked "Export to PCK/Zip"
Thank you!

image

@Wavesonics
Copy link
Owner

Wavesonics commented Jul 29, 2020 via email

@ZackingIt
Copy link
Author

image

Here is the Entry.gd code as well, only changed some print statements to make it more prominent which OS.feature type I'm using:

extends Node

# Entry point for the whole app
# Determine the type of app this is, and load the entry point for that type
func _ready():
	print("Application started")
	if OS.has_feature("server"):
		print("*** SERVER INSTANCE****")
		get_tree().change_scene("res://server/ServerEntry.tscn")
	elif OS.has_feature("client"):
		print("*** CLIENT INSTANCE****")
		get_tree().change_scene("res://client/ClientEntry.tscn")
	# When running from the editor, this is how we'll default to being a client
	else:
		print("Could not detect application type! Defaulting to server.")
		print("*** SERVER INSTANCE****")
		get_tree().change_scene("res://server/ServerEntry.tscn")

@ZackingIt
Copy link
Author

And I used this server binary:
serverbinarypic

@ZackingIt
Copy link
Author

Yikes this may be a Godot issue: godotengine/godot#38747

@ZackingIt
Copy link
Author

ZackingIt commented Jul 29, 2020

Here's my temporary fix for anyone else stumbling into this issue -- basically we detect the name of the executable instead of the feature flag, per the other Godot issue.


func check_if_server() -> bool:
	return OS.get_executable_path().ends_with("godot_server.64")

func check_if_client() -> bool:
	return OS.get_executable_path().ends_with("godot.exe")


# Entry point for the whole app
# Determine the type of app this is, and load the entry point for that type
func _ready():
	print("Application started: ", OS.is_debug_build())
	print("My executable path: ", OS.get_executable_path())
	
	if check_if_server():
		print("*** SERVER INSTANCE****")
		get_tree().change_scene("res://server/ServerEntry.tscn")
	elif check_if_client():
		print("*** CLIENT INSTANCE****")
		get_tree().change_scene("res://client/ClientEntry.tscn")
	# When running from the editor, this is how we'll default to being a client
	else:
		print("COULD NOT DETECT APPLICATION TYPE. Defaulting to server.")
		print("*** SERVER INSTANCE****")
		get_tree().change_scene("res://server/ServerEntry.tscn")

image

@Wavesonics
Copy link
Owner

I haven't had time to look into this yet, but I did just test my project that I'm using this architecture for: https://github.com/FugitiveTheGame/Fugitive3D

And at least when exporting the Windows Server binary on 3.2.2, it does pick up the features as it should. I haven't had time to check the Linux build today, but I have a couple live headless Linux servers running on 3.2.2 which are functioning properly.

I know that isn't very helpful to you right now, but seems like there is something weird going on, and not a 100% broken issue in the current build of Godot.

@ZackingIt
Copy link
Author

Thanks so much for checking I will do a few more attempts. FWIW I'm using Ubuntu on Windows / Bash on Windows.

@dweremeichik
Copy link

dweremeichik commented Nov 14, 2020

From the official documentation it looks like you might be using the wrong flag:

# Note: Feature tags are case-sensitive! It's "Server", not "server".
if OS.has_feature("Server"):
    # Run your server startup code here...
    # Note that using this check may break unit testing scripts when
    # running them with headless or server binaries.
    pass

Edit:
Also for what it is worth "client" isn't a default feature flag either.

@Wavesonics
Copy link
Owner

So I'm still unable to reproduce this on my end.

I just got latest and tried with Godot 3.2.3 (Win64):
Screenshot 2020-11-14 181030

I exported that binary as such:
Screenshot 2020-11-14 181229

And simply ran the exe produced by that export.

@dweremeichik the feature we're detecting is a custom feature, not one baked into an export template. That way we can export to any platform, not just the dedicated server template for linux.

As you can see in the above screenshot, the custom feature is lower case. I'm wondering if maybe this bug is coming from incorrectly configured exports?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants