static void drawEnteringTitle(void) { int x = SCREENWIDTH/2, y = WI_TITLEY; char* mapName = NULL; uint mapNum; ddmapinfo_t minfo; patchid_t patchId; patchinfo_t info; AutoStr* mapPath; Uri* mapUri; /// @kludge We need to properly externalize the map progression. if((gameModeBits & (GM_DOOM2|GM_DOOM2_PLUT|GM_DOOM2_TNT)) && wbs->nextMap == 30) { return; } /// kludge end. // See if there is a map name. mapUri = G_ComposeMapUri(wbs->episode, wbs->nextMap); mapPath = Uri_Compose(mapUri); if(Def_Get(DD_DEF_MAP_INFO, Str_Text(mapPath), &minfo) && minfo.name) { if(Def_Get(DD_DEF_TEXT, minfo.name, &mapName) == -1) mapName = minfo.name; } Uri_Delete(mapUri); // Skip the E#M# or Map #. if(mapName) { char* ptr = strchr(mapName, ':'); if(ptr) { mapName = M_SkipWhite(ptr + 1); } } DGL_Enable(DGL_TEXTURE_2D); DGL_Color4f(1, 1, 1, 1); FR_SetFont(FID(GF_FONTB)); FR_LoadDefaultAttrib(); FR_SetColorAndAlpha(defFontRGB2[CR], defFontRGB2[CG], defFontRGB2[CB], 1); // Draw "Entering" WI_DrawPatchXY3(pEntering, Hu_ChoosePatchReplacement(cfg.inludePatchReplaceMode, pEntering), x, y, ALIGN_TOP, 0, DTF_NO_TYPEIN); if(R_GetPatchInfo(pMapNames[wbs->nextMap], &info)) y += (5 * info.geometry.size.height) / 4; // Draw map. mapNum = (wbs->episode * 9) + wbs->nextMap; patchId = (mapNum < pMapNamesSize? pMapNames[mapNum] : 0); FR_SetColorAndAlpha(defFontRGB[CR], defFontRGB[CG], defFontRGB[CB], 1); WI_DrawPatchXY3(patchId, Hu_ChoosePatchReplacement2(cfg.inludePatchReplaceMode, patchId, mapName), x, y, ALIGN_TOP, 0, DTF_NO_TYPEIN); DGL_Disable(DGL_TEXTURE_2D); }
void GetDefState(char *def, int *val) { char *data; // Get the value. if(!Def_Get(DD_DEF_VALUE, def, &data)) return; // Get the state number. *val = Def_Get(DD_DEF_STATE, data, 0); if(*val < 0) *val = 0; }
/** * Initialize weapon info. */ void P_InitWeaponInfo(void) { #define WPINF "Weapon Info|" int i; int pclass = PCLASS_PLAYER; ammotype_t k; char buf[80]; char* data; for(i = 0; i < NUM_WEAPON_TYPES; ++i) { //// \todo Only allows for one type of ammo per weapon. sprintf(buf, WPINF "%i|Type", i); if(Def_Get(DD_DEF_VALUE, buf, &data)) { // Set the right types of ammo. if(!stricmp(data, "noammo")) { for(k = 0; k < NUM_AMMO_TYPES; ++k) { weaponInfo[i][pclass].mode[0].ammoType[k] = false; weaponInfo[i][pclass].mode[0].perShot[k] = 0; } } else { for(k = 0; k < NUM_AMMO_TYPES; ++k) { if(!stricmp(data, ammoTypeNames[k])) { weaponInfo[i][pclass].mode[0].ammoType[k] = true; sprintf(buf, WPINF "%i|Per shot", i); GetDefInt(buf, &weaponInfo[i][pclass].mode[0].perShot[k]); break; } } } } // end todo sprintf(buf, WPINF "%i|Up", i); GetDefState(buf, &weaponInfo[i][pclass].mode[0].upState); sprintf(buf, WPINF "%i|Down", i); GetDefState(buf, &weaponInfo[i][pclass].mode[0].downState); sprintf(buf, WPINF "%i|Ready", i); GetDefState(buf, &weaponInfo[i][pclass].mode[0].readyState); sprintf(buf, WPINF "%i|Atk", i); GetDefState(buf, &weaponInfo[i][pclass].mode[0].attackState); sprintf(buf, WPINF "%i|Flash", i); GetDefState(buf, &weaponInfo[i][pclass].mode[0].flashState); sprintf(buf, WPINF "%i|Static", i); weaponInfo[i][pclass].mode[0].staticSwitch = GetDefInt(buf, 0); } #undef WPINF }
// Initialize weapon info, maxammo and clipammo. void P_InitWeaponInfo() { #define PLMAX "Player|Max ammo|" #define PLCLP "Player|Clip ammo|" #define WPINF "Weapon Info|" int i, k; char buf[80]; char *data; char *ammotypes[] = { "clip", "shell", "cell", "misl", "-", "noammo", 0 }; // Max ammo. GetDefInt(PLMAX "Clip", &maxammo[am_clip]); GetDefInt(PLMAX "Shell", &maxammo[am_shell]); GetDefInt(PLMAX "Cell", &maxammo[am_cell]); GetDefInt(PLMAX "Misl", &maxammo[am_misl]); // Clip ammo. GetDefInt(PLCLP "Clip", &clipammo[am_clip]); GetDefInt(PLCLP "Shell", &clipammo[am_shell]); GetDefInt(PLCLP "Cell", &clipammo[am_cell]); GetDefInt(PLCLP "Misl", &clipammo[am_misl]); for(i = 0; i < NUMWEAPONS; i++) { sprintf(buf, WPINF "%i|Type", i); if(Def_Get(DD_DEF_VALUE, buf, &data)) { // Set the right type of ammo. for(k = 0; ammotypes[k]; k++) if(!stricmp(data, ammotypes[k])) { weaponinfo[i].ammo = k; break; } } sprintf(buf, WPINF "%i|Per shot", i); GetDefInt(buf, &weaponinfo[i].pershot); sprintf(buf, WPINF "%i|Up", i); GetDefState(buf, &weaponinfo[i].upstate); sprintf(buf, WPINF "%i|Down", i); GetDefState(buf, &weaponinfo[i].downstate); sprintf(buf, WPINF "%i|Ready", i); GetDefState(buf, &weaponinfo[i].readystate); sprintf(buf, WPINF "%i|Atk", i); GetDefState(buf, &weaponinfo[i].atkstate); sprintf(buf, WPINF "%i|Flash", i); GetDefState(buf, &weaponinfo[i].flashstate); sprintf(buf, WPINF "%i|Static", i); weaponinfo[i].static_switch = GetDefInt(buf, 0); } }
//=========================================================================== // GetDefInt //=========================================================================== int GetDefInt(char *def, int *returned_value) { char *data; int val; // Get the value. if(!Def_Get(DD_DEF_VALUE, def, &data)) return 0; // No such value... // Convert to integer. val = strtol(data, 0, 0); if(returned_value) *returned_value = val; return val; }
//=========================================================================== // S_LevelMusic // Start the song for the current map. //=========================================================================== void S_LevelMusic(void) { ddmapinfo_t info; char id[10]; if(gamestate != GS_LEVEL) return; sprintf(id, "E%iM%i", gameepisode, gamemap); if(Def_Get(DD_DEF_MAP_INFO, id, &info) && info.music >= 0) { S_StartMusicNum(info.music, true); } else { S_StartMusicNum((gameepisode - 1) * 9 + gamemap - 1, true); } }
/* * This routine tests for a string-replacement for the patch. If one is * found, it's used instead of the original graphic. * * If the patch is not in an IWAD, it won't be replaced! */ void WI_DrawPatch(int x, int y, int lump) { char def[80], *string; const char *name = W_LumpName(lump); // "{fontb; r=0.5; g=1; b=0; x=2; y=-2}This is good!" strcpy(def, "Patch Replacement|"); strcat(def, name); if(!cfg.usePatchReplacement || !W_IsFromIWAD(lump) || !Def_Get(DD_DEF_VALUE, def, &string)) { // Replacement string not found, draw the patch. GL_DrawPatch(x, y, lump); return; } WI_DrawParamText(x, y, string, hu_font_b, 1, 0, 0, false, false); }
void XG_WriteTypes(FILE * f) { int i, k; int linecount = 0, sectorcount = 0; linetype_t line; sectortype_t sec; file = f; // The first four four bytes are a header. // They will be updated with the real counts afterwards. i = 0; fwrite(&i, 4, 1, file); // Number of lines & sectors (two shorts). // This is a very simple way to get the definitions. for(i = 1; i < 65536; i++) { if(!Def_Get(DD_DEF_LINE_TYPE, (char *) i, &line)) continue; linecount++; // Write marker. WriteByte(XGSEG_LINE); WriteShort(line.id); WriteLong(line.flags); WriteLong(line.flags2); WriteLong(line.flags3); WriteShort(line.line_class); WriteByte(line.act_type); WriteShort(line.act_count); WriteFloat(line.act_time); WriteLong(line.act_tag); Write(line.aparm, sizeof(line.aparm)); WriteFloat(line.ticker_start); WriteFloat(line.ticker_end); WriteLong(line.ticker_interval); WriteShort(line.act_sound); WriteShort(line.deact_sound); WriteShort(line.ev_chain); WriteShort(line.act_chain); WriteShort(line.deact_chain); WriteByte(line.wallsection); WriteShort(line.act_tex); WriteShort(line.deact_tex); WriteString(line.act_msg); WriteString(line.deact_msg); WriteFloat(line.texmove_angle); WriteFloat(line.texmove_speed); Write(line.iparm, sizeof(line.iparm)); Write(line.fparm, sizeof(line.fparm)); for(k = 0; k < DDLT_MAX_SPARAMS; k++) WriteString(line.sparm[k]); } // Then the sectors. for(i = 1; i < 65536; i++) { if(!Def_Get(DD_DEF_SECTOR_TYPE, (char *) i, &sec)) continue; sectorcount++; // Write marker. WriteByte(XGSEG_SECTOR); WriteShort(sec.id); WriteLong(sec.flags); WriteLong(sec.act_tag); Write(sec.chain, sizeof(sec.chain)); Write(sec.chain_flags, sizeof(sec.chain_flags)); Write(sec.start, sizeof(sec.start)); Write(sec.end, sizeof(sec.end)); Write(sec.interval, sizeof(sec.interval)); Write(sec.count, sizeof(sec.count)); WriteShort(sec.ambient_sound); Write(sec.sound_interval, sizeof(sec.sound_interval)); Write(sec.texmove_angle, sizeof(sec.texmove_angle)); Write(sec.texmove_speed, sizeof(sec.texmove_speed)); WriteFloat(sec.wind_angle); WriteFloat(sec.wind_speed); WriteFloat(sec.vertical_wind); WriteFloat(sec.gravity); WriteFloat(sec.friction); WriteString(sec.lightfunc); WriteShort(sec.light_interval[0]); WriteShort(sec.light_interval[1]); WriteString(sec.colfunc[0]); WriteString(sec.colfunc[1]); WriteString(sec.colfunc[2]); for(k = 0; k < 3; k++) { WriteShort(sec.col_interval[k][0]); WriteShort(sec.col_interval[k][1]); } WriteString(sec.floorfunc); WriteFloat(sec.floormul); WriteFloat(sec.flooroff); WriteShort(sec.floor_interval[0]); WriteShort(sec.floor_interval[1]); WriteString(sec.ceilfunc); WriteFloat(sec.ceilmul); WriteFloat(sec.ceiloff); WriteShort(sec.ceil_interval[0]); WriteShort(sec.ceil_interval[1]); } // Write the end marker. WriteByte(XGSEG_END); // Update header. rewind(file); fwrite(&linecount, 2, 1, file); fwrite(§orcount, 2, 1, file); }