Go Back   Wiremod Forums > Wiremod Adv. Skills > Wiremod Lua Coding

Reply
 
LinkBack Thread Tools Display Modes
Old 10-10-2008   #1 (permalink)
COMPLETE BLOODY BASTARD

 
AzraelUK's Avatar
 

Join Date: Aug 2007
Location: Camelot, it is a silly place.
Posts: 583
AzraelUK is on a distinguished road
Send a message via MSN to AzraelUK
Post Console Screen server-client communication is extremely inefficient.

Let's look at one function here, shall we?
Code:
function ENT:SendPixel()
	if (self.Clk >= 1) && (self.CharX >= 0) && (self.CharX < 30) &&
			      (self.CharY >= 0) && (self.CharY < 18) then
		local address = math.floor(self.CharY)*30+math.floor(self.CharX)
		self.Memory[address*2] = self.Char

		local rp = RecipientFilter()
		rp:AddAllPlayers()

		umsg.Start("consolescreen_datamessage", rp)
			umsg.Long(self:EntIndex())
			umsg.Long(self.Clk)
			umsg.Long(1)
			umsg.Long(address*2)
			umsg.Float(self.Char)
		umsg.End()

		self.Memory[address*2+1] = self.CharParam

		local rp = RecipientFilter()
		rp:AddAllPlayers()

		umsg.Start("consolescreen_datamessage", rp)
			umsg.Long(self:EntIndex())
			umsg.Long(self.Clk)
			umsg.Long(1)
			umsg.Long(address*2+1)
			umsg.Float(self.CharParam)
		umsg.End()
	end
end
  • Don't send two usermessages when your usermessage structure allows you to send the data in one. (The 'umsg.Long(1)' is how many datamessages are in the usermessage.)
  • Don't use Long() with the entity index, use Entity() with the entity itself.
  • Don't use Long() for booleans, use Bool()
  • Don't use Long() for addresses unless they can get really big -- Short() can go up to 32767.
__________________
A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away.
—Antoine De Saint-Exupery
AzraelUK is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Old 10-10-2008   #2 (permalink)
Wire Guru

 
Black Phoenix's Avatar
 

Join Date: Feb 2007
Location: Kyiv, Ukraine
Posts: 2,203
Black Phoenix will become famous soon enough
Send a message via ICQ to Black Phoenix Send a message via MSN to Black Phoenix Send a message via Yahoo to Black Phoenix
Default Re: Console Screen server-client communication is extremely inefficient.

1) That function get's called rare enough
2) Highspeed link interface uses caching
3) It's a long value, not bool. They can get really big. Entity is 100% same as entity index, I like it more this way

Long value - it's size of cache, 1. Console screen uses ugly caching, because data that gets written to it is usually terribly sequenced anyway

You see, saving 2 bytes when this gets used only max 20 times a second is not nice. Even more, saving 2 bytes in 254 vs 256 bytes is not nice too.

I'll stick those two usermessages in one later, it's code from long time ago before caching was there
__________________
I'm a wire-crazy person with a tail.

Take a daily journey into my brain

D2K5


Last edited by Black Phoenix; 10-10-2008 at 05:53 AM..
Black Phoenix is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-10-2008   #3 (permalink)
COMPLETE BLOODY BASTARD

 
AzraelUK's Avatar
 

Join Date: Aug 2007
Location: Camelot, it is a silly place.
Posts: 583
AzraelUK is on a distinguished road
Send a message via MSN to AzraelUK
Default Re: Console Screen server-client communication is extremely inefficient.

It wasn't how the function was doing it that was my complaint, it was the usermessage format in general.

Also, get rid of caching in singleplayer plzplzplz?
__________________
A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away.
—Antoine De Saint-Exupery
AzraelUK is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-11-2008   #4 (permalink)
Wire Guru

 
Black Phoenix's Avatar
 

Join Date: Feb 2007
Location: Kyiv, Ukraine
Posts: 2,203
Black Phoenix will become famous soon enough
Send a message via ICQ to Black Phoenix Send a message via MSN to Black Phoenix Send a message via Yahoo to Black Phoenix
Default Re: Console Screen server-client communication is extremely inefficient.

Quote:
Originally Posted by AzraelUK View Post
It wasn't how the function was doing it that was my complaint, it was the usermessage format in general.

Also, get rid of caching in singleplayer plzplzplz?
Can't, the limit is 100% same for singleplayer, if you try sending a lot of info it will drop its legs at the same rate as MP
__________________
I'm a wire-crazy person with a tail.

Take a daily journey into my brain

D2K5

Black Phoenix is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -7. The time now is 12:33 AM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.

Page top