[bug] Phantom X - phantom is revealed

Moderators: Duck_42, mead

[bug] Phantom X - phantom is revealed

Postby Frozen_byte » 26 May 2012, 20:22

Even if all settings are set to "never" the Phantom will be revealed.
Tested twice.
~¿Quis custodes custodit?~
User avatar
Frozen_byte
Avatar-of-War
 
Posts: 208
Joined: 21 Sep 2011, 22:03
Has liked: 37 times
Been liked: 22 times
FAF User Name: Frozen_byte

Re: [bug] Phantom X - phantom is revealed

Postby Duck_42 » 03 Jun 2012, 02:32

Frozen_Byte,

I noticed the same thing while playing a phantom game. I tested the mod with AIs, and had the same problem. I checked the LUA code for the mod, and that's not the only bug in the mod. The way it's coded causes the problem you mentioned and also makes the reveal times cumulative.

For the following scenario:
Phantom 1 Reveal Time: 5 minutes
Phantom 2 Reveal Time: 5 minutes
Phantom 3 Reveal Time: 5 minutes

You'd expect the mod to have revealed all phantoms by 8 + 5 + 5 + 5 = 23 minutes. Instead, it ends up being 62 minutes
(8 assignment + (8 + 5 phantom 1) + (8+5+5 phantom 2) + (8 + 5 + 5 + 5 phantom 3).

I'm going to try to put together a fixed version of the code in the next few days and post it here. That being said, I don't have anything to do with FA Forever development, so I can't actually apply the fix.
User avatar
Duck_42
Avatar-of-War
 
Posts: 237
Joined: 29 May 2012, 03:16
Has liked: 5 times
Been liked: 18 times
FAF User Name: Duck_42

Re: [bug] Phantom X - phantom is revealed

Postby Duck_42 » 03 Jun 2012, 09:03

Ok, here's the fix. Now we just need someone to patch FAF with it.

:!: DISCLAIMER :!:
This is the first LUA code I've actually written ;) , so it's possible I could have goofed something up. I did run it through a quick test, and it appears to work right...

In PhantomSim.lua...

replace beginning of PhantomMainThread function with this...
Code: Select all
function PhantomMainThread()
#   cur.config.declare = ScenarioInfo.Options.PhantomDeclareTime
#   cur.config.vote = cur.config.declare - (1 * 60)
   
   #Bugfix #1: Removed cummulative addition of reveal times
   cur.config.reveal1 = (tonumber(ScenarioInfo.Options.PhantomRevealTime1) * 60)
   cur.config.reveal2 = (tonumber(ScenarioInfo.Options.PhantomRevealTime2) * 60)
   cur.config.reveal3 = (tonumber(ScenarioInfo.Options.PhantomRevealTime3) * 60)
   
   #Old Code
   #cur.config.reveal1 = cur.config.declare + (tonumber(ScenarioInfo.Options.PhantomRevealTime1) * 60)
   #cur.config.reveal2 = cur.config.reveal1 + (tonumber(ScenarioInfo.Options.PhantomRevealTime2) * 60)
   #cur.config.reveal3 = cur.config.reveal2 + (tonumber(ScenarioInfo.Options.PhantomRevealTime3) * 60)

   ...original function continues...


The DoneShowingPhantoms function doesn't really have to be changed, I just tweaked the wording a little...
Code: Select all
function DoneShowingPhantoms(cnt)
   if(cnt == 0) then
      Sync.pAlert("All Phantoms have been revealed.")
   end
   if(cnt == 1) then
      Sync.pAlert("Revealable Phantoms are now known.  One more remains hidden.")
   else
      Sync.pAlert("Revealable Phantoms are now known.  "..cnt.." more remain hidden.")
   end
end


Finally, replace the PhantomRevealThread function with this code...
Code: Select all
function PhantomRevealThread()
   LOG('starting phantom reveal thread')
#   WaitSeconds(cur.config.reveal1)

   pRevealed = {
      phant1 = nil,
      phant2 = nil,
      phant3 = nil
   }
   
   local maxPhants = table.getn(cur.phantoms)

   #BugFix 2:      Rearranged reveal logic to correctly handle all scenarios
   #Assumptions:   Once we encounter a reveal time of zero, it is assumed that all revelations are done. 
   #      i.e. If phantom 1's reveal time is Never, then phantoms 2 and 3 will not be revealed either.
   
   #Build a table to use in our loop
   local revealtimes = {}
   revealtimes[1] = cur.config.reveal1
   revealtimes[2] = cur.config.reveal2
   revealtimes[3] = cur.config.reveal3
   
   for index, p in cur.phantoms do
      #If reveal time is "never", break from this thread...
      if(revealtimes[index] == 0) then
         DoneShowingPhantoms(maxPhants - index + 1)
         do return end
      else
         WaitSeconds(revealtimes[index])
         Sync.pAlert = { ArmyBrains[p].Nickname.." is a phantom!", "KILL HIM." }
         LOG('revealed phantom: ', ArmyBrains[p].Nickname)
      end
      
      if(index == 1) then
         pRevealed.phant1 = ArmyBrains[p].Nickname
      end
      if(index == 2) then
         pRevealed.phant2 = ArmyBrains[p].Nickname
      end
      if(index == 3) then
         pRevealed.phant3 = ArmyBrains[p].Nickname
      end
      
      Sync.pRevealed = pRevealed
      LOG('syncing from sim')
   end
   
   WaitSeconds(10)
   Sync.pAlert("All Phantoms have been revealed.")
end


Here's the fixed LUA file in its entirety
PhantomSim.zip
Fixed PhantomSim.lua file for Phantom-X
(4.07 KiB) Downloaded 196 times

ok... bedtime. :shock:
User avatar
Duck_42
Avatar-of-War
 
Posts: 237
Joined: 29 May 2012, 03:16
Has liked: 5 times
Been liked: 18 times
FAF User Name: Duck_42

Re: [bug] Phantom X - phantom is revealed

Postby noobymcnoobcake » 03 Jun 2012, 10:30

Yes i noticed this too. Now if only we can get them to put that in update.

Does only the host need this fix? Or everyone in the game?
User avatar
noobymcnoobcake
Evaluator
 
Posts: 672
Joined: 17 Sep 2011, 16:34
Has liked: 16 times
Been liked: 5 times

Re: [bug] Phantom X - phantom is revealed

Postby Plasma_Wolf » 03 Jun 2012, 10:52

Doesn't really matter I think, we only have to let this be applied in a central FAF update and all accounts will follow as soon as they log in.
User avatar
Plasma_Wolf
Supreme Commander
 
Posts: 1335
Joined: 20 Oct 2011, 11:28
Has liked: 23 times
Been liked: 91 times
FAF User Name: Plasma_Wolf

Re: [bug] Phantom X - phantom is revealed

Postby Ze_PilOt » 03 Jun 2012, 16:47

That's the spirit, if you want something done, do it ! :)

Thank you, I'm updating the online version.
Nossa wrote:I've never played GPG or even heard of FA until FAF started blowing up.
User avatar
Ze_PilOt
Supreme Commander
 
Posts: 8985
Joined: 24 Aug 2011, 18:41
Location: fafland
Has liked: 18 times
Been liked: 376 times
FAF User Name: Ze_PilOt

Re: [bug] Phantom X - phantom is revealed

Postby noobymcnoobcake » 03 Jun 2012, 17:11

Thanks Zep ^^
User avatar
noobymcnoobcake
Evaluator
 
Posts: 672
Joined: 17 Sep 2011, 16:34
Has liked: 16 times
Been liked: 5 times

Re: [bug] Phantom X - phantom is revealed

Postby uberge3k » 03 Jun 2012, 17:17

Thank you very much Duck_42, really appreciate the initiative. :)
Ze_PilOt wrote:If you want something to happen, do it yourself.
User avatar
uberge3k
Supreme Commander
 
