Skip to content

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

@nosoop

Description

@nosoop

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions