Пример #1
0
OSRM_impl::OSRM_impl(libosrm_config &lib_config)
{
    if (lib_config.use_shared_memory)
    {
        barrier = osrm::make_unique<SharedBarriers>();
        query_data_facade = new SharedDataFacade<QueryEdge::EdgeData>();
    }
    else
    {
        // populate base path
        populate_base_path(lib_config.server_paths);
        query_data_facade = new InternalDataFacade<QueryEdge::EdgeData>(lib_config.server_paths);
    }

    // The following plugins handle all requests.
    RegisterPlugin(new DistanceTablePlugin<BaseDataFacade<QueryEdge::EdgeData>>(
        query_data_facade, lib_config.max_locations_distance_table));
    RegisterPlugin(new HelloWorldPlugin());
    RegisterPlugin(new LocatePlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
    RegisterPlugin(new MultiTargetPlugin<BaseDataFacade<QueryEdge::EdgeData>, true>(query_data_facade));
    RegisterPlugin(new MultiTargetPlugin<BaseDataFacade<QueryEdge::EdgeData>, false>(query_data_facade));
    RegisterPlugin(new NearestPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
    RegisterPlugin(new MapMatchingPlugin<BaseDataFacade<QueryEdge::EdgeData>>(
        query_data_facade, lib_config.max_locations_map_matching));
    RegisterPlugin(new TimestampPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
    RegisterPlugin(new ViaRoutePlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
    RegisterPlugin(new RoundTripPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
}
Пример #2
0
bool NyquistEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm)
{
   // Autoregister effects that we "think" are ones that have been shipped with
   // Audacity.  A little simplistic, but it should suffice for now.
   wxArrayString pathList = NyquistEffect::GetNyquistSearchPath();
   wxArrayString files;

   if (!pm.IsPluginRegistered(NYQUIST_PROMPT_ID))
   {
      RegisterPlugin(pm, NYQUIST_PROMPT_ID);
   }

   for (int i = 0; i < WXSIZEOF(kShippedEffects); i++)
   {
      files.Clear();
      pm.FindFilesInPathList(kShippedEffects[i], pathList, files);
      for (size_t j = 0, cnt = files.GetCount(); j < cnt; j++)
      {
         if (!pm.IsPluginRegistered(files[j]))
         {
            RegisterPlugin(pm, files[j]);
         }
      }
   }

   // We still want to be called during the normal registration process
   return false;
}
Пример #3
0
PLUGIN_INIT()
{
    // register our new plugin

    RegisterPlugin(PLUGIN_NAME, CreatePlugin, DestroyPlugin);
    return 0;
}
Пример #4
0
LWRESULT Cx_PluginLoader::RegisterFrameWork(Ix_Module* pModule)
{
	ASSERT_CHECK_RET(LWDP_MODULE_LOG, LWDP_PARAMETER_ERROR, (pModule), "Cx_PluginLoader::RegisterFrameWork Para Error");

    int32_ existIndex = GetPluginIndex(pModule->GetModuleMODID());

    if (existIndex >= 0 && m_modules[existIndex]->modid.empty())
    {
        return LWDP_PLUGINMGR_MODULE_ALREADY_LOAD;
    }

	LWRESULT stat = LWDP_ERROR;
    if (pModule)
    {	
    	pModule->Initialize(this, 0);
        if(RegisterPlugin(pModule) == LWDP_OK)
        {
            int32_ moduleIndex = FindModule(pModule->GetModuleMODID());

        	ASSERT_CHECK_RET(LWDP_MODULE_LOG, LWDP_PLUGINMGR_MODULE_INDEX_ERROR, (moduleIndex >= 0), "Module Index Error");        
        	ASSERT_CHECK_RET(LWDP_MODULE_LOG, LWDP_PLUGINMGR_MODULE_INDEX_ERROR, (existIndex < 0 || existIndex == moduleIndex), "Module Index Error");        
        }
    }
    else
    {
    	return LWDP_PLUGINMGR_LOADMODULE_ERROR;
    }

    return LWDP_OK;
}
Пример #5
0
PLUGIN_INIT()
{
    // register our new plugin
    std::cout << "PLUGIN_INIT" << std::endl;
    RegisterPlugin(PLUGIN_NAME, CreatePlugin, DestroyPlugin);
    return 0;
}
Пример #6
0
/**
 * Initialize respond2 plugin
 *
 * @return void function
 */
void SetupRespond2(void)
{
    RegisterPlugin("resp", Respond2Init);
    GenRandIPID(&config);  /* generate random IP ID cache */

    return;
}
Пример #7
0
/****************************************************************************
 * 
 * Function: SetupTemplate()
 *
 * Purpose: Generic detection engine plugin template.  Registers the
 *          configuration function and links it to a rule keyword.  This is
 *          the function that gets called from InitPlugins in plugbase.c.
 *
 * Arguments: None.
 *
 * Returns: void function
 *
 ****************************************************************************/
void SetupTemplate()
{
    /* map the keyword to an initialization/processing function */
    RegisterPlugin("keyword", TemplateInit);

    DebugMessage(DEBUG_PLUGIN,"Plugin: TemplateName Setup\n");
}
Пример #8
0
 void RegisterArchiveContainers(ArchivePluginsRegistrator& registrator)
 {
   for (const ContainerPluginDescription* it = UNARCHIVES; it != boost::end(UNARCHIVES); ++it)
   {
     RegisterPlugin(*it, registrator);
   }
 }
Пример #9
0
/****************************************************************************
 * 
 * Function: SetupTcpAckCheck()
 *
 * Purpose: Link the ack keyword to the initialization function
 *
 * Arguments: None.
 *
 * Returns: void function
 *
 ****************************************************************************/
void SetupTcpAckCheck()
{
    /* map the keyword to an initialization/processing function */
    RegisterPlugin("ack", TcpAckCheckInit);

#ifdef DEBUG
    printf("Plugin: TcpAckCheck Initialized\n");
#endif
}
Пример #10
0
/****************************************************************************
 * 
 * Function: SetupReferenceCheck()
 *
 * Purpose: Registers our keywords
 *
 * Arguments: None.
 *
 * Returns: void function
 *
 ****************************************************************************/
void SetupReference()
{
    /* map the keyword to an initialization/processing function */
    RegisterPlugin("reference", ReferenceInit);

#ifdef DEBUG
    printf("Plugin: Reference Setup\n");
#endif
}
Пример #11
0
/****************************************************************************
 * 
 * Function: SetupIcmpIdCheck()
 *
 * Purpose: Registers the configuration function and links it to a rule
 *          keyword.  This is the function that gets called from InitPlugins
 *          in plugbase.c.
 *
 * Arguments: None.
 *
 * Returns: void function
 *
 ****************************************************************************/
void SetupIcmpIdCheck()
{
    /* map the keyword to an initialization/processing function */
    RegisterPlugin("icmp_id", IcmpIdCheckInit);

#ifdef DEBUG
    printf("Plugin: IcmpIdCheck Setup\n");
#endif
}
Пример #12
0
/****************************************************************************
 * 
 * Function: SetupSession()
 *
 * Purpose: Init the session plugin module.
 *
 * Arguments: None.
 *
 * Returns: void function
 *
 ****************************************************************************/
void SetupSession()
{
    /* map the keyword to an initialization/processing function */
    RegisterPlugin("session", SessionInit);

#ifdef DEBUG
    printf("Plugin: Session Setup\n");
#endif
}
Пример #13
0
//! \fn				: DllRegisterServer
//! \brief			: Registers plugin (exported function)
//! \return			: HRESULT
//! \param          : void
HRESULT CALLBACK DllRegisterServer(void)
{
	KLSTD_TRACE0 ( MCOU_TL_INFO, L"DllRegisterServer called\n" );
	TCHAR szThisModuleFileName [MAX_PATH];
	if (MCOU::GetThisModuleFileName (szThisModuleFileName, MAX_PATH) == 0)
		return E_FAIL;

	return RegisterPlugin (szThisModuleFileName);
}
void ModuleFactory::RegisterAllPlugins() {
    TRACE("ModuleFactory::RegisterAllPlugins - Start\n");
    DIR* dir;
    struct dirent* entry;
    dir = opendir("./plugins/");
    while ((entry = readdir(dir)) != NULL) {  
        TRACE( "ModuleFactory::RegisterAllPlugins - Wczytuje: %s\n", entry->d_name );
        RegisterPlugin (entry->d_name);
    }
    TRACE("ModuleFactory::RegisterAllPlugins - Koniec\n" );
}
/****************************************************************************
 * 
 * Function: SetupFlowBits()
 *
 * Purpose: Generic detection engine plugin template.  Registers the
 *          configuration function and links it to a rule keyword.  This is
 *          the function that gets called from InitPlugins in plugbase.c.
 *
 * Arguments: None.
 *
 * Returns: void function
 *
 * 3/4/05 - man beefed up the hash table size from 100 -> 10000
 *
 ****************************************************************************/
void SetupFlowBits()
{
    /* setup our storage hash */
    flowbits_hash = sfghash_new( 10000, 0 , 0, 0);
    if (!flowbits_hash) {
        FatalError("Could not setup flowbits hash\n");
    }

    /* map the keyword to an initialization/processing function */
    RegisterPlugin("flowbits", FlowBitsInit);

    DEBUG_WRAP(DebugMessage(DEBUG_PLUGIN, "Plugin: FlowBits Setup\n"););
Пример #16
0
bool Cx_PluginLoader::LoadPlugin(const wchar_t* filename)
{
    if (!x3InMainThread())
    {
        X3LOG_WARNING2(L"Can't load plugin in sub thread.", filename);
        return false;
    }

    CLockCount locker(&m_loading);
    int existIndex = GetPluginIndex(filename);

    if (existIndex >= 0 && m_modules[existIndex]->hdll)
    {
        if (_wcsicmp(filename, m_modules[existIndex]->filename) != 0)
        {
            X3LOG_DEBUG2(L"The plugin is already loaded.",
                filename << L", " << (m_modules[existIndex]->filename));
        }
        return false;
    }

    HMODULE hdll = x3LoadLibrary(filename);
    DWORD errcode = GetLastError();

    if (hdll)
    {
        if (RegisterPlugin(hdll))
        {
            int moduleIndex = FindModule(hdll);

            ASSERT(moduleIndex >= 0);
            ASSERT(existIndex < 0 || existIndex == moduleIndex);

            m_modules[moduleIndex]->owned = true;
#ifdef _WIN32
            DisableThreadLibraryCalls(hdll);
#endif
        }
        else
        {
            FreeLibrary(hdll);
            hdll = NULL;
        }
    }
    else if (PathFileExistsW(filename))
    {
        X3LOG_WARNING2(L"Fail to load plugin.", 
            x3::GetSystemErrorString(errcode) << L", " << filename);
    }

    return hdll != NULL;
}
Пример #17
0
OSRM::OSRM( const ServerPaths & server_paths, const bool use_shared_memory )
 :
    use_shared_memory(use_shared_memory)
{
    if( !use_shared_memory ) {
        query_data_facade = new InternalDataFacade<QueryEdge::EdgeData>(
            server_paths
        );
    } else {
        query_data_facade = new SharedDataFacade<QueryEdge::EdgeData>( );
    }

    //The following plugins handle all requests.
    RegisterPlugin(
        new HelloWorldPlugin()
    );
    RegisterPlugin(
        new LocatePlugin<BaseDataFacade<QueryEdge::EdgeData> >(
            query_data_facade
        )
    );
    RegisterPlugin(
        new NearestPlugin<BaseDataFacade<QueryEdge::EdgeData> >(
            query_data_facade
        )
    );
    RegisterPlugin(
        new TimestampPlugin<BaseDataFacade<QueryEdge::EdgeData> >(
            query_data_facade
        )
    );
    RegisterPlugin(
        new ViaRoutePlugin<BaseDataFacade<QueryEdge::EdgeData> >(
            query_data_facade
        )
    );
}
Пример #18
0
LWRESULT Cx_PluginLoader::LoadPlugin(const MODID& modid)
{
    int32_ existIndex = GetPluginIndex(modid);

    if (existIndex >= 0 && m_modules[existIndex]->modid.empty())
    {
        return LWDP_PLUGINMGR_MODULE_ALREADY_LOAD;
    }

	Cx_Interface<Ix_FwIntf> iFwIntf(CLSID_FwIntf);
	ASSERT_CHECK_RET(LWDP_MODULE_LOG, LWDP_OBJECT_POINTER_IS_NULL, !iFwIntf.IsNull(), 
		             "Cx_PluginLoader::LoadPlugin Get Object(FwIntf) Error");
	Ix_Module* pModule = iFwIntf->Api_Fw_GetModulePtr(modid);
	if(!pModule)
	{
		return LWDP_PLUGINMGR_NOT_FIND_MODULE_ENTRY;
	}

	LWRESULT stat = LWDP_ERROR;
    if (pModule)
    {
    	if((stat = CheckPlugin(pModule)) != LWDP_OK)
    	{
    		if(pModule->GetModuleInstance()) //!< 只有加载的外部模块才Unload
    		{
    			Cx_Interface<Ix_FwIntf> iFwIntf(CLSID_FwIntf);
				ASSERT_CHECK_RET(LWDP_MODULE_LOG, LWDP_OBJECT_POINTER_IS_NULL, !iFwIntf.IsNull(), 
					             "Cx_PluginLoader::LoadPlugin Get Object(FwIntf) Error");
				iFwIntf->Api_Fw_UnLoadModule(pModule->GetModuleMODID());
    		}
			return stat;
    	}
		
    	pModule->Initialize(this, 0);
        if(RegisterPlugin(pModule) == LWDP_OK)
        {
            int32_ moduleIndex = FindModule(pModule->GetModuleMODID());

        	ASSERT_CHECK_RET(LWDP_MODULE_LOG, LWDP_PLUGINMGR_MODULE_INDEX_ERROR, (moduleIndex >= 0), "Module Index Error");        
        	ASSERT_CHECK_RET(LWDP_MODULE_LOG, LWDP_PLUGINMGR_MODULE_INDEX_ERROR, (existIndex < 0 || existIndex == moduleIndex), "Module Index Error");        
        }
    }
    else
    {
    	return LWDP_PLUGINMGR_LOADMODULE_ERROR;
    }

    return LWDP_OK;
}
Пример #19
0
bool BuiltinEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm)
{
   for (size_t i = 0; i < WXSIZEOF(kEffectNames); i++)
   {
      wxString path(wxString(BUILTIN_EFFECT_PREFIX) + kEffectNames[i]);

      if (!pm.IsPluginRegistered(path))
      {
         RegisterPlugin(pm, path);
      }
   }

   // We still want to be called during the normal registration process
   return false;
}
Пример #20
0
void
GameEvent(CORE_DATA *cd)
{
	switch (cd->event) {
	case EVENT_START:
		RegisterPlugin(OPENCORE_VERSION, CORE_NAME, "cycad", OPENCORE_VERSION, __DATE__, __TIME__, "core handler", 0, 0);
		register_commands();
		break;
	case EVENT_COMMAND:
		switch (cd->cmd_id) {
		case CMD_DIE: cmd_die(cd); break;
		case CMD_STOPBOT: cmd_stopbot(cd); break;
		case CMD_GETFILE: cmd_getfile(cd); break;
		case CMD_PUTFILE: cmd_putfile(cd); break;
		case CMD_LISTBOTS: cmd_listbots(cd); break;
		case CMD_TYPES: cmd_types(cd); break;
		case CMD_LOADTYPES: cmd_loadtypes(cd); break;
		case CMD_LOG: cmd_log(cd); break;
		case CMD_CMDLOG: cmd_cmdlog(cd); break;
		case CMD_ABOUT: cmd_about(cd); break;
		case CMD_INSLIB: cmd_inslib(cd); break;
		case CMD_RMLIB: cmd_rmlib(cd); break;
		case CMD_HELP: cmd_help(cd); break;
		case CMD_SYSINFO: cmd_sysinfo(cd); break;
		case CMD_LOADOPS: cmd_loadops(cd); break;
		case CMD_LISTOPS: cmd_listops(cd); break;
		case CMD_EXEC: cmd_exec(cd); break;
		case CMD_STARTBOT: cmd_startbot(cd); break;
		case CMD_GO: cmd_go(cd); break;
		default: break;
		}
		break;
	default:
		break;
	}
}
Пример #21
0
Exporter::Exporter()
{
   mMixerSpec = NULL;

   RegisterPlugin(New_ExportPCM());
   RegisterPlugin(New_ExportMP3());

#ifdef USE_LIBVORBIS
   RegisterPlugin(New_ExportOGG());
#endif

#ifdef USE_LIBFLAC
   RegisterPlugin(New_ExportFLAC());
#endif

#if USE_LIBTWOLAME
   RegisterPlugin(New_ExportMP2());
#endif

   // Command line export not available on Windows and Mac platforms
   RegisterPlugin(New_ExportCL());
}
Пример #22
0
void
GameEvent(CORE_DATA *cd)
{
	USER_DATA *ud = UD(cd);

	switch (cd->event) {
	case EVENT_START:
		RegisterPlugin(OPENCORE_VERSION, "chess", "cycad", "1.0", __DATE__, __TIME__, "A player-vs-player chess bot", sizeof(USER_DATA), 0); 
		ud = UD(cd);

		// allocate chess board
		ud->board = (BOARD)calloc(8, sizeof(PIECE*));
		for (int i = 0; i < 8; ++i) {
			ud->board[i] = (PIECE*)calloc(8, sizeof(PIECE));
		}

		BoardReset(ud, ud->board);

		// draw the board
		LvzDrawAll(ud, NULL, true);
		RegisterCommand(COMMAND_CHESSHELP, "!chesshelp", "Chess", 0, CMD_PUBLIC | CMD_PRIVATE, NULL, "Get basic chessbot information", NULL);
		RegisterCommand(COMMAND_GAMEINFO, "!gameinfo", "Chess", 0, CMD_PUBLIC | CMD_PRIVATE, NULL, "Get information about the current game", NULL);
		RegisterCommand(COMMAND_WHITE, "!white", "Chess", 0, CMD_PUBLIC | CMD_PRIVATE, NULL, "Play as White", NULL);
		RegisterCommand(COMMAND_BLACK, "!black", "Chess", 0, CMD_PUBLIC | CMD_PRIVATE, NULL, "Play as Black", NULL);
		RegisterCommand(COMMAND_MOVE, "!move", "Chess", 0, CMD_PUBLIC | CMD_PRIVATE, "<coord1>,<coord2>", "Move a chess piece", NULL);
		RegisterCommand(COMMAND_QUIT, "!quit", "Chess", 0, CMD_PUBLIC | CMD_PRIVATE, NULL, "Stop playing chess", NULL);
		break;
	case EVENT_COMMAND:
		switch (cd->cmd_id) {
			case COMMAND_CHESSHELP: CmdChessHelp(cd); break;
			case COMMAND_GAMEINFO: CmdGameInfo(cd); break;
			case COMMAND_WHITE: CmdWhite(cd); break;
			case COMMAND_BLACK: CmdBlack(cd); break;
			case COMMAND_MOVE: CmdMove(cd); break;
			case COMMAND_QUIT: CmdQuit(cd); break;
			default: assert(0); break;
		}
		break;
	case EVENT_MESSAGE:
#if 0
		// eventually handle commands in pubchat, like "b1,c3"
		if (cd->msg_type == MSG_PUBLIC &&
		    ud->in_progress &&
		    IsPlaying(cd->msg_name)) {
		}
#endif
		break;
	case EVENT_ENTER:
		LvzActivateBoard();
		LvzDrawAll(ud, cd->p1, true);
		LvzToMove(ud->to_move, cd->p1);

		if (IsPlaying(ud, cd->p1->name)) {
			// player rejoined
			ArenaMessageFmt("%s has returned to the game", cd->p1->name);
			KillTimer(ud->timer);
			ud->timer = 0;
		}
		break;
	case EVENT_LEAVE:
		// check if this player is relevant
		if (IsPlaying(ud, cd->p1->name)) {
			if (ud->in_progress && ud->timer) {
				// timer is only set when one player is already gone
				StopGame(ud, "Both players left the game");
				KillTimer(ud->timer);
				ud->timer = 0;
			} else if (ud->in_progress) {
				// someone left a game in progress
				ArenaMessageFmt("%s has left the game and has 2 minutes to return", cd->p1->name);
				ud->timer = SetTimer(2 * 60 * 1000, 0, 0);
			} else {
				// no need to wait for someone not playing
				ArenaMessageFmt("%s is no longer playing", cd->p1->name);
				UnsetPlayerName(ud, cd->p1->name);
			}
		}
		break;
	case EVENT_TIMER:
		// this game needs to be stopped due to timeout
		if (ud->in_progress && cd->timer_id == ud->timer) {
			StopGame(ud, "Player did not return to game");
			ud->timer = 0;
		} else if (cd->timer_data1) {
			uint32_t objid = (uint32_t)(intptr_t)cd->timer_data1;
			uint32_t on = (uint32_t)(intptr_t)cd->timer_data2;
			if (on) {
				PubMessageFmt("*objon %u", objid);
			} else {
				PubMessageFmt("*objoff %u", objid);
			}
		}
		break;
	case EVENT_STOP:
		// free chess board
		for (int i = 0; i < 8; ++i) {
			free(ud->board[i]);
		}
		free(ud->board);

		// free user data
		free(cd->user_data);
		break;
	}
}
Пример #23
0
/****************************************************************************
 * 
 * Function: SetupDynamic()
 *
 * Purpose: Load it up
 *
 * Arguments: None.
 *
 * Returns: void function
 *
 ****************************************************************************/
void SetupDynamic(void)
{
    /* map the keyword to an initialization/processing function */
    RegisterPlugin("dynamic", DynamicInit);

    DEBUG_WRAP(DebugMessage(DEBUG_PLUGIN,"Plugin: Dynamic Setup\n"););
Пример #24
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;
	}
}
Пример #25
0
void SetupAsn1()
{
    /* map the keyword to an initialization/processing function */
    RegisterPlugin("asn1", Asn1Init);

    DEBUG_WRAP(DebugMessage(DEBUG_PLUGIN,"Plugin: ASN1 Setup\n"););
Пример #26
0
/****************************************************************************
 * 
 * Function: SetupIpProto()
 *
 * Purpose: Generic detection engine plugin ip_proto.  Registers the
 *          configuration function and links it to a rule keyword.  This is
 *          the function that gets called from InitPlugins in plugbase.c.
 *
 * Arguments: None.
 *
 * Returns: void function
 *
 ****************************************************************************/
void SetupIpProto(void)
{
    /* map the keyword to an initialization/processing function */
    RegisterPlugin("ip_proto", IpProtoInit);
    DEBUG_WRAP(DebugMessage(DEBUG_PLUGIN,"Plugin: IpProto Setup\n"););
Пример #27
0
 void RegisterAyContainer(ArchivePluginsRegistrator& registrator)
 {
   RegisterPlugin(AY, registrator);
 }
Пример #28
0
/****************************************************************************
 * 
 * Function: SetupByteTest()
 *
 * Purpose: Load 'er up
 *
 * Arguments: None.
 *
 * Returns: void function
 *
 ****************************************************************************/
void SetupByteTest(void)
{
    /* map the keyword to an initialization/processing function */
    RegisterPlugin("byte_test", ByteTestInit);

    DEBUG_WRAP(DebugMessage(DEBUG_PLUGIN,"Plugin: ByteTest Setup\n"););
Пример #29
0
/****************************************************************************
 * 
 * Function: SetupTcpWinCheck()
 *
 * Purpose: Associate the window keyword with TcpWinCheckInit
 *
 * Arguments: None.
 *
 * Returns: void function
 *
 ****************************************************************************/
void SetupTcpWinCheck(void)
{
    /* map the keyword to an initialization/processing function */
    RegisterPlugin("window", TcpWinCheckInit);
}
Пример #30
0
/****************************************************************************
 * 
 * Function: SetupIsDataAt()
 *
 * Purpose: Load 'er up
 *
 * Arguments: None.
 *
 * Returns: void function
 *
 ****************************************************************************/
void SetupIsDataAt(void)
{
    /* map the keyword to an initialization/processing function */
    RegisterPlugin("isdataat", IsDataAtInit);

    DEBUG_WRAP(DebugMessage(DEBUG_PLUGIN,"Plugin: IsDataAt Setup\n"););