Posts: 1034
Joined: 04 Sep 2011, 13:46
Has liked: 2 times
Been liked: 48 times
FAF User Name: TAG_UBER

Re: [bug] Phantom X - phantom is revealed

Postby noobymcnoobcake » 03 Jun 2012, 18:04

Another issue - Storages have 3599 values. E storage only holds 2k. I believe they were changed so they dont go up and down. This is because you could tell who the phantoms were by watching then as phantoms get resource bonuses.
User avatar
noobymcnoobcake
Evaluator
 
Posts: 672
Joined: 17 Sep 2011, 16:34
Has liked: 16 times
Been liked: 5 times

Re: [bug] Phantom X - phantom is revealed

Postby Duck_42 » 03 Jun 2012, 18:34

Changing the storage should just be a matter of adjusting the blueprint files. I'll see about fixing that.

I also misunderstood the Sync.pAlert syntax when I was fixing the LUA code, so I broke part of the announcements in my fix. :oops:

So, for the next fix, I've got:
-Fix announcement bug
-Correct energy and mass storage values
-Add phantom numbering to assignment display (so if you're phantom, you'll know where you are in the reveal order).
-Fix reveal countdown timer so that it doesn't keep counting down after all revealable phantoms have been shown.
(this only happens if Phantom 1 or 2 are set to never and phantom 2 or 3 are set to some number)
User avatar
Duck_42
Avatar-of-War
 
Posts: 237
Joined: 29 May 2012, 03:16
Has liked: 5 times
Been liked: 18 times
FAF User Name: Duck_42

Next

Return to Phantom-X

Who is online

Users browsing this forum: No registered users and 1 guest