Permalink
Browse files

Fixes HTML entities in names, fixes movement being broken and adds ni…

…ckname insensitive checking.
  • Loading branch information...
1 parent e75b2e7 commit abaa79983122796106f06cf61254806302676745 @Overv committed Dec 30, 2011
Showing with 12 additions and 9 deletions.
  1. +5 −4 js/network.js
  2. +2 −0 js/render.js
  3. +5 −5 multiplayer.html
View
@@ -409,10 +409,11 @@ Server.prototype.onNickname = function( socket, data )
{
var nickname = s.sanitiseInput( data.nickname );
- if ( s.activeNicknames[nickname] )
- {
- s.kick( socket, "That username is already in use!" );
- return;
+ for ( var n in s.activeNicknames ) {
+ if ( n.toLowerCase() == nickname.toLowerCase() ) {
+ s.kick( socket, "That username is already in use!" );
+ return;
+ }
}
if ( s.log ) s.log( "Client " + socket.handshake.address.address + " is now known as " + nickname + "." );
View
@@ -216,6 +216,8 @@ Renderer.prototype.buildPlayerName = function( nickname )
var canvas = this.textCanvas;
var ctx = this.textContext;
+ nickname = nickname.replace( /&lt;/g, "<" ).replace( /&gt;/g, ">" ).replace( /&quot;/, "\"" );
+
var w = ctx.measureText( nickname ).width + 16;
var h = 45;
View
@@ -166,20 +166,20 @@
page.chatboxEntry.style.visibility = null;
// Render loop
- var lastUpdate = +new Date();
+ var lastUpdate = +new Date() / 1000.0;
setInterval( function()
{
var time = +new Date() / 1000.0;
// Update local player
+ player.update();
+
+ // Update networked player
if ( time - lastUpdate > 0.033 ) {
- player.update();
+ client.updatePlayer();
lastUpdate = time;
}
- // Update networked player
- client.updatePlayer();
-
// Build chunks
render.buildChunks( 5 );

0 comments on commit abaa799

Please sign in to comment.