diff --git a/Makefile b/Makefile index abc4057..981af8d 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ endif all: CFLAGS := -O3 all: radiusGenerator modelGenerator chunkExtractor regionFileReader -debug: CFLAGS := -Wall -Werror -Wpedantic +debug: CFLAGS := -Wall -Werror -Wpedantic -g debug: radiusGenerator modelGenerator chunkExtractor regionFileReader cNBT.o: diff --git a/chunkParser.c b/chunkParser.c index 5a613fc..5c15fcf 100644 --- a/chunkParser.c +++ b/chunkParser.c @@ -147,7 +147,7 @@ unsigned int getSections(unsigned char* nbtFileData, long sz, section* sections) propertyString = appendProperty(propertyString, north, "north"); } if(open != NULL){ - propertyString = appendProperty(propertyString, part, "open"); + propertyString = appendProperty(propertyString, open, "open"); } if(part != NULL){ propertyString = appendProperty(propertyString, part, "part"); diff --git a/mtlGen.py b/mtlGen.py index bc1f21f..824bae2 100755 --- a/mtlGen.py +++ b/mtlGen.py @@ -67,6 +67,8 @@ def writeMaterialSection(o:TextIOWrapper, name:str, rgb:tuple, d:float) -> None: rgb[2] = 113 / 255 if "top" in filename and t: filename = filename.replace("_top", "", 1) + if "water_still" in filename: + writeMaterialSection(o, filename[:-4].replace("_still", ""), rgb, rgb[3]) writeMaterialSection(o, filename[:-4], rgb, rgb[3]) else: writeMaterialSection(o, filename[:-4], (1, 1, 1), 1) diff --git a/radiusGenerator.c b/radiusGenerator.c index 6ca91be..e814e04 100644 --- a/radiusGenerator.c +++ b/radiusGenerator.c @@ -296,37 +296,46 @@ int main(int argc, char** argv){ printf("%.2f%% done\r", ((float)progress / (float)numChildren) * 100); fflush(stdout); //in theory we have to check the WIFEXITED - if(WIFEXITED(status) && WEXITSTATUS(status) == EXIT_SUCCESS){ - int childNum = 0; - for(int i = 0; i < counter; i++){ - if(childrenPids[i] == wpid){ - childNum = i; - break; + if(WIFEXITED(status)){ + int exitStatus = WEXITSTATUS(status); + if(exitStatus == EXIT_SUCCESS){ + int childNum = 0; + for(int i = 0; i < counter; i++){ + if(childrenPids[i] == wpid){ + childNum = i; + break; + } } + size_t size = -1; + ssize_t res = read(fd[childNum][READ_END], &size, sizeof(size_t)); + if(res < 0){ + pipeError("parent", "reading 1"); + } + if(size < 1){ + pipeError("parent", "reading-size value invalid"); + } + parts[childNum] = malloc(size); + close(fd[childNum][READ_END]); + int shmid = shmget(parentId + childNum, size, 0644); + if(shmid < 0){ + shmError("parent shmget"); + } + char* shmBuffer = (char*)shmat(shmid, NULL, 0); + if(shmBuffer == NULL){ + shmError("parent shmat"); + } + strcpy(parts[childNum], shmBuffer); + shmdt(shmBuffer); + //having done what we wanted to do now we can just remove this shared segment + shmctl(shmid, IPC_RMID, 0); + currentSize += size; } - size_t size = -1; - ssize_t res = read(fd[childNum][READ_END], &size, sizeof(size_t)); - if(res < 0){ - pipeError("parent", "reading 1"); - } - if(size < 1){ - pipeError("parent", "reading-size value invalid"); - } - parts[childNum] = malloc(size); - close(fd[childNum][READ_END]); - int shmid = shmget(parentId + childNum, size, 0644); - if(shmid < 0){ - shmError("parent shmget"); - } - char* shmBuffer = (char*)shmat(shmid, NULL, 0); - if(shmBuffer == NULL){ - shmError("parent shmat"); + else{ + fprintf(stderr, "Process %d failed with exit status:%d", wpid, exitStatus); } - strcpy(parts[childNum], shmBuffer); - shmdt(shmBuffer); - //having done what we wanted to do now we can just remove this shared segment - shmctl(shmid, IPC_RMID, 0); - currentSize += size; + } + else if(WIFSIGNALED(status)){ + fprintf(stderr, "Process %d failed by signal %s.\n", wpid, strsignal(WTERMSIG(status))); } else{ fprintf(stderr, "Process %d failed.\n", wpid);