Exemple #1
0
void advance_to_next_level( game_state_t* GS )
{
	int i, j, k;

	// Reset formations
	for( i = 0 ; i < MAX_FORMATIONS ; i++ ) {

		GS->formations[i].nr_ranks = 0;

		for( j = 0 ; j < MAX_FORMATION_RANKS ; j++ ) {

			GS->formations[i].ranks[j].occupied_by = NULL;

			for( k = 0 ; k < NR_FILLFROM_RANKS ; k++ ) {
				GS->formations[i].ranks[j].fillfrom_index[k] = -1;
			}
		}
	}

	//...! record score

	//...GS->shots_fired	= 0;
	//...GS->shots_missed	= 0;
	//...GS->best_resource	= 0;

	++GS->current_level;

#if TEST_LEVELS
	int L = GS->current_level;
	formation_t* f = &(GS->formations[0]);
	f->nr_ranks = create_formation( GS, f, TIER_1, L, 0, 1 );
	create_formation_enemies( GS, f, TIER_1, L*L );
#elif LEVEL_DESIGN_V2
	int L = GS->current_level;
	int formation_index = 0;
	create_wave( GS, L, &formation_index );
	create_wave( GS, L+1, &formation_index );
#else
	create_units( GS );

#endif
}
Exemple #2
0
trans_block_t* null_fec_encode_src_block(char *data, unsigned long long len,
        unsigned int sbn, unsigned short es_len) {

    trans_block_t *tr_block;		/* transport block struct */
    trans_unit_t *tr_unit;			/* transport unit struct */
    unsigned int nb_of_units;		/* number of units */
    unsigned int i;					/* loop variables */
    unsigned long long data_left;
    char *ptr;						/* pointer to left data */

    data_left = len;

    nb_of_units = (unsigned int)ceil((double)(unsigned int)len / (double)es_len);

    tr_block = create_block();

    if(tr_block == NULL) {
        return tr_block;
    }

    tr_unit = create_units(nb_of_units);

    if(tr_unit == NULL) {
        free(tr_block);
        return NULL;
    }

    ptr = data;

    tr_block->unit_list = tr_unit;
    tr_block->sbn = sbn;
    tr_block->n = nb_of_units;
    tr_block->k = nb_of_units;

    for(i = 0; i < nb_of_units; i++) {
        tr_unit->esi = i;
        tr_unit->len = data_left < es_len ? (unsigned short)data_left : es_len; /*min(eslen, data_left);*/

        /* Alloc memory for TU data */
        if(!(tr_unit->data = (char*)calloc(tr_unit->len, sizeof(char)))) {
            printf("Could not alloc memory for transport unit's data!\n");

            tr_unit = tr_block->unit_list;

            while(tr_unit != NULL) {
                free(tr_unit->data);
                tr_unit++;
            }

            free(tr_block->unit_list);
            free(tr_block);
            return NULL;
        }

        memcpy(tr_unit->data, ptr, tr_unit->len);

        ptr += tr_unit->len;
        data_left -= tr_unit->len;
        tr_unit++;
    }

    return tr_block;
}