Setting up a Coop or SP Battlefield 2 or 2142 Game on a Multi Core Machine

Table of Contents 


03/05/12 - Guide has been substantially updated. The main change is that the server/client communication can be run through localhost ( which massively improves the local ping to what it should be. Connecting to a LAN address (192.168.x.x) was introducing effects that are normally seen on the internet ... delayed hit detection, jumpy location detection of soldiers and vehicles (they start "skipping" ahead and jumping around) and so on. Obviously we don't want this for a local game with bots ! However Coop is another story. In Coop a few players could have a lot of fun playing with so many bots as well. Sometimes not everyone can get together a huge group of friends ... so why not just two or three players ? Imagine a stand off between you and your friend playing as the commander on each side ... like a huge game of chess with the bots as the pawns ;). So my priority has been getting a single player game going first which is optimised. When I have that going I'll move up to testing a LAN Coop game.

Battlefield 2 and 2142

1. You will need 2 or more cores or CPU's.

2. In <battlefield 2 directory>\mods\fh2\settings\ create the file maplist.con with the following content.

mapList.append crete_1941 gpm_coop 64

Change the map name and size (16/32/64) to set different maps.

3. In <battlefield 2 directory>\mods\fh2\settings\ create the file serverSettings.con with the following content. I've tried to include other settings that might be required ... for VOIP between Coop players for example. But I don't require those kind of settings so you'll have to research elsewhere if you want to set those up fully.

sv.serverName "Phorce Coop/SP"
sv.password ""
sv.internet 0
sv.serverIP "" [Note: BF2 can be run through the loopback device which improves performance for the local client/server. However a LAN game would need to be on a LAN address such as 192.168.x.x. I have found that for some reason this introduces very bad network performance. This could simply be a network problem with my machine. I'm looking into this. BTW don't include this line in your server settings file !]
sv.serverPort 16567
sv.welcomeMessage "Welcome to Phorce Server"
sv.punkBuster 0
sv.allowFreeCam 1
sv.allowExternalViews 1
sv.allowNoseCam 1
sv.hitIndicator 1
sv.autoBalanceTeam 1
sv.teamRatioPercent 100
sv.coopBotRatio 100
sv.coopBotCount 53
sv.maxPlayers 1
sv.numPlayersNeededToStart 1
sv.notEnoughPlayersRestartDelay 15
sv.startDelay 15
sv.endDelay 15
sv.endOfRoundDelay 15
sv.roundsPerMap 1
sv.timeLimit 0
sv.scoreLimit 0
sv.soldierFriendlyFire 100
sv.vehicleFriendlyFire 100
sv.soldierSplashFriendlyFire 100
sv.vehicleSplashFriendlyFire 100
sv.tkPunishEnabled 0
sv.tkNumPunishToKick 3
sv.tkPunishByDefault 0
sv.votingEnabled 0
sv.voteTime 90
sv.minPlayersForVoting 2
sv.teamVoteOnly 0
sv.gameSpyPort 29900
sv.allowNATNegotiation 1
sv.autoRecord 0
sv.demoIndexURL ""
sv.demoDownloadURL "http://"
sv.autoDemoHook "adminutils/demo/rotate_demo.exe"
sv.demoQuality 1
sv.adminScript "modmanager"
sv.timeBeforeRestartMap 30
sv.coopBotDifficulty 50
sv.voipEnabled 0
sv.voipQuality 3
sv.voipServerRemote 0
sv.voipServerPort 55125
sv.voipBFClientPort 55123
sv.voipBFServerPort 55124
sv.useGlobalRank 0
sv.useGlobalUnlocks 1
sv.noVehicles 0
sv.sponsorText ""
sv.sponsorLogoURL ""
sv.communityLogoURL ""
sv.radioSpamInterval 6
sv.radioMaxSpamFlagCount 6
sv.radioBlockedDurationTime 30
sv.numReservedSlots 0
sv.friendlyFireWithMines 0

Alter as necessary. For example the IP will need changing.

The core of the settings here is this ...

sv.teamRatioPercent 100
sv.coopBotRatio 100
sv.coopBotCount 53

On my machine in <battlefield 2 directory>\mods\fh2\ai\ I have bots set to 108. sv.coopBotCount is set to half of the bots for a game with 50/50 split of bots between the teams. So on my machine it is set to 53. This may need to be adjusted depending on how you have your single player or coop game set up (to take into account other human players as well).

You may notice that there has been no mention of ticket numbers. This is set in <battlefield 2 directory>\mods\fh2\gamelogicinit.con ...

gameLogic.setDefaultNumberOfTickets 1 250
gameLogic.setDefaultNumberOfTickets 2 250

4. Create shortcuts ...

"C:\Program Files\Battlefield_2_141\bf2_w32ded.exe" +modPath mods/fh2

"C:\Program Files\Battlefield_2_141\FH2.exe" +fullscreen 1 +widescreen 0 +szx 1440 +szy 900 +joinServer +port 16567

Adjust as necessary - you might not need the widescreen options. Notice the +joinServer This will enable BF2 to load straight into the server running on your local host. For FH2, BF2 will load. Login as normal. When the menu loads you should hear the music fading and whatever level you set up on the server will start to load. Note that (at least on my machine) manually joining a local host server ( in the BF2 server browser menu will NOT work. It is possible to manually join server's on other IP's (192.168.x.x, etc) but for some reason BF2 is awkward about joining the localhost loopback address. The only way that I have found to do it is with "+joinServer".

5. Set CPU or core affinity to have the server (bf2_w32ded.exe) and Battlefield 2 (bf2.exe) on separate cores or CPU's.

6. Start the server with the shortcuts created in step 4. A dos window will open. You should see gametype as gpm_coop and maybe a message about bot settings if you are still have that comment in your You should see the server IP address and the map name. If not then go back and check you have followed the steps properly.

7. Start Battlefield 2 for Forgotten Hope in the usual way. If you are using a LAN address then join the game in the server browser ... Multiplayer --> Join Local. If you are using localhost and have set it up correctly then the map will load automatically. Have fun !

UPDATE: A note really. Large bot numbers and large map size can lead to a crash on low memory systems. sv.maxPlayers should match what is set in aidefault.con ... Another note. When logged into an online account choosing "join server IP" and entering WILL join the server (but clicking on the entry in the listing won't). This may need the server interface IP to be set the same as the server IP.

YES ! Server IP and server interface must be set the same THEN you can join by selecting "Connect to IP", but you MUST be using an ONLINE account.


UPDATE: I have been watching CPU usage in the task manager. Both the server and client appear to use ALL the cores they are given. So in Affinity II make sure "auto set" is on and give multiple cores to both server and client. ALSO sv.maxPlayers must be set to match the number of bots set in aidefault.con. That seems to improve the AI performance (the bots don't start jumping around or lagging). I suspect the server was porting all the 128 bots through a tiny little slot ... I had it set to one !

SO ! I managed to get the 2142 server and client running on separate cores with 128 bots. On a single core the client, started as a coop server, runs at 15-39 FPS (fraps). With multicore affinity set using seperate server and client on separate cores, the client stays at 60fps (vsync) ! So this definitely works. Games are MUCH more fierce and impressive and there may be some evidence of not just improved performance but improved LOGIC of the bots as the engine is not having to scale their behaviour down so much to compensate for lack of CPU power. DICE have definitely confirmed before that this is what their engine does, so bots are less likely to follow paths properly and so forth with lack of CPU power ... but now they can !

BTW the latest server download is 1.50 ... my 2142 was patched to 1.51 but the seeming version mismatch does not seem to make any difference.

My testing revealed that the server has to be an UNRANKED server. I also opened all the ports recommended in the server readme. I'm not absolutely sure if this step is necessary yet so you might want to skip opening a LOT of ports. I had to use this for some of them ...

FOR /L %I IN (1500,1,4999) DO netsh firewall add portopening UDP %I "2142"%I

FOR /L %I IN (1024,1,1124) DO netsh firewall add portopening UDP %I "2142"%I

FOR /L %I IN (1024,1,1124) DO netsh firewall add portopening TCP %I "2142"%I

Anyway, if you get a "Error: You client is older than the server" message and the server line is RED then check and check again (and again) all your settings files AND shortcuts. I found an error ... my client was not set to load the same mod as the server. There is a possibility that this was caused by initially having used a RANKED server (hence references to EA Link?) when it should have been UNRANKED. All the ports may need to be open AND things like Peerguardian turned off (if you are blocking in game advertising) as we are dealing with proprietary code here so EA/DICE could be scanning for anything running in the background that might interfere with their system.

I started using the same maplist and serversettings, as above, but as yet I cannot get 2142 to auto join a locahost server (using +joinServer). As in BF2, 2142 will NOT *manually* (in the server menu) join a locahost ( server. The method that works for bf2 with the shortcut command switch does NOT work. It will join with the IP set to 192.168.x.x but that means that there is some ping lag when there should not be.

Here are the shortcuts that I used ...

"E:\Program Files\Electronic Arts\Battlefield 2142 Server\BF2142_w32ded.exe" +config e:\serverSettings.con +mapList e:\maplist.con +modPath mods/Unlocks_v1.20c

"C:\Program Files\Electronic Arts\Battlefield 2142 Deluxe Edition\BF2142.exe" +menu 1 +fullscreen 1 +widescreen 1 +szx 1440 +szy 900 +port 16567 +modPath mods/Unlocks_v1.20c

Scholarly Lite is a free theme, contributed to the Drupal Community by More than Themes.