diff --git a/src/dobject.cpp b/src/dobject.cpp index 191fa3c43..9d674d226 100644 --- a/src/dobject.cpp +++ b/src/dobject.cpp @@ -517,8 +517,8 @@ size_t DObject::StaticPointerSubstitution (DObject *old, DObject *notOld) #define SECTOR_CHECK(f,t) \ if (sectors[i].f.p == static_cast(old)) { sectors[i].f = static_cast(notOld); changed++; } SECTOR_CHECK( SoundTarget, AActor ); - SECTOR_CHECK( CeilingSkyBox, ASkyViewpoint ); - SECTOR_CHECK( FloorSkyBox, ASkyViewpoint ); + SECTOR_CHECK( SkyBoxes[sector_t::ceiling], ASkyViewpoint ); + SECTOR_CHECK( SkyBoxes[sector_t::floor], ASkyViewpoint ); SECTOR_CHECK( SecActTarget, ASectorAction ); SECTOR_CHECK( floordata, DSectorEffect ); SECTOR_CHECK( ceilingdata, DSectorEffect ); diff --git a/src/dobjgc.cpp b/src/dobjgc.cpp index d52962f11..3812c0b08 100644 --- a/src/dobjgc.cpp +++ b/src/dobjgc.cpp @@ -640,8 +640,8 @@ size_t DSectorMarker::PropagateMark() { sector_t *sec = §ors[SecNum + i]; GC::Mark(sec->SoundTarget); - GC::Mark(sec->CeilingSkyBox); - GC::Mark(sec->FloorSkyBox); + GC::Mark(sec->SkyBoxes[sector_t::ceiling]); + GC::Mark(sec->SkyBoxes[sector_t::floor]); GC::Mark(sec->SecActTarget); GC::Mark(sec->floordata); GC::Mark(sec->ceilingdata); diff --git a/src/g_shared/a_skies.cpp b/src/g_shared/a_skies.cpp index ef5623746..a8c8ebd55 100644 --- a/src/g_shared/a_skies.cpp +++ b/src/g_shared/a_skies.cpp @@ -67,13 +67,13 @@ void ASkyViewpoint::Destroy () // remove all sector references to ourselves. for (int i = 0; i CeilingSkyBox = box; + Sector->SkyBoxes[sector_t::ceiling] = box; if (box == NULL) Sector->MoreFlags |= SECF_NOCEILINGSKYBOX; // sector should ignore the level's default skybox } if (0 == (args[1] & 1)) { - Sector->FloorSkyBox = box; + Sector->SkyBoxes[sector_t::floor] = box; if (box == NULL) Sector->MoreFlags |= SECF_NOFLOORSKYBOX; // sector should ignore the level's default skybox } } diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index bcbc3deeb..d0aa237b8 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -418,7 +418,7 @@ void P_SerializeWorld (FArchive &arc) << sec->sky << sec->MoreFlags << sec->Flags - << sec->FloorSkyBox << sec->CeilingSkyBox + << sec->SkyBoxes[sector_t::floor] << sec->SkyBoxes[sector_t::ceiling] << sec->ZoneNumber; if (SaveVersion < 4529) { diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 6c5c08a56..83adc438f 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -805,16 +805,8 @@ int sector_t::GetCeilingLight () const ASkyViewpoint *sector_t::GetSkyBox(int which) { - if (which == floor) - { - if (FloorSkyBox != NULL) return FloorSkyBox; - if (MoreFlags & SECF_NOFLOORSKYBOX) return NULL; - } - else - { - if (CeilingSkyBox != NULL) return CeilingSkyBox; - if (MoreFlags & SECF_NOCEILINGSKYBOX) return NULL; - } + if (SkyBoxes[which] != NULL) return SkyBoxes[which]; + if (MoreFlags & (SECF_NOFLOORSKYBOX << which)) return NULL; return level.DefaultSkybox; } diff --git a/src/p_spec.cpp b/src/p_spec.cpp index e153e0fb8..1e91a13a0 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -912,10 +912,10 @@ static void SetupFloorPortal (AStackPoint *point) { NActorIterator it (NAME_LowerStackLookOnly, point->tid); sector_t *Sector = point->Sector; - Sector->FloorSkyBox = static_cast(it.Next()); - if (Sector->FloorSkyBox != NULL && Sector->FloorSkyBox->bAlways) + Sector->SkyBoxes[sector_t::floor] = static_cast(it.Next()); + if (Sector->SkyBoxes[sector_t::floor] != NULL && Sector->SkyBoxes[sector_t::floor]->bAlways) { - Sector->FloorSkyBox->Mate = point; + Sector->SkyBoxes[sector_t::floor]->Mate = point; if (Sector->GetAlpha(sector_t::floor) == OPAQUE) Sector->SetAlpha(sector_t::floor, Scale (point->args[0], OPAQUE, 255)); } @@ -925,48 +925,15 @@ static void SetupCeilingPortal (AStackPoint *point) { NActorIterator it (NAME_UpperStackLookOnly, point->tid); sector_t *Sector = point->Sector; - Sector->CeilingSkyBox = static_cast(it.Next()); - if (Sector->CeilingSkyBox != NULL && Sector->CeilingSkyBox->bAlways) + Sector->SkyBoxes[sector_t::ceiling] = static_cast(it.Next()); + if (Sector->SkyBoxes[sector_t::ceiling] != NULL && Sector->SkyBoxes[sector_t::ceiling]->bAlways) { - Sector->CeilingSkyBox->Mate = point; + Sector->SkyBoxes[sector_t::ceiling]->Mate = point; if (Sector->GetAlpha(sector_t::ceiling) == OPAQUE) Sector->SetAlpha(sector_t::ceiling, Scale (point->args[0], OPAQUE, 255)); } } -static bool SpreadCeilingPortal(AStackPoint *pt, fixed_t alpha, sector_t *sector) -{ - bool fail = false; - sector->validcount = validcount; - for(int i=0; ilinecount; i++) - { - line_t *line = sector->lines[i]; - sector_t *backsector = sector == line->frontsector? line->backsector : line->frontsector; - if (line->backsector == line->frontsector) continue; - if (backsector == NULL) { fail = true; continue; } - if (backsector->validcount == validcount) continue; - if (backsector->CeilingSkyBox == pt) continue; - - // Check if the backside would map to the same visplane - if (backsector->CeilingSkyBox != NULL) { fail = true; continue; } - if (backsector->ceilingplane != sector->ceilingplane) { fail = true; continue; } - if (backsector->lightlevel != sector->lightlevel) { fail = true; continue; } - if (backsector->GetTexture(sector_t::ceiling) != sector->GetTexture(sector_t::ceiling)) { fail = true; continue; } - if (backsector->GetXOffset(sector_t::ceiling) != sector->GetXOffset(sector_t::ceiling)) { fail = true; continue; } - if (backsector->GetYOffset(sector_t::ceiling) != sector->GetYOffset(sector_t::ceiling)) { fail = true; continue; } - if (backsector->GetXScale(sector_t::ceiling) != sector->GetXScale(sector_t::ceiling)) { fail = true; continue; } - if (backsector->GetYScale(sector_t::ceiling) != sector->GetYScale(sector_t::ceiling)) { fail = true; continue; } - if (backsector->GetAngle(sector_t::ceiling) != sector->GetAngle(sector_t::ceiling)) { fail = true; continue; } - if (SpreadCeilingPortal(pt, alpha, backsector)) { fail = true; continue; } - } - if (!fail) - { - sector->CeilingSkyBox = pt; - sector->SetAlpha(sector_t::ceiling, alpha); - } - return fail; -} - void P_SetupPortals() { TThinkerIterator it; @@ -994,9 +961,9 @@ static void SetPortal(sector_t *sector, int plane, ASkyViewpoint *portal, fixed_ // plane: 0=floor, 1=ceiling, 2=both if (plane > 0) { - if (sector->CeilingSkyBox == NULL || !sector->CeilingSkyBox->bAlways) + if (sector->SkyBoxes[sector_t::ceiling] == NULL || !sector->SkyBoxes[sector_t::ceiling]->bAlways) { - sector->CeilingSkyBox = portal; + sector->SkyBoxes[sector_t::ceiling] = portal; if (sector->GetAlpha(sector_t::ceiling) == OPAQUE) sector->SetAlpha(sector_t::ceiling, alpha); @@ -1005,9 +972,9 @@ static void SetPortal(sector_t *sector, int plane, ASkyViewpoint *portal, fixed_ } if (plane == 2 || plane == 0) { - if (sector->FloorSkyBox == NULL || !sector->FloorSkyBox->bAlways) + if (sector->SkyBoxes[sector_t::floor] == NULL || !sector->SkyBoxes[sector_t::floor]->bAlways) { - sector->FloorSkyBox = portal; + sector->SkyBoxes[sector_t::floor] = portal; } if (sector->GetAlpha(sector_t::floor) == OPAQUE) sector->SetAlpha(sector_t::floor, alpha); diff --git a/src/r_defs.h b/src/r_defs.h index eae8558d8..915316b32 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -389,7 +389,7 @@ enum SECF_DRAWN = 128, // sector has been drawn at least once SECF_HIDDEN = 256, // Do not draw on textured automap SECF_NOFLOORSKYBOX = 512, // force use of regular sky - SECF_NOCEILINGSKYBOX = 1024, // force use of regular sky + SECF_NOCEILINGSKYBOX = 1024, // force use of regular sky (do not separate from NOFLOORSKYBOX!!!) }; enum @@ -849,7 +849,7 @@ struct sector_t // [RH] The sky box to render for this sector. NULL means use a // regular sky. - TObjPtr FloorSkyBox, CeilingSkyBox; + TObjPtr SkyBoxes[2]; int sectornum; // for comparing sector copies diff --git a/src/wildmidi/wildmidi_lib.cpp b/src/wildmidi/wildmidi_lib.cpp index 0a01a9402..5f711bf35 100644 --- a/src/wildmidi/wildmidi_lib.cpp +++ b/src/wildmidi/wildmidi_lib.cpp @@ -1417,7 +1417,7 @@ get_sample_data(struct _patch *sample_patch, unsigned long int freq) { void _WM_AdjustNoteVolumes(struct _mdi *mdi, unsigned char ch, struct _note *nte) { double premix_dBm; double premix_lin; - unsigned char pan_ofs; + int pan_ofs; double premix_dBm_left; double premix_dBm_right; double premix_left; @@ -2893,7 +2893,7 @@ void WildMidi_Renderer::LongEvent(const unsigned char *data, int len) { sysex_ch -= 1; } - _event_data ev = { sysex_ch, static_cast(data[8]) }; + _event_data ev = { sysex_ch, data[8] }; do_sysex_roland_drum_track((_mdi *)handle, &ev); } else if (data[6] == 0x00 && data[7] == 0x7F && data[8] == 0x00)