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

Fleet Movement Error Results HTTP 500 Error #448

Closed
asparatu opened this issue Dec 27, 2020 · 8 comments
Closed

Fleet Movement Error Results HTTP 500 Error #448

asparatu opened this issue Dec 27, 2020 · 8 comments
Assignees
Labels
Bug Issues that is an error, bug or it is not working as expected Fixed Issues that after being labeled as Bug have been resolved
Milestone

Comments

@asparatu
Copy link

Describe the bug
There is still an HTTP 500 Error that happens when you have Fleet movements. I believe has only do when transport resource to plant or moon. This error does not happen all the time, but somehow the mission does not get sometimes meaning instead of the value of 3 being set in the fleet table it is zero. I have debugged the whole fleet movement from start to finish there is no place I can see that updates the fleet_mission field expect when inserted. This makes me believe it does not get a set mission value.

app/controllers/game/fleet4.php Line 561
// add the fleet mission $this->_fleet_data['fleet_mission'] = $data['mission'];

I believe the $data['mission'] is not being set.

Screenshots
Database record showing fleet_mission is zero
fleet_movement_error

Debug Error shows the same thing saying offset is zero
fleet_movement_offset_error

When I change the fleet_mission to 3 the HTTP 500 Error is gone and the game portal works again and the fleet movement is completed and deleted from the server.

I would suggest you add value 0 and just call it default or something stop this errro from happening.

Server (please complete the following information):

  • PHP Version: PHP 7.3
  • MySQL Version: MySQL 5.7
@duhow
Copy link
Contributor

duhow commented Dec 27, 2020

Can you provide all steps to reproduce the issue?
Also what XGP version / commit are you using?

@asparatu
Copy link
Author

asparatu commented Dec 27, 2020

@duhow I am using version 3.2.0 (master branch/ commit 5d02f9e)

I created a fleet that 5000 large cargo ships, sent them to my moon, and add some resources about 20k, 40k, 1 million. I select the transport.

Here are database records from other instances, these are on different days.

INSERT INTO xd_fleets VALUES("1470","32","0","400","a:1:{i:209;s:3:\"400\";}","1608077651","1","10","4","1","1608077680","0","1","10","4","3","0","20000","40000","20000","70","32","0","1","1608077622");
INSERT INTO xd_fleets VALUES("1338","17","0","123","a:1:{i:203;s:3:\"123\";}","1607653689","6","1","6","1","1607653712","0","1","4","11","1","0","0","3004685","0","70315","17","0","1","1607653666");
INSERT INTO xd_fleets VALUES("1236","17","0","100","a:1:{i:203;s:3:\"100\";}","1607361021","1","4","10","1","1607361026","0","1","4","11","1","0","0","2034496","0","576","17","0","1","1607361016");

This fleet movement issue does not happen all the time, so I am not sure what happens.

@BeReal86
Copy link
Member

Hi @asparatu, Thank you for your feedback with priority.

I am using php 7.4 version. When I tried on localhost, I did not get any errors. The XGP version I use is in the link below, as you mentioned.

https://github.com/XGProyect/XG-Proyect-v3.x.x/releases/tag/v3.2.0

I will experiment on hosting.

@asparatu
Copy link
Author

asparatu commented Jan 3, 2021

Hello @BeReal86

I found a way to reproduce the fleet movement error. When you get the page that you select the fleet movement if you do not select anything of the option this will set $data['mission'] as zero.

For example, if you just add the resources and don't select transportation or deployment option when press continue it saves to the database. when the fleet gets to where suppose to the code does not know what do and crashes and give the HTTP 500 error because there is no fleet movement number defined.

So, what I can see is there is validation before you save to the database because if there was this error would not happen. This why I said does not happen all the time.

What you can do when you create the objects, set numbers to -1 so easy to validate if the values and strings to NULL and not empty strings.

I have noticed that there has to be more client-side validation and feedback to what is happening, just not resetting the page going to back to the first page of the fleet movement because you do not know what you input wrong or if you are not able to do something. For example when you try to create a planet and if you are certain planet number instead of telling you can not create planet there it just resets the page that is not helpful.

@asparatu
Copy link
Author

Hello @BeReal86

Here is the code I use to fix the problem in the control/game/fleet4.php. This will stop from continuing and not put zero in the fleet_mission database column.

//add if statement to check mission status is zero redirect to fleet1 page 
        if ($data['mission'] == 0) {
            Functions::redirect('game.php?page=fleet1');
         } else {
            // add the fleet mission
            $this->_fleet_data['fleet_mission'] = $data['mission'];
         }

@duhow
Copy link
Contributor

duhow commented Jan 10, 2021

@asparatu do you mean to set that code in here?

if (is_null($data)) {
Functions::redirect('game.php?page=fleet1');
}

@asparatu
Copy link
Author

asparatu commented Jan 10, 2021

Hello @duhow,

// add the fleet mission
$this->_fleet_data['fleet_mission'] = $data['mission'];

if(is_null($data['mission']) || $data['mission'] == 0) {
Functions::redirect('game.php?page=fleet1') }else{
// add the fleet mission
            $this->_fleet_data['fleet_mission']
}

Sorry again.. I am still get use to using git and GitHub.

@BeReal86 BeReal86 added the Bug Issues that is an error, bug or it is not working as expected label Mar 31, 2021
@BeReal86 BeReal86 added this to the v3.3.0 milestone Mar 31, 2021
LucasKovacs added a commit that referenced this issue Dec 26, 2021
@LucasKovacs
Copy link
Member

fixed on 3.3 - thanks for everybody's contribution

@LucasKovacs LucasKovacs added the Fixed Issues that after being labeled as Bug have been resolved label Dec 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues that is an error, bug or it is not working as expected Fixed Issues that after being labeled as Bug have been resolved
Projects
None yet
Development

No branches or pull requests

4 participants