VGAP4 programming tips

Tips for writers of VGAP4 utilities

General

VGAP4 is written in a mixture of Visual Basic 5 and PowerBasic. (PowerBasic is a Borland version of Basic which is about 20 times faster than VB, or so they claim.) It comprises a few core programs (master.exe, host.exe and the client, planets4.exe). In fact host.exe is just a pretty GUI shell round v4host.exe, but let's not get into too many details just yet.

Version 3 (VGAP3) had a "simple" data structure where game information was kept in various arrays (some effectively encrypted by being compressed). Utilities, whether Host- or Client-side, had to meddle with the bytes in those directly. People wrote lots of utilities: "simple" ones like wormhole / wraparound ones which teleported ships which reached certain locations (ie, their x,y co-ords were changed); all the way up to extremely complex ones which used hooks in the VGAP3 code to override a normal section of Host code, and replace it with e.g. a different combat engine. This has limitations though. It gets progressively more dificult to support because any Host changes are likely to upset 3rd party programs meddling with the data structure. Also, cheats were continually coming up with ways of hacking things since some of the vital information about ships and bases was held on the players' computers.

So VGAP4 has a different structure. The programs are supported by several DLL's. There is tons more data in a VGAP4 game (for example max 20,000 ships instead of 1000... many more ship  properties etc). The data structure is orders of magnitude more complex and the only way to access it is via DLL's. The VGAP3 structure was unravelled by dedicated fans. VGAP4's is unlikely to be. This means Tim can control access to the databases via the DLL's and ensure no cheating, andthere can be no badly behaved utilities which use brute force to change parameters... which tended to upset other more delicate utilities.

There aren't many DLL's released yet because Tim is still finalising the data structure. However he realises the success of VGAP3 was partly due to the many customisations offered by 3rd party programmers. He realises that writing more DLL's will take the load off him! There are various suggestions floating round for DLL's, but I think the first new ones he'll do are ones which permit people to write AI players by directly moving ships, etc.

One other thing about the data structure. The entire game's Host files are held in a file called gamename.yig. This is actually a Zipped file; whenHost runs, it unzips it into several other files, then repacks it at the end of a Host run.

The first few utilities for VGAP4 were some map utilities (because Tim released an example program with source code showing how to create new map files, it's on his site somewhere) and a couple of scripting programs (Diplomat, Orchestrator, ScriptZ0r) which didn't need to directly manipulate data inside Planets at all.

Links to more info

Tim's page about programming

v4face2.dll interface code for C++ programmers , by Roger Norris. "The title says it all.  If you are interested in using Tim's DLL to pull information directly out of ship packs and race packs, but were scared off by trying to interface with nasty BASIC code (no offense to BASIC guys out there :)  ), this is for you. It's very simple C++ example code."

Diplomat . If anyone wants a copy of the source code I can send it to them (I need to look into GNU licences and stuff). It is written in VB6. It uses the DLL's which pul information from race and ship packs. Perhaps the trickiest thing in Diplomat was figuring out how to call Master and Host sequentially, because in VB, it is very tricky to call external programs. It took me ages to figure out how to force VB to stop and wait for Master to finish before running Host...