Mirage Source

Free ORPG making software.
It is currently Tue Apr 23, 2024 12:16 pm

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: VB.Net
PostPosted: Mon Apr 13, 2009 10:49 pm 
I've started to convert my source to VB.Net and I've hit a snag.

With the byte array packet system Dugor designed, he uses a function called "GetAddress" and then calls it with the addressof for each sub that handles a packet.

In VB6, this is a perfect method to use. In VB.Net, it bitches, saying:

Code:
'AddressOf' expression cannot be converted to 'Long' because 'Long' is not a delegate type.


Here's an example of how AddressOf is used:
Code:
HandleDataSub(modEnumerations.ClientPackets.CGetClasses) = GetAddress(AddressOf HandleGetClasses)


And here's the GetAddress function:

Code:
    Public Function GetAddress(ByVal FunAddr As Long) As Long
        GetAddress = FunAddr
    End Function


Anyone here know anything about VB.Net? I'm using VB2008..

Once I figure this out, I can keep moving, but I'm at a loss.

Thanks guys. :D


Top
  
 
 Post subject: Re: VB.Net
PostPosted: Tue Apr 14, 2009 1:32 am 
Offline
Pro
User avatar

Joined: Mon May 29, 2006 3:26 pm
Posts: 493
Location: São Paulo, Brasil
Google Talk: blackagesbr@gmail.com
I don't know much VB.Net, but I'm good with C#, so what I can see from this:
'AddressOf' expression cannot be converted to 'Long' because 'Long' is not a delegate type.
is:
Vb.Net does not handle function pointers like VB6, probably it is like it's done in C# (since everything is just .Net). Delegate types are probably needed here.
Create a delegate type: "Delegate Sub MyDelSub()"
Then inside the function create an instance of this type : "Dim del As MyDelSub"
Now you can use the AddressOf function: "del = New MyDelSub(AddressOf YOURFUNCTIONNAME)"
Then to invoke, just use the Invoke function xD: "del.Invoke()"

Good luck!

_________________
http://www.blackages.com.br
Image
Dave wrote:
GameBoy wrote:
www.FreeMoney.com
I admit I clicked. I immediately closed upon realizing there was, in fact, no free money.
Robin wrote:
I love you and your computer.Marry me.


Top
 Profile  
 
 Post subject: Re: VB.Net
PostPosted: Tue Apr 14, 2009 1:42 am 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
You are correct!

I just looked into it for him.

Code:
Public Delegate Sub HandleDataDelegate(ByVal Index As Long, ByRef Data() As Byte)


Code:
Public HandleDataSub(ClientPackets.CMSG_COUNT) As HandleDataDelegate


Code:
HandleDataSub(modEnumerations.ClientPackets.CGetClasses) = AddressOf HandleGetClasses


Code:
HandleDataSub(MsgType).Invoke(Index, Buffer.ReadBytes(Buffer.Length - 3))


Top
 Profile  
 
 Post subject: Re: VB.Net
PostPosted: Tue Apr 14, 2009 1:49 am 
Sweet. Two people who kinda know wtf they're talkin' about. :D

Since Jacob is helping me with a lot of this stuff, after I get my source converted to VB.Net, I will be converting whatever version of MS4 is released at that point, as well.

Gotta give back to the community. :D


Top
  
 
 Post subject: Re: VB.Net
PostPosted: Tue Apr 14, 2009 2:07 am 
Offline
Pro
User avatar

Joined: Sun Aug 05, 2007 2:26 pm
Posts: 547
and i will make it 3d!

_________________
GIAKEN wrote:
I think what I see is this happening:

Labmonkey gets mod, everybody loves him, people find out his code sucks, he gets demoted, then banned, then he makes an engine called Chaos Engine.


Top
 Profile  
 
 Post subject: Re: VB.Net
PostPosted: Tue Apr 14, 2009 2:43 am 
Offline
Persistant Poster
User avatar

Joined: Fri Aug 15, 2008 3:11 pm
Posts: 633
Labmonkey wrote:
and i will make it 3d!

and i will use it

_________________
╔╗╔═╦═╦══╦═══╗
║║║║║║║╔╗║╔═╗║
║║║║║║║╚╝║║║║║
║╚╣║║║║╔╗║╚═╝║
╚═╩╩═╩╩╝╚╩═══╝


╔╦═╦╦════╦═══╗
║║║║╠═╗╔═╣╔══╝
║║║║║║║║╚═╗
║║║║║║║║╔═╝
╚═╩═╝╚╝╚╝ ?


Top
 Profile  
 
 Post subject: Re: VB.Net
PostPosted: Wed Apr 15, 2009 12:46 am 
Offline
Persistant Poster
User avatar

Joined: Thu Aug 17, 2006 5:27 pm
Posts: 866
Location: United Kingdom
Wow, Doomy made me chuckle o.0


Top
 Profile  
 
 Post subject: Re: VB.Net
PostPosted: Wed Apr 15, 2009 7:57 am 
Offline
Banned
User avatar

Joined: Mon Jun 05, 2006 9:22 pm
Posts: 394
Location: USA
Can someone explain what the issue was? Why did it have to be delegated? I've used defined functions before as well, so I'm just unsure as to why this one had to be different.


Top
 Profile  
 
 Post subject: Re: VB.Net
PostPosted: Wed Apr 15, 2009 11:01 am 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
The VB6 code was using an array of longs that held the memory address of functions. Then it used CallWindowProc to call the function in the array.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group