void P_CopyLine(Line *dest, Line *src) { xline_t *xsrc = P_ToXLine(src); xline_t *xdest = P_ToXLine(dest); if(src == dest) return; // no point copying self // Copy the built-in properties for(int i = 0; i < 2; ++i) // For each side { int sidx = (i==0? DMU_FRONT : DMU_BACK); Side *sidefrom = (Side *)P_GetPtrp(src, sidx); Side *sideto = (Side *)P_GetPtrp(dest, sidx); if(!sidefrom || !sideto) continue; float temp[4]; coord_t itemp[2]; P_SetPtrp (sideto, DMU_TOP_MATERIAL, P_GetPtrp(sidefrom, DMU_TOP_MATERIAL)); P_GetDoublepv(sidefrom, DMU_TOP_MATERIAL_OFFSET_XY, itemp); P_SetDoublepv(sideto, DMU_TOP_MATERIAL_OFFSET_XY, itemp); P_GetFloatpv (sidefrom, DMU_TOP_COLOR, temp); P_SetFloatpv (sideto, DMU_TOP_COLOR, temp); P_SetPtrp (sideto, DMU_MIDDLE_MATERIAL, P_GetPtrp(sidefrom, DMU_MIDDLE_MATERIAL)); P_GetDoublepv(sidefrom, DMU_MIDDLE_MATERIAL_OFFSET_XY, itemp); P_SetDoublepv(sideto, DMU_MIDDLE_MATERIAL_OFFSET_XY, itemp); P_SetFloatpv (sideto, DMU_MIDDLE_COLOR, temp); P_SetIntp (sideto, DMU_MIDDLE_BLENDMODE, P_GetIntp(sidefrom, DMU_MIDDLE_BLENDMODE)); P_SetPtrp (sideto, DMU_BOTTOM_MATERIAL, P_GetPtrp(sidefrom, DMU_BOTTOM_MATERIAL)); P_GetDoublepv(sidefrom, DMU_BOTTOM_MATERIAL_OFFSET_XY, itemp); P_SetDoublepv(sideto, DMU_BOTTOM_MATERIAL_OFFSET_XY, itemp); P_GetFloatpv (sidefrom, DMU_BOTTOM_COLOR, temp); P_SetFloatpv (sideto, DMU_BOTTOM_COLOR, temp); } // Copy the extended properties too #if __JDOOM__ || __JHERETIC__ || __JDOOM64__ xdest->special = xsrc->special; xdest->tag = xsrc->tag; if(xsrc->xg && xdest->xg) std::memcpy(xdest->xg, xsrc->xg, sizeof(*xdest->xg)); else xdest->xg = 0; #else xdest->special = xsrc->special; xdest->arg1 = xsrc->arg1; xdest->arg2 = xsrc->arg2; xdest->arg3 = xsrc->arg3; xdest->arg4 = xsrc->arg4; xdest->arg5 = xsrc->arg5; #endif }
void P_CopySector(Sector *dest, Sector *src) { xsector_t *xsrc = P_ToXSector(src); xsector_t *xdest = P_ToXSector(dest); if(src == dest) return; // no point copying self. // Copy the built-in properties. float ftemp[4]; coord_t dtemp[2]; P_SetFloatp (dest, DMU_LIGHT_LEVEL, P_GetFloatp(src, DMU_LIGHT_LEVEL)); P_GetFloatpv (src, DMU_COLOR, ftemp); P_SetFloatpv (dest, DMU_COLOR, ftemp); P_SetDoublep (dest, DMU_FLOOR_HEIGHT, P_GetDoublep(src, DMU_FLOOR_HEIGHT)); P_SetPtrp (dest, DMU_FLOOR_MATERIAL, P_GetPtrp(src, DMU_FLOOR_MATERIAL)); P_GetFloatpv (src, DMU_FLOOR_COLOR, ftemp); P_SetFloatpv (dest, DMU_FLOOR_COLOR, ftemp); P_GetDoublepv(src, DMU_FLOOR_MATERIAL_OFFSET_XY, dtemp); P_SetDoublepv(dest, DMU_FLOOR_MATERIAL_OFFSET_XY, dtemp); P_SetIntp (dest, DMU_FLOOR_SPEED, P_GetIntp(src, DMU_FLOOR_SPEED)); P_SetDoublep (dest, DMU_FLOOR_TARGET_HEIGHT, P_GetFloatp(src, DMU_FLOOR_TARGET_HEIGHT)); P_SetDoublep (dest, DMU_CEILING_HEIGHT, P_GetDoublep(src, DMU_CEILING_HEIGHT)); P_SetPtrp (dest, DMU_CEILING_MATERIAL, P_GetPtrp(src, DMU_CEILING_MATERIAL)); P_GetFloatpv (src, DMU_CEILING_COLOR, ftemp); P_SetFloatpv (dest, DMU_CEILING_COLOR, ftemp); P_GetDoublepv(src, DMU_CEILING_MATERIAL_OFFSET_XY, dtemp); P_SetDoublepv(dest, DMU_CEILING_MATERIAL_OFFSET_XY, dtemp); P_SetIntp (dest, DMU_CEILING_SPEED, P_GetIntp(src, DMU_CEILING_SPEED)); P_SetDoublep (dest, DMU_CEILING_TARGET_HEIGHT, P_GetFloatp(src, DMU_CEILING_TARGET_HEIGHT)); // Copy the extended properties too #if __JDOOM__ || __JHERETIC__ || __JDOOM64__ xdest->special = xsrc->special; xdest->soundTraversed = xsrc->soundTraversed; xdest->soundTarget = xsrc->soundTarget; #if __JHERETIC__ xdest->seqType = xsrc->seqType; #endif xdest->SP_floororigheight = xsrc->SP_floororigheight; xdest->SP_ceilorigheight = xsrc->SP_ceilorigheight; xdest->origLight = xsrc->origLight; std::memcpy(xdest->origRGB, xsrc->origRGB, sizeof(float) * 3); if(xsrc->xg && xdest->xg) std::memcpy(xdest->xg, xsrc->xg, sizeof(*xdest->xg)); else xdest->xg = 0; #else xdest->special = xsrc->special; xdest->soundTraversed = xsrc->soundTraversed; xdest->soundTarget = xsrc->soundTarget; xdest->seqType = xsrc->seqType; #endif }
void P_TranslatePlaneMaterialOrigin(Plane* plane, float deltaXY[2]) { float origin[2]; DENG_ASSERT(plane); if(FEQUAL(deltaXY[0], 0) && FEQUAL(deltaXY[1], 0)) return; P_GetFloatpv(plane, DMU_OFFSET_XY, origin); if(!FEQUAL(deltaXY[0], 0)) { origin[0] += deltaXY[0]; } if(!FEQUAL(deltaXY[1], 0)) { origin[1] += deltaXY[1]; } P_SetFloatpv(plane, DMU_OFFSET_XY, origin); }
void P_TranslateSideMaterialOrigin(Side* side, SideSection section, float deltaXY[2]) { DENG_ASSERT(side); DENG_ASSERT(VALID_SIDESECTION(section)); { const uint dmuSurfaceOriginFlags = DMU_OFFSET_XY | DMU_FLAG_FOR_SIDESECTION(section); float origin[2]; if(FEQUAL(deltaXY[0], 0) && FEQUAL(deltaXY[1], 0)) return; P_GetFloatpv(side, dmuSurfaceOriginFlags, origin); if(!FEQUAL(deltaXY[0], 0)) { origin[0] += deltaXY[0]; } if(!FEQUAL(deltaXY[1], 0)) { origin[1] += deltaXY[1]; } P_SetFloatpv(side, dmuSurfaceOriginFlags, origin); }}
/** * Reads all versions of archived lines. * Including the old Ver1. */ void SV_ReadLine(Line *li, MapStateReader *msr) { xline_t *xli = P_ToXLine(li); Reader1 *reader = msr->reader(); int mapVersion = msr->mapVersion(); bool xgDataFollows = false; #if __JHEXEN__ if(mapVersion >= 4) #else if(mapVersion >= 2) #endif { xgDataFollows = Reader_ReadByte(reader) == 1; } #ifdef __JHEXEN__ DENG2_UNUSED(xgDataFollows); #endif // A version byte? int ver = 1; #if __JHEXEN__ if(mapVersion >= 3) #else if(mapVersion >= 5) #endif { ver = (int) Reader_ReadByte(reader); } if(ver >= 4) { P_SetIntp(li, DMU_FLAGS, Reader_ReadInt16(reader)); } int flags = Reader_ReadInt16(reader); if(xli->flags & ML_TWOSIDED) { flags |= ML_TWOSIDED; } if(ver < 4) { // Translate old line flags. int ddLineFlags = 0; if(flags & 0x0001) // old ML_BLOCKING flag { ddLineFlags |= DDLF_BLOCKING; flags &= ~0x0001; } if(flags & 0x0008) // old ML_DONTPEGTOP flag { ddLineFlags |= DDLF_DONTPEGTOP; flags &= ~0x0008; } if(flags & 0x0010) // old ML_DONTPEGBOTTOM flag { ddLineFlags |= DDLF_DONTPEGBOTTOM; flags &= ~0x0010; } P_SetIntp(li, DMU_FLAGS, ddLineFlags); } if(ver < 3) { if(flags & ML_MAPPED) { int lineIDX = P_ToIndex(li); // Set line as having been seen by all players.. de::zap(xli->mapped); for(int i = 0; i < MAXPLAYERS; ++i) { P_SetLineAutomapVisibility(i, lineIDX, true); } } } xli->flags = flags; if(ver >= 3) { for(int i = 0; i < MAXPLAYERS; ++i) { xli->mapped[i] = Reader_ReadByte(reader); } } #if __JHEXEN__ xli->special = Reader_ReadByte(reader); xli->arg1 = Reader_ReadByte(reader); xli->arg2 = Reader_ReadByte(reader); xli->arg3 = Reader_ReadByte(reader); xli->arg4 = Reader_ReadByte(reader); xli->arg5 = Reader_ReadByte(reader); #else xli->special = Reader_ReadInt16(reader); /*xli->tag =*/ Reader_ReadInt16(reader); #endif // For each side for(int i = 0; i < 2; ++i) { Side *si = (Side *)P_GetPtrp(li, (i? DMU_BACK:DMU_FRONT)); if(!si) continue; // Versions latter than 2 store per surface texture offsets. if(ver >= 2) { float offset[2]; offset[VX] = (float) Reader_ReadInt16(reader); offset[VY] = (float) Reader_ReadInt16(reader); P_SetFloatpv(si, DMU_TOP_MATERIAL_OFFSET_XY, offset); offset[VX] = (float) Reader_ReadInt16(reader); offset[VY] = (float) Reader_ReadInt16(reader); P_SetFloatpv(si, DMU_MIDDLE_MATERIAL_OFFSET_XY, offset); offset[VX] = (float) Reader_ReadInt16(reader); offset[VY] = (float) Reader_ReadInt16(reader); P_SetFloatpv(si, DMU_BOTTOM_MATERIAL_OFFSET_XY, offset); } else { float offset[2]; offset[VX] = (float) Reader_ReadInt16(reader); offset[VY] = (float) Reader_ReadInt16(reader); P_SetFloatpv(si, DMU_TOP_MATERIAL_OFFSET_XY, offset); P_SetFloatpv(si, DMU_MIDDLE_MATERIAL_OFFSET_XY, offset); P_SetFloatpv(si, DMU_BOTTOM_MATERIAL_OFFSET_XY, offset); } if(ver >= 3) { P_SetIntp(si, DMU_TOP_FLAGS, Reader_ReadInt16(reader)); P_SetIntp(si, DMU_MIDDLE_FLAGS, Reader_ReadInt16(reader)); P_SetIntp(si, DMU_BOTTOM_FLAGS, Reader_ReadInt16(reader)); } world_Material *topMaterial = 0, *bottomMaterial = 0, *middleMaterial = 0; #if !__JHEXEN__ if(mapVersion >= 4) #endif { topMaterial = msr->material(Reader_ReadInt16(reader), 1); bottomMaterial = msr->material(Reader_ReadInt16(reader), 1); middleMaterial = msr->material(Reader_ReadInt16(reader), 1); } P_SetPtrp(si, DMU_TOP_MATERIAL, topMaterial); P_SetPtrp(si, DMU_BOTTOM_MATERIAL, bottomMaterial); P_SetPtrp(si, DMU_MIDDLE_MATERIAL, middleMaterial); // Ver2 includes surface colours if(ver >= 2) { float rgba[4]; int flags; for(int k = 0; k < 3; ++k) rgba[k] = (float) Reader_ReadByte(reader) / 255.f; rgba[3] = 1; P_SetFloatpv(si, DMU_TOP_COLOR, rgba); for(int k = 0; k < 3; ++k) rgba[k] = (float) Reader_ReadByte(reader) / 255.f; rgba[3] = 1; P_SetFloatpv(si, DMU_BOTTOM_COLOR, rgba); for(int k = 0; k < 4; ++k) rgba[k] = (float) Reader_ReadByte(reader) / 255.f; P_SetFloatpv(si, DMU_MIDDLE_COLOR, rgba); P_SetIntp(si, DMU_MIDDLE_BLENDMODE, Reader_ReadInt32(reader)); flags = Reader_ReadInt16(reader); if(mapVersion < 12) { if(P_GetIntp(si, DMU_FLAGS) & SDF_SUPPRESS_BACK_SECTOR) flags |= SDF_SUPPRESS_BACK_SECTOR; } P_SetIntp(si, DMU_FLAGS, flags); } } #if !__JHEXEN__ if(xgDataFollows) { SV_ReadXGLine(li, msr); } #endif }