MapChange

Expand and mod your server.
Post Reply
User avatar
optic delusion
Special Forces
Special Forces
Posts: 1052
Joined: Sat Sep 25, 2004 2:29 pm
Location: Planet MoFo
Contact:

MapChange

Post by optic delusion »

Gnurdux is 100 percent responsible for the creation of this plugin, and since six months have passed and he still doesnt want to release it, I convinced him that I should release it for him.
Thanks also to A_Temporal_Distraction, Thumper, and A_Meteorite for help in making this post.

Map rotation scripts have been around for a few years, the chief benefit of the plugin is you get to choose which map will run after restart.
I put a debian-compiled .so in the zip. Not sure how it will behave on your system.
I provide example code here, but you'll have to use your own paths to /plugins and /bzfs.




Compile or place mapchange.so in your normal plugins directory.

Where you usually keep your .conf's, make a directory named to match the port of your map change server. I used 4242-mapchange

Into that directory put all the desired regular .bzw and .conf files.

Edit all of these conf files to use the same port number chosen. Add helpfiles, srvmsg, etc. if desired.

Create a new text file "mapchange.conf" that contains the names of the server conf files used. The first word is the command that will be entered in-game, the second word is the exact name of the conf that corresponds with the command. Here's a sample from mofo-mapchange:

mapchange.conf

Code: Select all

1v1 1v1.conf
4team 4team.conf
HTF HTF.conf
hunt hunt.conf
pillbox pillbox.conf
redvsblue redvsblue.conf
Create a new file "mapchange.sh" that contains the script to run that starts it. You'll have to correct the plugin and bzfs locations.

mapchange.sh

Code: Select all

#!/bin/bash 
#! 
#! Mapchange script 
#! 
#! FILE - sets the name of the mapchange configuration file and list of configurations 
#! if FILE=mapchange then you get 'mapchange.out' as the output file of the plugin 
#! with the selected configuration and 'mapchange.conf' is the list of configurations 
#! to choose from. 

#! Configuration 
#! 
FILE=mapchange # base of configuration filename and output file 
SLEEPTIME=2.5 # Time in seconds to sleep between restarts 
PLUGIN=plugins/mapchange # mapchange plugin 
BZFS=./bzfs	 # bzflag server binary 

#! Build the output file and configuration file parameters for the mapchange plugin 
MCOUT=$FILE.out 
MCCFG=$FILE.conf 

#! Loop forever - display name of the selected configuration 
while cat $MCOUT; do 
#! Run the server 
$BZFS -conf $(cat $MCOUT) -loadplugin $PLUGIN,$MCOUT,$MCCFG 
#! Wait some time between restarts 
sleep $SLEEPTIME 
done
Make that script executable by opening your terminal and cd to the correct directory then...

Code: Select all

chmod +x mapchange.sh



Create the initial output file "mapchange.out" that is written by the script.
This text file should initially contain the name of the first map to load

#EDIT people are getting tripped up on this step.
The mapchange.out file is needed by the plugin. It contains the name of the NEXT conf that the plugin will load (and nothing else). When you run the command "/mapchange name" (from the client) the plugin will write the name of the next conf to the mapchange.out file.
You need to provide mapchange.out for the plugin the first time you run the mapchange script, so the plugin knows which conf is needed. It does not need to be chmod'd, it is a text file.

After the server is running, and you change a map or conf file (badly) causing the server to hang... the mapchange script keeps running, there is a 5 second delay built into the script to prevent mapchange from consuming 100 percent of CPU while the script loops, but you still need to start the server. There are 2 ways to fix the server.
1. Fix the file you broke while the loop continues, the script will pick up the changes on the next loop.
2. open mapchange.out and edit a known "good" conf into it, the script will pick up the changes on the next loop. Now you can fix the broken bzw or conf while the server is running, and hope no one does /mapchange broken again.
#end EDIT

mapchange.out

Code: Select all

redvsblue.conf
Edit your groups file.
Add CONFCHANGE to which evey groups you want to have the power to run the /mapchange command. (It's CONFchange -- not MAPchange permission... a legacy of early development with this plugin.)


The mapchange server should work now.
Run the script with ./mapchange.sh


I like to add a help file as well.

mapchange-help.txt

Code: Select all

*******
Mapchange commands that an admin can do

/maplist
/mapchange <map>
/maprandom

When you use the '/mapchange <map>' command, the server
will restart immediately, so give some warning before you do it.
******
Add this line to the conf file for each game

Code: Select all

 -helpmsg ./mapchange-help.txt mapchange

After it's running, you'll want to add new maps:
simply add a conf and map to the directory
edit the conf for correct port, etc.
edit one line into mapchange.conf
restart server using a pre-existing conf
your new map will be available.
Attachments
mapchange.zip
(77.57 KiB) Downloaded 937 times
Last edited by optic delusion on Fri Oct 26, 2007 8:06 pm, edited 3 times in total.
Take a look at my Defender game mode concept.

Thinking is not an automatic process. A man can choose to think or to let his mind stagnate, or he can choose actively to turn against his intelligence, to evade his knowledge, to subvert his reason. If he refuses to think, he courts disaster: he cannot with impunity reject his means of perceiving reality.
User avatar
Zelgadis
Private First Class
Private First Class
Posts: 638
Joined: Sat Jul 02, 2005 2:31 pm
Location: European Union

Post by Zelgadis »

Yes very nice plugin, i thank to gnurdux that i got it some months ago :)

