int game_client_init(const char *file_name) { char *back_name = "", *grad_name = ""; int i; coins = 0; status = GAME_NONE; game_client_free(file_name); /* Load SOL data. */ if (!game_base_load(file_name)) return (gd.state = 0); if (!sol_load_vary(&gd.vary, &game_base)) { game_base_free(NULL); return (gd.state = 0); } if (!sol_load_draw(&gd.draw, &gd.vary, config_get_d(CONFIG_SHADOW))) { sol_free_vary(&gd.vary); game_base_free(NULL); return (gd.state = 0); } gd.state = 1; /* Initialize game state. */ game_tilt_init(&gd.tilt); game_view_init(&gd.view); gd.jump_e = 1; gd.jump_b = 0; gd.jump_dt = 0.0f; gd.goal_e = 0; gd.goal_k = 0.0f; /* Initialize interpolation. */ game_lerp_init(&gl, &gd); /* Initialize fade. */ gd.fade_k = 1.0f; gd.fade_d = -2.0f; /* Load level info. */ version.x = 0; version.y = 0; for (i = 0; i < gd.vary.base->dc; i++) { char *k = gd.vary.base->av + gd.vary.base->dv[i].ai; char *v = gd.vary.base->av + gd.vary.base->dv[i].aj; if (strcmp(k, "back") == 0) back_name = v; if (strcmp(k, "grad") == 0) grad_name = v; if (strcmp(k, "version") == 0) sscanf(v, "%d.%d", &version.x, &version.y); } /* * If the version of the loaded map is 1, assume we have a version * match with the server. In this way 1.5.0 replays don't trigger * bogus map compatibility warnings. Post-1.5.0 replays will have * CMD_MAP override this. */ game_compat_map = version.x == 1; /* Initialize particles. */ part_reset(); /* Initialize command state. */ cmd_state_init(&cs); /* Initialize background. */ back_init(grad_name); sol_load_full(&gd.back, back_name, 0); /* Initialize lighting. */ light_reset(); return gd.state; }
int game_server_init(const char *file_name, int t, int e) { struct { int x, y; } version; int i; timer = (float) t / 100.f; timer_down = (t > 0); coins = 0; status = GAME_NONE; game_server_free(file_name); /* Load SOL data. */ if (!game_base_load(file_name)) return (server_state = 0); if (!sol_load_vary(&vary, &game_base)) { game_base_free(NULL); return (server_state = 0); } server_state = 1; /* Get SOL version. */ version.x = 0; version.y = 0; for (i = 0; i < vary.base->dc; i++) { char *k = vary.base->av + vary.base->dv[i].ai; char *v = vary.base->av + vary.base->dv[i].aj; if (strcmp(k, "version") == 0) sscanf(v, "%d.%d", &version.x, &version.y); } input_init(); game_tilt_init(&tilt); /* Initialize jump and goal states. */ jump_e = 1; jump_b = 0; goal_e = e ? 1 : 0; /* Initialize the view (and put it at the ball). */ game_view_fly(&view, &vary, 0.0f); view_k = 1.0f; view_time = 0.0f; view_fade = 0.0f; /* Initialize ball size tracking. */ got_orig = 0; grow = 0; /* Initialize simulation. */ sol_init_sim(&vary); sol_cmd_enq_func(game_proxy_enq); /* Send initial update. */ game_cmd_map(file_name, version.x, version.y); game_cmd_ups(); game_cmd_timer(); if (goal_e) game_cmd_goalopen(); game_cmd_init_balls(); game_cmd_init_items(); game_cmd_updview(); game_cmd_eou(); /* Reset lockstep state. */ lockstep_clr(&server_step); return server_state; }