示例#1
0
// List the registered cvars for the given plugin id.
void DLLINTERNAL MRegCvarList::show(int plugin_id) {
	int i, n=0;
	MRegCvar *icvar;
	char bname[30+1], bval[15+1];	// +1 for term null
	
	/*
	// If OS doesn't support DLFNAME, then we can't know what the plugin's
	// registered cvars are.
	DLFNAME(NULL);
	if(meta_errno==ME_OSNOTSUP) {
		META_CONS("Registered cvars: unknown (can't get info under this OS)");
		return;
	}
	*/
	
	META_CONS("%-*s     %*s  %s", 
			sizeof(bname)-1, "Registered cvars:",
			sizeof(bval)-1, "float value",
			"string value");
	for(i=0; i < endlist; i++) {
		icvar = &vlist[i];
		if(icvar->plugid != plugin_id)
			continue;
		STRNCPY(bname, icvar->data->name, sizeof(bname));
		safevoid_snprintf(bval, sizeof(bval), "%f", icvar->data->value);
		META_CONS("   %-*s  %*s  %s", 
				sizeof(bname)-1, bname,
				sizeof(bval)-1, bval,
				icvar->data->string);
		n++;
	}
	META_CONS("%d cvars", n); 
}
示例#2
0
// List the registered usermsgs for the gamedll.
void DLLINTERNAL MRegMsgList::show(void) {
	int i, n=0;
	MRegMsg *imsg;
	char bname[25+1];	// +1 for term null

	META_CONS("%-*s    %5s  %5s", 
			sizeof(bname)-1, "Game registered user msgs:", "msgid", "size");
	for(i=0; i < endlist; i++) {
		imsg = &mlist[i];
		STRNCPY(bname, imsg->name, sizeof(bname));
		META_CONS("   %-*s   %3d    %3d", 
				sizeof(bname)-1, bname,
				imsg->msgid,
				imsg->size);
		n++;
	}
	META_CONS("%d game user msgs", n); 
}
示例#3
0
// List all the registered cvars.
void DLLINTERNAL MRegCvarList::show(void) {
	int i, n=0, a=0;
	MRegCvar *icvar;
	MPlugin *iplug;
	char bplug[13+1], bname[20+1], bval[15+1];	// +1 for term null

	META_CONS("Registered plugin cvars:");
	META_CONS("  %*s  %-*s  %-*s  %*s  %s", 
			WIDTH_MAX_REG, "",
			sizeof(bplug)-1, "plugin",
			sizeof(bname)-1, "cvar",
			sizeof(bval)-1, "float value",
			"string value");
	
	for(i=0; i < endlist; i++) {
		icvar = &vlist[i];
		if(icvar->status==RG_VALID) {
			iplug=Plugins->find(icvar->plugid);
			if(iplug)
				STRNCPY(bplug, iplug->desc, sizeof(bplug));
			else
				STRNCPY(bplug, "(unknown)", sizeof(bplug));
		}
		else
			STRNCPY(bplug, "(unloaded)", sizeof(bplug));
		STRNCPY(bname, icvar->data->name, sizeof(bname));
		safevoid_snprintf(bval, sizeof(bval), "%f", icvar->data->value);
		META_CONS(" [%*d] %-*s  %-*s  %*s  %s", 
				WIDTH_MAX_REG, icvar->index, 
				sizeof(bplug)-1, bplug,
				sizeof(bname)-1, bname,
				sizeof(bval)-1, bval,
				icvar->data->string);
		if(icvar->status==RG_VALID)
			a++;
		n++;
	}
	META_CONS("%d cvars, %d available (%d allocated)", n, a, size);
}
示例#4
0
void MPluginList::show(int source_index) {
	int i, n=0, r=0;
	MPlugin *pl;
	char desc[15+1], file[16+1], vers[7+1];		// plus 1 for term null

	if (source_index <= 0)
		META_CONS("Currently loaded plugins:");
	else
		META_CONS("Child plugins:");

	META_CONS("  %*s  %-*s  %-4s %-4s  %-*s  v%-*s  %-3s  %-5s %-5s",
			WIDTH_MAX_PLUGINS, "",
			sizeof(desc)-1, "description",
			"stat", "pend",
			sizeof(file)-1, "file", sizeof(vers)-1, "ers",
			"src", "load ", "unlod");
	for(i=0; i < endlist; i++) {
		pl=&plist[i];
		if(pl->status < PL_VALID)
			continue;
		if ((source_index > 0) && (pl->source_plugin_index != source_index))
			continue;
		STRNCPY(desc, pl->desc, sizeof(desc));
		STRNCPY(file, pl->file, sizeof(file));
		if(pl->info && pl->info->version) STRNCPY(vers, pl->info->version, sizeof(vers));
		else STRNCPY(vers, " -", sizeof(vers));
		META_CONS(" [%*d] %-*s  %-4s %-4s  %-*s  v%-*s  %-3s  %-5s %-5s",
				WIDTH_MAX_PLUGINS, pl->index, 
				sizeof(desc)-1, desc,
				pl->str_status(ST_SHOW), pl->str_action(SA_SHOW),
				sizeof(file)-1, file, sizeof(vers)-1, vers,
				pl->str_source(SO_SHOW),
				pl->str_loadable(SL_SHOW), pl->str_unloadable(SL_SHOW));
		if(pl->status == PL_RUNNING)
			r++;
		n++;
	}
	META_CONS("%d plugins, %d running", n, r);
}
示例#5
0
// List all the registered commands.
void DLLINTERNAL MRegCmdList::show(void) {
	int i, n=0, a=0;
	MRegCmd *icmd;
	MPlugin *iplug;
	char bplug[18+1];	// +1 for term null

	META_CONS("Registered plugin commands:");
	META_CONS("  %*s  %-*s  %-s", 
			WIDTH_MAX_REG, "",
			sizeof(bplug)-1, "plugin", "command");
	
	for(i=0; i < endlist; i++) {
		icmd = &mlist[i];
		
		if(icmd->status==RG_VALID) {
			iplug=Plugins->find(icmd->plugid);
		
			if(iplug)
				STRNCPY(bplug, iplug->desc, sizeof(bplug));
			else
				STRNCPY(bplug, "(unknown)", sizeof(bplug));
		}
		else
			STRNCPY(bplug, "(unloaded)", sizeof(bplug));
		
		META_CONS(" [%*d] %-*s  %-s", 
				WIDTH_MAX_REG, icmd->index, 
				sizeof(bplug)-1, bplug,
				icmd->name);
		
		if(icmd->status==RG_VALID)
			a++;
		
		n++;
	}
	
	META_CONS("%d commands, %d available (%d allocated)", n, a, size);
}
示例#6
0
// List all the registered commands for the given plugin id.
void DLLINTERNAL MRegCmdList::show(int plugin_id) {
	int i, n=0;
	MRegCmd *icmd;
	
	/*
	// If OS doesn't support DLFNAME, then we can't know what the plugin's
	// registered cvars are.
	DLFNAME(NULL);
	if(meta_errno==ME_OSNOTSUP) {
		META_CONS("Registered commands: unknown (can't get info under this OS)");
		return;
	}
	*/
	
	META_CONS("Registered commands:");
	for(i=0; i < endlist; i++) {
		icmd = &mlist[i];
		if(icmd->plugid != plugin_id)
			continue;
		META_CONS("   %s", icmd->name);
		n++;
	}
	META_CONS("%d commands", n);
}
示例#7
0
void DLLINTERNAL MConfig::show(void) {
	option_t *optp;
	if(filename)
		META_CONS("%s and %s:", "Config options from localinfo", filename);
	else
		META_CONS("%s:", "Config options from localinfo");
	for(optp=list; optp->name; optp++) {
		int *optval = (int *) optp->dest;
		char **optstr = (char **) optp->dest;
		// cvar_t *optcvar = (cvar_t *) optp->dest;
		// SETOPT_FN optcmd = (SETOPT_FN) optp->dest;
		switch(optp->type) {
			case CF_INT:
				META_CONS("   %-20s\t%d\n", optp->name, *optval);
				break;
			case CF_BOOL:
				META_CONS("   %-20s\t%s\n", optp->name, 
						*optval ? "true" : "false");
				break;
			case CF_STR:
			case CF_PATH:
				META_CONS("   %-20s\t%s\n", optp->name, 
						*optstr ? *optstr : "");
				break;
#if 0
			case CF_CVAR:
				META_CONS("   %-20s\tstores in: %s\n", optp->name, optcvar->name);
				break;
			case CF_CMD:
				META_CONS("   %-20s\tparsed by: %d\n", optp->name, (int) optcmd);
				break;
#endif
			case CF_NONE:
				break;
		}
	}
}
示例#8
0
mBOOL MPluginList::cmd_addload(const char *args) {
	MPlugin pl_temp;
	MPlugin *pl_found, *pl_added;

	// XXX move back to comands_meta ?

	// parse into a temp plugin
	memset(&pl_temp, 0, sizeof(pl_temp));
	if(pl_temp.cmd_parseline(args) != mTRUE) {
		META_CONS("Couldn't parse 'meta load' arguments: %s", args);
		// meta_errno should be already set in cmd_parseline()
		return(mFALSE);
	}

	// resolve given path into a file; accepts various "shortcut"
	// pathnames.
	if(pl_temp.resolve() != mTRUE) {
		// Couldn't find a matching file on disk
		META_CONS("Couldn't resolve given path into a file: %s", 
				pl_temp.file);
		// meta_errno should be already set in resolve()
		return(mFALSE);
	}

	// Try to find plugin with this pathname in the current list of
	// plugins.
	if((pl_found=find(pl_temp.pathname))) {
		// Already in list
		META_CONS("Plugin '%s' already in current list; file=%s desc='%s'", 
				pl_temp.file, pl_found->file, pl_found->desc);
		RETURN_ERRNO(mFALSE, ME_ALREADY);
	}
	// new plugin; add to list
	if(!(pl_added=add(&pl_temp))) {
		META_CONS("Couldn't add plugin '%s' to list; see log", pl_temp.desc);
		// meta_errno should be already set in add()
		return(mFALSE);
	}

	// try to load new plugin
	pl_added->action=PA_LOAD;
	if(!pl_added->load(PT_ANYTIME)) {
		// load failed
		if(meta_errno==ME_DELAYED) 
			META_CONS("Loaded plugin '%s', but will wait to become active, %s", 
					pl_added->desc, pl_added->str_loadable(SL_ALLOWED));
		else if(meta_errno==ME_NOTALLOWED) {
			META_CONS("Plugin '%s' couldn't attach; only allowed %s", 
					pl_added->desc, pl_added->str_loadable(SL_ALLOWED));
			pl_added->clear();
		}
		else if(pl_added->status == PL_OPENED)
			META_CONS("Opened plugin '%s', but failed to attach; see log", pl_added->desc);
		else
			META_CONS("Couldn't load plugin '%s'; see log", pl_added->desc);
		show(0);
		// meta_errno should be already set in load()
		return(mFALSE);
	}
	META_CONS("Loaded plugin '%s' successfully", pl_added->desc);
	show(0);
	return(mTRUE);
}