Skip to content

[Compat] StructureSpawn.renewCreep throws when undefined is passed as the creep #57

@Hexcede

Description

@Hexcede

When StructureSpawn.renewCreep is called with undefined as the creep value, it results in a runtime error in creep's checkCommon function.

Location of error in source (creep.ts)

This should have one additional check which ensures the creep value is defined, and if it isn't, it should return C.ERR_INVALID_TARGET as seen here (structures.js) in the original in-vm bindings, and here (creep.js) in the original intents processor.

Relevant stack trace:

Error: TypeError: Cannot read property 'my' of undefined
    at checkCommon (webpack:/module/xxscreeps/src/mods/creep/creep.ts:440:13)
    at webpack:/module/xxscreeps/src/mods/spawn/spawn.ts:276:9
    at chainIntentChecks (webpack:/module/xxscreeps/src/game/checks.ts:7:18)
    at checkRenewCreep (webpack:/module/xxscreeps/src/mods/spawn/spawn.ts:274:9)
    at webpack:/module/xxscreeps/src/mods/spawn/spawn.ts:157:10
    at chainIntentChecks (webpack:/module/xxscreeps/src/game/checks.ts:7:18)
    at StructureSpawn.renewCreep (webpack:/module/xxscreeps/src/mods/spawn/spawn.ts:156:10)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions