Skip to content

Commit

Permalink
Map rotation fixes:
Browse files Browse the repository at this point in the history
Fixes mutiple rotate operations from breaking the server, map rotation will properly detect rotation operations as well as update operations and abort.
Fixes max pop being treated as minpop
Adds more feedback to admin verbs.
  • Loading branch information
MrStonedOne committed Oct 7, 2015
1 parent 29cf9bd commit e27e9e8
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 21 deletions.
9 changes: 7 additions & 2 deletions code/modules/admin/verbs/maprotation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
mapname += "\]"

maprotatechoices[mapname] = VM
var/choosenmap = input("Choose a map to rotate to", "Change Map") as null|anything in maprotatechoices
var/choosenmap = input("Choose a map to change to", "Change Map") as null|anything in maprotatechoices
if (!choosenmap)
return
changemap(maprotatechoices[choosenmap])
ticker.maprotatechecked = 1
var/datum/votablemap/VM = maprotatechoices[choosenmap]
message_admins("[key_name_admin(usr)] is changing the map to [VM.name]([VM.friendlyname])")
log_admin("[key_name(usr)] is changing the map to [VM.name]([VM.friendlyname])")
if (changemap(VM) == 0)
message_admins("[key_name_admin(usr)] has changed the map to [VM.name]([VM.friendlyname])")
32 changes: 22 additions & 10 deletions code/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ var/failed_db_connections = 0
if (VM.minusers > 0 && players < VM.minusers)
mapvotes.Remove(map)
continue
if (VM.maxusers > 0 && players < VM.maxusers)
if (VM.maxusers > 0 && players > VM.maxusers)
mapvotes.Remove(map)
continue

Expand All @@ -350,6 +350,8 @@ var/failed_db_connections = 0
return
if (!istype(VM))
return

log_game("Changing map to [VM.name]([VM.friendlyname])")
var/file = file("setnewmap.bat")
file << "\nset MAPROTATE=[VM.name]\n"
. = shell("..\\bin\\maprotate.bat")
Expand All @@ -359,15 +361,25 @@ var/failed_db_connections = 0
log_game("Failed to change map: Could not run map rotator")
if (0)
log_game("Changed to map [VM.friendlyname]")
//1x: file errors
if (11)
message_admins("Failed to change map: Map rotator script couldn't find file listing new map")
log_game("Failed to change map: Map rotator script couldn't find file listing new map")
message_admins("Failed to change map: File error: Map rotator script couldn't find file listing new map")
log_game("Failed to change map: File error: Map rotator script couldn't find file listing new map")
if (12)
message_admins("Failed to change map: Map rotator script couldn't find tgstation-server framework")
log_game("Failed to change map: Map rotator script couldn't find tgstation-server framework")
if (13)
message_admins("Failed to change map: Could not compile new map:[VM.name]")
log_game("Failed to change map: Could not compile new map:[VM.name]")
message_admins("Failed to change map: File error: Map rotator script couldn't find tgstation-server framework")
log_game("Failed to change map: File error: Map rotator script couldn't find tgstation-server framework")
//2x: conflicting operation errors
if (21)
message_admins("Failed to change map: Conflicting operation error: Current server update operation detected")
log_game("Failed to change map: Conflicting operation error: Current server update operation detected")
if (22)
message_admins("Failed to change map: Conflicting operation error: Current map rotation operation detected")
log_game("Failed to change map: Conflicting operation error: Current map rotation operation detected")
//3x: external errors
if (31)
message_admins("Failed to change map: External error: Could not compile new map:[VM.name]")
log_game("Failed to change map: External error: Could not compile new map:[VM.name]")

else
message_admins("Failed to change map: Unknown error")
log_game("Failed to change map: Unknown error")
message_admins("Failed to change map: Unknown error: Error code #[.]")
log_game("Failed to change map: Unknown error: Error code #[.]")
20 changes: 18 additions & 2 deletions tools/tgstation-server/Update Server.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ call bin\getcurdate.bat
echo This will handle downloading git, compiling the server, and applying the update.
echo ready?
timeout 120
if exists updating.lk (
echo ERROR! A current update script has been detected running. if you know this is a mistake:
pause
echo Please be double sure that an update script is not currently running, if you think one might be, close this window. otherwise:
pause
)
if exists rotating.lk (
echo ERROR! A current map rotation operation has been detected running. IT IS STRONGLY RECOMMENDED YOU DO NOT UPDATE RIGHT NOW. if you know this is a mistake, and that the game server is not currently rotating the map:
pause
echo IT IS STRONGLY RECOMMENDED YOU DO NOT UPDATE RIGHT NOW. If a map rotation script runs at the same time as an update script the server will generally break in ways not trivial to recover from. Are you REALLY sure? Please close this window if you are not, otherwise:
pause
)
@del /F /Q rotating.lk >nul 2>nul
echo lock>updating.lk

