diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index 0c8070a2b1..0ab56fc326 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -729,6 +729,7 @@ {"id":{"name":"spr_fleet_inquisition","path":"sprites/spr_fleet_inquisition/spr_fleet_inquisition.yy",},}, {"id":{"name":"spr_tooltip1","path":"sprites/spr_tooltip1/spr_tooltip1.yy",},}, {"id":{"name":"spr_fleet_chaos","path":"sprites/spr_fleet_chaos/spr_fleet_chaos.yy",},}, + {"id":{"name":"__init_external","path":"scripts/__init_external/__init_external.yy",},}, {"id":{"name":"spr_fleet_ork","path":"sprites/spr_fleet_ork/spr_fleet_ork.yy",},}, {"id":{"name":"spr_fleet_necron","path":"sprites/spr_fleet_necron/spr_fleet_necron.yy",},}, {"id":{"name":"spr_fleet_tau","path":"sprites/spr_fleet_tau/spr_fleet_tau.yy",},}, diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index ab1269eeaa..d35758bb07 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -323,11 +323,6 @@ if (window_get_fullscreen()=1){ cheatcode=0; cheatyface=0; // ** Debugging file created ** -debug_lines=0; -ini_open("debug_log.ini"); -debug_lines=ini_read_real("Main","lines",0); -ini_close(); - debugl("=========Controller Created"); // ** Creates saves.ini with default settings ** ini_open("saves.ini"); diff --git a/objects/obj_main_menu/Create_0.gml b/objects/obj_main_menu/Create_0.gml index f6f921d11c..d1a028bbfb 100644 --- a/objects/obj_main_menu/Create_0.gml +++ b/objects/obj_main_menu/Create_0.gml @@ -132,11 +132,6 @@ tim3=0; tim4=0; tim5=0; -if (!directory_exists("ErrorLogs")) { - directory_create("ErrorLogs"); -} - - // TODO: maybe replace the OG debug_log.ini with something like this. // if (!directory_exists("SessionLogs")) { // directory_create("SessionLogs"); @@ -146,23 +141,6 @@ if (!directory_exists("ErrorLogs")) { // file_text_close(global.session_log_file); -global.build_date = "unknown build"; -global.game_version = "unknown version"; - -var _version_file_path = working_directory + "\\main\\version.json"; -var _parsed_json = json_to_gamemaker(_version_file_path, json_parse); - -if (_parsed_json != undefined) { - var _build_date = _parsed_json[$ "build_date"]; - _build_date = string_replace(_build_date, "BS", ""); - _build_date = string_replace(_build_date, "BE", ""); - var _version = _parsed_json[$ "version"]; - _version = string_replace(_version, "VSv", ""); - _version = string_replace(_version, "VE", ""); - global.build_date = _build_date; - global.game_version = _version; -} - /* */ action_set_alarm(1, 3); action_set_alarm(30, 4); diff --git a/scripts/__init_external/__init_external.gml b/scripts/__init_external/__init_external.gml new file mode 100644 index 0000000000..7eead58ff9 --- /dev/null +++ b/scripts/__init_external/__init_external.gml @@ -0,0 +1,40 @@ +gml_pragma( "global", "__init_external();"); + +function __init_external() { + // Delete leftover files from old versions; + // Remove these lines after a couple of months; + // ======================== + if (directory_exists("ErrorLogs")) { + directory_destroy("ErrorLogs"); + } + if (file_exists("debug_log.ini")) { + file_delete("debug_log.ini"); + } + if (file_exists("message_log.log")) { + file_delete("message_log.log"); + } + // ======================== + + if (!directory_exists("logs")) { + directory_create("logs"); + } + var _log_file = file_text_open_write($"logs/last_messages.log"); + file_text_close(_log_file); + + global.build_date = "unknown build"; + global.game_version = "unknown version"; + + var _version_file_path = working_directory + "\\main\\version.json"; + var _parsed_json = json_to_gamemaker(_version_file_path, json_parse); + + if (_parsed_json != undefined) { + var _build_date = _parsed_json[$ "build_date"]; + _build_date = string_replace(_build_date, "BS", ""); + _build_date = string_replace(_build_date, "BE", ""); + var _version = _parsed_json[$ "version"]; + _version = string_replace(_version, "VSv", ""); + _version = string_replace(_version, "VE", ""); + global.build_date = _build_date; + global.game_version = _version; + } +} diff --git a/scripts/__init_external/__init_external.yy b/scripts/__init_external/__init_external.yy new file mode 100644 index 0000000000..86573adfcd --- /dev/null +++ b/scripts/__init_external/__init_external.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "__init_external", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "compatibility", + "path": "folders/Scripts/compatibility.yy", + }, +} \ No newline at end of file diff --git a/scripts/__init_global/__init_global.gml b/scripts/__init_global/__init_global.gml index c74c6bba31..022fecd434 100644 --- a/scripts/__init_global/__init_global.gml +++ b/scripts/__init_global/__init_global.gml @@ -4,6 +4,4 @@ function __init_global() { // set any global defaults layer_force_draw_depth(true,0); // force all layers to draw at depth 0 draw_set_colour( c_black ); - - } diff --git a/scripts/debugl/debugl.gml b/scripts/debugl/debugl.gml index 1b33c2394f..b5aa356872 100644 --- a/scripts/debugl/debugl.gml +++ b/scripts/debugl/debugl.gml @@ -1,32 +1,8 @@ -function debugl(argument0) { - - // argument0: string to add to debug log - - if (instance_exists(obj_controller)){ - obj_controller.debug_lines+=1; - - var numeral;numeral=""; - if (obj_controller.debug_lines<10) then numeral="0000"+string(obj_controller.debug_lines); - if (obj_controller.debug_lines>=10) and (obj_controller.debug_lines<100) then numeral="000"+string(obj_controller.debug_lines); - if (obj_controller.debug_lines>=100) and (obj_controller.debug_lines<1000) then numeral="00"+string(obj_controller.debug_lines); - if (obj_controller.debug_lines>=1000) and (obj_controller.debug_lines<10000) then numeral="0"+string(obj_controller.debug_lines); - if (obj_controller.debug_lines>=10000) and (obj_controller.debug_lines<100000) then numeral=string(obj_controller.debug_lines); - - ini_open("debug_log.ini"); - ini_write_real("Main","lines",obj_controller.debug_lines); - // ini_write_string("Main",string(obj_controller.debug_lines),string(argument0)); - ini_write_string("Main",string(numeral),string(argument0)); - ini_close(); - } - - if (!instance_exists(obj_controller)){ - ini_open("debug_log.ini"); - var dbl;dbl=ini_read_real("Main","lines",0)+1; - ini_write_real("Main","lines",dbl); - ini_write_string("Main",string(dbl),string(argument0)); - ini_close(); - } - - +/// @desc Writes a string into the last_messages.log. +/// @param {string} _string +function debugl(_string) { + var _log_file = file_text_open_append("logs/" + $"last_messages.log"); + file_text_write_string(_log_file, _string + "\n"); + file_text_close(_log_file); } diff --git a/scripts/macros/macros.gml b/scripts/macros/macros.gml index 8c3b319a6d..3c83ec6947 100644 --- a/scripts/macros/macros.gml +++ b/scripts/macros/macros.gml @@ -3,6 +3,7 @@ function macros() { #macro DEFAULT_TOOLTIP_VIEW_OFFSET 32 #macro DEFAULT_LINE_GAP -1 #macro LB_92 "############################################################################################" +#macro START_DATE_TIME_1 $"{current_day}-{current_month}-{current_year}-{current_hour}{current_minute}{current_second}" enum luck { bad = -1, diff --git a/scripts/scr_log/scr_log.gml b/scripts/scr_log/scr_log.gml index 3d1fd9606c..43fa29780c 100644 --- a/scripts/scr_log/scr_log.gml +++ b/scripts/scr_log/scr_log.gml @@ -1,11 +1,11 @@ /// @function log_into_file -/// @description Creates an error_log file in ErrorLogs folder and puts _message there. +/// @description Creates an error file in the logs folder and puts _message there. /// @param {string} _message string to put into the error log. function log_into_file(_message) { if (string_length(_message) > 0) { var _entry = string(_message); - var _date_time = $"{current_day}-{current_month}-{current_year}_{current_hour}{current_minute}{current_second}"; - var _log_file = file_text_open_write("ErrorLogs/" + $"error_{_date_time}.log"); + var _date_time = $"{START_DATE_TIME_1}"; + var _log_file = file_text_open_write("logs/" + $"{_date_time}_error.log"); file_text_write_string(_log_file, _entry); file_text_close(_log_file); @@ -32,7 +32,7 @@ function handle_exception(_exception, custom_title = STR_error_message_head, cus #macro STR_error_message_head "Your game just encountered and caught an error :(" #macro STR_error_message_head2 "Your game just encountered a critical error :(" #macro STR_error_message_head3 "Your game just encountered and caught an error ({0}) :(" - #macro MSG_error_message $"The error log is automatically copied into your clipboard and a copy is created at: \nC:>Users>(UserName)>AppData>Local>ChapterMaster>ErrorLogs \n\nPlease, do the following: \n\n1) Create a bug report on the bug-report-forum in our 'Chapter Master Discord' server. \n\n2) Press CTRL+V to paste the error log into the bug report. \n\n3) Title your report by cutting and pasting the first line of the main message (it contains game version and file that caused the error). \n\n4) If for some reason the error log wasn't pasted, find the location that is mentioned above and attach the latest (sort by time) error_*date-time*.log to your bug report. In this case you can name your report as you wish. \n\n\nThank you :)" + #macro MSG_error_message $"The error log is automatically copied into your clipboard and a copy is created at: \nC:>Users>(UserName)>AppData>Local>ChapterMaster>ErrorLogs \n\nPlease, do the following: \n\n1) Create a bug report on the bug-report-forum in our 'Chapter Master Discord' server. \n\n2) Press CTRL+V to paste the error log into the bug report. \n\n3) Title your report by cutting and pasting the first line of the main message (it contains game version and file that caused the error). \n\n4) If for some reason the error log wasn't pasted, find the location that is mentioned above and attach the latest (sort by time) _error.log to your bug report. In this case you can name your report as you wish. \n\n\nThank you :)" #macro MSG_error_message_ps $"P.S. You can ALT-TAB and try to continue playing - if the error is not severe, the game should continue working, just try to avoid what caused it. \n\nBut it's recommended to wait for a response on the bug-report forum, otherwise you may make the issue worse." var _popup_header = $"{custom_title}\n\n";