• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Wurst] Frentity: "Trying to assign entity to unit that already has an entity"

Status
Not open for further replies.
Level 19
Joined
Apr 28, 2008
Messages
76
What is wrong with this code?

BattleSystem.wurst
Wurst:
package BattleSystem

import Entity

public abstract class BattleUnit extends UnitEntity

  construct(player p, int unitId, vec2 pos, angle facing)
    super(createUnit(p, unitId, pos, facing))

Summoner.wurst
Wurst:
package Summoner

import BattleSystem

public class Summoner extends BattleUnit

  construct(player p, vec2 pos, angle facing)
    super(p, SUMMONER_ID, pos, facing)

But when I call new Summoner() more than once it causes an error.
"Trying to assign entity to unit that already has an entity"
But I do not understand, because every time createUnit(p, unitId, pos, facing) was called it should be a new instance.
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
You code sample is too incomplete to judge. Frentity uses the UnitIndexer to attach entities to units, and the check for the error is a simple unit.getEntity() != null.
Thus apparently that unit-index already has an entity. Are you doing other illegal operations? Do you make use of custom unit UserData? Do you remove the unit without terminating the entity?
It can be caused by something else you did, leaving undestroyed entities. You could add some debug to see how many Battleunits/Entites get created, and how many destroyed to find leaks.

The error should normally print you a stacktrace, perhaps post that one as well to find the order of execution.

Also, does the error just occur now and it worked before, or did it never work? Are you dependencies up to date (using setup-> update project) ?
 
Status
Not open for further replies.
Top