Spaces To Tabs

This commit is contained in:
NeeEoo
2023-04-22 12:15:49 +02:00
parent 2b2990ae30
commit 85cdfdeb10
108 changed files with 23942 additions and 23944 deletions
+1 -1
View File
@@ -72,7 +72,7 @@ class ModsFolder {
* @param modName Name of the mod
* @param force Whenever the mod should be reloaded if it has already been loaded
*/
public static function loadModLib(path:String, force:Bool = false) {
public static function loadModLib(path:String, force:Bool = false) {
#if MOD_SUPPORT
if (FileSystem.exists('$path.zip'))
return loadLibraryFromZip('$path'.toLowerCase(), '$path.zip', force);
+15 -15
View File
@@ -3,7 +3,7 @@ package funkin.backend.utils;
/**
* All types of utils only usable in a sorted array.
*/
class SortedArrayUtil {
class SortedArrayUtil {
/**
* Gets the index of a possible new element of an Array of T using an efficient algorithm.
* @param array Array of T to check in
@@ -15,7 +15,7 @@ package funkin.backend.utils;
if (getVal(array[0]) > val) return 0; // in case its the minimum
if (getVal(array[array.length-1]) < val) return array.length; // in case its the maximum
// binary search
// binary search
var iMin:Int = 0;
var iMax:Int = array.length-1;
@@ -25,25 +25,25 @@ package funkin.backend.utils;
i = Math.floor((iMin + iMax) / 2);
mid = getVal(array[i]);
if (mid < val)
iMin = i+1
iMin = i+1
else if (mid > val)
iMax = i-1;
else {
iMin = i;
break;
}
iMin = i;
break;
}
}
return iMin;
}
/**
* Adds to a sorted array, using binary search.
* @param array Array to add to
* @param val Value to add
* @param getVal Function that returns the value that needs to be sorted
*/
public static inline function addSorted<T>(array:Array<T>, val:T, getVal:T->Float) {
/**
* Adds to a sorted array, using binary search.
* @param array Array to add to
* @param val Value to add
* @param getVal Function that returns the value that needs to be sorted
*/
public static inline function addSorted<T>(array:Array<T>, val:T, getVal:T->Float) {
if (val != null)
array.insert(binarySearch(array, getVal(val), getVal), val);
}
array.insert(binarySearch(array, getVal(val), getVal), val);
}
}
+119 -119
View File
@@ -13,146 +13,146 @@ import haxe.zip.InflateImpl;
* Half of the code is taken from haxe libraries btw
*/
class SysZip extends Reader {
var input:Input;
var fileInput:FileInput;
var input:Input;
var fileInput:FileInput;
public var entries:List<SysZipEntry>;
public var entries:List<SysZipEntry>;
/**
* Opens a zip from a specified path.
* @param path Path to the zip file.
*/
public static function openFromFile(path:String) {
/**
* Opens a zip from a specified path.
* @param path Path to the zip file.
*/
public static function openFromFile(path:String) {
return new SysZip(File.read(path, true));
}
return new SysZip(File.read(path, true));
}
/**
* Creates a new SysZip from a specified file input.
* @param input File input.
*/
public function new(input:FileInput) {
super(input);
fileInput = input;
}
/**
* Creates a new SysZip from a specified file input.
* @param input File input.
*/
public function new(input:FileInput) {
super(input);
fileInput = input;
}
/**
* Reads all the data present in a specified entry.
* NOTE: If the entry is compressed, the data won't be decompressed. For decompression, use `unzipEntry`.
* @param e Entry
*/
public function readEntryData(e:SysZipEntry) {
var bytes:haxe.io.Bytes = null;
/**
* Reads all the data present in a specified entry.
* NOTE: If the entry is compressed, the data won't be decompressed. For decompression, use `unzipEntry`.
* @param e Entry
*/
public function readEntryData(e:SysZipEntry) {
var bytes:haxe.io.Bytes = null;
var buf = null;
var tmp = null;
fileInput.seek(e.seekPos, SeekBegin);
if (e.crc32 == null) {
if (e.compressed) {
#if neko
// enter progressive mode : we use a different input which has
// a temporary buffer, this is necessary since we have to uncompress
// progressively, and after that we might have pending read data
// that needs to be processed
var bufSize = 65536;
if (buf == null) {
buf = new haxe.io.BufferInput(i, haxe.io.Bytes.alloc(bufSize));
tmp = haxe.io.Bytes.alloc(bufSize);
i = buf;
}
var out = new haxe.io.BytesBuffer();
var z = new neko.zip.Uncompress(-15);
z.setFlushMode(neko.zip.Flush.SYNC);
while (true) {
if (buf.available == 0)
buf.refill();
var p = bufSize - buf.available;
if (p != buf.pos) {
// because of lack of "srcLen" in zip api, we need to always be stuck to the buffer end
buf.buf.blit(p, buf.buf, buf.pos, buf.available);
buf.pos = p;
}
var r = z.execute(buf.buf, buf.pos, tmp, 0);
out.addBytes(tmp, 0, r.write);
buf.pos += r.read;
buf.available -= r.read;
if (r.done)
break;
}
bytes = out.getBytes();
#else
var bufSize = 65536;
if (tmp == null)
tmp = haxe.io.Bytes.alloc(bufSize);
var out = new haxe.io.BytesBuffer();
var z = new InflateImpl(i, false, false);
while (true) {
var n = z.readBytes(tmp, 0, bufSize);
out.addBytes(tmp, 0, n);
if (n < bufSize)
break;
}
bytes = out.getBytes();
#end
} else
bytes = i.read(e.dataSize);
e.crc32 = i.readInt32();
if (e.crc32 == 0x08074b50)
e.crc32 = i.readInt32();
e.dataSize = i.readInt32();
e.fileSize = i.readInt32();
// set data to uncompressed
e.dataSize = e.fileSize;
e.compressed = false;
} else
bytes = i.read(e.dataSize);
return bytes;
}
fileInput.seek(e.seekPos, SeekBegin);
if (e.crc32 == null) {
if (e.compressed) {
#if neko
// enter progressive mode : we use a different input which has
// a temporary buffer, this is necessary since we have to uncompress
// progressively, and after that we might have pending read data
// that needs to be processed
var bufSize = 65536;
if (buf == null) {
buf = new haxe.io.BufferInput(i, haxe.io.Bytes.alloc(bufSize));
tmp = haxe.io.Bytes.alloc(bufSize);
i = buf;
}
var out = new haxe.io.BytesBuffer();
var z = new neko.zip.Uncompress(-15);
z.setFlushMode(neko.zip.Flush.SYNC);
while (true) {
if (buf.available == 0)
buf.refill();
var p = bufSize - buf.available;
if (p != buf.pos) {
// because of lack of "srcLen" in zip api, we need to always be stuck to the buffer end
buf.buf.blit(p, buf.buf, buf.pos, buf.available);
buf.pos = p;
}
var r = z.execute(buf.buf, buf.pos, tmp, 0);
out.addBytes(tmp, 0, r.write);
buf.pos += r.read;
buf.available -= r.read;
if (r.done)
break;
}
bytes = out.getBytes();
#else
var bufSize = 65536;
if (tmp == null)
tmp = haxe.io.Bytes.alloc(bufSize);
var out = new haxe.io.BytesBuffer();
var z = new InflateImpl(i, false, false);
while (true) {
var n = z.readBytes(tmp, 0, bufSize);
out.addBytes(tmp, 0, n);
if (n < bufSize)
break;
}
bytes = out.getBytes();
#end
} else
bytes = i.read(e.dataSize);
e.crc32 = i.readInt32();
if (e.crc32 == 0x08074b50)
e.crc32 = i.readInt32();
e.dataSize = i.readInt32();
e.fileSize = i.readInt32();
// set data to uncompressed
e.dataSize = e.fileSize;
e.compressed = false;
} else
bytes = i.read(e.dataSize);
return bytes;
}
/**
* Unzips and returns all of the data present in an entry.
* @param f Entry to read from.
*/
public function unzipEntry(f:SysZipEntry) {
var data = readEntryData(f);
/**
* Unzips and returns all of the data present in an entry.
* @param f Entry to read from.
*/
public function unzipEntry(f:SysZipEntry) {
var data = readEntryData(f);
if (!f.compressed)
return data;
var c = new haxe.zip.Uncompress(-15);
var s = haxe.io.Bytes.alloc(f.fileSize);
var r = c.execute(data, 0, s, 0);
c.close();
if (!r.done || r.read != data.length || r.write != f.fileSize)
throw "Invalid compressed data for " + f.fileName;
data = s;
return data;
}
if (!f.compressed)
return data;
var c = new haxe.zip.Uncompress(-15);
var s = haxe.io.Bytes.alloc(f.fileSize);
var r = c.execute(data, 0, s, 0);
c.close();
if (!r.done || r.read != data.length || r.write != f.fileSize)
throw "Invalid compressed data for " + f.fileName;
data = s;
return data;
}
public override function read():List<Entry> {
if (entries != null)
return entries;
entries = new List();
public override function read():List<Entry> {
if (entries != null)
return entries;
entries = new List();
while (true) {
var e = readEntryHeader();
if (e == null)
break;
var zipEntry:SysZipEntry = cast e;
zipEntry.seekPos = fileInput.tell();
entries.add(zipEntry);
fileInput.seek(e.dataSize, SeekCur);
var zipEntry:SysZipEntry = cast e;
zipEntry.seekPos = fileInput.tell();
entries.add(zipEntry);
fileInput.seek(e.dataSize, SeekCur);
}
return entries;
}
}
public function dispose() {
if (input != null)
input.close();
}
public function dispose() {
if (input != null)
input.close();
}
}
typedef SysZipEntry = {
> Entry,
var seekPos:Int;
> Entry,
var seekPos:Int;
}
#end
+4 -6
View File
@@ -1159,7 +1159,7 @@ class PlayState extends MusicBeatState
if (generatedMusic && FlxG.keys.justPressed.ONE)
endSong();
#end
super.update(elapsed);
scripts.call("postUpdate", [elapsed]);
@@ -1456,8 +1456,8 @@ class PlayState extends MusicBeatState
note.wasGoodHit = true;
/**
* CALCULATES RATING
*/
* CALCULATES RATING
*/
var noteDiff = Math.abs(Conductor.songPosition - note.strumTime);
var daRating:String = "sick";
var score:Int = 300;
@@ -1503,10 +1503,8 @@ class PlayState extends MusicBeatState
{
songScore += score;
var separatedScore:String = Std.string(combo).addZeros(3);
if (combo == 0 || combo >= 10) {
if (combo >= 10) {
var comboSpr:FlxSprite = comboGroup.recycleLoop(FlxSprite).loadAnimatedGraphic(Paths.image('${event.ratingPrefix}combo${event.ratingSuffix}'));
@@ -1697,7 +1695,7 @@ class PlayState extends MusicBeatState
* @param weekData Week Data
* @param difficulty Week Difficulty
*/
public static function loadWeek(weekData:WeekData, difficulty:String = "normal") {
public static function loadWeek(weekData:WeekData, difficulty:String = "normal") {
storyWeek = weekData;
storyPlaylist = [for(e in weekData.songs) e.name];
isStoryMode = true;
+7 -7
View File
@@ -46,17 +46,17 @@ class FreeplayState extends MusicBeatState
* Text containing the score info (PERSONAL BEST: 0)
*/
public var scoreText:FlxText;
/**
* Text containing the current difficulty (< HARD >)
*/
public var diffText:FlxText;
/**
* Text containing the current coop/opponent mode ([TAB] Co-Op mode)
*/
public var coopText:FlxText;
/**
* Currently lerped score. Is updated to go towards `intendedScore`.
*/
@@ -256,7 +256,7 @@ class FreeplayState extends MusicBeatState
if (controls.ACCEPT && !dontPlaySongThisFrame)
select();
}
var __opponentMode:Bool = false;
var __coopMode:Bool = false;
@@ -351,7 +351,7 @@ class FreeplayState extends MusicBeatState
* @param change How much to change
* @param force Force the change, even if `change` is equal to 0.
*/
public function changeCoopMode(change:Int = 0, force:Bool = false) {
public function changeCoopMode(change:Int = 0, force:Bool = false) {
if (change == 0 && !force) return;
if (!songs[curSelected].coopAllowed && !songs[curSelected].opponentModeAllowed) return;
@@ -361,7 +361,7 @@ class FreeplayState extends MusicBeatState
if (event.cancelled) return;
curCoopMode = event.value;
updateScore();
if (bothEnabled) {
@@ -431,7 +431,7 @@ class FreeplaySonglist {
} else {
songsFound = Paths.getFolderDirectories('songs', false, source);
}
if (songsFound.length > 0) {
for(s in songsFound)
songs.push(Chart.loadChartMeta(s, "normal", source == MODS));