mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
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:
parent
131997f34f
commit
9cc5f3e4d5
@ -25,7 +25,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
return; // ignore the malformed packet
|
return; // ignore the malformed packet
|
||||||
|
|
||||||
sP_CL2LS_REQ_LOGIN* login = (sP_CL2LS_REQ_LOGIN*)data->buf;
|
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 userLogin((char*)login->szCookie_TEGid);
|
||||||
std::string userPassword((char*)login->szCookie_authid);
|
std::string userPassword((char*)login->szCookie_authid);
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
bool success = false;
|
bool success = false;
|
||||||
int errorCode = 0;
|
int errorCode = 0;
|
||||||
|
|
||||||
//checking regex
|
// checking regex
|
||||||
if (!CNLoginServer::isLoginDataGood(userLogin, userPassword))
|
if (!CNLoginServer::isLoginDataGood(userLogin, userPassword))
|
||||||
{
|
{
|
||||||
errorCode = (int)LoginError::LOGIN_ERROR;
|
errorCode = (int)LoginError::LOGIN_ERROR;
|
||||||
@ -53,7 +53,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::unique_ptr<Database::Account> findUser = Database::findAccount(userLogin);
|
std::unique_ptr<Database::Account> findUser = Database::findAccount(userLogin);
|
||||||
//if account not found, create it
|
// if account not found, create it
|
||||||
if (findUser == nullptr)
|
if (findUser == nullptr)
|
||||||
{
|
{
|
||||||
loginSessions[sock] = CNLoginData();
|
loginSessions[sock] = CNLoginData();
|
||||||
@ -61,16 +61,16 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
loginSessions[sock].slot = 1;
|
loginSessions[sock].slot = 1;
|
||||||
success = true;
|
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))
|
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) ||
|
if (CNLoginServer::isAccountInUse(findUser->AccountID) ||
|
||||||
PlayerManager::isAccountInUse(findUser->AccountID))
|
PlayerManager::isAccountInUse(findUser->AccountID))
|
||||||
{
|
{
|
||||||
errorCode = (int)LoginError::ID_ALREADY_IN_USE;
|
errorCode = (int)LoginError::ID_ALREADY_IN_USE;
|
||||||
}
|
}
|
||||||
//if not, login success
|
// if not, login success
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
loginSessions[sock] = CNLoginData();
|
loginSessions[sock] = CNLoginData();
|
||||||
@ -124,12 +124,12 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
charInfo.iY = it->y;
|
charInfo.iY = it->y;
|
||||||
charInfo.iZ = it->z;
|
charInfo.iZ = it->z;
|
||||||
|
|
||||||
//save character in session (for char select)
|
// save character in session (for char select)
|
||||||
int UID = it->iID;
|
int UID = it->iID;
|
||||||
loginSessions[sock].characters[UID] = Player(*it);
|
loginSessions[sock].characters[UID] = Player(*it);
|
||||||
loginSessions[sock].characters[UID].FEKey = sock->getFEKey();
|
loginSessions[sock].characters[UID].FEKey = sock->getFEKey();
|
||||||
|
|
||||||
//Equip info
|
// Equip info
|
||||||
for (int i = 0; i < AEQUIP_COUNT; i++) {
|
for (int i = 0; i < AEQUIP_COUNT; i++) {
|
||||||
charInfo.aEquip[i] = it->Equip[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));
|
sock->sendPacket((void*)&charInfo, P_LS2CL_REP_CHAR_INFO, sizeof(sP_LS2CL_REP_CHAR_INFO));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Failure
|
// Failure
|
||||||
else {
|
else {
|
||||||
INITSTRUCT(sP_LS2CL_REP_LOGIN_FAIL, resp);
|
INITSTRUCT(sP_LS2CL_REP_LOGIN_FAIL, resp);
|
||||||
|
|
||||||
@ -165,11 +165,11 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
bool success = true;
|
bool success = true;
|
||||||
int errorcode = 0;
|
int errorcode = 0;
|
||||||
|
|
||||||
//check regex
|
// check regex
|
||||||
if (!CNLoginServer::isCharacterNameGood(U16toU8(nameCheck->szFirstName), U16toU8(nameCheck->szLastName))) {
|
if (!CNLoginServer::isCharacterNameGood(U16toU8(nameCheck->szFirstName), U16toU8(nameCheck->szLastName))) {
|
||||||
success = false;
|
success = false;
|
||||||
errorcode = 4;
|
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;
|
success = false;
|
||||||
errorcode = 1;
|
errorcode = 1;
|
||||||
}
|
}
|
||||||
@ -252,7 +252,7 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
resp.iLevel = player.level;
|
resp.iLevel = player.level;
|
||||||
resp.sOn_Item = character->sOn_Item;
|
resp.sOn_Item = character->sOn_Item;
|
||||||
|
|
||||||
//save player in session
|
// save player in session
|
||||||
loginSessions[sock].characters[UID] = Player(player);
|
loginSessions[sock].characters[UID] = Player(player);
|
||||||
loginSessions[sock].characters[UID].FEKey = sock->getFEKey();
|
loginSessions[sock].characters[UID].FEKey = sock->getFEKey();
|
||||||
|
|
||||||
@ -322,11 +322,11 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
return;
|
return;
|
||||||
sP_CL2LS_REQ_SAVE_CHAR_TUTOR* save = (sP_CL2LS_REQ_SAVE_CHAR_TUTOR*)data->buf;
|
sP_CL2LS_REQ_SAVE_CHAR_TUTOR* save = (sP_CL2LS_REQ_SAVE_CHAR_TUTOR*)data->buf;
|
||||||
Database::finishTutorial(save->iPC_UID);
|
Database::finishTutorial(save->iPC_UID);
|
||||||
//update character in session
|
// update character in session
|
||||||
auto key = loginSessions[sock].characters[save->iPC_UID].FEKey;
|
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] = Player(Database::getPlayer(save->iPC_UID));
|
||||||
loginSessions[sock].characters[save->iPC_UID].FEKey = key;
|
loginSessions[sock].characters[save->iPC_UID].FEKey = key;
|
||||||
//no response here
|
// no response here
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case P_CL2LS_REQ_CHANGE_CHAR_NAME: {
|
case P_CL2LS_REQ_CHANGE_CHAR_NAME: {
|
||||||
|
@ -34,7 +34,7 @@ private:
|
|||||||
static bool isPasswordCorrect(std::string actualPassword, std::string tryPassword);
|
static bool isPasswordCorrect(std::string actualPassword, std::string tryPassword);
|
||||||
static bool isAccountInUse(int accountId);
|
static bool isAccountInUse(int accountId);
|
||||||
static bool isCharacterNameGood(std::string Firstname, std::string Lastname);
|
static bool isCharacterNameGood(std::string Firstname, std::string Lastname);
|
||||||
//returns true if success
|
// returns true if success
|
||||||
static bool exitDuplicate(int accountId);
|
static bool exitDuplicate(int accountId);
|
||||||
public:
|
public:
|
||||||
CNLoginServer(uint16_t p);
|
CNLoginServer(uint16_t p);
|
||||||
|
@ -75,7 +75,7 @@ auto db = make_storage("database.db",
|
|||||||
|
|
||||||
void Database::open()
|
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;
|
bool preserve = true;
|
||||||
db.sync_schema(preserve);
|
db.sync_schema(preserve);
|
||||||
DEBUGLOG(
|
DEBUGLOG(
|
||||||
@ -102,7 +102,7 @@ void Database::updateSelected(int accountId, int slot)
|
|||||||
|
|
||||||
std::unique_ptr<Database::Account> Database::findAccount(std::string login)
|
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>(
|
auto find = db.get_all<Account>(
|
||||||
where(c(&Account::Login) == login), limit(1));
|
where(c(&Account::Login) == login), limit(1));
|
||||||
if (find.empty())
|
if (find.empty())
|
||||||
@ -130,24 +130,24 @@ int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
|
|||||||
|
|
||||||
DbPlayer create = {};
|
DbPlayer create = {};
|
||||||
|
|
||||||
//save packet data
|
// save packet data
|
||||||
create.FirstName = U16toU8(save->szFirstName);
|
create.FirstName = U16toU8(save->szFirstName);
|
||||||
create.LastName = U16toU8(save->szLastName);
|
create.LastName = U16toU8(save->szLastName);
|
||||||
create.slot = save->iSlotNum;
|
create.slot = save->iSlotNum;
|
||||||
create.AccountID = AccountID;
|
create.AccountID = AccountID;
|
||||||
|
|
||||||
//set flags
|
// set flags
|
||||||
create.AppearanceFlag = 0;
|
create.AppearanceFlag = 0;
|
||||||
create.TutorialFlag = 0;
|
create.TutorialFlag = 0;
|
||||||
create.PayZoneFlag = 0;
|
create.PayZoneFlag = 0;
|
||||||
|
|
||||||
//set namecheck based on setting
|
// set namecheck based on setting
|
||||||
if (settings::APPROVEALLNAMES || save->iFNCode)
|
if (settings::APPROVEALLNAMES || save->iFNCode)
|
||||||
create.NameCheck = 1;
|
create.NameCheck = 1;
|
||||||
else
|
else
|
||||||
create.NameCheck = 0;
|
create.NameCheck = 0;
|
||||||
|
|
||||||
//create default body character
|
// create default body character
|
||||||
create.Body = 0;
|
create.Body = 0;
|
||||||
create.Class = 0;
|
create.Class = 0;
|
||||||
create.EyeColor = 1;
|
create.EyeColor = 1;
|
||||||
@ -184,7 +184,7 @@ void Database::finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character)
|
|||||||
finish.Level = 1;
|
finish.Level = 1;
|
||||||
finish.SkinColor = character->PCStyle.iSkinColor;
|
finish.SkinColor = character->PCStyle.iSkinColor;
|
||||||
db.update(finish);
|
db.update(finish);
|
||||||
//clothes
|
// clothes
|
||||||
Inventory Foot, LB, UB;
|
Inventory Foot, LB, UB;
|
||||||
Foot.playerId = character->PCStyle.iPC_UID;
|
Foot.playerId = character->PCStyle.iPC_UID;
|
||||||
Foot.id = character->sOn_Item.iEquipFootID;
|
Foot.id = character->sOn_Item.iEquipFootID;
|
||||||
@ -212,9 +212,9 @@ void Database::finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character)
|
|||||||
void Database::finishTutorial(int PlayerID)
|
void Database::finishTutorial(int PlayerID)
|
||||||
{
|
{
|
||||||
Player finish = getPlayer(PlayerID);
|
Player finish = getPlayer(PlayerID);
|
||||||
//set flag
|
// set flag
|
||||||
finish.PCStyle2.iTutorialFlag= 1;
|
finish.PCStyle2.iTutorialFlag= 1;
|
||||||
//add Gun
|
// add Gun
|
||||||
Inventory LightningGun = {};
|
Inventory LightningGun = {};
|
||||||
LightningGun.playerId = PlayerID;
|
LightningGun.playerId = PlayerID;
|
||||||
LightningGun.id = 328;
|
LightningGun.id = 328;
|
||||||
@ -222,7 +222,7 @@ void Database::finishTutorial(int PlayerID)
|
|||||||
LightningGun.Type = 0;
|
LightningGun.Type = 0;
|
||||||
LightningGun.Opt = 1;
|
LightningGun.Opt = 1;
|
||||||
db.insert(LightningGun);
|
db.insert(LightningGun);
|
||||||
//add Nano
|
// add Nano
|
||||||
Nano Buttercup = {};
|
Nano Buttercup = {};
|
||||||
Buttercup.playerId = PlayerID;
|
Buttercup.playerId = PlayerID;
|
||||||
Buttercup.iID = 1;
|
Buttercup.iID = 1;
|
||||||
@ -230,7 +230,7 @@ void Database::finishTutorial(int PlayerID)
|
|||||||
Buttercup.iStamina = 150;
|
Buttercup.iStamina = 150;
|
||||||
finish.equippedNanos[0] = 1;
|
finish.equippedNanos[0] = 1;
|
||||||
db.insert(Buttercup);
|
db.insert(Buttercup);
|
||||||
//save missions
|
// save missions
|
||||||
MissionManager::saveMission(&finish, 0);
|
MissionManager::saveMission(&finish, 0);
|
||||||
MissionManager::saveMission(&finish, 1);
|
MissionManager::saveMission(&finish, 1);
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ std::vector <Player> Database::getCharacters(int UserID)
|
|||||||
std::vector<DbPlayer>characters =
|
std::vector<DbPlayer>characters =
|
||||||
db.get_all<DbPlayer>(where
|
db.get_all<DbPlayer>(where
|
||||||
(c(&DbPlayer::AccountID) == UserID));
|
(c(&DbPlayer::AccountID) == UserID));
|
||||||
//parsing DbPlayer to Player
|
// parsing DbPlayer to Player
|
||||||
std::vector<Player> result = std::vector<Player>();
|
std::vector<Player> result = std::vector<Player>();
|
||||||
for (auto &character : characters) {
|
for (auto &character : characters) {
|
||||||
Player toadd = DbToPlayer(character);
|
Player toadd = DbToPlayer(character);
|
||||||
@ -319,9 +319,9 @@ Database::DbPlayer Database::playerToDb(Player *player)
|
|||||||
result.Nano2 = player->equippedNanos[1];
|
result.Nano2 = player->equippedNanos[1];
|
||||||
result.Nano3 = player->equippedNanos[2];
|
result.Nano3 = player->equippedNanos[2];
|
||||||
|
|
||||||
//quests
|
// quests
|
||||||
result.QuestFlag = std::vector<char>();
|
result.QuestFlag = std::vector<char>();
|
||||||
//parsing long array to char vector
|
// parsing long array to char vector
|
||||||
for (int i=0; i<16; i++)
|
for (int i=0; i<16; i++)
|
||||||
{
|
{
|
||||||
int64_t temp = player->aQuestFlag[i];
|
int64_t temp = player->aQuestFlag[i];
|
||||||
@ -420,13 +420,13 @@ void Database::updatePlayer(Player *player) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Database::updateInventory(Player *player){
|
void Database::updateInventory(Player *player){
|
||||||
//start transaction
|
// start transaction
|
||||||
db.begin_transaction();
|
db.begin_transaction();
|
||||||
//remove all
|
// remove all
|
||||||
db.remove_all<Inventory>(
|
db.remove_all<Inventory>(
|
||||||
where(c(&Inventory::playerId) == player->iID)
|
where(c(&Inventory::playerId) == player->iID)
|
||||||
);
|
);
|
||||||
//insert equip
|
// insert equip
|
||||||
for (int i = 0; i < AEQUIP_COUNT; i++) {
|
for (int i = 0; i < AEQUIP_COUNT; i++) {
|
||||||
if (player->Equip[i].iID != 0) {
|
if (player->Equip[i].iID != 0) {
|
||||||
sItemBase* next = &player->Equip[i];
|
sItemBase* next = &player->Equip[i];
|
||||||
@ -440,7 +440,7 @@ void Database::updateInventory(Player *player){
|
|||||||
db.insert(toAdd);
|
db.insert(toAdd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//insert inventory
|
// insert inventory
|
||||||
for (int i = 0; i < AINVEN_COUNT; i++) {
|
for (int i = 0; i < AINVEN_COUNT; i++) {
|
||||||
if (player->Inven[i].iID != 0) {
|
if (player->Inven[i].iID != 0) {
|
||||||
sItemBase* next = &player->Inven[i];
|
sItemBase* next = &player->Inven[i];
|
||||||
@ -454,7 +454,7 @@ void Database::updateInventory(Player *player){
|
|||||||
db.insert(toAdd);
|
db.insert(toAdd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//insert bank
|
// insert bank
|
||||||
for (int i = 0; i < ABANK_COUNT; i++) {
|
for (int i = 0; i < ABANK_COUNT; i++) {
|
||||||
if (player->Bank[i].iID != 0) {
|
if (player->Bank[i].iID != 0) {
|
||||||
sItemBase* next = &player->Bank[i];
|
sItemBase* next = &player->Bank[i];
|
||||||
@ -471,13 +471,13 @@ void Database::updateInventory(Player *player){
|
|||||||
db.commit();
|
db.commit();
|
||||||
}
|
}
|
||||||
void Database::updateNanos(Player *player) {
|
void Database::updateNanos(Player *player) {
|
||||||
//start transaction
|
// start transaction
|
||||||
db.begin_transaction();
|
db.begin_transaction();
|
||||||
//remove all
|
// remove all
|
||||||
db.remove_all<Nano>(
|
db.remove_all<Nano>(
|
||||||
where(c(&Nano::playerId) == player->iID)
|
where(c(&Nano::playerId) == player->iID)
|
||||||
);
|
);
|
||||||
//insert
|
// insert
|
||||||
for (int i=1; i < SIZEOF_NANO_BANK_SLOT; i++)
|
for (int i=1; i < SIZEOF_NANO_BANK_SLOT; i++)
|
||||||
{
|
{
|
||||||
if ((player->Nanos[i]).iID == 0)
|
if ((player->Nanos[i]).iID == 0)
|
||||||
@ -493,18 +493,18 @@ void Database::updateNanos(Player *player) {
|
|||||||
db.commit();
|
db.commit();
|
||||||
}
|
}
|
||||||
void Database::getInventory(Player* player) {
|
void Database::getInventory(Player* player) {
|
||||||
//get items from DB
|
// get items from DB
|
||||||
auto items = db.get_all<Inventory>(
|
auto items = db.get_all<Inventory>(
|
||||||
where(c(&Inventory::playerId) == player->iID)
|
where(c(&Inventory::playerId) == player->iID)
|
||||||
);
|
);
|
||||||
//set items
|
// set items
|
||||||
for (const Inventory ¤t : items) {
|
for (const Inventory ¤t : items) {
|
||||||
sItemBase toSet = {};
|
sItemBase toSet = {};
|
||||||
toSet.iID = current.id;
|
toSet.iID = current.id;
|
||||||
toSet.iType = current.Type;
|
toSet.iType = current.Type;
|
||||||
toSet.iOpt = current.Opt;
|
toSet.iOpt = current.Opt;
|
||||||
toSet.iTimeLimit = current.TimeLimit;
|
toSet.iTimeLimit = current.TimeLimit;
|
||||||
//assign to proper arrays
|
// assign to proper arrays
|
||||||
if (current.slot <= AEQUIP_COUNT)
|
if (current.slot <= AEQUIP_COUNT)
|
||||||
player->Equip[current.slot] = toSet;
|
player->Equip[current.slot] = toSet;
|
||||||
else if (current.slot <= (AEQUIP_COUNT + AINVEN_COUNT))
|
else if (current.slot <= (AEQUIP_COUNT + AINVEN_COUNT))
|
||||||
@ -515,11 +515,11 @@ void Database::getInventory(Player* player) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
void Database::getNanos(Player* player) {
|
void Database::getNanos(Player* player) {
|
||||||
//get from DB
|
// get from DB
|
||||||
auto nanos = db.get_all<Nano>(
|
auto nanos = db.get_all<Nano>(
|
||||||
where(c(&Nano::playerId) == player->iID)
|
where(c(&Nano::playerId) == player->iID)
|
||||||
);
|
);
|
||||||
//set
|
// set
|
||||||
for (const Nano& current : nanos) {
|
for (const Nano& current : nanos) {
|
||||||
sNano *toSet = &player->Nanos[current.iID];
|
sNano *toSet = &player->Nanos[current.iID];
|
||||||
toSet->iID = current.iID;
|
toSet->iID = current.iID;
|
||||||
|
@ -69,23 +69,23 @@ namespace Database {
|
|||||||
|
|
||||||
#pragma endregion DatabaseStructs
|
#pragma endregion DatabaseStructs
|
||||||
|
|
||||||
//handles migrations
|
// handles migrations
|
||||||
void open();
|
void open();
|
||||||
//returns ID
|
// returns ID
|
||||||
int addAccount(std::string login, std::string password);
|
int addAccount(std::string login, std::string password);
|
||||||
void updateSelected(int accountId, int playerId);
|
void updateSelected(int accountId, int playerId);
|
||||||
std::unique_ptr<Account> findAccount(std::string login);
|
std::unique_ptr<Account> findAccount(std::string login);
|
||||||
bool isNameFree(sP_CL2LS_REQ_CHECK_CHAR_NAME* nameCheck);
|
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);
|
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);
|
void finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character);
|
||||||
//called after tutorial
|
// called after tutorial
|
||||||
void finishTutorial(int PlayerID);
|
void finishTutorial(int PlayerID);
|
||||||
//returns slot number
|
// returns slot number
|
||||||
int deleteCharacter(int characterID, int userID);
|
int deleteCharacter(int characterID, int userID);
|
||||||
std::vector <Player> getCharacters(int userID);
|
std::vector <Player> getCharacters(int userID);
|
||||||
//accepting/declining custom name
|
// accepting/declining custom name
|
||||||
enum class CustomName {
|
enum class CustomName {
|
||||||
APPROVE = 1,
|
APPROVE = 1,
|
||||||
DISAPPROVE = 2
|
DISAPPROVE = 2
|
||||||
@ -93,11 +93,11 @@ namespace Database {
|
|||||||
void evaluateCustomName(int characterID, CustomName decision);
|
void evaluateCustomName(int characterID, CustomName decision);
|
||||||
void changeName(sP_CL2LS_REQ_CHANGE_CHAR_NAME* save);
|
void changeName(sP_CL2LS_REQ_CHANGE_CHAR_NAME* save);
|
||||||
|
|
||||||
//parsing DbPlayer
|
// parsing DbPlayer
|
||||||
DbPlayer playerToDb(Player *player);
|
DbPlayer playerToDb(Player *player);
|
||||||
Player DbToPlayer(DbPlayer player);
|
Player DbToPlayer(DbPlayer player);
|
||||||
|
|
||||||
//getting players
|
// getting players
|
||||||
DbPlayer getDbPlayerById(int id);
|
DbPlayer getDbPlayerById(int id);
|
||||||
Player getPlayer(int id);
|
Player getPlayer(int id);
|
||||||
|
|
||||||
|
@ -11,9 +11,9 @@ void ItemManager::init() {
|
|||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_ITEM_MOVE, itemMoveHandler);
|
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_ITEM_DELETE, itemDeleteHandler);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GIVE_ITEM, itemGMGiveHandler);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GIVE_ITEM, itemGMGiveHandler);
|
||||||
//Bank
|
// Bank
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_BANK_OPEN, itemBankOpenHandler);
|
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, itemTradeOfferHandler);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_TRADE_OFFER_ACCEPT, itemTradeOfferAcceptHandler);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_TRADE_OFFER_ACCEPT, itemTradeOfferAcceptHandler);
|
||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_TRADE_OFFER_REFUSAL, itemTradeOfferRefusalHandler);
|
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];
|
PlayerView& plr = PlayerManager::players[sock];
|
||||||
|
|
||||||
//sanity check
|
// sanity check
|
||||||
if (plr.plr->Equip[itemmove->iFromSlotNum].iType != 0 && itemmove->eFrom == 0 && itemmove->eTo == 0) {
|
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
|
// this packet should never happen unless it is a weapon, tell the client to do nothing and do nothing ourself
|
||||||
resp.eTo = itemmove->eFrom;
|
resp.eTo = itemmove->eFrom;
|
||||||
@ -53,7 +53,7 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
if (itemmove->iToSlotNum > ABANK_COUNT || itemmove->iToSlotNum < 0)
|
if (itemmove->iToSlotNum > ABANK_COUNT || itemmove->iToSlotNum < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//get the fromItem
|
// get the fromItem
|
||||||
sItemBase *fromItem;
|
sItemBase *fromItem;
|
||||||
switch ((SlotType)itemmove->eFrom) {
|
switch ((SlotType)itemmove->eFrom) {
|
||||||
case SlotType::EQUIP:
|
case SlotType::EQUIP:
|
||||||
@ -67,7 +67,7 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the toItem
|
// get the toItem
|
||||||
sItemBase* toItem;
|
sItemBase* toItem;
|
||||||
switch ((SlotType)itemmove->eTo) {
|
switch ((SlotType)itemmove->eTo) {
|
||||||
case SlotType::EQUIP:
|
case SlotType::EQUIP:
|
||||||
@ -81,16 +81,16 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//save items to response
|
// save items to response
|
||||||
resp.ToSlotItem = *toItem;
|
resp.ToSlotItem = *toItem;
|
||||||
resp.FromSlotItem = *fromItem;
|
resp.FromSlotItem = *fromItem;
|
||||||
|
|
||||||
//swap items in session
|
// swap items in session
|
||||||
sItemBase temp = *toItem;
|
sItemBase temp = *toItem;
|
||||||
*toItem = *fromItem;
|
*toItem = *fromItem;
|
||||||
*fromItem = temp;
|
*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) {
|
if (itemmove->eFrom == (int)SlotType::EQUIP || itemmove->eTo == (int)SlotType::EQUIP) {
|
||||||
INITSTRUCT(sP_FE2CL_PC_EQUIP_CHANGE, equipChange);
|
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.eTo = itemmove->eFrom;
|
||||||
resp.iToSlotNum = itemmove->iFromSlotNum;
|
resp.iToSlotNum = itemmove->iFromSlotNum;
|
||||||
resp.eFrom = itemmove->eTo;
|
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))
|
if (data->size != sizeof(sP_CL2FE_REQ_PC_BANK_OPEN))
|
||||||
return; // ignore the malformed packet
|
return; // ignore the malformed packet
|
||||||
|
|
||||||
//just send bank inventory
|
// just send bank inventory
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_BANK_OPEN_SUCC, resp);
|
INITSTRUCT(sP_FE2CL_REP_PC_BANK_OPEN_SUCC, resp);
|
||||||
for (int i = 0; i < ABANK_COUNT; i++) {
|
for (int i = 0; i < ABANK_COUNT; i++) {
|
||||||
resp.aBank[i] = PlayerManager::players[sock].plr->Bank[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));
|
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);
|
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));
|
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;
|
plr.plr->isTrading = true;
|
||||||
|
@ -14,7 +14,7 @@ namespace ItemManager {
|
|||||||
void itemMoveHandler(CNSocket* sock, CNPacketData* data);
|
void itemMoveHandler(CNSocket* sock, CNPacketData* data);
|
||||||
void itemDeleteHandler(CNSocket* sock, CNPacketData* data);
|
void itemDeleteHandler(CNSocket* sock, CNPacketData* data);
|
||||||
void itemGMGiveHandler(CNSocket* sock, CNPacketData* data);
|
void itemGMGiveHandler(CNSocket* sock, CNPacketData* data);
|
||||||
//Bank
|
// Bank
|
||||||
void itemBankOpenHandler(CNSocket* sock, CNPacketData* data);
|
void itemBankOpenHandler(CNSocket* sock, CNPacketData* data);
|
||||||
void itemTradeOfferHandler(CNSocket* sock, CNPacketData* data);
|
void itemTradeOfferHandler(CNSocket* sock, CNPacketData* data);
|
||||||
//void itemTradeOfferCancel(CNSocket* sock, CNPacketData* data);
|
//void itemTradeOfferCancel(CNSocket* sock, CNPacketData* data);
|
||||||
|
@ -103,7 +103,7 @@ void MissionManager::taskEnd(CNSocket* sock, CNPacketData* data) {
|
|||||||
// if it's the last task
|
// if it's the last task
|
||||||
if (task["m_iSUOutgoingTask"] == 0)
|
if (task["m_iSUOutgoingTask"] == 0)
|
||||||
{
|
{
|
||||||
//save completed mission on player
|
// save completed mission on player
|
||||||
saveMission(plr, (int)(task["m_iHMissionID"])-1);
|
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) {
|
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 row = missionId / 64;
|
||||||
int column = missionId % 64;
|
int column = missionId % 64;
|
||||||
player->aQuestFlag[row] |= (1ULL << column);
|
player->aQuestFlag[row] |= (1ULL << column);
|
||||||
|
@ -220,13 +220,13 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
response.PCLoadData2CL.iFatigue = 50;
|
response.PCLoadData2CL.iFatigue = 50;
|
||||||
response.PCLoadData2CL.PCStyle = plr.PCStyle;
|
response.PCLoadData2CL.PCStyle = plr.PCStyle;
|
||||||
response.PCLoadData2CL.PCStyle2 = plr.PCStyle2;
|
response.PCLoadData2CL.PCStyle2 = plr.PCStyle2;
|
||||||
//inventory
|
// inventory
|
||||||
for (int i = 0; i < AEQUIP_COUNT; i++)
|
for (int i = 0; i < AEQUIP_COUNT; i++)
|
||||||
response.PCLoadData2CL.aEquip[i] = plr.Equip[i];
|
response.PCLoadData2CL.aEquip[i] = plr.Equip[i];
|
||||||
|
|
||||||
for (int i = 0; i < AINVEN_COUNT; i++)
|
for (int i = 0; i < AINVEN_COUNT; i++)
|
||||||
response.PCLoadData2CL.aInven[i] = plr.Inven[i];
|
response.PCLoadData2CL.aInven[i] = plr.Inven[i];
|
||||||
//nanos
|
// nanos
|
||||||
for (int i = 1; i < SIZEOF_NANO_BANK_SLOT; i++) {
|
for (int i = 1; i < SIZEOF_NANO_BANK_SLOT; i++) {
|
||||||
response.PCLoadData2CL.aNanoBank[i] = plr.Nanos[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];
|
response.PCLoadData2CL.aNanoSlots[i] = plr.equippedNanos[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
//missions
|
// missions
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
response.PCLoadData2CL.aQuestFlag[i] = plr.aQuestFlag[i];
|
response.PCLoadData2CL.aQuestFlag[i] = plr.aQuestFlag[i];
|
||||||
}
|
}
|
||||||
@ -450,7 +450,7 @@ void PlayerManager::ziplinePlayer(CNSocket* sock, CNPacketData* data) {
|
|||||||
ziplineResponse.fVZ = ziplineData->fVZ;
|
ziplineResponse.fVZ = ziplineData->fVZ;
|
||||||
ziplineResponse.fMovDistance = ziplineData->fMovDistance;
|
ziplineResponse.fMovDistance = ziplineData->fMovDistance;
|
||||||
ziplineResponse.fMaxDistance = ziplineData->fMaxDistance;
|
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.iStX = ziplineData->iStX;
|
||||||
ziplineResponse.iStY = ziplineData->iStY;
|
ziplineResponse.iStY = ziplineData->iStY;
|
||||||
ziplineResponse.iStZ = ziplineData->iStZ;
|
ziplineResponse.iStZ = ziplineData->iStZ;
|
||||||
@ -673,7 +673,7 @@ void PlayerManager::enterPlayerVehicle(CNSocket* sock, CNPacketData* data) {
|
|||||||
INITSTRUCT(sP_FE2CL_PC_VEHICLE_ON_SUCC, response);
|
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));
|
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;
|
plr.plr->iPCState = 8;
|
||||||
INITSTRUCT(sP_FE2CL_PC_STATE_CHANGE, response2);
|
INITSTRUCT(sP_FE2CL_PC_STATE_CHANGE, response2);
|
||||||
response2.iPC_ID = plr.plr->iID;
|
response2.iPC_ID = plr.plr->iID;
|
||||||
@ -696,7 +696,7 @@ void PlayerManager::exitPlayerVehicle(CNSocket* sock, CNPacketData* data) {
|
|||||||
|
|
||||||
PlayerView plr = PlayerManager::players[sock];
|
PlayerView plr = PlayerManager::players[sock];
|
||||||
|
|
||||||
//send to other players
|
// send to other players
|
||||||
plr.plr->iPCState = 0;
|
plr.plr->iPCState = 0;
|
||||||
INITSTRUCT(sP_FE2CL_PC_STATE_CHANGE, response2);
|
INITSTRUCT(sP_FE2CL_PC_STATE_CHANGE, response2);
|
||||||
response2.iPC_ID = plr.plr->iID;
|
response2.iPC_ID = plr.plr->iID;
|
||||||
|
Loading…
Reference in New Issue
Block a user