示例#1
0
void V_Init()
{
CVAR_BEGIN(vars)
#if !NO_DEBUG
	CVAR_VAR(cl_testblend, 0, 0),
	CVAR_VAR(cl_testentities, 0, 0),
	CVAR_VAR(cl_testlights, 0, CVAR_CHEAT),

	CVAR_VAR(r_playerpos, 0, CVAR_CHEAT),
	CVAR_VAR(r_surfinfo, 0, CVAR_CHEAT),
	CVAR_VAR(r_showBrush, -1, CVAR_CHEAT),
#endif // NO_DEBUG

	CVAR_VAR(r_drawfps, 0, 0),
	CVAR_VAR(scr_viewsize, 100, CVAR_ARCHIVE)	//?? should rename: not scr var
CVAR_END

	Cvar_GetVars(ARRAY_ARG(vars));

#if GUN_DEBUG
	RegisterCommand("gun_next",  Gun_Next_f);
	RegisterCommand("gun_prev",  Gun_Prev_f);
	RegisterCommand("gun_model", Gun_Model_f);
#endif
#if !NO_DEBUG
	RegisterCommand("setlight", SetLight_f);
#endif
	RegisterCommand("sky", Sky_f);
}
示例#2
0
  RoboRobo* RoboRoboFactory::Create()
  {
    auto client = std::unique_ptr<gloox::Client>(CreateClient());
    auto commandsMap = std::make_unique<CommandsMap>();
    const CommandsMap& commandsMapRef = *commandsMap;
    auto messageHandler = new MessageHandler(*client, std::move(commandsMap));
    auto connectionListener = new ConnectionListener(*client);

    client->registerMessageHandler(messageHandler);
    client->registerConnectionListener(connectionListener);

    auto soundPlayer = SoundPlayerFactory::CreateUniquePointer();
    auto synthesizer = SpeechSynthesizerFactory::CreateUniquePointer(*soundPlayer);
    auto gpio = GpioFactory::CreateUniquePointer();


    messageHandler->RegisterDefaultCommand(std::move(std::make_unique<UnknownCommand>()));
    messageHandler->RegisterCommand('s', std::move(std::make_unique<ServoCommand>(*gpio)));
    messageHandler->RegisterCommand('l', std::move(std::make_unique<LedCommand>(*gpio)));
    messageHandler->RegisterCommand('t', std::move(std::make_unique<TellCommand>(*synthesizer)));
    messageHandler->RegisterCommand('p', std::move(std::make_unique<PlaySoundCommand>(*soundPlayer)));
    messageHandler->RegisterCommand('h', std::move(std::make_unique<HelpCommand>(commandsMapRef)));

    auto robo = new RoboRobo(std::move(gpio), std::move(soundPlayer), std::move(synthesizer), std::move(client));
    return robo;
  }
示例#3
0
void InitModels()
{
	memset(&map, 0, sizeof(map));

	RegisterCommand("modellist", Modellist_f);
#if TEST_LOAD
	RegisterCommand("loadmodel", LoadModel_f);
#endif
}
示例#4
0
void Console::registerDefaultCommands_()			//! loads a few default commands into the console
{
  LoadSaveCommands_();

  RegisterCommand(new IC_Command_ECHO() );
  RegisterCommand(new IC_Command_HELP() );
  RegisterCommand(new IC_Command_LIST() );
  RegisterCommand(new IC_Command_CLS() );
  RegisterCommand(new IC_Command_SCRIPT() );
}
示例#5
0
  GStringLibrary()
  {

    RegisterCommand("setstring", [&](Context *context) {
      std::string strValue =
          context->InterpolateString(context->stack.Pop().GetString());
      std::string strName = context->stack.Pop().GetString();

      context->SetVariable(strName, GVARTYPE_STRING, GStringVariable(strValue));

      Log::Get().Print(LOGLEVEL_VERBOSE, "setstring %s=%s\n", strName.c_str(),
                       strValue.c_str());
    });

    RegisterCommand("addstring", [&](Context *context) {
      std::string strValue =
          context->InterpolateString(context->stack.Pop().GetString());
      std::string strName = context->stack.Pop().GetString();

      GStringVariable *strVariable =
          (GStringVariable *)context->GetVariable(strName, GVARTYPE_STRING);

      if (strVariable == nullptr) {
        context->SetVariable(strName, GVARTYPE_STRING,
                             GStringVariable(strValue));

        Log::Get().Print(LOGLEVEL_VERBOSE, "addstring %s=%s\n", strName.c_str(),
                         strValue.c_str());
      } else {
        context->SetVariable(strName, GVARTYPE_STRING,
                             GStringVariable(strVariable->string + strValue));

        Log::Get().Print(LOGLEVEL_VERBOSE, "addstring %s=%s\n", strName.c_str(),
                         (strVariable->string + strValue).c_str());
      }
    });

    RegisterFunction("strtofloat", [&](Context *context) {
      std::string strValue =
          context->InterpolateString(context->stack.Pop().GetString());

      try {
        context->stack.Push(std::stof(strValue));
      }

      catch (...) {
        context->stack.Push(0.0f);
      }
    });
  };
