Move from isGM to Account Levels (#106)

Co-authored-by: dongresource <dongresource@protonmail.com>
This commit is contained in:
CakeLancelot 2020-09-21 21:26:12 -05:00 committed by GitHub
parent 5d8bb7f8a5
commit adf017b07c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 25 additions and 20 deletions

View File

@ -34,8 +34,14 @@ xdtdata=tdata/xdt.json
mobdata=tdata/mobs.json
# path json
pathdata=tdata/paths.json
# is everyone a GM?
gm=true
# account permission level that will be set upon character creation
# 1 = default, will allow *all* commands
# 30 = allow some more "abusable" commands such as /summon
# 50 = only allow cheat commands, like /itemN and /speed
# 99 = standard user account, no cheats allowed
# any number higher than 50 will disable commands
accountlevel=1
# spawn coordinates (Z is height)
# the supplied defaults are at Sector V (future)

View File

@ -52,7 +52,7 @@ auto db = make_storage("database.db",
make_column("Height", &Database::DbPlayer::Height),
make_column("NameCheck", &Database::DbPlayer::NameCheck),
make_column("SkinColor", &Database::DbPlayer::SkinColor),
make_column("isGM", &Database::DbPlayer::isGM),
make_column("AccountLevel", &Database::DbPlayer::AccountLevel),
make_column("FusionMatter", &Database::DbPlayer::FusionMatter),
make_column("Taros", &Database::DbPlayer::Taros),
make_column("Quests", &Database::DbPlayer::QuestFlag),
@ -202,7 +202,7 @@ int Database::createCharacter(sP_CL2LS_REQ_SAVE_CHAR_NAME* save, int AccountID)
create.HairStyle = 1;
create.Height = 0;
create.SkinColor = 1;
create.isGM = settings::GM;
create.AccountLevel = settings::ACCLEVEL;
create.x_coordinates = settings::SPAWN_X;
create.y_coordinates = settings::SPAWN_Y;
create.z_coordinates = settings::SPAWN_Z;
@ -347,7 +347,7 @@ Database::DbPlayer Database::playerToDb(Player *player)
result.HairStyle = player->PCStyle.iHairStyle;
result.Height = player->PCStyle.iHeight;
result.HP = player->HP;
result.isGM = player->IsGM;
result.AccountLevel = player->accountLevel;
result.LastName = U16toU8(player->PCStyle.szLastName);
result.Level = player->level;
result.NameCheck = player->PCStyle.iNameCheck;
@ -402,7 +402,7 @@ Player Database::DbToPlayer(DbPlayer player) {
result.PCStyle.iHairStyle = player.HairStyle;
result.PCStyle.iHeight = player.Height;
result.HP = player.HP;
result.IsGM = player.isGM;
result.accountLevel = player.AccountLevel;
U8toU16(player.LastName, result.PCStyle.szLastName);
result.level = player.Level;
result.PCStyle.iNameCheck = player.NameCheck;

View File

@ -58,7 +58,7 @@ namespace Database {
short int PayZoneFlag;
short int SkinColor;
bool TutorialFlag;
bool isGM;
int AccountLevel;
int FusionMatter;
int Taros;
int x_coordinates;

View File

@ -158,11 +158,10 @@ void ItemManager::itemGMGiveHandler(CNSocket* sock, CNPacketData* data) {
sP_CL2FE_REQ_PC_GIVE_ITEM* itemreq = (sP_CL2FE_REQ_PC_GIVE_ITEM*)data->buf;
PlayerView& plr = PlayerManager::players[sock];
// Commented and disabled for future use
//if (!plr.plr->IsGM) {
if (plr.plr->accountLevel > 50) {
// TODO: send fail packet
// return;
//}
return;
}
if (itemreq->eIL == 2) {
// Quest item, not a real item, handle this later, stubbed for now

View File

@ -408,7 +408,7 @@ void NPCManager::npcUnsummonHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_NPC_UNSUMMON))
return; // malformed packet
if (!PlayerManager::getPlayer(sock)->IsGM)
if (PlayerManager::getPlayer(sock)->accountLevel > 30)
return;
sP_CL2FE_REQ_NPC_UNSUMMON* req = (sP_CL2FE_REQ_NPC_UNSUMMON*)data->buf;
@ -424,7 +424,7 @@ void NPCManager::npcSummonHandler(CNSocket* sock, CNPacketData* data) {
Player* plr = PlayerManager::getPlayer(sock);
// permission & sanity check
if (!plr->IsGM || req->iNPCType >= 3314)
if (plr->accountLevel > 30 || req->iNPCType >= 3314)
return;
resp.NPCAppearanceData.iNPC_ID = NPCs.size()+1;

View File

@ -12,6 +12,7 @@
struct Player {
int accountId;
int accountLevel; // permission level (see CN_ACCOUNT_LEVEL enums)
int64_t SerialKey;
int32_t iID;
uint64_t FEKey;
@ -42,7 +43,6 @@ struct Player {
int32_t moneyInTrade;
bool isTrading;
bool isTradeConfirm;
bool IsGM;
int64_t aQuestFlag[16];
int tasks[ACTIVE_MISSION_COUNT];

View File

@ -202,7 +202,7 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
response.iID = plr.iID;
response.uiSvrTime = getTime();
response.PCLoadData2CL.iUserLevel = plr.level;
response.PCLoadData2CL.iUserLevel = plr.accountLevel;
response.PCLoadData2CL.iHP = plr.HP;
response.PCLoadData2CL.iLevel = plr.level;
response.PCLoadData2CL.iCandy = plr.money;

View File

@ -40,7 +40,7 @@ void TransportManager::transportRegisterLocationHandler(CNSocket* sock, CNPacket
}
// update registration bitfield using bitmask
uint32_t newScamperFlag = plr->iWarpLocationFlag | (plr->IsGM ? UINT32_MAX : (1UL << (transport->iLocationID - 1)));
uint32_t newScamperFlag = plr->iWarpLocationFlag | (plr->accountLevel <= 40 ? UINT32_MAX : (1UL << (transport->iLocationID - 1)));
if (newScamperFlag != plr->iWarpLocationFlag) {
plr->iWarpLocationFlag = newScamperFlag;
newReg = true;
@ -61,7 +61,7 @@ void TransportManager::transportRegisterLocationHandler(CNSocket* sock, CNPacket
/*
* assuming the two bitfields are just stuck together to make a longer one, do a similar operation
*/
if (plr->IsGM) {
if (plr->accountLevel <= 40) {
plr->aSkywayLocationFlag[0] = UINT64_MAX;
plr->aSkywayLocationFlag[1] = UINT64_MAX;
newReg = true;

View File

@ -24,7 +24,7 @@ std::string settings::XDTJSON = "tdata/xdt.json";
std::string settings::MOBJSON = "tdata/mobs.json";
std::string settings::PATHJSON = "tdata/paths.json";
std::string settings::MOTDSTRING = "Welcome to OpenFusion!";
bool settings::GM = true;
int settings::ACCLEVEL = 1;
void settings::init() {
INIReader reader("config.ini");
@ -55,5 +55,5 @@ void settings::init() {
MOBJSON = reader.Get("shard", "mobdata", MOBJSON);
PATHJSON = reader.Get("shard", "pathdata", PATHJSON);
MOTDSTRING = reader.Get("shard", "motd", MOTDSTRING);
GM = reader.GetBoolean("shard", "gm", GM);
ACCLEVEL = reader.GetBoolean("shard", "accountlevel", ACCLEVEL);
}

View File

@ -13,12 +13,12 @@ namespace settings {
extern int SPAWN_Y;
extern int SPAWN_Z;
extern int SPAWN_ANGLE;
extern int ACCLEVEL;
extern std::string MOTDSTRING;
extern std::string NPCJSON;
extern std::string XDTJSON;
extern std::string MOBJSON;
extern std::string PATHJSON;
extern bool GM;
void init();
}