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 T_FloorWaggle(waggle_t *waggle) { DENG_ASSERT(waggle != 0); switch(waggle->state) { default: case WS_STABLE: if(waggle->ticker != -1) { if(!--waggle->ticker) { waggle->state = WS_REDUCE; } } break; case WS_EXPAND: if((waggle->scale += waggle->scaleDelta) >= waggle->targetScale) { waggle->scale = waggle->targetScale; waggle->state = WS_STABLE; } break; case WS_REDUCE: if((waggle->scale -= waggle->scaleDelta) <= 0) { // Remove. P_SetDoublep(waggle->sector, DMU_FLOOR_HEIGHT, waggle->originalHeight); P_ChangeSector(waggle->sector, 1 /*crush damage*/); P_ToXSector(waggle->sector)->specialData = nullptr; P_NotifySectorFinished(P_ToXSector(waggle->sector)->tag); Thinker_Remove(&waggle->thinker); return; } break; } waggle->accumulator += waggle->accDelta; coord_t fh = waggle->originalHeight + FLOATBOBOFFSET(((int) waggle->accumulator) & 63) * waggle->scale; P_SetDoublep(waggle->sector, DMU_FLOOR_HEIGHT, fh); P_SetDoublep(waggle->sector, DMU_FLOOR_TARGET_HEIGHT, fh); P_SetFloatp(waggle->sector, DMU_FLOOR_SPEED, 0); P_ChangeSector(waggle->sector, 1 /*crush damage*/); }
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); } } }