Very good job :)
Want to improve your skill? Join the http://guleague.org!
User avatar
Destroyer
Private First Class
Private First Class
Posts: 284
Joined: Sun Sep 25, 2005 3:40 pm
Location: Germany
Contact:

Post by Destroyer »

yes i agree! Nice Plugin!
Image
Gnurdux
Corporal
Corporal
Posts: 25
Joined: Thu Jun 16, 2005 10:12 pm

Post by Gnurdux »

Sorry about not posting it. I'm just a lazy person. Btw, most plugins of my plugins (probably including ones not yet made at this post) are available at http://gnurdux.homelinux.net/bzplugins -- no warrantee :P

If in doubt, assume they're under the GPL
User avatar
optic delusion
Special Forces
Special Forces
Posts: 1052
Joined: Sat Sep 25, 2004 2:29 pm
Location: Planet MoFo
Contact:

2-Part conf loading

Post by optic delusion »

Yes, Gnurdux proves that you don't need rank to be king.

Now with the plugin as above, there's one last problem. You have a dozen confs with a dozen maps, and sooner or later you will have to change one setting (maybe your welcome message) in all 12 confs in order to do that. Major pain in the butt.
Here we have modified the mapchange.sh script to load a 2-part conf file. You can have one file that contains all the settings that are the same across all maps, and another much shorter file that contains only the settings that are unique to each individual map. The script combines both files into a new temporary file that is then loaded by bzfs at mapchange.

Code: Select all

#!/bin/bash
#!
#! Mapchange script
#!
#! FILE - sets the name of the mapchange configuration file and list of configurations
#!        if FILE=mapchange then you get 'mapchange.out' as the output file of the plugin
#!        with the selected configuration and 'mapchange.conf' is the list of configurations
#!        to choose from.

#! Configuration
#!
FILE=mapchange            # base of configuration filename and output file
SLEEPTIME=2.5             # Time in seconds to sleep between restarts
PLUGIN=plugins/mapchange  # mapchange plugin
BZFS=./bzfs		  # bzflag server binary

#! Build the output file and configuration file parameters for the mapchange plugin
MCOUT=$FILE.out
MCCFG=$FILE.conf

#! Loop forever - display name of the selected configuration
while cat $MCOUT; do
	#! Run the server
	cat 4040a.conf $(cat $MCOUT) >CONF.tmp
	$BZFS -conf CONF.tmp -loadplugin $PLUGIN,$MCOUT,$MCCFG
	#! Wait some time between restarts
	sleep $SLEEPTIME
done
Just make this new script executable and split your confs into two parts, you now can make changes across all servers by changing only one file, conf-part-A
Every other operation of the plugin remains the same.


note: anybody who saw this on jan20 or 21... I pasted the wrong script... it's fixed now
Take a look at my Defender game mode concept.

Thinking is not an automatic process. A man can choose to think or to let his mind stagnate, or he can choose actively to turn against his intelligence, to evade his knowledge, to subvert his reason. If he refuses to think, he courts disaster: he cannot with impunity reject his means of perceiving reality.
User avatar
optic delusion
Special Forces
Special Forces
Posts: 1052
Joined: Sat Sep 25, 2004 2:29 pm
Location: Planet MoFo
Contact:

To whom it may concern.

Post by optic delusion »

The One Thousand Map Library Server!
Read all about it!

http://my.bzflag.org/bb/viewtopic.php?p=100958#100958
Take a look at my Defender game mode concept.

Thinking is not an automatic process. A man can choose to think or to let his mind stagnate, or he can choose actively to turn against his intelligence, to evade his knowledge, to subvert his reason. If he refuses to think, he courts disaster: he cannot with impunity reject his means of perceiving reality.
User avatar
Durf
Private First Class
Private First Class
Posts: 47
Joined: Mon Mar 20, 2006 12:12 am
Location: In a tank! Where else?

Post by Durf »

yea im lazy. could someone make something where all someone has to do is put in names and it generates all files ready to use.?
........................
.__......._..___....
|__)(_)|..'.|-........
............................
User avatar
blast
General
General
Posts: 4931
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Post by blast »

