fix input bug

This commit is contained in:
John Alanbrook 2024-05-30 12:05:51 -05:00
parent b2a45fcfdd
commit 1ff46c3975
5 changed files with 27 additions and 18 deletions

View file

@ -535,10 +535,8 @@ Object.unhide = function(obj, ...props)
{ {
for (var prop of props) { for (var prop of props) {
var p = Object.getOwnPropertyDescriptor(obj,prop); var p = Object.getOwnPropertyDescriptor(obj,prop);
if (!p) { if (!p)
console.warn(`No property of name ${prop}.`); continue;
return;
}
p.enumerable = true; p.enumerable = true;
Object.defineProperty(obj, prop, p); Object.defineProperty(obj, prop, p);
} }

View file

@ -354,6 +354,7 @@ function process()
var st = profile.now(); var st = profile.now();
prosperon.window_render(window.rendersize); prosperon.window_render(window.rendersize);
prosperon.draw(); prosperon.draw();
prosperon.debug();
prosperon.gui(); prosperon.gui();
prosperon.screengui(); prosperon.screengui();
prosperon.hookend?.(); prosperon.hookend?.();

View file

@ -300,15 +300,20 @@ var Player = {
raw_input(cmd, state, ...args) { raw_input(cmd, state, ...args) {
for (var pawn of this.pawns.reversed()) { for (var pawn of this.pawns.reversed()) {
if (typeof pawn.inputs?.any === 'function') { if (!pawn.inputs) {
console.error(`pawn no longer has inputs object.`);
continue;
}
if (typeof pawn.inputs.any === 'function') {
pawn.inputs.any(cmd); pawn.inputs.any(cmd);
if (!pawn.inputs.fallthru) if (!pawn.inputs.fallthru)
return; return;
} }
if (!pawn.inputs?.[cmd]) { if (!pawn.inputs[cmd]) {
if (pawn.inputs?.block) return; if (pawn.inputs.block) return;
continue; continue;
} }
@ -330,6 +335,7 @@ var Player = {
if (typeof fn === 'function') { if (typeof fn === 'function') {
fn.call(pawn, ... args); fn.call(pawn, ... args);
if (!pawn.inputs) continue; // TODO: OK? Checking if the call uncontrolled the pawn
pawn.inputs.post?.call(pawn); pawn.inputs.post?.call(pawn);
} }
@ -370,6 +376,10 @@ var Player = {
pawns: [], pawns: [],
control(pawn) { control(pawn) {
if (!pawn.inputs) {
console.warn(`attempted to control a pawn without any input object.`);
return;
}
this.pawns.push_unique(pawn); this.pawns.push_unique(pawn);
}, },

View file

@ -92,7 +92,7 @@ void mYughLog(int category, int priority, int line, const char *file, const char
printf("\n"); printf("\n");
} }
if (priority >= LOG_ERROR) { if (priority >= LOG_PANIC) {
js_stacktrace(); js_stacktrace();
#ifdef __WIN32 #ifdef __WIN32
DebugBreak(); DebugBreak();