diff --git a/src/rvalue.h b/src/rvalue.h index c76307063..38bd0e656 100644 --- a/src/rvalue.h +++ b/src/rvalue.h @@ -84,6 +84,7 @@ struct RValue { GMLMethod* method; #endif Instance* structInst; + int32_t assetIndex; }; // We use uint8_t for the type instead of RValueType because a enum value occupies 4 bytes, while uint8_t occupies 1 byte uint8_t type; @@ -329,7 +330,19 @@ static inline char* RValue_toString(RValue val) { snprintf(buf, sizeof(buf), "", val.structInst != nullptr ? Instance_getInstanceId(val.structInst) : 0); return safeStrdup(buf); case RVALUE_ASSETREF: - snprintf(buf, sizeof(buf), "%d", val.int32); + switch (val.assetRefType) { + case ASSET_TYPE_PATH: + snprintf(buf, sizeof(buf), "ref path __newpath%d", val.int32); + break; + + case ASSET_TYPE_SPRITE: + snprintf(buf, sizeof(buf), "ref sprite %d", val.int32); + break; + + default: + snprintf(buf, sizeof(buf), "%d", val.int32); + break; + } return safeStrdup(buf); } return safeStrdup(""); diff --git a/src/vm_builtins.c b/src/vm_builtins.c index bd3c122d8..6db2f842b 100644 --- a/src/vm_builtins.c +++ b/src/vm_builtins.c @@ -14431,7 +14431,7 @@ static GamePath* getPath(Runner* runner, int32_t pathIdx) { return &runner->dataWin->path.paths[pathIdx]; } -// path_add() - create a new empty path, return its index +// path_add() - create a new empty path, returns a path reference (AssetRef) to it, or -1 on failure. static RValue builtin_path_add(VMContext* ctx, MAYBE_UNUSED RValue* args, MAYBE_UNUSED int32_t argCount) { Runner* runner = ctx->runner; PathChunk* pc = &runner->dataWin->path; @@ -14441,7 +14441,11 @@ static RValue builtin_path_add(VMContext* ctx, MAYBE_UNUSED RValue* args, MAYBE_ pc->paths = paths; GamePath* p = &paths[newIdx]; memset(p, 0, sizeof(GamePath)); - p->name = ""; + + char buffer[32]; + snprintf(buffer, sizeof(buffer), "__newpath%u", newIdx); + p->name = safeStrdup(buffer); + p->isSmooth = false; p->isClosed = true; p->precision = 4; @@ -14451,7 +14455,7 @@ static RValue builtin_path_add(VMContext* ctx, MAYBE_UNUSED RValue* args, MAYBE_ p->internalPoints = nullptr; p->length = 0.0; pc->count = newIdx + 1; - return RValue_makeInt32((int32_t) newIdx); + return RValue_makeAssetRef((int32_t)newIdx, ASSET_TYPE_PATH); } // path_clear_points(path)