Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/data_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@ static void readRoomBackgrounds(BinaryReader* reader, Room* room) {
free(bgPtrs);
}

static void readRoomViews(BinaryReader* reader, DataWin* dw, Room* room) {
static void readRoomViews(BinaryReader* reader, Room* room) {
uint32_t viewCount;
uint32_t* viewPtrsArr = readPointerTable(reader, &viewCount);
room->views = safeMalloc(8 * sizeof(RoomView));
Expand Down Expand Up @@ -1726,7 +1726,7 @@ static void readRoomPayload(BinaryReader* reader, DataWin* dw, Room* room) {
readRoomBackgrounds(reader, room);

BinaryReader_seek(reader, room->viewsFileOffset);
readRoomViews(reader, dw, room);
readRoomViews(reader, room);

BinaryReader_seek(reader, room->gameObjectsFileOffset);
readRoomGameObjects(reader, dw, room);
Expand Down
3 changes: 2 additions & 1 deletion src/desktop/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,8 @@ static PreviousSignalActionEntry* previousSignalActions = nullptr;
static void onCrashSignal(int sig) {
saveInputRecording();
// Restore the previous handler (ASAN) and re-raise so it can report the fault
sigaction(sig, &previousSignalActions[hmgeti(previousSignalActions, sig)].value, nullptr);
ssize_t idx = hmgeti(previousSignalActions, sig);
sigaction(sig, &previousSignalActions[idx].value, nullptr);
raise(sig);
}
#endif
Expand Down
1 change: 0 additions & 1 deletion src/gl/gl_renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,6 @@ static void glDrawTriangle(Renderer *renderer, float x1, float y1, float x2, flo

flushBatch(gl);

int i = 0;
float verts[24] = {
x1, y1, 0.0f, 0.0f, r, g, b, renderer->drawAlpha,
x2, y2, 0.0f, 0.0f, r, g, b, renderer->drawAlpha,
Expand Down
3 changes: 1 addition & 2 deletions src/runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -2369,7 +2369,7 @@ static void dispatchCollisionEvents(Runner* runner) {
if (needsPrecise) {
bool preciseHit = Collision_instancesOverlapPrecise(runner, self, other, bboxSelf, bboxOther);
#ifdef ENABLE_VM_TRACING
if (traceThisPair) fprintf(stderr, " precise=%s (selfSepMasks=%d otherSepMasks=%d)\n", preciseHit ? "hit" : "miss", sprSelf ? sprSelf->sepMasks : -1, sprOther ? sprOther->sepMasks : -1);
if (traceThisPair) fprintf(stderr, " precise=%s (selfSepMasks=%d otherSepMasks=%d)\n", preciseHit ? "hit" : "miss", sprSelf ? (int32_t)sprSelf->sepMasks : -1, sprOther ? (int32_t)sprOther->sepMasks : -1);
#endif
if (!preciseHit) continue;
}
Expand Down Expand Up @@ -2551,7 +2551,6 @@ static void updateViews(Runner* runner) {
}

static void dispatchOutsideRoomEvents(Runner* runner) {
DataWin* dataWin = runner->dataWin;
int32_t outsideSlot = EventSlotMap_lookup(&runner->eventSlotMap, EVENT_OTHER, OTHER_OUTSIDE_ROOM);
if (0 > outsideSlot) return;
ResolvedEventTable* table = &runner->eventTable;
Expand Down
10 changes: 0 additions & 10 deletions src/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,16 +424,6 @@ static ArrayAccess popArrayAccess(VMContext* ctx, uint32_t varRef) {
}

// ===[ Variable Resolution ]===
static const char* instanceTypeName(int32_t instanceType) {
switch (instanceType) {
case INSTANCE_SELF: return "self";
case INSTANCE_OTHER: return "other";
case INSTANCE_GLOBAL: return "global";
case INSTANCE_LOCAL: return "local";
case INSTANCE_ARG: return "arg";
default: return "instance";
}
}

// Returns the object name for an instance, or "<global_scope>" for the global scope dummy instance
static const char* instanceObjectName(VMContext* ctx, Instance* inst) {
Expand Down
42 changes: 7 additions & 35 deletions src/vm_builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,24 +167,6 @@ static DsQueue* dsQueueGet(Runner* runner, int32_t id) {

// ===[ BUILT-IN VARIABLE GET/SET ]===

/**
* Gets the argument number from the name
*
* If it returns -1, then the name is not an argument variable
*
* @param name The name
* @return The argument number, -1 if it is not an argument variable
*/
static int extractArgumentNumber(const char* name) {
if (strncmp(name, "argument", 8) == 0) {
char* end;
long argNumber = strtol(name + 8, &end, 10);
if (end == name + 8 || *end != '\0' || 0 > argNumber || argNumber > 15) return -1;
return (int) argNumber;
}
return -1;
}

static bool isValidAlarmIndex(int alarmIndex) {
return alarmIndex >= 0 && GML_ALARM_COUNT > alarmIndex;
}
Expand Down Expand Up @@ -2157,8 +2139,8 @@ static RValue builtin_string_replace(MAYBE_UNUSED VMContext* ctx, RValue* args,
int32_t before = (int32_t) (appearance - str);
char *outputString = safeMalloc(newLen + 1);

strncpy(outputString, str, before);
strncpy(outputString + before, replacement, replacementLen);
memcpy(outputString, str, before);
memcpy(outputString + before, replacement, replacementLen);
strcpy(outputString + before + replacementLen, appearance + needleLen);

free(str);
Expand Down Expand Up @@ -2852,7 +2834,6 @@ static RValue builtin_room_get_info(VMContext* ctx, RValue* args, int32_t argCou
VM_structSet(ctx, ls, "visible", RValue_makeBool(lay->visible));

if (wantLayerEls) {
int32_t elemCount = 0;
GMLArray* elements = nullptr;
switch ((RoomLayerType) lay->type) {
case RoomLayerType_Background: {
Expand All @@ -2873,7 +2854,6 @@ static RValue builtin_room_get_info(VMContext* ctx, RValue* args, int32_t argCou
VM_structSet(ctx, es, "speed_type", RValue_makeInt32((int32_t) bg->animSpeedType));
}
*GMLArray_slot(elements, 0) = RValue_makeStructAndIncRef(es);
elemCount = 1;
break;
}
case RoomLayerType_Instances: {
Expand All @@ -2887,7 +2867,6 @@ static RValue builtin_room_get_info(VMContext* ctx, RValue* args, int32_t argCou
VM_structSet(ctx, es, "inst_id", RValue_makeInt32((int32_t) id->instanceIds[j]));
*GMLArray_slot(elements, j) = RValue_makeStructAndIncRef(es);
}
elemCount = ic;
break;
}
case RoomLayerType_Tiles: {
Expand All @@ -2913,13 +2892,11 @@ static RValue builtin_room_get_info(VMContext* ctx, RValue* args, int32_t argCou
}
}
*GMLArray_slot(elements, 0) = RValue_makeStructAndIncRef(es);
elemCount = 1;
break;
}
default:
// Asset/Path/Effect layers: emit an empty element list. Filling these out matches the HTML5 runner but isn't required for room_goto navigation.
elements = GMLArray_create(1);
elemCount = 0;
break;
}
if (elements != nullptr) VM_structSet(ctx, ls, "elements", RValue_makeArray(elements));
Expand Down Expand Up @@ -7695,7 +7672,7 @@ static RValue builtin_buffer_base64_decode(MAYBE_UNUSED VMContext* ctx, RValue*
unsigned int inLen = (unsigned int) strlen(input);
size_t outLen = BASE64_DECODE_OUT_SIZE(inLen);
uint8_t* out = safeMalloc(outLen);
base64_decode((const unsigned char*) input, inLen, out);
base64_decode(input, inLen, out);
free(input);
int32_t id = gmlBufferCreate(runner, outLen, GML_BUFFER_GROW, 1);
GmlBuffer* buf = gmlBufferGet(runner, id);
Expand Down Expand Up @@ -7747,7 +7724,6 @@ static RValue builtin_buffer_md5(MAYBE_UNUSED VMContext* ctx, RValue* args, MAYB
MD5Final(digest, &mctx);

char* hex = safeMalloc(33);
static const char HEX[] = "0123456789abcdef";
for (int32_t i = 0; 16 > i; i++) {
sprintf(&hex[i * 2], "%02x", digest[i]);
}
Expand Down Expand Up @@ -8005,9 +7981,6 @@ static RValue builtin_draw_sprite_general(VMContext* ctx, RValue* args, MAYBE_UN
float yscale = (float) RValue_toReal(args[9]);
float rot = (float) RValue_toReal(args[10]);
uint32_t c1 = (uint32_t) RValue_toInt32(args[11]);
uint32_t c2 = (uint32_t) RValue_toInt32(args[12]);
uint32_t c3 = (uint32_t) RValue_toInt32(args[13]);
uint32_t c4 = (uint32_t) RValue_toInt32(args[14]);
float alpha = (float) RValue_toReal(args[15]);

if (0 > subimg && ctx->currentInstance != nullptr) {
Expand Down Expand Up @@ -8094,8 +8067,6 @@ static RValue builtin_draw_healthbar(VMContext* ctx, RValue* args, MAYBE_UNUSED
uint32_t maxCol = (uint32_t) RValue_toInt32(args[7]);
uint32_t intermediateColor = (uint32_t) Color_lerp((int32_t) minCol, (int32_t) maxCol, amount);

int32_t direction = RValue_toInt32(args[8]);

bool showBack = RValue_toBool(args[9]);

if (showBack) {
Expand Down Expand Up @@ -12004,7 +11975,8 @@ static RValue builtin_mp_grid_add_rectangle(VMContext* ctx, RValue* args, int32_
int32_t y1 = RValue_toInt32(args[2]);
int32_t x2 = RValue_toInt32(args[3]);
int32_t y2 = RValue_toInt32(args[4]);
if (x1 < 0) x1 = 0; if (y1 < 0) y1 = 0;
if (x1 < 0) x1 = 0;
if (y1 < 0) y1 = 0;
if (x2 >= g->hcells) x2 = g->hcells - 1;
if (y2 >= g->vcells) y2 = g->vcells - 1;
for (int32_t cx = x1; x2 >= cx; cx++) {
Expand All @@ -12024,7 +11996,8 @@ static RValue builtin_mp_grid_clear_rectangle(VMContext* ctx, RValue* args, int3
int32_t y1 = RValue_toInt32(args[2]);
int32_t x2 = RValue_toInt32(args[3]);
int32_t y2 = RValue_toInt32(args[4]);
if (x1 < 0) x1 = 0; if (y1 < 0) y1 = 0;
if (x1 < 0) x1 = 0;
if (y1 < 0) y1 = 0;
if (x2 >= g->hcells) x2 = g->hcells - 1;
if (y2 >= g->vcells) y2 = g->vcells - 1;
for (int32_t cx = x1; x2 >= cx; cx++) {
Expand Down Expand Up @@ -12713,7 +12686,6 @@ static RValue builtin_asset_get_index(VMContext* ctx, RValue* args, int32_t argC
}

char* name = RValue_toString(args[0]);
DataWin* dw = ctx->dataWin;

int32_t value = shget(ctx->runner->assetsByName, name);
free(name);
Expand Down
Loading