Ejemplo n.º 1
0
/**
 * @brief Resolves references to frequently accessed media.
 */
static void G_InitMedia(void) {
	uint16_t i;

	memset(&g_media, 0, sizeof(g_media));

	// preload items/set item media ptrs
	G_InitItems();

	// precache sexed sounds; clients will load these when a new player model
	// gets loaded.
	gi.SoundIndex("*gurp_1");
	gi.SoundIndex("*drown_1");
	gi.SoundIndex("*fall_1");
	gi.SoundIndex("*fall_2");
	gi.SoundIndex("*land_1");
	gi.SoundIndex("*jump_1");
	gi.SoundIndex("*jump_2");
	gi.SoundIndex("*jump_3");
	gi.SoundIndex("*jump_4");
	gi.SoundIndex("*jump_5");
	gi.SoundIndex("*sizzle_1");
	gi.SoundIndex("*death_1");
	gi.SoundIndex("*gasp_1");
	gi.SoundIndex("*pain25_1");
	gi.SoundIndex("*pain50_1");
	gi.SoundIndex("*pain75_1");
	gi.SoundIndex("*pain100_1");

	g_media.models.grenade = gi.ModelIndex("models/objects/grenade/tris");
	g_media.models.rocket = gi.ModelIndex("models/objects/rocket/tris");
	g_media.models.hook = gi.ModelIndex("models/objects/grapplehook/tris");
	g_media.models.fireball = gi.ModelIndex("models/objects/fireball/tris");

	g_media.sounds.bfg_hit = gi.SoundIndex("weapons/bfg/hit");
	g_media.sounds.bfg_prime = gi.SoundIndex("weapons/bfg/prime");
	g_media.sounds.grenade_hit = gi.SoundIndex("objects/grenade/hit");
	g_media.sounds.grenade_throw = gi.SoundIndex("weapons/handgrenades/hg_throw");
	g_media.sounds.rocket_fly = gi.SoundIndex("objects/rocket/fly");
	g_media.sounds.lightning_fly = gi.SoundIndex("weapons/lightning/fly");
	g_media.sounds.quad_attack = gi.SoundIndex("quad/attack");
	g_media.sounds.quad_expire = gi.SoundIndex("quad/expire");

	g_media.sounds.hook_fire = gi.SoundIndex("objects/hook/fire");
	g_media.sounds.hook_fly = gi.SoundIndex("objects/hook/fly");
	g_media.sounds.hook_hit = gi.SoundIndex("objects/hook/hit");
	g_media.sounds.hook_pull = gi.SoundIndex("objects/hook/pull");
	g_media.sounds.hook_detach = gi.SoundIndex("objects/hook/detach");
	g_media.sounds.hook_gibhit = gi.SoundIndex("objects/hook/gibhit");

	g_media.sounds.teleport = gi.SoundIndex("world/teleport");

	g_media.sounds.water_in = gi.SoundIndex("world/water_in");
	g_media.sounds.water_out = gi.SoundIndex("world/water_out");

	g_media.sounds.weapon_no_ammo = gi.SoundIndex("weapons/common/no_ammo");
	g_media.sounds.weapon_switch = gi.SoundIndex("weapons/common/switch");

	for (i = 0; i < NUM_GIB_MODELS; i++) {
		g_media.models.gibs[i] = gi.ModelIndex(va("models/gibs/gib_%i/tris", i + 1));
	}

	for (i = 0; i < NUM_GIB_SOUNDS; i++) {
		g_media.sounds.gib_hits[i] = gi.SoundIndex(va("gibs/gib_%i/hit", i + 1));
	}

	for (i = 1; i < lengthof(g_media.sounds.countdown); i++) {
		g_media.sounds.countdown[i] = gi.SoundIndex(va("world/countdown_%d", i));
	}

	g_media.sounds.roar = gi.SoundIndex("world/ominous_bwah");

	g_media.sounds.techs[TECH_HASTE] = gi.SoundIndex("tech/haste");
	g_media.sounds.techs[TECH_REGEN] = gi.SoundIndex("tech/regen");
	g_media.sounds.techs[TECH_RESIST] = gi.SoundIndex("tech/resist");
	g_media.sounds.techs[TECH_STRENGTH] = gi.SoundIndex("tech/strength");
	g_media.sounds.techs[TECH_VAMPIRE] = gi.SoundIndex("tech/vampire");

	g_media.images.health = gi.ImageIndex("pics/i_health");
}
Ejemplo n.º 2
0
/*
 * G_Init
 *
 * This will be called when the game module is first loaded.
 */
