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

SDKHooks: OnLevelInit stops being called when the last registered plugin is reloaded #912

Closed
nosoop opened this issue Oct 27, 2018 · 3 comments · Fixed by #916
Closed

SDKHooks: OnLevelInit stops being called when the last registered plugin is reloaded #912

nosoop opened this issue Oct 27, 2018 · 3 comments · Fixed by #916

Comments

@nosoop
Copy link
Contributor

nosoop commented Oct 27, 2018

Environment

  • Operating System version: Linux
  • Game/AppID (with version if applicable): Team Fortress 2
  • Tested against SourceMod stable 1.9.0.6259, development 1.10.0.6353
  • Tested against MetaMod:Source snapshot 1.11.0-dev+1116

Description

When the last plugin using OnLevelInit is unloaded (or reloaded), the forward never fires again.

Problematic Code (or Steps to Reproduce)

Below is levelinit_check.sp; all it does is report that OnLevelInit is called and logs it to a text file.

#pragma semicolon 1
#include <sourcemod>

#include <sdkhooks>

#pragma newdecls required
#pragma dynamic 1048576

public Action OnLevelInit(const char[] mapName, char mapEntities[2097152]) {
	LogToFile("level_inits.txt", "-------- Level init on %s --------", mapName);
}

The test case assumes that no other plugin using OnLevelInit is loaded in.

If the plugin is installed before the server starts up:

  1. Message is correctly displayed on level init.
  2. Perform mapchange; message is correctly displayed on level init.
  3. Reload plugin via sm plugins reload levelinit_check.
  4. Perform mapchange, message is (incorrectly) not displayed.

Without the plugin present:

  1. Message is correctly not displayed on the first map.
  2. Install plugin and load via sm plugins load levelinit_check.
  3. Perform mapchange; message is correctly displayed.
  4. Reload plugin via sm plugins reload levelinit_check.
  5. Perform mapchange, message is (incorrectly) not displayed.
@asherkin
Copy link
Member

Looks like the only possible cause of this I can see is if OnPluginLoaded is being called before forwards are re-bound.

Does it work if you unload and then load the plugin rather than using reload?

@nosoop
Copy link
Contributor Author

nosoop commented Oct 27, 2018

The plugin does not report any output if the plugin is unloaded and reloaded loaded before performing a map change (in the case that the message was previously displayed on level init).

@KyleSanderson
Copy link
Member

Thanks for filling the issue :-)

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

Successfully merging a pull request may close this issue.

3 participants