Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STATIC Spawn methods no longer return the group name #1335

Closed
thebgpikester opened this issue Jun 9, 2020 · 3 comments
Closed

STATIC Spawn methods no longer return the group name #1335

thebgpikester opened this issue Jun 9, 2020 · 3 comments
Assignees
Labels
Bug Moose bug that needs to be fixed. High Prio Urgent matter of high priority. Needs to be fixed within days.

Comments

@thebgpikester
Copy link
Collaborator

Additionally think there is an issue with spawned statics being registered in the database, since the last update.

Version not working:
2020-06-09 14:37:32.581 INFO SCRIPTING: *** MOOSE GITHUB Commit Hash ID: 2020-05-27T20:19:25.0000000Z-55760fcb42896f68fe0e6c58eaccbb40cf3e1fbf ***

Version working:
2020-06-09 14:36:37.538 INFO SCRIPTING: *** MOOSE GITHUB Commit Hash ID: 2020-05-20T21:04:36.0000000Z-9e4273f0667216536e5549f035b9660722deeffc ***

Additionally:
2020-06-09 14:36:44.421 INFO SCRIPTING: 13027( 29769)/I: DATABASE00003._RegisterStaticTemplate({[Coalition]=2,[Static]=Boron#001,[Country]=2,[Category]=4,})

No longer appears in the logs when spawning statics. Possibly not added to database

CODE:

zone = ZONE:FindByName( "z_test" )
vec2 = zone:GetVec2()
place = POINT_VEC2:NewFromVec2(vec2)

test1 = SPAWNSTATIC:NewFromStatic( "UH-1H cargo", country.id.USA )
static = test1:SpawnFromPointVec2(place, 1, ("Boron#001" )  )
s_name = static:GetName()
    env.info(" Spawned NEW cargo at ".. zone:GetName() .." called " .. s_name )

On broken moose the error is

2020-06-09 14:37:41.878 ERROR   DCS: Mission script error: : [string "    local s_name = static:GetName()..."]:1: attempt to index global 'static' (a nil value)
stack traceback:
	[C]: ?
	[string "    local s_name = static:GetName()..."]:1: in main chunk

The attached mission has the broken version, you can downgrade it to see working.

To reproduce, run the miz, observe the logs, either error or logging after a few seconds.

@thebgpikester thebgpikester added Bug Moose bug that needs to be fixed. High Prio Urgent matter of high priority. Needs to be fixed within days. labels Jun 9, 2020
@thebgpikester
Copy link
Collaborator Author

static_test1_fucked.zip

@thebgpikester
Copy link
Collaborator Author

OLD method

function SPAWNSTATIC:SpawnFromPointVec2( PointVec2, Heading, NewName ) --R2.1
  self:F( { PointVec2, Heading, NewName  } )
  
  local StaticTemplate, CoalitionID, CategoryID, CountryID = _DATABASE:GetStaticGroupTemplate( self.SpawnTemplatePrefix )
  
  if StaticTemplate then
  
    local StaticUnitTemplate = StaticTemplate.units[1]
  
    StaticUnitTemplate.x = PointVec2.x
    StaticUnitTemplate.y = PointVec2.z
  
    StaticTemplate.route = nil
    StaticTemplate.groupId = nil
    
    StaticTemplate.name = NewName or string.format("%s#%05d", self.SpawnTemplatePrefix, self.SpawnIndex )
    StaticUnitTemplate.name = StaticTemplate.name
    StaticUnitTemplate.heading = ( Heading / 180 ) * math.pi
    
    _DATABASE:_RegisterStaticTemplate( StaticTemplate, CoalitionID, CategoryID, CountryID)
    
    self:F({StaticTemplate = StaticTemplate})

    local Static = coalition.addStaticObject( self.CountryID or CountryID, StaticTemplate.units[1] )
    
    self.SpawnIndex = self.SpawnIndex + 1
    
    return _DATABASE:FindStatic(Static:getName())
  end
  
  return nil
end

NEW method:

function SPAWNSTATIC:SpawnFromPointVec2(PointVec2, Heading, NewName)

  local vec2={x=PointVec2:GetX(), y=PointVec2:GetY()}

  local Coordinate=COORDINATE:NewFromVec2(vec2)
  
  return self:SpawnFromCoordinate(Coordinate, Heading, NewName)
end

@funkyfranky
Copy link
Collaborator

yes, that seems to be a problem specific to cargo statics. other statics work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Moose bug that needs to be fixed. High Prio Urgent matter of high priority. Needs to be fixed within days.
Projects
None yet
Development

No branches or pull requests

2 participants