Skip to content

Commit

Permalink
never clear the invisible/hidden gm status
Browse files Browse the repository at this point in the history
  • Loading branch information
Helianthella committed Jul 8, 2020
1 parent c01f80b commit 10a83bd
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 12 deletions.
9 changes: 9 additions & 0 deletions src/char/char.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,8 +812,17 @@ void create_online_files(void)
// display each player.
for (CharPair& cd : char_keys)
{
CharData *p = nullptr;

if (!server_for(&cd))
continue;

p = cd.data.get();

// failsafe
if (bool(p->option & Opt0::HIDE))
continue;

players++;
FPRINTF(fp2, " <tr>\n"_fmt);
// displaying the character name
Expand Down
25 changes: 25 additions & 0 deletions src/map/atcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,31 @@ bool is_atcommand(Session *s, dumb_ptr<map_session_data> sd,
}
}

bool can_use_atcommand(dumb_ptr<map_session_data> sd, ZString message)
{
nullpo_retr(false, sd);

if (!message.startswith('@'))
return false;

XString command;
ZString arg;
asplit(message, &command, &arg);

GmLevel gmlvl = pc_isGM(sd);

if (battle_config.atcommand_gm_only != 0 && !gmlvl)
return false; // level 0 commands are disabled

Option<P<AtCommandInfo>> info_ = atcommand(command);
P<AtCommandInfo> info = TRY_UNWRAP(info_,
{
return false; // command not found
});

return gmlvl.satisfies(info->level);
}

Option<Borrowed<AtCommandInfo>> atcommand(XString cmd)
{
if (cmd.startswith('@'))
Expand Down
2 changes: 2 additions & 0 deletions src/map/atcommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ namespace map
bool is_atcommand(Session *s, dumb_ptr<map_session_data> sd,
ZString message, GmLevel gmlvl);

bool can_use_atcommand(dumb_ptr<map_session_data> sd, ZString message);

bool atcommand_config_read(ZString cfgName);

void log_atcommand(dumb_ptr<map_session_data> sd, ZString cmd);
Expand Down
23 changes: 12 additions & 11 deletions src/map/pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,25 +779,26 @@ int pc_authok(AccountId id, int login_id2, ClientVersion client_version,
// イベント関係の初期化
sd->eventqueuel.clear();

// 位置の設定
pc_setpos(sd, sd->status.last_point.map_, sd->status.last_point.x,
sd->status.last_point.y, BeingRemoveWhy::GONE);

{
Opt0 old_option = sd->status.option;
sd->status.option = Opt0::ZERO;

// This would leak information.
// It's better to make it obvious that players can see you.
if (false && bool(old_option & Opt0::INVISIBILITY))
is_atcommand(sd->sess, sd, "@invisible"_s, GmLevel());
if (bool(old_option & Opt0::INVISIBILITY) && can_use_atcommand(sd, "@invisible"_s)) {
// prevent leaking by first applying hide before status_change
sd->status.option |= Opt0::HIDE;
sd->status.option |= Opt0::INVISIBILITY;
clif_status_change(sd, StatusChange::CLIF_OPTION_SC_INVISIBILITY, 1);
} else if (bool(old_option & Opt0::HIDE) && can_use_atcommand(sd, "@hide"_s)) {
sd->status.option |= Opt0::HIDE;
}

if (bool(old_option & Opt0::HIDE))
is_atcommand(sd->sess, sd, "@hide"_s, GmLevel());
// atcommand_hide might already send it, but also might not
clif_changeoption(sd);
}

// 位置の設定
pc_setpos(sd, sd->status.last_point.map_, sd->status.last_point.x,
sd->status.last_point.y, BeingRemoveWhy::GONE);

// パーティ、ギルドデータの要求
if (sd->status.party_id
&& party_search(sd->status.party_id).is_none())
Expand Down
2 changes: 1 addition & 1 deletion src/map/skill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ int skill_status_change_clear(dumb_ptr<block_list> bl, int type)
*opt1 = Opt1::ZERO;
*opt2 = Opt2::ZERO;
*opt3 = Opt3::ZERO;
*option = Opt0::ZERO;
//*option = Opt0::ZERO;

if (type == 0 || type & 2)
clif_changeoption(bl);
Expand Down

0 comments on commit 10a83bd

Please sign in to comment.