Durf wrote:yea im lazy. could someone make something where all someone has to do is put in names and it generates all files ready to use.?
Sure, you're more than welcome to create such a tool or script.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
User avatar
Grans Remedy
Private First Class
Private First Class
Posts: 91
Joined: Sun Dec 05, 2004 10:47 pm
Location: New Zealand

Help - Plugin wont load

Post by Grans Remedy »

I can't load this plugin - I think I need to compile from source, but when running make over the dir in the supplied zip archive produces an error:
[grans@gransplace mapchange]$ make
make: *** No targets specified and no makefile found. Stop
Can someone give me a clue pse?
This is on Centos 4 - I have the FairCTF plugin working just fine (after compiling from source).

Cheers
Grans.
No coffee, no workee
User avatar
macsforme
General
General
Posts: 2069
Joined: Wed Mar 01, 2006 5:43 am

Re: Help - Plugin wont load

Post by macsforme »

Grans Remedy wrote:I can't load this plugin - I think I need to compile from source, but when running make over the dir in the supplied zip archive produces an error:
[grans@gransplace mapchange]$ make
make: *** No targets specified and no makefile found. Stop
Can someone give me a clue pse?
This is on Centos 4 - I have the FairCTF plugin working just fine (after compiling from source).

Cheers
Grans.
You should be able to compile it the same way you compiled FairCTF. Assuming it's just one source code file, you can use newplug.sh to add it to the main source code tree, or use a shell command to compile like:

Code: Select all

g++ -I /path/to/bzflag/include -shared -o mapchange.so mapchange.cpp
User avatar
Grans Remedy
Private First Class
Private First Class
Posts: 91
Joined: Sun Dec 05, 2004 10:47 pm
Location: New Zealand

Post by Grans Remedy »

Thanks Const, I managed to get this to compile, and I can load the plugin. But, server says /maplist is unknown command (even tho the plugin is loadable using /loadplugin /path/to/plugin.so)
Any ideas ?

Cheers
Grans.
No coffee, no workee
User avatar
blast
General
General
Posts: 4931
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Post by blast »

Grans Remedy, run the server with -dddd and check for any plugin loading errors. Of course, you won't want to run that for long, since that will create a huge log file (if you save logs).
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
User avatar
optic delusion
Special Forces
Special Forces
Posts: 1052
Joined: Sat Sep 25, 2004 2:29 pm
Location: Planet MoFo
Contact:

edited into the first post

Post by optic delusion »

I have edited the first post in this thread.
I also strongly encourage that you use the SECOND mapchange.sh script that I posted in this thread, and split your confs. It's a bit more work at the start, but will save you a ton of time later.


The mapchange.out file is needed by the plugin. It contains the name of the NEXT conf that the plugin will load (and nothing else). When you run the command "/mapchange name" (from the client) the plugin will write the name of the next conf to the mapchange.out file.
You need to provide mapchange.out for the plugin the first time you run the mapchange script, so the plugin knows which conf is needed. It does not need to be chmod'd, it is a text file.

After the server is running, and you change a map or conf file (badly) causing the server to hang... the mapchange script keeps running, there is a 5 second delay built into the script to prevent mapchange from consuming 100 percent of CPU while the script loops, but you still need to start the server. There are 2 ways to fix the server.
1. Fix the file you broke while the loop continues, the script will pick up the changes on the next loop.
2. open mapchange.out and edit a known "good" conf into it, the script will pick up the changes on the next loop. Now you can fix the broken bzw or conf while the server is running, and hope no one does /mapchange broken again.
Take a look at my Defender game mode concept.

Thinking is not an automatic process. A man can choose to think or to let his mind stagnate, or he can choose actively to turn against his intelligence, to evade his knowledge, to subvert his reason. If he refuses to think, he courts disaster: he cannot with impunity reject his means of perceiving reality.
User avatar
allejo
Breaker of Builds
Breaker of Builds
Posts: 809
Joined: Sun Feb 17, 2008 10:01 pm
Location: /dev/null
Contact:

Re: MapChange

Post by allejo »

I'm sorry, I didn't realize I hadn't posted the updated version for 2.4.x of the plug-in. I haven't tested it so no guarantees that it'll work.
Attachments
mapchange.cpp
2.4.x API
(5.51 KiB) Downloaded 273 times
User avatar
Trogdor BurNinat0R
Private First Class
Private First Class
Posts: 11
Joined: Fri Jun 29, 2007 3:33 am
Location: Location Location
Contact:

Re: MapChange

Post by Trogdor BurNinat0R »

as you probably know, it works.

thanks!
User avatar
allejo
Breaker of Builds
Breaker of Builds
Posts: 809
Joined: Sun Feb 17, 2008 10:01 pm
Location: /dev/null
Contact:

Re: MapChange

Post by allejo »

As an update for this plug-in, Constitution's fork of the mapchange plug-in and then my fork of that has moved to github, https://github.com/allejo/mapchange
Post Reply