Skip to content

Commit

Permalink
refactor(FTS): utilize constant for marking an fts file uncompressed
Browse files Browse the repository at this point in the history
  • Loading branch information
meszaros-lajos-gyorgy committed May 30, 2024
1 parent 285e927 commit 7a35e9e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/fts/FTS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ export type ArxFTS = {
roomDistances: ArxRoomDistance[]
}

/**
* Arx Libertatis feature: setting the uncompressed bytes' size in the header to 0 gets
* interpreted as the file being uncompressed
*
* source of discussion: https://arx-libertatis.org/irclogs/2023/%23arx.2023-01-01.log
*
* implemented in: https://github.com/arx/ArxLibertatis/commit/2d2226929780b6202f54982bacc79ddf75dbec53
*/
const IS_AN_UNCOMPRESSED_FTS = 0

export class FTS {
Expand Down Expand Up @@ -99,11 +107,7 @@ export class FTS {
roomDistances,
])

// Arx Libertatis feature: setting uncompressed size in bytes to 0 gets
// interpreted as the file being uncompressed
// source of discussion: https://arx-libertatis.org/irclogs/2023/%23arx.2023-01-01.log
// implemented in: https://github.com/arx/ArxLibertatis/commit/2d2226929780b6202f54982bacc79ddf75dbec53
const header = FtsHeader.accumulateFrom(json, isCompressed ? dataWithoutHeader.length : 0)
const header = FtsHeader.accumulateFrom(json, isCompressed ? dataWithoutHeader.length : IS_AN_UNCOMPRESSED_FTS)
const uniqueHeaders = Buffer.concat(json.uniqueHeaders.map(UniqueHeader.accumulateFrom))

return Buffer.concat([header, uniqueHeaders, dataWithoutHeader])
Expand Down

0 comments on commit 7a35e9e

Please sign in to comment.