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

[Bug] Setting "ff2_plugin_subplugins" to a directory inside a directory crashes the server #67

Closed
DanishSoup opened this issue Jul 22, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@DanishSoup
Copy link

Description

In issue #47 a request had been made to make sub-plugins load/unload in "freaks" which would be changed to another directory like "disabled". But when trying to do set "ff2_plugin_subplugins" to a directory inside a directory ("disabled/freaks" or "freaks/disabled"), the server crashes with many of the sub-plugins failing to load and being blamed/

Reproduce

Steps to reproduce the behavior:

  1. Edit "ff2_plugin_subplugins" in /tf/cfg/sourcemod/FF2Rewrite.cfg
  2. Set "ff2_plugin_subplugins" to "disabled/freaks" or "freaks/disabled"
  3. Start the server and wait for a boss to be picked
  4. Before the boss can be picked, the server crashes

Media

Example of errors:
L 07/21/2023 - 19:58:38: [SM] Blaming: disabled/freaks/bill_abilities.smx
L 07/21/2023 - 19:58:38: [SM] Call stack trace:
L 07/21/2023 - 19:58:38: [SM] [1] Line 11, C:\Users\RavensBro\Desktop\knights of god\source mod and meta mod\sourcemod-1.5.1-hg3914-windows-ff2\addons\sourcemod\scripting\include\freak_fortress_2_subplugin.inc::GetThisPluginName
L 07/21/2023 - 19:58:38: [SM] [2] Line 33, C:\Users\RavensBro\Desktop\knights of god\source mod and meta mod\sourcemod-1.5.1-hg3914-windows-ff2\addons\sourcemod\scripting\include\freak_fortress_2_subplugin.inc::OnPluginStart
L 07/21/2023 - 19:58:38: [SM] [4] ServerExecute
L 07/21/2023 - 19:58:38: [SM] [5] Line 3116, freak_fortress_2/bosses.sp::EnableSubplugins
L 07/21/2023 - 19:58:38: [SM] [6] Line 1602, freak_fortress_2/bosses.sp::Bosses_CreateFromConfig
L 07/21/2023 - 19:58:38: [SM] [7] Line 1576, freak_fortress_2/bosses.sp::Bosses_CreateFromSpecial
L 07/21/2023 - 19:58:38: [SM] [8] Line 250, freak_fortress_2/gamemode.sp::Gamemode_RoundSetup
L 07/21/2023 - 19:58:38: [SM] [9] Line 362, freak_fortress_2/dhooks.sp::DHook_RoundRespawn
[SM] Plugin disabled/freaks/bill_abilities.smx failed to load: Error detected in plugin startup (see error logs).

Environment

  • OS: Linux Mint 21.2
  • SourceMod Version/Build: 1.11.0.6934
  • Freak Fortress Version/Build: 1.1.118

Other Information

The server uses some legacy sub-plugins and new rewrite sub-plugins

@DanishSoup DanishSoup added the bug Something isn't working label Jul 22, 2023
@Batfoxkid
Copy link
Owner

Batfoxkid commented Jul 29, 2023

This is a result of a coding mistake done in the original FF2 subplugin include. There is no way to fix this through the main plugin and all subplugins using this include need to be compiled to fix this issue.

void GetThisPluginName()
{
	char pluginName[80];
	GetPluginFilename(INVALID_HANDLE, pluginName, sizeof(pluginName));
	
	int finalPluginName = -1;
	for(;;)
	{
		int forwardSlash = StrContains(pluginName[finalPluginName+1], "/");
		int backwardSlash = StrContains(pluginName[finalPluginName+1], "\\");
		if((backwardSlash<forwardSlash && backwardSlash!=-1) || forwardSlash==-1)
		{
			if(backwardSlash == -1)
				break;
+			
+			if(finalPluginName == -1)
+				finalPluginName = 0;
+			
+			finalPluginName += backwardSlash;
-			finalPluginName = backwardSlash;
		}
		else if((forwardSlash<backwardSlash && forwardSlash!=-1) || backwardSlash==-1)
		{
			if(forwardSlash == -1)
				break;
+			
+			if(finalPluginName == -1)
+				finalPluginName = 0;
+			
+			finalPluginName += forwardSlash;
-			finalPluginName = forwardSlash;
		}
	}
	strcopy(this_plugin_name, sizeof(this_plugin_name), pluginName[finalPluginName+1]);
}

