Pages: [1]
  Print  
Author Topic: Small tool to create map list for Openarena  (Read 4307 times)
vindimy
Bigger member


Cakes 15
Posts: 161


lolwut?


WWW
« on: April 07, 2009, 10:18:06 PM »

Hey all,

I got sick of manually typing list of maps for my Openarena server, especially tracking all the numbers! So I sat down for half an hour and created a simple tool to generate that list!

Knowing that fromhell drools over opensource software and GPL, I licensed the tool as such :D

Features:

* Reliably generate a map list
* Start from any number, not just 0
* Increment numbers by 5 if you'd like (useful if you're inserting more maps in between later)

Here it is:

http://oa.thedimi.net/tools/maplist-generator.php

I'll also post the source code below in case my server goes down:
Code:
<?php 
if (!empty($_REQUEST['source']))
{
   echo 
"<pre>";
   echo 
htmlspecialchars(file_get_contents($_SERVER['SCRIPT_FILENAME']));
   echo 
"</pre>";
   die();
}
?>
<html>
<head>
   <title>Openarena Map List Generator</title>
</head>
<body>
<pre>
[<a href="/">home</a>]


<b>Openarena Map List Generator</b>

   Put your list of maps in the textbox below, one map per line. Click submit, and you'll get a list of maps ready to go
into maps.cfg for your Openarena server. Also works for any Quake 3 or ioquake3 based games. Enjoy!

   <b>*Note:</b> <i>No more than 150 entries allowed, and each entry will be cut off at 50 characters!</i>

   <b>*Note:</b> <i>You can also <a target="_blank" href="<?php echo $PHP_SELF "?source=1"?>">view source</a> of this tool!</i>

<form method="post" action="<?php echo $PHP_SELF?>">
<textarea name="maps" cols="80" rows="20"><?php echo htmlspecialchars($_REQUEST['maps']); ?></textarea>
(optional) start count at: <input type="text" name="start" value="<?php echo (empty($_REQUEST['start'])) ? htmlspecialchars($_REQUEST['start']); 
?>
"></input> (0 - 1000)
(optional) skip 5 numbers each count: <input type="checkbox" name="skip" value="surewhynot"<?php echo (isset($_REQUEST['skip'])) ? ' checked="checked"' ' '?>></input>
<input type="submit" value=" Submit "></input>

<?php

/*

    Purpose: Generate a map configuration file for a server running a
             Quake 3-based or ioquake3-based game, such as Openarena.
    Creator: Dmitriy Vi (me AT thedimi . net)
    Version: 0.1

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

// These settings prevent potential overloading of the server by malicious users.
define("MAX_ENTRIES"150);      // total number of entries to accept
define("MAX_ENTRY_LENGTH"50);  // maximum number of characters per entry
define("MAX_START_AT"1000);    // do not allow to start count from any number larger than this one

define("INCREMENT_BY"5);       // some users like gaps in their map numbering sequence to insert more maps later

if (!empty($_REQUEST['maps']))
{
   
$start_at = (is_numeric($_REQUEST['start']) && $_REQUEST['start'] > && $_REQUEST['start'] < MAX_START_AT+1) ? $_REQUEST['start'] : 0;
   
$j $start_at;
   
$incr_by = (isset($_REQUEST['skip']) && $_REQUEST['skip'] == "surewhynot") ? INCREMENT_BY 1;

   
$maps_arr split("\n"htmlspecialchars($_REQUEST['maps']), MAX_ENTRIES+1);
   if (!empty(
$maps_arr[MAX_ENTRIES]))
      die (
"ERROR: Can't process your request, too many entries!");

   echo 
"Here's your maps.cfg:\n\n//------------------------------\n";
   for (
$i 0$i count($maps_arr); $i++)
   {
      
$last = ($j count($maps_arr)*$incr_by $incr_by == $start_at) ? $start_at $j+$incr_by;
      
printf("set m%04d \"map %s ; set nextmap vstr m%04d\"\n"$jtrim(substr($maps_arr[$i], 0, (MAX_ENTRY_LENGTH-1))), $last);
      
$j += $incr_by;
   }
   
printf("\nwait\n\nvstr m%04d"$start_at);
   echo 
"\n//------------------------------\n";
}
?>

</pre>
</body>
</html>
« Last Edit: April 07, 2009, 11:37:45 PM by vindimy » Logged

Pages: [1]
  Print  
 
Jump to: