Skip to content

Commit

Permalink
fix-publicserver
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandru Stan committed Apr 24, 2010
1 parent 3384658 commit 41b8a5d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/fpsgame/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ namespace server
extern int mastermode;
extern int mastermask;
extern char smapname[260];
extern int publicserver;
extern char *adminpass;
extern char *serverpass;
extern int gamemode;
Expand Down
6 changes: 6 additions & 0 deletions src/pycontrol/servermodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,11 @@ static PyObject *adminPass(PyObject *self, PyObject *args)
return Py_BuildValue("s", server::adminpass);
}

static PyObject *publicServer(PyObject *self, PyObject *args)
{
return Py_BuildValue("i", server::publicserver);
}

static PyObject *sendMapReload(PyObject *self, PyObject *args)
{
server::sendmapreload();
Expand Down Expand Up @@ -956,6 +961,7 @@ static PyMethodDef ModuleMethods[] = {
{"setMinsRemaining", setGameMins, METH_VARARGS, "Set the minutes remanining in current game."},
{"endGame", endGame, METH_VARARGS, "End the current game."},
{"adminPassword", adminPass, METH_VARARGS, "Get the administrator password."},
{"publicServer", publicServer, METH_VARARGS, "Decides how masters are chosen and what privileges they have."},
{"sendMapReload", sendMapReload, METH_VARARGS, "Causes all users to send vote on next map."},
{"serverPassword", serverPassword, METH_VARARGS, "Password for entry to the server."},
{"minutesRemaining", minRemain, METH_VARARGS, "Minutes remaining in current match."},
Expand Down
19 changes: 16 additions & 3 deletions src/pyscripts/xsbs/users/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from xsbs.commands import commandHandler, UsageError, StateError, ArgumentValueError
from xsbs.colors import red, green, orange
from xsbs.ui import info, error, warning
from xsbs.players import player
from xsbs.players import player, currentAdmin, currentMaster
from xsbs.settings import loadPluginConfig
from xsbs.ban import ban
from xsbs.timers import addTimer
Expand Down Expand Up @@ -172,7 +172,7 @@ def onSetMaster(cn, givenhash):
NickAccount.query.filter(NickAccount.nick==p.name()).one()
except NoResultFound:
if givenhash != adminhash:
p.message(error('Your name is not assigned to any accounts'))
setSimpleMaster(cn)
except MultipleResultsFound:
p.message(error(' This name is linked to multiple accounts. Contact the system administrator.'))
else:
Expand All @@ -181,7 +181,20 @@ def onSetMaster(cn, givenhash):
login(cn, na.user)
else:
if givenhash != adminhash:
p.message(error('Invalid password'))
setSimpleMaster(cn)

def setSimpleMaster(cn):
p = player(cn)
if sbserver.publicServer() == 1:
sbserver.playerMessage(cn, error('This is not an open server, you need auth or master privileges to get master.'))
return
if currentAdmin() != None:
sbserver.playerMessage(cn, error('Admin is present'))
return
if currentMaster() != None:
sbserver.playerMessage(cn, error('Master is present'))
return
sbserver.setMaster(cn)

def warnNickReserved(cn, count, sessid):
try:
Expand Down

0 comments on commit 41b8a5d

Please sign in to comment.