示例#6
0
//---------------------------------------------------------------------------
void DeveloperConsole::Initialize()
{
	m_cursorBlinkTimerSeconds = 0.5f;
	m_currentCursorTimer = 0.f;
	m_currentCursorIndex = 0;
	m_currentCommandHistoryIndex = 0;
	m_isCursorVisible = true;
	//m_currentConsoleCommandString = "\0"; // null terminate

	RegisterCommand( "help", Command_Help, "Displays command information. Usage: <help> <command>" );
	RegisterCommand( "clear", Command_Clear, "Clears the command log. Usage: <clear>" );
	RegisterCommand( "quit", Command_Quit, "Quits the program. Usage: <quit>" );
	RegisterCommand( "qqq", Command_Quit, "Quits the program. Usage: <qqq>" );
}
TEST(command, CreateCommandInstance) {
  ASSERT_TRUE(CreateCommandInstance("mock1") == nullptr);
  RegisterCommand("mock1", [] { return std::unique_ptr<Command>(new MockCommand); });
  ASSERT_TRUE(CreateCommandInstance("mock1") != nullptr);
  UnRegisterCommand("mock1");
  ASSERT_TRUE(CreateCommandInstance("mock1") == nullptr);
}
示例#8
0
文件: main.cpp 项目: pretty-wise/link
bool RestClientPluginTest::OnStartup(const char* config, streamsize nbytes) {
	bool result = RegisterCommand(&m_command);
	if(!result) {
		PLUGIN_INFO("failed to register %s", m_command.Name());
	}
	return result;
}
TEST(command, GetAllCommands) {
  size_t command_count = GetAllCommandNames().size();
  RegisterCommand("mock1", [] { return std::unique_ptr<Command>(new MockCommand); });
  ASSERT_EQ(command_count + 1, GetAllCommandNames().size());
  UnRegisterCommand("mock1");
  ASSERT_EQ(command_count, GetAllCommandNames().size());
}
示例#10
0
CCommand::CCommand(tstring sName, CommandCallback pfnCallback)
{
	m_sName = sName;
	m_pfnCallback = pfnCallback;

	RegisterCommand(this);
}
示例#11
0
void S_Init(void)
{
	cvar_t *cv = Cvar_Get("nosound", "0", 0);
	if (cv->integer)
		appPrintf(S_CYAN"Sound disabled\n");
	else
	{
CVAR_BEGIN(vars)
		CVAR_VAR(s_volume, 0.7, CVAR_ARCHIVE),
		CVAR_VAR(s_khz, 22, CVAR_ARCHIVE),
		CVAR_VAR(s_loadas8bit, 0, CVAR_ARCHIVE),
		CVAR_VAR(s_reverse_stereo, 0, CVAR_ARCHIVE),
		CVAR_VAR(s_mixahead, 0.2, CVAR_ARCHIVE),
		CVAR_VAR(s_show, 0, 0),
		CVAR_VAR(s_testsound, 0, 0),
		CVAR_VAR(s_primary, 0, CVAR_ARCHIVE)		//?? win32 specific
CVAR_END

		Cvar_GetVars(ARRAY_ARG(vars));

		appPrintf("\n------- Sound initialization -------\n");

		if (!SNDDMA_Init()) return;

		RegisterCommand("play", S_Play_f);
		RegisterCommand("stopsound", S_StopAllSounds_f);
		RegisterCommand("soundlist", S_SoundList_f);
		RegisterCommand("soundinfo", S_SoundInfo_f);

		S_InitScaletable();

		sound_started = true;
		num_sfx = 0;

		soundtime   = 0;
		paintedtime = 0;

		appPrintf("sound sampling rate: %d\n", dma.speed);

		S_StopAllSounds_f();

		appPrintf("------------------------------------\n");
	}
}
示例#12
0
    ViewerRecorder(EnvironmentBasePtr penv, std::istream& sinput) : ModuleBase(penv)
    {
        __description = ":Interface Author: Rosen Diankov\n\nRecords the images produced from a viewer into video file. The recordings can be synchronized to real-time or simulation time, by default simulation time is used. Each instance can record only one file at a time. To record multiple files simultaneously, create multiple VideoRecorder instances";
        RegisterCommand("Start",boost::bind(&ViewerRecorder::_StartCommand,this,_1,_2),
                        "Starts recording a file, this will stop all previous recordings and overwrite any previous files stored in this location. Format::\n\n  Start [width] [height] [framerate] codec [codec] timing [simtime/realtime/controlsimtime[=timestepmult]] viewer [name]\\n filename [filename]\\n\n\nBecause the viewer and filenames can have spaces, the names are ready until a newline is encountered");
        RegisterCommand("Stop",boost::bind(&ViewerRecorder::_StopCommand,this,_1,_2),
                        "Stops recording and saves the file. Format::\n\n  Stop\n\n");
        RegisterCommand("GetCodecs",boost::bind(&ViewerRecorder::_GetCodecsCommand,this,_1,_2),
                        "Return all the possible codecs, one codec per line:[video_codec id] [name]");
        RegisterCommand("SetWatermark",boost::bind(&ViewerRecorder::_SetWatermarkCommand,this,_1,_2),
                        "Set a WxHx4 image as a watermark. Each color is an unsigned integer ordered as A|B|G|R. The origin should be the top left corner");
        _nFrameCount = _nVideoWidth = _nVideoHeight = 0;
        _framerate = 0;
        _nUseSimulationTime = 1;
        _fSimulationTimeMultiplier = 1;
        _starttime = 0;
        _bContinueThread = true;
        _bStopRecord = true;
        _frameindex = 0;
#ifdef _WIN32
        _pfile = NULL;
        _ps = NULL;
        _psCompressed = NULL;
        _psText = NULL;
        _biSizeImage = 0;
#else
        _bWroteURL = false;
        _bWroteHeader = false;
        _output = NULL;
        _stream = NULL;
        _picture = NULL;
        _yuv420p = NULL;
        _picture_buf = NULL;
        _outbuf = NULL;
        _picture_size = 0;
        _outbuf_size = 0;
#endif
        _threadrecord.reset(new boost::thread(boost::bind(&ViewerRecorder::_RecordThread,this)));
    }
