Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

Server: pq_connectmute tutorial

| Inside3d Forums Forum Index -> Programming Tutorials

View previous topic :: View next topic
Author | Message
--- | ---
Baker Joined: 14 Mar 2006 Posts: 1538 |

Posted: Tue Dec 29, 2009 7:03 am Post subject: Server: pq_connectmute tutorial |

With mods (at least in NetQuake), traditionally the way the ban file works is that mods read the ban file in and then if the ip address matches a banned ip, the player gets booted. Vulnerability It takes at least a fraction of a second for the mod to read the ban file. Maybe 1 second or 2 seconds.
During that time a player can spam chat. With a creative alias, they can connect, chat spam, connect, chat spam, connect chat spam.
And they can ruin a game by doing so, particularly a team game where communication is important. At a minimum it is disruptive. And they aren't supposed to be able to connect to a server they are banned on anyway.
PQ_CONNECTMUTE: # of seconds before a player is allowed to speak upon connecting ...
This engine modification allows the server to only permit chatting after X seconds of being connected. This gives the mod time to read the ban file and execute it. I have ProQuake in dedicated server mod set it to 3 automatically.
I wrote this for ProQuake server about 2 years ago. Actually, R00k walked me through the implementation because at the time I was very new to engine coding.
Anyway, this is a "bandage" to solve this issue. The preferred way would be the engine reading the ban file unless there is a good reason that QuakeC is the "right way" to do this for reasons I am unaware of.
Tutorial (Adapted to GLQuake/WinQuake)
1. in host.c, create a cvar "pq_connectmute" with a default value of 0! Yes zero.
Add this:

Quote:
// Baker 3.99g - from Rook ... protect against players connecting and spamming before banfile can kick in cvar_t pq_connectmute = {"pq_connectmute", "0", false, true}; // (value in seconds)

Add the yellow:

Quote:
Cvar_RegisterVariable (&coop); Cvar_RegisterVariable (&pq_connectmute); // Baker 3.99g: from Rook, protection against repeatedly connecting + spamming

2. sv_main.c
We default pq_connectmute to 0 because it is undesireable in single player or a listen server. But for a dedicated server, we will likely want it. GLQuake/WinQuake doesn't have sophisticated cvar defaulting, so we need to set it to 3 in the code if the server is running in dedicated mode.
Add this to SV_Init:

Code:
// Baker: Dedicated server "defaults" - this is ok because quake.rc is executed later, so these "defaults" won't override config.cfg settings, etc. if (COM_CheckParm ("-dedicated")) { Cvar_Set("pq_connectmute", "3"); // Baker 3.99g: "Default" it to 10 seconds
}

At first glance, you would think this is improper because it would override the value specified in the command line or elsewhere, but it's fine because that all occurs later.
3. Open host_cmd.c and in Host_Say add the yellow:

Quote:
// turn on color set 1 if (!fromServer) { // R00k - dont allow new connecting players to spam obscenities... if (pq_connectmute.value && (net_time - host_client->netconnection->connecttime) < pq_connectmute.value)
return;

So if pq_connectmute has a value of 3, it will be 3 seconds before the server will allow a player to chat. The ban file will have been read by that time and executed.
And banned players spamming chat with a script is no longer possible.

Back to top |

Baker Joined: 14 Mar 2006 Posts: 1538 |

Posted: Tue Dec 29, 2009 7:53 am Post subject: |

Another "bandage", this time limiting the ability for disruptive players to ruin games. This time it is joining a team game setup in progress and selecting a color. There is an annoying player who likes to connect to servers and disrupt the setup of team games by connecting via a proxy and selecting a color, before a game start.
This little "bandage" prevents any color change for X seconds in theory.

Code:
// Baker: If the player pants color isn't 0 // and the player shirt color isn't 0 (hence playercolor will be 0) // and pq_colorlock has a non-zero value // then deny changes to the color for X seconds as specified in pq_colorlock if (playercolor && !pq_colorlock.value && (net_time - host_client->netconnection->connecttime) < pq_colorlock.value)
return;

So if a player cannot select a color until being connected for, say, 45 seconds it is rather difficult to be able to reconnect and ruin a game setup if you can't change your color immediately upon connecting.
[Better anti-proxy prevention in the engine would be a far better solution, this is a POOR solution. But with someone using a proxy and reconnecting after being kicked/banned, it should be an effective solution.]

Back to top |

mh Joined: 12 Jan 2008 Posts: 910 |

Posted: Tue Dec 29, 2009 2:02 pm Post subject: |

Neat. Don't forget to define and register the pq_colorlock cvar by the way. I'd bag these for DirectQ only it's not really meant to be used as a server (I even removed the dedicated server a good time back). Feck it, I'm bagging pq_colorlock anyway.
_________________
DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines

Back to top |

Baker Joined: 14 Mar 2006 Posts: 1538 |

Posted: Tue Dec 29, 2009 2:25 pm Post subject: |

This tutorial does fall solidly into the boring and low utility category. It's not exciting like ripping the awesome Enforcer lasers effect out of ezQuake or perverting Rook's powerupshells stuff in an EF_YELLOW tutorial on how to make cool looking forcefielded monsters
However, that's actually why it is important to write it up and file it here to collect the knowledge and if someone casually reads some of the info here, might see something.
There have probably been 10 external texture tutorials and 6 MD3 tutorials in Quakesrc.org, but what everyone needs are the oddball ones (like scratch.qc -- I had never even heard of that).
I have a few more boring ones on the way too.
It's all good. Eventually I have a very large endgame planned, but I spend my time plodding around with small details that have to get fixed for that to matter. The car is no good if the frame cannot support the weight

Back to top |

FrikaC Site Admin Joined: 08 Oct 2004 Posts: 947 |

Posted: Thu Dec 31, 2009 9:07 pm Post subject: |

I totally think the engine should handle all the ban features. There's no good reason I can think of for a mod to handle any of that stuff.

Back to top |

Downsider Joined: 16 Sep 2008 Posts: 478 |

Posted: Thu Dec 31, 2009 9:54 pm Post subject: |

I'd like the finished scratch QC deal, I think Avirox has it, because I hate stripping out Quake stuff or starting from 100% scratch every time I experiment. ^ Sometimes nessecary due to the PSP's limited RAM. Can't load nice maps if I'm precaching all these Quake models and textures that won't be in the final version anyway!

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> Programming Tutorials | All times are GMT
Page 1 of 1

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group