diff options
| author | Darkelarious <darkelarious@333networks.com> | 2020-12-29 17:38:39 +0000 |
|---|---|---|
| committer | Darkelarious <darkelarious@333networks.com> | 2020-12-29 17:38:39 +0000 |
| commit | 6c9f14e8d2c10584d59a3c24127d95e447dc9ab0 (patch) | |
| tree | b0ca177ec9bfdc82bf98d0d4f5b3e07882332a78 /common/status.pl | |
| parent | 47b7a453f6d7153077df6e8a534b7a8e2c7d9e11 (diff) | |
| download | Simulation-Tools-6c9f14e8d2c10584d59a3c24127d95e447dc9ab0.tar.gz Simulation-Tools-6c9f14e8d2c10584d59a3c24127d95e447dc9ab0.zip | |
gameserver simulation tool
Diffstat (limited to 'common/status.pl')
| -rwxr-xr-x | common/status.pl | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/common/status.pl b/common/status.pl new file mode 100755 index 0000000..4e9ad28 --- /dev/null +++ b/common/status.pl @@ -0,0 +1,140 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Switch; + +# query id counter +my $qid = 0; + +# status information +my %basic = ( + gamename => "ut", + gamever => 451, + location => 0, +); +my %info = ( + hostname => "333networks test server", + hostport => 7777, + maptitle => "333networks", + mapname => "DM-333networks", + gametype => "DeathMatchPlus", + numplayers => 6, + maxplayers => 8, + gamemode => "openplaying", + gamever => 451, + minnetver => 432, + worldlog => "False", +); +my %rules = ( + mutators => "333networks simulated server", + listenserver => "False", + password => "False", + timelimit => 150, + goalteamscore => 0, + minplayers => 0, + changelevels => "True", + balanceteams => "True", + playersbalanceteams => "False", + friendlyfire => "10%", + gamestyle => "Hardcore", + AdminName => "Darkelarious", + AdminEMail => "simulate@333networks.com", +); +my %player = ( + player_ => "Player", + frags_ => 0, + health_ => 100, + deaths_ => 200, + ping_ => 75, + team_ => 1, + mesh_ => "Boss", + skin_ => "SourceSkins.sourceclan", + face_ => "SourceSkins.dark", + ngsecret_ => "True" +); + +# get gamename outside status environment +sub getGameName +{ + return $basic{gamename}; +} + +# parse to gamespy0 format: \key\value +sub getResponse +{ + # what was requested? + my ($key, $value) = @_; + + # count responses + ++$qid; + + # determine response + switch(lc $key) + { + case "basic" + { + my $reply = "\\" . join '\\', %basic; + return "$reply\\queryid\\$qid.3"; + } + + case "info" + { + my $reply = "\\" . join '\\', %info; + return "$reply\\queryid\\$qid.3"; + } + + case "rules" + { + my $reply = "\\" . join '\\', %rules; + return "$reply\\queryid\\$qid.3"; + } + + case "players" + { + my $reply = ""; + for ( 0..$info{numplayers}-1 ) + { + $reply .= "\\player_$_\\" .$player{player_}; + $reply .= "\\frags_$_\\" .$player{frags_}; + $reply .= "\\health_$_\\" .$player{health_}; + $reply .= "\\deaths_$_\\" .$player{deaths_}; + $reply .= "\\ping_$_\\" .int(rand(400)); # random number! + $reply .= "\\team_$_\\" .$player{team_}; + $reply .= "\\mesh_$_\\" .$player{mesh_}; + $reply .= "\\skin_$_\\" .$player{skin_}; + $reply .= "\\face_$_\\" .$player{face_}; + $reply .= "\\ngsecret_$_\\".$player{ngsecret_}; + } + return "$reply\\queryid\\$qid.3"; + } + + case "status" + { + my $reply = ""; + $reply .= "\\" . join '\\', %basic; + $reply .= "\\" . join '\\', %info; + $reply .= "\\" . join '\\', %rules; + for ( 0..$info{numplayers}-1 ) + { + $reply .= "\\player_$_\\" .$player{player_}; + $reply .= "\\frags_$_\\" .$player{frags_}; + $reply .= "\\health_$_\\" .$player{health_}; + $reply .= "\\deaths_$_\\" .$player{deaths_}; + $reply .= "\\ping_$_\\" .int(rand(400)); # random number! + $reply .= "\\team_$_\\" .$player{team_}; + $reply .= "\\mesh_$_\\" .$player{mesh_}; + $reply .= "\\skin_$_\\" .$player{skin_}; + $reply .= "\\face_$_\\" .$player{face_}; + $reply .= "\\ngsecret_$_\\".$player{ngsecret_}; + } + return "$reply\\queryid\\$qid.3"; + + } + + else # echo and others + { + return "\\echo_reply\\$value"; + } + } +} |
