void setup(void) { // Initialize Sega VDP VDP_init(); // Configure the screen with to 40 columns VDP_setScreenWidth320(); // Configure background planes to be 64 x 32 cells VDP_setPlanSize(64,32); // Initialize column text output (DMA graphic tiles) col_init(); // Disable interrupts during configuration SYS_disableInts(); // Allow all three interrupts SYS_setInterruptMaskLevel(0); // Set pointers to interrupt service routines SYS_setVIntCallback((_voidCallback *)v_int); SYS_setHIntCallback((_voidCallback *)h_int); // Now we can enable interrupts SYS_enableInts(); // Configure the screen with to 40 columns VDP_setScreenWidth320(); // Configure background planes to be 64 x 32 cells VDP_setPlanSize(64,32); }
void GAMECLIENT::on_connected() { layers_init(); col_init(); render_tilemap_generate_skip(); for(int i = 0; i < all.num; i++) { all.components[i]->on_mapload(); all.components[i]->on_reset(); } SERVER_INFO current_server_info; client_serverinfo(¤t_server_info); servermode = SERVERMODE_PURE; // send the inital info send_info(true); freeview = true; spectate_cid = -1; last_game_over = false; last_warmup = false; last_flag_carrier[0] = -1; last_flag_carrier[1] = -1; }
void mods_init() { //if(!data) /* only load once */ //data = load_data_from_memory(internal_data); for(int i = 0; i < NUM_NETOBJTYPES; i++) snap_set_staticsize(i, netobj_get_size(i)); layers_init(); col_init(); game.controller = new GAMECONTROLLER_BALL; MAPITEM_LAYER_TILEMAP *tmap = layers_game_layer(); TILE *tiles = (TILE *)map_get_data(tmap->data); for(int y = 0; y < tmap->height; y++) { for(int x = 0; x < tmap->width; x++) { int index = tiles[y*tmap->width+x].index; if(index >= ENTITY_OFFSET) { vec2 pos(x*32.0f+16.0f, y*32.0f+16.0f); game.controller->on_entity(index-ENTITY_OFFSET, pos); } } } //game.world.insert_entity(game.controller); #ifdef CONF_DEBUG if(config.dbg_dummies) { for(int i = 0; i < config.dbg_dummies ; i++) { mods_connected(MAX_CLIENTS-i-1); mods_client_enter(MAX_CLIENTS-i-1); if(game.controller->is_teamplay()) game.players[MAX_CLIENTS-i-1]->team = i&1; } } #endif }
void GAMECLIENT::on_connected() { layers_init(); col_init(); render_tilemap_generate_skip(); for(int i = 0; i < all.num; i++) { all.components[i]->on_mapload(); all.components[i]->on_reset(); } SERVER_INFO current_server_info; client_serverinfo(¤t_server_info); servermode = SERVERMODE_PURE; // send the inital info send_info(true); }
/** * Pivot the rows, creating a new resultset * * Call dbpivot() immediately after dbresults(). It calls dbnextrow() as long as * it returns REG_ROW, transforming the results into a cross-tab report. * dbpivot() modifies the metadata such that DB-Library can be used tranparently: * retrieve the rows as usual with dbnumcols(), dbnextrow(), etc. * * @dbproc, our old friend * @nkeys the number of left-edge columns to group by * @keys an array of left-edge columns to group by * @ncols the number of top-edge columns to group by * @cols an array of top-edge columns to group by * @func the aggregation function to use * @val the number of the column to which @func is applied * * @returns the return code from the final call to dbnextrow(). * Success is normally indicated by NO_MORE_ROWS. */ RETCODE dbpivot(DBPROCESS *dbproc, int nkeys, int *keys, int ncols, int *cols, DBPIVOT_FUNC func, int val) { enum { logalot = 1 }; struct pivot_t P, *pp; struct agg_t input, *pout = NULL; struct key_t *pacross; struct metadata_t *metadata, *pmeta; size_t i, nmeta = 0; tdsdump_log(TDS_DBG_FUNC, "dbpivot(%p, %d,%p, %d,%p, %p, %d)\n", dbproc, nkeys, keys, ncols, cols, func, val); if (logalot) { char buffer[1024] = {'\0'}, *s = buffer; const static char *names[2] = { "\tkeys (down)", "\n\tcols (across)" }; int *p = keys, *pend = p + nkeys; for (i=0; i < 2; i++) { const char *sep = ""; s += sprintf(s, "%s: ", names[i]); for ( ; p < pend; p++) { s += sprintf(s, "%s%d", sep, *p); sep = ", "; } p = cols; pend = p + ncols; assert(s < buffer + sizeof(buffer)); } tdsdump_log(TDS_DBG_FUNC, "%s\n", buffer); } memset(&input, 0, sizeof(input)); P.dbproc = dbproc; if ((pp = tds_find(&P, pivots, npivots, sizeof(*pivots), pivot_key_equal)) == NULL ) { pp = realloc(pivots, (1 + npivots) * sizeof(*pivots)); if (!pp) return FAIL; pivots = pp; pp += npivots++; } else { agg_free(pp->output); key_free(pp->across); } memset(pp, 0, sizeof(*pp)); if ((input.row_key.keys = calloc(nkeys, sizeof(*input.row_key.keys))) == NULL) return FAIL; input.row_key.nkeys = nkeys; for (i=0; i < nkeys; i++) { int type = dbcoltype(dbproc, keys[i]); int len = dbcollen(dbproc, keys[i]); assert(type && len); col_init(input.row_key.keys+i, type, len); if (FAIL == dbbind(dbproc, keys[i], bind_type(type), input.row_key.keys[i].len, col_buffer(input.row_key.keys+i))) return FAIL; if (FAIL == dbnullbind(dbproc, keys[i], &input.row_key.keys[i].null_indicator)) return FAIL; } if ((input.col_key.keys = calloc(ncols, sizeof(*input.col_key.keys))) == NULL) return FAIL; input.col_key.nkeys = ncols; for (i=0; i < ncols; i++) { int type = dbcoltype(dbproc, cols[i]); int len = dbcollen(dbproc, cols[i]); assert(type && len); col_init(input.col_key.keys+i, type, len); if (FAIL == dbbind(dbproc, cols[i], bind_type(type), input.col_key.keys[i].len, col_buffer(input.col_key.keys+i))) return FAIL; if (FAIL == dbnullbind(dbproc, cols[i], &input.col_key.keys[i].null_indicator)) return FAIL; } /* value */ { int type = dbcoltype(dbproc, val); int len = dbcollen(dbproc, val); assert(type && len); col_init(&input.value, type, len); if (FAIL == dbbind(dbproc, val, bind_type(type), input.value.len, col_buffer(&input.value))) return FAIL; if (FAIL == dbnullbind(dbproc, val, &input.value.null_indicator)) return FAIL; } while ((pp->status = dbnextrow(dbproc)) == REG_ROW) { /* add to unique list of crosstab columns */ if ((pacross = tds_find(&input.col_key, pp->across, pp->nacross, sizeof(*pp->across), key_equal)) == NULL ) { pacross = realloc(pp->across, (1 + pp->nacross) * sizeof(*pp->across)); if (!pacross) return FAIL; pp->across = pacross; pacross += pp->nacross++; key_cpy(pacross, &input.col_key); } assert(pp->across); if ((pout = tds_find(&input, pp->output, pp->nout, sizeof(*pp->output), agg_equal)) == NULL ) { pout = realloc(pp->output, (1 + pp->nout) * sizeof(*pp->output)); if (!pout) return FAIL; pp->output = pout; pout += pp->nout++; if ((pout->row_key.keys = calloc(input.row_key.nkeys, sizeof(*pout->row_key.keys))) == NULL) return FAIL; key_cpy(&pout->row_key, &input.row_key); if ((pout->col_key.keys = calloc(input.col_key.nkeys, sizeof(*pout->col_key.keys))) == NULL) return FAIL; key_cpy(&pout->col_key, &input.col_key); col_init(&pout->value, input.value.type, input.value.len); } func(&pout->value, &input.value); } /* Mark this proc as pivoted, so that dbnextrow() sees it when the application calls it */ pp->dbproc = dbproc; pp->dbresults_state = dbproc->dbresults_state; dbproc->dbresults_state = pp->output < pout? _DB_RES_RESULTSET_ROWS : _DB_RES_RESULTSET_EMPTY; /* * Initialize new metadata */ nmeta = input.row_key.nkeys + pp->nacross; metadata = calloc(nmeta, sizeof(*metadata)); assert(pp->across || pp->nacross == 0); /* key columns are passed through as-is, verbatim */ for (i=0; i < input.row_key.nkeys; i++) { assert(i < nkeys); metadata[i].name = strdup(dbcolname(dbproc, keys[i])); metadata[i].pacross = NULL; col_cpy(&metadata[i].col, input.row_key.keys+i); } /* pivoted columms are found in the "across" data */ for (i=0, pmeta = metadata + input.row_key.nkeys; i < pp->nacross; i++) { struct col_t col; col_init(&col, SYBFLT8, sizeof(double)); assert(pmeta + i < metadata + nmeta); pmeta[i].name = make_col_name(pp->across+i); assert(pp->across); pmeta[i].pacross = pp->across + i; col_cpy(&pmeta[i].col, pp->nout? &pp->output[0].value : &col); } if (!reinit_results(dbproc->tds_socket, nmeta, metadata)) { return FAIL; } return SUCCEED; #if 0 for (pp->pout=pp->output; pp->pout < pp->output + pp->nout; pp->pout++) { char name[256] = {0}; assert(pp->pout->col_key.keys[0].len < sizeof(name)); memset(name, '\0', sizeof(name)); memcpy(name, pp->pout->col_key.keys[0].s, pp->pout->col_key.keys[0].len), printf("%5d %-30s %5d\n", pp->pout->row_key.keys[0].i, name, pp->pout->value.i ); } exit(1); #endif }
void mods_init() { //if(!data) /* only load once */ //data = load_data_from_memory(internal_data); for(int i = 0; i < NUM_NETOBJTYPES; i++) snap_set_staticsize(i, netobj_get_size(i)); layers_init(); col_init(); // reset everything here //world = new GAMEWORLD; //players = new PLAYER[MAX_CLIENTS]; // select gametype if(strcmp(config.sv_gametype, "mod") == 0) game.controller = new GAMECONTROLLER_MOD; else if(strcmp(config.sv_gametype, "ctf") == 0) game.controller = new GAMECONTROLLER_CTF; else if(strcmp(config.sv_gametype, "tdm") == 0) game.controller = new GAMECONTROLLER_TDM; else if(strcmp(config.sv_gametype, "race") == 0) game.controller = new GAMECONTROLLER_RACE; else game.controller = new GAMECONTROLLER_DM; // setup core world //for(int i = 0; i < MAX_CLIENTS; i++) // game.players[i].core.world = &game.world.core; // create all entities from the game layer MAPITEM_LAYER_TILEMAP *tmap = layers_game_layer(); TILE *tiles = (TILE *)map_get_data(tmap->data); /* num_spawn_points[0] = 0; num_spawn_points[1] = 0; num_spawn_points[2] = 0; */ for(int y = 0; y < tmap->height; y++) { for(int x = 0; x < tmap->width; x++) { int index = tiles[y*tmap->width+x].index; if(index >= ENTITY_OFFSET) { game.controller->on_entity(index-ENTITY_OFFSET, x, y); } } } //game.world.insert_entity(game.controller); #ifdef CONF_DEBUG if(config.dbg_dummies) { for(int i = 0; i < config.dbg_dummies ; i++) { mods_connected(MAX_CLIENTS-i-1); mods_client_enter(MAX_CLIENTS-i-1); if(game.controller->is_teamplay()) game.players[MAX_CLIENTS-i-1]->team = i&1; } } #endif }