Gtest is a command-line interface to the Anet API. It lets you call most of the dp and dpio functions directly. It also has a few commands to support writing test scripts, and rudimentary simulation of a network game's frame update cycle.
Gtest makes a good tool for learning, too, especially if you are willing to refer to the source file, gtest.c, to make up for the poor documentation.
Gtest prints out a usage message if you run it without arguments that lists the commandline options:
Usage: gtest [-N:comm.dll][-B:busy10msec][-P:adrString][-S][-x] [-W:phonenum][-Y:commportnum(0 : com1)][-Z:baudrate][-I:modeministr] [-Kirq:irqnum][-Kport:hexportnum][-Kpulse][-Ktest] Option details: -n:foo.dll Load comm dll foo.dll -b:10 Burn CPU for 10 centisec, then call dpReceive until empty, repeat -p:server Connect to given game server -s Read commands from stdin (needed for win32) -x use dpio, not dp -c don't create dp on startupCopy the transport DLL you want to use to the current directory, then specify it when you start gtest with -N:path, e.g.
gtest -N:wipx2d.dllThe current comm dll's are
If you use a version that was compiled for debugging, it will read gtest.ini on startup.
help: Basic script language commands help: # -- Comment help: help -- Get help help: quit -- terminate program (can give an exit code; default 0) help: remotequit -- tell other players to terminate program help: wait -- Wait until enum or join finishes. help: sleep -- Sleep given number of seconds help: busy -- Be busy given number of 10ms per main loop help: set -- Set var to val; var is theVar or dwUser1 help: show -- Print variable value; var is one of anyGroup,anyPlayer,dwUser1,n_players,n_sessions,theError,theVar,thisGroup, or thisPlayer help: spam -- Send data to node at intervals help: assert -- Compare values and abort if unequal; var is one of anyGroup,anyPlayer,dwUser1,n_players,n_sessions,theError,theVar,thisGroup, or thisPlayer help: dpio commands help: dpio_create -- Load dpio help: dpio_openHdl -- Open a comm handle to a given node help: dpio_closeHdl -- Close a comm handle help: dpio_findTimedOutHost -- Find closed handles help: dpio_setMaxPlayerHdls -- Set maximum handles help: dpio_setHandleOptions -- Set handle options help: dpio_put_reliable -- Send datagram via dpio reliably to given node help: dpio_freeze -- Save dpio to disk [dpio.dat] help: dpio_thaw -- Restore dpio from disk [dpio.dat] help: statinit -- initialize dp statistics help: statprint -- print dp statistics help: startup/shutdown help: enumtransports -- list available transports help: gameservers -- list available game servers help: setGameServer -- connects to a game server help: dpCreate -- load dp help: dpDestroy -- unload dp help: freeze -- freeze the current session and destroy help: thaw -- Restore a dp session from disk help: session mgmt help: species -- Set species used for listing and hosting help: host -- create new session; name [maxpl] [flags] [dwuser1]. help: lobby -- declare the current session to be a server lobby help: join -- join an existing session help: joinany -- join any existing session help: dpClose -- Disconnect from the current session help: sessions -- list available sessions help: sdeltas -- request session deltas; [on|off] help: gdeltas -- request gameserver deltas; [on|off] help: pdeltas -- request player deltas; [on|off] help: dpGetSessionDesc -- get current session description help: player mgmt help: players -- list players in current session help: rplayers -- list players in named session help: xplayers -- list players in current session help: xrplayers -- list players in named session help: newplayer -- create a player in current session help: delplayer -- destroy a player in current session help: setpname -- change the name of the player with the given id help: setpblob -- change the blob of the player with the given id help: group mgmt help: groups -- list groups in current session help: newgroup -- create a group in current session help: delgroup -- destroy a group in current session help: gaddplayer -- add a player to a group help: gdelplayer -- delete a player from a group help: gplayers -- list players in given group help: player variables help: pset -- Set a variable of a player help: fpset -- Set a variable of a player to a given file help: pget -- Get value of a variable of a player help: misc help: ping -- measure round trip lag time to a player help: scap -- Get capabilities of current session. help: enumapp -- list available applications help: patch -- Check whether patch is needed [apply] help: pickapp -- pick an existing application for use with launchapp help: launchapp -- freeze, start the application selected from pickapp, then destroy help: crash -- cause an exception help: sending/receiving datagrams help: send -- send a packet to a given player or group help: chat -- broadcast a chat message
assert n_sessions > 0makes sure at least one session was found. You may use the >, <, ==, and != comparison operators inside assert commands. If the condition does not evaluate to TRUE, the program is aborted with an error message.
C:> gtest -n=wipx2.dll hostand joining it from another machine as follows:
C:> gtest -n=wipx2.dll sessions join demo newplayer JoeWhen the player Joe is created, all other machines in the game will handle the dp_user_addPlayer_packet_t system message, and display a message on the screen.
sessions wait join demo sleep 5 quityou can run it in gtest as follows:
C:> gtest -n=wipx2.dll -s < test.inand it will return to the DOS prompt automatically when it's done.
Scripts are great during debugging because they let you run regression tests. For example, to make sure that at least one game is active on the LAN, you could write a script
sessions wait assert n_sessions > 0 quit
There are example gtest scripts in the demo/gtest directory.