/** * @brief Ensures client-side prediction has the current collision model at its * disposal. */ void Cl_UpdatePrediction(void) { // ensure the world model is loaded if (!Com_WasInit(QUETOO_SERVER) || cl.demo_server || !Cm_NumModels()) { int64_t bs; const char *bsp_name = cl.config_strings[CS_MODELS]; const int64_t bsp_size = strtoll(cl.config_strings[CS_BSP_SIZE], NULL, 10); Cm_LoadBspModel(bsp_name, &bs); if (bs != bsp_size) { Com_Error(ERROR_DROP, "Local map version differs from server: " "%" PRId64 " != %" PRId64 "\n", bs, bsp_size); } } // load the BSP models for prediction as well for (uint16_t i = 1; i < MAX_MODELS; i++) { const char *s = cl.config_strings[CS_MODELS + i]; if (*s == '*') { cl.cm_models[i] = Cm_Model(cl.config_strings[CS_MODELS + i]); } else { cl.cm_models[i] = NULL; } } }
/* * @brief Loads the map or demo file and populates the server-controlled "config * strings." We hand off the entity string to the game module, which will * load the rest. */ static void Sv_LoadMedia(const char *server, sv_state_t state) { int32_t i, map_size; strcpy(sv.name, server); strcpy(sv.config_strings[CS_NAME], server); if (state == SV_ACTIVE_DEMO) { // loading a demo sv.models[0] = Cm_LoadBsp(NULL, &map_size); sv.demo_file = Fs_OpenRead(va("demos/%s.dem", sv.name)); svs.spawn_count = 0; Com_Print(" Loaded demo %s.\n", sv.name); } else { // loading a map g_snprintf(sv.config_strings[CS_MODELS], MAX_QPATH, "maps/%s.bsp", sv.name); sv.models[0] = Cm_LoadBsp(sv.config_strings[CS_MODELS], &map_size); const char *dir = Fs_RealDir(sv.config_strings[CS_MODELS]); if (g_str_has_suffix(dir, ".zip")) { g_strlcpy(sv.config_strings[CS_ZIP], Basename(dir), MAX_QPATH); } for (i = 1; i < Cm_NumModels(); i++) { char *s = sv.config_strings[CS_MODELS + i]; g_snprintf(s, MAX_QPATH, "*%d", i); sv.models[i] = Cm_Model(s); } sv.state = SV_LOADING; Sv_InitWorld(); svs.game->SpawnEntities(sv.name, Cm_EntityString()); Sv_CreateBaseline(); Com_Print(" Loaded map %s, %d entities.\n", sv.name, svs.game->num_edicts); } g_snprintf(sv.config_strings[CS_BSP_SIZE], MAX_QPATH, "%i", map_size); Cvar_FullSet("map_name", sv.name, CVAR_SERVER_INFO | CVAR_NO_SET); }