-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Bug] Placing ships #41
Comments
I created a diffrent test case:
for both clients
This time it works.... so there might be then the issue on my side. |
The result of my "research" is that when ever the server gets mixed values such as in the first example it gets confused and places them inside of the same 10x10 grid.
Example 2: "Wrong" setting:
There are 2 solutions to this problem:
a_Y = (a_Y > g_BoardWidth)? a_Y - g_BoardWidth : a_y; In the function: ECollision BattleShipsGame::PlaceShip(EPlayer a_Player, EShip a_Ship, uint32_t a_X, uint32_t a_Y, EDirection a_Direction)
{
AssertMessage(nullptr != m_Board, "Attempt to place a ship without a valid board!");
AssertMessage(!m_PlacementDone[static_cast<uint32_t>(a_Player)], "Attempt to place a ship while the player finalized ship placement already!");
AssertMessage(a_X < g_BoardWidth && a_Y < g_BoardHeight << 2, "Attempt to place a ship on an invalid position!");
ECollision collision = ECollision_None;
if (EPlayer_Two == a_Player)
{
// for player two, turn the board upside-down (flip x and y coordinate and direction)
a_Y = (a_Y > g_BoardWidth)? a_Y - g_BoardWidth : a_y;
collision = m_Board->AddShip(a_Player, a_Ship, FlipX(a_X), FlipY(a_Y), FlipDirection(a_Direction));
}
else if (EPlayer_One == a_Player)
{
// for player one, keep the board as is
a_Y = (a_Y > g_BoardWidth)? a_Y - g_BoardWidth : a_y;
collision = m_Board->AddShip(a_Player, a_Ship, a_X, a_Y, a_Direction);
}
return collision;
} This approach is tested and would work. The question is more if it is the responsibility of the Server to correct the data or if it is more the responsibility of the client to provide the correct data. This is something the Server Author has to decide. |
I am not sure if this is a bug or if this is what you want. I made the server print out the placements of the ships.
The placements: (based on the server out put)
player 1
player 2:
The data the client i sending over to the server:
it looks like the server is not flipping the X|Y coordinates correctly. Important here is is this a problem by me (my server) or as well as the server at the uni. I will investigate this further by pulling down the latest and build.
The text was updated successfully, but these errors were encountered: