Skip to content

Commit

Permalink
Merge branch 'the-merge' of github.com:X-R-G-B/R-Bus into the-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
romainpanno committed Nov 5, 2023
2 parents 760899d + adc75ee commit 75b39ff
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 33 deletions.
1 change: 0 additions & 1 deletion src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ namespace Menu {
{
auto idsButton = Registry::getInstance().getEntitiesByComponents({typeid(Types::Button)});

Logger::error("!!!!!!!!!!!sendReadyPacket!!!!!!");
Nitwork::NitworkClient::getInstance().addReadyMsg();
for (auto &id : idsButton) {
Registry::getInstance().removeEntity(id);
Expand Down
6 changes: 3 additions & 3 deletions src/Client/Systems/Menus/Menu/MenuSystems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ namespace Systems {
::Menu::MenuBuilder::getInstance().initMenuSceneEntity(
Json::getInstance().getDatasFromList(jsonData));
} catch (std::runtime_error &err) {
Logger::info(err.what());
Logger::warn(err.what());
}
SystemManagersDirector::getInstance().getSystemManager(managerId).removeSystem(systemId);
}
Expand Down Expand Up @@ -254,11 +254,11 @@ namespace Systems {
return;
}
try {
// Parallax::initParalax();
Parallax::initParalax();
preloadTexture();
initHud();
} catch (std::runtime_error &err) {
Logger::info(err.what());
Logger::warn(err.what());
}
SystemManagersDirector::getInstance().getSystemManager(managerId).removeSystem(systemId);
}
Expand Down
1 change: 0 additions & 1 deletion src/Client/Systems/Network/ClientNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ namespace Systems {
}
for (auto &id : otherPlayersIds) {
if (arrOtherPlayers[id].constId == playerDeath.playerId) {
Logger::fatal("Other player death: " + std::to_string(playerDeath.playerId));
arrHealth[id].hp = 0;
return;
}
Expand Down
4 changes: 0 additions & 4 deletions src/Game/CreateMissiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ namespace Systems {
#ifdef CLIENT
static void addSpriteRectsForBullet(nlohmann::json &bulletData, Types::CollisionRect &collisionRect)
{
Logger::fatal("cacaaaaaaaaaaaaaaaaaaa------------------------------------------");
Json &json = Json::getInstance();
const std::string bulletPath = json.getDataFromJson<std::string>(bulletData, "spritePath");
Types::Rect spriteRect = json.getDataFromJson<Types::Rect>(bulletData, "spriteRect");
Expand All @@ -100,11 +99,9 @@ namespace Systems {

std::size_t createPlayerMissile(Types::Position pos, Types::Missiles &typeOfMissile)
{
Logger::fatal("Create missile");
if (typeOfMissile.type >= MAX_MISSILE_TYPE || typeOfMissile.type < 0) {
throw std::runtime_error("Unknown missile type");
}
Logger::fatal("Create missile2");
Json &json = Json::getInstance();
std::size_t id = Registry::getInstance().addEntity();
nlohmann::json bulletData =
Expand All @@ -125,7 +122,6 @@ namespace Systems {

Registry::getInstance().getComponents<Types::PlayerAllies>().insertBack(playerAlliesComp);
addPhysicsToEntity(bulletData, pos);
Logger::fatal("type of missile = " + std::to_string(typeOfMissile.type) + " pos = " + std::to_string(pos.x) + " " + std::to_string(pos.y));
Registry::getInstance().getComponents<Types::Position>().insertBack(pos);
Registry::getInstance().getComponents<Types::CollisionRect>().insertBack(collisionRect);
Registry::getInstance().getComponents<Types::Missiles>().insertBack(missileType);
Expand Down
5 changes: 0 additions & 5 deletions src/Game/GameSystems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ namespace Systems {

static void sendMissileDeath(std::size_t arrId)
{
Logger::fatal("start send missile death");
auto &arrMissiles = Registry::getInstance().getComponents<Types::Missiles>();

if (arrMissiles.exist(arrId)) {
Expand All @@ -96,7 +95,6 @@ namespace Systems {

static void sendEnemyDeath(std::size_t arrId)
{
Logger::fatal("start send enemy death");
auto &arrEnemies = Registry::getInstance().getComponents<Types::Enemy>();

if (!arrEnemies.exist(arrId)) {
Expand All @@ -107,7 +105,6 @@ namespace Systems {
#else
Nitwork::NitworkServer::getInstance().addEnemyDeathMessage(arrEnemies[arrId].getConstId().id);
#endif
Logger::fatal("end send enemy death");
}
#ifdef CLIENT
static void sendLifeUpdateToServer(std::size_t id)
Expand All @@ -124,7 +121,6 @@ namespace Systems {

static void sendPlayerDeathToServer(std::size_t id)
{
Logger::fatal("start send player death");
auto &arrPlayer = Registry::getInstance().getComponents<Types::Player>();
auto &arrOtherPlayer = Registry::getInstance().getComponents<Types::OtherPlayer>();

Expand All @@ -135,7 +131,6 @@ namespace Systems {
Logger::debug("other player send death " + std::to_string(id));
Nitwork::NitworkClient::getInstance().addPlayerDeathMsg(arrOtherPlayer[id].constId);
}
Logger::fatal("end send player death");
}
#endif

Expand Down
3 changes: 1 addition & 2 deletions src/Nitwork/ANitwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ namespace Nitwork {
try {
action.second(action.first.data, action.first.endpoint);
} catch (std::exception &e) {
Logger::fatal("StartInputHandler:");
Logger::error("NITWORK: catch action: " + std::string(e.what()));
Logger::error("StartInputHandler: NITWORK: catch action: " + std::string(e.what()));
}
}
_actions.clear();
Expand Down
10 changes: 0 additions & 10 deletions src/Nitwork/NitworkClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,10 @@ namespace Nitwork {
},
.msg = {.magick = MAGICK_DISCONNECT_LOBBY},
};
Logger::error("------------------------------------ Sending disconnect lobby msg: " + std::to_string(NITWORK_DISCONNECT_LOBBY) + " " + std::to_string(MAGICK_DISCONNECT_LOBBY));
Packet packet(
packetDisconnectLobby.action.magick,
std::make_any<struct packetDisconnectLobby_s>(packetDisconnectLobby),
_serverEndpoint);
Logger::fatal("Disconnecting from lobby");
addPacketToSend(packet);
}

Expand All @@ -172,7 +170,6 @@ namespace Nitwork {
},
.msgInit = {.magick = MAGICK_INIT}
};
Logger::error("------------------------------------ Sending init msg: " + std::to_string(NITWORK_INIT) + " " + std::to_string(MAGICK_INIT));
Packet packet(
packetMsgInit.action.magick,
std::make_any<struct packetMsgInit_s>(packetMsgInit),
Expand All @@ -188,7 +185,6 @@ namespace Nitwork {
.action = {.magick = NITWORK_READY},
.msgReady = {.magick = MAGICK_READY}
};
Logger::error("------------------------------------ Sending ready msg: " + std::to_string(NITWORK_READY) + " " + std::to_string(MAGICK_READY));
Packet packet(
packetMsgReady.action.magick,
std::make_any<struct packetMsgReady_s>(packetMsgReady),
Expand Down Expand Up @@ -284,7 +280,6 @@ namespace Nitwork {
.life = life,
},
};
Logger::error("------------------------------------ Sending life update msg: " + std::to_string(playerId) + " " + std::to_string(MAGICK_LIFE_UPDATE));
Packet packet(
packetLifeUpdate.action.magick,
std::make_any<struct packetLifeUpdate_s>(packetLifeUpdate),
Expand Down Expand Up @@ -348,7 +343,6 @@ namespace Nitwork {
.missileId = id,
},
};
Logger::error("------------------------------------ Sending missile death msg: " + std::to_string(NITWORK_MISSILE_DEATH) + " " + std::to_string(MAGICK_MISSILE_DEATH));
Packet packet(
packetMissileDeath.action.magick,
std::make_any<struct packetMissileDeath_s>(packetMissileDeath),
Expand All @@ -366,7 +360,6 @@ namespace Nitwork {
},
.msg = {.magick = MAGICK_REQUEST_LIST_LOBBY},
};
Logger::error("------------------------------------ Sending list lobby msg: " + std::to_string(NITWORK_LIST_LOBBY) + " " + std::to_string(MAGICK_REQUEST_LIST_LOBBY));
Packet packet(
packetListLobby.action.magick,
std::make_any<struct packetRequestListLobby_s>(packetListLobby),
Expand All @@ -393,7 +386,6 @@ namespace Nitwork {
.maxNbPlayer = maxNbPlayer,
.ownerInfos = {.ip = "", .port = _mainServerEndpoint.port()}}
};
Logger::error("------------------------------------ Sending create lobby msg: " + std::to_string(NITWORK_CREATE_LOBBY) + " " + std::to_string(MAGICK_CREATE_LOBBY));
std::strcpy(packetCreateLobby.msg.name, (name.size() > 32 ? name.substr(0, 32) : name).c_str());
std::strcpy(
packetCreateLobby.msg.ownerInfos.ip,
Expand All @@ -419,7 +411,6 @@ namespace Nitwork {
},
.msg = {.magick = MAGICK_CONNECT_MAIN_SERVER},
};
Logger::error("------------------------------------ Sending connect main server msg: " + std::to_string(NITWORK_CONNECT_MAIN_SERVER) + " " + std::to_string(MAGICK_CONNECT_MAIN_SERVER));
Packet packet(
packetConnectMainServer.action.magick,
std::make_any<struct packetConnectMainServer_s>(packetConnectMainServer),
Expand All @@ -438,7 +429,6 @@ namespace Nitwork {
},
.msg = {.magick = MAGICK_CONNECT_LOBBY},
};
Logger::error("------------------------------------ Sending connect lobby msg: " + std::to_string(NITWORK_CONNECT_LOBBY) + " " + std::to_string(MAGICK_CONNECT_LOBBY));
Packet packet(
packetConnectLobby.action.magick,
std::make_any<struct packetConnectLobby_s>(packetConnectLobby),
Expand Down
2 changes: 1 addition & 1 deletion src/Nitwork/NitworkMainServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace Nitwork {
void NitworkMainServer::handleInitMsg(std::any & /* unused */, boost::asio::ip::udp::endpoint &endpoint)
{
if (isClientAlreadyConnected(endpoint)) {
Logger::info("Client already connected");
Logger::warn("Client already connected");
sendConnectMainServerResp(endpoint);
return;
}
Expand Down
10 changes: 4 additions & 6 deletions src/Nitwork/NitworkServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,13 @@ namespace Nitwork {
bool canConnect = true;

if (_isGameStarted) {
Logger::info("Game already started, connection refused");
Logger::warn("Game already started, connection refused");
return;
}
if (msgData.magick != MAGICK_CONNECT_LOBBY) {
Logger::error("Error: magick not matching");
return;
}
Logger::error("magick connect lobby = " + std::to_string(msgData.magick) + " (" + MAGICK_CONNECT_LOBBY + ")");
if (_endpoints.size() >= _serverInfos.maxNbPlayer) {
Logger::error("Too many clients, can't add an other one");
canConnect = false;
Expand All @@ -202,7 +201,7 @@ namespace Nitwork {
{
std::lock_guard<std::mutex> lock(Registry::getInstance().mutex);
if (_isGameStarted) {
Logger::info("Game already started, connection refused");
Logger::warn("Game already started, connection refused");
return;
}
if (_endpoints.size() >= _serverInfos.maxNbPlayer) {
Expand All @@ -213,7 +212,6 @@ namespace Nitwork {
Logger::error("Client already connected");
return;
}
Logger::error("WTF WTF ICI");
_endpoints.emplace_back(endpoint);
auto playerId = static_cast<n_id_t>(_endpoints.size() - 1);
auto &jsonInstance = Json::getInstance();
Expand Down Expand Up @@ -251,7 +249,7 @@ namespace Nitwork {
NitworkServer::handleReadyMsg(const std::any & /* unused */, boost::asio::ip::udp::endpoint &endpoint)
{
if (_isGameStarted) {
Logger::info("Game already started, connection refused");
Logger::warn("Game already started, connection refused");
return;
}
if (!isClientAlreadyConnected(endpoint)) {
Expand All @@ -273,7 +271,7 @@ namespace Nitwork {
NitworkServer::handleRelativePositionMsg(const std::any &msg, boost::asio::ip::udp::endpoint &endpoint)
{
if (!isClientAlreadyConnected(endpoint)) {
Logger::info("Client not connected");
Logger::warn("Client not connected");
return;
}
auto msgData = std::any_cast<struct msgPositionRelative_s>(msg);
Expand Down

0 comments on commit 75b39ff

Please sign in to comment.