From 9af1969cec6362631285acf5ced8d17a988a960f Mon Sep 17 00:00:00 2001 From: Fang Lu <cc2lufang@gmail.com> Date: Sun, 10 Dec 2017 20:20:49 -0600 Subject: [PATCH] osufs - integrate hitobject parsing NOT tested --- osufs/osufs.xcodeproj/project.pbxproj | 6 +++++ osufs/osufs/osu.cpp | 22 ++++++++++++++++--- .../osu_object_analyze/osu_object_parser.cpp | 6 +++-- osufs/osufs/osufs.h | 10 +++++---- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/osufs/osufs.xcodeproj/project.pbxproj b/osufs/osufs.xcodeproj/project.pbxproj index e09370d..3ff9fb0 100644 --- a/osufs/osufs.xcodeproj/project.pbxproj +++ b/osufs/osufs.xcodeproj/project.pbxproj @@ -629,6 +629,9 @@ 201233671FCD4F4400FCBFC8 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ADDRESS_SANITIZER_CONTAINER_OVERFLOW = YES; + CLANG_UNDEFINED_BEHAVIOR_SANITIZER_INTEGER = YES; + CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES; CODE_SIGN_STYLE = Automatic; PRODUCT_NAME = "$(TARGET_NAME)"; }; @@ -637,6 +640,9 @@ 201233681FCD4F4400FCBFC8 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ADDRESS_SANITIZER_CONTAINER_OVERFLOW = YES; + CLANG_UNDEFINED_BEHAVIOR_SANITIZER_INTEGER = YES; + CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES; CODE_SIGN_STYLE = Automatic; PRODUCT_NAME = "$(TARGET_NAME)"; }; diff --git a/osufs/osufs/osu.cpp b/osufs/osufs/osu.cpp index 2fea11b..85a0313 100644 --- a/osufs/osufs/osu.cpp +++ b/osufs/osufs/osu.cpp @@ -195,6 +195,8 @@ osu_song osu_read_osu(const char *filename, mdev *dev, osu_meta *meta, memset(&ret, 0xcc, sizeof(ret)); strncpy(ret.magic, "DEAD", 4); + ret.combo_colors_start = 0; + ret.storyboard = NULL; sprintf(line, "%s/%s", cont->dirname, filename); @@ -279,7 +281,7 @@ int osu_parse_general(char *line, osu_song *song, return 1; } // AudioFilename (String) specifies the location of the audio file relative to the current folder. - if (strcasecmp(key, "AudioFilename") == 0) { + if (0 && strcasecmp(key, "AudioFilename") == 0) { if (cont->fs.find(val) == cont->fs.end()) { printf("Allocating storage for audio %s\n", val); uint32_t addr = meta->available_block; @@ -479,6 +481,7 @@ int osu_parse_difficulty(char *line, osu_song *song, int osu_parse_events(char *line, osu_song *song, mdev *dev, osu_meta *meta, osu_dir *cont) { // Events section is in CSV format + return 0; switch (line[0]) { case '0': { // Background image @@ -538,11 +541,24 @@ int osu_parse_colors(char *line, osu_song *song, return 1; } - if (strncasecmp(key, "Combo",5) != 0) { + int r, g, b; + + if (strncasecmp(key, "SliderBody", 10) == 0) { + if (sscanf(val, "%d,%d,%d", &r, &g, &b) != 3) { + fprintf(stderr, "Warning: bad SliderBody color: %s\n", val); + return 1; + } + song->combo_slider_color[0] = r; + song->combo_slider_color[1] = g; + song->combo_slider_color[2] = b; + return 0; + } + + if (strncasecmp(key, "Combo", 5) != 0) { return 0; } - int n = key[6] - '1', r, g, b; + int n = key[5] - '1'; if (sscanf(val, "%d,%d,%d", &r, &g, &b) != 3) { fprintf(stderr, "Warning: bad combo color: %s\n", val); return 1; diff --git a/osufs/osufs/osu_object_analyze/osu_object_parser.cpp b/osufs/osufs/osu_object_analyze/osu_object_parser.cpp index d26440c..7146857 100644 --- a/osufs/osufs/osu_object_analyze/osu_object_parser.cpp +++ b/osufs/osufs/osu_object_analyze/osu_object_parser.cpp @@ -74,7 +74,7 @@ int osu_parse_hit_object(char* line, osu_song* song){ break; } //update count and data block - if (song->storyboard){ + if (!song->storyboard){ song->storyboard = (uint8_t *) malloc(4+4+32*temp_c); *((uint32_t*)(song->storyboard)) = 0b01110010011001010110000101101100; *((uint32_t*)(song->storyboard)+1) = temp_c; @@ -89,7 +89,9 @@ int osu_parse_hit_object(char* line, osu_song* song){ return 0; } -void string_split(char* dup, const char* delim, vector<string> & v){ +void string_split(char* line, const char* delim, vector<string> & v){ + char dup[1024]; + strncpy(dup, line, 1024); char * token = strtok(dup, delim); while(token != NULL){ v.push_back(string(token)); diff --git a/osufs/osufs/osufs.h b/osufs/osufs/osufs.h index 7a97d15..a4b2458 100644 --- a/osufs/osufs/osufs.h +++ b/osufs/osufs/osufs.h @@ -228,11 +228,13 @@ extern "C" { uint16_t stack_leniency; // 78 - 79 //for analyze side only - uint8_t combo_colors_count; // 80 - 80 - uint8_t combo_colors_start; // 81 - 81 - uint8_t *storyboard; // 82 - 89 + uint8_t *storyboard; // 80 - 87 + uint8_t combo_colors_count; // 88 + uint8_t combo_colors_start; // 89 + uint8_t combo_slider_color[3]; // 90 - 92 - char _padding[230]; // 90 - 319 + + char _padding[227]; // 93 - 319 char title[64]; // 320 - 383 char artist[64]; // 384 - 447 -- GitLab