Skip to content

Commit

Permalink
major bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
amelted authored Oct 23, 2020
1 parent 4221e52 commit 12c354a
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 60 deletions.
137 changes: 80 additions & 57 deletions QuickNoodle/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ private List<string> parseBookmarks(dynamic bookmarks, dynamic map)
// {"r=0.0,0.0,0.0", "b=1.0,1.0,1.0", "offset=-0.1"}

#region defining stuff for later use
int[] reds = new int[3] { -1, -1, -1 };
int[] blues = new int[3] { -1, -1, -1 };
float[] reds = new float[3] { -1, -1, -1 };
float[] blues = new float[3] { -1, -1, -1 };

int[] noteReds = new int[3] { -1, -1, -1 };
int[] noteBlues = new int[3] { -1, -1, -1 };
float[] noteReds = new float[3] { -1, -1, -1 };
float[] noteBlues = new float[3] { -1, -1, -1 };

int[] eventReds = new int[3] { -1, -1, -1 };
int[] eventBlues = new int[3] { -1, -1, -1 };
float[] eventReds = new float[3] { -1, -1, -1 };
float[] eventBlues = new float[3] { -1, -1, -1 };

float[] worldRotation = new float[3] { 0.0f, 0.0f, 0.0f };
float[] noteRotation = new float[3] { 0.0f, 0.0f, 0.0f };
Expand Down Expand Up @@ -146,23 +146,23 @@ private List<string> parseBookmarks(dynamic bookmarks, dynamic map)
if (noteRed.Length != 3)
{
log.WriteLine("Note Red color only has one value, skipping");
noteReds = new int[3] { -1, -1, -1 };
noteReds = new float[3] { -1, -1, -1 };
break;
}

