Skip to content
Permalink
Browse files

Add netgameinfo and fix bugs related.

  • Loading branch information
roncli committed Jul 7, 2015
1 parent 2cbe779 commit f49cce6da5b6935210e8c27576941e6da9338184
Showing with 29 additions and 20 deletions.
  1. +9 −10 README.md
  2. +19 −9 index.js
  3. +1 −1 package.json
@@ -146,18 +146,8 @@ The instantiated console object is an `EventEmitter`, and will emit events when

`say (player, text)` - Someone said something. `player` is who said it, and `text` was what they said.

`setgaollimit (goalLimit)` - The goal limit was just set. `goalLimit` is the number of points required to end the level, or null if the goal limit is disabled.

`setmaxplayers (maxPlayers)` - The maximum number of players was just set. `maxPlayers` is the maximum number of players allowed in the game, including the server.

`setpps (maxPps)` - The maximum PPS of the game was just set. `maxPps` is the maximum PPS allowed by the server.

`setrespawntime (respawntime)` - The weapon respawn time was just set. `respawntime` is the weapon respawn time in seconds.

`setteamname` (fromTeam, toTeam)` - A team name was changed. `fromTeam` is the team's old name, and `toTeam` is the team's new name.
`settimelimit (timeLimit)` - The time limit was just set. `timeLimit` is the time in minutes before the level ends, or null if the time limit is disabled.
`setwait (time)` - The server will make clients wait in place for a set time before playing. `time` is the amount of time in seconds after the level begins before players will be able to play.
`shutdown` - The server is shutting down.
@@ -268,6 +258,8 @@ Note that all instance methods return nothing. Any output from these methods is
`d3console.killMsgFilter(killMsgFilter)` - Changes the setting for the kill message filter. `killMsgFilter` is either "none", "simple", or "full".
`d3console.netgameInfo()` - Gets general game information.
`d3console.playerInfo(playerNum)` - Gets player information for a player. `playerNum` is a player number. You can get a player's number using the `d3console.players()` command.
`d3console.players()` - Gets the list of players.
@@ -320,6 +312,13 @@ Note that all instance methods return nothing. Any output from these methods is
## History
### Version 0.1.5 - 7/7/2015
* Added `netgameinfo` method.
* Fixed a bug with the `safeexec` RegExp extension.
* Fixed a bug with `timeLimit` detection.
* Removed `setgaollimit`, `setmaxplayers`, `setpps`, `setrespawntime`, and `settimelimit` events in favor of `gameinfo` events.
### Version 0.1.4 - 7/6/2015
* Fixed a bug with trying to close a console that's not connected.
@@ -11,7 +11,11 @@ RegExp.prototype.safeexec = function(string) {

if (result) {
result.forEach(function(item, index) {
result[index] = item.split("").join("");
if (item) {
result[index] = item.split("").join("");
} else {
result[index] = undefined;
}
});
}

@@ -114,7 +118,7 @@ Console.prototype.connect = function() {
}

// Lines to ignore.
if (route(line, /^(?:NetGame Information|PNum Name|Packet Loss: N\/A|Mission over\. {2}Looping back to first level in mission file\.|Opening level .*\.\.\.|Downloading mission data\.\.\..* level [1-9][0-9]* [0-9]+ Percent Complete|Analyzing data\.\.\..* level [1-9][0-9]* [0-9]+ Percent Complete|\x08+|Input Command List:|Prefix a '\$' before the commands listed below. {2}To get more detailed help|about a command, type '\$help <command>'|allowteamchange +autobalance|autosavedisconnect +autosavelevel|balance +ban|banlist +changeteam|endlevel +help|hudnames +kick|killmsgfilter +netgameinfo|observer +piggyback|playerinfo +players|rehash +remote|remoteadmin +remoteadminlogout|remoteadminpass +removeban|savestats +scores|serverhudnames +setgoallimit|setmaxplayers +setpps|setrespawntime +setteamname|settimelimit +statmsgs|team +wait|warp +|quit|allowteamchange:|\[(?:Dedicated )?(?:Server|Client) Only\]|Turns off\/on allowing clients to change their team\.|Usage: "\$allowteamchange <off\/on>"|autobalance:|Turns off\/on allowing the automatic team placement of new players by the server\.|Usage: "\$autobalance <off\/on>"|autosavedisconnect:|Enables\/Disables the automatic saving of the game stats if you disconnect from the server\.|Usage: "\$autosavedisconnect <on\/off>"|autosavelevel:|Enables\/Disables the automatic saving of the game stats when the level ends\.|Usage: "\$autosavelevel <on\/off>"|balance:|Automatically balances the teams, based on senority\.|Usage: "\$balance"|\*Balancing Teams|\*Ending the level|ban:|Bans a player from the game\.|Usage: "\$ban <pnum>"|Banning .*|banlist:|Lists the players banned from the game along with their ban number, which can be used to remove the ban\.|Usage: "\$banlist"|changeteam:|Forces a player to a team\.|Usage: "\$changeteam <pnum> <team_name>"|\*Attempting to change .* to .* team|endlevel:|Ends the level\.|Usage: "\$endlevel"|help:|Displays help information for the input commands.|Usage: "\$help \[command\]"|hudnames:|Sets your personal level for the HUD name filter\.|Usage: "\$hudnames <full\/team\/none>"|NOTE: You can only set your HUD Callsign level up to the level that the server is\. {2}So if the server is only allowing up to teammates, you won't be able to set to full|\*Personal HUD Name Level: .*|kick:|Kicks a player from the game\.|Usage: "\$kick <pnum>"|killmsgfilter:|Sets the kill message filter, for what style of messages you want\.|Usage: "\$killmsgfilter <full\/simple\/none>"|netgameinfo:?|observer:|If you pass specify 'on', it puts you into observer mode, else it will return you back to normal mode\.|Usage: "\$observer <on\/off>"|piggyback:|Puts you into Piggyback Observer mode."\$piggyback <pnum>"|playerinfo:|Displays information about a player\.|Usage: "\$playerinfo <pnum>"|\*Getting Playerinfo for .*|players:|Displays a list of the players in the game, with their player numbers\.|Usage: "\$players"|rehash:|Rehashes the hosts\.allow and hosts\.deny files\. {2}First it flushes the old, and reloads them\.|Usages: "\$rehash"|remote:|handles a remote admin command|Usage: "\$remote <command> <option parms> <\.\.\.>"|remoteadmin:|handles enable\/disable remote administration|Usage: "\$remoteadmin <on\/off>"{2}|remoteadminlogout:|handles seeing who is logged in, and allows the server to log them out|If no parameter is given it lists all the players logged in\.|To log out a player give the login-id as a parameter|Usage: "\$remoteadminlogout \[login-id\]"|remoteadminpass:|handles setting\/changing the remote administration password|Usage: "\$remoteadminpass <password>"|removeban:|Removes a ban from a player, given the number associated with them from \$banlist\.|Usage: "\$removeban <player>"|\*Ban Removed|\*Couldn't remove ban|savestats:|Saves the game stats to file immediatly\.|Usage: "\$savestats"|scores:|Displays the scores or stats of the game\.|Usage: "\$scores"|Pilot +(?:Points|Score) +K(?:ills)? +D(?:eaths)? +S(?:uicides)? +Ping *|Pilot +Points BlKillDeaSuicidPing *|serverhudnames:|Sets the highest HUD name filter permitted for the clients\.|Usage: "\$serverhudnames <full\/team\/none>"|setgoallimit:|Changes the goal limit for the level\.|Usage: "\$setgoallimit <points>"|setmaxplayers:|Sets the maximum number of players allowed in the game\.|Usage: "\$setmaxplayers <count>"|setpps:|Changes the Packets Per Second \(PPS\) threshold of the game|Usage: "\$setpps <pps>"|setrespawntime:|Changes the respawn time of the powerups in the level\.|Usage: "\$setrespawntime <seconds>"|setteamname:|Changes the name of a team\.|Usage: "\$setteamname <team_num> <new_team_name>"|settimelimit:|Changes the time limit for the level\.|Usage: "\$settimelimit <minutes>"|statmsgs:|Enables\/Disables random statistical messages\.|Usage: "\$statmsgs <on\/off>"|team:|Change teams for yourself\.|Usage: "\$team <team_name>"|wait:|handles a request to make all clients wait\/or stop waiting\. {2}If a time is giving, the server will wait that long each level until it lets clients to play\.|Usage: "\$wait <on\/off or time-in-seconds>"|warp:|Changes the current level to another level in the mission\.|Usage: "\$warp <level>")$/, function() {
if (route(line, /^(?:NetGame Information|PNum Name|Packet Loss: N\/A|Mission over\. {2}Looping back to first level in mission file\.|Opening level .*\.\.\.|Downloading mission data\.\.\..* level [1-9][0-9]* [0-9]+ Percent Complete|Analyzing data\.\.\..* level [1-9][0-9]* [0-9]+ Percent Complete|\x08+|Input Command List:|Prefix a '\$' before the commands listed below. {2}To get more detailed help|about a command, type '\$help <command>'|allowteamchange +autobalance|autosavedisconnect +autosavelevel|balance +ban|banlist +changeteam|endlevel +help|hudnames +kick|killmsgfilter +netgameinfo|observer +piggyback|playerinfo +players|rehash +remote|remoteadmin +remoteadminlogout|remoteadminpass +removeban|savestats +scores|serverhudnames +setgoallimit|setmaxplayers +setpps|setrespawntime +setteamname|settimelimit +statmsgs|team +wait|warp +|quit|allowteamchange:|\[(?:Dedicated )?(?:Server|Client) Only\]|Turns off\/on allowing clients to change their team\.|Usage: "\$allowteamchange <off\/on>"|autobalance:|Turns off\/on allowing the automatic team placement of new players by the server\.|Usage: "\$autobalance <off\/on>"|autosavedisconnect:|Enables\/Disables the automatic saving of the game stats if you disconnect from the server\.|Usage: "\$autosavedisconnect <on\/off>"|autosavelevel:|Enables\/Disables the automatic saving of the game stats when the level ends\.|Usage: "\$autosavelevel <on\/off>"|balance:|Automatically balances the teams, based on senority\.|Usage: "\$balance"|\*Balancing Teams|\*Ending the level|ban:|Bans a player from the game\.|Usage: "\$ban <pnum>"|Banning .*|banlist:|Lists the players banned from the game along with their ban number, which can be used to remove the ban\.|Usage: "\$banlist"|changeteam:|Forces a player to a team\.|Usage: "\$changeteam <pnum> <team_name>"|\*Attempting to change .* to .* team|endlevel:|Ends the level\.|Usage: "\$endlevel"|help:|Displays help information for the input commands.|Usage: "\$help \[command\]"|hudnames:|Sets your personal level for the HUD name filter\.|Usage: "\$hudnames <full\/team\/none>"|NOTE: You can only set your HUD Callsign level up to the level that the server is\. {2}So if the server is only allowing up to teammates, you won't be able to set to full|\*Personal HUD Name Level: .*|kick:|Kicks a player from the game\.|Usage: "\$kick <pnum>"|killmsgfilter:|Sets the kill message filter, for what style of messages you want\.|Usage: "\$killmsgfilter <full\/simple\/none>"|netgameinfo:?|observer:|If you pass specify 'on', it puts you into observer mode, else it will return you back to normal mode\.|Usage: "\$observer <on\/off>"|piggyback:|Puts you into Piggyback Observer mode."\$piggyback <pnum>"|netgameinfo:?|playerinfo:|Displays information about a player\.|Usage: "\$playerinfo <pnum>"|\*Getting Playerinfo for .*|players:|Displays a list of the players in the game, with their player numbers\.|Usage: "\$players"|rehash:|Rehashes the hosts\.allow and hosts\.deny files\. {2}First it flushes the old, and reloads them\.|Usages: "\$rehash"|remote:|handles a remote admin command|Usage: "\$remote <command> <option parms> <\.\.\.>"|remoteadmin:|handles enable\/disable remote administration|Usage: "\$remoteadmin <on\/off>"{2}|remoteadminlogout:|handles seeing who is logged in, and allows the server to log them out|If no parameter is given it lists all the players logged in\.|To log out a player give the login-id as a parameter|Usage: "\$remoteadminlogout \[login-id\]"|remoteadminpass:|handles setting\/changing the remote administration password|Usage: "\$remoteadminpass <password>"|removeban:|Removes a ban from a player, given the number associated with them from \$banlist\.|Usage: "\$removeban <player>"|\*Ban Removed|\*Couldn't remove ban|savestats:|Saves the game stats to file immediatly\.|Usage: "\$savestats"|scores:|Displays the scores or stats of the game\.|Usage: "\$scores"|Pilot +(?:Points|Score) +K(?:ills)? +D(?:eaths)? +S(?:uicides)? +Ping *|Pilot +Points BlKillDeaSuicidPing *|serverhudnames:|Sets the highest HUD name filter permitted for the clients\.|Usage: "\$serverhudnames <full\/team\/none>"|setgoallimit:|Changes the goal limit for the level\.|Usage: "\$setgoallimit <points>"|setmaxplayers:|Sets the maximum number of players allowed in the game\.|Usage: "\$setmaxplayers <count>"|setpps:|Changes the Packets Per Second \(PPS\) threshold of the game|Usage: "\$setpps <pps>"|setrespawntime:|Changes the respawn time of the powerups in the level\.|Usage: "\$setrespawntime <seconds>"|setteamname:|Changes the name of a team\.|Usage: "\$setteamname <team_num> <new_team_name>"|settimelimit:|Changes the time limit for the level\.|Usage: "\$settimelimit <minutes>"|statmsgs:|Enables\/Disables random statistical messages\.|Usage: "\$statmsgs <on\/off>"|team:|Change teams for yourself\.|Usage: "\$team <team_name>"|wait:|handles a request to make all clients wait\/or stop waiting\. {2}If a time is giving, the server will wait that long each level until it lets clients to play\.|Usage: "\$wait <on\/off or time-in-seconds>"|warp:|Changes the current level to another level in the mission\.|Usage: "\$warp <level>")$/, function() {
return true;
})) {
return;
@@ -461,8 +465,8 @@ Console.prototype.connect = function() {
return;
}

if (route(line, /^Time Limit: (None|([1-9][0-9]*)) minutes?$/, function(timeLimit, minutes) {
d3console.emit("gameinfo", {timeLimit: timeLimit === "None" ? null : +minutes});
if (route(line, /^Time Limit: (None|[1-9][0-9]*)(?: minutes?)?$/, function(timeLimit) {
d3console.emit("gameinfo", {timeLimit: timeLimit === "None" ? null : +timeLimit});
return true;
})) {
return;
@@ -680,31 +684,31 @@ Console.prototype.connect = function() {

// $setgoallimit reply
if (route(line, /^\*Goal Limit: (None|[1-9][0-9]*)$/, function(goalLimit) {
d3console.emit("setgoallimit", goalLimit === "None" ? null : +goalLimit);
d3console.emit("gameinfo", {killGoal: goalLimit === "None" ? null : +goalLimit});
return true;
})) {
return;
}

// $setmaxplayers reply
if (route(line, /^\*Max Players: ([1-9][0-9]*)$/, function(maxPlayers) {
d3console.emit("setmaxplayers", +maxPlayers);
d3console.emit("gameinfo", {maxPlayers: +maxPlayers});
return true;
})) {
return;
}

// $setpps reply
if (route(line, /^\*Max PPS: ([1-9][0-9]*)$/, function(maxPps) {
d3console.emit("setpps", +maxPps);
d3console.emit("gameinfo", {pps: +maxPps});
return true;
})) {
return;
}

// $setrespawntime reply
if (route(line, /^\*Respawn Time: ([1-9][0-9]*)$/, function(respawnTime) {
d3console.emit("setrespawntime", +respawnTime);
d3console.emit("gameinfo", {respawnTime: +respawnTime});
return true;
})) {
return;
@@ -720,7 +724,7 @@ Console.prototype.connect = function() {

// $settimelimit reply
if (route(line, /^\*Time Limit: (Off|[1-9][0-9]*)$/, function(timeLimit) {
d3console.emit("settimelimit", timeLimit === "Off" ? null : +timeLimit);
d3console.emit("gameinfo", {timeLimit: timeLimit === "Off" ? null : +timeLimit});
return true;
})) {
return;
@@ -1311,6 +1315,12 @@ Console.prototype.killMsgFilter = function(killMsgFilter) {
this.send("$killmsgfilter " + killMsgFilter);
};

Console.prototype.netgameInfo = function() {
"use strict";

this.send("$netgameinfo");
};

Console.prototype.playerInfo = function(playerNum) {
"use strict";

@@ -1,6 +1,6 @@
{
"name": "descent3console",
"version": "0.1.4",
"version": "0.1.5",
"description": "A cross-platform, event-driven interface to Descent 3 consoles implemented in node.js.",
"keywords": [
"Descent 3",

0 comments on commit f49cce6

Please sign in to comment.
You can’t perform that action at this time.