Log Viewer Source Code

From WinBolo

Jump to: navigation, search

It is available under the GNU GPL version 2 and available to download via Google code.

The Log Viewer application can be found under the winbolo/src/logviewer folder.



  • Direct X 5
  • Windows MM Libraries (included in windows)
  • Winsock 2 (used for DNS lookups)


Add all files from the src/logviewer and src/zlib directory to a windows application project. Add DirectDraw, DirectSound, Windows mulitmedia and winsock libraries to the project.


The Log viewer application shares the same design principle of WinBolo (as well as a lot of code) The application is split into two parts:

  • Backend - Manages the game world and processing the Log Files
  • Frontend - User interface and provides function callbacks for drawing and playing sound.

The backend is not thread safe and calls to the backend functions must be mutex locked.


The backend is accessed through screen.c. Functions provided by this file are:

Log file functions:

screenLoadMap() - Loads a log file
screenCloseLog() - Closes a log file
screenFastForward() - Fast forward 
screenRewind() - Rewind back to previous snapshot
screenLogTick() - Advance one game tick

Drawing functions:

screenUpdate()- Refresh the main screen or move the screens map position
screenRequestUpdate() - Called periodically (once a second) updating item window status
screenSetSizeX() - Number of map squares wide of data requested by screenUpdate()
screenSetSizeY() - Number of map squares wide of data requested by screenUpdate()

Misc functions:

screenGetTime() - Gets the current game time formated as a MM:SS string
screenTankCentred() - Keep centred on the tank
screenSaveMap() - Saves the map file at the current state

Front End

The following functions must be provided by the front end as they are called back by the backend as part of various requests.

windowRemoveEvents() - Remove events in the game messages window. May be called by rewind.

main.c provide the entry point to the application.


The most interesting part of this code is the blocks.c file which is part of the backend.

Logs are read sequentially from the zip file. zlib does not provide a function for unreading data or moving backwards through the file. Every time a log file is moved back a snapshot the zip file needed to be closed then reopened and the file reread to the log file position.

blocks.c abstracts away access to zip file. It provides a linked list of memory each 512K in size. As the zip file is read it is cached into the memory blocks until the maximum cache memory is used up. At this point it starts deleting blocks as far as away from the current file position. If rewind it first tries to retrieve the data from the cached memory. If it is too far from the current position the cache is destroyed and the zip file reload process must occur. The cache starts building from that point.

blocks.c also XOR's the data before returning it ready for processing.

Personal tools