mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-14 10:20:05 +00:00
Cleanup for 1.2.
Cleaned up whitespace, comments, brace style, etc. Updated tdata reference.
This commit is contained in:
parent
d713fafb1c
commit
10534886b8
@ -145,8 +145,7 @@ void BuddyManager::reqAcceptBuddy(CNSocket* sock, CNPacketData* data) {
|
|||||||
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
|
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
|
||||||
buddyList(otherSock, resp.BuddyInfo); // saves requester's data to this player's buddylist
|
buddyList(otherSock, resp.BuddyInfo); // saves requester's data to this player's buddylist
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, declineResp);
|
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, declineResp);
|
||||||
|
|
||||||
declineResp.iErrorCode = 6; // Buddy declined notification
|
declineResp.iErrorCode = 6; // Buddy declined notification
|
||||||
@ -218,8 +217,7 @@ void BuddyManager::reqFindNameBuddyAccept(CNSocket* sock, CNPacketData* data) {
|
|||||||
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
|
otherSock->sendPacket((void*)&resp, P_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_SUCC));
|
||||||
buddyList(otherSock, resp.BuddyInfo);
|
buddyList(otherSock, resp.BuddyInfo);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, declineResp);
|
INITSTRUCT(sP_FE2CL_REP_ACCEPT_MAKE_BUDDY_FAIL, declineResp);
|
||||||
|
|
||||||
declineResp.iErrorCode = 6; // Buddy declined notification
|
declineResp.iErrorCode = 6; // Buddy declined notification
|
||||||
|
@ -57,27 +57,23 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
loginSessions[sock].slot = 1;
|
loginSessions[sock].slot = 1;
|
||||||
loginSessions[sock].lastHeartbeat = getTime();
|
loginSessions[sock].lastHeartbeat = getTime();
|
||||||
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)) {
|
||||||
/*calling this here to timestamp login attempt,
|
/*calling this here to timestamp login attempt,
|
||||||
* in order to make duplicate exit sanity check work*/
|
* in order to make duplicate exit sanity check work*/
|
||||||
Database::updateSelected(findUser->AccountID, findUser->Selected);
|
Database::updateSelected(findUser->AccountID, findUser->Selected);
|
||||||
// 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)) {
|
||||||
errorCode = (int)LoginError::ID_ALREADY_IN_USE;
|
errorCode = (int)LoginError::ID_ALREADY_IN_USE;
|
||||||
}
|
} else { // if not, login success
|
||||||
// if not, login success
|
|
||||||
else
|
|
||||||
{
|
|
||||||
loginSessions[sock] = CNLoginData();
|
loginSessions[sock] = CNLoginData();
|
||||||
loginSessions[sock].userID = findUser->AccountID;
|
loginSessions[sock].userID = findUser->AccountID;
|
||||||
loginSessions[sock].slot = findUser->Selected;
|
loginSessions[sock].slot = findUser->Selected;
|
||||||
loginSessions[sock].lastHeartbeat = getTime();
|
loginSessions[sock].lastHeartbeat = getTime();
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
errorCode = (int)LoginError::ID_AND_PASSWORD_DO_NOT_MATCH;
|
errorCode = (int)LoginError::ID_AND_PASSWORD_DO_NOT_MATCH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -369,10 +365,11 @@ void CNLoginServer::handlePacket(CNSocket* sock, CNPacketData* data) {
|
|||||||
if (settings::VERBOSITY)
|
if (settings::VERBOSITY)
|
||||||
std::cerr << "OpenFusion: LOGIN UNIMPLM ERR. PacketType: " << Defines::p2str(CL2LS, data->type) << " (" << data->type << ")" << std::endl;
|
std::cerr << "OpenFusion: LOGIN UNIMPLM ERR. PacketType: " << Defines::p2str(CL2LS, data->type) << " (" << data->type << ")" << std::endl;
|
||||||
break;
|
break;
|
||||||
/* Unimplemented CL2LS packets:
|
/*
|
||||||
P_CL2LS_CHECK_NAME_LIST - unused by the client
|
* Unimplemented CL2LS packets:
|
||||||
P_CL2LS_REQ_SERVER_SELECT
|
* P_CL2LS_CHECK_NAME_LIST - unused by the client
|
||||||
P_CL2LS_REQ_SHARD_LIST_INFO - dev commands, useless as we only run 1 server
|
* P_CL2LS_REQ_SERVER_SELECT
|
||||||
|
* P_CL2LS_REQ_SHARD_LIST_INFO - dev commands, useless as we only run 1 server
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,7 @@ int CNSocketEncryption::Encrypt_byte_change_A(int ERSize, uint8_t* data, int siz
|
|||||||
int num2 = 0;
|
int num2 = 0;
|
||||||
int num3 = 0;
|
int num3 = 0;
|
||||||
|
|
||||||
while (num + ERSize <= size)
|
while (num + ERSize <= size) {
|
||||||
{
|
|
||||||
int num4 = num + num3;
|
int num4 = num + num3;
|
||||||
int num5 = num + (ERSize - 1 - num3);
|
int num5 = num + (ERSize - 1 - num3);
|
||||||
|
|
||||||
@ -19,8 +18,7 @@ int CNSocketEncryption::Encrypt_byte_change_A(int ERSize, uint8_t* data, int siz
|
|||||||
data[num5] = b;
|
data[num5] = b;
|
||||||
num += ERSize;
|
num += ERSize;
|
||||||
num3++;
|
num3++;
|
||||||
if (num3 > ERSize / 2)
|
if (num3 > ERSize / 2) {
|
||||||
{
|
|
||||||
num3 = 0;
|
num3 = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,12 +54,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Packets format (sent from the client):
|
* Packets format (sent from the client):
|
||||||
[4 bytes] - size of packet including the 4 byte packet type
|
* [4 bytes] - size of packet including the 4 byte packet type
|
||||||
[size bytes] - Encrypted packet (byte swapped && xor'd with 8 byte key; see CNSocketEncryption)
|
* [size bytes] - Encrypted packet (byte swapped && xor'd with 8 byte key; see CNSocketEncryption)
|
||||||
[4 bytes] - packet type (which is a combination of the first 4 bytes of the packet and a checksum in some versions)
|
* [4 bytes] - packet type (which is a combination of the first 4 bytes of the packet and a checksum in some versions)
|
||||||
[structure] - one member contains length of trailing data (expressed in packet-dependant structures)
|
* [structure] - one member contains length of trailing data (expressed in packet-dependant structures)
|
||||||
[trailing data] - optional variable-length data that only some packets make use of
|
* [trailing data] - optional variable-length data that only some packets make use of
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// error checking calloc wrapper
|
// error checking calloc wrapper
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
CNShared.hpp
|
* CNShared.hpp
|
||||||
There's some data shared between the Login Server and the Shard Server. Of course all of this needs to be thread-safe. No mucking about on this one!
|
* There's some data shared between the Login Server and the Shard Server. Of course all of this needs to be thread-safe. No mucking about on this one!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
CNStructs.hpp - defines some basic structs & useful methods for packets used by FusionFall based on the version defined
|
* CNStructs.hpp - defines some basic structs & useful methods for packets used by FusionFall based on the version defined
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -223,8 +223,7 @@ void ChunkManager::createInstance(uint64_t instanceID) {
|
|||||||
NPCManager::updateNPCInstance(newID, instanceID); // make sure the npc state gets updated
|
NPCManager::updateNPCInstance(newID, instanceID); // make sure the npc state gets updated
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
std::cout << "Instance " << instanceID << " already exists" << std::endl;
|
std::cout << "Instance " << instanceID << " already exists" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
INSTANCE_OVERWORLD // default instance every player starts in
|
INSTANCE_OVERWORLD, // default instance every player starts in
|
||||||
//INSTANCE_IZ, // these aren't actually used
|
INSTANCE_IZ, // these aren't actually used
|
||||||
//INSTANCE_UNIQUE
|
INSTANCE_UNIQUE // these aren't actually used
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace ChunkManager {
|
namespace ChunkManager {
|
||||||
|
@ -100,8 +100,7 @@ auto db = make_storage("database.db",
|
|||||||
|
|
||||||
#pragma region LoginServer
|
#pragma region LoginServer
|
||||||
|
|
||||||
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);
|
||||||
@ -130,8 +129,7 @@ int Database::getPlayersCount() {
|
|||||||
return db.count<DbPlayer>();
|
return db.count<DbPlayer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Database::addAccount(std::string login, std::string password)
|
int Database::addAccount(std::string login, std::string password) {
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
password = BCrypt::generateHash(password);
|
password = BCrypt::generateHash(password);
|
||||||
@ -143,8 +141,7 @@ int Database::addAccount(std::string login, std::string password)
|
|||||||
return db.insert(account);
|
return db.insert(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::updateSelected(int accountId, int slot)
|
void Database::updateSelected(int accountId, int slot) {
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
Account acc = db.get<Account>(accountId);
|
Account acc = db.get<Account>(accountId);
|
||||||
@ -154,8 +151,7 @@ void Database::updateSelected(int accountId, int slot)
|
|||||||
db.update(acc);
|
db.update(acc);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Database::Account> Database::findAccount(std::string login)
|
std::unique_ptr<Database::Account> Database::findAccount(std::string login) {
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
// this is awful, I've tried everything to improve it
|
// this is awful, I've tried everything to improve it
|
||||||
@ -167,8 +163,7 @@ std::unique_ptr<Database::Account> Database::findAccount(std::string login)
|
|||||||
std::unique_ptr<Account>(new Account(find.front()));
|
std::unique_ptr<Account>(new Account(find.front()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::isNameFree(sP_CL2LS_REQ_CHECK_CHAR_NAME* nameCheck)
|
bool Database::isNameFree(sP_CL2LS_REQ_CHECK_CHAR_NAME* nameCheck) {
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
std::string First = U16toU8(nameCheck->szFirstName);
|
std::string First = U16toU8(nameCheck->szFirstName);
|
||||||
@ -180,8 +175,7 @@ bool Database::isNameFree(sP_CL2LS_REQ_CHECK_CHAR_NAME* nameCheck)
|
|||||||
.empty());
|
.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
|
int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID) {
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
// fail if the player already has 4 or more characters
|
// fail if the player already has 4 or more characters
|
||||||
@ -235,8 +229,7 @@ int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
|
|||||||
return db.insert(create);
|
return db.insert(create);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character)
|
void Database::finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character) {
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
DbPlayer finish = getDbPlayerById(character->PCStyle.iPC_UID);
|
DbPlayer finish = getDbPlayerById(character->PCStyle.iPC_UID);
|
||||||
@ -277,8 +270,7 @@ void Database::finishCharacter(sP_CL2LS_REQ_CHAR_CREATE* character)
|
|||||||
db.insert(UB);
|
db.insert(UB);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::finishTutorial(int PlayerID)
|
void Database::finishTutorial(int PlayerID) {
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
Player finish = getPlayer(PlayerID);
|
Player finish = getPlayer(PlayerID);
|
||||||
@ -307,8 +299,7 @@ void Database::finishTutorial(int PlayerID)
|
|||||||
db.update(playerToDb(&finish));
|
db.update(playerToDb(&finish));
|
||||||
}
|
}
|
||||||
|
|
||||||
int Database::deleteCharacter(int characterID, int userID)
|
int Database::deleteCharacter(int characterID, int userID) {
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
auto find =
|
auto find =
|
||||||
@ -321,8 +312,7 @@ int Database::deleteCharacter(int characterID, int userID)
|
|||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector <Player> Database::getCharacters(int UserID)
|
std::vector <Player> Database::getCharacters(int UserID) {
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(dbCrit);
|
std::lock_guard<std::mutex> lock(dbCrit);
|
||||||
|
|
||||||
std::vector<DbPlayer>characters =
|
std::vector<DbPlayer>characters =
|
||||||
@ -361,8 +351,7 @@ void Database::changeName(sP_CL2LS_REQ_CHANGE_CHAR_NAME* save) {
|
|||||||
db.update(Player);
|
db.update(Player);
|
||||||
}
|
}
|
||||||
|
|
||||||
Database::DbPlayer Database::playerToDb(Player *player)
|
Database::DbPlayer Database::playerToDb(Player *player) {
|
||||||
{
|
|
||||||
// TODO: move stuff that is never updated to separate table so it doesn't try to update it every time
|
// TODO: move stuff that is never updated to separate table so it doesn't try to update it every time
|
||||||
DbPlayer result = {};
|
DbPlayer result = {};
|
||||||
|
|
||||||
@ -395,8 +384,7 @@ Database::DbPlayer Database::playerToDb(Player *player)
|
|||||||
result.y_coordinates = player->y;
|
result.y_coordinates = player->y;
|
||||||
result.z_coordinates = player->z;
|
result.z_coordinates = player->z;
|
||||||
result.angle = player->angle;
|
result.angle = player->angle;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
result.x_coordinates = player->lastX;
|
result.x_coordinates = player->lastX;
|
||||||
result.y_coordinates = player->lastY;
|
result.y_coordinates = player->lastY;
|
||||||
result.z_coordinates = player->lastZ;
|
result.z_coordinates = player->lastZ;
|
||||||
@ -580,8 +568,7 @@ void Database::updateNanos(Player *player) {
|
|||||||
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)
|
||||||
continue;
|
continue;
|
||||||
Nano toAdd = {};
|
Nano toAdd = {};
|
||||||
@ -603,8 +590,7 @@ void Database::updateQuests(Player* player) {
|
|||||||
where(c(&DbQuest::PlayerId) == player->iID)
|
where(c(&DbQuest::PlayerId) == player->iID)
|
||||||
);
|
);
|
||||||
// insert
|
// insert
|
||||||
for (int i = 0; i < ACTIVE_MISSION_COUNT; i++)
|
for (int i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
||||||
{
|
|
||||||
if (player->tasks[i] == 0)
|
if (player->tasks[i] == 0)
|
||||||
continue;
|
continue;
|
||||||
DbQuest toAdd = {};
|
DbQuest toAdd = {};
|
||||||
@ -655,8 +641,7 @@ void Database::removeExpiredVehicles(Player* player) {
|
|||||||
std::vector<sItemBase*> toRemove;
|
std::vector<sItemBase*> toRemove;
|
||||||
|
|
||||||
// equiped vehicle
|
// equiped vehicle
|
||||||
if (player->Equip[8].iOpt > 0 && player->Equip[8].iTimeLimit < currentTime)
|
if (player->Equip[8].iOpt > 0 && player->Equip[8].iTimeLimit < currentTime) {
|
||||||
{
|
|
||||||
toRemove.push_back(&player->Equip[8]);
|
toRemove.push_back(&player->Equip[8]);
|
||||||
player->toRemoveVehicle.eIL = 0;
|
player->toRemoveVehicle.eIL = 0;
|
||||||
player->toRemoveVehicle.iSlotNum = 8;
|
player->toRemoveVehicle.iSlotNum = 8;
|
||||||
|
@ -7,8 +7,7 @@
|
|||||||
namespace Database {
|
namespace Database {
|
||||||
#pragma region DatabaseStructs
|
#pragma region DatabaseStructs
|
||||||
|
|
||||||
struct Account
|
struct Account {
|
||||||
{
|
|
||||||
int AccountID;
|
int AccountID;
|
||||||
std::string Login;
|
std::string Login;
|
||||||
std::string Password;
|
std::string Password;
|
||||||
@ -16,8 +15,7 @@ namespace Database {
|
|||||||
uint64_t Created;
|
uint64_t Created;
|
||||||
uint64_t LastLogin;
|
uint64_t LastLogin;
|
||||||
};
|
};
|
||||||
struct Inventory
|
struct Inventory {
|
||||||
{
|
|
||||||
int playerId;
|
int playerId;
|
||||||
int slot;
|
int slot;
|
||||||
int16_t Type;
|
int16_t Type;
|
||||||
@ -31,8 +29,7 @@ namespace Database {
|
|||||||
int16_t iSkillID;
|
int16_t iSkillID;
|
||||||
int16_t iStamina;
|
int16_t iStamina;
|
||||||
};
|
};
|
||||||
struct DbPlayer
|
struct DbPlayer {
|
||||||
{
|
|
||||||
int PlayerID;
|
int PlayerID;
|
||||||
int AccountID;
|
int AccountID;
|
||||||
short int slot;
|
short int slot;
|
||||||
|
@ -13,7 +13,7 @@ std::map<int32_t, std::vector<VendorListing>> ItemManager::VendorTables;
|
|||||||
std::map<int32_t, CrocPotEntry> ItemManager::CrocPotTable;
|
std::map<int32_t, CrocPotEntry> ItemManager::CrocPotTable;
|
||||||
std::map<int32_t, std::vector<int>> ItemManager::RarityRatios;
|
std::map<int32_t, std::vector<int>> ItemManager::RarityRatios;
|
||||||
std::map<int32_t, Crate> ItemManager::Crates;
|
std::map<int32_t, Crate> ItemManager::Crates;
|
||||||
/// pair Itemset, Rarity -> vector of pointers (map iterators) to records in ItemData
|
// pair Itemset, Rarity -> vector of pointers (map iterators) to records in ItemData
|
||||||
std::map<std::pair<int32_t, int32_t>, std::vector<std::map<std::pair<int32_t, int32_t>, Item>::iterator>> ItemManager::CrateItems;
|
std::map<std::pair<int32_t, int32_t>, std::vector<std::map<std::pair<int32_t, int32_t>, Item>::iterator>> ItemManager::CrateItems;
|
||||||
|
|
||||||
void ItemManager::init() {
|
void ItemManager::init() {
|
||||||
@ -143,8 +143,7 @@ void ItemManager::itemMoveHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
if (itemmove->eFrom == (int)SlotType::EQUIP) {
|
if (itemmove->eFrom == (int)SlotType::EQUIP) {
|
||||||
equipChange.iEquipSlotNum = itemmove->iFromSlotNum;
|
equipChange.iEquipSlotNum = itemmove->iFromSlotNum;
|
||||||
equipChange.EquipSlotItem = resp.ToSlotItem;
|
equipChange.EquipSlotItem = resp.ToSlotItem;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
equipChange.iEquipSlotNum = itemmove->iToSlotNum;
|
equipChange.iEquipSlotNum = itemmove->iToSlotNum;
|
||||||
equipChange.EquipSlotItem = resp.FromSlotItem;
|
equipChange.EquipSlotItem = resp.FromSlotItem;
|
||||||
}
|
}
|
||||||
@ -950,8 +949,7 @@ int ItemManager::getCrateItem(sItemBase& result, int itemSetId, int rarity, int
|
|||||||
|
|
||||||
// only take into account items that have correct gender
|
// only take into account items that have correct gender
|
||||||
std::vector<std::map<std::pair<int32_t, int32_t>, Item>::iterator> items;
|
std::vector<std::map<std::pair<int32_t, int32_t>, Item>::iterator> items;
|
||||||
for (auto crateitem : CrateItems[key])
|
for (auto crateitem : CrateItems[key]) {
|
||||||
{
|
|
||||||
int gender = crateitem->second.gender;
|
int gender = crateitem->second.gender;
|
||||||
// if gender is incorrect, exclude item
|
// if gender is incorrect, exclude item
|
||||||
if (gender != 0 && gender != playerGender)
|
if (gender != 0 && gender != playerGender)
|
||||||
|
@ -44,7 +44,6 @@ namespace ItemManager {
|
|||||||
// 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 itemTradeOfferAcceptHandler(CNSocket* sock, CNPacketData* data);
|
void itemTradeOfferAcceptHandler(CNSocket* sock, CNPacketData* data);
|
||||||
void itemTradeOfferRefusalHandler(CNSocket* sock, CNPacketData* data);
|
void itemTradeOfferRefusalHandler(CNSocket* sock, CNPacketData* data);
|
||||||
void itemTradeConfirmHandler(CNSocket* sock, CNPacketData* data);
|
void itemTradeConfirmHandler(CNSocket* sock, CNPacketData* data);
|
||||||
|
@ -148,8 +148,7 @@ bool MissionManager::endTask(CNSocket *sock, int32_t taskNum) {
|
|||||||
// update player
|
// update player
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
for (i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
||||||
if (plr->tasks[i] == taskNum)
|
if (plr->tasks[i] == taskNum) {
|
||||||
{
|
|
||||||
plr->tasks[i] = 0;
|
plr->tasks[i] = 0;
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
plr->RemainingNPCCount[i][j] = 0;
|
plr->RemainingNPCCount[i][j] = 0;
|
||||||
@ -161,8 +160,7 @@ bool MissionManager::endTask(CNSocket *sock, int32_t taskNum) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
||||||
@ -211,8 +209,7 @@ void MissionManager::quitTask(CNSocket* sock, int32_t taskNum, bool manual) {
|
|||||||
// update player
|
// update player
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
for (i = 0; i < ACTIVE_MISSION_COUNT; i++) {
|
||||||
if (plr->tasks[i] == taskNum)
|
if (plr->tasks[i] == taskNum) {
|
||||||
{
|
|
||||||
plr->tasks[i] = 0;
|
plr->tasks[i] = 0;
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
plr->RemainingNPCCount[i][j] = 0;
|
plr->RemainingNPCCount[i][j] = 0;
|
||||||
@ -449,14 +446,12 @@ void MissionManager::mobKilled(CNSocket *sock, int mobid) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// acknowledge killing of mission mob...
|
// acknowledge killing of mission mob...
|
||||||
if (task["m_iCSUNumToKill"][j] != 0)
|
if (task["m_iCSUNumToKill"][j] != 0) {
|
||||||
{
|
|
||||||
missionmob = true;
|
missionmob = true;
|
||||||
// sanity check
|
// sanity check
|
||||||
if (plr->RemainingNPCCount[i][j] == 0) {
|
if (plr->RemainingNPCCount[i][j] == 0) {
|
||||||
std::cout << "[WARN] RemainingNPCCount tries to go below 0?!" << std::endl;
|
std::cout << "[WARN] RemainingNPCCount tries to go below 0?!" << std::endl;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
plr->RemainingNPCCount[i][j]--;
|
plr->RemainingNPCCount[i][j]--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,6 +258,7 @@ void MobManager::giveEventReward(CNSocket* sock, Player* player) {
|
|||||||
// random drop chance
|
// random drop chance
|
||||||
if (rand() % 100 > settings::EVENTCRATECHANCE)
|
if (rand() % 100 > settings::EVENTCRATECHANCE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// no slot = no reward
|
// no slot = no reward
|
||||||
int slot = ItemManager::findFreeSlot(player);
|
int slot = ItemManager::findFreeSlot(player);
|
||||||
if (slot == -1)
|
if (slot == -1)
|
||||||
@ -284,8 +285,7 @@ void MobManager::giveEventReward(CNSocket* sock, Player* player) {
|
|||||||
|
|
||||||
// which crate to drop
|
// which crate to drop
|
||||||
int crateId;
|
int crateId;
|
||||||
switch (settings::EVENTMODE)
|
switch (settings::EVENTMODE) {
|
||||||
{
|
|
||||||
// knishmas
|
// knishmas
|
||||||
case 1: crateId = 1187; break;
|
case 1: crateId = 1187; break;
|
||||||
// halloween
|
// halloween
|
||||||
|
@ -60,10 +60,6 @@ struct Mob : public BaseNPC {
|
|||||||
dropType = data["m_iDropType"];
|
dropType = data["m_iDropType"];
|
||||||
level = data["m_iNpcLevel"];
|
level = data["m_iNpcLevel"];
|
||||||
|
|
||||||
// XXX: temporarily force respawns for Fusions until we implement instancing
|
|
||||||
//if (regenTime >= 300000000)
|
|
||||||
// regenTime = 1500;
|
|
||||||
|
|
||||||
roamX = spawnX = appearanceData.iX;
|
roamX = spawnX = appearanceData.iX;
|
||||||
roamY = spawnY = appearanceData.iY;
|
roamY = spawnY = appearanceData.iY;
|
||||||
roamZ = spawnZ = appearanceData.iZ;
|
roamZ = spawnZ = appearanceData.iZ;
|
||||||
|
@ -288,8 +288,7 @@ void NPCManager::npcVendorSell(CNSocket* sock, CNPacketData* data) {
|
|||||||
if (plr->Inven[req->iInvenSlotNum].iOpt - req->iItemCnt > 0) { // selling part of a stack
|
if (plr->Inven[req->iInvenSlotNum].iOpt - req->iItemCnt > 0) { // selling part of a stack
|
||||||
item->iOpt -= req->iItemCnt;
|
item->iOpt -= req->iItemCnt;
|
||||||
original.iOpt = req->iItemCnt;
|
original.iOpt = req->iItemCnt;
|
||||||
}
|
} else { // selling entire slot
|
||||||
else { // selling entire slot
|
|
||||||
item->iID = 0;
|
item->iID = 0;
|
||||||
item->iOpt = 0;
|
item->iOpt = 0;
|
||||||
item->iType = 0;
|
item->iType = 0;
|
||||||
@ -378,7 +377,7 @@ void NPCManager::npcVendorTable(CNSocket* sock, CNPacketData* data) {
|
|||||||
vItem.item = base;
|
vItem.item = base;
|
||||||
vItem.iSortNum = listings[i].sort;
|
vItem.iSortNum = listings[i].sort;
|
||||||
vItem.iVendorID = req->iVendorID;
|
vItem.iVendorID = req->iVendorID;
|
||||||
//vItem.fBuyCost = listings[i].price; this value is not actually the one that is used
|
//vItem.fBuyCost = listings[i].price; // this value is not actually the one that is used
|
||||||
|
|
||||||
resp.item[i] = vItem;
|
resp.item[i] = vItem;
|
||||||
}
|
}
|
||||||
@ -461,8 +460,7 @@ void NPCManager::npcCombineItems(CNSocket* sock, CNPacketData* data) {
|
|||||||
Item* itemLooksDat = ItemManager::getItemData(itemLooks->iID, itemLooks->iType);
|
Item* itemLooksDat = ItemManager::getItemData(itemLooks->iID, itemLooks->iType);
|
||||||
|
|
||||||
if (itemStatsDat == nullptr || itemLooksDat == nullptr
|
if (itemStatsDat == nullptr || itemLooksDat == nullptr
|
||||||
|| ItemManager::CrocPotTable.find(abs(itemStatsDat->level - itemLooksDat->level)) == ItemManager::CrocPotTable.end()) // sanity check 2
|
|| ItemManager::CrocPotTable.find(abs(itemStatsDat->level - itemLooksDat->level)) == ItemManager::CrocPotTable.end()) { // sanity check 2
|
||||||
{
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_ITEM_COMBINATION_FAIL, failResp);
|
INITSTRUCT(sP_FE2CL_REP_PC_ITEM_COMBINATION_FAIL, failResp);
|
||||||
failResp.iCostumeItemSlot = req->iCostumeItemSlot;
|
failResp.iCostumeItemSlot = req->iCostumeItemSlot;
|
||||||
failResp.iStatItemSlot = req->iStatItemSlot;
|
failResp.iStatItemSlot = req->iStatItemSlot;
|
||||||
@ -477,8 +475,7 @@ void NPCManager::npcCombineItems(CNSocket* sock, CNPacketData* data) {
|
|||||||
float successChance = recipe->base / 100.0f; // base success chance
|
float successChance = recipe->base / 100.0f; // base success chance
|
||||||
|
|
||||||
// rarity gap multiplier
|
// rarity gap multiplier
|
||||||
switch(abs(itemStatsDat->rarity - itemLooksDat->rarity))
|
switch(abs(itemStatsDat->rarity - itemLooksDat->rarity)) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
successChance *= recipe->rd0;
|
successChance *= recipe->rd0;
|
||||||
break;
|
break;
|
||||||
@ -514,8 +511,7 @@ void NPCManager::npcCombineItems(CNSocket* sock, CNPacketData* data) {
|
|||||||
itemStats->iOpt = 0;
|
itemStats->iOpt = 0;
|
||||||
itemStats->iTimeLimit = 0;
|
itemStats->iTimeLimit = 0;
|
||||||
itemStats->iType = 0;
|
itemStats->iType = 0;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// failure; don't do anything?
|
// failure; don't do anything?
|
||||||
resp.iSuccessFlag = 0;
|
resp.iSuccessFlag = 0;
|
||||||
}
|
}
|
||||||
@ -603,8 +599,7 @@ void NPCManager::handleWarp(CNSocket* sock, int32_t warpId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// std::cerr << "Warped to Map Num:" << Warps[warpId].instanceID << " NPC ID " << Warps[warpId].npcID << std::endl;
|
// std::cerr << "Warped to Map Num:" << Warps[warpId].instanceID << " NPC ID " << Warps[warpId].npcID << std::endl;
|
||||||
if (Warps[warpId].isInstance)
|
if (Warps[warpId].isInstance) {
|
||||||
{
|
|
||||||
uint64_t instanceID = Warps[warpId].instanceID;
|
uint64_t instanceID = Warps[warpId].instanceID;
|
||||||
if (Warps[warpId].limitTaskID != 0) { // if warp requires you to be on a mission, it's gotta be a unique instance
|
if (Warps[warpId].limitTaskID != 0) { // if warp requires you to be on a mission, it's gotta be a unique instance
|
||||||
instanceID += ((uint64_t)plrv.plr->iIDGroup << 32); // upper 32 bits are leader ID
|
instanceID += ((uint64_t)plrv.plr->iIDGroup << 32); // upper 32 bits are leader ID
|
||||||
@ -612,9 +607,7 @@ void NPCManager::handleWarp(CNSocket* sock, int32_t warpId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlayerManager::sendPlayerTo(sock, Warps[warpId].x, Warps[warpId].y, Warps[warpId].z, instanceID);
|
PlayerManager::sendPlayerTo(sock, Warps[warpId].x, Warps[warpId].y, Warps[warpId].z, instanceID);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC, resp); // Can only be used for exiting instances because it sets the instance flag to false
|
INITSTRUCT(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC, resp); // Can only be used for exiting instances because it sets the instance flag to false
|
||||||
resp.iX = Warps[warpId].x;
|
resp.iX = Warps[warpId].x;
|
||||||
resp.iY = Warps[warpId].y;
|
resp.iY = Warps[warpId].y;
|
||||||
|
@ -66,7 +66,6 @@ void PlayerManager::removePlayer(CNSocket* key) {
|
|||||||
PlayerView& view = players[key];
|
PlayerView& view = players[key];
|
||||||
uint64_t fromInstance = view.plr->instanceID;
|
uint64_t fromInstance = view.plr->instanceID;
|
||||||
|
|
||||||
//MissionManager::failInstancedMissions(key); moved to enter
|
|
||||||
GroupManager::groupKickPlayer(view.plr);
|
GroupManager::groupKickPlayer(view.plr);
|
||||||
|
|
||||||
// save player to DB
|
// save player to DB
|
||||||
@ -863,8 +862,7 @@ void PlayerManager::enterPlayerVehicle(CNSocket* sock, CNPacketData* data) {
|
|||||||
sock->sendPacket((void*)&response, P_FE2CL_PC_VEHICLE_ON_FAIL, sizeof(sP_FE2CL_PC_VEHICLE_ON_FAIL));
|
sock->sendPacket((void*)&response, P_FE2CL_PC_VEHICLE_ON_FAIL, sizeof(sP_FE2CL_PC_VEHICLE_ON_FAIL));
|
||||||
|
|
||||||
// check if vehicle didn't expire
|
// check if vehicle didn't expire
|
||||||
if (plr.plr->Equip[8].iTimeLimit < getTimestamp())
|
if (plr.plr->Equip[8].iTimeLimit < getTimestamp()) {
|
||||||
{
|
|
||||||
plr.plr->toRemoveVehicle.eIL = 0;
|
plr.plr->toRemoveVehicle.eIL = 0;
|
||||||
plr.plr->toRemoveVehicle.iSlotNum = 8;
|
plr.plr->toRemoveVehicle.iSlotNum = 8;
|
||||||
ItemManager::checkItemExpire(sock, plr.plr);
|
ItemManager::checkItemExpire(sock, plr.plr);
|
||||||
@ -955,8 +953,7 @@ WarpLocation PlayerManager::getRespawnPoint(Player *plr) {
|
|||||||
|
|
||||||
bool PlayerManager::isAccountInUse(int accountId) {
|
bool PlayerManager::isAccountInUse(int accountId) {
|
||||||
std::map<CNSocket*, PlayerView>::iterator it;
|
std::map<CNSocket*, PlayerView>::iterator it;
|
||||||
for (it = PlayerManager::players.begin(); it != PlayerManager::players.end(); it++)
|
for (it = PlayerManager::players.begin(); it != PlayerManager::players.end(); it++) {
|
||||||
{
|
|
||||||
if (it->second.plr->accountId == accountId)
|
if (it->second.plr->accountId == accountId)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -223,8 +223,7 @@ void TableData::init() {
|
|||||||
*/
|
*/
|
||||||
int TableData::getItemType(int itemSet) {
|
int TableData::getItemType(int itemSet) {
|
||||||
int overriden;
|
int overriden;
|
||||||
switch (itemSet)
|
switch (itemSet) {
|
||||||
{
|
|
||||||
case 11: // Chest items don't have iEquipLoc and are type 9.
|
case 11: // Chest items don't have iEquipLoc and are type 9.
|
||||||
overriden = 9;
|
overriden = 9;
|
||||||
break;
|
break;
|
||||||
@ -343,13 +342,11 @@ void TableData::loadDrops() {
|
|||||||
|
|
||||||
toAdd.dropChanceType = (int)drop["DropChance"];
|
toAdd.dropChanceType = (int)drop["DropChance"];
|
||||||
// Check if DropChance exists
|
// Check if DropChance exists
|
||||||
if (MobManager::MobDropChances.find(toAdd.dropChanceType) == MobManager::MobDropChances.end())
|
if (MobManager::MobDropChances.find(toAdd.dropChanceType) == MobManager::MobDropChances.end()) {
|
||||||
{
|
|
||||||
throw TableException(" MobDropChance not found: " + std::to_string((toAdd.dropChanceType)));
|
throw TableException(" MobDropChance not found: " + std::to_string((toAdd.dropChanceType)));
|
||||||
}
|
}
|
||||||
// Check if number of crates is correct
|
// Check if number of crates is correct
|
||||||
if (!(MobManager::MobDropChances[(int)drop["DropChance"]].cratesRatio.size() == toAdd.crateIDs.size()))
|
if (!(MobManager::MobDropChances[(int)drop["DropChance"]].cratesRatio.size() == toAdd.crateIDs.size())) {
|
||||||
{
|
|
||||||
throw TableException(" DropType " + std::to_string((int)drop["DropType"]) + " contains invalid number of crates");
|
throw TableException(" DropType " + std::to_string((int)drop["DropType"]) + " contains invalid number of crates");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,8 +389,7 @@ void TableData::loadDrops() {
|
|||||||
std::pair<int32_t, int32_t> itemSetkey = std::make_pair((int)item["ItemSet"], (int)item["Rarity"]);
|
std::pair<int32_t, int32_t> itemSetkey = std::make_pair((int)item["ItemSet"], (int)item["Rarity"]);
|
||||||
std::pair<int32_t, int32_t> itemDataKey = std::make_pair((int)item["Id"], (int)item["Type"]);
|
std::pair<int32_t, int32_t> itemDataKey = std::make_pair((int)item["Id"], (int)item["Type"]);
|
||||||
|
|
||||||
if (ItemManager::ItemData.find(itemDataKey) == ItemManager::ItemData.end())
|
if (ItemManager::ItemData.find(itemDataKey) == ItemManager::ItemData.end()) {
|
||||||
{
|
|
||||||
char buff[255];
|
char buff[255];
|
||||||
sprintf(buff, "Unknown item with Id %d and Type %d", (int)item["Id"], (int)item["Type"]);
|
sprintf(buff, "Unknown item with Id %d and Type %d", (int)item["Id"], (int)item["Type"]);
|
||||||
throw TableException(std::string(buff));
|
throw TableException(std::string(buff));
|
||||||
|
2
tdata
2
tdata
@ -1 +1 @@
|
|||||||
Subproject commit ffbb1afb36381e99e2ec7de3006bcbe09b3d4e18
|
Subproject commit aa4338202eb02d913bdfd8cf6d008795ded0f026
|
Loading…
Reference in New Issue
Block a user