MG/Processing game mods

From MegaGlest
Jump to navigation Jump to search

It can be somewhat tedious to add new game mods (maps, tilesets, techtrees) to the game mod database so here's some documentation on the internal process of adding game mod data to the database.

Maps[edit]

What to request from contributors[edit]

  • Map file, example filename: mapfile.mgm, the filename shoould be all lowercase.
  • 800x600 pixel preview image in JPEG format, the filename should be exactly the same as that of the map file, with an extra '.jpg' extension, example filename: mapfile.mgm.jpg
  • Description text, example: 3 vs. 3 player map, use tileset 'desert2', Author: newbie

Internal processing[edit]

  • Place the maps in ~/.megaglest/maps and test them
  • Generate CRCs (you may use the Linux shell script below)
  • Upload files to the web server using FTP or, if available, SSH access. Place all files in the mods/maps/ directory.
  • Run SQL query against the database (using PHPMyAdmin web interface or, if available, the mysql command line / console) to add references to the new maps; see the example SQL query below

Examples[edit]

Shell script to generate checksums for all custom maps[edit]

Place this script in your MegaGlest installation (probably ~/megaglest/) or build directory and make it executable (chmod +x filename). Mine is called dev_crcmaps.sh.

#!/bin/sh
#
# Print all CRC checksums for all maps in ~/.megaglest/maps

for filepath in ~/.megaglest/maps/*.gbm ~/.megaglest/maps/*.mgm 
do 
  filename=$(basename "$filepath"|sed 's/\(\..*\)$//')
  ./megaglest --show-map-crc="$filename" | grep '^CRC value for map'
done | sort -k 5

Example SQL query to add maps to database[edit]

This example SQL code would add three new maps. It was rewrapped for better readability, and while it works as such, could also be a one-liner.

INSERT INTO `glestmaps` 
  (`updatetime`, `glestversion`, `mapname`, `playercount`, `crc`, `description`, `url`, `imageUrl`, `disabled`) 
VALUES 
  (CURRENT_TIMESTAMP, '3.6.0.2', 'no_masters.mgm', 6, -147021482, 'Small to medium map for 2-6 players or 1-3 vs. CPU\nDo NOT use with tilesets Karningul, Pine Peat or Swamp\n\nMap author: atze', 'http://mods.megaglest.org/maps/no_masters.mgm', 'http://mods.megaglest.org/maps/no_masters.mgm.jpg', '0'), 
  (CURRENT_TIMESTAMP, '3.6.0.2', 'renkontre.mgm', 6, 42644594, 'Small to medium map for 2-6 players or 1-3 vs. CPU\n\nMap author: atze', 'http://mods.megaglest.org/maps/renkontre.mgm', 'http://mods.megaglest.org/maps/renkontre.mgm.jpg', '0'),
  (CURRENT_TIMESTAMP, '3.6.0.2', 'tour_de_force.mgm', 6, -95475776, 'Small to medium map for 2-6 players or 1-3 vs. CPU\n\nMap author: atze', 'http://mods.megaglest.org/maps/tour_de_force.mgm', 'http://mods.megaglest.org/maps/tour_de_force.mgm.jpg', '0');

You will probably not add exactly three new entries, so make sure you do not mix up , on the one hand (which separates entries to make as well as fields) and ; on the other hand (which separates SQL statements, i.e. you probably only want one and only in the very end).