HarbourMasters / 2ship2harkinian

Creative Commons Zero v1.0 Universal
772 stars 64 forks source link

Spawning certain Actors via the Actor List Crashes. #575

Closed bluexephops closed 1 day ago

bluexephops commented 4 months ago

Description of the crash:

In the actor viewer, selecting new and spawning certain actors like Epona (ID 13) and Iron Knuckle (ID 132(param 1 doesn't crash)) causes the program to crash.

Can you reproduce? If so please list the steps:

  1. Open Actor viewer under Developer Tools
  2. Go to new and select ID:13
  3. Select spawn
  4. crash

    Logs:

    2 Ship 2 Harkinian.log

System Information:

Additional Information:

Seems to happen no matter what location I'm in. Remove object dependency is turned on.

Archez commented 3 months ago

Spawning actors requires that the correct params are passed in that match the actor. Each actor treats their params differently. Some use it for simple checks, others may use it to index structures. If an unexpected value is used, this could lead to crashing.

Unfortunately, since all the game code is in C, there isn't really a simple way to do something like a try / catch to safely abort spawning the actor.

My stance on this type of issue is that the actor viewer is meant purely as a debug tool. If you don't use it correctly, you are bound to run into problems. Trying to make the debug tool "safe" would require us to basically catalog all possible "good" values, which is purely unrealistic at this moment.

I'll leave this open for a little bit to give others a chance to chime in, but my opinion is "buyer beware". Maybe we can just add a disclaimer that says "incompatible values can lead to crashing".

louist103 commented 1 day ago

I see where the bug is for Iron Knuckles is but I'm not sure if it is in the scope of the project to fix it since it will never crash if spawned "properly"

this->actor.params = IK_GET_ARMOR_TYPE(&this->actor);
this->actor.params--;

In the init function. And then:

gfxArmorType = sIronKnuckleArmorType[this->actor.params];

In the draw function. Its underflowing params and overflowing sIronKnuckleArmorType

louist103 commented 1 day ago

That said I will close it unless someone wants to fix it. I agree with Archez. A better "fix" for this case it to put a warning in the editor.