int R_SetSky(char *skyname) { int i; int real_width, real_height; char *groupname; r_skyboxloaded = false; // set skyname to groupname if any skyname = (groupname = TP_GetSkyGroupName(TP_MapName(), NULL)) ? groupname : skyname; if (!skyname || !skyname[0] || strchr(skyname, '.')) { // Empty name or contain dot(dot causing troubles with skipping part of the name as file extenson), // so do nothing. return 1; } for (i = 0; i < MAX_SKYBOXTEXTURES; i++) { byte *data; if ( (data = GL_LoadImagePixels (va("env/%s%s", skyname, skybox_ext[i]), 0, 0, 0, &real_width, &real_height)) || (data = GL_LoadImagePixels (va("gfx/env/%s%s", skyname, skybox_ext[i]), 0, 0, 0, &real_width, &real_height)) || (data = GL_LoadImagePixels (va("env/%s_%s", skyname, skybox_ext[i]), 0, 0, 0, &real_width, &real_height)) || (data = GL_LoadImagePixels (va("gfx/env/%s_%s", skyname, skybox_ext[i]), 0, 0, 0, &real_width, &real_height)) ) { skyboxtextures[i] = GL_LoadTexture( va("skybox:%s", skybox_ext[i]), real_width, real_height, data, TEX_NOCOMPRESS | TEX_MIPMAP, 4); // we shold free data from GL_LoadImagePixels() Q_free(data); } else { skyboxtextures[i] = 0; // GL_LoadImagePixels() fail to load anything } if (!skyboxtextures[i]) { Com_Printf ("Couldn't load skybox \"%s\"\n", skyname); return 1; } } // everything was OK r_skyboxloaded = true; return 0; }
void MVD_Init_Info (int player_slot) { int i; int z; for (z=0,i=0;i<MAX_CLIENTS;i++){ if (!cl.players[i].name[0] || cl.players[i].spectator == 1) continue; mvd_new_info[z].id = i; if (player_slot == i || player_slot == MAX_CLIENTS) { mvd_new_info[z].mvdinfo.initialized = false; } // memset(mvd_new_info[z].item_info, 0, sizeof(mvd_new_info[z].item_info)); mvd_new_info[z++].p_info = &cl.players[i]; } strlcpy(mvd_cg_info.mapname,TP_MapName(),sizeof(mvd_cg_info.mapname)); mvd_cg_info.timelimit=cl.timelimit; strlcpy(mvd_cg_info.team1, (z ? mvd_new_info[0].p_info->team : ""),sizeof(mvd_cg_info.team1)); for (i = 0; i < z; i++) { if(strcmp(mvd_new_info[i].p_info->team,mvd_cg_info.team1)){ strlcpy(mvd_cg_info.team2,mvd_new_info[i].p_info->team,sizeof(mvd_cg_info.team2)); break; } } if (z==2) mvd_cg_info.gametype=0; else if (z==4) mvd_cg_info.gametype=1; else if (z==6) mvd_cg_info.gametype=2; else if (z==8) mvd_cg_info.gametype=3; else mvd_cg_info.gametype=4; strlcpy(mvd_cg_info.hostname,Info_ValueForKey(cl.serverinfo,"hostname"),sizeof(mvd_cg_info.hostname)); mvd_cg_info.deathmatch=atoi(Info_ValueForKey(cl.serverinfo,"deathmatch")); mvd_cg_info.pcount = z; for (i = 0; i < mvd_cg_info.pcount; i++) mvd_new_info[i].p_state = &cl.frames[cl.parsecount & UPDATE_MASK].playerstate[mvd_new_info[i].id]; }
/* ==================== CL_EasyRecord_f easyrecord [demoname] ==================== */ void CL_EasyRecord_f (void) { int c; char name[1024]; char name2[MAX_OSPATH*2]; int i; char *p; FILE *f; c = Cmd_Argc(); if (c > 2) { Com_Printf ("easyrecord <demoname>\n"); return; } if (cls.state != ca_active) { Com_Printf ("You must be connected to record.\n"); return; } if (cls.demorecording) CL_Stop_f(); /// FIXME: check buffer sizes!!! if (c == 2) Q_snprintfz (name, sizeof(name), "%s", Cmd_Argv(1)); else if (cl.spectator) { // FIXME: if tracking a player, use his name Q_snprintfz (name, sizeof(name), "spec_%s_%s", TP_PlayerName(), TP_MapName()); } else { // guess game type and write demo name i = TP_CountPlayers(); if (cl.teamplay && i >= 3) { // Teamplay Q_snprintfz (name, sizeof(name), "%s_%s_vs_%s_%s", TP_PlayerName(), TP_PlayerTeam(), TP_EnemyTeam(), TP_MapName()); } else { if (i == 2) { // Duel Q_snprintfz (name, sizeof(name), "%s_vs_%s_%s", TP_PlayerName(), TP_EnemyName(), TP_MapName()); } else if (i > 2) { // FFA Q_snprintfz (name, sizeof(name), "%s_ffa_%s", TP_PlayerName(), TP_MapName()); } else { // one player Q_snprintfz (name, sizeof(name), "%s_%s", TP_PlayerName(), TP_MapName()); } } } // Make sure the filename doesn't contain illegal characters for (p = name; *p; p++) { char c; *p &= 0x7F; // strip high bit c = *p; if (c <= ' ' || c == '?' || c == '*' || c == '\\' || c == '/' || c == ':' || c == '<' || c == '>' || c == '"') *p = '_'; } strlcpy (name, va("%s/%s", cls.gamedir, name), MAX_OSPATH); // find a filename that doesn't exist yet strcpy (name2, name); COM_ForceExtension (name2, ".qwd"); f = fopen (name2, "rb"); if (f) { i = 0; do { fclose (f); strcpy (name2, va("%s_%02i", name, i)); COM_ForceExtension (name2, ".qwd"); f = fopen (name2, "rb"); i++; } while (f); } // // open the demo file // cls.demofile = fopen (name2, "wb"); if (!cls.demofile) { Com_Printf ("ERROR: couldn't open.\n"); return; } Com_Printf ("recording to %s.\n", name2); CL_Record (); }
void MVD_Info (void){ char str[1024]; char mvd_info_final_string[1024], mvd_info_powerups[20], mvd_info_header_string[1024]; char *mapname; int x,y,z,i; #ifdef DEBUG printf("MVD_Info Started\n"); #endif z=1; if (loc_loaded == 0){ mapname = TP_MapName(); TP_LoadLocFile (mapname, true); loc_loaded = 1; } if (!mvd_info.value) return; if (!cls.mvdplayback) return; x = ELEMENT_X_COORD(mvd_info); y = ELEMENT_Y_COORD(mvd_info); if (mvd_info_show_header.value){ strlcpy(mvd_info_header_string,mvd_info_setup.string,sizeof(mvd_info_header_string)); Replace_In_String(mvd_info_header_string,sizeof(mvd_info_header_string),'%',\ 10,\ "a","Armor",\ "f","Frags",\ "h","Health",\ "l","Location",\ "n","Nick",\ "P","Ping",\ "p","Powerup",\ "v","Value",\ "w","Cur.Weap.",\ "W","Best Weap."); strlcpy(mvd_info_header_string,Make_Red(mvd_info_header_string,0),sizeof(mvd_info_header_string)); Draw_String (x, y+((z++)*8), mvd_info_header_string); } for ( i=0 ; i<mvd_cg_info.pcount ; i++ ){ mvd_info_powerups[0]=0; if (mvd_new_info[i].p_info->stats[STAT_ITEMS] & IT_QUAD) //strlcpy(mvd_info_powerups, tp_name_quad.string, sizeof(mvd_info_powerups)); if (mvd_new_info[i].p_info->stats[STAT_ITEMS] & IT_INVULNERABILITY) { //if (mvd_info_powerups[0]) // strlcat(mvd_info_powerups, tp_name_separator.string, sizeof(mvd_info_powerups)); //strlcat(mvd_info_powerups, tp_name_pent.string, sizeof(mvd_info_powerups)); } if (mvd_new_info[i].p_info->stats[STAT_ITEMS] & IT_INVISIBILITY) { //if (mvd_info_powerups[0]) // strlcat(mvd_info_powerups, tp_name_separator.string, sizeof(mvd_info_powerups)); //strlcat(mvd_info_powerups, tp_name_ring.string, sizeof(mvd_info_powerups)); } strlcpy(mvd_info_final_string,mvd_info_setup.string,sizeof(mvd_info_final_string)); Replace_In_String(mvd_info_final_string,sizeof(mvd_info_final_string),'%',\ 10,\ "w",va("%s:%i",TP_ItemName(mvd_new_info[i].p_info->stats[STAT_ACTIVEWEAPON]),mvd_new_info[i].p_info->stats[STAT_AMMO]),\ "W",va("%s:%s",MVD_BestWeapon_strings(i),MVD_BestAmmo(i)),\ "a",va("%i",mvd_new_info[i].p_info->stats[STAT_ARMOR]),\ "f",va("%i",mvd_new_info[i].p_info->frags),\ "h",va("%i",mvd_new_info[i].p_info->stats[STAT_HEALTH]),\ "l",TP_LocationName(mvd_new_info[i].p_state->origin),\ "n",mvd_new_info[i].p_info->name,\ "P",va("%i",mvd_new_info[i].p_info->ping),\ "p",mvd_info_powerups,\ "v",va("%f",mvd_new_info[i].value)); strlcpy(str, mvd_info_final_string,sizeof(str)); Draw_String (x, y+((z++)*8), str); #ifdef DEBUG printf("MVD_Info Stopped\n"); #endif } }