Browse Source

Change services to log an error when not spawning

pull/8/head
Anton Tarasenko 4 years ago
parent
commit
be05bc156d
  1. 6
      sources/Service.uc

6
sources/Service.uc

@ -24,6 +24,8 @@ class Service extends Singleton
// Listeners listed here will be automatically activated. // Listeners listed here will be automatically activated.
var public const array< class<Listener> > requiredListeners; var public const array< class<Listener> > requiredListeners;
var LoggerAPI.Definition errNoService;
// Enables feature of given class. // Enables feature of given class.
public static final function Service Require() public static final function Service Require()
{ {
@ -35,6 +37,9 @@ public static final function Service Require()
default.blockSpawning = false; default.blockSpawning = false;
newInstance = Service(__().memory.Allocate(default.class)); newInstance = Service(__().memory.Allocate(default.class));
default.blockSpawning = true; default.blockSpawning = true;
if (newInstance == none) {
__().logger.Auto(default.errNoService).ArgClass(default.class);
}
return newInstance; return newInstance;
} }
@ -78,4 +83,5 @@ defaultproperties
blockSpawning = true blockSpawning = true
// Features are server-only actors // Features are server-only actors
remoteRole = ROLE_None remoteRole = ROLE_None
errNoService = "Cannot start required service %1."
} }
Loading…
Cancel
Save