コード例 #1
0
ファイル: sv_init.c プロジェクト: devilx4/quake2world
/*
 * @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);
}
コード例 #2
0
ファイル: r_model.c プロジェクト: darkshade9/aq2w
/*
 * R_BeginLoading
 *
 * Loads the specified level after resetting all model data.
 */
void R_BeginLoading(const char *bsp_name, int bsp_size) {

	R_FreeModels(); // free all models

	// load bsp for collision detection (prediction)
	if (!Com_WasInit(Q2W_SERVER)) {
		int bs;

		Cm_LoadBsp(bsp_name, &bs);

		if (bs != bsp_size) {
			Com_Error(ERR_DROP, "Local map version differs from server: "
				"%i != %i.", bs, bsp_size);
		}
	}

	// then load materials
	R_LoadMaterials(bsp_name);

	// finally load the bsp for rendering (surface arrays)
	r_world_model = R_LoadModel(bsp_name);
}