void writeSoundTargets() { #if !__JHEXEN__ if (!IS_SERVER) return; // Not for us. // Write the total number. int count = 0; for (int i = 0; i < numsectors; ++i) { xsector_t *xsec = P_ToXSector((Sector *)P_ToPtr(DMU_SECTOR, i)); if (xsec->soundTarget) { count += 1; } } // beginSegment(); Writer_WriteInt32(writer, count); // Write the mobj references using the mobj archive. for (int i = 0; i < numsectors; ++i) { xsector_t *xsec = P_ToXSector((Sector *)P_ToPtr(DMU_SECTOR, i)); if (xsec->soundTarget) { Writer_WriteInt32(writer, i); Writer_WriteInt16(writer, thingArchive->serialIdFor(xsec->soundTarget)); } } // endSegment(); #endif }
int waggle_s::read(MapStateReader *msr) { Reader1 *reader = msr->reader(); int mapVersion = msr->mapVersion(); if(mapVersion >= 4) { /*int ver =*/ Reader_ReadByte(reader); // version byte. // Start of used data members. sector = (Sector *)P_ToPtr(DMU_SECTOR, (int) Reader_ReadInt32(reader)); DENG_ASSERT(sector != 0); originalHeight = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); accumulator = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); accDelta = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); targetScale = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); scale = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); scaleDelta = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); ticker = Reader_ReadInt32(reader); state = wagglestate_e(Reader_ReadInt32(reader)); } else { // Its in the old pre V4 format which serialized waggle_t // Padding at the start (an old thinker_t struct) byte junk[16]; // sizeof thinker_t Reader_Read(reader, junk, 16); // Start of used data members. // A 32bit pointer to sector, serialized. sector = (Sector *)P_ToPtr(DMU_SECTOR, (int) Reader_ReadInt32(reader)); DENG_ASSERT(sector != 0); originalHeight = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); accumulator = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); accDelta = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); targetScale = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); scale = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); scaleDelta = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); ticker = Reader_ReadInt32(reader); state = wagglestate_e(Reader_ReadInt32(reader)); } thinker.function = (thinkfunc_t) T_FloorWaggle; P_ToXSector(sector)->specialData = this; return true; // Add this thinker. }
void P_BuildLineTagLists(void) { int i; P_DestroyLineTagLists(); for(i = 0; i < numlines; ++i) { Line* line = P_ToPtr(DMU_LINE, i); xline_t* xline = P_ToXLine(line); #if !__JHEXEN__ if(xline->tag) { iterlist_t* list = P_GetLineIterListForTag(xline->tag, true); IterList_PushBack(list, line); } #else switch(xline->special) { default: break; case 121: ///< Line_SetIdentification. if(xline->arg1) { iterlist_t* list = P_GetLineIterListForTag((int) xline->arg1, true); IterList_PushBack(list, line); } xline->special = 0; break; } #endif } }
static int SV_ReadStrobe(strobe_t *strobe) { /* Original Heretic format: typedef struct { thinker_t thinker; // was 12 bytes Sector *sector; int count; int minLight; int maxLight; int darkTime; int brightTime; } v13_strobe_t; */ // Padding at the start (an old thinker_t struct) Reader_Read(svReader, NULL, SIZEOF_V13_THINKER_T); // Start of used data members. // A 32bit pointer to sector, serialized. strobe->sector = P_ToPtr(DMU_SECTOR, Reader_ReadInt32(svReader)); if(!strobe->sector) Con_Error("tc_strobe: bad sector number\n"); strobe->count = Reader_ReadInt32(svReader); strobe->minLight = (float) Reader_ReadInt32(svReader) / 255.0f; strobe->maxLight = (float) Reader_ReadInt32(svReader) / 255.0f; strobe->darkTime = Reader_ReadInt32(svReader); strobe->brightTime = Reader_ReadInt32(svReader); strobe->thinker.function = (thinkfunc_t) T_StrobeFlash; return true; // Add this thinker. }
static int SV_ReadGlow(glow_t *glow) { /* Original Heretic format: typedef struct { thinker_t thinker; // was 12 bytes Sector *sector; int minLight; int maxLight; int direction; } v13_glow_t; */ // Padding at the start (an old thinker_t struct) Reader_Read(svReader, NULL, SIZEOF_V13_THINKER_T); // Start of used data members. // A 32bit pointer to sector, serialized. glow->sector = P_ToPtr(DMU_SECTOR, Reader_ReadInt32(svReader)); if(!glow->sector) Con_Error("tc_glow: bad sector number\n"); glow->minLight = (float) Reader_ReadInt32(svReader) / 255.0f; glow->maxLight = (float) Reader_ReadInt32(svReader) / 255.0f; glow->direction = Reader_ReadInt32(svReader); glow->thinker.function = (thinkfunc_t) T_Glow; return true; // Add this thinker. }
void writeElements() { beginSegment(ASEG_MAP_ELEMENTS); for (int i = 0; i < numsectors; ++i) { SV_WriteSector((Sector *)P_ToPtr(DMU_SECTOR, i), thisPublic); } for (int i = 0; i < numlines; ++i) { SV_WriteLine((Line *)P_ToPtr(DMU_LINE, i), thisPublic); } // endSegment(); }
int pillar_s::read(MapStateReader *msr) { Reader1 *reader = msr->reader(); int mapVersion = msr->mapVersion(); if(mapVersion >= 4) { // Note: the thinker class byte has already been read. /*int ver =*/ Reader_ReadByte(reader); // version byte. // Start of used data members. sector = (Sector *)P_ToPtr(DMU_SECTOR, (int) Reader_ReadInt32(reader)); DENG_ASSERT(sector != 0); ceilingSpeed = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); floorSpeed = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); floorDest = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); ceilingDest = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); direction = Reader_ReadInt32(reader); crush = Reader_ReadInt32(reader); } else { // Its in the old pre V4 format which serialized pillar_t // Padding at the start (an old thinker_t struct) byte junk[16]; // sizeof thinker_t Reader_Read(reader, junk, 16); // Start of used data members. // A 32bit pointer to sector, serialized. sector = (Sector *)P_ToPtr(DMU_SECTOR, (int) Reader_ReadInt32(reader)); DENG_ASSERT(sector != 0); ceilingSpeed = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); floorSpeed = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); floorDest = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); ceilingDest = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); direction = Reader_ReadInt32(reader); crush = Reader_ReadInt32(reader); } thinker.function = (thinkfunc_t) T_BuildPillar; P_ToXSector(sector)->specialData = this; return true; // Add this thinker. }
int light_s::read(MapStateReader *msr) { Reader1 *reader = msr->reader(); int mapVersion = msr->mapVersion(); if(mapVersion >= 4) { /*int ver =*/ Reader_ReadByte(reader); // version byte. type = (lighttype_t) Reader_ReadByte(reader); sector = (Sector *)P_ToPtr(DMU_SECTOR, Reader_ReadInt32(reader)); DENG_ASSERT(sector != 0); value1 = (float) Reader_ReadInt32(reader) / 255.0f; value2 = (float) Reader_ReadInt32(reader) / 255.0f; tics1 = Reader_ReadInt32(reader); tics2 = Reader_ReadInt32(reader); count = Reader_ReadInt32(reader); } else { // Its in the old pre V4 format which serialized light_t // Padding at the start (an old thinker_t struct) byte junk[16]; // sizeof thinker_t Reader_Read(reader, junk, 16); // Start of used data members. // A 32bit pointer to sector, serialized. sector = (Sector *)P_ToPtr(DMU_SECTOR, (int) Reader_ReadInt32(reader)); DENG_ASSERT(sector != 0); type = lighttype_t(Reader_ReadInt32(reader)); value1 = (float) Reader_ReadInt32(reader) / 255.0f; value2 = (float) Reader_ReadInt32(reader) / 255.0f; tics1 = Reader_ReadInt32(reader); tics2 = Reader_ReadInt32(reader); count = Reader_ReadInt32(reader); } thinker.function = (thinkfunc_t) T_Light; return true; // Add this thinker. }
void IN_DrawStatBack(void) { DGL_SetMaterialUI(P_ToPtr(DMU_MATERIAL, Materials_ResolveUriCString("Flats:FLOOR16")), DGL_REPEAT, DGL_REPEAT); DGL_Enable(DGL_TEXTURE_2D); DGL_Color4f(1, 1, 1, 1); DGL_DrawRectf2Tiled(0, 0, SCREENWIDTH, SCREENHEIGHT, 64, 64); DGL_Disable(DGL_TEXTURE_2D); }
int lightflash_s::read(MapStateReader *msr) { Reader1 *reader = msr->reader(); int mapVersion = msr->mapVersion(); if(mapVersion >= 5) { // Note: the thinker class byte has already been read. /*int ver =*/ Reader_ReadByte(reader); // version byte. // Start of used data members. sector = (Sector *)P_ToPtr(DMU_SECTOR, (int) Reader_ReadInt32(reader)); DENG_ASSERT(sector != 0); count = Reader_ReadInt32(reader); maxLight = (float) Reader_ReadInt32(reader) / 255.0f; minLight = (float) Reader_ReadInt32(reader) / 255.0f; maxTime = Reader_ReadInt32(reader); minTime = Reader_ReadInt32(reader); } else { // Its in the old pre V5 format which serialized lightflash_t // Padding at the start (an old thinker_t struct) byte junk[16]; // sizeof thinker_t Reader_Read(reader, junk, 16); // Start of used data members. // A 32bit pointer to sector, serialized. sector = (Sector *)P_ToPtr(DMU_SECTOR, (int) Reader_ReadInt32(reader)); DENG_ASSERT(sector != 0); count = Reader_ReadInt32(reader); maxLight = (float) Reader_ReadInt32(reader) / 255.0f; minLight = (float) Reader_ReadInt32(reader) / 255.0f; maxTime = Reader_ReadInt32(reader); minTime = Reader_ReadInt32(reader); } thinker.function = (thinkfunc_t) T_LightFlash; return true; // Add this thinker. }
void P_InitTerrainTypes(void) { struct matttypedef_s { const char* materialUri; ///< Percent encoded. const char* ttName; } defs[] = { #if __JDOOM__ || __JDOOM64__ { "Flats:FWATER1", "Water" }, { "Flats:LAVA1", "Lava" }, { "Flats:BLOOD1", "Blood" }, { "Flats:NUKAGE1", "Nukage" }, { "Flats:SLIME01", "Slime" }, #endif #if __JHERETIC__ { "Flats:FLTWAWA1", "Water" }, { "Flats:FLTFLWW1", "Water" }, { "Flats:FLTLAVA1", "Lava" }, { "Flats:FLATHUH1", "Lava" }, { "Flats:FLTSLUD1", "Sludge" }, #endif #if __JHEXEN__ { "Flats:X_005", "Water" }, { "Flats:X_001", "Lava" }, { "Flats:X_009", "Sludge" }, { "Flats:F_033", "Ice" }, #endif { 0, 0 } }; uint i; if(materialTTypes) Z_Free(materialTTypes); materialTTypes = 0; numMaterialTTypes = maxMaterialTTypes = 0; for(i = 0; defs[i].materialUri; ++i) { Material* mat; uint idx = findTerrainTypeNumForName(defs[i].ttName); if(!idx) continue; mat = P_ToPtr(DMU_MATERIAL, Materials_ResolveUriCString(defs[i].materialUri)); if(!mat) continue; App_Log(DE2_DEV_RES_VERBOSE, "P_InitTerrainTypes: Material \"%s\" linked to terrain type '%s'", defs[i].materialUri, defs[i].ttName); getMaterialTerrainType(mat, idx); } }
void P_BuildSectorTagLists() { P_DestroySectorTagLists(); for(int i = 0; i < numsectors; ++i) { Sector *sec = (Sector *)P_ToPtr(DMU_SECTOR, i); xsector_t *xsec = P_ToXSector(sec); if(xsec->tag) { iterlist_t *list = P_GetSectorIterListForTag(xsec->tag, true); IterList_PushBack(list, sec); } } }
static int SV_ReadPlat(plat_t *plat) { /* Original Heretic format: typedef struct { thinker_t thinker; // was 12 bytes Sector *sector; fixed_t speed; fixed_t low; fixed_t high; int wait; int count; platstate_e status; // was 32bit int platstate_e oldStatus; // was 32bit int boolean crush; int tag; plattype_e type; // was 32bit int } v13_plat_t; */ byte temp[SIZEOF_V13_THINKER_T]; // Padding at the start (an old thinker_t struct) Reader_Read(svReader, &temp, SIZEOF_V13_THINKER_T); // Start of used data members. // A 32bit pointer to sector, serialized. plat->sector = P_ToPtr(DMU_SECTOR, Reader_ReadInt32(svReader)); if(!plat->sector) Con_Error("tc_plat: bad sector number\n"); plat->speed = FIX2FLT(Reader_ReadInt32(svReader)); plat->low = FIX2FLT(Reader_ReadInt32(svReader)); plat->high = FIX2FLT(Reader_ReadInt32(svReader)); plat->wait = Reader_ReadInt32(svReader); plat->count = Reader_ReadInt32(svReader); plat->state = Reader_ReadInt32(svReader); plat->oldState = Reader_ReadInt32(svReader); plat->crush = Reader_ReadInt32(svReader); plat->tag = Reader_ReadInt32(svReader); plat->type = Reader_ReadInt32(svReader); plat->thinker.function = T_PlatRaise; if(!(temp + V13_THINKER_T_FUNC_OFFSET)) Thinker_SetStasis(&plat->thinker, true); P_ToXSector(plat->sector)->specialData = T_PlatRaise; return true; // Add this thinker. }
/** * T_FireFlicker was added to save games in ver5, therefore we don't have * an old format to support. */ int fireflicker_s::read(MapStateReader *msr) { Reader1 *reader = msr->reader(); /*int ver =*/ Reader_ReadByte(reader); // version byte. // Note: the thinker class byte has already been read. sector = (Sector*)P_ToPtr(DMU_SECTOR, (int) Reader_ReadInt32(reader)); DENG_ASSERT(sector != 0); maxLight = (float) Reader_ReadInt32(reader) / 255.0f; minLight = (float) Reader_ReadInt32(reader) / 255.0f; thinker.function = (thinkfunc_t) T_FireFlicker; return true; // Add this thinker. }
static int SV_ReadFloor(floor_t *floor) { /* Original Heretic format: typedef struct { thinker_t thinker; // was 12 bytes floortype_e type; // was 32bit int boolean crush; Sector *sector; int direction; int newspecial; short texture; fixed_t floordestheight; fixed_t speed; } v13_floormove_t; */ Uri *newTextureUrn; // Padding at the start (an old thinker_t struct) Reader_Read(svReader, NULL, SIZEOF_V13_THINKER_T); // Start of used data members. floor->type = Reader_ReadInt32(svReader); floor->crush = Reader_ReadInt32(svReader); // A 32bit pointer to sector, serialized. floor->sector = P_ToPtr(DMU_SECTOR, Reader_ReadInt32(svReader)); if(!floor->sector) Con_Error("tc_floor: bad sector number\n"); floor->state = (int) Reader_ReadInt32(svReader); floor->newSpecial = Reader_ReadInt32(svReader); newTextureUrn = readTextureUrn(svReader, "Flats"); floor->material = DD_MaterialForTextureUri(newTextureUrn); Uri_Delete(newTextureUrn); floor->floorDestHeight = FIX2FLT(Reader_ReadInt32(svReader)); floor->speed = FIX2FLT(Reader_ReadInt32(svReader)); floor->thinker.function = T_MoveFloor; P_ToXSector(floor->sector)->specialData = T_MoveFloor; return true; // Add this thinker. }
static int SV_ReadCeiling(ceiling_t *ceiling) { /* Original Heretic format: typedef struct { thinker_t thinker; ///< 12 bytes ceilingtype_e type; ///< 32bit int Sector* sector; fixed_t bottomheight, topheight; fixed_t speed; boolean crush; int direction; /// 1= up, 0= waiting, -1= down int tag' int olddirection; } v13_ceiling_t; */ byte temp[SIZEOF_V13_THINKER_T]; // Padding at the start (an old thinker_t struct) Reader_Read(svReader, &temp, SIZEOF_V13_THINKER_T); // Start of used data members. ceiling->type = Reader_ReadInt32(svReader); // A 32bit pointer to sector, serialized. ceiling->sector = P_ToPtr(DMU_SECTOR, Reader_ReadInt32(svReader)); if(!ceiling->sector) Con_Error("tc_ceiling: bad sector number\n"); ceiling->bottomHeight = FIX2FLT(Reader_ReadInt32(svReader)); ceiling->topHeight = FIX2FLT(Reader_ReadInt32(svReader)); ceiling->speed = FIX2FLT(Reader_ReadInt32(svReader)); ceiling->crush = Reader_ReadInt32(svReader); ceiling->state = (Reader_ReadInt32(svReader) == -1? CS_DOWN : CS_UP); ceiling->tag = Reader_ReadInt32(svReader); ceiling->oldState = (Reader_ReadInt32(svReader) == -1? CS_DOWN : CS_UP); ceiling->thinker.function = T_MoveCeiling; if(!(temp + V13_THINKER_T_FUNC_OFFSET)) Thinker_SetStasis(&ceiling->thinker, true); P_ToXSector(ceiling->sector)->specialData = T_MoveCeiling; return true; // Add this thinker. }
static int SV_ReadDoor(door_t *door) { /* Original Heretic format: typedef struct { thinker_t thinker; // was 12 bytes doortype_e type; // was 32bit int Sector *sector; fixed_t topheight; fixed_t speed; int direction; // 1 = up, 0 = waiting at top, -1 = down int topwait; // tics to wait at the top // (keep in case a door going down is reset) int topcountdown; // when it reaches 0, start going down } v13_vldoor_t; */ // Padding at the start (an old thinker_t struct) Reader_Read(svReader, NULL, SIZEOF_V13_THINKER_T); // Start of used data members. door->type = Reader_ReadInt32(svReader); // A 32bit pointer to sector, serialized. door->sector = P_ToPtr(DMU_SECTOR, Reader_ReadInt32(svReader)); if(!door->sector) Con_Error("tc_door: bad sector number\n"); door->topHeight = FIX2FLT(Reader_ReadInt32(svReader)); door->speed = FIX2FLT(Reader_ReadInt32(svReader)); door->state = Reader_ReadInt32(svReader); door->topWait = Reader_ReadInt32(svReader); door->topCountDown = Reader_ReadInt32(svReader); door->thinker.function = T_Door; P_ToXSector(door->sector)->specialData = T_Door; return true; // Add this thinker. }
int plat_t::read(MapStateReader *msr) { Reader *reader = msr->reader(); int mapVersion = msr->mapVersion(); #if __JHEXEN__ if(mapVersion >= 4) #else if(mapVersion >= 5) #endif { // Note: the thinker class byte has already been read. /*int ver =*/ Reader_ReadByte(reader); // version byte. thinker.function = T_PlatRaise; #if !__JHEXEN__ // Should we put this into stasis? if(mapVersion == 5) { if(!Reader_ReadByte(reader)) Thinker_SetStasis(&thinker, true); } #endif type = plattype_e(Reader_ReadByte(reader)); sector = (Sector *)P_ToPtr(DMU_SECTOR, Reader_ReadInt32(reader)); DENG_ASSERT(sector != 0); speed = FIX2FLT(Reader_ReadInt32(reader)); low = (float) Reader_ReadInt16(reader); high = (float) Reader_ReadInt16(reader); wait = Reader_ReadInt32(reader); count = Reader_ReadInt32(reader); state = platstate_e(Reader_ReadByte(reader)); oldState = platstate_e(Reader_ReadByte(reader)); crush = (dd_bool) Reader_ReadByte(reader); tag = Reader_ReadInt32(reader); } else { // Its in the old format which serialized plat_t // Padding at the start (an old thinker_t struct) int32_t junk[4]; // sizeof thinker_t Reader_Read(reader, (byte *)junk, 16); // Start of used data members. // A 32bit pointer to sector, serialized. sector = (Sector *)P_ToPtr(DMU_SECTOR, (int) Reader_ReadInt32(reader)); DENG_ASSERT(sector != 0); speed = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); low = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); high = FIX2FLT((fixed_t) Reader_ReadInt32(reader)); wait = Reader_ReadInt32(reader); count = Reader_ReadInt32(reader); state = platstate_e(Reader_ReadInt32(reader)); oldState = platstate_e(Reader_ReadInt32(reader)); crush = Reader_ReadInt32(reader); tag = Reader_ReadInt32(reader); type = plattype_e(Reader_ReadInt32(reader)); thinker.function = T_PlatRaise; #if !__JHEXEN__ if(junk[2] == 0) { Thinker_SetStasis(&thinker, true); } #endif } P_ToXSector(sector)->specialData = this; return true; // Add this thinker. }
void P_SpawnSectorSpecialThinkers() { // Clients spawn specials only on the server's instruction. if(IS_CLIENT) return; for(int i = 0; i < numsectors; ++i) { Sector *sec = (Sector *)P_ToPtr(DMU_SECTOR, i); xsector_t *xsec = P_ToXSector(sec); // XG sector types override the game's built-in types. if(xsec->xg) continue; // jd64 > // DJS - yet more hacks! Why use the tag? switch(xsec->tag) { default: break; case 10000: case 10001: case 10002: case 10003: case 10004: P_SpawnGlowingLight(sec); break; case 11000: P_SpawnLightFlash(sec); break; case 12000: P_SpawnFireFlicker(sec); break; case 13000: P_SpawnLightBlink(sec); break; case 20000: P_SpawnGlowingLight(sec); break; } // < d64tc switch(xsec->special) { default: break; case 1: ///< FLICKERING LIGHTS P_SpawnLightFlash(sec); break; case 2: ///< STROBE FAST P_SpawnStrobeFlash(sec, FASTDARK, 0); break; case 3: ///< STROBE SLOW P_SpawnStrobeFlash(sec, SLOWDARK, 0); break; case 4: ///< STROBE FAST/DEATH SLIME P_SpawnStrobeFlash(sec, FASTDARK, 0); xsec->special = 4; break; case 8: ///< GLOWING LIGHT P_SpawnGlowingLight(sec); break; case 10: ///< DOOR CLOSE IN 30 SECONDS P_SpawnDoorCloseIn30(sec); break; case 12: ///< SYNC STROBE SLOW P_SpawnStrobeFlash(sec, SLOWDARK, 1); break; case 13: ///< SYNC STROBE FAST P_SpawnStrobeFlash(sec, FASTDARK, 1); break; case 14: ///< DOOR RAISE IN 5 MINUTES P_SpawnDoorRaiseIn5Mins(sec); break; case 17: P_SpawnFireFlicker(sec); break; } } }
static void P_v13_UnArchiveWorld(void) { int i, j; fixed_t offx, offy; Sector* sec; xsector_t* xsec; Line* line; xline_t* xline; // Do sectors. for(i = 0; i < numsectors; ++i) { Uri *floorTextureUrn, *ceilingTextureUrn; sec = P_ToPtr(DMU_SECTOR, i); xsec = P_ToXSector(sec); P_SetDoublep(sec, DMU_FLOOR_HEIGHT, (coord_t)Reader_ReadInt16(svReader)); P_SetDoublep(sec, DMU_CEILING_HEIGHT, (coord_t)Reader_ReadInt16(svReader)); floorTextureUrn = readTextureUrn(svReader, "Flats"); P_SetPtrp(sec, DMU_FLOOR_MATERIAL, DD_MaterialForTextureUri(floorTextureUrn)); Uri_Delete(floorTextureUrn); ceilingTextureUrn = readTextureUrn(svReader, "Flats"); P_SetPtrp(sec, DMU_CEILING_MATERIAL, DD_MaterialForTextureUri(ceilingTextureUrn)); Uri_Delete(ceilingTextureUrn); P_SetFloatp(sec, DMU_LIGHT_LEVEL, (float) (Reader_ReadInt16(svReader)) / 255.0f); xsec->special = Reader_ReadInt16(svReader); // needed? /*xsec->tag = **/Reader_ReadInt16(svReader); // needed? xsec->specialData = 0; xsec->soundTarget = 0; } // Do lines. for(i = 0; i < numlines; ++i) { line = P_ToPtr(DMU_LINE, i); xline = P_ToXLine(line); xline->flags = Reader_ReadInt16(svReader); xline->special = Reader_ReadInt16(svReader); /*xline->tag =*/Reader_ReadInt16(svReader); for(j = 0; j < 2; ++j) { Uri *topTextureUrn, *bottomTextureUrn, *middleTextureUrn; Side* sdef = P_GetPtrp(line, j == 0? DMU_FRONT : DMU_BACK); if(!sdef) continue; offx = Reader_ReadInt16(svReader) << FRACBITS; offy = Reader_ReadInt16(svReader) << FRACBITS; P_SetFixedp(sdef, DMU_TOP_MATERIAL_OFFSET_X, offx); P_SetFixedp(sdef, DMU_TOP_MATERIAL_OFFSET_Y, offy); P_SetFixedp(sdef, DMU_MIDDLE_MATERIAL_OFFSET_X, offx); P_SetFixedp(sdef, DMU_MIDDLE_MATERIAL_OFFSET_Y, offy); P_SetFixedp(sdef, DMU_BOTTOM_MATERIAL_OFFSET_X, offx); P_SetFixedp(sdef, DMU_BOTTOM_MATERIAL_OFFSET_Y, offy); topTextureUrn = readTextureUrn(svReader, "Textures"); P_SetPtrp(sdef, DMU_TOP_MATERIAL, DD_MaterialForTextureUri(topTextureUrn)); Uri_Delete(topTextureUrn); bottomTextureUrn = readTextureUrn(svReader, "Textures"); P_SetPtrp(sdef, DMU_BOTTOM_MATERIAL, DD_MaterialForTextureUri(bottomTextureUrn)); Uri_Delete(bottomTextureUrn); middleTextureUrn = readTextureUrn(svReader, "Textures"); P_SetPtrp(sdef, DMU_MIDDLE_MATERIAL, DD_MaterialForTextureUri(middleTextureUrn)); Uri_Delete(middleTextureUrn); } } }
void SV_ReadSector(Sector *sec, MapStateReader *msr) { xsector_t *xsec = P_ToXSector(sec); Reader1 *reader = msr->reader(); int mapVersion = msr->mapVersion(); // A type byte? int type = 0; #if __JHEXEN__ if(mapVersion < 4) type = sc_ploff; else #else if(mapVersion <= 1) type = sc_normal; else #endif type = Reader_ReadByte(reader); // A version byte? int ver = 1; #if __JHEXEN__ if(mapVersion > 2) #else if(mapVersion > 4) #endif { ver = Reader_ReadByte(reader); } int fh = Reader_ReadInt16(reader); int ch = Reader_ReadInt16(reader); P_SetIntp(sec, DMU_FLOOR_HEIGHT, fh); P_SetIntp(sec, DMU_CEILING_HEIGHT, ch); #if __JHEXEN__ // Update the "target heights" of the planes. P_SetIntp(sec, DMU_FLOOR_TARGET_HEIGHT, fh); P_SetIntp(sec, DMU_CEILING_TARGET_HEIGHT, ch); // The move speed is not saved; can cause minor problems. P_SetIntp(sec, DMU_FLOOR_SPEED, 0); P_SetIntp(sec, DMU_CEILING_SPEED, 0); #endif world_Material *floorMaterial = 0, *ceilingMaterial = 0; #if !__JHEXEN__ if(mapVersion == 1) { // The flat numbers are absolute lump indices. de::Uri uri("Flats:", RC_NULL); uri.setPath(CentralLumpIndex()[Reader_ReadInt16(reader)].name().fileNameWithoutExtension()); floorMaterial = (world_Material *)P_ToPtr(DMU_MATERIAL, Materials_ResolveUri(reinterpret_cast<uri_s *>(&uri))); uri.setPath(CentralLumpIndex()[Reader_ReadInt16(reader)].name().fileNameWithoutExtension()); ceilingMaterial = (world_Material *)P_ToPtr(DMU_MATERIAL, Materials_ResolveUri(reinterpret_cast<uri_s *>(&uri))); } else if(mapVersion >= 4) #endif { // The flat numbers are actually archive numbers. floorMaterial = msr->material(Reader_ReadInt16(reader), 0); ceilingMaterial = msr->material(Reader_ReadInt16(reader), 0); } P_SetPtrp(sec, DMU_FLOOR_MATERIAL, floorMaterial); P_SetPtrp(sec, DMU_CEILING_MATERIAL, ceilingMaterial); if(ver >= 3) { P_SetIntp(sec, DMU_FLOOR_FLAGS, Reader_ReadInt16(reader)); P_SetIntp(sec, DMU_CEILING_FLAGS, Reader_ReadInt16(reader)); } byte lightlevel; #if __JHEXEN__ lightlevel = (byte) Reader_ReadInt16(reader); #else // In Ver1 the light level is a short if(mapVersion == 1) { lightlevel = (byte) Reader_ReadInt16(reader); } else { lightlevel = Reader_ReadByte(reader); } #endif P_SetFloatp(sec, DMU_LIGHT_LEVEL, (float) lightlevel / 255.f); #if !__JHEXEN__ if(mapVersion > 1) #endif { byte rgb[3]; Reader_Read(reader, rgb, 3); for(int i = 0; i < 3; ++i) P_SetFloatp(sec, DMU_COLOR_RED + i, rgb[i] / 255.f); } // Ver 2 includes surface colours if(ver >= 2) { byte rgb[3]; Reader_Read(reader, rgb, 3); for(int i = 0; i < 3; ++i) P_SetFloatp(sec, DMU_FLOOR_COLOR_RED + i, rgb[i] / 255.f); Reader_Read(reader, rgb, 3); for(int i = 0; i < 3; ++i) P_SetFloatp(sec, DMU_CEILING_COLOR_RED + i, rgb[i] / 255.f); } xsec->special = Reader_ReadInt16(reader); /*xsec->tag =*/ Reader_ReadInt16(reader); #if __JHEXEN__ xsec->seqType = seqtype_t(Reader_ReadInt16(reader)); #endif if(type == sc_ploff #if !__JHEXEN__ || type == sc_xg1 #endif ) { P_SetFloatp(sec, DMU_FLOOR_MATERIAL_OFFSET_X, Reader_ReadFloat(reader)); P_SetFloatp(sec, DMU_FLOOR_MATERIAL_OFFSET_Y, Reader_ReadFloat(reader)); P_SetFloatp(sec, DMU_CEILING_MATERIAL_OFFSET_X, Reader_ReadFloat(reader)); P_SetFloatp(sec, DMU_CEILING_MATERIAL_OFFSET_Y, Reader_ReadFloat(reader)); } #if !__JHEXEN__ if(type == sc_xg1) { SV_ReadXGSector(sec, reader, mapVersion); } #endif #if !__JHEXEN__ if(mapVersion <= 1) #endif { xsec->specialData = 0; } // We'll restore the sound targets latter on xsec->soundTarget = 0; }