@Batfoxkid Batfoxkid closed this as not planned Won't fix, can't repro, duplicate, stale Jul 29, 2023
@Batfoxkid Batfoxkid pinned this issue Jul 29, 2023
@DanishSoup
Copy link
Author

DanishSoup commented Jul 29, 2023

This is a result of a coding mistake done in the original FF2 subplugin include. There is no way to fix this through the main plugin and all subplugins using this include need to be compiled to fix this issue.

void GetThisPluginName()
{
	char pluginName[80];
	GetPluginFilename(INVALID_HANDLE, pluginName, sizeof(pluginName));
	
	int finalPluginName = -1;
	for(;;)
	{
		int forwardSlash = StrContains(pluginName[finalPluginName+1], "/");
		int backwardSlash = StrContains(pluginName[finalPluginName+1], "\\");
		if((backwardSlash<forwardSlash && backwardSlash!=-1) || forwardSlash==-1)
		{
			if(backwardSlash == -1)
				break;
+			
+			if(finalPluginName == -1)
+				finalPluginName = 0;
+			
+			finalPluginName += backwardSlash;
-			finalPluginName = backwardSlash;
		}
		else if((forwardSlash<backwardSlash && forwardSlash!=-1) || backwardSlash==-1)
		{
			if(forwardSlash == -1)
				break;
+			
+			if(finalPluginName == -1)
+				finalPluginName = 0;
+			
+			finalPluginName += forwardSlash;
-			finalPluginName = forwardSlash;
		}
	}
	strcopy(this_plugin_name, sizeof(this_plugin_name), pluginName[finalPluginName+1]);
}

I seem to still be having problems when trying to load legacy plugins through another directory. I applied both of the freak_fortress_2_subplugins.inc edits provided and I would get this error in console

L 07/29/2023 - 11:28:01: [SM] Blaming: disabled/freaks/ff2_phatrages.smx
L 07/29/2023 - 11:28:01: [SM] Call stack trace:
L 07/29/2023 - 11:28:01: [SM]   [1] Line 9, /home/danish/Downloads/freak_fortress_2/addons/sourcemod/scripting/include/freak_fortress_2_subplugin.inc::GetThisPluginName
L 07/29/2023 - 11:28:01: [SM]   [2] Line 40, /home/danish/Downloads/freak_fortress_2/addons/sourcemod/scripting/include/freak_fortress_2_subplugin.inc::OnPluginStart
L 07/29/2023 - 11:28:01: [SM]   [4] ServerExecute
L 07/29/2023 - 11:28:01: [SM]   [5] Line 3116, freak_fortress_2/bosses.sp::EnableSubplugins
L 07/29/2023 - 11:28:01: [SM]   [6] Line 1602, freak_fortress_2/bosses.sp::Bosses_CreateFromConfig
L 07/29/2023 - 11:28:01: [SM]   [7] Line 1576, freak_fortress_2/bosses.sp::Bosses_CreateFromSpecial
L 07/29/2023 - 11:28:01: [SM]   [8] Line 250, freak_fortress_2/gamemode.sp::Gamemode_RoundSetup
L 07/29/2023 - 11:28:01: [SM]   [9] Line 362, freak_fortress_2/dhooks.sp::DHook_RoundRespawn
[SM] Plugin disabled/freaks/ff2_phatrages.smx failed to load: Error detected in plugin startup (see error logs).
[SM] Loaded plugin disabled/freaks/ff2r_epic_abilities.smx successfully.
[SM] Loaded plugin disabled/freaks/ff2r_menu_abilities.smx successfully.
[SM] Loaded plugin disabled/freaks/ff2r_tfcond.smx successfully.
[SM] Loaded plugin disabled/freaks/ff2r_default_abilities.smx successfully.

Before the boss round starts, it would hang up for a few seconds but the plugin would refuse to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants