Manual on how to test and fix the Lagcycle-Bug
Author: [SC]BelovedMonster
Version: 20 oktober 2005 – pre release
Introduction
The lagcycle-bug is a nasty mysterious bug that plagues several custom multiplayer maps of different gametypes. When you play the infected map you notice nothing special. However, the map you play after the infected map lags considerably. This leads often to wrong conclusions about custom maps, as it is not immediately clear what causes the lag on a specific map – it could be the bad design of the map itself, but it could also be that the map itself is good, but the map that was played right before had the lagcycle-bug. Also it is not clear what the cause is of the lagcycle-bug. This has lead, among other things, to desperate mappers who have tried to fix the bug for their map. This also applied to me, when I was working on mp_helix. The released BETA-version (called mp_HELiX_Prologue_BETA) was infected by the lagcycle-bug, and I wanted to fix it.
Luckily, it has been discovered that building a new map based on a stock map like mp_airstrip reduces the chances of being infected. This has lead also to the suggestion to fix the lagcycle-bug by building the map again from scratch based on a stock map. That is exactly what I did with mp_helix, and finally I succeeded in this. What I have learnt from this, I have put in this manual in the strong hope that other mappers can do the same. However, a warning is in order, as I cannot garantee success. The only thing I know is that it worked for me. The entire manual is written on the basis of my experience in fixing the bug for mp_helix. Any suggestions to improve the manual are more than welcome.
Overview
Roughly the following steps must be taken to test and fix the Lagcycle-Bug.
Test if your map is infected. If yes then go on with step 2 else leave this manual.
Install a new basic map that is not infected.
Now you need to export all the stuff from your infected map.
When the heightmap of your infected map has not the size of 1024×1024 then you need to resize your heightmap and (if present) resize the masks of the manual textures.
Now you need to import all that stuff into the new uninfected map.
Finishing touches.
These steps are described in this manual, but first i start with some definitions:
- i call the map that is (possibly) infected by the bug: mp_infect
- i call the new map that should not be infected: mp_new (when following this manual you temporarily have two versions of your map, the infected one and the new uninfected one.)
- i call the Sandbox editor in which you make your Farcry-maps, simply: Editor
Step 1: Test if your map is infected
Required:
a) custommap mp_urbanwar_2 is installed
b) knowledge on how to show FPS (frames per second) in FarCry (r_displayinfo 1)
I do the following to test if a map is infected by the Lagcycle-Bug:
1. Start FarCry, choose Multiplayer, [Create a LAN-server], Select your gametype (assault/tdm/ffa), Select mp_infect, [Run].
2. When your map has loaded, play for say 10 seconds in your map, then hit ESC and disconnect.
3. Select Assault, Select mp_urbanwar_2, [Run].
4. When I see that urbanwar_2 runs with FPS 60+ the mp_infect is NOT infected. When FPS is around 20 then mp_infect is infected.
Step 2: Installation of mp_basic
The quickest way to make a new basicmap that is not infected is the following:
1. Go to http://www.springcreature.net. Choose downloads. Select Far Cry Maps. Download Far Cry basicmap.
2. Run the downloaded .exe. Now you should have a directory …/FarCry/levels/mp_basicmap
3. Change the name of the directory to your liking. In the directory you can also change the name of mp_basicmap.cry. For convenience reasons I will call the map mp_new
4. Start the Editor / Load mp_new / Delete the missions that are not in your mp_infected (e.g. delete FFA/TDM when your map is an ASSAULT map) / Save / Export to Engine.
Step 3: Export all the stuff from mp_infect
Required: paper and pencil
Most things of a map can be exported with the editor. Some things however must be done manually:
Start the Editor. Load mp_infect.
Write down manual stuff
Environment
In the RollupBar: Choose Terrain / Click Environment / Write down all this data. NB If you don’t know which bars I mean, choose Window from the menu and (de-)select the bar.Lighting
In the ToolBar: Click Lightning / Write down all this data. You must estimate the 4 sliders. / Also write down the Sky Color and Sun Color.
Libraries
Open the Database view (e.g. by selecting it under the menu Window). Write down or remember the libraries you use in your map, like the animal library when you have animals in your map, or several material libraries when you use custommaterials on objects. NB. The selected libraries are loaded everytime your map is loaded.
Holes
If you made holes in the terrain: look at these holes and try to remember how big they are.
Lightmap
If you made a lightmap: write down the lightmap settings you used to make that lightmap. That is: In the Game-menu, choose generate lightmaps / write down the settings at ‘quality’ and ‘misc’ Automatic export
Layers
In the RollupBar: Choose Layers Settings / Click the small floppy disk / Choose a name and save it.
Objects
First be sure that no objects are froozen or hidden. Then select ALL objects: Choose menu Edit / Click Select All / Then Choose menu Modify / Click Save Object(s) / Choose a name and save it.
Vegetation
In the RollupBar: Choose Terrain / Select ALL vegetation groups (holding shift – choose the first vegetation group – then choose the last) / Click the small floppy disk / Choose a name and save it.
Textures
In the ToolBar: Click Texture (you are now in the Terrain Layers Editor) / Choose File-menu / Choose Export Layers / Choose a name and save it.
Heightmap
In the ToolBar: Click Terrain / Choose File-menu / Choose Export Heightmap / Choose as file-type: .pgm or .raw (NOT .bmp) / Choose a name and save it
Check if your heightmap dimensions are 1024×1024. (In the ToolBar: Click Terrain ). If your heightmap dimensions are not 1024×1024 then you must go to step 4 else go to step 5.
Step 4 (optional): Resize heightmap & texture-masks
Required: program to edit images like photoshop or paintshop-pro
If the heightmap dimensions of mp_infect are not 1024×1024 (but for instance 512×512) then the heightmap must be resized. For now I pressume the heightmap that was exported at step 3 had dimensions 512×512. Then this heightmap must be resized (or better enlarged) to 1024×1024, otherwise it cannot be imported at the following step. Also when you used one or more manual texture masks, these images must also be resized.
Resize of heightmap from 5121024
Schematically the resize looks like this:
You can load the original heightmap into Paintshop (or whatever program you use). How exactly you must do the transformation sketched above in Paintshop I do not know. I admit to be a kind of Paintshop-noob. I tried several things that looked logical, but when I tried to import the result (see next step) I run into all kind of problems. Therefor I used a manual method
Manual method
Shot explanation of .pgm -format
I used the .pgm format to export the heightmap in the previous step. The file can be opened with a simple word-editor, as the file contains only numbers. In fact it has:
- a header: starts with P2, then the dimensions of the heightmap (512 512), then the maximum height-value (65535)
- 512 lines of 512 numbers (for each position in the heightmap it has a number: the higher the number, the higher the terrain)
Changes in .pgm file
The changes you must make to transform the file from 512 to 1024 are the following:
Change the header dimensions: from 512 512 to 1024 1024
Put in 512 numbers (mostly zero, some ones and twos to keep track of things) after the 512 lines
Put in 512 extra lines of 1024 numbers (mostly zero, some ones and twos to keep track of things)
Save the new file under another name
Resize of texture-masks
When the heightmap changed from 512 to 1024, the manual texture masks (i.e. the textures that are not automatically generated but are painted manually with the layerpainter) must also change from 512 to 1024.
Start the Editor / Load mp_infect / In the ToolBar: Click Terrain / For all textures that are not generated automatically do the following:
Select the texture from the list / Click ‘Export Mask’ (located under Preview-Layer mask) / Choose a name / Save (the saved files are .bmp formats)
For all saved texture masks the same transformation must be made, as sketched at the heightmap. The difference is that the texture masks has .bmp format (they have a size of 49 MB for a texture of 4096×4096). I did the transformation with Paintshop Pro (select/copy and paste). Warning: you must be very accurate with this copy-paste-thing!
NB. Because the .bmp files are so large, you can have problems with copy&paste in Paintshop Pro: it gave me sometimes a not-enough-memory error, while my computer has 1 GB ram. Possible solution is to divide the picture in 2 and do 2 copy-pastes
Step 5: Import all the stuff into mp_new
Start the Editor. Load mp_new
Take your paper where you wrote down the stuff at step 3.
Environment
In the RollupBar: Choose Terrain / Click Environment / Input the stuff you wrote down / Hit apply.
Lighting
In the ToolBar: Click Lighting / Input the stuff you wrote down. / Hit ok.
NB. Don’t forget to change the Sky Color and Sun Color.
Libraries
Open the Database view (e.g. by selecting it under the menu Window). Open the libraries you wrote down.
Holes
If you made holes in the terrain: remake them again.
Automatic import
Heightmap
In the ToolBar: Click Terrain / Choose File-menu / Choose Import Heightmap / Select your saved heightmap and open it
Layers
In the RollupBar: Choose Layers Settings / Click the open folder button / Select your saved layers and open it
Note: if you do not import layers, then the imported objects are all going to be in the Main-layer.
Objects
Choose menu Modify / Click Load Object(s) / Select your saved objects and open it.
Vegetation
In the RollupBar: Choose Terrain / Click the open folder button / Select your saved vegetation and open it
Textures
In the ToolBar: Click Texture / Choose File-menu / Choose Import Layers / Select your saved textures and open it
Texture masks for manual textures
If you resized your manual texture masks in step 5 then: In the ToolBar: Click Terrain / For all manual textures that are resized do the following:
Select the texture from the list / Click ‘Import Mask’ (located under Preview-Layer mask) / Select your resized mask / Open it
Save your map / Generate surface texture / Export to engine / Exit the Edito
You should have now a first new version of your map that is not infected. Check if the steps you took were all succesfull (like objects etc).
Step 6: Finishing touches
Start the Editor. Load mp_new
Manual texture masks
When you resized your manual texture masks, pay special attention to these textures. The result can be slightly different from the original, because they are less accurate (e.g. you use the same texture dimension –e.g. 2048 or 4096- for an area that is twice as big). I did a sharpening of the masks in Paintshop Pro, because the resulted values after copy/paste where slightly less then the original. I also tweaked these textures by using the Layer painter in the Editor.
Holes: if your mp_infect had holes in the terrain then remake the holes again.
Lightmap: if you made a lightmap in mp_new then make this lightmap again (remember that you wrote down the lightmap-settings in step 3).
Save / Export to engine / Exit the Editor.
Test if your mp_new is infected (see step 1). It should NOT be infected!!
If you succeed then first of all congratulations!!! You can of course move mp_infect to some backup-directory and rename mp_new to your liking. Remember that the described method is based on one succesfull attempt to get rid of the lagcycle-bug. Therefor at the start of this manual, I gave no garantee for success. But… I surely hope you made it!! Comments are welcome!