rem if the first arg to nudge.py is not a channel, it is treated as the "source"
if not defined UPDATE_LOG_CHANNEL set UPDATE_LOG_CHANNEL="UPDATER"
Expand All @@ -16,6 +30,7 @@ call bin\updategit.bat
if %GIT_EXIT% neq 0 (
echo git pull failed. Aborting update
python bot\nudge.py %UPDATE_LOG_CHANNEL% "Git pull failed. Aborting update"
@del updating.lk >nul 2>nul
pause
exit /b 1
)
Expand All @@ -27,10 +42,10 @@ if defined PUSHCHANGELOGTOGIT (
git add -u html/changelog.html
git add -u html/changelogs
git commit -m "Automatic changelog compile"
REM an error here generally means there was nothing to commit.
if %ERRORLEVEL% == 0 (
git push
)
REM an error here generally means there was nothing to commit.
)
)

Expand All @@ -54,6 +69,7 @@ call bin\build.bat
if %DM_EXIT% neq 0 (
echo DM compile failed. Aborting.
python bot\nudge.py %UPDATE_LOG_CHANNEL% "DM compile failed Aborting update." >nul 2>nul
@del /F /Q updating.lk >nul 2>nul
pause
exit /b 1
)
Expand All @@ -63,7 +79,7 @@ if not defined NOWAITUPDATES (
echo Ready?
pause
)

@del updating.lk >nul 2>nul
rmdir /q gamefolder
mklink /d gamefolder gamecode\%AB% >nul
python bot\nudge.py %UPDATE_LOG_CHANNEL% "Update job finished. Update will take place next round." >nul 2>nul
Expand Down
8 changes: 3 additions & 5 deletions tools/tgstation-server/bin/copyfromgit.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ rmdir /q gamecode\%AB%\data >nul 2>nul
rmdir /q gamecode\%AB%\config >nul 2>nul
rmdir /q gamecode\%AB%\cfg >nul 2>nul
del /q gamecode\%AB%\nudge.py >nul 2>nul
del /q gamecode\%AB%\CORE_DATA >nul 2>nul
del /q gamecode\%AB%\CORE_DATA.py >nul 2>nul

rmdir /S /q gamecode\%AB%
del /S /F /Q gamecode\%AB%

echo Copying files
xcopy gitrepo gamecode\%AB% /Y /X /K /R /H /I /C /V /E /Q /EXCLUDE:copyexclude.txt >nul
Expand All @@ -19,6 +19,4 @@ rmdir /q gamecode\%AB%\data >nul 2>nul
rmdir /s /q gamecode\%AB%\data >nul 2>nul
mklink /d gamecode\%AB%\data ..\..\gamedata\data >nul
mklink /d gamecode\%AB%\config ..\..\gamedata\config >nul
mklink /d gamecode\%AB%\cfg ..\..\gamedata\cfg >nul

copy bin\maprotate.bat gamecode\%AB%\maprotate.bat
mklink /d gamecode\%AB%\cfg ..\..\gamedata\cfg >nul
9 changes: 7 additions & 2 deletions tools/tgstation-server/bin/maprotate.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
if not exist setnewmap.bat exit 11
call setnewmap.bat
cd ..

if exists updating.lk exit 21
if exists rotating.lk exit 22

if not exist config.bat exit 12
call config.bat

echo lock>rotating.lk
cls
echo Rotating map to %MAPROTATE%

Expand All @@ -21,7 +25,8 @@ cls
echo Rotating map to %MAPROTATE%

call bin\build.bat
if %DM_EXIT% neq 0 exit 13
@del /F /Q rotating.lk >nul 2>nul
if %DM_EXIT% neq 0 exit 31

rmdir /q gamefolder
mklink /d gamefolder gamecode\%AB%

0 comments on commit e27e9e8

Please sign in to comment.