frnsys / half_earth

Half-Earth Socialism: The Game, for Half-Earth Socialism (Verso 2022)
GNU Affero General Public License v3.0
39 stars 7 forks source link

Dialogue branching crash #181

Closed frnsys closed 2 years ago

frnsys commented 2 years ago

recursive use of an object detected which would lead to unsafe aliasing in rust

./engine/pkg/half_earth_engine_bg.js in eval_branch_conditions at line 468:19
./src/game.js in Object.evalBranchConditions at line 188:15
./src/components/Dialogue.vue at line 219:18
<anonymous> in Proxy.find
./src/components/Dialogue.vue in nextLine at line 218:37
./src/components/Dialogue.vue in advance at line 211:14
./src/components/Dialogue.vue in apply at line 159:14

session: 208b03c6-c3c1-628f-3411-15ae76b97b02

We aren't using dialogue branch conditions in many places so hopefully not too difficult to narrow down the dialogue causing the problem.

frnsys commented 2 years ago

I think the only event that actually uses branch conditions is "New Cuisine"

frnsys commented 2 years ago

Just saw the actual error:

panicked at 'index out of bounds: the len is 0 but the index is 0', src/game.rs:121:34

So somehow branch_eval_conditions is getting branch ids that don't exist:

      if (Array.isArray(this.line.next)) {
        let branch = this.line.next.find((b) => {
          return game.evalBranchConditions(this.eventId, this.regionId, b.id);
        });
        this.current = branch.line_id;
      } else {