void G_Init(void) {

	gi.Print("  Game initialization...\n");

	memset(&g_game, 0, sizeof(g_game));

	gi.Cvar("game_name", GAME_NAME, CVAR_SERVER_INFO | CVAR_NO_SET, NULL);
	gi.Cvar("game_date", __DATE__, CVAR_SERVER_INFO | CVAR_NO_SET, NULL);

	g_auto_join = gi.Cvar("g_auto_join", "1", CVAR_SERVER_INFO, NULL);
	g_capture_limit = gi.Cvar("g_capture_limit", "8", CVAR_SERVER_INFO, NULL);
	g_chat_log = gi.Cvar("g_chat_log", "0", 0, NULL);
	g_cheats = gi.Cvar("g_cheats", "0", CVAR_SERVER_INFO, NULL);
	g_ctf = gi.Cvar("g_ctf", "0", CVAR_SERVER_INFO, NULL);
	g_frag_limit = gi.Cvar("g_frag_limit", "30", CVAR_SERVER_INFO, NULL);
	g_frag_log = gi.Cvar("g_frag_log", "0", 0, NULL);
	g_friendly_fire = gi.Cvar("g_friendly_fire", "1", CVAR_SERVER_INFO, NULL);
	g_gameplay = gi.Cvar("g_gameplay", "0", CVAR_SERVER_INFO, NULL);
	g_gravity = gi.Cvar("g_gravity", "800", CVAR_SERVER_INFO, NULL);
	g_match = gi.Cvar("g_match", "0", CVAR_SERVER_INFO, NULL);
	g_max_entities = gi.Cvar("g_max_entities", "1024", CVAR_LATCH, NULL);
	g_mysql = gi.Cvar("g_mysql", "0", 0, NULL);
	g_mysql_db = gi.Cvar("g_mysql_db", "quake2world", 0, NULL);
	g_mysql_host = gi.Cvar("g_mysql_host", "localhost", 0, NULL);
	g_mysql_password = gi.Cvar("g_mysql_password", "", 0, NULL);
	g_mysql_user = gi.Cvar("g_mysql_user", "quake2world", 0, NULL);
	g_player_projectile = gi.Cvar("g_player_projectile", "1", CVAR_SERVER_INFO,
			NULL);
	g_random_map = gi.Cvar("g_random_map", "0", 0, NULL);
	g_round_limit = gi.Cvar("g_round_limit", "30", CVAR_SERVER_INFO, NULL);
	g_rounds = gi.Cvar("g_rounds", "0", CVAR_SERVER_INFO, NULL);
	g_spawn_farthest = gi.Cvar("g_spawn_farthest", "0", CVAR_SERVER_INFO, NULL);
	g_teams = gi.Cvar("g_teams", "0", CVAR_SERVER_INFO, NULL);
	g_time_limit = gi.Cvar("g_time_limit", "20", CVAR_SERVER_INFO, NULL);
	g_voting = gi.Cvar("g_voting", "1", CVAR_SERVER_INFO, "Activates voting");

	password = gi.Cvar("password", "", CVAR_USER_INFO, NULL);

	sv_max_clients = gi.Cvar("sv_max_clients", "8",
			CVAR_SERVER_INFO | CVAR_LATCH, NULL);
	dedicated = gi.Cvar("dedicated", "0", CVAR_NO_SET, NULL);

	if (g_frag_log->value)
		gi.OpenFile("frag_log.log", &frag_log, FILE_APPEND);

	if (g_chat_log->value)
		gi.OpenFile("chat_log.log", &chat_log, FILE_APPEND);

#ifdef HAVE_MYSQL
	if(g_mysql->value) { //init database

		mysql = mysql_init(NULL);

		mysql_real_connect(mysql, g_mysql_host->string,
				g_mysql_user->string, g_mysql_password->string,
				g_mysql_db->string, 0, NULL, 0
		);

		if(mysql != NULL)
		gi.Print("    MySQL connection to %s/%s", g_mysql_host->string,
				g_mysql_user->string);
	}
#endif

	G_ParseMapList("maps.lst");

	G_InitItems();

	// initialize entities and clients for this game
	g_game.edicts = gi.TagMalloc(g_max_entities->integer * sizeof(g_edict_t),
			TAG_GAME);
	g_game.clients = gi.TagMalloc(sv_max_clients->integer * sizeof(g_client_t),
			TAG_GAME);

	ge.edicts = g_game.edicts;
	ge.max_edicts = g_max_entities->integer;
	ge.num_edicts = sv_max_clients->integer + 1;

	// set these to false to avoid spurious game restarts and alerts on init
	g_gameplay->modified = g_teams->modified = g_match->modified
			= g_rounds->modified = g_ctf->modified = g_cheats->modified
					= g_frag_limit->modified = g_round_limit->modified
							= g_capture_limit->modified
									= g_time_limit->modified = false;

	gi.Print("  Game initialized.\n");
}