示例#13
0
ConsoleAPI::ConsoleAPI(Framework *fw) :
    QObject(fw),
    framework(fw),
    enabledLogChannels(LogLevelErrorWarnInfo),
    logFile(0),
    logFileText(0)
{
    if (!fw->IsHeadless())
        consoleWidget = new ConsoleWidget(framework);

    inputContext = framework->Input()->RegisterInputContext("Console", 100);
    inputContext->SetTakeKeyboardEventsOverQt(true);
    connect(inputContext.get(), SIGNAL(KeyEventReceived(KeyEvent *)), SLOT(HandleKeyEvent(KeyEvent *)));

    RegisterCommand("help", "Lists all registered commands.", this, SLOT(ListCommands()));
    RegisterCommand("clear", "Clears the console log.", this, SLOT(ClearLog()));
    RegisterCommand("setLogLevel", "Sets the current log level. Call with one of the parameters \"error\", \"warning\", \"info\", or \"debug\".",
        this, SLOT(SetLogLevel(const QString &)));
#ifdef WIN32
    RegisterCommand("createConsole", "Creates the native Windows console if Tundra was started without such.", this, SLOT(CreateNativeConsole()));
    RegisterCommand("removeConsole", "Removes the native Windows console if applicable.", this, SLOT(RemoveNativeConsole()));
#endif

    /// \todo Visual Leak Detector shows a memory leak originating from this allocation although the shellInputThread is released in the destructor. Perhaps a shared pointer is held elsewhere.
    shellInputThread = MAKE_SHARED(ShellInputThread);

    QStringList logLevel = fw->CommandLineParameters("--loglevel");
    if (logLevel.size() >= 1)
        SetLogLevel(logLevel[logLevel.size()-1]);
    if (logLevel.size() > 1)
        LogWarning("Ignoring multiple --loglevel command line parameters!");

    QStringList logFile = fw->CommandLineParameters("--logfile");
    if (logFile.size() >= 1)
        SetLogFile(logFile[logFile.size()-1]);
    if (logFile.size() > 1)
        LogWarning("Ignoring multiple --logfile command line parameters!");
}
示例#14
0
MENU_ITEM* GenerateMenu(LPXLOPER xllName, char* menuName, char* subMenu, LPXLOPER items)
{
    int itemCount = items->val.array.rows;
    MENU_ITEM* mi = (MENU_ITEM*) malloc(sizeof(MENU_ITEM) * (itemCount + 1));
    mi[0].menuName = menuName;
    mi[0].helpText = "";
    mi[0].menuCommand = "";
    for(int i = 0; i < itemCount; i++) {
        LPXLOPER x = &items->val.array.lparray[i];
        mi[i+1].menuName = XLMap::getNTString(x, "name");
        mi[i+1].helpText = XLMap::getNTString(x, "help");
        mi[i+1].menuCommand = RegisterCommand(xllName, menuName, subMenu, mi[i+1].menuName);
    }
    return mi;
}
示例#15
0
/*****************************************************************************
 * Create: allocates adjust video thread output method
 *****************************************************************************
 * This function allocates and initializes a adjust vout method.
 *****************************************************************************/
