Beispiel #1
0
void sec_crypto_dump (unsigned handle)
{
	Entity_t	*p = entity_ptr (handle);
	Participant_t	*pp;
	LocalEndpoint_t	*ep;
	CryptoData_t	*dp;
	unsigned	ch;

	if (!p) {
		dbg_printf ("Entity not found!\r\n");
		return;
	}
	switch (entity_type (p)) {
		case ET_PARTICIPANT:
			pp = (Participant_t *) p;
			ch = pp->p_crypto;
			break;
		case ET_WRITER:
		case ET_READER:
			if ((p->flags & EF_LOCAL) != 0) {
				ep = (LocalEndpoint_t *) p;
				ch = ep->crypto;
			}
			else if (entity_type (p) == ET_WRITER)
				ch = rtps_peer_writer_crypto_get (NULL, 
							(DiscoveredWriter_t *) p);
			else
				ch = rtps_peer_reader_crypto_get (NULL, 
							(DiscoveredReader_t *) p);
			break;
		default:
			dbg_printf ("Invalid entity type!\r\n");
			return;
	}
	if (!ch) {
		dbg_printf ("No associated crypto context.\r\n");
		return;
	}
	dp = crypto_lookup (ch);
	if (!dp) {
		dbg_printf ("Crypto context deleted.\r\n");
		return;
	}
	dp->plugin->dump (dp->plugin, dp, p);
}
Beispiel #2
0
static int subscriber_notify_reader (Skiplist_t *list, void *node, void *args)
{
	Endpoint_t		*ep, **epp = (Endpoint_t **) node;
	Subscriber_t		*sp = (Subscriber_t *) args;
	Reader_t		*rp;

	ARG_NOT_USED (list)

	ep = *epp;
	if (!entity_reader (entity_type (&ep->entity)) || ep->u.subscriber != sp)
		return (1);

	rp = (Reader_t *) ep;
	if (dcps_data_available_listener (rp) &&
	    (rp->r_status & DDS_DATA_AVAILABLE_STATUS) != 0)
		dds_notify (NSC_DCPS, (Entity_t *) rp, NT_DATA_AVAILABLE);

	else if (rp->r_conditions)
		dcps_waitset_wakeup (rp, rp->r_conditions, &sp->domain->lock);

	return (1);
}
Beispiel #3
0
static int subscriber_get_reader (Skiplist_t *list, void *node, void *args)
{
	Endpoint_t		*ep, **epp = (Endpoint_t **) node;
	SubGReaders_t		*sp = (SubGReaders_t *) args;
	Reader_t		*rp;

	ARG_NOT_USED (list)

	ep = *epp;
	if (!entity_reader (entity_type (&ep->entity)) || ep->u.subscriber != sp->sp)
		return (1);

	rp = (Reader_t *) ep;
	if (!hc_avail (rp->r_cache, sp->skip))
		return (1);

	if (dds_seq_append (sp->rseq, (DDS_DataReader *) &rp)) {
		sp->ret = DDS_RETCODE_OUT_OF_RESOURCES;
		return (0);
	}
	return (1);
}
Beispiel #4
0
void weapon_collide(Entity *ent, cpArbiter *arb) {
    cpBody *body = entity_body(ent);
    cpBody *other = physics_arbiter_get_other(body, arb);
    Entity *other_ent = cpBodyGetUserData(other);

    //only damage players
    if (!entity_valid(other_ent) || entity_type(other_ent) != &PlayerEntity) {
        return;
    }
    //only damage enemies
    if (entity_owner(ent) != connection_get_user_id()
        || entity_owner(other_ent) == connection_get_user_id()) {
        return;
    }

    float speed = cpvlength(cpBodyGetVelocity(body));
    if (speed < WEAPON_HURT_THRESHOLD) {
        return;
    }

    player_hurt(entity_owner(other_ent), WEAPON_DAMAGE * speed, entity_owner(ent));
}
Beispiel #5
0
static int ep_dump_fct (Skiplist_t *list, void *node, void *arg)
{
	LocalEndpoint_t	*ep, **epp = (LocalEndpoint_t **) node;
	DomainId_t	*dip = (DomainId_t *) arg;
	int		n;

	ARG_NOT_USED (list)

	ep = *epp;
	dbg_printf ("    %u/%02x%02x%02x-%02x %c{%u}\t",
			*dip,
			ep->ep.entity_id.id [0], 
			ep->ep.entity_id.id [1],
			ep->ep.entity_id.id [2],
			ep->ep.entity_id.id [3],
			entity_writer (entity_type (&ep->ep.entity)) ? 'W' : 'R',
			ep->ep.entity.handle);
	dbg_printf ("%u", hc_total_changes (ep->cache));
	if ((n = hc_total_instances (ep->cache)) >= 0)
		dbg_printf ("/%d", n);
	dbg_printf ("\t%s/%s\r\n", str_ptr (ep->ep.topic->name),
				   str_ptr (ep->ep.topic->type->type_name));
	return (1);
}
Beispiel #6
0
/* Preload images for entities that could be found on this map and gamemode.
   This was basically cut & paste from bits of ../server/sv_map.c */
void preload_entities(char *filename, int gamemode)
{
    char buf[MAXLINE], name[32], *line;
    ent_type_t *et;
    FILE *file;
    int entity_section, i, skipline;

    /* Open the map file */
    if( !(file = open_data_file("maps", filename) ) ) {
	printf("%s: Couldn't open %s\n", __FILE__, filename);
	return;
    }

    if( !ent_img_loaded[client.entity_type] ) { /* Load clients entity image */
	if( (et = entity_type(client.entity_type)) == NULL )
	    return;
	image(entity_type_animation(et, ALIVE)->pixmap, MASKED);
	ent_img_loaded[client.entity_type] = 1;
    }

    /* Scan map for entities that will be loaded */
    entity_section = 0; /* Found section yet? */
    while( !feof(file) ) {
	if( !fgets(buf, MAXLINE, file) )
	    break;
	CHOMP(buf);
	if( buf[0] == '#' || buf[0] == '\0' )
	    continue; /* skip line */
	if( entity_section ) {
	    line = buf;
	    skipline = 0;
	    /* check for gamemode specific line prefix characters */
	    for(i=0 ; i<NUM_GAME_MODES ; i++ ) {
		if( buf[0] == gamemodechar[i] ) {
		    if( gamemode == i )
			line = buf + 1;
		    else
			skipline = 1;
		}
	    }

	    if( skipline )
		continue; /* Not in our mode */

	    if( sscanf(line, "%s", name) && strcasecmp(name, "SPAWN") != 0 ) {
		for( i=0 ; i < num_entity_types ; i++ ) {
		    if( (et = entity_type(i)) == NULL )
			continue;
		    if( !ent_img_loaded[i] && !strcasecmp( et->name, name ) ) {
			ent_img_loaded[i] = 1;
			image(entity_type_animation(et,ALIVE)->pixmap, MASKED);
		    }
		}
	    }
	} else if( !strcasecmp("ENTITY", buf) )
	    entity_section = 1;
    }

    fclose(file);

}