Fleet locking randomly - OPBE - "Trying to decrease Tech"

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Fleet locking randomly - OPBE - "Trying to decrease Tech"

      Hi again :)

      Im using 2moons 2.0

      As the original Battle Engine was quite buggy for us I decided to switch to OPBE as some in this forum suggested. It was said that OPBE should be compatible with any 2moons-version but there might be some complications so maybe this problem is a problem with the version? anyway, lets geht to the error:

      Sometimes a fleet of a player is locking so I have to unlock it via admin-panel. This happens around twice a day. This is the error.log which seems to be the reason but im not sure as I sometimes have 2 lockes Fleets of 2 different players but only one error

      Source Code

      1. [03-Jan-2020 14:16:49] USER ERROR: "Trying to decrease tech"
      2. File: /var/www/html/fjdn/2moons/includes/libs/opbe/models/ShipType.php | Line: 106
      3. URL: https://fjdn.ddns.net/fjdn/2moons/game.php?page=overview | Version: 2.0.git
      4. Stack trace:
      5. #0 /includes/libs/opbe/models/Fleet.php(69): ShipType->setWeaponsTech(-1)
      6. #1 /includes/libs/opbe/models/Player.php(64): Fleet->setTech(-1, 0, -3)
      7. #2 /includes/libs/opbe/implementations/2Moons/1_7_2_injectionMode/calculateAttack.php(110): Player->addFleet(Object(HomeFleet))
      8. #3 /includes/classes/missions/MissionCaseExpedition.class.php(361): calculateAttack(Array, Array, '30', '0')
      9. #4 /includes/classes/class.FlyingFleetHandler.php(86): MissionCaseExpedition->EndStayEvent()
      10. #5 /includes/FleetHandler.php(31): FlyingFleetHandler->run()
      11. #6 /includes/common.php(127): require('/var/www/html/f...')
      12. #7 /game.php(24): require('/var/www/html/f...')
      13. #8 {main}
      Display All


      so as it seems i get negative values for the Techlevels. To be honest I dont understand the variables in the ShipType.php:

      Source Code

      1. public function setWeaponsTech($level)
      2. {
      3. if (!is_numeric($level))
      4. return;
      5. $level = intval($level);
      6. $diff = $level - $this->weapons_tech;
      7. if ($diff < 0)
      8. throw new Exception('Trying to decrease tech');
      9. $this->weapons_tech = $level;
      10. $incr = 1 + WEAPONS_TECH_INCREMENT_FACTOR * $diff;
      11. $this->singlePower *= $incr;
      12. $this->fullPower *= $incr;
      13. }
      Display All

      Is there a Problem with the $level-variable? maybe the problem lies in the calculateAttack.php?

      I hope someone can help me finding the problem :)

      happy new year btw
    • Yes thats the bug with OPBE. Just catch the Techlevels when its negative and add if(Techlevels < 0) {Techlevels = 0}
      This will not allow the techlevel be under 0.
    • I now did it like this although I do not know if this solves the problem or creates new ones:

      Source Code

      1. public function setWeaponsTech($level)
      2. {
      3. if (!is_numeric($level))
      4. return;
      5. $level = intval($level);
      6. $diff = $level - $this->weapons_tech;
      7. if ($diff < 0)
      8. {
      9. throw new Exception('Trying to decrease tech');
      10. $diff = 0;
      11. }
      12. $this->weapons_tech = $level;
      13. $incr = 1 + WEAPONS_TECH_INCREMENT_FACTOR * $diff;
      14. $this->singlePower *= $incr;
      15. $this->fullPower *= $incr;
      16. }
      Display All

      I hope this does not fiddle with the battleengine, i will report after a while as this error does need some time to occur
    • Source Code

      1. public function setWeaponsTech($level)
      2. {
      3. if (!is_numeric($level))
      4. return;
      5. $level = intval($level);
      6. $diff = $level - $this->weapons_tech;
      7. if ($diff < 0)
      8. {
      9. $diff = 0;
      10. }
      11. $this->weapons_tech = $level;
      12. $incr = 1 + WEAPONS_TECH_INCREMENT_FACTOR * $diff;
      13. $this->singlePower *= $incr;
      14. $this->fullPower *= $incr;
      15. }
      Display All
      If the expection is deleted the fleets wont lock anymore. this is a rather messy approach for that problem i guess