Skip to content

Commit

Permalink
[jak2] fully implement *user* (#3046)
Browse files Browse the repository at this point in the history
Fixes #1918
  • Loading branch information
ManDude authored Oct 1, 2023
1 parent d149838 commit dfeb88b
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 13 deletions.
1 change: 0 additions & 1 deletion common/goos/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Interpreter::Interpreter(const std::string& username) {
// set user profile name
auto user = SymbolObject::make_new(reader.symbolTable, username);
define_var_in_env(global_environment, user, "*user*");
define_var_in_env(goal_env, user, "*user*");

// setup maps
special_forms = {
Expand Down
2 changes: 1 addition & 1 deletion common/repl/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ std::string find_repl_username() {
}
}

return "#f";
return "unknown";
}

fs::path get_startup_file_path(const std::string& username, const GameVersion game_version) {
Expand Down
7 changes: 6 additions & 1 deletion game/kernel/jak2/kboot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <cstring>

#include "common/goal_constants.h"
#include "common/repl/util.h"
#include "common/util/Timer.h"

#include "game/common/game_common_types.h"
Expand All @@ -26,7 +27,11 @@ char DebugBootArtGroup[64];
void kboot_init_globals() {
memset(DebugBootUser, 0, sizeof(DebugBootUser));
memset(DebugBootArtGroup, 0, sizeof(DebugBootArtGroup));
strcpy(DebugBootUser, "unknown");
// strcpy(DebugBootUser, "unknown");
// CHANGED : let's just try to find the username automatically by default!
// the default is still "unknown"
auto username = REPL::find_repl_username();
strcpy(DebugBootUser, username.c_str());
}

void KernelCheckAndDispatch();
Expand Down
7 changes: 4 additions & 3 deletions game/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ std::string game_arg_documentation() {
output += " -level [name] Used to inform the game to boot a specific level the default level is `#f`\n";
// Jak 1 Related
output += fmt::format(fmt::emphasis::bold | fmt::fg(fmt::color::orange), "Jak 1:\n");
output += " -demo Used to pass the message `demo` to the gkernel in the DebugBootMessage (instead of play)\n";
output += " -demo Boot the game in demo mode\n";
// Jak 2 only
output += fmt::format(fmt::emphasis::bold | fmt::fg(fmt::color::purple), "Jak 2:\n");
output += " -kiosk A demo mode, TODO on specifics\n";
output += " -preview A demo mode, TODO on specifics\n";
output += " -demo Boot the game in demo mode\n";
output += " -kiosk Boot the game in kiosk demo mode\n";
output += " -preview Boot the game in preview demo mode\n";
output += " -debug-boot Used to boot the game in retail mode, but with debug segments\n";
output += " -user [name] Specify the debugging username, the default is `unknown`\n";
output += " -art [name] Specify the art-group name to set `DebugBootArtGroup`, there is no default\n";
Expand Down
6 changes: 3 additions & 3 deletions game/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void deci2_runner(SystemThreadInterface& iface) {
// then allow the server to accept connections
bool server_ok = server.init_server();
if (!server_ok) {
lg::error("[DECI2] failed to initialize, REPL will not work.\n");
lg::error("[DECI2] failed to initialize, REPL will not work.");
}

lg::debug("[DECI2] Waiting for listener...");
Expand Down Expand Up @@ -434,8 +434,8 @@ RuntimeExitStatus exec_runtime(GameLaunchOptions game_options, int argc, const c
try {
Gfx::Loop([]() { return MasterExit == RuntimeExitStatus::RUNNING; });
} catch (std::exception& e) {
lg::error("Exception thrown from graphics loop: {}\n", e.what());
lg::error("Everything will crash now. good luck\n");
lg::error("Exception thrown from graphics loop: {}", e.what());
lg::error("Everything will crash now. good luck");
throw;
}
}
Expand Down
1 change: 1 addition & 0 deletions game/sce/sif_ee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ s32 sceOpen(const char* filename, s32 flag) {

default: {
// either append or truncate
file_util::create_dir_if_needed_for_file(name);
if (flag & SCE_TRUNC) {
fp = file_util::open_file(name.c_str(), "w");
} else {
Expand Down
4 changes: 0 additions & 4 deletions goal_src/goal-lib.gc
Original file line number Diff line number Diff line change
Expand Up @@ -1020,10 +1020,6 @@
;;;; user stuf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defmacro get-user ()
`(quote ,*user*)
)

(defmacro user? (&rest users)
(cond
((null? users) #f)
Expand Down
3 changes: 3 additions & 0 deletions goal_src/jak1/kernel-defs.gc
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@

(define-extern pc-prof (function string pc-prof-event none))

(defmacro get-user ()
`(quote ,*user*)
)
(defconstant *user* (get-user))

(define-extern pc-filter-debug-string? (function string float symbol))
Expand Down

0 comments on commit dfeb88b

Please sign in to comment.