Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show games with password to admins #353

Closed
Kellsya opened this issue May 16, 2018 · 23 comments
Closed

Show games with password to admins #353

Kellsya opened this issue May 16, 2018 · 23 comments

Comments

@Kellsya
Copy link

Kellsya commented May 16, 2018

By default pvpgn can hide/display games with password using this setting in bnetd.conf

hide_pass_games = true

The bug here is that even if the setting is set to true normal players can still see passworded games that that shouldn't happen as the option is enabled. Can we have so that only admins (maybe certain cg) can see the full list of games normal players the public games? This is mainly important for games like warcraft and diablo games.

@RElesgoe
Copy link
Member

How is this important for WarCraft and Diablo games?

@RElesgoe RElesgoe changed the title Show games with password Show games with password to admins May 16, 2018
@Kellsya
Copy link
Author

Kellsya commented May 16, 2018

@RElesgoe, for example in diablo games you dont want players to see private games created by other players but only public games and you want for admins to see them and check all games list if anyone is cheating. Cheating with a bot for example will create private games one after another with increasing number and it's easy to track if you are able to see full games list.

@Kellsya
Copy link
Author

Kellsya commented May 17, 2018

@HarpyWar, maybe a lua command can be added for this?

@HarpyWar
Copy link
Member

HarpyWar commented May 17, 2018

It's possible to override returned game list from Lua in handle_game.lua > function handle_game_list(account)

Example of code which returns only games with passwords for admins, edit it to your needs:

local gamelist = {}
-- is admin account
local is_admin = account_get_auth_admin(account.name, nil)

if is_admin then
	-- get server games
	local glist = server_get_games()
	-- iterate games
	for i,game in pairs(glist) do
		-- if game password is not empty
		if not string:empty(game.pass) then
			-- then add to new gamelist
			table.insert(gamelist, game.id)
			table.insert(gamelist, game.name)
		end
	end

	-- return new gamelist
	return {"id", "name"}, gamelist
end

Game object properties
Account object properties

@Kellsya
Copy link
Author

Kellsya commented May 17, 2018

Thanks @HarpyWar. Do I need to replace the entire function or can I keep war3xp one too? I see current function is related to ghost for warcraft. Can it be added as separate function for D2XP and keep WAR3XP too https://pastebin.com/jUAwm2Xk? Also can you make it please so it returns all games with pass for certain command group only instead of all admins? So only admins with certain cg that I choose can see that.

@HarpyWar
Copy link
Member

HarpyWar commented May 17, 2018

This requires testing, so I can't do it now.
Example of reading command groups of account https://github.com/pvpgn/pvpgn-server/blob/master/lua/handle_command.lua#L49
You can keep code for ghost or just remove it if you don't plan to use it. Anyway it can be disabled from config.lua.

You can debug and finish the script by yourself with /rehash lua and DEBUG("text") inside Lua scripts to display veriable values and any text in main server log.
Also you can see script errors in logs with a line number if something wrong. It's impossible to crash a server from Lua.

@Kellsya
Copy link
Author

Kellsya commented May 17, 2018

I'm not good with lua so whenever you have time I would appreciate if you can take a look and make so cg flag can be used instead of all admins, only when you have time. Will test the command today anyway to see if all works good. Thanks again, helpful as always.

@HarpyWar
Copy link
Member

If you know any other programming language I can suggest the following link which helped me for writing these scripts for pvpgn http://tylerneylon.com/a/learn-lua/

@Kellsya
Copy link
Author

Kellsya commented May 17, 2018

I wished I knew any but I don't and not because I am lazy or anything, tried to learn c++ few years ago but barely understood few simple things that are always used, wouldn't know to develop from from that. I will try to find something useful on the link you gave me although at first look it's like chineese to me.

@RElesgoe
Copy link
Member

Have you tried using the /games all command? I'm not entirely sure if it shows passworded games though. Let me know if it doesn't.

@Kellsya
Copy link
Author

Kellsya commented May 17, 2018

@RElesgoe I am testing now and used /games all command and seems it shows all games including passworded games to normal players too so this is not good. hide_pass_games = true is set inside bnetd.conf yet any player can see password games too.

@HarpyWar, I replaced the lua function. When using /games I can only see public games, when using /games all I can see all games including passworded but non-admins can see those too.

@RElesgoe
Copy link
Member

As a workaround for now, you can modify conf/command_groups.conf to restrict the /games command to specific command groups.

@Kellsya
Copy link
Author

Kellsya commented May 17, 2018

This will block the command for all normal players though and in games like diablo they must be allowed to see all normal games. Something seems to be broken with hide_pass_games = true when using /games all in pro because in pvpgn this should block password games from being displayed and I tried not without the lua changes and /games all displays password games by default to everyone all the time.

@RElesgoe
Copy link
Member

I don't think the /game all command takes into account of the hide_pass_games option, but that needs to be fixed some day. The /games command is unnecessary for normal users since they could still view the game list as they usually do, so that's why restricting the /games command to certain command groups can be a workaround to your problem.

@Kellsya
Copy link
Author

Kellsya commented May 17, 2018

@RElesgoe, how about setting /games all as separate command and have different cg? This will solve the problems because players can still use /games and see public and admins have /games all to see all the games. Command /games it is necessary for normal users for games like diablo because full games do not appear in the game list at 8/8 players anymore and for farm games it's important to have that. Having separate command group for /games and /games all would fix every inconvenience with this.

@RElesgoe
Copy link
Member

I've made a commit (8464f2b) to the develop branch that would allow admins to view private games only if they use the /games all command. I think it would be overkill to do this based on command groups.

@Kellsya
Copy link
Author

Kellsya commented May 18, 2018

@RElesgoe, maybe if you only give a certain command group number the permission it won't be as overkill? Let's say only those with cg 3 can see and if we need to change that we only modify that file in source. Either way I bet many will love this new commit and thank you for being so fast, will test this as soon as I get to pc.

@RElesgoe
Copy link
Member

It's pretty arbitrary and inconsistent to restrict this specific command and parameter to a specific command group. If you still want this feature, you would have to implement it yourself.

@Kellsya
Copy link
Author

Kellsya commented May 19, 2018

@RElesgoe, I tested the new commit on the source I'm using and works perfect, thanks a lot for that. Yes, maybe giving specific cg is personal preference because I would prefer not to give someone /admin +username for games list alone so in this case cg makes more sense, you know like other pvpgn individual commands are assigned to different command groups. Could you maybe point me to what I need to edit to achieve this goal? Whenever you have the time of course or if you want to.

@RElesgoe
Copy link
Member

You'll want to modify the _glist_cb() function in src/bnetd/command.cpp and add a check for the command group of the account belonging to cbdata->c.

@Kellsya
Copy link
Author

Kellsya commented May 19, 2018

I tried to change account_get_auth_admin(conn_get_account(cbdata->c) to account_get_command_groups(conn_get_account(cbdata->c) in _glist_cb() but I get compile error. How the check line for cg should look like?

@RElesgoe
Copy link
Member

You should replace
else if (cbdata->tag == 0 && account_get_auth_admin(conn_get_account(cbdata->c), nullptr) != 1)
with
else if (cbdata->tag == 0 && !(account_get_command_groups(conn_get_account(cbdata->c)) & 1 << (3 - 1)))

@Kellsya
Copy link
Author

Kellsya commented May 19, 2018

Thanks a lot, much appreciated. The setting in bnetd.conf works correctly now too, you guys were so fast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants