diff --git a/src/level/level.cpp b/src/level/level.cpp index 9e13194..3c810dc 100644 --- a/src/level/level.cpp +++ b/src/level/level.cpp @@ -596,6 +596,11 @@ void FProcessor::BuildNodes() void FProcessor::BuildLightmaps(const char *configFile) { + LMBuilder.ambience = 0.0f; + LMBuilder.samples = 64; + LMBuilder.textureWidth = LIGHTMAP_MAX_SIZE; + LMBuilder.textureHeight = LIGHTMAP_MAX_SIZE; + Level.ParseConfigFile(configFile); Level.SetupDlight(); Surface_AllocateFromMap(Level); diff --git a/src/level/level_udmf.cpp b/src/level/level_udmf.cpp index 674b072..c852331 100644 --- a/src/level/level_udmf.cpp +++ b/src/level/level_udmf.cpp @@ -182,6 +182,7 @@ void FProcessor::ParseLinedef(IntLineDef *ld) { SC_MustGetStringName("{"); ld->v1 = ld->v2 = ld->sidenum[0] = ld->sidenum[1] = NO_INDEX; + ld->flags = 0; ld->special = 0; while (!SC_CheckString("}")) { @@ -206,6 +207,19 @@ void FProcessor::ParseLinedef(IntLineDef *ld) { ld->args[0] = CheckInt(key); } + else if (!stricmp(key, "blocking") && !stricmp(value, "true")) + { + ld->flags |= ML_BLOCKING; + } + else if (!stricmp(key, "blockmonsters") && !stricmp(value, "true")) + { + ld->flags |= ML_BLOCKMONSTERS; + } + else if (!stricmp(key, "twosided") && !stricmp(value, "true")) + { + ld->flags |= ML_TWOSIDED; + } + if (!stricmp(key, "sidefront")) { ld->sidenum[0] = CheckInt(key); @@ -256,16 +270,64 @@ void FProcessor::ParseSidedef(IntSideDef *sd) // //=========================================================================== +static void CopyUDMFString(char *dest, int destlen, const char *udmfvalue) +{ + destlen--; + + char endchar = 0; + if (udmfvalue[0] == '"' || udmfvalue[0] == '\'') + { + endchar = udmfvalue[0]; + udmfvalue++; + } + + for (int i = 0; i < destlen && udmfvalue[i] != 0 && udmfvalue[i] != endchar; i++) + { + *(dest++) = udmfvalue[i]; + } + + *dest = 0; +} + void FProcessor::ParseSector(IntSector *sec) { + memset(&sec->data, 0, sizeof(sec->data)); + sec->data.lightlevel = 160; + SC_MustGetStringName("{"); while (!SC_CheckString("}")) { const char *value; const char *key = ParseKey(value); - // No specific sector properties are ever used by the node builder - // so everything can go directly to the props array. + if (stricmp(key, "textureceiling") == 0) + { + CopyUDMFString(sec->data.ceilingpic, 8, value); + } + else if (stricmp(key, "texturefloor") == 0) + { + CopyUDMFString(sec->data.floorpic, 8, value); + } + else if (stricmp(key, "heightceiling") == 0) + { + sec->data.ceilingheight = CheckFloat(key); + } + else if (stricmp(key, "heightfloor") == 0) + { + sec->data.floorheight = CheckFloat(key); + } + else if (stricmp(key, "lightlevel") == 0) + { + sec->data.lightlevel = CheckInt(key); + } + else if (stricmp(key, "special") == 0) + { + sec->data.special = CheckInt(key); + } + else if (stricmp(key, "id") == 0) + { + sec->data.tag = CheckInt(key); + } // now store the key in its unprocessed form UDMFKey k = {key, value}; diff --git a/src/lightmap/lightmap.cpp b/src/lightmap/lightmap.cpp index 7aa14f0..a311b45 100644 --- a/src/lightmap/lightmap.cpp +++ b/src/lightmap/lightmap.cpp @@ -902,8 +902,8 @@ void kexLightmapBuilder::CreateLightGrid() // determine the size of the grid block for(int i = 0; i < 3; ++i) { - mins[i] = gridSize[i] * kexMath::Ceil(worldGrid.min[i] / gridSize[i]); - maxs[i] = gridSize[i] * kexMath::Floor(worldGrid.max[i] / gridSize[i]); + mins[i] = gridSize[i] * kexMath::Floor(worldGrid.min[i] / gridSize[i]); + maxs[i] = gridSize[i] * kexMath::Ceil(worldGrid.max[i] / gridSize[i]); gridBlock[i] = (maxs[i] - mins[i]) / gridSize[i] + 1; } diff --git a/src/lightmap/mapdata.cpp b/src/lightmap/mapdata.cpp index ee575de..df209eb 100644 --- a/src/lightmap/mapdata.cpp +++ b/src/lightmap/mapdata.cpp @@ -259,7 +259,7 @@ IntSector *FLevel::GetBackSector(const MapSegGLEx *seg) IntLineDef *line = &Lines[seg->linedef]; - if (line->flags & ML_TWOSIDED) + if ((line->flags & ML_TWOSIDED) && line->sidenum[seg->side ^ 1] != 0xffffffff) { IntSideDef *backSide = &Sides[line->sidenum[seg->side ^ 1]]; return &Sectors[backSide->sector];