Compare commits
No commits in common. "c3a7148686d87a3cb68704304888c4743fb505b0" and "4d60403adf9b43d5efa1bc4f4d0f21615560dbda" have entirely different histories.
c3a7148686
...
4d60403adf
2 changed files with 9 additions and 7 deletions
|
|
@ -52,9 +52,9 @@ PacketHandler::HandlePacket(std::shared_ptr<Session> session,
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case PacketID::CS_UpgradeSword: {
|
case PacketID::CS_UpgradeSword: {
|
||||||
auto currentLevel = session->GetSwordLevel();
|
uint32_t currentLevel = session->GetSwordLevel();
|
||||||
auto cost = SwordLogic::GetUpgradeCost(currentLevel);
|
uint64_t cost = SwordLogic::GetUpgradeCost(currentLevel);
|
||||||
auto currentGold = session->GetGold();
|
uint64_t currentGold = session->GetGold();
|
||||||
|
|
||||||
Protocol::SC_UpgradeResult res;
|
Protocol::SC_UpgradeResult res;
|
||||||
if (currentGold < cost) {
|
if (currentGold < cost) {
|
||||||
|
|
@ -62,7 +62,7 @@ PacketHandler::HandlePacket(std::shared_ptr<Session> session,
|
||||||
res.set_result(2);
|
res.set_result(2);
|
||||||
} else {
|
} else {
|
||||||
session->SetGold(currentGold - cost);
|
session->SetGold(currentGold - cost);
|
||||||
auto result = SwordLogic::TryUpgrade(currentLevel);
|
uint8_t result = SwordLogic::TryUpgrade(currentLevel);
|
||||||
res.set_result(result);
|
res.set_result(result);
|
||||||
|
|
||||||
// 성공
|
// 성공
|
||||||
|
|
@ -113,9 +113,9 @@ PacketHandler::HandlePacket(std::shared_ptr<Session> session,
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case PacketID::CS_SellSword: {
|
case PacketID::CS_SellSword: {
|
||||||
auto currentLevel = session->GetSwordLevel();
|
uint32_t currentLevel = session->GetSwordLevel();
|
||||||
auto price = SwordLogic::GetSellPrice(currentLevel);
|
uint64_t price = SwordLogic::GetSellPrice(currentLevel);
|
||||||
auto newGold = session->GetGold() + price;
|
uint64_t newGold = session->GetGold() + price;
|
||||||
|
|
||||||
session->SetGold(newGold);
|
session->SetGold(newGold);
|
||||||
session->SetSwordLevel(0);
|
session->SetSwordLevel(0);
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,8 @@ void SessionManager::Broadcast(PacketHeader header,
|
||||||
std::memcpy(buffer.data() + sizeof(PacketHeader), body.data(), body.size());
|
std::memcpy(buffer.data() + sizeof(PacketHeader), body.data(), body.size());
|
||||||
|
|
||||||
for (auto &session : sessions_) {
|
for (auto &session : sessions_) {
|
||||||
|
// session::send에 span을 전달해야 함. 벡터 자체를 전달할 수도 있지만 우리
|
||||||
|
// Send는 span을 인자로 받음. Session::Send는 span을 받아 복사본을 생성함.
|
||||||
session->Send(buffer);
|
session->Send(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue