From d9b9530e9de9c3b699de7ece7f8ae1be9e8e5690 Mon Sep 17 00:00:00 2001 From: Ben Carter Date: Fri, 22 Aug 2025 00:34:11 -0400 Subject: [PATCH] improved logger and more methods related to maps --- modules/classes/logger.ts | 25 +++++++++++++++++++------ modules/classes/mapzones.ts | 6 ++++-- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/modules/classes/logger.ts b/modules/classes/logger.ts index 9eb742f..41b8fca 100644 --- a/modules/classes/logger.ts +++ b/modules/classes/logger.ts @@ -3,36 +3,49 @@ export class Logger { public logname: string; + public loglevel: number; constructor(name: string) { this.logname = name; - } + this.loglevel = _G["ets_loglevel"]; + PrintInfo(`Logger initialized for ${name} with loglevel ${this.loglevel}`); + } log(message: string) { const info = debug.getinfo(2, "Sl"); - print(`[${this.logname}][Log]: ${message} was printed from ${info.short_src}:${info.currentline}`); + if(this.loglevel >= 5) { + print(`[${this.logname}][Log]: ${message} was printed from ${info.short_src}:${info.currentline}`); + } } debug(message: string) { const info = debug.getinfo(2, "Sl"); - PrintDebug(`[${this.logname}][Debug]: ${message} was printed from ${info.short_src}:${info.currentline}`); + if(this.loglevel >= 4) { + PrintDebug(`[${this.logname}][Debug]: ${message} was printed from ${info.short_src}:${info.currentline}`); + } } info(message: string) { const info = debug.getinfo(2, "Sl"); - PrintInfo(`[${this.logname}][Info]: ${message} was printed from ${info.short_src}:${info.currentline}`); + if(this.loglevel >= 3) { + PrintInfo(`[${this.logname}][Info]: ${message} was printed from ${info.short_src}:${info.currentline}`); + } } warn(message: string) { const info = debug.getinfo(2, "Sl"); - print(`\\27[33m[${this.logname}][Warn]: ${message} was printed from ${info.short_src}:${info.currentline}\\27[0m`); + if(this.loglevel >= 2) { + print(`\\27[33m[${this.logname}][Warn]: ${message} was printed from ${info.short_src}:${info.currentline}\\27[0m`); + } } error(message: string) { const info = debug.getinfo(2, "Sl"); - PrintError(`[${this.logname}][Error]: ${message} was printed from ${info.short_src}:${info.currentline}`); + if(this.loglevel >= 1) { + PrintError(`[${this.logname}][Error]: ${message} was printed from ${info.short_src}:${info.currentline}`); + } } } \ No newline at end of file diff --git a/modules/classes/mapzones.ts b/modules/classes/mapzones.ts index e6df914..76cb5bf 100644 --- a/modules/classes/mapzones.ts +++ b/modules/classes/mapzones.ts @@ -553,12 +553,14 @@ export function isBossDbCheck(entry: number): boolean { left join creature c on ct.entry = c.id1 left join map_dbc m on c.map = m.ID where - (ct.\`rank\` = 3 and InstanceType > 0) + ((ct.\`rank\` = 3 and InstanceType > 0) OR (ct.\`rank\` = 3 and ct.ScriptName like 'boss_%') OR (ExpansionID = 1 and ct.ScriptName like '%boss%') - OR (m.InstanceType = 1 and ExperienceModifier = 2) + OR (m.InstanceType = 1 and ExperienceModifier = 2)) and entry = ${entry}`; + logger.debug(`Checking if ${entry} is a boss sql: ${sql}`); + const result = WorldDBQuery(sql); if(result) { return true;