Cleaned up comment formatting.

The incantation was: sed -i 's://\([^ ]\):// \1:' src/*.[ch]pp

Lines of code that was commented out were then manually reverted.
This commit is contained in:
dongresource 2020-09-14 16:03:30 +02:00
parent 131997f34f
commit 9cc5f3e4d5
8 changed files with 72 additions and 72 deletions

View File

@ -25,7 +25,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
return; // ignore the malformed packet
sP_CL2LS_REQ_LOGIN* login = (sP_CL2LS_REQ_LOGIN*)data->buf;
//TODO: implement better way of sending credentials
// TODO: implement better way of sending credentials
std::string userLogin((char*)login->szCookie_TEGid);
std::string userPassword((char*)login->szCookie_authid);
@ -45,7 +45,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
bool success = false;
int errorCode = 0;
//checking regex
// checking regex
if (!CNLoginServer::isLoginDataGood(userLogin, userPassword))
{
errorCode = (int)LoginError::LOGIN_ERROR;
@ -53,7 +53,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
else
{
std::unique_ptr<Database::Account> findUser = Database::findAccount(userLogin);
//if account not found, create it
// if account not found, create it
if (findUser == nullptr)
{
loginSessions[sock] = CNLoginData();
@ -61,16 +61,16 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
loginSessions[sock].slot = 1;
success = true;
}
//if user exists, check if password is correct
// if user exists, check if password is correct
else if (CNLoginServer::isPasswordCorrect(findUser->Password, userPassword))
{
//check if account isn't currently in use
// check if account isn't currently in use
if (CNLoginServer::isAccountInUse(findUser->AccountID) ||
PlayerManager::isAccountInUse(findUser->AccountID))
{
errorCode = (int)LoginError::ID_ALREADY_IN_USE;
}
//if not, login success
// if not, login success
else
{
loginSessions[sock] = CNLoginData();
@ -124,12 +124,12 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
charInfo.iY = it->y;
charInfo.iZ = it->z;
//save character in session (for char select)
// save character in session (for char select)
int UID = it->iID;
loginSessions[sock].characters[UID] = Player(*it);
loginSessions[sock].characters[UID].FEKey = sock->getFEKey();
//Equip info
// Equip info
for (int i = 0; i < AEQUIP_COUNT; i++) {
charInfo.aEquip[i] = it->Equip[i];
}
@ -141,7 +141,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
sock->sendPacket((void*)&charInfo, P_LS2CL_REP_CHAR_INFO, sizeof(sP_LS2CL_REP_CHAR_INFO));
}
}
//Failure
// Failure
else {
INITSTRUCT(sP_LS2CL_REP_LOGIN_FAIL, resp);
@ -165,11 +165,11 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
bool success = true;
int errorcode = 0;
//check regex
// check regex
if (!CNLoginServer::isCharacterNameGood(U16toU8(nameCheck->szFirstName), U16toU8(nameCheck->szLastName))) {
success = false;
errorcode = 4;
} else if (!Database::isNameFree(nameCheck)){ //check if name isn't already occupied
} else if (!Database::isNameFree(nameCheck)){ // check if name isn't already occupied
success = false;
errorcode = 1;
}
@ -252,7 +252,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
resp.iLevel = player.level;
resp.sOn_Item = character->sOn_Item;
//save player in session
// save player in session
loginSessions[sock].characters[UID] = Player(player);
loginSessions[sock].characters[UID].FEKey = sock->getFEKey();
@ -322,11 +322,11 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
return;
sP_CL2LS_REQ_SAVE_CHAR_TUTOR* save = (sP_CL2LS_REQ_SAVE_CHAR_TUTOR*)data->buf;
Database::finishTutorial(save->iPC_UID);
//update character in session
// update character in session
auto key = loginSessions[sock].characters[save->iPC_UID].FEKey;
loginSessions[sock].characters[save->iPC_UID] = Player(Database::getPlayer(save->iPC_UID));
loginSessions[sock].characters[save->iPC_UID].FEKey = key;
//no response here
// no response here
break;
}
case P_CL2LS_REQ_CHANGE_CHAR_NAME: {

View File

@ -34,7 +34,7 @@ private:
static bool isPasswordCorrect(std::string actualPassword, std::string tryPassword);
static bool isAccountInUse(int accountId);
static bool isCharacterNameGood(std::string Firstname, std::string Lastname);
//returns true if success
// returns true if success
static bool exitDuplicate(int accountId);
public:
CNLoginServer(uint16_t p);

View File

@ -75,7 +75,7 @@ auto db = make_storage("database.db",
void Database::open()
{
//this parameter means it will try to preserve data during migration
// this parameter means it will try to preserve data during migration
bool preserve = true;
db.sync_schema(preserve);
DEBUGLOG(
@ -102,7 +102,7 @@ void Database::updateSelected(int accountId, int slot)
std::unique_ptr<Database::Account> Database::findAccount(std::string login)
{
//this is awful, I've tried everything to improve it
// this is awful, I've tried everything to improve it
auto find = db.get_all<Account>(
where(c(&Account::Login) == login), limit(1));
if (find.empty())
@ -130,24 +130,24 @@ int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
DbPlayer create = {};
//save packet data
// save packet data
create.FirstName = U16toU8(save->szFirstName);
create.LastName = U16toU8(save->szLastName);
create.slot = save->iSlotNum;
create.AccountID = AccountID;
//set flags
// set flags
create.AppearanceFlag = 0;
create.TutorialFlag = 0;
create.PayZoneFlag = 0;
//set namecheck based on setting
// set namecheck based on setting
if (settings::APPROVEALLNAMES || save->iFNCode)
create.NameCheck = 1;
else
create.NameCheck = 0;
//create default body character
// create default body character
create.Body = 0;
create.Class = 0;
create.EyeColor = 1;
@ -184,7 +184,7 @@ void Database::finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character)
finish.Level = 1;
finish.SkinColor = character->PCStyle.iSkinColor;
db.update(finish);
//clothes
// clothes
Inventory Foot, LB, UB;
Foot.playerId = character->PCStyle.iPC_UID;
Foot.id = character->sOn_Item.iEquipFootID;
@ -212,9 +212,9 @@ void Database::finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character)
void Database::finishTutorial(int PlayerID)
{
Player finish = getPlayer(PlayerID);
//set flag
// set flag
finish.PCStyle2.iTutorialFlag= 1;
//add Gun
// add Gun
Inventory LightningGun = {};
LightningGun.playerId = PlayerID;
LightningGun.id = 328;
@ -222,7 +222,7 @@ void Database::finishTutorial(int PlayerID)
LightningGun.Type = 0;
LightningGun.Opt = 1;
db.insert(LightningGun);
//add Nano
// add Nano
Nano Buttercup = {};
Buttercup.playerId = PlayerID;
Buttercup.iID = 1;
@ -230,7 +230,7 @@ void Database::finishTutorial(int PlayerID)
Buttercup.iStamina = 150;
finish.equippedNanos[0] = 1;
db.insert(Buttercup);
//save missions
// save missions
MissionManager::saveMission(&finish, 0);
MissionManager::saveMission(&finish, 1);
@ -254,7 +254,7 @@ std::vector <Player> Database::getCharacters(int UserID)
std::vector<DbPlayer>characters =
db.get_all<DbPlayer>(where
(c(&DbPlayer::AccountID) == UserID));
//parsing DbPlayer to Player
// parsing DbPlayer to Player
std::vector<Player> result = std::vector<Player>();
for (auto &character : characters) {
Player toadd = DbToPlayer(character);
@ -319,9 +319,9 @@ Database::DbPlayer Database::playerToDb(Player *player)
result.Nano2 = player->equippedNanos[1];
result.Nano3 = player->equippedNanos[2];
//quests
// quests
result.QuestFlag = std::vector<char>();
//parsing long array to char vector
// parsing long array to char vector
for (int i=0; i<16; i++)
{
int64_t temp = player->aQuestFlag[i];
@ -420,13 +420,13 @@ void Database::updatePlayer(Player *player) {
}
void Database::updateInventory(Player *player){
//start transaction
// start transaction
db.begin_transaction();
//remove all
// remove all
db.remove_all<Inventory>(
where(c(&Inventory::playerId) == player->iID)
);
//insert equip
// insert equip
for (int i = 0; i < AEQUIP_COUNT; i++) {
if (player->Equip[i].iID != 0) {
sItemBase* next = &player->Equip[i];
@ -440,7 +440,7 @@ void Database::updateInventory(Player *player){
db.insert(toAdd);
}
}
//insert inventory
// insert inventory
for (int i = 0; i < AINVEN_COUNT; i++) {
if (player->Inven[i].iID != 0) {
sItemBase* next = &player->Inven[i];
@ -454,7 +454,7 @@ void Database::updateInventory(Player *player){
db.insert(toAdd);
}
}
//insert bank
// insert bank
for (int i = 0; i < ABANK_COUNT; i++) {
if (player->Bank[i].iID != 0) {
sItemBase* next = &player->Bank[i];
@ -471,13 +471,13 @@ void Database::updateInventory(Player *player){
db.commit();
}
void Database::updateNanos(Player *player) {
//start transaction
// start transaction
db.begin_transaction();
//remove all
// remove all
db.remove_all<Nano>(
where(c(&Nano::playerId) == player->iID)
);
//insert
// insert
for (int i=1; i < SIZEOF_NANO_BANK_SLOT; i++)
{
if ((player->Nanos[i]).iID == 0)
@ -493,18 +493,18 @@ void Database::updateNanos(Player *player) {
db.commit();
}
void Database::getInventory(Player* player) {
//get items from DB
// get items from DB
auto items = db.get_all<Inventory>(
where(c(&Inventory::playerId) == player->iID)
);
//set items
// set items
for (const Inventory &current : items) {
sItemBase toSet = {};
toSet.iID = current.id;
toSet.iType = current.Type;
toSet.iOpt = current.Opt;
toSet.iTimeLimit = current.TimeLimit;
//assign to proper arrays
// assign to proper arrays
if (current.slot <= AEQUIP_COUNT)
player->Equip[current.slot] = toSet;
else if (current.slot <= (AEQUIP_COUNT + AINVEN_COUNT))
@ -515,11 +515,11 @@ void Database::getInventory(Player* player) {
}
void Database::getNanos(Player* player) {
//get from DB
// get from DB
auto nanos = db.get_all<Nano>(
where(c(&Nano::playerId) == player->iID)
);
//set
// set
for (const Nano& current : nanos) {
sNano *toSet = &player->Nanos[current.iID];
toSet->iID = current.iID;

View File

@ -69,23 +69,23 @@ namespace Database {
#pragma endregion DatabaseStructs
//handles migrations
// handles migrations
void open();
//returns ID
// returns ID
int addAccount(std::string login, std::string password);
void updateSelected(int accountId, int playerId);
std::unique_ptr<Account> findAccount(std::string login);
bool isNameFree(sP_CL2LS_REQ_CHECK_CHAR_NAME* nameCheck);
//called after chosing name, returns ID
// called after chosing name, returns ID
int createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID);
//called after finishing creation
// called after finishing creation
void finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character);
//called after tutorial
// called after tutorial
void finishTutorial(int PlayerID);
//returns slot number
// returns slot number
int deleteCharacter(int characterID, int userID);
std::vector <Player> getCharacters(int userID);
//accepting/declining custom name
// accepting/declining custom name
enum class CustomName {
APPROVE = 1,
DISAPPROVE = 2
@ -93,11 +93,11 @@ namespace Database {
void evaluateCustomName(int characterID, CustomName decision);
void changeName(sP_CL2LS_REQ_CHANGE_CHAR_NAME* save);
//parsing DbPlayer
// parsing DbPlayer
DbPlayer playerToDb(Player *player);
Player DbToPlayer(DbPlayer player);
//getting players
// getting players
DbPlayer getDbPlayerById(int id);
Player getPlayer(int id);

View File

@ -11,9 +11,9 @@ void ItemManager::init() {
REGISTER_SHARD_PACKET(P_CL2FE_REQ_ITEM_MOVE, itemMoveHandler);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_ITEM_DELETE, itemDeleteHandler);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GIVE_ITEM, itemGMGiveHandler);
//Bank
// Bank
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_BANK_OPEN, itemBankOpenHandler);
//Trade handlers
// Trade handlers
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_TRADE_OFFER, itemTradeOfferHandler);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_TRADE_OFFER_ACCEPT, itemTradeOfferAcceptHandler);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_TRADE_OFFER_REFUSAL, itemTradeOfferRefusalHandler);
@ -35,7 +35,7 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
PlayerView& plr = PlayerManager::players[sock];
//sanity check
// sanity check
if (plr.plr->Equip[itemmove->iFromSlotNum].iType != 0 && itemmove->eFrom == 0 && itemmove->eTo == 0) {
// this packet should never happen unless it is a weapon, tell the client to do nothing and do nothing ourself
resp.eTo = itemmove->eFrom;
@ -53,7 +53,7 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
if (itemmove->iToSlotNum > ABANK_COUNT || itemmove->iToSlotNum < 0)
return;
//get the fromItem
// get the fromItem
sItemBase *fromItem;
switch ((SlotType)itemmove->eFrom) {
case SlotType::EQUIP:
@ -67,7 +67,7 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
break;
}
//get the toItem
// get the toItem
sItemBase* toItem;
switch ((SlotType)itemmove->eTo) {
case SlotType::EQUIP:
@ -81,16 +81,16 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
break;
}
//save items to response
// save items to response
resp.ToSlotItem = *toItem;
resp.FromSlotItem = *fromItem;
//swap items in session
// swap items in session
sItemBase temp = *toItem;
*toItem = *fromItem;
*fromItem = temp;
//send equip change to viewable players
// send equip change to viewable players
if (itemmove->eFrom == (int)SlotType::EQUIP || itemmove->eTo == (int)SlotType::EQUIP) {
INITSTRUCT(sP_FE2CL_PC_EQUIP_CHANGE, equipChange);
@ -114,7 +114,7 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
}
}
//send response
// send response
resp.eTo = itemmove->eFrom;
resp.iToSlotNum = itemmove->iFromSlotNum;
resp.eFrom = itemmove->eTo;
@ -177,7 +177,7 @@ void ItemManager::itemBankOpenHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_BANK_OPEN))
return; // ignore the malformed packet
//just send bank inventory
// just send bank inventory
INITSTRUCT(sP_FE2CL_REP_PC_BANK_OPEN_SUCC, resp);
for (int i = 0; i < ABANK_COUNT; i++) {
resp.aBank[i] = PlayerManager::players[sock].plr->Bank[i];
@ -220,7 +220,7 @@ void ItemManager::itemTradeOfferHandler(CNSocket* sock, CNPacketData* data) {
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_TRADE_OFFER_REFUSAL, sizeof(sP_FE2CL_REP_PC_TRADE_OFFER_REFUSAL));
return; //prevent trading with a player already trading
return; // prevent trading with a player already trading
}
INITSTRUCT(sP_FE2CL_REP_PC_TRADE_OFFER, resp);
@ -275,7 +275,7 @@ void ItemManager::itemTradeOfferAcceptHandler(CNSocket* sock, CNPacketData* data
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_TRADE_OFFER_REFUSAL, sizeof(sP_FE2CL_REP_PC_TRADE_OFFER_REFUSAL));
return; //prevent trading with a player already trading
return; // prevent trading with a player already trading
}
plr.plr->isTrading = true;

View File

@ -14,7 +14,7 @@ namespace ItemManager {
void itemMoveHandler(CNSocket* sock, CNPacketData* data);
void itemDeleteHandler(CNSocket* sock, CNPacketData* data);
void itemGMGiveHandler(CNSocket* sock, CNPacketData* data);
//Bank
// Bank
void itemBankOpenHandler(CNSocket* sock, CNPacketData* data);
void itemTradeOfferHandler(CNSocket* sock, CNPacketData* data);
//void itemTradeOfferCancel(CNSocket* sock, CNPacketData* data);

View File

@ -103,7 +103,7 @@ void MissionManager::taskEnd(CNSocket* sock, CNPacketData* data) {
// if it's the last task
if (task["m_iSUOutgoingTask"] == 0)
{
//save completed mission on player
// save completed mission on player
saveMission(plr, (int)(task["m_iHMissionID"])-1);
}
@ -332,7 +332,7 @@ void MissionManager::mobKilled(CNSocket *sock, int mobid) {
}
void MissionManager::saveMission(Player* player, int missionId) {
//Missions are stored in int_64t array
// Missions are stored in int_64t array
int row = missionId / 64;
int column = missionId % 64;
player->aQuestFlag[row] |= (1ULL << column);

View File

@ -220,13 +220,13 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
response.PCLoadData2CL.iFatigue = 50;
response.PCLoadData2CL.PCStyle = plr.PCStyle;
response.PCLoadData2CL.PCStyle2 = plr.PCStyle2;
//inventory
// inventory
for (int i = 0; i < AEQUIP_COUNT; i++)
response.PCLoadData2CL.aEquip[i] = plr.Equip[i];
for (int i = 0; i < AINVEN_COUNT; i++)
response.PCLoadData2CL.aInven[i] = plr.Inven[i];
//nanos
// nanos
for (int i = 1; i < SIZEOF_NANO_BANK_SLOT; i++) {
response.PCLoadData2CL.aNanoBank[i] = plr.Nanos[i];
}
@ -234,7 +234,7 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
response.PCLoadData2CL.aNanoSlots[i] = plr.equippedNanos[i];
}
//missions
// missions
for (int i = 0; i < 16; i++) {
response.PCLoadData2CL.aQuestFlag[i] = plr.aQuestFlag[i];
}
@ -450,7 +450,7 @@ void PlayerManager::ziplinePlayer(CNSocket* sock, CNPacketData* data) {
ziplineResponse.fVZ = ziplineData->fVZ;
ziplineResponse.fMovDistance = ziplineData->fMovDistance;
ziplineResponse.fMaxDistance = ziplineData->fMaxDistance;
ziplineResponse.fDummy = ziplineData->fDummy; //wtf is this for?
ziplineResponse.fDummy = ziplineData->fDummy; // wtf is this for?
ziplineResponse.iStX = ziplineData->iStX;
ziplineResponse.iStY = ziplineData->iStY;
ziplineResponse.iStZ = ziplineData->iStZ;
@ -673,7 +673,7 @@ void PlayerManager::enterPlayerVehicle(CNSocket* sock, CNPacketData* data) {
INITSTRUCT(sP_FE2CL_PC_VEHICLE_ON_SUCC, response);
sock->sendPacket((void*)&response, P_FE2CL_PC_VEHICLE_ON_SUCC, sizeof(sP_FE2CL_PC_VEHICLE_ON_SUCC));
//send to other players
// send to other players
plr.plr->iPCState = 8;
INITSTRUCT(sP_FE2CL_PC_STATE_CHANGE, response2);
response2.iPC_ID = plr.plr->iID;
@ -696,7 +696,7 @@ void PlayerManager::exitPlayerVehicle(CNSocket* sock, CNPacketData* data) {
PlayerView plr = PlayerManager::players[sock];
//send to other players
// send to other players
plr.plr->iPCState = 0;
INITSTRUCT(sP_FE2CL_PC_STATE_CHANGE, response2);
response2.iPC_ID = plr.plr->iID;