Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/rvalue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -329,7 +330,19 @@ static inline char* RValue_toString(RValue val) {
snprintf(buf, sizeof(buf), "<struct:%u>", 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("");
Expand Down
10 changes: 7 additions & 3 deletions src/vm_builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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)
Expand Down
Loading