static int Create( vlc_object_t *p_this )
{
    filter_t *p_filter = (filter_t *)p_this;
    filter_sys_t *p_sys;

    /* Allocate structure */
    p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
    if( p_filter->p_sys == NULL )
        return VLC_ENOMEM;
    p_sys = p_filter->p_sys;

    BufferInit( &p_sys->input );
    BufferInit( &p_sys->output );
    QueueInit( &p_sys->atomic );
    QueueInit( &p_sys->pending );
    QueueInit( &p_sys->processed );
    do_ListInit( &p_sys->overlays );

    p_sys->i_inputfd = -1;
    p_sys->i_outputfd = -1;
    p_sys->b_updated = true;
    p_sys->b_atomic = false;
    vlc_mutex_init( &p_sys->lock );

    p_filter->pf_sub_source = Filter;

    config_ChainParse( p_filter, "overlay-", ppsz_filter_options,
                       p_filter->p_cfg );

    p_sys->psz_inputfile = var_CreateGetStringCommand( p_filter,
                                                       "overlay-input" );
    p_sys->psz_outputfile = var_CreateGetStringCommand( p_filter,
                                                        "overlay-output" );

    var_AddCallback( p_filter, "overlay-input", AdjustCallback, p_sys );
    var_AddCallback( p_filter, "overlay-output", AdjustCallback, p_sys );

    RegisterCommand( p_filter );
    return VLC_SUCCESS;
}
示例#16
0
void appInit(/*?? const char *_cmdLine */)
{
	guard(appInit);

	// verify type sizes
	staticAssert(sizeof(short)==2, Sizeof_Short_2);
	staticAssert(sizeof(int)==4, Sizeof_Int_4);
	staticAssert(sizeof(int64)==8, Sizeof_Int64_8);
	staticAssert((char)127 > (char)128, Char_Should_Be_Signed);
	staticAssert(sizeof(address_t)==sizeof(void*), Wrong_Address_t_Size);

	appInitPlatform();
	appInitMemory();
	appInitError();
	appLoadDebugSymbols();

//!!	GVersion = PkgVersion;
//!!	RegisterCommand("version", Cmd_Version);
	RegisterCommand("quit", Cmd_Quit);		//?? add "exit" as synonym ("quit" came from Quake, but "exit" from bash etc)

	unguard;
}
示例#17
0
BOOL CGTProcessor::Init()
{
    RegisterCommand(GTLS_LOGIN_REQ, CGTProcessor::OnLoginReq);
    RegisterCommand(GTLS_LOGIN_EX_REQ, CGTProcessor::OnLoginExReq);

    RegisterCommand(CLILS_REGISTER_REQ, CGTProcessor::OnRegisterUserNameReq);
    RegisterCommand(CLILS_BIND_REQ, CGTProcessor::OnBindReq);
    RegisterCommand(CLILS_UNBIND_REQ, CGTProcessor::OnUnBindReq);

    RegisterCommand(GSLS_PLAYER_UPGRADE_NTF, CGTProcessor::OnPlayerUpgrate);
    RegisterCommand(GSLS_DSPNAME_UPGRADE_NTF, CGTProcessor::OnDspNameUpgrate);

    RegisterCommand(CLILS_LOGOUT_REQ, CGTProcessor::OnLogoutReq);

    RegisterCommand(GSLS_ACTIVITY_NOTIFY_NTF, CGTProcessor::OnActivityNotify);
    RegisterCommand(GTLS_CHANGE_PWD_REQ, CGTProcessor::OnChangePwdReq);

    RegisterCommand(CLILS_BIND_MOBILE_REQ, CGTProcessor::OnBindMobileReq);
    RegisterCommand(CLILS_BIND_CHECK_VER_CODE_REQ, CGTProcessor::OnBindCheckVerCodeReq);

    RegisterCommand(CLILS_UNBIND_MOBILE_REQ, CGTProcessor::OnUnBindMobileReq);
    RegisterCommand(CLILS_UNBIND_CHECK_VER_CODE_REQ, CGTProcessor::OnUnBindCheckVerCodeReq);

	RegisterCommand(CLILS_GET_USER_EXPAND_REQ, CGTProcessor::OnGetUserExpandReq);
    return TRUE;
}
示例#18
0
RakNetTransportCommandParser::RakNetTransportCommandParser()
{
	RegisterCommand(1, "SetPassword","Changes the console password to whatever.");
	RegisterCommand(0, "ClearPassword","Removes the console passwords.");
	RegisterCommand(0, "GetPassword","Gets the console password.");
}
示例#19
0
LogCommandParser::LogCommandParser()
{
    RegisterCommand(CommandParserInterface::VARIABLE_NUMBER_OF_PARAMETERS,"Subscribe","[<ChannelName>] - Subscribes to a named channel, or all channels");
    RegisterCommand(CommandParserInterface::VARIABLE_NUMBER_OF_PARAMETERS,"Unsubscribe","[<ChannelName>] - Unsubscribes from a named channel, or all channels");
    memset(channelNames,0,sizeof(channelNames));
}
示例#20
0
void
GameEvent(CORE_DATA *cd)
{
	switch (cd->event) {
	case EVENT_START:
		RegisterPlugin(OPENCORE_VERSION, "rabbit", "cycad", "1.0", __DATE__, __TIME__, "A rabbit bot", sizeof(USER_DATA), 0);

		/* set rabbit pid to nobody */
		ud(cd)->rabbit_pid = PID_NONE;

		/* register rabbit command */
		RegisterCommand(COMMAND_RABBIT, "!rabbit", "Rabbit", 2, CMD_PRIVATE, "<name>:<bounty>[:<special>]", "Start the rabbit game", NULL); break;
	case EVENT_LOGIN:
		/* set the bot's location to center */
		SetPosition(16 * 512, 16 * 512, 0, 0);
		break;
	case EVENT_COMMAND:
		switch (cd->cmd_id) {
		case COMMAND_RABBIT: {
			int show_usage = 0;

			PLAYER_ID rpid = ud(cd)->rabbit_pid;

			if (rpid == PID_NONE) {	/* rabbit game is not runnig */
				if (cd->cmd_argc <= 1) {
					show_usage = 1;
				} else {
					char *cmd = cd->cmd_argr[1];
					int nargs = ArgCount(cmd, ':');

					if (nargs != 2 && nargs != 3) {
						show_usage = 1;
					} else {	/* args to command are valid */
						/* copy name out of command */
						char rname[20];
						DelimArgs(rname, sizeof(rname), cmd, 0, ':', 0);

						/* copy bounty out of command */
						int bty = AtoiArg(cmd, 1, ':');

						/* copy special out of command if it was specified */
						int special = 0;
						if (nargs == 3)
							special = AtoiArg(cmd, 2, ':');

						/* find the player specified on the command line */
						PLAYER *rabbit = FindPlayerName(rname, MATCH_HERE | MATCH_PREFIX);
						if (rabbit) {
							/* player found, start the game */
							start_rabbit_game(cd, rabbit, bty, special);
						} else {
							RmtMessageFmt(cd->cmd_name, "Player not found: %s", rname);
						}
					}
				}
			} else {
				/* rabbit game is already running */
				PLAYER *p = FindPlayerPid(rpid, MATCH_HERE);

				RmtMessageFmt(cd->cmd_name, "Rabbit is already running (%s is the rabbit)",
				    p ? p->name : "**UNKNOWN**");
			}

			/* display usage if necessary */
			if (show_usage) RmtMessageFmt(cd->cmd_name, "Usage: %s <name>:<bounty>[:<special>]", cd->cmd_argv[0]);
		}
		default: break;
		}
		break;
	case EVENT_UPDATE:
		if (ud(cd)->rabbit_pid == cd->p1->pid) {	/* if the update is for the rabbit */
			if (cd->p1->status & STATUS_SAFE) {	/* check if the rabbit is in safe */
				/* the rabbit entered safe, end the game */
				ArenaMessageFmt("%s has lost the rabbit game by entering safe!", cd->p1->name);
				ud(cd)->rabbit_pid = PID_NONE;
			}
		}
		break;
	case EVENT_TIMER:
		if (ud(cd)->rabbit_pid != PID_NONE) {	/* if the rabbit game is running */
			/* find the rabbit */
			PLAYER *p = FindPlayerPid(ud(cd)->rabbit_pid, MATCH_HERE);
			if (p) {
				if (ud(cd)->where_timer == cd->timer_id) {
					/* a *where timer expired, send the next one and look for response */
					PrivMessage(p, "*where");
					ud(cd)->expecting_where = 1;
				} else if (ud(cd)->gameover_timer == cd->timer_id) {
					/* the game over timer expired, the rabbit didnt die and he won */
					ArenaMessageFmt("%s wins the rabbit game by staying alive!", p->name);
					ud(cd)->rabbit_pid = PID_NONE;
				}
			} else {
				/* rabbit not found, this should never happen! */
			}
		}
	case EVENT_MESSAGE:
		/*
		 * Only look for a response of the game is running, the bot is expecting *where,
		 * and the message type is an arena message.
		 */
		if (ud(cd)->rabbit_pid != PID_NONE && ud(cd)->expecting_where && 
		    cd->msg_type == MSG_ARENA) {
			/* message is a possible *where response */

			/* find the rabbit */
			PLAYER *p = FindPlayerPid(ud(cd)->rabbit_pid, MATCH_HERE);
			if (p) {
				char where_prefix[32];
				snprintf(where_prefix, 32, "%s: ", p->name);
				where_prefix[32 - 1] = '\0';

				/*
				 * Verify that this is *where output by looking for "rabbit: " at the
				 * beginning of the string.
				 */
				if (strncasecmp(where_prefix, cd->msg, strlen(where_prefix)) == 0) {
					/* this must be a *where response, process it */
					char loc[4];
					snprintf(loc, 4, "%s", &cd->msg[strlen(where_prefix)]);
					loc[4 - 1] = '\0';

					/* announce the rabbits location */
					ArenaMessageFmt(">>> Rabbit %s is at %-3s <<<", p->name, loc);

					/* set the next *where timer */
					ud(cd)->where_timer = SetTimer(30 * 1000, 0, 0);

					/*
					 * The bot wont be looking for *where responses until the
					 * next time it sends the command, so turn parsing off
					 * for now.
					 */
					ud(cd)->expecting_where = 0;
				}
			}
		}
		break;
	case EVENT_KILL:
		if (cd->p1->pid == ud(cd)->rabbit_pid) {
			/* the rabbit died */
			ArenaMessageFmt("%s wins the rabbit game by killing Rabbit %s!", cd->p2->name, cd->p1->name);
			ud(cd)->rabbit_pid = PID_NONE;
		}
		break;
	case EVENT_LEAVE:
		if (ud(cd)->rabbit_pid == cd->p1->pid) {
			/* the rabbit left */
			ArenaMessageFmt("%s has lost the rabbit game by leaving the arena!", cd->p1->name);
			ud(cd)->rabbit_pid = PID_NONE;
		}
		break;
	case EVENT_CHANGE:
		if (ud(cd)->rabbit_pid == cd->p1->pid) {
			/* the rabbit changed ship */
			ArenaMessageFmt("%s has lost the rabbit game by changing ship/freq!", cd->p1->name);
			ud(cd)->rabbit_pid = PID_NONE;
		}
		break;
	}
}
CBirrtProblem::CBirrtProblem(EnvironmentBasePtr penv) : ProblemInstance(penv)
{
    __description = ":Interface Author: Dmitry Berenson\nInterface to CBiRRT planner that parses input and passes it to the planner. Can also call the GeneralIK plugin. \n\n`C++ Documentation <http://automation.berkeley.edu/~berenson/docs/cbirrt/index.html>`_";
    RegisterCommand("GrabBody",boost::bind(&CBirrtProblem::GrabBody,this,_1,_2),
                    "Robot calls ::Grab on a body with its current manipulator");

    RegisterCommand("RunCBirrt",boost::bind(&CBirrtProblem::RunCBirrt,this,_1,_2),
                    "Run the CBirrt Planner");

    RegisterCommand("DoGeneralIK",boost::bind(&CBirrtProblem::DoGeneralIK,this,_1,_2),
                    "Calls the General IK solver");

    RegisterCommand("CheckSupport",boost::bind(&CBirrtProblem::CheckSupport,this,_1,_2),
                    "Checks whether the cg of the robot is over the given support polygon");

    RegisterCommand("CheckSelfCollision",boost::bind(&CBirrtProblem::CheckSelfCollision,this,_1,_2),
                    "Checks whether the robot is in self-collision");

    RegisterCommand("GetJointAxis",boost::bind(&CBirrtProblem::GetJointAxis,this,_1,_2),
                    "Returns the joint axis of a given kinbody");

    RegisterCommand("GetJointTransform",boost::bind(&CBirrtProblem::GetJointTransform,this,_1,_2),
                    "Returns the joint transform of a given kinbody");

    RegisterCommand("GetCamView",boost::bind(&CBirrtProblem::GetCamView,this,_1,_2),
                    "Get the currnet camera view");

    RegisterCommand("SetCamView",boost::bind(&CBirrtProblem::SetCamView,this,_1,_2),
                    "Set the currnet camera view");

    RegisterCommand("Traj",boost::bind(&CBirrtProblem::Traj,this,_1,_2),
                    "Execute a trajectory from a file on the local filesystem");

    RegisterCommand("GetPlannerState",boost::bind(&CBirrtProblem::GetPlannerState,this,_1,_2),
                    "Returns the current state of the planner");

    RegisterCommand("StopPlanner",boost::bind(&CBirrtProblem::StopPlanner,this,_1,_2),
                    "Stops the planner if it is running");

    _reusePlanner = false;
    _plannerState = PS_Idle;
    _plannerThread.reset();

}
RakNetCommandParser::RakNetCommandParser()
{
	RegisterCommand(4, "Startup","( unsigned short maxConnections, int _threadSleepTimer, unsigned short localPort, const char *forceHostAddress );");
	RegisterCommand(0,"InitializeSecurity","();");
	RegisterCommand(0,"DisableSecurity","( void );");
	RegisterCommand(1,"AddToSecurityExceptionList","( const char *ip );");
	RegisterCommand(1,"RemoveFromSecurityExceptionList","( const char *ip );");
	RegisterCommand(1,"IsInSecurityExceptionList","( const char *ip );");
	RegisterCommand(1,"SetMaximumIncomingConnections","( unsigned short numberAllowed );");
	RegisterCommand(0,"GetMaximumIncomingConnections","( void ) const;");
	RegisterCommand(4,"Connect","( const char* host, unsigned short remotePort, const char *passwordData, int passwordDataLength );");
	RegisterCommand(2,"Disconnect","( unsigned int blockDuration, unsigned char orderingChannel=0 );");
	RegisterCommand(0,"IsActive","( void ) const;");
	RegisterCommand(0,"GetConnectionList","() const;");
	RegisterCommand(4,"CloseConnection","( const SystemAddress target, bool sendDisconnectionNotification, unsigned char orderingChannel=0 );");
	RegisterCommand(2,"IsConnected","( );");
	RegisterCommand(2,"GetIndexFromSystemAddress","( const SystemAddress systemAddress );");
	RegisterCommand(1,"GetSystemAddressFromIndex","( int index );");
	RegisterCommand(2,"AddToBanList","( const char *IP, RakNetTime milliseconds=0 );");
	RegisterCommand(1,"RemoveFromBanList","( const char *IP );");
	RegisterCommand(0,"ClearBanList","( void );");
	RegisterCommand(1,"IsBanned","( const char *IP );");
	RegisterCommand(2,"Ping1","( const SystemAddress target );");
	RegisterCommand(3,"Ping2","( const char* host, unsigned short remotePort, bool onlyReplyOnAcceptingConnections );");
	RegisterCommand(2,"GetAveragePing","( const SystemAddress systemAddress );");
	RegisterCommand(2,"GetLastPing","( const SystemAddress systemAddress ) const;");
	RegisterCommand(2,"GetLowestPing","( const SystemAddress systemAddress ) const;");
	RegisterCommand(1,"SetOccasionalPing","( bool doPing );");
	RegisterCommand(2,"SetOfflinePingResponse","( const char *data, const unsigned int length );");
	RegisterCommand(0,"GetInternalID","( void ) const;");
	RegisterCommand(2,"GetExternalID","( const SystemAddress target ) const;");
	RegisterCommand(3,"SetTimeoutTime","( RakNetTime timeMS, const SystemAddress target );");
	RegisterCommand(1,"SetMTUSize","( int size );");
	RegisterCommand(0,"GetMTUSize","( void ) const;");
	RegisterCommand(0,"GetNumberOfAddresses","( void );");
	RegisterCommand(1,"GetLocalIP","( unsigned int index );");
	RegisterCommand(1,"AllowConnectionResponseIPMigration","( bool allow );");
	RegisterCommand(4,"AdvertiseSystem","( const char *host, unsigned short remotePort, const char *data, int dataLength );");
	RegisterCommand(2,"SetIncomingPassword","( const char* passwordData, int passwordDataLength );");
	RegisterCommand(0,"GetIncomingPassword","( void );");
	RegisterCommand(3,"ApplyNetworkSimulator","( double maxSendBPS, unsigned short minExtraPing, unsigned short extraPingVariance);");
	RegisterCommand(0,"IsNetworkSimulatorActive","( void );");
}
void RegisterListCommand() {
  RegisterCommand("list", [] { return std::unique_ptr<Command>(new ListCommand); });
}
示例#24
0
void RegisterAPICommands() {
  RegisterCommand("api-prepare",
                  []{ return std::unique_ptr<Command>(new PrepareCommand()); });
  RegisterCommand("api-collect",
                  []{ return std::unique_ptr<Command>(new CollectCommand()); });
}
示例#25
0
BOOL CLSProcessor::Init()
{
    RegisterCommand(GTLS_LOGIN_ACK,        CLSProcessor::OnLoginAck);
    RegisterCommand(GTLS_LOGIN_EX_ACK,		CLSProcessor::OnLoginExAck);
    return TRUE;
}
示例#26
0
BOOL CTLCProcessor::Init()
{
    RegisterCommand(LSTLC_AUTH_ACK, CTLCProcessor::OnAuthAck);

    return TRUE;
}
示例#27
0
bool GatePlugin::OnStartup(const char *config, streamsize nbytes) {

  if(!RegisterCommand(&m_list_cmd) || !RegisterCommand(&m_disconnect_cmd) ||
     !RegisterCommand(&m_logout_cmd)) {
    return false;
  }
  if(!config || nbytes == 0) {
    PLUGIN_ERROR("no config");
    return false;
  }

  tinyxml2::XMLDocument doc;
  tinyxml2::XMLError err = doc.Parse(config, nbytes);

  if(err != tinyxml2::XML_SUCCESS) {
    PLUGIN_ERROR("problem parsing config: %s(%d)", doc.ErrorName(), err);
    return false;
  }

  u16 port = 0;
  u32 max_connections = 0;
  std::string redis_hostname("localhost");
  u16 redis_port = 6379;
  {
    tinyxml2::XMLElement *root = doc.RootElement();
    if(root->Attribute("port")) {
      port = root->IntAttribute("port");
      PLUGIN_INFO("port read %d", port);
    } else {
      PLUGIN_WARN("no port specified, defaulting to 0");
    }

    if(!root->Attribute("max_connections")) {
      PLUGIN_ERROR("maximum connection count not specified");
      return false;
    }
    max_connections = root->IntAttribute("max_connections");
    PLUGIN_INFO("maximum number of connections: %d", max_connections);

    if(max_connections == 0) {
      PLUGIN_ERROR("invalid number of max connections: %d", max_connections);
      return false;
    }

    tinyxml2::XMLElement *redis = root->FirstChildElement("redis");
    if(redis && redis->Attribute("hostname") && redis->Attribute("port")) {
      redis_hostname = redis->Attribute("hostname");
      redis_port = redis->IntAttribute("port");
    } else {
      PLUGIN_WARN("failed to load redis config");
    }
  }

  m_users = new Users(max_connections);
  if(m_users == nullptr) {
    PLUGIN_ERROR("problem creating users data");
    return false;
  }

  TCPServer::Callbacks callbacks = {Link::Gate::OnConnected,
                                    Link::Gate::OnDisconnected,
                                    Link::Gate::OnMessage};

  m_conn = new TCPServer(max_connections, callbacks, this);

  if(!m_conn->CreateListenSocket(port)) {
    delete m_conn;
    PLUGIN_ERROR("failed to create listen port");
    return false;
  }

  PLUGIN_INFO("gate listening on port: %d", port);

  RedisConnectBlocking(redis_hostname.c_str(), redis_port);

  return true;
}
示例#28
0
void clConsole::AfterConstruction()
{
	RegisterCommand( "Quit",             Utils::Bind( &clConsole::QuitC,          this ) );
	RegisterCommand( "Exit",             Utils::Bind( &clConsole::QuitC,          this ) );
	RegisterCommand( "Exec",             Utils::Bind( &clConsole::ExecC,          this ) );
	RegisterCommand( "Bind",             Utils::Bind( &clConsole::BindC,          this ) );
	RegisterCommand( "Alias",            Utils::Bind( &clConsole::AliasC,         this ) );
	RegisterCommand( "ToggleConsole",    Utils::Bind( &clConsole::ToggleConsoleC, this ) );
	RegisterCommand( "Mount",            Utils::Bind( &clConsole::MountC,         this ) );
	RegisterCommand( "Clear",            Utils::Bind( &clConsole::ClearC,         this ) );
	RegisterCommand( "Version",          Utils::Bind( &clConsole::VersionC,       this ) );
	RegisterCommand( "Help",             Utils::Bind( &clConsole::HelpC,          this ) );
	RegisterCommand( "CmdList",          Utils::Bind( &clConsole::HelpC,          this ) );
	RegisterCommand( "TogglePause",      Utils::Bind( &clConsole::TogglePauseC,   this ) );
	RegisterCommand( "Toggle",           Utils::Bind( &clConsole::ToggleC,        this ) );
	RegisterCommand( "Set",              Utils::Bind( &clConsole::SetC,           this ) );
	RegisterCommand( "SetProperty",      Utils::Bind( &clConsole::SetPropertyC,   this ) );
	RegisterCommand( "Show",             Utils::Bind( &clConsole::ShowC,          this ) );
	RegisterCommand( "Menu",             Utils::Bind( &clConsole::MenuC,          this ) );
	RegisterCommand( "SaveVars",         Utils::Bind( &clConsole::SaveVarsC,      this ) );
	RegisterCommand( "RefreshScreen",    Utils::Bind( &clConsole::RefreshScreenC, this ) );
	RegisterCommand( "Sleep",            Utils::Bind( &clConsole::SleepC,         this ) );
	RegisterCommand( "SetLogLevel",      Utils::Bind( &clConsole::SetLogLevelC,   this ) );
	RegisterCommand( "PrintLogLevel",    Utils::Bind( &clConsole::PrintLogLevelC, this ) );

	RegisterCommand( "AddDirWatch",      Utils::Bind( &clFileSystem::AddDirWatchC,     Env->FileSystem ) );
	RegisterCommand( "AddFileWatch",     Utils::Bind( &clFileSystem::AddFileWatchC,    Env->FileSystem ) );
	RegisterCommand( "RemoveDirWatch",   Utils::Bind( &clFileSystem::RemoveDirWatchC,  Env->FileSystem ) );
	RegisterCommand( "RemoveFileWatch",  Utils::Bind( &clFileSystem::RemoveFileWatchC, Env->FileSystem ) );

	Env->Logger->Connect( L_EVENT_ERROR,       BIND( &clConsole::Event_ERROR ) );
	Env->Connect( L_EVENT_TIMER,       BIND( &clConsole::Event_TIMER ) );
	Env->ConnectWithPriority( L_EVENT_KEY,         BIND( &clConsole::Event_KEY         ),  -1 );

	FConsoleHUDFileName = GetVar( "GUI.ConsoleHUD" );
	FConsoleHUDFileName->SetString( "Interface/Console.gui" );

	FShouldSaveHistory = GetVar ( "Console.SaveHistory" );
	FShouldSaveHistory->SetBool( true );

	GetVarDefault( "Core.EngineVersion", ENGINE_VERSION );

	if ( Env->FileSystem->FileExists( HistoryFileName ) )
	{
		iIStream* Input = Env->FileSystem->CreateFileReader( HistoryFileName );

		FCommandsHistory->LoadFromStream( Input );

		delete( Input );
	}

	// instantiate script compiler
	// its initialization is delayed until some script is actually compiled
	FScriptCompiler = Env->Linker->Instantiate( "clScriptCompiler" );
}
示例#29
0
static
void
register_commands()
{
	bool is_master = strcmp(get_thread_data()->bot_type, "master") == 0;

	if (is_master) {
		RegisterCommand(CMD_DIE, "!die", CORE_NAME, 9, CMD_PRIVATE | CMD_REMOTE, NULL, "Shut down the bot core", "This shuts down the bot core and all running bots.");
		RegisterCommand(CMD_STARTBOT, "!startbot", CORE_NAME, 2, CMD_PRIVATE | CMD_REMOTE, "<type> <arena>", "Start a bot", "Start a bot of <type> into <arena>");
		RegisterCommand(CMD_GETFILE, "!getfile", CORE_NAME, 7, CMD_PRIVATE | CMD_REMOTE, "<filename>", "Force the bot to download <filename>", "Force the bot to download <filename>");
		RegisterCommand(CMD_PUTFILE, "!putfile", CORE_NAME, 7, CMD_PRIVATE | CMD_REMOTE, "<filename>", "Force the bot to upload <filename>", "Force the bot to upload <filename>");
		RegisterCommand(CMD_LISTBOTS, "!listbots", CORE_NAME, 2, CMD_PRIVATE | CMD_REMOTE, NULL, "List the running bots", "List the running bots");
		RegisterCommand(CMD_TYPES, "!types", CORE_NAME, 1, CMD_PRIVATE | CMD_REMOTE, NULL, "List types of bots tha can be started", "List types of bots tha can be started");
		RegisterCommand(CMD_LOADTYPES, "!loadtypes", CORE_NAME, OP_HSMOD, CMD_PRIVATE | CMD_REMOTE, NULL, "Load the bot types file", "Load the bot types file");
		RegisterCommand(CMD_SYSINFO, "!sysinfo", CORE_NAME, 2, CMD_PRIVATE | CMD_REMOTE, NULL, "Show system information", "Show system information, including load averages. Load averages are the average number of processes in the system process queue over the last 1, 5, and 15 minutes.");
		RegisterCommand(CMD_LOADOPS, "!loadops", CORE_NAME, 5, CMD_PRIVATE | CMD_REMOTE, NULL, "Load op file", "Reload the op file. This affects all bots.");
		RegisterCommand(CMD_EXEC, "!exec", CORE_NAME, 9, CMD_PRIVATE | CMD_REMOTE, NULL, "Execute a shell command", "Execute a shell command and spew the output");
	} else {
		RegisterCommand(CMD_STOPBOT, "!stopbot", CORE_NAME, 2, CMD_PRIVATE | CMD_REMOTE, NULL, "Stops this bot", "Stops this bot");
		RegisterCommand(CMD_GO, "!go", CORE_NAME, 7, CMD_PRIVATE | CMD_REMOTE, "<arena>", "Change the bot's arena", "Change the bot's arena");
	}

	RegisterCommand(CMD_LOG, "!log", CORE_NAME, 2, CMD_PRIVATE | CMD_REMOTE, NULL, "Show the bot's log", "Show the bot's log");
	RegisterCommand(CMD_CMDLOG, "!cmdlog", CORE_NAME, 2, CMD_PRIVATE | CMD_REMOTE, NULL, "Show the bot's command log", "Show the bot's command log");
	RegisterCommand(CMD_ABOUT, "!about", CORE_NAME, 0, CMD_PRIVATE | CMD_REMOTE, NULL, "Show core and library information", "Shows information about the core and libraries.");
	RegisterCommand(CMD_INSLIB, "!inslib", CORE_NAME, 9, CMD_PRIVATE | CMD_REMOTE, "<lib name>", "Load a module into the bot", "Load a module into the bot");
	RegisterCommand(CMD_RMLIB, "!rmlib", CORE_NAME, 9, CMD_PRIVATE | CMD_REMOTE, "<lib name>", "Unload a library from the bot", "Unload a library from the bot");
	RegisterCommand(CMD_HELP, "!help", CORE_NAME, 0, CMD_PRIVATE | CMD_REMOTE, "[class | command]", "Show available commands", "This displays all commands. If a class is specified, all commands in that class are shown. If a command is specified, its usage and long description are shown.");
	RegisterCommand(CMD_LISTOPS, "!listops", CORE_NAME, 1, CMD_PRIVATE | CMD_REMOTE, NULL, "List bot ops", "List bot ops at or below your access level");
}
示例#30
0
BOOL CGSProcessor::Init()
{
    RegisterCommand(GSNS_PLAYER_DEFAULT_NTF, CGSProcessor::OnPlayerDefaultNTF);
    return TRUE;
}