for (int i = 0; i < 3; i++)
{
string flot = noteRed[i];

if (int.TryParse(flot, out int fa))
if (float.TryParse(flot, out float fa))
{
reds[i] = fa;
reds[i] = fa / 255;

}
else
{
log.WriteLine($"Error whilst decoding red note colors on bookmark at {time}, skipping");
noteReds = new int[3] { -1, -1, -1 };
noteReds = new float[3] { -1, -1, -1 };

break;
}
Expand All @@ -177,23 +177,23 @@ private List<string> parseBookmarks(dynamic bookmarks, dynamic map)
if (noteBlue.Length != 3)
{
log.WriteLine("Note blue color only has one value, skipping");
noteBlues = new int[3] { -1, -1, -1 };
noteBlues = new float[3] { -1, -1, -1 };
break;
}

for (int i = 0; i < 3; i++)
{
string flot = noteBlue[i];

if (int.TryParse(flot, out int fa))
if (float.TryParse(flot, out float fa))
{
noteBlues[i] = fa;
noteBlues[i] = fa / 255;

}
else
{
log.WriteLine($"Error whilst decoding blue note colors on bookmark at {time}, skipping");
noteBlues = new int[3] { -1, -1, -1 };
noteBlues = new float[3] { -1, -1, -1 };

break;
}
Expand All @@ -208,23 +208,23 @@ private List<string> parseBookmarks(dynamic bookmarks, dynamic map)
if (eventRed.Length != 3)
{
log.WriteLine("Event Red color only has one value, skipping");
eventReds = new int[3] { -1, -1, -1 };
eventReds = new float[3] { -1, -1, -1 };
break;
}

for (int i = 0; i < 3; i++)
{
string flot = eventRed[i];

if (int.TryParse(flot, out int fa))
if (float.TryParse(flot, out float fa))
{
eventReds[i] = fa;
eventReds[i] = fa / 255;

}
else
{
log.WriteLine($"Error whilst decoding red event colors on bookmark at {time}, skipping");
eventReds = new int[3] { -1, -1, -1 };
eventReds = new float[3] { -1, -1, -1 };

break;
}
Expand All @@ -239,23 +239,23 @@ private List<string> parseBookmarks(dynamic bookmarks, dynamic map)
if (eventBlue.Length != 3)
{
log.WriteLine("Event Blue color only has one value, skipping");
eventBlues = new int[3] { -1, -1, -1 };
eventBlues = new float[3] { -1, -1, -1 };
break;
}

for (int i = 0; i < 3; i++)
{
string flot = eventBlue[i];

if (int.TryParse(flot, out int fa))
if (float.TryParse(flot, out float fa))
{
eventBlues[i] = fa;
eventBlues[i] = fa / 255;

}
else
{
log.WriteLine($"Error whilst decoding blue evemt colors on bookmark at {time}, skipping");
eventBlues = new int[3] { -1, -1, -1 };
eventBlues = new float[3] { -1, -1, -1 };

break;
}
Expand All @@ -271,7 +271,7 @@ private List<string> parseBookmarks(dynamic bookmarks, dynamic map)
if (red.Length != 3)
{
log.WriteLine("Red color only has one value, skipping");
reds = new int[3] { -1, -1, -1 };
reds = new float[3] { -1, -1, -1 };
break;
}

Expand All @@ -280,15 +280,15 @@ private List<string> parseBookmarks(dynamic bookmarks, dynamic map)
{
string flot = red[i];

if (int.TryParse(flot, out int fa))
if (float.TryParse(flot, out float fa))
{
reds[i] = fa;
reds[i] = fa / 255;

}
else
{
log.WriteLine($"Error whilst decoding red colors on bookmark at {time}, skipping");
reds = new int[3] { -1, -1, -1 };
reds = new float[3] { -1, -1, -1 };

break;
}
Expand All @@ -304,21 +304,21 @@ private List<string> parseBookmarks(dynamic bookmarks, dynamic map)
if (blue.Length != 3)
{
log.WriteLine("Blue color only has one value, skipping");
blues = new int[3] { -1, -1, -1 };
blues = new float[3] { -1, -1, -1 };
break;
}
for (int i = 0; i < 3; i++)
{
string flot = blue[i];
if (int.TryParse(flot, out int fl))
if (float.TryParse(flot, out float fl))
{
blues[i] = fl;
blues[i] = fl / 255;

}
else
{
log.WriteLine($"Error whilst decoding blue color value on bookmark at {time}, skipping");
blues = new int[3] { -1, -1, -1 };
blues = new float[3] { -1, -1, -1 };

break;
}
Expand Down Expand Up @@ -495,7 +495,7 @@ private void addCustomDataToMap(dynamic map)
}

// Ignore my spaghetti please
public void newProcessing(int[] reds, int[] blues, int[] noteReds, int[] noteBlues, int[] eventReds, int[] eventBlues, float[] worldRotation, float[] noteRotation, float noteSpawnOffset, float noteJumpSpeed, bool isNull, float time, dynamic mapCopy, dynamic next, int bookmarkNumber)
public void newProcessing(float[] reds, float[] blues, float[] noteReds, float[] noteBlues, float[] eventReds, float[] eventBlues, float[] worldRotation, float[] noteRotation, float noteSpawnOffset, float noteJumpSpeed, bool isNull, float time, dynamic mapCopy, dynamic next, int bookmarkNumber)
{

// Start processing data
Expand All @@ -514,23 +514,28 @@ public void newProcessing(int[] reds, int[] blues, int[] noteReds, int[] noteBlu
float _nextTime = next._time;
// Console.WriteLine($"{_time} < {_nextTime}");
// Console.WriteLine($"{time} < {_nextTime}");
if(time <= _time /* if time of bookmark is less than time of note && _time < _nextTime*/)
if (time <= _time /* if time of bookmark is less than time of note && _time < _nextTime*/)
{
if (isNull)
continue;

#region spaghetti

if (!_note.ContainsKey("_customData"))
{
_note.Add(new JProperty("_customData", new JObject()));
}
// Utilities.addOrUpdateElement(_note, "_customData", new JProperty("_customData"), Utilities.JType.JObj);
Utilities.addOrUpdateElement(_note._customData, "_rotation", worldRotation, Utilities.JType.JArray);
Utilities.addOrUpdateElement(_note._customData, "_localRotation", noteRotation, Utilities.JType.JArray);
Utilities.addOrUpdateElement(_note._customData, "_noteJumpMovementSpeed", noteJumpSpeed, Utilities.JType.JValue);
Utilities.addOrUpdateElement(_note._customData, "_noteJumpStartBeatOffset", noteSpawnOffset, Utilities.JType.JValue);
Utilities.addOrUpdateElement(_note._customData, "_color", reds, Utilities.JType.JArray);
lock (noteLock)
{
Utilities.addOrUpdateElement(_note._customData, "_rotation", worldRotation, Utilities.JType.JArray);
Utilities.addOrUpdateElement(_note._customData, "_localRotation", noteRotation, Utilities.JType.JArray);
Utilities.addOrUpdateElement(_note._customData, "_noteJumpMovementSpeed", noteJumpSpeed, Utilities.JType.JValue);
Utilities.addOrUpdateElement(_note._customData, "_noteJumpStartBeatOffset", noteSpawnOffset, Utilities.JType.JValue);
Utilities.addOrUpdateElement(_note._customData, "_color", reds, Utilities.JType.JArray);

}

#region uncomment this for spaghetti
/*
if (!_note._customData.ContainsKey("_rotation"))
Expand Down Expand Up @@ -583,7 +588,7 @@ public void newProcessing(int[] reds, int[] blues, int[] noteReds, int[] noteBlu
{
lock (noteLock)
{
_note._customData._color = new JArray(noteReds.Select(x => x / 255).ToArray());
_note._customData._color = new JArray(noteReds);
}
}
else
Expand All @@ -592,7 +597,7 @@ public void newProcessing(int[] reds, int[] blues, int[] noteReds, int[] noteBlu
{
if (reds[0] > 0)
{
_note._customData._color = new JArray(reds.Select(x => x / 255).ToArray());
_note._customData._color = new JArray(reds);
}
else
{
Expand All @@ -608,7 +613,7 @@ public void newProcessing(int[] reds, int[] blues, int[] noteReds, int[] noteBlu
{
lock (noteLock)
{
_note._customData._color = new JArray(noteBlues.Select(x => x / 255).ToArray());
_note._customData._color = new JArray(noteBlues);
}
}
else
Expand All @@ -617,7 +622,7 @@ public void newProcessing(int[] reds, int[] blues, int[] noteReds, int[] noteBlu
{
if (blues[0] > 0)
{
_note._customData._color = new JArray(blues.Select(x => x / 255).ToArray());
_note._customData._color = new JArray(blues);
}
else
{
Expand All @@ -642,7 +647,11 @@ public void newProcessing(int[] reds, int[] blues, int[] noteReds, int[] noteBlu

lock (balanceLock)
{
mapCopy._notes[i] = _note;
lock(noteLock)
{
mapCopy._notes[i] = _note;
}

}


Expand Down Expand Up @@ -682,38 +691,51 @@ public void newProcessing(int[] reds, int[] blues, int[] noteReds, int[] noteBlu
{
if (!_event._customData.ContainsKey("_color"))
{
if (eventBlues[0] > 0)
{
Utilities.addOrUpdateElement(_event._customData, "_color", eventBlues, Utilities.JType.JArray);

_event._customData.Add(new JProperty("_color", blues));
}
else if (blues[0] > 0)
{
Utilities.addOrUpdateElement(_event._customData, "_color", blues, Utilities.JType.JArray);
}

}
else
{
_event._customData._color = new JArray(blues);
}
}
lock (eventLock)
lock (balanceLock)
{
mapCopy._events[i] = _event;
lock (eventLock)
{
mapCopy._events[i] = _event;
}
}
break;
case 5: case 6: case 7:
lock (eventLock)
{
if (!_event._customData.ContainsKey("_color"))
{

_event._customData.Add(new JProperty("_color", reds));
}
else
{
_event._customData._color = new JArray(reds);
if(eventReds[0] > 0)
{
Utilities.addOrUpdateElement(_event._customData, "_color", eventReds, Utilities.JType.JArray);

} else if (reds[0] > 0)
{
Utilities.addOrUpdateElement(_event._customData, "_color", reds, Utilities.JType.JArray);
}

}
}


lock (balanceLock)
{
mapCopy._events[i] = _event;
lock(eventLock)
{
mapCopy._events[i] = _event;
}

}
break;
}
Expand All @@ -739,6 +761,7 @@ public void newProcessing(int[] reds, int[] blues, int[] noteReds, int[] noteBlu
mapObject = mapCopy;
}
log.WriteLine($"Finished processing {bookmarkNumber}th bookmark in {length.Elapsed.Seconds} seconds");

}
private List<string> parseText(String s, float time)
{
Expand Down
Loading

0 comments on commit 12c354a

Please sign in to comment.